Guitarix
gx_main_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * --------------------------------------------------------------------------
19  *
20  * This file is part of the guitarix GUI main class
21  * Note: this header file is the base for gx_main_boxes.h
22  *
23  * ----------------------------------------------------------------------------
24  */
25 
26 /* ------- This is the GUI namespace ------- */
27 
28 #pragma once
29 
30 #ifndef SRC_HEADERS_GX_MAIN_INTERFACE_H_
31 #define SRC_HEADERS_GX_MAIN_INTERFACE_H_
32 
33 #include <gxwmm/bigknob.h>
34 #include <gxwmm/midknob.h>
35 #include <gxwmm/smallknob.h>
36 #include <gxwmm/smallknobr.h>
37 #include <gxwmm/wheel.h>
38 #include <gxwmm/hslider.h>
39 #include <gxwmm/eqslider.h>
40 #include <gxwmm/levelslider.h>
41 #include <gxwmm/minislider.h>
42 #include <gxwmm/switch.h>
43 #include <gxwmm/selector.h>
44 #include <gxwmm/valuedisplay.h>
45 #include <gxwmm/simplevaluedisplay.h>
46 #include <gxwmm/fastmeter.h>
47 #include <gxwmm/tuner.h>
48 #include <gxwmm/racktuner.h>
49 #include <gxwmm/waveview.h>
50 #include <gxwmm/portdisplay.h>
51 #include <gxwmm/playhead.h>
52 #include <gtkmm/box.h>
53 #include <gtkmm/alignment.h>
54 #include <gtkmm/checkmenuitem.h>
55 #include <gtkmm/radiomenuitem.h>
56 #include <gtkmm/builder.h>
57 #include <gtkmm/widgetpath.h>
58 
59 #include <iostream>
60 #include <map>
61 #include <string>
62 #include <vector>
63 
64 namespace gx_gui {
65 
66 /****************************************************************
67  **
68  */
69 
70 class CpBase {
71 public:
72  CpBase();
73  ~CpBase();
74  void init(Gxw::Regler& regler, bool show_value);
75 };
76 
77 class CpBaseCaption: public Gtk::VBox {
78 protected:
80  Gtk::Label m_label;
81 public:
82  CpBaseCaption();
83  ~CpBaseCaption();
84  void init(Gxw::Regler& regler, bool show_value);
85  void set_effect_label(const char *label);
86  void set_rack_label(const char *label);
87  void set_rack_label_inverse(const char *label);
88 };
89 
90 class CpMasterCaption: public Gtk::HBox {
91 protected:
93  Gtk::Label m_label;
94 public:
96  ~CpMasterCaption();
97  void init(Gxw::Regler& regler);
98  void set_label(const char *label);
99 };
100 
101 class CpBaseCaptionBoxed: public Gtk::VBox {
102 protected:
104  Gtk::HBox h_box;
105  Gtk::Label m_label;
106 public:
109  void init(Gxw::Regler& regler, bool show_value);
110  void set_rack_label(const char *label);
111  void set_rack_label_inverse(const char *label);
112 };
113 
114 template <class T>
115 class UiRegler: public T {
116 protected:
118 public:
119  UiRegler(bool show_value = true)
120  : T(), base() { base.init(*this, show_value); }
121 };
122 
123 template <class T>
125 protected:
127 public:
129  : CpBaseCaption(), regler() { init(regler, true); }
130  T *get_regler() { return &regler; }
131 };
132 
133 template <class T>
135 protected:
137 public:
139  : CpMasterCaption(), regler() { init(regler); }
140  T *get_regler() { return &regler; }
141 };
142 
143 template<class T>
145 protected:
147 public:
149  : CpBaseCaptionBoxed(), regler() { init(regler, true); }
150  T *get_regler() { return &regler; }
151 };
152 
153 
154 /****************************************************************/
155 
156 class UiSelectorWithCaption: public Gtk::VBox {
157 private:
158  Gxw::Selector m_selector;
159  Gtk::Label m_label;
160 public:
161  UiSelectorWithCaption(const char *label);
162  void set_name(const Glib::ustring& n) { m_selector.set_name(n); }
163  void set_rack_label_inverse() {m_label.set_name("rack_label_inverse"); }
164  Gxw::Selector *get_selector() { return &m_selector; }
165 };
166 
167 /****************************************************************/
168 
169 bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase& machine, const std::string& id);
170 int precision(double n);
171 std::string fformat(float value, float step);
172 
173 /****************************************************************/
174 
175 #ifndef NDEBUG
176 // debug_check
177 inline void check_id(Gtk::Widget *w, const std::string& id, gx_engine::GxMachineBase& machine) {
178  if (!machine.parameter_hasId(id)) {
179  Gtk::WidgetPath pt = w->get_path();
180  cerr << "id '" << id << "' not found in definition of widget: "
181  << pt.to_string() << endl;
182  assert(false);
183  }
184  //gx_engine::parameter_map[zone].setUsed();
185 }
186 #endif
187 
188 /****************************************************************/
189 
190 inline void connect_midi_controller(Gtk::Widget *w, const std::string& id, gx_engine::GxMachineBase& machine) {
191  debug_check(check_id, w, id, machine);
192  w->signal_button_press_event().connect(
193  sigc::bind(sigc::ptr_fun(button_press_cb), sigc::ref(machine), id), false);
194 }
195 
196 /****************************************************************/
197 
198 /* -------------------------------------------------------------------------- */
199 } /* end of gx_gui namespace */
200 
201 #endif // SRC_HEADERS_GX_MAIN_INTERFACE_H_
202 
void check_id(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
UiRegler(bool show_value=true)
int precision(double n)
#define debug_check(func,...)
Definition: gx_parameter.h:36
virtual bool parameter_hasId(const char *p)=0
void connect_midi_controller(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase &machine, const std::string &id)
void set_name(const Glib::ustring &n)
std::string fformat(float value, float step)
void init(Gxw::Regler &regler, bool show_value)