Guitarix
gx_stackbox_builder.cpp
Go to the documentation of this file.
1 #include "guitarix.h" // NOLINT
2 
3 #include <glibmm/i18n.h> // NOLINT
4 
5 // -------- the gx_head user interface build instruktions
6 
7 namespace gx_gui {
8 
9 // Paint Functions for Gxw::PaintBox
10 
11 const char *pb_gx_rack_amp_expose = "gx_rack_amp_expose";
12 const char *pb_rectangle_skin_color_expose = "rectangle_skin_color_expose";
13 const char *pb_zac_expose = "zac_expose";
14 const char *pb_gxhead_expose = "gxhead_expose";
15 const char *pb_RackBox_expose = "RackBox_expose";
16 const char *pb_gxrack_expose = "gxrack_expose";
17 const char *pb_level_meter_expose = "level_meter_expose";
18 
19 
20 int precision(double n) {
21  if (n < 0.009999)
22  return 3;
23  else if (n < 0.099999)
24  return 2;
25  else if (n < 0.999999)
26  return 1;
27  else
28  return 0;
29 }
30 
31 string fformat(float value, float step) {
32  ostringstream buf;
33  buf << fixed << setprecision(precision(step)) << value;
34  return buf.str();
35 }
36 
37 bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase& machine, const std::string& id) {
38  if (event->button == 2) {
39  if (!machine.midi_get_config_mode()) {
40  new gx_main_midi::MidiConnect(event, machine.get_parameter(id), machine);
41  }
42  return true;
43  }
44  return false;
45 }
46 
47 
48 /****************************************************************
49  ** class WidgetStack
50  */
51 
52 void WidgetStack::container_add(Gtk::Widget *w) {
53  dynamic_cast<Gtk::Container*>(top())->add(*w);
54 }
55 
56 void WidgetStack::box_pack_start(Gtk::Widget *w, bool expand, bool fill, int padding) {
57  dynamic_cast<Gtk::Box*>(top())->pack_start(*w, expand, fill, padding);
58 }
59 
60 void WidgetStack::notebook_append_page(Gtk::Widget *w, Gtk::Widget *label) {
61  dynamic_cast<Gtk::Notebook*>(top())->append_page(*w, *label);
62 }
63 
64 Gtk::Widget *WidgetStack::add(Gtk::Widget *w, const Glib::ustring& label) {
65  w->show();
66  Gtk::Widget *t = top();
67  Gtk::Notebook *n = dynamic_cast<Gtk::Notebook*>(t);
68  if (n) {
69  n->append_page(*w, *manage(new Gtk::Label(label)));
70  return w;
71  }
72  Gtk::Box *b = dynamic_cast<Gtk::Box*>(t);
73  if (b) {
74  b->pack_start(*w, true, true, 0);
75  return w;
76  }
77  Gtk::Container *c = dynamic_cast<Gtk::Container*>(t);
78  if (c) {
79  c->add(*w);
80  return w;
81  }
82  assert(false);
83  return w;
84 }
85 
86 /****************************************************************
87  ** class StackBoxBuilder
88  */
89 
91  gx_engine::GxMachineBase& machine_, Gxw::WaveView &fWaveView_, Gtk::Label &convolver_filename_label_,
92  Gtk::Label &convolver_mono_filename_label_, Glib::RefPtr<Gdk::Pixbuf> window_icon_)
93  : fBox(), machine(machine_),
94  fWaveView(fWaveView_), convolver_filename_label(convolver_filename_label_),
95  convolver_mono_filename_label(convolver_mono_filename_label_),
96  widget(), accels(), window_icon(window_icon_), next_flags(0) {
97 }
98 
100 }
101 
102 void StackBoxBuilder::openVerticalMidiBox(const char* label) {
103  openVerticalBox(label);
104 }
105 
107  widget = new Gtk::HBox();
108  widget->show();
109  fBox.push(manage(widget));
110 }
111 
112 #ifndef NDEBUG
113 void wnotify(gpointer data, GObject *where_the_object_was) {
114  printf("WN %p %p\n", where_the_object_was, data);
115 }
116 
117 // check if object will be finalized
118 void trace_finalize(Glib::Object *o, int n) {
119  g_object_weak_ref(o->gobj(), wnotify, GINT_TO_POINTER(n));
120 }
121 #endif
122 
123 void StackBoxBuilder::fetch(Gtk::Widget*& mainbox, Gtk::Widget*& minibox) {
124  fBox.pop();
125  assert(fBox.empty());
126  mainbox = widget;
127  Glib::ListHandle<Gtk::Widget*> l = widget->get_children();
128  if (l.size() == 2) {
129  Glib::ListHandle<Gtk::Widget*>::iterator i = l.begin();
130  minibox = new Gtk::VBox();
131  minibox->show();
132  (*i)->show();
133  (*i)->reparent(*minibox);
134  } else {
135  minibox = 0;
136  }
137 }
138 
139 void StackBoxBuilder::get_box(const std::string& name, Gtk::Widget*& mainbox, Gtk::Widget*& minibox) {
140  struct {
141  const char *name;
142  void (StackBoxBuilder::*func)();
143  } mapping[] = {
144  // mono
145  { "oscilloscope", &StackBoxBuilder::make_rackbox_oscilloscope },
146  { "jconv_mono", &StackBoxBuilder::make_rackbox_jconv_mono },
149  // stereo
151  };
152  mainbox = minibox = 0;
153  for (unsigned int i = 0; i < sizeof(mapping) / sizeof(mapping[0]); ++i) {
154  if (name == mapping[i].name) {
155  prepare();
156  (this->*mapping[i].func)();
157  fetch(mainbox, minibox);
158  }
159  }
160 }
161 
162 void StackBoxBuilder::loadRackFromBuilder(const Glib::RefPtr<GxBuilder>& bld) {
163  if (!bld->has_object("rackbox")) {
164  gx_print_error("load_ui Error", "can't find widget 'rackbox'");
165  return;
166  }
167  Gtk::Widget* w;
168  if (bld->has_object("minibox")) {
169  bld->find_widget("minibox", w);
170  fBox.add(w);
171  }
172  bld->find_widget("rackbox", w);
173  fBox.add(w);
174 
175  // find fastmeters in glade UI's and add a timeout callback to set the levels
176  // fastmeters must have id=gxfastmeterN were N starts with 1
177  std::string id;
178  for (int i = 1; i<12;++i) {
179  Glib::ustring fm = "gxfastmeter" + gx_system::to_string(i);
180  if (bld->has_object(fm)) {
181  Gxw::FastMeter *fastmeter;
182  bld->find_widget(fm, fastmeter);
183  fastmeter->get_property("var_id",id);
184  fastmeter->set_name("simplemeter");
185  if (!id.empty())
186  Glib::signal_timeout().connect(sigc::bind<Gxw::FastMeter*>(sigc::bind<const std::string>(
187  sigc::mem_fun(*this, &StackBoxBuilder::set_simple),id), fastmeter), 60);
188  fastmeter->set_by_power(0.0001);
189  } else {
190  break;
191  }
192  }
193  for (int i = 1; i<12;++i) {
194  Glib::ustring fm = "gxfastmeter" + gx_system::to_string(i)+ ":meterframe";
195  if (bld->has_object(fm)) {
196  Gxw::FastMeter *fastmeter;
197  bld->find_widget(fm, fastmeter);
198  fastmeter->get_property("var_id",id);
199  //fastmeter->set_name("meterframe");
200  if (!id.empty())
201  Glib::signal_timeout().connect(sigc::bind<Gxw::FastMeter*>(sigc::bind<const std::string>(
202  sigc::mem_fun(*this, &StackBoxBuilder::set_simple),id), fastmeter), 60);
203  fastmeter->set_by_power(0.0001);
204  } else {
205  break;
206  }
207  }
208  for (int i = 1; i<12;++i) {
209  Glib::ustring fm = "gxcompressormeter" + gx_system::to_string(i);
210  if (bld->has_object(fm)) {
211  Gxw::FastMeter *fastmeter;
212  bld->find_widget(fm, fastmeter);
213  fastmeter->get_property("var_id",id);
214  fastmeter->set_name("simplemeter");
215  if (!id.empty())
216  Glib::signal_timeout().connect(sigc::bind<Gxw::FastMeter*>(sigc::bind<const std::string>(
217  sigc::mem_fun(*this, &StackBoxBuilder::set_compressor_level),id), fastmeter), 60);
218  fastmeter->set_c_level(0.0);
219  } else {
220  break;
221  }
222  }
223  for (int i = 1; i<12;++i) {
224  Glib::ustring fm = "gxportdisplay" + gx_system::to_string(i);
225  if (bld->has_object(fm)) {
226  Gxw::PortDisplay *regler;
227  bld->find_widget(fm, regler);
228  regler->get_property("var_id",id);
229  if (!id.empty())
230  Glib::signal_timeout().connect(sigc::bind<const std::string>(
231  sigc::mem_fun(*this, &StackBoxBuilder::set_engine_value),id), 60);
232  } else {
233  break;
234  }
235  }
236  // find feedback switches and connect a timeout callback to update the UI elements.
237  // feedback switches must have the id gxfswitchN were N starts with 1
238  for (int i = 1; i<12;++i) {
239  Glib::ustring fm = "gxfswitch" + gx_system::to_string(i);
240  if (bld->has_object(fm)) {
241  Gxw::Switch *sw;
242  bld->find_widget(fm, sw);
243  sw->get_property("var_id",id);
244  sw->set_name("effect_on_off");
245  if (!id.empty())
246  Glib::signal_timeout().connect(sigc::bind<Gxw::Switch*>(sigc::bind<const std::string>(
247  sigc::mem_fun(*this, &StackBoxBuilder::set_engine_cp_value),id),sw), 60);
248  } else {
249  break;
250  }
251  }
252  // find feedback Regler and connect a timeout callback to update the UI elements.
253  // were Regler could be GxKnob's or GxSlider's
254  // feedback Regler must have the id gxfreglerN were N starts with 1
255  for (int i = 1; i<12;++i) {
256  Glib::ustring fm = "gxfregler" + gx_system::to_string(i);
257  if (bld->has_object(fm)) {
258  Gxw::Regler *regler;
259  bld->find_widget(fm, regler);
260  regler->get_property("var_id",id);
261  if (!id.empty())
262  Glib::signal_timeout().connect(sigc::bind<Gxw::Regler*>(sigc::bind<const std::string>(
263  sigc::mem_fun(*this, &StackBoxBuilder::set_regler_cp_value),id),regler), 60);
264  } else {
265  break;
266  }
267  }
268 }
269 
270 static const char *rackbox_ids[] = { "rackbox", "minibox", 0 };
271 
272 void StackBoxBuilder::loadRackFromGladeFile(const char *fname) {
273  loadRackFromBuilder(
274  GxBuilder::create_from_file(
275  machine.get_options().get_builder_filepath(fname), &machine, rackbox_ids));
276 }
277 
278 void StackBoxBuilder::loadRackFromGladeData(const char *xmldesc) {
279  loadRackFromBuilder(GxBuilder::create_from_string(xmldesc, &machine, rackbox_ids));
280 }
281 
282 void StackBoxBuilder::addwidget(Gtk::Widget *widget) {
283  if (widget) {
284  fBox.container_add(manage(widget));
285  }
286  next_flags = 0;
287 }
288 
289 void StackBoxBuilder::addSmallJConvFavButton(const char* label, gx_jconv::IRWindow *irw) {
290  Gtk::Button *button = new Gtk::Button();
291  button->set_name("smallbutton");
292  Gtk::Label *lab = new Gtk::Label(label);
293  Pango::FontDescription font = lab->get_style()->get_font();
294  font.set_size(7*Pango::SCALE);
295  font.set_weight(Pango::WEIGHT_NORMAL);
296  lab->modify_font(font);
297  button->add(*manage(lab));
298  //lab->set_name("rack_label_inverse");
299  lab->set_padding(5,0);
300  fBox.add(manage(button), label);
301  lab->show();
302  button->signal_clicked().connect(
303  sigc::mem_fun(*irw, &gx_jconv::IRWindow::reload_and_show));
304 }
305 
306 void StackBoxBuilder::set_convolver_filename(const gx_engine::GxJConvSettings *jcs) {
307  convolver_filename_label.set_label(jcs->getIRFile());
308 }
309 
310 void StackBoxBuilder::set_convolver_mono_filename(const gx_engine::GxJConvSettings *jcs) {
311  convolver_mono_filename_label.set_label(jcs->getIRFile());
312 }
313 
314 void StackBoxBuilder::openSetLabelBox() {
315  Gtk::VBox *box = new Gtk::VBox();
316  box->set_homogeneous(false);
317  box->set_spacing(0);
318  box->set_border_width(0);
319  convolver_filename_label.set_name("rack_label");
320  Pango::FontDescription font = convolver_filename_label.get_style()->get_font();
321  font.set_size(8*Pango::SCALE);
322  font.set_weight(Pango::WEIGHT_BOLD);
323  convolver_filename_label.modify_font(font);
324  box->pack_start(convolver_filename_label, false, false, 0);
325  box->show_all();
326  gx_engine::JConvParameter *jcp = dynamic_cast<gx_engine::JConvParameter*>(&machine.get_parameter("jconv.convolver"));
327  assert(jcp);
328  convolver_filename_label.set_label(jcp->get_value().getIRFile());
329  jcp->signal_changed().connect(
330  sigc::mem_fun(*this, &StackBoxBuilder::set_convolver_filename));
331  fBox.box_pack_start(manage(box), false);
332  fBox.push(box);
333 }
334 
335 void StackBoxBuilder::openSetMonoLabelBox() {
336  Gtk::VBox *box = new Gtk::VBox();
337  box->set_homogeneous(false);
338  box->set_spacing(0);
339  box->set_border_width(0);
340  convolver_mono_filename_label.set_name("rack_label");
341  Pango::FontDescription font = convolver_mono_filename_label.get_style()->get_font();
342  font.set_size(8*Pango::SCALE);
343  font.set_weight(Pango::WEIGHT_BOLD);
344  convolver_mono_filename_label.modify_font(font);
345  box->pack_start(convolver_mono_filename_label, true, false, 0);
346  box->show_all();
347  gx_engine::JConvParameter *jcp = dynamic_cast<gx_engine::JConvParameter*>(&machine.get_parameter("jconv_mono.convolver"));
348  assert(jcp);
349  convolver_mono_filename_label.set_label(jcp->get_value().getIRFile());
350  jcp->signal_changed().connect(
351  sigc::mem_fun(*this, &StackBoxBuilder::set_convolver_mono_filename));
352  fBox.box_pack_start(manage(box));
353  fBox.push(box);
354 }
355 
356 void StackBoxBuilder::addJConvButton(const char* label, gx_jconv::IRWindow *irw) {
357  Gtk::Button *button = new Gtk::Button();
358  button->set_can_default(false);
359  button->set_can_focus(false);
360  Gtk::Label *lab = new Gtk::Label(label);
361  //Pango::FontDescription font = lab->get_style()->get_font();
362  //font.set_size(10*Pango::SCALE);
363  //font.set_weight(Pango::WEIGHT_NORMAL);
364  //lab->modify_font(font);
365  button->add(*manage(lab));
366  //lab->set_name("rack_label_inverse");
367  Gtk::Alignment *al = new Gtk::Alignment(0.0, 0.5, 0.0, 0.0);
368  al->add(*manage(button));
369  al->show_all();
370  fBox.box_pack_start(manage(al), false);
371  button->signal_clicked().connect(
372  sigc::mem_fun(*irw, &gx_jconv::IRWindow::reload_and_show));
373 }
374 
375 void StackBoxBuilder::addSmallSeqButton(const char* label, gx_seq::SEQWindow *seqw) {
376  Gtk::Button *button = new Gtk::Button();
377  button->set_name("smallbutton");
378  Gtk::Label *lab = new Gtk::Label(label);
379  Pango::FontDescription font = lab->get_style()->get_font();
380  font.set_size(7*Pango::SCALE);
381  font.set_weight(Pango::WEIGHT_NORMAL);
382  lab->modify_font(font);
383  button->add(*manage(lab));
384  //lab->set_name("rack_label_inverse");
385  lab->set_padding(5,0);
386  fBox.add(manage(button), label);
387  lab->show();
388  button->signal_clicked().connect(
389  sigc::mem_fun(*seqw, &gx_seq::SEQWindow::reload_and_show));
390 }
391 
392 void StackBoxBuilder::addSeqButton(const char* label, gx_seq::SEQWindow *seqw) {
393  Gtk::Button *button = new Gtk::Button();
394  button->set_can_default(false);
395  button->set_can_focus(false);
396  Gtk::Label *lab = new Gtk::Label(label);
397  //Pango::FontDescription font = lab->get_style()->get_font();
398  //font.set_size(10*Pango::SCALE);
399  //font.set_weight(Pango::WEIGHT_NORMAL);
400  //lab->modify_font(font);
401  button->add(*manage(lab));
402  //lab->set_name("rack_label_inverse");
403  Gtk::Alignment *al = new Gtk::Alignment(0.0, 0.5, 0.0, 0.0);
404  al->add(*manage(button));
405  al->show_all();
406  fBox.box_pack_start(manage(al), false);
407  button->signal_clicked().connect(
408  sigc::mem_fun(*seqw, &gx_seq::SEQWindow::reload_and_show));
409 }
410 
411 void StackBoxBuilder::set_next_flags(int flags) {
412  next_flags = flags;
413 }
414 
415 bool StackBoxBuilder::set_simple(Gxw::FastMeter *fastmeter,const std::string id) {
416  if (machine.parameter_hasId(id)) {
417  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off"))
418  fastmeter->set_by_power(machine.get_parameter_value<float>(id));
419  else
420  fastmeter->set_by_power(0.0001);
421  return true;
422  } else {
423  return false;
424  }
425 }
426 
427 bool StackBoxBuilder::set_compressor_level(Gxw::FastMeter *fastmeter,const std::string id) {
428  if (machine.parameter_hasId(id)) {
429  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off"))
430  fastmeter->set_c_level(machine.get_parameter_value<float>(id));
431  else
432  fastmeter->set_c_level(0.0);
433  return true;
434  } else {
435  return false;
436  }
437 }
438 
439 void StackBoxBuilder::create_simple_meter(const std::string& id) {
440  Gxw::FastMeter *fastmeter = new Gxw::FastMeter();
441  fastmeter->set_hold_count(5);
442  fastmeter->set_property("dimen",2);
443  fastmeter->set_property("type",0);
444  Glib::signal_timeout().connect(sigc::bind<Gxw::FastMeter*>(sigc::bind<const std::string>(
445  sigc::mem_fun(*this, &StackBoxBuilder::set_simple),id), fastmeter), 60);
446  fastmeter->set_by_power(0.0001);
447  Gtk::HBox *box = new Gtk::HBox();
448  box->set_border_width(2);
449  box->pack_start(*Gtk::manage(static_cast<Gtk::Widget*>(fastmeter)),Gtk::PACK_SHRINK);
450  box->show_all();
451  fBox.box_pack_start(manage(box),false);
452 }
453 
454 void StackBoxBuilder::create_simple_c_meter(const std::string& id, const std::string& idm, const char *label) {
455  Gxw::FastMeter *fastmeter = new Gxw::FastMeter();
456  fastmeter->set_hold_count(5);
457  fastmeter->set_property("dimen",2);
458  fastmeter->set_property("type",0);
459  fastmeter->set_name("simplemeter");
460  Glib::signal_timeout().connect(sigc::bind<Gxw::FastMeter*>(sigc::bind<const std::string>(
461  sigc::mem_fun(*this, &StackBoxBuilder::set_simple),id), fastmeter), 60);
462  fastmeter->set_by_power(0.0001);
463  Gxw::LevelSlider *w = new UiRegler<Gxw::LevelSlider>(machine, idm);
464  w->set_name("lmw");
465  GxPaintBox *box = new GxPaintBox("simple_level_meter_expose");
466  box->set_border_width(2);
467  box->pack_start(*Gtk::manage(static_cast<Gtk::Widget*>(fastmeter)),Gtk::PACK_SHRINK);
468  box->add(*Gtk::manage(static_cast<Gtk::Widget*>(w)));
469  if (label && label[0]) {
470  Gtk::VBox *boxv = new Gtk::VBox();
471  //boxv->set_property("orientation",Gtk::ORIENTATION_VERTICAL);
472  boxv->set_homogeneous(false);
473  boxv->set_spacing(0);
474  // boxv->set_border_width(4);
475  Gtk::Label *lab = new Gtk::Label(label);
476  Pango::FontDescription font = lab->get_style()->get_font();
477  font.set_size(6*Pango::SCALE);
478  font.set_weight(Pango::WEIGHT_NORMAL);
479  lab->modify_font(font);
480  lab->set_name("beffekt_label");
481  boxv->add(*manage(lab));
482  boxv->add(*manage(box));
483  boxv->show_all();
484  fBox.box_pack_start(manage(boxv),false);
485  } else {
486  box->show_all();
487  fBox.box_pack_start(manage(box),false);
488  }
489 }
490 
491 bool StackBoxBuilder::set_regler_cp_value(Gxw::Regler * regler, const std::string id) {
492  if (machine.parameter_hasId(id)) {
493  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off"))
494  regler->cp_set_value(machine.get_parameter_value<float>(id));
495  return true;
496  } else {
497  return false;
498  }
499 }
500 
501 bool StackBoxBuilder::set_engine_cp_value(Gxw::Switch * sw, const std::string id) {
502  if (machine.parameter_hasId(id)) {
503  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off"))
504  sw->cp_set_value(machine.get_parameter_value<float>(id));
505  return true;
506  } else {
507  return false;
508  }
509 }
510 
511 bool StackBoxBuilder::set_engine_value(const std::string id) {
512  if (machine.parameter_hasId(id)) {
513  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off"))
514  machine.signal_parameter_value<float>(id)(machine.get_parameter_value<float>(id));
515  return true;
516  } else {
517  return false;
518  }
519 }
520 
521 void StackBoxBuilder::create_port_display(const std::string& id, const char *label) {
523  Glib::signal_timeout().connect(sigc::bind<const std::string>(
524  sigc::mem_fun(*this, &StackBoxBuilder::set_engine_value),id), 60);
525  if (next_flags & UI_LABEL_INVERSE) {
526  w->set_rack_label_inverse(label);
527  } else {
528  w->set_rack_label(label);
529  }
530  addwidget(w);
531 }
532 
533 bool StackBoxBuilder::set_pd_value(Gxw::PortDisplay *w, const std::string id, const std::string& idl, const std::string& idh) {
534  if (machine.parameter_hasId(id)) {
535  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off")) {
536  float low = machine.get_parameter_value<float>(idl);
537  float high = 100-machine.get_parameter_value<float>(idh);
538  w->set_state(int(low),int(high));
539  float set = (low + high)*0.001;
540  machine.signal_parameter_value<float>(id)(machine.get_parameter_value<float>(id)+set);
541  }
542  return true;
543  } else {
544  return false;
545  }
546 }
547 
548 void StackBoxBuilder::create_p_display(const std::string& id, const std::string& idl, const std::string& idh) {
549  Gxw::PortDisplay *w = new UiRegler<Gxw::PortDisplay>(machine, id);
550  w->set_name("playhead");
551  Gtk::EventBox* e_box = new Gtk::EventBox();
552  e_box->set_size_request(-1, -1);
553  e_box->set_border_width(0);
554  e_box->set_visible_window(true);
555  e_box->set_above_child(true);
556  e_box->add(*manage(static_cast<Gtk::Widget*>(w)));
557  addwidget(e_box);
558  e_box->show_all();
559  Glib::signal_timeout().connect(sigc::bind<Gxw::PortDisplay*>(sigc::bind<const std::string>(
560  sigc::bind<const std::string>(sigc::bind<const std::string>(
561  sigc::mem_fun(*this, &StackBoxBuilder::set_pd_value),idh),idl),id),w ), 60);
562 }
563 
564 void StackBoxBuilder::create_feedback_switch(const char *sw_type, const std::string& id) {
565  Gtk::Widget *sw = UiSwitch::create(machine, sw_type, id);
566  Gxw::Switch *regler = static_cast<Gxw::Switch*>(sw);
567  //regler->set_relief(Gtk::RELIEF_NONE);
568  regler->set_name("effect_on_off");
569  addwidget(sw);
570  Glib::signal_timeout().connect(sigc::bind<const std::string>(
571  sigc::mem_fun(*this, &StackBoxBuilder::set_engine_value),id), 60);
572 }
573 
574 void StackBoxBuilder::load_file(const std::string& id, const std::string& idf) {
575  static Glib::ustring recent_filename = "";
576  static Glib::ustring hostname = "localhost";
577  if (! machine.get_jack()) {
578  hostname = Gio::Resolver::get_default()->lookup_by_address
579  (Gio::InetAddress::create( machine.get_options().get_rpcaddress()));
580  }
581  if (machine.parameter_hasId(id)) {
582  if (machine.get_parameter_value<bool>(id.substr(0,id.find_last_of(".")+1)+"on_off")) {
583  if (machine.get_parameter_value<float>(id)>0) {
584  Glib::ustring filename = machine.get_parameter_value<string>(idf);
585  Glib::ustring title = hostname + ": Select loop file";
586  Gtk::FileChooserDialog d( title);
587  d.set_local_only(false);
588  d.property_destroy_with_parent().set_value(true);
589  d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
590  d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
591  Glib::ustring loop_dir = machine.get_options().get_loop_dir();
592  d.add_shortcut_folder_uri(Glib::filename_to_uri(loop_dir, hostname));
593  Gtk::FileFilter wav;
594  wav.set_name("WAV Files");
595  wav.add_mime_type("audio/x-vorbis+ogg");
596  wav.add_mime_type("audio/x-wav");
597  wav.add_pattern("*.ogg");
598  wav.add_pattern("*.wav");
599  wav.add_pattern("*.WAV");
600  wav.add_pattern("*.Wav");
601  d.add_filter(wav);
602  Gtk::FileFilter audio;
603  audio.set_name("Audio Files");
604  audio.add_mime_type("audio/*");
605  d.add_filter(audio);
606  Gtk::FileFilter all;
607  all.add_pattern("*");
608  all.set_name("All Files");
609  d.add_filter(all);
610  if (!recent_filename.empty()) {
611  d.set_uri(Glib::filename_to_uri (recent_filename, hostname));
612  } else if ((filename.find("tape") != Glib::ustring::npos) && (!filename.empty())) {
613  d.set_uri(Glib::filename_to_uri (loop_dir + filename + string(".wav"), hostname));
614  } else {
615  d.set_current_folder_uri(Glib::filename_to_uri (loop_dir, hostname));
616  }
617  d.signal_response().connect(sigc::bind<Gtk::FileChooserDialog*>(sigc::bind<const std::string>(
618  sigc::bind<const std::string>(sigc::mem_fun(*this, &StackBoxBuilder::on_file_chooser_response),idf),id), &d) );
619  d.show();
620  while(machine.get_parameter_value<float>(id)>0) {
621  //g_main_context_iteration (NULL, true);
622  if (Gtk::Main::iteration(false)) {
623  machine.set_parameter_value(id,0.0);
624  machine.signal_parameter_value<float>(id)(0.0);
625  }
626  }
627 
628  // if (d.run() != Gtk::RESPONSE_OK) {
629  // machine.set_parameter_value(id,0.0);
630  // machine.signal_parameter_value<float>(id)(0.0);
631  // return;
632  // }
633  // filename = Glib::filename_from_uri(d.get_uri(), hostname);
634  // recent_filename = filename;
635  // Gtk::RecentManager::Data data;
636  // bool result_uncertain;
637  // data.mime_type = Gio::content_type_guess(filename, "", result_uncertain);
638  // data.app_name = "guitarix";
639  // data.groups.push_back("loopfiles");
640  // Gtk::RecentManager::get_default()->add_item(d.get_uri(), data);
641  // machine.set_parameter_value(idf,filename);
642  // machine.set_parameter_value(id,0.0);
643  // machine.signal_parameter_value<float>(id)(0.0);
644  }
645  }
646  }
647 }
648 
649 void StackBoxBuilder::on_file_chooser_response(int response_id, Gtk::FileChooserDialog *d, const std::string& id, const std::string& idf)
650 {
651  if( response_id == Gtk::RESPONSE_OK) {
652  static Glib::ustring hostname = "localhost";
653  if (! machine.get_jack()) {
654  hostname = Gio::Resolver::get_default()->lookup_by_address
655  (Gio::InetAddress::create( machine.get_options().get_rpcaddress()));
656  }
657  Glib::ustring filename = Glib::filename_from_uri(d->get_uri(), hostname);
658  Glib::ustring recent_filename = filename;
659  Gtk::RecentManager::Data data;
660  bool result_uncertain;
661  data.mime_type = Gio::content_type_guess(filename, "", result_uncertain);
662  data.app_name = "guitarix";
663  data.groups.push_back("loopfiles");
664  Gtk::RecentManager::get_default()->add_item(d->get_uri(), data);
665  d->hide();
666  machine.set_parameter_value(idf,filename);
667  machine.set_parameter_value(id,0.0);
668  machine.signal_parameter_value<float>(id)(0.0);
669  } else {
670  d->hide();
671  machine.set_parameter_value(id,0.0);
672  machine.signal_parameter_value<float>(id)(0.0);
673  }
674  }
675 
676 void StackBoxBuilder::load_file_f(const std::string& id, const std::string& idf) {
677  Glib::signal_timeout().connect_once(
678  sigc::bind<const std::string>(sigc::bind<const std::string>(sigc::mem_fun(this, &StackBoxBuilder::load_file), idf), id),100);
679 }
680 
681 void StackBoxBuilder::create_fload_switch(const char *sw_type, const std::string& id, const std::string& idf) {
682  //if (machine.get_jack()) {
683  Gtk::Widget *sw = UiSwitch::create(machine, sw_type, id);
684  Gxw::Switch *regler = static_cast<Gxw::Switch*>(sw);
685  //regler->set_relief(Gtk::RELIEF_NONE);
686  regler->set_name("effect_on_off");
687  addwidget(sw);
688  gx_engine::Parameter& p = machine.get_parameter(id);
689  p.signal_changed_float().connect(sigc::hide(
690  sigc::bind<const std::string>(sigc::bind<const std::string>(sigc::mem_fun(this, &StackBoxBuilder::load_file_f), idf), id)));
691  //}
692 }
693 
694 void StackBoxBuilder::create_h_switch(const char *sw_type, const std::string& id, const char *label) {
695  Gtk::Widget* sw = UiHSwitchWithCaption::create(machine, sw_type, id, label);
696  UiHSwitchWithCaption *w = static_cast<UiHSwitchWithCaption*>(sw);
697  //w->get_regler()->set_relief(Gtk::RELIEF_NONE);
698  w->get_regler()->set_name("effect_on_off");
699  if (next_flags & UI_LABEL_INVERSE) {
701  }
702  addwidget(sw);
703 }
704 
705 void StackBoxBuilder::create_v_switch(const char *sw_type, const std::string& id, const char *label) {
706  Gtk::Widget* sw = UiVSwitchWithCaption::create(machine, sw_type, id, label);
707  UiVSwitchWithCaption *w = static_cast<UiVSwitchWithCaption*>(sw);
708  //w->get_regler()->set_relief(Gtk::RELIEF_NONE);
709  w->get_regler()->set_name("effect_on_off");
710  if (next_flags & UI_LABEL_INVERSE) {
712  }
713  addwidget(sw);
714 }
715 
716 void StackBoxBuilder::create_feedback_slider(const std::string& id, const char *label) {
718  Glib::signal_timeout().connect(sigc::bind<const std::string>(
719  sigc::mem_fun(*this, &StackBoxBuilder::set_engine_value),id), 60);
720  w->set_label(label);
721  addwidget(w);
722  }
723 
724 void StackBoxBuilder::create_selector(const std::string& id, const char *widget_name) {
725  gx_engine::Parameter& p = machine.get_parameter(id);
726  Gxw::Selector *s;
727  if (p.isFloat()) {
728  s = new UiSelector<float>(machine, id);
729  } else {
730  s = new UiSelector<int>(machine, id);
731  }
732  if (widget_name) {
733  s->set_name(widget_name);
734  }
735  addwidget(s);
736 }
737 
738 void StackBoxBuilder::create_selector_with_caption(const std::string& id, const char *label) {
739  gx_engine::Parameter& p = machine.get_parameter(id);
740  Gtk::VBox *s;
741  if (p.isFloat()) {
743  s = new UiSelectorWithCaption<float>(machine, id, label);
744  sel = static_cast<UiSelectorWithCaption<float>*>(s);
745  if (next_flags & UI_LABEL_INVERSE) {
746  sel->set_rack_label_inverse();
747  }
748  } else {
750  s = new UiSelectorWithCaption<int>(machine, id, label);
751  sel = static_cast<UiSelectorWithCaption<int>*>(s);
752  if (next_flags & UI_LABEL_INVERSE) {
753  sel->set_rack_label_inverse();
754  }
755  }
756  addwidget(s);
757 }
758 
759 void StackBoxBuilder::openSpaceBox(const char* label) {
760  GxVBox * box = new GxVBox();
761  box->set_homogeneous(true);
762  box->set_spacing(1);
763  box->set_border_width(4);
764  box->show_all();
765  if (!fBox.top_is_notebook() && label && label[0]) {
766  fBox.box_pack_start(manage(box));
767  fBox.push(box);
768  } else {
769  fBox.push(fBox.add(manage(box), label));
770  }
771 }
772 
773 void StackBoxBuilder::check_set_flags(Gxw::Regler *r) {
774  if (next_flags & UI_NUM_SHOW_ALWAYS) {
775  r->set_name("show_always");
776  }
777  if ((next_flags & UI_NUM_POSITION_MASK)) {
778  Gtk::PositionType pos = Gtk::POS_BOTTOM;
779  switch (next_flags & UI_NUM_POSITION_MASK) {
780  case UI_NUM_TOP: pos = Gtk::POS_TOP; break;
781  case UI_NUM_LEFT: pos = Gtk::POS_LEFT; break;
782  case UI_NUM_RIGHT: pos = Gtk::POS_RIGHT; break;
783  }
784  r->set_value_position(pos);
785  }
786 }
787 
788 void StackBoxBuilder::create_mid_rackknob(const std::string& id, const char *label) {
790  if (next_flags & UI_LABEL_INVERSE) {
791  w->set_rack_label_inverse(label);
792  } else {
793  w->set_rack_label(label);
794  }
795  check_set_flags(w->get_regler());
796  addwidget(w);
797 }
798 
799 void StackBoxBuilder::create_small_rackknob(const std::string& id, const char *label) {
801  if (next_flags & UI_LABEL_INVERSE) {
802  w->set_rack_label_inverse(label);
803  } else {
804  w->set_rack_label(label);
805  }
806  check_set_flags(w->get_regler());
807  addwidget(w);
808 }
809 
810 void StackBoxBuilder::create_small_rackknobr(const std::string& id, const char *label) {
812  if (next_flags & UI_LABEL_INVERSE) {
813  w->set_rack_label_inverse(label);
814  } else {
815  w->set_rack_label(label);
816  }
817  check_set_flags(w->get_regler());
818  addwidget(w);
819 }
820 
821 void StackBoxBuilder::create_big_rackknob(const std::string& id, const char *label) {
823  if (next_flags & UI_LABEL_INVERSE) {
824  w->set_rack_label_inverse(label);
825  } else {
826  w->set_rack_label(label);
827  }
828  check_set_flags(w->get_regler());
829  addwidget(w);
830 }
831 
832 void StackBoxBuilder::addLiveWaveDisplay(const char* label) {
833  Gtk::HBox * box = new Gtk::HBox(false, 4);
834  Gtk::VBox * box1 = new Gtk::VBox(false, 0);
835  Gtk::VBox * box2 = new Gtk::VBox(false, 0);
836  Gtk::EventBox* e_box = new Gtk::EventBox();
837  //g_signal_connect(box->gobj(), "expose-event", G_CALLBACK(gx_cairo::conv_widget_expose), NULL);
838  //box->set_size_request(303, 82);
839  e_box->set_size_request(284, 84);
840  //box->set_border_width(12);
841  e_box->add(fWaveView);
842  box->pack_start(*manage(box1), true, true, 0);
843  box->pack_start(*manage(e_box), false, false, 0);
844  box->pack_start(*manage(box2), true, true, 0);
845  fBox.add(manage(box), label);
846  fWaveView.hide(); // was show()'n by addWidget
847  fWaveView.property_text_pos_left() = 1.5;
848  fWaveView.property_text_pos_right() = 77;
849  // multiplicator is already set by signal handler
850  box->show_all();
851 }
852 
853 void StackBoxBuilder::openVerticalBox1(const char* label) {
854  GxVBox * box = new GxVBox();
855  box->set_homogeneous(false);
856  box->set_spacing(1);
857  box->set_border_width(0);
858 
859  if (!fBox.top_is_notebook() && label && label[0]) {
860  box->m_label.set_text(label);
861  box->m_label.set_name("effekt_label");
862  box->pack_start(box->m_label, false, false, 0 );
863  fBox.box_pack_start(manage(box));
864  box->show();
865  box->m_label.show();
866  fBox.push(box);
867  } else {
868  fBox.push(fBox.add(manage(box), label));
869  }
870 }
871 
872 void StackBoxBuilder::openVerticalBox2(const char* label) {
873  Gtk::VPaned * box = new Gtk::VPaned();
874  box->set_border_width(0);
875  GxHBox * pbox = new GxHBox();
876  if (!fBox.top_is_notebook() && label && label[0]) {
877  pbox->m_label.set_text(label);
878  pbox->m_label.set_name("rack_label");
879  pbox->pack_start(pbox->m_label, false, false, 0 );
880  }
881  pbox->set_border_width(0);
882  box->pack1(*Gtk::manage(static_cast<Gtk::Widget*>(pbox)),true,true);
883  GxHBox * hbox = new GxHBox();
884  hbox->set_homogeneous(false);
885  hbox->set_spacing(1);
886  hbox->set_border_width(0);
887  box->pack2(*Gtk::manage(static_cast<Gtk::Widget*>(hbox)),true,true);
888  box->set_position(200);
889  fBox.box_pack_start(manage(box), false, false, 0);
890  box->show_all();
891  fBox.push(hbox);
892 }
893 
894 void StackBoxBuilder::openFlipLabelBox(const char* label) {
895  GxVBox * box = new GxVBox();
896  box->set_homogeneous(false);
897  box->set_spacing(0);
898  box->set_border_width(0);
899 
900  if (!fBox.top_is_notebook() && label && label[0]) {
901  GxVBox * vbox = new GxVBox();
902  vbox->set_homogeneous(false);
903  vbox->set_spacing(0);
904  vbox->set_border_width(0);
905 
906  GxHBox * hbox = new GxHBox();
907  hbox->set_homogeneous(false);
908  hbox->set_spacing(0);
909  hbox->set_border_width(0);
910 
911  hbox->m_label.set_text(label);
912  hbox->m_label.set_name("effekt_label");
913  hbox->m_label.set_angle(90);
914  hbox->m_label.set_size_request(15, -1);
915 
916  Pango::FontDescription font = hbox->m_label.get_style()->get_font();
917  font.set_size(8*Pango::SCALE);
918  font.set_weight(Pango::WEIGHT_BOLD);
919  hbox->m_label.modify_font(font);
920 
921  hbox->add(hbox->m_label);
922  hbox->add(*manage(vbox));
923  box->add(*manage(hbox));
924  fBox.box_pack_start(manage(box), false);
925  box->show_all();
926  fBox.push(vbox);
927  } else {
928  fBox.push(fBox.add(manage(box), label));
929  }
930 }
931 
932 class uiSpinner: public Gtk::SpinButton {
933 private:
934  uiAdjustment adj;
935 public:
936  uiSpinner(float step, gx_engine::GxMachineBase& machine, const std::string& id)
937  : Gtk::SpinButton(step, precision(step)), adj(machine, id, get_adjustment()) {
938  get_adjustment()->signal_value_changed().connect(
939  sigc::mem_fun(adj, &uiAdjustment::changed));
940  }
941 };
942 
943 void StackBoxBuilder::addNumEntry(const std::string& id, const char* label_) {
944  Glib::ustring label(label_);
945  if (!machine.parameter_hasId(id)) {
946  return;
947  }
948  const gx_engine::FloatParameter &p = machine.get_parameter(id).getFloat();
949  if (label.empty()) {
950  label = p.l_name();
951  }
952  float step = p.getStepAsFloat();
953  uiSpinner* spinner = new uiSpinner(step, machine, id);
954  spinner->get_adjustment()->configure(
955  machine.get_parameter_value<float>(id), p.getLowerAsFloat(), p.getUpperAsFloat(), step, 10*step, 0);
956  connect_midi_controller(spinner, id, machine);
957  Gtk::HBox *box = new Gtk::HBox(homogene, 0);
958  Gtk::Label *lab = new Gtk::Label(label);
959  box->add(*manage(lab));
960  lab->set_name("rack_label");
961  fBox.add(manage(box), label);
962  fBox.add(manage(spinner), label);
963 }
964 
965 class uiToggleButton: public Gtk::ToggleButton {
966 private:
967  gx_engine::GxMachineBase& machine;
968  const std::string id;
969 public:
970  uiToggleButton(gx_engine::GxMachineBase& machine_, const std::string& id_);
971  void toggled();
972  void set_value(bool v);
973 };
974 
976  : Gtk::ToggleButton(), machine(machine_), id(id_) {
977  machine.signal_parameter_value<bool>(id).connect(
978  sigc::mem_fun(this, &Gtk::ToggleButton::set_active));
979  signal_toggled().connect(
980  sigc::mem_fun(this, &uiToggleButton::toggled));
981 }
982 
984  machine.set_parameter_value(id, get_active());
985 }
986 
987 void StackBoxBuilder::addMToggleButton(const std::string& id, const char* label_) {
988  Glib::ustring label(label_);
989  if (!machine.parameter_hasId(id)) {
990  return;
991  }
992  const gx_engine::BoolParameter &p = machine.get_parameter(id).getBool();
993  if (label.empty()) {
994  label = p.l_name();
995  }
996  Gdk::Color colorRed("#58b45e");
997  Gdk::Color colorOwn("#7f7f7f");
998  Gdk::Color colorwn("#000000");
999  uiToggleButton* button = new uiToggleButton(machine, id);
1000  Gtk::Label* lab = new Gtk::Label(label);
1001  Pango::FontDescription font = lab->get_style()->get_font();
1002  font.set_weight(Pango::WEIGHT_BOLD);
1003  lab->modify_font(font);
1004  button->add(*manage(lab));
1005  button->set_size_request(70, 20);
1006  Gtk::Box* box = new Gtk::HBox(homogene, 4);
1007  Gtk::Box* box1 = new Gtk::VBox(homogene, 4);
1008  box->set_border_width(0);
1009  box1->set_border_width(0);
1010  box->add(*manage(box1));
1011  Gtk::Box* box2 = new Gtk::VBox(homogene, 4);
1012  box2->set_border_width(0);
1013  box2->set_size_request(6, 20);
1014  box->add(*manage(button));
1015  box->add(*manage(box2));
1016  box1->set_size_request(6, 20);
1017  button->show();
1018  box1->show();
1019  box2->show();
1020  lab->show();
1021  box->show();
1022  fBox.container_add(manage(box));
1023  button->modify_bg(Gtk::STATE_NORMAL, colorOwn);
1024  button->modify_bg(Gtk::STATE_ACTIVE, colorRed);
1025  lab->set_name("rack_label");
1026  connect_midi_controller(button, id, machine);
1027 }
1028 
1029 class uiCheckButton: public Gtk::CheckButton {
1030 private:
1031  gx_engine::GxMachineBase& machine;
1032  const std::string& id;
1033 public:
1034  uiCheckButton(gx_engine::GxMachineBase& machine_, const std::string& id_)
1035  : Gtk::CheckButton(), machine(machine_), id(id_) {
1036  set_active(machine.get_parameter_value<bool>(id));
1037  machine.signal_parameter_value<bool>(id).connect(sigc::mem_fun(this, &Gtk::CheckButton::set_active));
1038  signal_toggled().connect(
1039  sigc::mem_fun(this, &uiCheckButton::toggled));
1040  }
1041  void toggled() {
1042  machine.set_parameter_value(id, get_active());
1043  }
1044 };
1045 
1046 void StackBoxBuilder::addCheckButton(const std::string& id, const char* label_) {
1047  if (!machine.parameter_hasId(id)) {
1048  return;
1049  }
1050  Glib::ustring label;
1051  if (label_ && label_[0]) {
1052  label = label_;
1053  } else {
1054  label = machine.get_parameter(id).getBool().l_name();
1055  }
1056  Gdk::Color colorRed("#000000");
1057  Gdk::Color colorOwn("#4c5159");
1058  Gdk::Color colorba("#c4c0c0");
1059  Gtk::Label *lab = new Gtk::Label(label);
1060  uiCheckButton *button = new uiCheckButton(machine, id);
1061  button->add(*manage(lab));
1062  fBox.add(manage(button), label);
1063  button->modify_bg(Gtk::STATE_PRELIGHT, colorOwn);
1064  button->modify_fg(Gtk::STATE_PRELIGHT, colorRed);
1065  button->modify_text(Gtk::STATE_NORMAL, colorRed);
1066  button->modify_base(Gtk::STATE_NORMAL, colorba);
1067  Glib::RefPtr<Gtk::Style> style = lab->get_style();
1068  style->get_font().set_size(8*Pango::SCALE);
1069  style->get_font().set_weight(Pango::WEIGHT_NORMAL);
1070  lab->modify_font(style->get_font());
1071  connect_midi_controller(button, id, machine);
1072  lab->show();
1073 }
1074 
1075 void StackBoxBuilder::openHorizontalhideBox(const char* label) {
1076  GxHBox * box = new GxHBox();
1077  box->set_homogeneous(false);
1078  box->set_spacing(0);
1079  box->set_border_width(0);
1080  fBox.box_pack_start(manage(box) , false, false, 5);
1081  fBox.push(box);
1082  box->hide();
1083  if (label[0] != 0) {
1084  box->show();
1085  }
1086 }
1087 
1088 void StackBoxBuilder::openHorizontalTableBox(const char* label) {
1089  Gtk::HBox *box;
1090  if (!fBox.top_is_notebook() && label && label[0]) {
1091  GxHFrame *frame = new GxHFrame();
1092  frame->set_label(label);
1093  frame->set_shadow_type(Gtk::SHADOW_NONE);
1094  frame->add(frame->m_hbox);
1095  fBox.box_pack_start(manage(frame), false);
1096  frame->m_hbox.show();
1097  frame->show();
1098  box = &frame->m_hbox;
1099  fBox.push(box);
1100  } else {
1101  box = new Gtk::HBox();
1102  fBox.push(fBox.add(manage(box), label));
1103  }
1104  box->set_homogeneous(false);
1105  box->set_spacing(1);
1106  box->set_border_width(0);
1107 }
1108 
1109 void StackBoxBuilder::openPaintBox2(const char* label) {
1110  GxEventBox *box = new GxEventBox();
1111  box->m_eventbox.set_name(label);
1112  box->set_homogeneous(false);
1113  box->set_spacing(0);
1114  box->set_border_width(0);
1115  fBox.box_pack_start(manage(box), false, false);
1116  box->show_all();
1117  fBox.push(&box->m_hbox);
1118 }
1119 
1120 void StackBoxBuilder::openTabBox(const char* label) {
1121  GxNotebookBox * box = new GxNotebookBox();
1122  fBox.push(fBox.add(manage(box), label));
1123 }
1124 
1125 void StackBoxBuilder::openpaintampBox(const char* label) {
1126  GxPaintBox *box = new GxPaintBox("rectangle_skin_color_expose");
1127  box->m_hbox.set_border_width(4);
1128  box->set_name(label);
1129  box->set_tooltip_text(label);
1130  fBox.box_pack_start(manage(box));
1131  box->show_all();
1132  fBox.push(&box->m_hbox);
1133 }
1134 
1135 void StackBoxBuilder::closeBox() {
1136  assert(!fBox.empty());
1137  fBox.pop();
1138 }
1139 
1140 void StackBoxBuilder::openHorizontalBox(const char* label) {
1141  Gtk::HBox *box;
1142  if (!fBox.top_is_notebook() && label && label[0]) {
1143  GxHFrame *frame = new GxHFrame();
1144  frame->set_label(label);
1145  frame->set_shadow_type(Gtk::SHADOW_NONE);
1146  frame->add(frame->m_hbox);
1147  fBox.box_pack_start(manage(frame), false);
1148  frame->m_hbox.show();
1149  frame->show();
1150  box = &frame->m_hbox;
1151  fBox.push(box);
1152  } else {
1153  box = new Gtk::HBox();
1154  fBox.push(fBox.add(manage(box), label));
1155  }
1156  box->set_homogeneous(false);
1157  box->set_spacing(1);
1158  box->set_border_width(0);
1159 }
1160 
1161 void StackBoxBuilder::openVerticalBox(const char* label) {
1162  GxVBox * box = new GxVBox();
1163  box->set_homogeneous(false);
1164  box->set_spacing(1);
1165  box->set_border_width(0);
1166 
1167  if (!fBox.top_is_notebook() && label && label[0]) {
1168  box->m_label.set_text(label);
1169  box->m_label.set_name("rack_effect_label");
1170  Glib::RefPtr<Gtk::Style> style = box->m_label.get_style();
1171  style->get_font().set_size(8*Pango::SCALE);
1172  style->get_font().set_weight(Pango::WEIGHT_BOLD);
1173  box->m_label.modify_font(style->get_font());
1174  box->pack_start(box->m_label, false, false, 0 );
1175  fBox.box_pack_start(manage(box), false);
1176  box->show();
1177  box->m_label.show();
1178  fBox.push(box);
1179  } else {
1180  fBox.push(fBox.add(manage(box), label));
1181  }
1182 }
1183 
1184 void StackBoxBuilder::openFrameBox(const char* label) {
1185  Gtk::HBox *box;
1186 
1187  if (!fBox.top_is_notebook() && label && label[0]) {
1188  GxHFrame *frame = new GxHFrame();
1189  frame->set_label(label);
1190  frame->set_shadow_type(Gtk::SHADOW_NONE);
1191  frame->add(frame->m_hbox);
1192  fBox.box_pack_start(manage(frame), false);
1193  frame->m_hbox.show();
1194  frame->show();
1195  box = &frame->m_hbox;
1196  fBox.push(box);
1197  } else {
1198  box = new Gtk::HBox();
1199  fBox.push(fBox.add(manage(box), label));
1200  }
1201  box->set_homogeneous(false);
1202  box->set_spacing(1);
1203  box->set_border_width(2);
1204 }
1205 
1206 } // end namespace gx_gui
static Gtk::Widget * create(gx_engine::GxMachineBase &machine, const char *sw_type, const std::string &id, const char *label)
static Gtk::Widget * create(gx_engine::GxMachineBase &machine, const char *sw_type, const std::string &id, const char *label)
virtual float getUpperAsFloat() const
StackBoxBuilder(gx_engine::GxMachineBase &machine_, Gxw::WaveView &fWaveView_, Gtk::Label &convolver_filename_label_, Gtk::Label &convolver_mono_filename_label_, Glib::RefPtr< Gdk::Pixbuf > window_icon)
const char * pb_gxhead_expose
void notebook_append_page(Gtk::Widget *w, Gtk::Widget *label)
void wnotify(gpointer data, GObject *where_the_object_was)
std::string get_builder_filepath(const std::string &basename) const
Definition: gx_system.h:373
const char * pb_zac_expose
void get_box(const std::string &name, Gtk::Widget *&mainbox, Gtk::Widget *&minibox)
void container_add(Gtk::Widget *w)
virtual Parameter & get_parameter(const std::string &id)=0
static UiSwitch * create(gx_engine::GxMachineBase &machine, const char *sw_type, gx_engine::Parameter &param)
#define UI_NUM_POSITION_MASK
Definition: gx_plugin.h:43
#define UI_LABEL_INVERSE
Definition: gx_plugin.h:45
virtual gx_jack::GxJack * get_jack()=0
void set_c_level(double lvl)
Definition: fastmeter.cc:142
virtual float getLowerAsFloat() const
const char * pb_gx_rack_amp_expose
int precision(double n)
const std::string & get_loop_dir() const
Definition: gx_system.h:476
void set_label(const char *label)
sigc::signal< void, const GxJConvSettings * > & signal_changed()
Gtk::EventBox m_eventbox
#define UI_NUM_TOP
Definition: gx_plugin.h:39
const Glib::ustring & get_rpcaddress()
Definition: gx_system.h:492
void gx_print_error(const char *, const std::string &)
Definition: gx_logging.cpp:166
sigc::signal< void, float > & signal_changed_float()
Definition: gx_parameter.h:484
void cp_set_value(double value)
Gtk::Widget * add(Gtk::Widget *w, const Glib::ustring &label=Glib::ustring())
void set_rack_label(const char *label)
T get_parameter_value(const std::string &id)
bool isFloat() const
Definition: gx_parameter.h:163
const char * pb_RackBox_expose
#define UI_NUM_LEFT
Definition: gx_plugin.h:41
string l_name() const
Definition: gx_parameter.h:177
virtual bool parameter_hasId(const char *p)=0
uiToggleButton(gx_engine::GxMachineBase &machine_, const std::string &id_)
const std::string & getIRFile() const
virtual void set_parameter_value(const std::string &id, int value)=0
const char * pb_level_meter_expose
void set_state(int cutoff_low, int cutoff_high)
Definition: portdisplay.cc:54
std::string to_string(const T &t)
Definition: gx_system.h:525
void connect_midi_controller(Gtk::Widget *w, const std::string &id, gx_engine::GxMachineBase &machine)
void push(Gtk::Widget *w)
void set_rack_label_inverse(const char *label)
void set_value_position(Gtk::PositionType p1)
Definition: regler.cc:477
void set_hold_count(int val)
Definition: fastmeter.cc:152
FloatParameter & getFloat()
Definition: gx_parameter.h:453
virtual gx_system::CmdlineOptions & get_options() const =0
virtual float getStepAsFloat() const
struct _GxPaintBox GxPaintBox
Definition: paintbox.h:32
const GxJConvSettings & get_value() const
bool button_press_cb(GdkEventButton *event, gx_engine::GxMachineBase &machine, const std::string &id)
Gtk::Label m_label
uiCheckButton(gx_engine::GxMachineBase &machine_, const std::string &id_)
void set_by_power(double lvl)
Definition: fastmeter.cc:137
const char * pb_rectangle_skin_color_expose
uiSpinner(float step, gx_engine::GxMachineBase &machine, const std::string &id)
void box_pack_start(Gtk::Widget *w, bool expand=true, bool fill=true, int padding=0)
void trace_finalize(Glib::Object *o, int n)
Gtk::Label m_label
#define UI_NUM_RIGHT
Definition: gx_plugin.h:42
const char * pb_gxrack_expose
void fetch(Gtk::Widget *&mainbox, Gtk::Widget *&minibox)
virtual bool midi_get_config_mode(int *ctl=0)=0
sigc::signal< void, T > & signal_parameter_value(const std::string &id)
BoolParameter & getBool()
Definition: gx_parameter.h:469
std::string fformat(float value, float step)
#define UI_NUM_SHOW_ALWAYS
Definition: gx_plugin.h:44