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  w->set_rack_label(label);
106  w->get_regler()->set_name("show_always");
107  addwidget(w);
108  }
109  void create_simple_spin_value(const std::string& id) {
111  w->set_name("show_always");
112  addwidget(w);
113  }
114  void create_eq_rackslider_no_caption(const std::string& id) {
115  addwidget(new UiRegler<Gxw::EqSlider>(machine, id, true));
116  }
117  bool set_engine_value(const std::string id);
118  bool set_engine_cp_value(Gxw::Switch *w,const std::string id);
119  bool set_regler_cp_value(Gxw::Regler *w,const std::string id);
120  bool set_pd_value(Gxw::PortDisplay *w, const std::string id, const std::string& idl, const std::string& idh);
121  void load_file(const std::string& id, const std::string& idf);
122  void on_file_chooser_response(int response_id, Gtk::FileChooserDialog *d, const std::string& id, const std::string& idf);
123  void load_file_f(const std::string& id, const std::string& idf);
124  void create_port_display(const std::string& id, const char *label);
125  void create_p_display(const std::string& id, const std::string& idl, const std::string& idh);
126  void create_feedback_switch(const char *sw_type, const std::string& id);
127  void create_feedback_slider(const std::string& id, const char *label);
128  void create_fload_switch(const char *sw_type, const std::string& id, const std::string& idf);
129  void create_selector(const std::string& id, const char *widget_name=0);
130  void create_selector_with_caption(const std::string& id, const char *label);
131  void openFlipLabelBox(const char* = 0);
132  void openVerticalBox1(const char* label = 0);
133  void openVerticalBox2(const char* label = 0);
134  void openPaintBox2(const char* label = 0);
135  void openTabBox(const char* label = 0);
136  void addCheckButton(const std::string& id, const char* label = 0);
137  void addNumEntry(const std::string& id, const char* label = 0);
138  void addMToggleButton(const std::string& id, const char* label = 0);
139  void addSmallJConvFavButton(const char* label, gx_jconv::IRWindow *irw);
140  void openSetLabelBox();
141  void openSetMonoLabelBox();
142  void addJConvFavButton(const char* label, gx_jconv::IRWindow *irw);
143  void addJConvButton(const char* label, gx_jconv::IRWindow *irw);
144  void addSeqButton(const char* label, gx_seq::SEQWindow *seqw);
145  void set_next_flags(int flags);
146 private:
147  // functions used indirectly
148  void addwidget(Gtk::Widget *widget);
149  friend class UiBuilderImpl;
150 public:
152  gx_engine::GxMachineBase& machine_, Gxw::WaveView &fWaveView_, Gtk::Label &convolver_filename_label_,
153  Gtk::Label& convolver_mono_filename_label_, Glib::RefPtr<Gdk::Pixbuf> window_icon);
154  ~StackBoxBuilder();
155  void set_accelgroup(Glib::RefPtr<Gtk::AccelGroup> accels_) { accels = accels_; }
156  void get_box(const std::string& name, Gtk::Widget*& mainbox, Gtk::Widget*& minibox);
157  void prepare();
158  void fetch(Gtk::Widget*& mainbox, Gtk::Widget*& minibox);
159  // mono
160  void make_rackbox_oscilloscope();
161  void make_rackbox_jconv_mono();
162  void make_rackbox_midi_out();
163  void make_rackbox_sequencer();
164  // stereo
165  void make_rackbox_jconv();
166 };
167 
168 } // 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)
void set_label(const char *label)
Gtk::Widget * add(Gtk::Widget *w, const Glib::ustring &label=Glib::ustring())
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_)