add VCAMasterStrip::set_selected()
[ardour.git] / gtk2_ardour / vca_master_strip.cc
1 /*
2     Copyright (C) 2016 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include "pbd/convert.h"
20
21 #include "ardour/vca.h"
22
23 #include "tooltips.h"
24 #include "vca_master_strip.h"
25
26 #include "i18n.h"
27
28 using namespace ARDOUR;
29 using namespace ARDOUR_UI_UTILS;
30 using namespace Gtkmm2ext;
31 using std::string;
32
33 VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
34         : AxisView (s)
35         , _vca (v)
36         , gain_meter (s, 250)
37 {
38         gain_meter.set_controls (boost::shared_ptr<Route>(),
39                                  boost::shared_ptr<PeakMeter>(),
40                                  boost::shared_ptr<Amp>(),
41                                  _vca->control());
42
43         hide_button.set_icon (ArdourIcon::CloseCross);
44         set_tooltip (&hide_button, _("Hide this VCA strip"));
45
46         width_button.set_icon (ArdourIcon::StripWidth);
47         set_tooltip (width_button, _("Click to toggle the width of this VCA strip."));
48
49         width_button.signal_button_press_event().connect (sigc::mem_fun(*this, &VCAMasterStrip::width_button_pressed), false);
50         hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked));
51
52         width_hide_box.set_spacing (2);
53         width_hide_box.pack_start (width_button, false, true);
54         width_hide_box.pack_start (number_label, true, true);
55         width_hide_box.pack_end (hide_button, false, true);
56
57         number_label.set_text (PBD::to_string (v->number(), std::dec));
58         number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive));
59         number_label.set_no_show_all ();
60         number_label.set_name ("tracknumber label");
61         number_label.set_fixed_colors (0x80808080, 0x80808080);
62         number_label.set_alignment (.5, .5);
63         number_label.set_fallthrough_to_parent (true);
64
65         name_button.set_text (_vca->name());
66         active_button.set_text ("active");
67
68         top_padding.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */
69         bottom_padding.set_size_request (-1, 50); /* this one is a hack. there's no trivial way to compute it */
70
71         global_vpacker.set_border_width (1);
72         global_vpacker.set_spacing (0);
73
74         global_vpacker.pack_start (top_padding, false, false);
75         global_vpacker.pack_start (width_hide_box, false, false);
76         global_vpacker.pack_start (active_button, false, false);
77         global_vpacker.pack_start (name_button, false, false);
78         global_vpacker.pack_start (vertical_padding, true, true);
79         global_vpacker.pack_start (gain_meter, false, false);
80         global_vpacker.pack_start (bottom_padding, false, false);
81
82         global_frame.add (global_vpacker);
83         global_frame.set_shadow_type (Gtk::SHADOW_IN);
84         global_frame.set_name ("BaseFrame");
85
86         add (global_frame);
87
88         global_vpacker.show ();
89         global_frame.show ();
90         top_padding.show ();
91         bottom_padding.show ();
92         vertical_padding.show ();
93         width_hide_box.show_all ();
94         active_button.show_all ();
95         name_button.show_all ();
96         gain_meter.show_all ();
97
98         /* force setting of visible selected status */
99
100         _selected = true;
101         set_selected (false);
102 }
103
104 string
105 VCAMasterStrip::name() const
106 {
107         return _vca->name();
108 }
109
110 void
111 VCAMasterStrip::hide_clicked ()
112 {
113 }
114
115 bool
116 VCAMasterStrip::width_button_pressed (GdkEventButton* ev)
117 {
118         return false;
119 }
120
121 void
122 VCAMasterStrip::set_selected (bool yn)
123 {
124         AxisView::set_selected (yn);
125
126         if (_selected) {
127                 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
128                 global_frame.set_name ("MixerStripSelectedFrame");
129         } else {
130                 global_frame.set_shadow_type (Gtk::SHADOW_IN);
131                 global_frame.set_name ("MixerStripFrame");
132         }
133
134         global_frame.queue_draw ();
135 }
136