2e231861c7594eb74a67b2bc65be67391e13021b
[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         bool _show_master;
64         bool _show_midi;
65
66         Gtk::ScrolledWindow scroller;
67         Gtk::HBox meterarea;
68         Gtk::HBox global_hpacker;
69         Gtk::VBox global_vpacker;
70
71         gint start_updating ();
72         gint stop_updating ();
73
74         sigc::connection fast_screen_update_connection;
75         void fast_update_strips ();
76
77         void add_strips (ARDOUR::RouteList&);
78         void remove_strip (MeterStrip *);
79         void update_metrics ();
80
81         void session_going_away ();
82         void sync_order_keys (ARDOUR::RouteSortOrderKey src);
83         void resync_order ();
84
85         std::list<MeterStrip *> strips;
86
87         MeterStrip metrics_left;
88         MeterStrip metrics_right;
89
90         Gtk::VBox metrics_vpacker_left;
91         Gtk::VBox metrics_vpacker_right;
92         Gtk::HBox metrics_spacer_left;
93         Gtk::HBox metrics_spacer_right;
94
95         static const int32_t default_width = 600;
96         static const int32_t default_height = 400;
97         static const int max_height = 1200; // == 1024 + 148 + 16 + 12 see meter_strip.cc
98         int cur_max_width;
99
100         void update_title ();
101
102         // for restoring window geometry.
103         int m_root_x, m_root_y, m_width, m_height;
104
105         void set_window_pos_and_size ();
106         void get_window_pos_and_size ();
107
108         bool on_key_press_event (GdkEventKey*);
109         bool on_key_release_event (GdkEventKey*);
110
111         void on_size_allocate (Gtk::Allocation&);
112         void on_size_request (Gtk::Requisition*);
113
114         void parameter_changed (std::string const & p);
115 };
116
117 #endif