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
64namespace gx_gui {
65
66/****************************************************************
67 **
68 */
69
70class CpBase {
71public:
74 void init(Gxw::Regler& regler, bool show_value);
75};
76
77class CpBaseCaption: public Gtk::VBox {
78protected:
80 Gtk::Label m_label;
81public:
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
90class CpMasterCaption: public Gtk::HBox {
91protected:
93 Gtk::Label m_label;
94public:
97 void init(Gxw::Regler& regler);
98 void set_label(const char *label);
99};
100
101class CpBaseCaptionBoxed: public Gtk::VBox {
102protected:
104 Gtk::HBox h_box;
105 Gtk::Label m_label;
106public:
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
114template <class T>
115class UiRegler: public T {
116protected:
118public:
119 UiRegler(bool show_value = true)
120 : T(), base() { base.init(*this, show_value); }
121};
122
123template <class T>
125protected:
127public:
129 : CpBaseCaption(), regler() { init(regler, true); }
130 T *get_regler() { return &regler; }
131};
132
133template <class T>
135protected:
137public:
139 : CpMasterCaption(), regler() { init(regler); }
140 T *get_regler() { return &regler; }
141};
142
143template<class T>
145protected:
147public:
149 : CpBaseCaptionBoxed(), regler() { init(regler, true); }
150 T *get_regler() { return &regler; }
151};
152
153
154/****************************************************************/
155
156class UiSelectorWithCaption: public Gtk::VBox {
157private:
158 Gxw::Selector m_selector;
159 Gtk::Label m_label;
160public:
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
169bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase& machine, const std::string& id);
170int precision(double n);
171std::string fformat(float value, float step);
172
173/****************************************************************/
174
175#ifndef NDEBUG
176// debug_check
177inline 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
190inline 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
virtual bool parameter_hasId(const char *p)=0
void set_rack_label(const char *label)
void init(Gxw::Regler &regler, bool show_value)
void set_rack_label_inverse(const char *label)
void init(Gxw::Regler &regler, bool show_value)
void set_rack_label_inverse(const char *label)
void set_rack_label(const char *label)
void set_effect_label(const char *label)
void init(Gxw::Regler &regler, bool show_value)
void init(Gxw::Regler &regler)
void set_label(const char *label)
UiRegler(bool show_value=true)
void set_name(const Glib::ustring &n)
UiSelectorWithCaption(const char *label)
#define debug_check(func,...)
Definition: gx_parameter.h:36
void connect_midi_controller(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
int precision(double n)
bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase &machine, const std::string &id)
std::string fformat(float value, float step)
void check_id(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)