Only show user-presets in favorite sidebar
[ardour.git] / gtk2_ardour / meter_strip.h
1 /*
2     Copyright (C) 2013 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_meter_strip__
21 #define __ardour_meter_strip__
22
23 #include <vector>
24 #include <cmath>
25
26 #include <gtkmm/alignment.h>
27 #include <gtkmm/box.h>
28 #include <gtkmm/drawingarea.h>
29 #include <gtkmm/eventbox.h>
30 #include <gtkmm/separator.h>
31
32 #include "pbd/stateful.h"
33
34 #include "ardour/types.h"
35 #include "ardour/ardour.h"
36
37 #include "widgets/ardour_button.h"
38
39 #include "level_meter.h"
40 #include "route_ui.h"
41
42 namespace ARDOUR {
43         class Route;
44         class RouteGroup;
45         class Session;
46 }
47
48 class MeterStrip : public Gtk::VBox, public AxisView, public RouteUI
49 {
50 public:
51         MeterStrip (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>);
52         MeterStrip (int, ARDOUR::MeterType);
53         ~MeterStrip ();
54
55         std::string name() const;
56         Gdk::Color color () const;
57
58         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
59
60         void set_session (ARDOUR::Session* s);
61         void fast_update ();
62         boost::shared_ptr<ARDOUR::Route> route() { return _route; }
63
64         static PBD::Signal1<void,MeterStrip*> CatchDeletion;
65         static PBD::Signal0<void> MetricChanged;
66         static PBD::Signal0<void> ConfigurationChanged;
67
68         void reset_peak_display ();
69         void reset_route_peak_display (ARDOUR::Route*);
70         void reset_group_peak_display (ARDOUR::RouteGroup*);
71
72         void set_meter_type_multi (int, ARDOUR::RouteGroup*, ARDOUR::MeterType);
73
74         void set_metric_mode (int, ARDOUR::MeterType);
75         int  get_metric_mode() { return _metricmode; }
76         void set_tick_bar (int);
77         int  get_tick_bar() { return _tick_bar; }
78         bool has_midi() { return _has_midi; }
79         bool is_metric_display() { return _strip_type == 0; }
80         ARDOUR::MeterType meter_type();
81
82         bool selected() const { return false; }
83
84 protected:
85         boost::shared_ptr<ARDOUR::Route> _route;
86         PBD::ScopedConnectionList meter_route_connections;
87         PBD::ScopedConnectionList level_meter_connection;
88         void self_delete ();
89
90         gint meter_metrics_expose (GdkEventExpose *);
91         gint meter_ticks1_expose (GdkEventExpose *);
92         gint meter_ticks2_expose (GdkEventExpose *);
93
94         void on_theme_changed ();
95
96         void on_size_allocate (Gtk::Allocation&);
97         void on_size_request (Gtk::Requisition*);
98
99         /* route UI */
100         void blink_rec_display (bool onoff);
101         std::string state_id() const;
102         void set_button_names ();
103
104 private:
105         Gtk::VBox mtr_vbox;
106         Gtk::VBox nfo_vbox;
107         Gtk::EventBox mtr_container;
108         Gtk::HSeparator mtr_hsep;
109         Gtk::HBox meterbox;
110         Gtk::HBox spacer;
111         Gtk::HBox namebx;
112         Gtk::VBox namenumberbx;
113         ArdourWidgets::ArdourButton name_label;
114         ArdourWidgets::ArdourButton number_label;
115         Gtk::DrawingArea meter_metric_area;
116         Gtk::DrawingArea meter_ticks1_area;
117         Gtk::DrawingArea meter_ticks2_area;
118
119         Gtk::HBox mutebox;
120         Gtk::HBox solobox;
121         Gtk::HBox recbox;
122         Gtk::HBox mon_in_box;
123         Gtk::HBox mon_disk_box;
124
125         Gtk::Alignment meter_align;
126         Gtk::Alignment peak_align;
127         Gtk::HBox peakbx;
128         Gtk::VBox btnbox;
129         ArdourWidgets::ArdourButton peak_display;
130
131         std::vector<ARDOUR::DataType> _types;
132         ARDOUR::MeterType metric_type;
133
134         float max_peak;
135         bool _has_midi;
136         int _tick_bar;
137         int _strip_type;
138         int _metricmode;
139
140         LevelMeterHBox *level_meter;
141
142         void route_property_changed (const PBD::PropertyChange&);
143         void meter_configuration_changed (ARDOUR::ChanCount);
144         void meter_type_changed (ARDOUR::MeterType);
145         void update_background (ARDOUR::MeterType);
146
147         bool peak_button_release (GdkEventButton*);
148
149         void parameter_changed (std::string const & p);
150         void redraw_metrics ();
151         void update_button_box ();
152         void update_name_box ();
153         void name_changed ();
154
155         void route_color_changed ();
156
157         bool _suspend_menu_callbacks;
158         bool level_meter_button_press (GdkEventButton* ev);
159         void popup_level_meter_menu (GdkEventButton* ev);
160         void add_level_meter_type_item (Gtk::Menu_Helpers::MenuList&, Gtk::RadioMenuItem::Group&, std::string const &, ARDOUR::MeterType);
161
162         bool name_label_button_release (GdkEventButton* ev);
163         void popup_name_label_menu (GdkEventButton* ev);
164         void add_label_height_item (Gtk::Menu_Helpers::MenuList&, Gtk::RadioMenuItem::Group&, std::string const &, uint32_t);
165
166         void set_meter_type (ARDOUR::MeterType mode);
167         void set_label_height (uint32_t);
168 };
169
170 #endif /* __ardour_mixer_strip__ */