Guitarix
gx_stackbox_builder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011, 2012 Andreas Degert, Hermann Meyer
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #include "guitarix.h" // NOLINT
20 
21 #include <glibmm/i18n.h> // NOLINT
22 
23 namespace gx_gui {
24 
25 /****************************************************************/
26 
27 class WidgetStack {
28 private:
29  std::vector<Gtk::Widget*> stack;
30  Gtk::Widget *top() { return stack.back(); }
31 public:
32  WidgetStack(): stack() {}
34  bool empty() { return stack.empty(); }
35  void push(Gtk::Widget *w) { stack.push_back(w); }
36  void pop() { return stack.pop_back(); }
37  void container_add(Gtk::Widget *w);
38  void box_pack_start(Gtk::Widget *w, bool expand=true, bool fill=true, int padding=0);
39  void notebook_append_page(Gtk::Widget *w, Gtk::Widget *label);
40  bool top_is_notebook() { return dynamic_cast<Gtk::Notebook*>(top()) != 0; }
41  Gtk::Widget *add(Gtk::Widget *w, const Glib::ustring& label = Glib::ustring());
42 };
43 
45 private:
46  WidgetStack fBox;
47  gx_engine::GxMachineBase& machine;
48  Gxw::WaveView& fWaveView;
49  Gtk::Label& convolver_filename_label;
50  Gtk::Label& convolver_mono_filename_label;
51  Gtk::HBox *widget;
52  Glib::RefPtr<Gtk::AccelGroup> accels;
53  Glib::RefPtr<Gdk::Pixbuf> window_icon;
54  int next_flags;
55 
56  static const gboolean homogene = false;
57  void loadRackFromGladeData(const char *xmldesc);
58  void loadRackFromGladeFile(const char *fname);
59  void set_convolver_filename(const gx_engine::GxJConvSettings *jcs);
60  void set_convolver_mono_filename(const gx_engine::GxJConvSettings *jcs);
61 private:
62  void loadRackFromBuilder(const Glib::RefPtr<GxBuilder>& bld);
63  void openVerticalMidiBox(const char* label = "");
64  // functions used in interfaces
65  void create_master_slider(const std::string& id, const char *label) {
67  w->set_label(label);
68  addwidget(w);
69  }
70 
71  void closeBox();
72  void openSpaceBox(const char* label = "");
73 
74  void check_set_flags(Gxw::Regler *r);
75  void create_simple_meter(const std::string& id);
76  void create_simple_c_meter(const std::string& id, const std::string& idl, const char *label);
77  bool set_simple(Gxw::FastMeter *fastmeter, const std::string id);
78  bool set_compressor_level(Gxw::FastMeter *fastmeter, const std::string id);
79  void create_mid_rackknob(const std::string& id, const char *label);
80  void create_small_rackknob(const std::string& id, const char *label);
81  void create_small_rackknobr(const std::string& id);
82  void create_small_rackknobr(const std::string& id, const char *label);
83  void create_big_rackknob(const std::string& id, const char *label);
84 
85  void openVerticalBox(const char* label = "");
86  void openFrameBox(const char* label);
87  void openHorizontalBox(const char* label = "");
88  void addLiveWaveDisplay(const char* label);
89  void openVerticalHideBox(const char* label = "");
90  void openHorizontalhideBox(const char* label = "");
91  void openHorizontalTableBox(const char* label);
92  void create_switch_no_caption(const char *sw_type, const std::string& id) {
93  addwidget(UiSwitch::create(machine, sw_type, id));
94  }
95  void create_h_switch(const char *sw_type, const std::string& id, const char *label);
96  void create_v_switch(const char *sw_type, const std::string& id, const char *label);
97  void openpaintampBox(const char* label = "");
98  void create_wheel(const std::string& id, const char *label=0) {
100  w->set_rack_label(label);
101  addwidget(w);
102  }
103  void create_spin_value(const std::string& id, const char *label) {
105  if (next_flags & UI_LABEL_INVERSE) {
106  w->set_rack_label_inverse(label);
107  } else {
108  w->set_rack_label(label);
109  }
110  w->get_regler()->set_name("show_always");
111  addwidget(w);
112  }
113  void create_simple_spin_value(const std::string& id) {
115  w->set_name("show_always");
116  addwidget(w);
117  }
118  void create_eq_rackslider_no_caption(const std::string& id) {
119  addwidget(new UiRegler<Gxw::EqSlider>(machine, id, true));
120  }
121  bool set_engine_value(const std::string id);
122  bool set_engine_cp_value(Gxw::Switch *w,const std::string id);
123  bool set_regler_cp_value(Gxw::Regler *w,const std::string id);
124  bool set_pd_value(Gxw::PortDisplay *w, const std::string id, const std::string& idl, const std::string& idh);
125  void load_file(const std::string& id, const std::string& idf);
126  void on_file_chooser_response(int response_id, Gtk::FileChooserDialog *d, const std::string& id, const std::string& idf);
127  void load_file_f(const std::string& id, const std::string& idf);
128  void create_port_display(const std::string& id, const char *label);
129  void create_p_display(const std::string& id, const std::string& idl, const std::string& idh);
130  void create_feedback_switch(const char *sw_type, const std::string& id);
131  void create_feedback_slider(const std::string& id, const char *label);
132  void create_fload_switch(const char *sw_type, const std::string& id, const std::string& idf);
133  void create_selector(const std::string& id, const char *widget_name=0);
134  void create_selector_with_caption(const std::string& id, const char *label);
135  void openFlipLabelBox(const char* = 0);
136  void openVerticalBox1(const char* label = 0);
137  void openVerticalBox2(const char* label = 0);
138  void openPaintBox2(const char* label = 0);
139  void openTabBox(const char* label = 0);
140  void addCheckButton(const std::string& id, const char* label = 0);
141  void addNumEntry(const std::string& id, const char* label = 0);
142  void addMToggleButton(const std::string& id, const char* label = 0);
143  void openSetLabelBox();
144  void openSetMonoLabelBox();
145  void addSmallJConvFavButton(const char* label, gx_jconv::IRWindow *irw);
146  void addJConvButton(const char* label, gx_jconv::IRWindow *irw);
147  void addSmallSeqButton(const char* label, gx_seq::SEQWindow *seqw);
148  void addSeqButton(const char* label, gx_seq::SEQWindow *seqw);
149  void set_next_flags(int flags);
150 private:
151  // functions used indirectly
152  void addwidget(Gtk::Widget *widget);
153  friend class UiBuilderImpl;
154 public:
156  gx_engine::GxMachineBase& machine_, Gxw::WaveView &fWaveView_, Gtk::Label &convolver_filename_label_,
157  Gtk::Label& convolver_mono_filename_label_, Glib::RefPtr<Gdk::Pixbuf> window_icon);
158  ~StackBoxBuilder();
159  void set_accelgroup(Glib::RefPtr<Gtk::AccelGroup> accels_) { accels = accels_; }
160  void get_box(const std::string& name, Gtk::Widget*& mainbox, Gtk::Widget*& minibox);
161  void prepare();
162  void fetch(Gtk::Widget*& mainbox, Gtk::Widget*& minibox);
163  // mono
164  void make_rackbox_oscilloscope();
165  void make_rackbox_jconv_mono();
166  void make_rackbox_midi_out();
167  void make_rackbox_sequencer();
168  // stereo
169  void make_rackbox_jconv();
170 };
171 
172 } // end namespace gx_gui
void notebook_append_page(Gtk::Widget *w, Gtk::Widget *label)
void container_add(Gtk::Widget *w)
static UiSwitch * create(gx_engine::GxMachineBase &machine, const char *sw_type, gx_engine::Parameter &param)
#define UI_LABEL_INVERSE
Definition: gx_plugin.h:45
void set_label(const char *label)
Gtk::Widget * add(Gtk::Widget *w, const Glib::ustring &label=Glib::ustring())
void set_rack_label_inverse(const char *label)
void set_rack_label(const char *label)
void push(Gtk::Widget *w)
void set_rack_label(const char *label)
void box_pack_start(Gtk::Widget *w, bool expand=true, bool fill=true, int padding=0)
void set_accelgroup(Glib::RefPtr< Gtk::AccelGroup > accels_)