shared peak-display reset in mixer+meterbridge
[ardour.git] / gtk2_ardour / meterbridge.h
1 /*
2     Copyright (C) 2012 Paul Davis
3     Author: Robin Gareus
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20 #ifndef __ardour_meterbridge_h__
21 #define __ardour_meterbridge_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/scrolledwindow.h>
25 #include <gtkmm/label.h>
26 #include <gtkmm/window.h>
27
28 #include "ardour/ardour.h"
29 #include "ardour/types.h"
30 #include "ardour/session_handle.h"
31
32 #include "pbd/stateful.h"
33 #include "pbd/signals.h"
34
35 #include "gtkmm2ext/visibility_tracker.h"
36
37 #include "meter_strip.h"
38
39 class Meterbridge :
40         public Gtk::Window,
41         public PBD::ScopedConnectionList,
42         public ARDOUR::SessionHandlePtr,
43         public Gtkmm2ext::VisibilityTracker
44 {
45   public:
46         static Meterbridge* instance();
47         ~Meterbridge();
48
49         void set_session (ARDOUR::Session *);
50
51         XMLNode& get_state (void);
52         int set_state (const XMLNode& );
53
54         void show_window ();
55         bool hide_window (GdkEventAny *ev);
56
57   private:
58         Meterbridge ();
59         static Meterbridge* _instance;
60
61         bool _visible;
62         bool _show_busses;
63
64         Gtk::ScrolledWindow scroller;
65         Gtk::HBox meterarea;
66         Gtk::HBox global_hpacker;
67         Gtk::VBox global_vpacker;
68
69         gint start_updating ();
70         gint stop_updating ();
71
72         sigc::connection fast_screen_update_connection;
73         void fast_update_strips ();
74
75         void add_strips (ARDOUR::RouteList&);
76         void remove_strip (MeterStrip *);
77         void update_metrics ();
78
79         void session_going_away ();
80         void sync_order_keys (ARDOUR::RouteSortOrderKey src);
81
82         std::list<MeterStrip *> strips;
83
84         MeterStrip metrics_left;
85         MeterStrip metrics_right;
86
87         Gtk::VBox metrics_vpacker_left;
88         Gtk::VBox metrics_vpacker_right;
89         Gtk::HBox metrics_spacer_left;
90         Gtk::HBox metrics_spacer_right;
91
92         static const int32_t default_width = 600;
93         static const int32_t default_height = 400;
94         static const int max_height = 1200; // == 1024 + 148 + 16 + 12 see meter_strip.cc
95         int cur_max_width;
96
97         void update_title ();
98
99         // for restoring window geometry.
100         int m_root_x, m_root_y, m_width, m_height;
101
102         void set_window_pos_and_size ();
103         void get_window_pos_and_size ();
104
105         bool on_key_press_event (GdkEventKey*);
106         bool on_key_release_event (GdkEventKey*);
107
108         void on_size_allocate (Gtk::Allocation&);
109         void on_size_request (Gtk::Requisition*);
110
111         void parameter_changed (std::string const & p);
112 };
113
114 #endif