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();
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:
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 
gx_gui::UiSelectorWithCaption::set_rack_label_inverse
void set_rack_label_inverse()
Definition: gx_main_interface.h:163
gx_engine::GxMachineBase::parameter_hasId
virtual bool parameter_hasId(const char *p)=0
gx_gui::UiMasterReglerWithCaption::UiMasterReglerWithCaption
UiMasterReglerWithCaption()
Definition: gx_main_interface.h:138
gx_gui::CpBaseCaption::~CpBaseCaption
~CpBaseCaption()
gx_engine::GxMachineBase
Definition: machine.h:55
gx_gui::UiReglerWithCaption::regler
T regler
Definition: gx_main_interface.h:126
gx_gui::CpBaseCaption::init
void init(Gxw::Regler &regler, bool show_value)
gx_gui::UiReglerWithCaption
Definition: gx_main_interface.h:124
gx_gui::CpBaseCaption::base
CpBase base
Definition: gx_main_interface.h:79
gx_gui::fformat
std::string fformat(float value, float step)
gx_gui::CpBase::CpBase
CpBase()
gx_gui::precision
int precision(double n)
gx_gui::CpBaseCaption::set_rack_label_inverse
void set_rack_label_inverse(const char *label)
gx_gui::UiSelectorWithCaption::set_name
void set_name(const Glib::ustring &n)
Definition: gx_main_interface.h:162
gx_gui::UiDisplayWithCaption
Definition: gx_main_interface.h:144
gx_gui::CpMasterCaption::~CpMasterCaption
~CpMasterCaption()
gx_gui::CpMasterCaption::base
CpBase base
Definition: gx_main_interface.h:92
gx_gui::CpMasterCaption::init
void init(Gxw::Regler &regler)
gx_gui::CpBaseCaptionBoxed::m_label
Gtk::Label m_label
Definition: gx_main_interface.h:105
gx_gui::UiDisplayWithCaption::get_regler
T * get_regler()
Definition: gx_main_interface.h:150
gx_gui::UiReglerWithCaption::UiReglerWithCaption
UiReglerWithCaption()
Definition: gx_main_interface.h:128
gx_gui::UiSelectorWithCaption
Definition: gx_main_interface.h:156
gx_gui::UiReglerWithCaption::get_regler
T * get_regler()
Definition: gx_main_interface.h:130
gx_gui::CpBaseCaptionBoxed::base
CpBase base
Definition: gx_main_interface.h:103
gx_gui::UiMasterReglerWithCaption::regler
T regler
Definition: gx_main_interface.h:136
gx_gui::CpBaseCaption::CpBaseCaption
CpBaseCaption()
gx_gui::UiMasterReglerWithCaption::get_regler
T * get_regler()
Definition: gx_main_interface.h:140
gx_gui::CpBaseCaptionBoxed::set_rack_label
void set_rack_label(const char *label)
gx_gui::CpBase::init
void init(Gxw::Regler &regler, bool show_value)
gx_gui::CpMasterCaption::set_label
void set_label(const char *label)
gx_gui::UiSelectorWithCaption::UiSelectorWithCaption
UiSelectorWithCaption(const char *label)
gx_gui::UiSelectorWithCaption::get_selector
Gxw::Selector * get_selector()
Definition: gx_main_interface.h:164
gx_gui::UiDisplayWithCaption::regler
T regler
Definition: gx_main_interface.h:146
gx_gui::UiRegler::base
CpBase base
Definition: gx_main_interface.h:117
gx_gui::UiDisplayWithCaption::UiDisplayWithCaption
UiDisplayWithCaption()
Definition: gx_main_interface.h:148
debug_check
#define debug_check(func,...)
Definition: gx_parameter.h:36
gx_gui::CpMasterCaption
Definition: gx_main_interface.h:90
gx_gui::CpBaseCaptionBoxed
Definition: gx_main_interface.h:101
gx_gui::CpBaseCaption
Definition: gx_main_interface.h:77
gx_gui::UiRegler::UiRegler
UiRegler(bool show_value=true)
Definition: gx_main_interface.h:119
gx_gui::UiMasterReglerWithCaption
Definition: gx_main_interface.h:134
gx_gui::CpBaseCaption::m_label
Gtk::Label m_label
Definition: gx_main_interface.h:80
gx_gui::CpBaseCaption::set_effect_label
void set_effect_label(const char *label)
gx_gui::CpMasterCaption::CpMasterCaption
CpMasterCaption()
gx_gui::CpBaseCaptionBoxed::init
void init(Gxw::Regler &regler, bool show_value)
gx_gui::UiSelectorWithCaption::m_selector
Gxw::Selector m_selector
Definition: gx_main_interface.h:158
gx_gui::CpBase
Definition: gx_main_interface.h:70
gx_gui::CpBase::~CpBase
~CpBase()
gx_gui::CpMasterCaption::m_label
Gtk::Label m_label
Definition: gx_main_interface.h:93
gx_gui
Definition: gx_gui_helpers.h:28
gx_gui::CpBaseCaption::set_rack_label
void set_rack_label(const char *label)
gx_gui::connect_midi_controller
void connect_midi_controller(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
Definition: gx_main_interface.h:190
gx_gui::CpBaseCaptionBoxed::h_box
Gtk::HBox h_box
Definition: gx_main_interface.h:104
gx_gui::CpBaseCaptionBoxed::set_rack_label_inverse
void set_rack_label_inverse(const char *label)
gx_gui::check_id
void check_id(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
Definition: gx_main_interface.h:177
gx_gui::CpBaseCaptionBoxed::CpBaseCaptionBoxed
CpBaseCaptionBoxed()
gx_gui::UiRegler
Definition: gx_main_interface.h:115
gx_gui::UiSelectorWithCaption::m_label
Gtk::Label m_label
Definition: gx_main_interface.h:159
gx_gui::button_press_cb
bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase &machine, const std::string &id)
gx_gui::CpBaseCaptionBoxed::~CpBaseCaptionBoxed
~CpBaseCaptionBoxed()