namespace and filename cleanup
[ardour.git] / libs / surfaces / faderport / gui.cc
1 /*
2     Copyright (C) 2009-2012 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
20 #include <iostream>
21 #include <list>
22 #include <string>
23
24 #include <gtkmm/comboboxtext.h>
25 #include <gtkmm/label.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/adjustment.h>
28 #include <gtkmm/spinbutton.h>
29 #include <gtkmm/table.h>
30
31 #include "gtkmm2ext/gtk_ui.h"
32 #include "gtkmm2ext/utils.h"
33
34 #include "faderport.h"
35
36 #include "i18n.h"
37
38 namespace ArdourSurface {
39
40 class GMCPGUI : public Gtk::VBox
41 {
42 public:
43         GMCPGUI (FaderPort&);
44         ~GMCPGUI ();
45
46 private:
47         FaderPort& cp;
48         Gtk::ComboBoxText map_combo;
49         Gtk::Adjustment bank_adjustment;
50         Gtk::SpinButton bank_spinner;
51         Gtk::CheckButton motorised_button;
52         Gtk::Adjustment threshold_adjustment;
53         Gtk::SpinButton threshold_spinner;
54
55         void binding_changed ();
56         void bank_changed ();
57         void motorised_changed ();
58         void threshold_changed ();
59 };
60
61 }
62
63 using namespace PBD;
64 using namespace ARDOUR;
65 using namespace ArdourSurface;
66 using namespace std;
67 using namespace Gtk;
68 using namespace Gtkmm2ext;
69
70 void*
71 FaderPort::get_gui () const
72 {
73         if (!gui) {
74                 const_cast<FaderPort*>(this)->build_gui ();
75         }
76         static_cast<Gtk::VBox*>(gui)->show_all();
77         return gui;
78 }
79
80 void
81 FaderPort::tear_down_gui ()
82 {
83         if (gui) {
84                 Gtk::Widget *w = static_cast<Gtk::VBox*>(gui)->get_parent();
85                 if (w) {
86                         w->hide();
87                         delete w;
88                 }
89         }
90         delete (GMCPGUI*) gui;
91         gui = 0;
92 }
93
94 void
95 FaderPort::build_gui ()
96 {
97         gui = (void*) new GMCPGUI (*this);
98 }
99
100 /*--------------------*/
101
102 GMCPGUI::GMCPGUI (FaderPort& p)
103         : cp (p)
104         , bank_adjustment (1, 1, 100, 1, 10)
105         , bank_spinner (bank_adjustment)
106         , motorised_button ("Motorised")
107         , threshold_adjustment (p.threshold(), 1, 127, 1, 10)
108         , threshold_spinner (threshold_adjustment)
109 {
110 }
111
112 GMCPGUI::~GMCPGUI ()
113 {
114 }
115
116 void
117 GMCPGUI::bank_changed ()
118 {
119 //      int new_bank = bank_adjustment.get_value() - 1;
120 //      cp.set_current_bank (new_bank);
121 }
122
123 void
124 GMCPGUI::binding_changed ()
125 {
126 }
127
128 void
129 GMCPGUI::motorised_changed ()
130 {
131 //      cp.set_motorised (motorised_button.get_active ());
132 }
133
134 void
135 GMCPGUI::threshold_changed ()
136 {
137 //      cp.set_threshold (threshold_adjustment.get_value());
138 }