Guitarix
gx_main_window.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 is the gx_head GUI main class
21  *
22  * ----------------------------------------------------------------------------
23  */
24 
25 template <class T>
26 class UiToggleAction: public Gtk::ToggleAction {
27 private:
28  gx_engine::GxMachineBase& machine;
29  std::string id;
30  void on_toggled();
31 protected:
33  gx_engine::GxMachineBase& machine_, const std::string& id, const Glib::ustring& name, const Glib::ustring& icon_name,
34  const Glib::ustring& label=Glib::ustring(), const Glib::ustring& tooltip=Glib::ustring(),
35  bool is_active=false);
37 public:
38  static Glib::RefPtr<UiToggleAction> create(
39  gx_engine::GxMachineBase& machine, const std::string& id, const Glib::ustring& name, const Glib::ustring& label=Glib::ustring(),
40  const Glib::ustring& tooltip=Glib::ustring(), bool is_active=false) {
41  return Glib::RefPtr<UiToggleAction>(
42  new UiToggleAction(machine, id, name, Glib::ustring(), label, tooltip, is_active));
43  }
44 };
45 
47 typedef UiBoolToggleAction UiSwitchToggleAction;
48 
49 
50 /****************************************************************
51  ** class KeySwitcher
52  */
53 
54 class KeySwitcher: public sigc::trackable {
55 private:
56  gx_engine::GxMachineBase& machine;
57  sigc::slot<void, const Glib::ustring&, const Glib::ustring&> display;
58  sigc::connection key_timeout;
59  Glib::ustring last_bank_key;
60 private:
61  void display_empty(const Glib::ustring& bank, const Glib::ustring& preset);
62  bool display_selected_bank();
63  bool display_current();
64 public:
66  sigc::slot<void, const Glib::ustring&, const Glib::ustring&> display_)
67  : machine(machine_), display(display_) {}
68  bool process_bank_key(int idx);
69  bool process_preset_key(int idx);
70  void display_key_error();
71  void deactivate();
72 };
73 
74 
75 /****************************************************************
76  ** class Liveplay
77  */
78 
79 class Liveplay: public sigc::trackable {
80 private:
81  Glib::RefPtr<gx_gui::GxBuilder> bld;
82  gx_engine::GxMachineBase &machine;
83  const GxActions& actions;
84  bool use_composite;
85  Gtk::Adjustment *brightness_adj;
86  Gtk::Adjustment *background_adj;
87  KeySwitcher keyswitch;
88  sigc::connection midi_conn;
89  Gtk::Window *window;
90  sigc::connection mouse_hide_conn;
91  //
92  Gtk::Image *bypass_image;
93  Gtk::Image *mute_image;
94  Gtk::Label *liveplay_bank;
95  Gtk::Label *liveplay_preset;
96  Gtk::Widget *liveplay_canvas;
97  Gxw::HSlider *brightness_slider;
98  Gtk::Box *brightness_box;
99  Gxw::HSlider *background_slider;
100  Gtk::ToggleButton *liveplay_exit;
101  Gtk::Table *midictrl_table;
102  Gxw::RackTuner *tuner;
103 private:
104  void add_midi_elements();
105  bool on_delete(GdkEventAny *ev);
106  void on_brightness_changed();
107  void on_background_changed();
108  bool transparent_expose(GdkEventExpose *event);
109  bool window_expose_event(GdkEventExpose* event);
110  void on_realize();
111  void on_engine_state_change(gx_engine::GxEngineState state);
112  void on_selection_done(bool v);
113  void on_selection_changed();
114  static bool do_action(
115  GtkAccelGroup *accel_group, GObject *acceleratable,
116  guint keyval, GdkModifierType modifier, GtkAction* act);
117  static bool on_keyboard_preset_select(
118  GtkAccelGroup *accel_group, GObject *acceleratable,
119  guint keyval, GdkModifierType modifier, Liveplay& self);
120  static bool on_keyboard_toggle_mute(
121  GtkAccelGroup *accel_group, GObject *acceleratable,
122  guint keyval, GdkModifierType modifier, Liveplay& self);
123  static bool on_keyboard_toggle_bypass(
124  GtkAccelGroup *accel_group, GObject *acceleratable,
125  guint keyval, GdkModifierType modifier, Liveplay& self);
126  static bool on_keyboard_arrows(
127  GtkAccelGroup *accel_group, GObject *acceleratable,
128  guint keyval, GdkModifierType modifier, Liveplay& self);
129  static bool on_keyboard_mode_switch(
130  GtkAccelGroup *accel_group, GObject *acceleratable,
131  guint keyval, GdkModifierType modifier, Liveplay& self);
132  bool pointer_motion(GdkEventMotion* event);
133  void display(const Glib::ustring& bank, const Glib::ustring& preset);
134  void set_display_state(TunerSwitcher::SwitcherState s);
135 public:
137  const std::string& fname, const GxActions& actions);
138  ~Liveplay();
139  void on_live_play(Glib::RefPtr<Gtk::ToggleAction> act);
140  void display_tuner(bool v);
141  Gxw::RackTuner& get_tuner() { return *tuner; }
142 };
143 
144 
145 /****************************************************************
146  ** class PluginUI
147  */
148 
149 class MainWindow;
150 class RackBox;
151 
152 class PluginUI: public sigc::trackable {
153 private:
154  Gtk::UIManager::ui_merge_id merge_id;
155  Glib::RefPtr<Gtk::ToggleAction> action;
156  void on_action_toggled();
157 public:
159  Glib::ustring tooltip;
160  const char *shortname;
161 
162  // data for ToolPalette entry
163  Glib::RefPtr<Gdk::Pixbuf> icon;
164  Gtk::ToolItemGroup *group;
165  Gtk::ToolItem *toolitem;
166 
169  bool hidden;
171 
172  PluginUI(MainWindow& main, const char* id_,
173  const Glib::ustring& tooltip_="");
174  virtual ~PluginUI();
176  return (plugin->get_pdef()->flags & PGN_STEREO) ? PLUGIN_TYPE_STEREO : PLUGIN_TYPE_MONO;
177  }
178  const char *get_id() const { return plugin->get_pdef()->id; }
179  const char *get_name() const { return plugin->get_pdef()->name; }
180  void display(bool v, bool animate);
181  void display_new(bool unordered = false);
182  void set_ui_merge_id(Gtk::UIManager::ui_merge_id id) { merge_id = id; }
183  void unset_ui_merge_id(Glib::RefPtr<Gtk::UIManager> uimanager);
184  void set_action(Glib::RefPtr<Gtk::ToggleAction>& act);
185  void set_active(bool v) { if (action) action->set_active(v); }
186  Glib::RefPtr<Gtk::ToggleAction> get_action() { return action; }
187  static bool is_registered(gx_engine::GxMachineBase& m, const char *name);
188  virtual void on_plugin_preset_popup();
189  inline const char *get_category() {
190  const char *cat = plugin->get_pdef()->category;
191  return (cat && *cat) ? cat : N_("External");
192  }
193  inline const char *get_shortname() const {
194  const char *name = shortname;
195  if (!name) {
196  name = plugin->get_pdef()->shortname;
197  }
198  if (!name || !*name) {
199  name = get_name();
200  }
201  return name;
202  }
203  void update_rackbox();
204  void compress(bool state);
205  void hide(bool animate);
206  void show(bool animate);
207  friend bool plugins_by_name_less(PluginUI *a, PluginUI *b);
208 };
209 
211 
212 /****************************************************************
213  ** class PluginDict
214  */
215 
216 class PluginDict: private std::map<std::string, PluginUI*> {
217 public:
218  typedef std::map<std::string, PluginUI*>::iterator iterator;
219  PluginDict(): std::map<std::string, PluginUI*>() {}
220  ~PluginDict();
221  void cleanup();
222  void add(PluginUI *p);
223  void remove(PluginUI *p);
224  PluginUI *operator[](const std::string& s) { return find(s)->second; }
225  using std::map<std::string, PluginUI*>::begin;
227  void compress(bool state);
228 };
229 
230 
231 /****************************************************************
232  ** class DragIcon
233  */
234 
235 class DragIcon {
236 private:
237  enum { gradient_length = 40 };
238  Gtk::Window *window;
239  Glib::RefPtr<Gdk::Pixbuf> drag_icon_pixbuf;
240 private:
241  bool icon_expose_event(GdkEventExpose *ev);
242  void create_drag_icon_pixbuf(const PluginUI& plugin, Glib::RefPtr<Gdk::Colormap> rgba, gx_system::CmdlineOptions& options);
243  bool window_expose_event(GdkEventExpose *event, Gtk::OffscreenWindow& w);
244 public:
245  DragIcon(const PluginUI& plugin, Glib::RefPtr<Gdk::DragContext> context, gx_system::CmdlineOptions& options, int xoff=0);
246  ~DragIcon();
247 };
248 
249 
250 /****************************************************************
251  ** class RackBox, class MiniRackBox
252  */
253 
254 //#define USE_SZG // use a SizeGroup instead of predefined width for Gxw::Switch("switchit")
255 
256 class MiniRackBox;
257 class RackContainer;
258 
259 class RackBox: public Gtk::VBox {
260 private:
261 #ifdef USE_SZG
262  static Glib::RefPtr<Gtk::SizeGroup> szg;
263 #endif
264  PluginUI& plugin;
265  MainWindow& main;
266  bool config_mode;
267  sigc::connection anim_tag;
268  bool compress;
269  bool delete_button;
270  Gxw::PaintBox mbox;
271  MiniRackBox* minibox;
272  Gtk::Widget *fbox;
273  std::string target;
274  int anim_height;
275  int anim_step;
276  DragIcon *drag_icon;
277  int target_height;
278  Gxw::PaintBox box;
279  bool box_visible;
280  Gxw::Switch on_off_switch;
281  gx_gui::uiToggle<bool> toggle_on_off;
282 private:
283  static void set_paintbox(Gxw::PaintBox& pb, PluginType tp);
284  static void set_paintbox_unit(Gxw::PaintBox& pb, PluginType tp);
285  static void set_paintbox_unit_shrink(Gxw::PaintBox& pb, PluginType tp);
286  static Gtk::Widget *make_label(const PluginUI& plugin, gx_system::CmdlineOptions& options, bool useshort=true);
287  static Gtk::Widget *make_bar(int left=4, int right=4, bool sens=false);
288  Gtk::Widget *wrap_bar(int left=4, int right=4, bool sens=false);
289  void init_dnd();
290  void enable_drag(bool v);
291  bool animate_vanish();
292  void animate_remove();
293  void on_my_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
294  bool animate_create();
295  bool on_my_leave_out(GdkEventCrossing *focus);
296  bool on_my_enter_in(GdkEventCrossing *focus);
297  bool on_my_button_press(GdkEventButton* ev);
298  void on_my_drag_end(const Glib::RefPtr<Gdk::DragContext>& context);
299  void on_my_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp);
300  void vis_switch(Gtk::Widget& a, Gtk::Widget& b);
301  void set_visibility(bool v);
302  Gtk::Button *make_expand_button(bool expand);
303  Gtk::Button *make_preset_button();
304  Gtk::HBox *make_full_box(gx_system::CmdlineOptions& options);
305  Gtk::VBox *switcher_vbox(gx_system::CmdlineOptions& options);
306  bool has_delete() const { return delete_button; }
307  void do_expand();
308 public:
309  RackBox(PluginUI& plugin, MainWindow& main, Gtk::Widget* bare=0);
310  static Gtk::Widget *create_drag_widget(const PluginUI& plugin, gx_system::CmdlineOptions& options);
311  RackContainer *get_parent();
312  bool can_compress() { return compress; }
313  friend class MiniRackBox;
314  const char *get_id() const { return plugin.get_id(); }
315  void set_config_mode(bool mode);
316  void swtch(bool mini);
317  void pack(Gtk::Widget *mainbox, Gtk::Widget *minibox, const Glib::RefPtr<Gtk::SizeGroup>& szg);
318  void animate_insert();
319  static Gtk::Widget *create_icon_widget(const PluginUI& plugin, gx_system::CmdlineOptions& options);
320  void setOrder(int pos, int post_pre);
321  void display(bool v, bool animate);
322  bool get_plug_visible() { return plugin.plugin->get_plug_visible(); }
323  bool get_box_visible() { return box_visible; }
324 };
325 
326 class MiniRackBox: public Gtk::HBox {
327 private:
328  static Glib::RefPtr<Gtk::SizeGroup> szg_label;
329  Gtk::EventBox evbox;
330  Gtk::HBox mconbox;
331  Gtk::Button *mb_expand_button;
332  Gtk::Widget *mb_delete_button;
333  Gtk::Button *preset_button;
334  Gxw::Switch on_off_switch;
335  bool on_my_leave_out(GdkEventCrossing *focus);
336  bool on_my_enter_in(GdkEventCrossing *focus);
337  gx_gui::uiToggle<bool> toggle_on_off;
338 private:
339  Gtk::Widget *make_delete_button(RackBox& rb);
340 public:
342  void set_config_mode(bool mode);
343  void pack(Gtk::Widget *w);
344 };
345 
346 /****************************************************************
347  ** class RackContainer
348  */
349 
350 class RackContainer: public Gtk::VBox {
351 private:
352  PluginType tp;
353  MainWindow& main;
354  bool config_mode;
355  int in_drag;
356  int child_count;
357  std::vector<std::string> targets;
358  std::vector<std::string> othertargets;
359  sigc::connection highlight_connection;
360  sigc::connection autoscroll_connection;
361 private:
362  using Gtk::VBox::add;
363  bool drag_highlight_expose(GdkEventExpose *event, int y0);
364  void find_index(int x, int y, int* len, int *ypos);
365  void on_my_remove(Gtk::Widget*);
366  bool check_targets(const std::vector<std::string>& tgts1, const std::vector<std::string>& tgts2);
367  virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint timestamp);
368  virtual void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint timestamp);
369  virtual void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint timestamp);
370  virtual void on_add(Widget* ch);
371  void unit_order_changed(bool stereo);
372  void renumber();
373  bool scroll_timeout();
374  bool scrollother_timeout();
375 public:
376  typedef Glib::ListHandle<const RackBox*> rackbox_const_list;
377  typedef Glib::ListHandle<RackBox*> rackbox_list;
379  rackbox_list get_children() {
380  return rackbox_list(
381  gtk_container_get_children(GTK_CONTAINER(gobj())),
382  Glib::OWNERSHIP_SHALLOW);
383  }
384  rackbox_const_list get_children() const {
385  return rackbox_const_list(
386  gtk_container_get_children(const_cast<GtkContainer*>(GTK_CONTAINER(gobj()))),
387  Glib::OWNERSHIP_SHALLOW);
388  }
389  inline bool check_if_animate(const RackBox& rackbox);
390  void show_entries();
391  void hide_entries();
392  void set_config_mode(bool mode);
393  bool empty() const { return child_count == 0; }
394  void add(RackBox& r, int pos=-1);
395  void check_order();
396  void ensure_visible(RackBox& child);
397  void reorder(const std::string& name, unsigned int pos);
398  void increment();
399  void decrement();
400  inline void resize_finished();
401 };
402 
403 
404 /****************************************************************
405  ** class TextLoggingBox
406  */
407 
408 class TextLoggingBox: public Gtk::Window {
409 private:
410  struct tab_table {
411  const char *tagname;
412  const char *tag_color;
413  };
414  Gtk::VBox box;
415  Gtk::Button ok_button;
416  Gtk::HButtonBox buttonbox;
417  Gtk::ScrolledWindow scrollbox;
418  Gtk::TextView tbox;
419  static tab_table tagdefs[GxLogger::kMessageTypeCount];
420  Glib::RefPtr<Gtk::TextTag> tags[GxLogger::kMessageTypeCount];
421  int highest_unseen_msg_level;
422  sigc::signal<void> msg_level_changed;
423 private:
424  virtual bool on_key_press_event(GdkEventKey *event);
425  void show_msg(string msgbuf, GxLogger::MsgType msgtype, bool plugged);
426  virtual void on_show();
427  virtual void on_hide();
428 public:
429  TextLoggingBox();
430  ~TextLoggingBox();
431  void reset_msg_level();
432  int get_unseen_msg_level() { return highest_unseen_msg_level; }
433  sigc::signal<void>& signal_msg_level_changed() { return msg_level_changed; }
434 };
435 
436 
437 /****************************************************************
438  ** class MainWindow
439  */
440 
441 class Freezer {
442 private:
443  Gtk::Window *window;
444  sigc::connection tag;
445  bool need_thaw;
446  int size_x;
447  int size_y;
448  sigc::slot<void> work;
449 private:
450  void do_thaw();
451  bool thaw_timeout();
452  void freeze(Gtk::Window *w, int width, int height);
453  void thaw();
454 public:
455  Freezer();
456  ~Freezer();
457  void freeze_until_width_update(Gtk::Window *w, int width);
458  void set_slot(sigc::slot<void> w);
459  void freeze_and_size_request(Gtk::Window *w, int width, int height);
460  bool check_thaw(int width, int height);
461 };
462 
463 
464 /****************************************************************
465  ** class PluginPresetPopup
466  */
467 
468 class PluginPresetPopup: public Gtk::Menu {
469 private:
470  const PluginDef *pdef;
471  gx_engine::GxMachineBase& machine;
472  const Glib::ustring save_name_default;
473  gx_preset::UnitPresetList presetnames;
474  void set_plugin_std_preset();
475  void set_plugin_preset(bool factory, const Glib::ustring& name);
476  bool add_plugin_preset_list(bool *found);
477  void save_plugin_preset();
478  void remove_plugin_preset();
479 protected:
480  virtual void on_selection_done();
481 public:
483  const Glib::ustring& save_name_default = "");
484  gx_preset::UnitPresetList::const_iterator begin() { return presetnames.begin(); }
485  gx_preset::UnitPresetList::const_iterator end() { return presetnames.end(); }
486  const PluginDef *get_pdef() { return pdef; }
487  gx_engine::GxMachineBase& get_machine() { return machine; }
488 };
489 
490 
491 /****************************************************************
492  ** GxUiRadioMenu
493  ** adds the values of an EnumParameter as Gtk::RadioMenuItem's
494  ** to a Gtk::MenuShell
495  */
496 
498 private:
499  gx_engine::GxMachineBase& machine;
500  const std::string id;
501  Glib::RefPtr<Gtk::RadioAction> action;
502  void set_value(unsigned int v);
503  void on_changed(Glib::RefPtr<Gtk::RadioAction> act);
504 public:
505  GxUiRadioMenu(gx_engine::GxMachineBase& machine, const std::string& id);
506  void setup(const Glib::ustring& prefix, const Glib::ustring& postfix,
507  Glib::RefPtr<Gtk::UIManager>& uimanager, Glib::RefPtr<Gtk::ActionGroup>& actiongroup);
508 };
509 
510 
511 struct GxActions {
512  // Main Window
513  Glib::RefPtr<Gtk::ActionGroup> group;
514  Glib::RefPtr<Gtk::AccelGroup> accels;
515 
516  Glib::RefPtr<Gtk::Action> quit;
517  Glib::RefPtr<Gtk::Action> compress;
518  Glib::RefPtr<Gtk::Action> expand;
519  Glib::RefPtr<Gtk::Action> jack_latency_menu;
520  Glib::RefPtr<Gtk::Action> osc_buffer_menu;
521  Glib::RefPtr<Gtk::Action> jackstartup;
522  Glib::RefPtr<Gtk::Action> loadladspa;
523 
524  Glib::RefPtr<Gtk::ToggleAction> rack_config;
525  Glib::RefPtr<Gtk::ToggleAction> live_play;
526  Glib::RefPtr<Gtk::ToggleAction> engine_mute;
527  sigc::connection engine_mute_conn;
528  Glib::RefPtr<Gtk::ToggleAction> engine_bypass;
529  sigc::connection engine_bypass_conn;
530  Glib::RefPtr<Gtk::ToggleAction> jackserverconnection;
531  Glib::RefPtr<Gtk::ToggleAction> jackports;
532  Glib::RefPtr<Gtk::ToggleAction> midicontroller;
533  Glib::RefPtr<Gtk::ToggleAction> meterbridge;
534  Glib::RefPtr<Gtk::ToggleAction> loggingbox;
535  Glib::RefPtr<Gtk::ToggleAction> animations;
536 
537  Glib::RefPtr<Gtk::ToggleAction> show_plugin_bar;
538  Glib::RefPtr<Gtk::ToggleAction> presets;
539  Glib::RefPtr<Gtk::ToggleAction> show_rack;
540  Glib::RefPtr<UiBoolToggleAction> tuner;
541  Glib::RefPtr<UiBoolToggleAction> livetuner;
542  Glib::RefPtr<UiBoolToggleAction> midi_out;
543  Glib::RefPtr<UiBoolToggleAction> midi_out_plug;
544  Glib::RefPtr<Gtk::ToggleAction> show_values;
545  Glib::RefPtr<Gtk::ToggleAction> tooltips;
546  Glib::RefPtr<UiSwitchToggleAction> midi_in_presets;
547  Glib::RefPtr<Gtk::ToggleAction> rackh;
548 
549  Glib::RefPtr<Gtk::RadioAction> skin;
550  Glib::RefPtr<Gtk::RadioAction> latency;
551  Glib::RefPtr<Gtk::RadioAction> osc_buffer_size;
552 
553  // preset window
554  Glib::RefPtr<Gtk::Action> new_bank;
555  Glib::RefPtr<Gtk::Action> save_changes;
556  Glib::RefPtr<Gtk::ToggleAction> organize;
557  Glib::RefPtr<Gtk::Action> online_preset_bank;
558 };
559 
560 class MainWindow: public sigc::trackable {
561 private:
562  gx_system::CmdlineOptions& options;
563  gx_engine::GxMachineBase& machine;
564  Glib::RefPtr<gx_gui::GxBuilder> bld;
565  Freezer freezer;
566  PluginDict plugin_dict;
567  int oldpos;
568  int scrl_size_x;
569  int scrl_size_y;
570  RackContainer monorackcontainer;
571  RackContainer stereorackcontainer;
572  int pre_act;
573  bool is_visible;
574  // bool ui_sleep();
575  DragIcon *drag_icon;
576  Glib::ustring preset_list_menu_bank;
577  Gtk::UIManager::ui_merge_id preset_list_merge_id;
578  Glib::RefPtr<Gtk::ActionGroup> preset_list_actiongroup;
579  Glib::RefPtr<Gtk::UIManager> uimanager;
580  Liveplay *live_play;
581  PresetWindow *preset_window;
582  Gxw::WaveView fWaveView;
583  Gtk::Label convolver_filename_label;
584  Gtk::Label convolver_mono_filename_label;
585  Glib::RefPtr<Gdk::Pixbuf> gx_head_icon;
586  gx_gui::StackBoxBuilder boxbuilder;
587  gx_portmap::PortMapWindow* portmap_window;
588  gx_gui::SelectJackControlPgm *select_jack_control;
589  TextLoggingBox fLoggingWindow;
590  GxUiRadioMenu amp_radio_menu;
591  Glib::RefPtr<Gdk::Pixbuf> pixbuf_insert_on;
592  Glib::RefPtr<Gdk::Pixbuf> pixbuf_insert_off;
593  Glib::RefPtr<Gdk::Pixbuf> pixbuf_on;
594  Glib::RefPtr<Gdk::Pixbuf> pixbuf_off;
595  Glib::RefPtr<Gdk::Pixbuf> pixbuf_bypass;
596  Glib::RefPtr<Gdk::Pixbuf> pixbuf_jack_connected;
597  Glib::RefPtr<Gdk::Pixbuf> pixbuf_jack_disconnected;
598  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_grey;
599  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_yellow;
600  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_red;
601  bool in_session;
602  Glib::RefPtr<Gtk::StatusIcon> status_icon;
603  Glib::RefPtr<Gdk::Pixbuf> gx_head_midi;
604  Glib::RefPtr<Gdk::Pixbuf> gx_head_warn;
605  GxActions actions;
606  KeySwitcher keyswitch;
607  std::map<Glib::ustring, Gtk::ToolItemGroup*> groupmap;
608  ladspa::PluginDisplay *ladspalist_window;
609  Glib::RefPtr<Gtk::SizeGroup> szg_rack_units;
610 
611  // Widget pointers
612  Gxw::PaintBox *tunerbox;
613  Gtk::ScrolledWindow *vrack_scrolledbox;
614  Gtk::HBox *stereorackcontainerH;
615  Gtk::HBox *stereorackcontainerV;
616  Gxw::PaintBox *rackcontainer;
617  Gtk::ScrolledWindow *stereorackbox;
618  Gtk::VBox *monocontainer;
619  Gxw::PaintBox *monoampcontainer;
620  Gtk::VPaned *main_vpaned;
621  Gtk::HBox *amp_toplevel_box;
622  Gtk::VBox *monobox;
623  Gtk::VBox *upper_rackbox;
624  Gtk::ScrolledWindow *preset_scrolledbox;
625  Gtk::Box *preset_box_no_rack;
626  Gxw::PaintBox *effects_frame_paintbox;
627  Gtk::Image *insert_image;
628  Gtk::Image *status_image;
629  Gtk::Image *jackd_image;
630  Gtk::Image *logstate_image;
631  Gtk::Window *window;
632  Gtk::HBox *menubox;
633  Gtk::ToggleButton *show_rack_button;
634  Gtk::ToggleButton *rack_order_h_button;
635  Gtk::ToggleButton *config_mode_button;
636  Gtk::ToggleButton *liveplay_button;
637  Gtk::ToggleButton *tuner_button;
638  Gtk::ToggleButton *effects_button;
639  Gtk::ToggleButton *presets_button;
640  Gtk::Button *compress_button;
641  Gtk::Button *expand_button;
642  Gtk::ToolPalette *effects_toolpalette;
643  Gxw::PaintBox *amp_background;
644  Gxw::Switch *tuner_on_off;
645  Gxw::Selector *tuner_mode;
646  Gxw::ValueDisplay *tuner_reference_pitch;
647  Gxw::Selector *tuner_tuning;
648  Gxw::Selector *tuner_temperament;
649  Gxw::RackTuner *racktuner;
650  Gtk::Button *ampdetail_compress;
651  Gtk::Button *ampdetail_expand;
652  Gtk::Widget *ampdetail_mini;
653  Gtk::Widget *ampdetail_normal;
654  Gxw::FastMeter *fastmeter[2];
655  Gtk::Entry *preset_status;
656  Gtk::Container *midi_out_box;
657  Gtk::Container *midi_out_normal;
658  Gtk::Container *midi_out_mini;
659  Gtk::Button *midi_out_compress;
660  Gtk::Button *midi_out_expand;
661  Gtk::Button *midi_out_presets_mini;
662  Gtk::Button *midi_out_presets_normal;
663  Gtk::RadioButton *channel1_button;
664  Gtk::Container *channel1_box;
665  Gtk::RadioButton *channel2_button;
666  Gtk::Container *channel2_box;
667  Gtk::RadioButton *channel3_button;
668  Gtk::Container *channel3_box;
669  Gtk::Alignment *vbam;
670  GdkPixbuf *hanl;
671  GdkPixbuf *hanr;
672 
673 private:
674  bool on_my_leave_out(GdkEventCrossing *focus);
675  bool on_my_enter_in(GdkEventCrossing *focus);
676  void load_widget_pointers();
677  void maybe_shrink_horizontally(bool preset_no_rack=false);
678  void on_show_tuner();
679  bool is_variable_size();
680  void maybe_change_resizable(void);
681  void on_show_rack();
682  void on_preset_action();
683  void on_compress_all();
684  void on_expand_all();
685  void on_show_plugin_bar();
686  void on_rack_configuration();
687  void set_tooltips();
688  void set_animations();
689  void move_widget(Gtk::Widget& w, Gtk::Box& b1, Gtk::Box& b2);
690  int rackbox_stacked_vertical() const;
691  void change_expand(Gtk::Widget& w, bool value);
692  void on_dir_changed();
693  void on_configure_event(GdkEventConfigure *ev);
694  void clear_box(Gtk::Container& box);
695  RackBox *add_rackbox_internal(PluginUI& plugin, Gtk::Widget *mainwidget, Gtk::Widget *miniwidget,
696  bool mini=false, int pos=-1, bool animate=false, Gtk::Widget *bare=0);
697  void on_show_values();
698  void create_actions();
699  void add_toolitem(PluginUI& pl, Gtk::ToolItemGroup *gw);
700  bool on_visibility_notify(GdkEventVisibility *ev);
701  void on_live_play();
702  void on_ti_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, const PluginUI& plugin);
703  void on_ti_drag_end(const Glib::RefPtr<Gdk::DragContext>& context);
704  void on_ti_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp, const char *effect_id);
705  void on_ti_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context, const char *effect_id);
706  bool on_ti_button_press(GdkEventButton *ev, const char *effect_id);
707  void on_tp_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, int info, int timestamp);
708  void fill_pluginlist();
709  void make_icons(bool force=true);
710  void jack_connection();
711  void on_miditable_toggle();
712  void on_portmap_activate();
713  void on_portmap_response(int);
714  bool connect_jack(bool v, Gtk::Window *splash = 0);
715  int start_jack();
716  void add_skin_menu();
717  void change_skin(Glib::RefPtr<Gtk::RadioAction> action);
718  void on_jack_client_changed();
719  void add_latency_menu();
720  void change_latency(Glib::RefPtr<Gtk::RadioAction> action);
721  void user_disable_latency_warn(Gtk::CheckButton* disable_warn);
722  int gx_wait_latency_warn();
723  void set_latency();
724  void set_osc_size();
725  void add_osc_size_menu();
726  void change_osc_buffer(Glib::RefPtr<Gtk::RadioAction> action);
727  void on_select_jack_control();
728  void on_load_ladspa();
729  void delete_select_jack_control();
730  void on_log_activate();
731  bool on_log_activated(GdkEventButton* ev);
732  bool on_log_scrolled(GdkEventScroll* ev);
733  void do_program_change(int pgm);
734  void on_engine_toggled();
735  void on_engine_state_change(gx_engine::GxEngineState state);
736  void set_new_skin(const Glib::ustring& skin_name);
737  void set_tuning(Gxw::RackTuner& tuner);
738  void set_tuner_tet(Gxw::RackTuner& tuner);
739  void set_tuner_ref(Gxw::RackTuner& tuner);
740  void setup_tuner_temperament(Gxw::RackTuner& tuner);
741  void setup_tuner(Gxw::RackTuner& tuner);
742  bool on_toggle_mute(GdkEventButton* ev);
743  bool on_scroll_toggle(GdkEventScroll* ev);
744  bool on_toggle_insert(GdkEventButton* ev);
745  bool on_scroll_toggle_insert(GdkEventScroll* ev);
746  void on_insert_jack_changed(bool s);
747  bool on_jackserverconnection(GdkEventButton* ev);
748  bool on_jackserverconnection_scroll(GdkEventScroll* ev);
749  void on_msg_level_changed();
750  void on_ampdetail_switch(bool compress, bool setparam);
751  void on_show_oscilloscope(bool v);
752  void set_waveview_buffer(unsigned int size);
753  void on_oscilloscope_post_pre(int post_pre);
754  int on_oscilloscope_activate(bool start);
755  bool on_refresh_oscilloscope();
756  bool refresh_meter_level(float falloff);
757  bool survive_jack_shutdown();
758  void gx_jack_is_down();
759  void jack_session_event();
760  void jack_session_event_ins();
761  void set_in_session();
762  void hide_extended_settings();
763  void systray_menu(guint button, guint32 activate_time);
764  void overload_status_changed(gx_engine::MidiAudioBuffer::Load l);
765  bool on_window_state_changed(GdkEventWindowState* event);
766  bool on_meter_button_release(GdkEventButton* ev);
767  void show_selected_preset();
768  void on_select_preset(int idx);
769  void set_switcher_controller();
770  void set_bypass_controller();
771  void set_vpaned_handle();
772  void rebuild_preset_menu();
773  bool on_key_press_event(GdkEventKey *event);
774  void display_preset_msg(const Glib::ustring& bank, const Glib::ustring& preset);
775  void on_show_midi_out();
776  void on_show_midi_out_plug();
777  void on_midi_out_channel_toggled(Gtk::RadioButton *rb, Gtk::Container *c);
778  void on_livetuner_toggled();
779  Gtk::ToolItemGroup *add_plugin_category(const char *cat, bool collapse = true);
780  Glib::ustring add_plugin_menu_entry(PluginUI *pui);
781  void register_plugin(PluginUI *pui);
782  void on_ladspa_finished(bool reload, bool quit);
783  bool delete_ladspalist_window();
784  bool on_quit();
785  void amp_controls_visible(Gtk::Range *rr);
786  void on_plugin_changed(gx_engine::Plugin *pl, gx_engine::PluginChange::pc c);
787 public:
788  GtkSizeGroup *left_column;
790  Gtk::Window *splash, const Glib::ustring& title);
791  ~MainWindow();
792  void hide_effect(const std::string& name);
793  RackContainer& get_monorackcontainer() { return monorackcontainer; }
794  RackBox *add_rackbox(PluginUI& pl, bool mini=false, int pos=-1, bool animate=false);
795  void add_icon(const std::string& name);
796  PluginUI *get_plugin(const std::string& name) { return plugin_dict[name]; }
797  PluginDict::iterator plugins_begin() { return plugin_dict.begin(); }
798  PluginDict::iterator plugins_end() { return plugin_dict.end(); }
799  void run();
800  gx_system::CmdlineOptions& get_options() { return options; }
801  void plugin_preset_popup(const PluginDef *pdef);
802  void plugin_preset_popup(const PluginDef *pdef, const Glib::ustring& name);
803  gx_engine::GxMachineBase& get_machine() { return machine; }
804  void add_plugin(std::vector<PluginUI*>& p, const char *id, const Glib::ustring& tooltip_="");
805  void set_rackbox_expansion();
806  double stop_at_stereo_bottom(double off, double step_size, double pagesize);
807  double stop_at_mono_top(double off, double step_size);
808  bool use_animations() { return actions.animations->get_active(); }
810  void resize_finished(RackContainer *ch);
811  void update_width();
812 };
813 
814 inline bool RackContainer::check_if_animate(const RackBox& rackbox) { return main.use_animations(); }
815 inline void RackContainer::resize_finished() { main.resize_finished(this); }
gx_preset::UnitPresetList::const_iterator end()
CmdConnection::msg_type end
Definition: jsonrpc.cpp:256
bool can_compress()
Glib::ListHandle< const RackBox * > rackbox_const_list
CmdConnection::msg_type start
Definition: jsonrpc.cpp:255
const char * shortname
Glib::RefPtr< Gtk::ToggleAction > get_action()
PluginDef * get_pdef()
Glib::RefPtr< Gtk::ToggleAction > meterbridge
Glib::RefPtr< UiBoolToggleAction > midi_out_plug
KeySwitcher(gx_engine::GxMachineBase &machine_, sigc::slot< void, const Glib::ustring &, const Glib::ustring & > display_)
gx_engine::GxMachineBase & get_machine()
UiToggleAction< bool > UiBoolToggleAction
Glib::RefPtr< Gtk::RadioAction > osc_buffer_size
static Glib::RefPtr< UiToggleAction > create(gx_engine::GxMachineBase &machine, const std::string &id, const Glib::ustring &name, const Glib::ustring &label=Glib::ustring(), const Glib::ustring &tooltip=Glib::ustring(), bool is_active=false)
Glib::RefPtr< Gtk::ToggleAction > engine_bypass
Glib::RefPtr< Gtk::Action > jack_latency_menu
gx_preset::UnitPresetList::const_iterator begin()
bool get_plug_visible()
sigc::connection engine_bypass_conn
bool get_box_visible()
Glib::RefPtr< Gtk::RadioAction > latency
std::vector< PluginPresetEntry > UnitPresetList
Definition: gx_preset.h:134
void set_ui_merge_id(Gtk::UIManager::ui_merge_id id)
Glib::ustring tooltip
#define N_(String)
const char * name
Definition: gx_plugin.h:186
Glib::RefPtr< UiBoolToggleAction > livetuner
Glib::RefPtr< Gtk::ToggleAction > show_values
bool get_plug_visible() const
Glib::RefPtr< Gdk::Pixbuf > icon
Glib::RefPtr< UiSwitchToggleAction > midi_in_presets
sigc::connection engine_mute_conn
STL namespace.
bool hidden_by_move
GtkSizeGroup * left_column
Glib::RefPtr< Gtk::ToggleAction > tooltips
PluginDict::iterator plugins_end()
const char * get_id() const
const char * get_shortname() const
Glib::RefPtr< Gtk::ToggleAction > rackh
UiToggleAction(gx_engine::GxMachineBase &machine_, const std::string &id, const Glib::ustring &name, const Glib::ustring &icon_name, const Glib::ustring &label=Glib::ustring(), const Glib::ustring &tooltip=Glib::ustring(), bool is_active=false)
Glib::RefPtr< Gtk::Action > save_changes
PluginType
Definition: machine.h:32
const PluginDef * get_pdef()
bool check_if_animate(const RackBox &rackbox)
const char * shortname
Definition: gx_plugin.h:191
PluginUI * get_plugin(const std::string &name)
Glib::RefPtr< Gtk::ToggleAction > rack_config
rackbox_const_list get_children() const
const char * get_name() const
Glib::RefPtr< Gtk::ToggleAction > show_rack
const char * category
Definition: gx_plugin.h:190
Glib::RefPtr< Gtk::ToggleAction > animations
Gtk::ToolItemGroup * group
gx_engine::Plugin * plugin
void pack(Gtk::Widget *w)
Definition: rack.cpp:479
Glib::RefPtr< Gtk::ActionGroup > group
Glib::RefPtr< Gtk::Action > expand
gx_system::CmdlineOptions & get_options()
virtual void create_default_scratch_preset()=0
void create_default_scratch_preset()
const char * id
Definition: gx_plugin.h:185
Glib::RefPtr< Gtk::Action > loadladspa
Glib::RefPtr< Gtk::ToggleAction > midicontroller
sigc::signal< void > & signal_msg_level_changed()
Glib::RefPtr< Gtk::Action > quit
int flags
Definition: gx_plugin.h:183
void set_active(bool v)
Glib::RefPtr< Gtk::Action > new_bank
PluginUI * operator[](const std::string &s)
Glib::RefPtr< Gtk::ToggleAction > organize
UiBoolToggleAction UiSwitchToggleAction
MainWindow & main
Glib::RefPtr< Gtk::ToggleAction > live_play
PluginType get_type() const
Glib::RefPtr< Gtk::RadioAction > skin
bool plugins_by_name_less(PluginUI *a, PluginUI *b)
Definition: rack.cpp:186
void set_config_mode(bool mode)
Definition: rack.cpp:485
Glib::RefPtr< Gtk::AccelGroup > accels
PluginDict::iterator plugins_begin()
rackbox_list get_children()
Gtk::ToolItem * toolitem
Glib::RefPtr< Gtk::Action > online_preset_bank
const char * get_id() const
Glib::RefPtr< UiBoolToggleAction > midi_out
Glib::RefPtr< UiBoolToggleAction > tuner
int get_unseen_msg_level()
gx_engine::GxMachineBase & get_machine()
void resize_finished()
int main(int argc, char *argv[])
Definition: gxw_demo.cc:62
Glib::RefPtr< Gtk::Action > jackstartup
Glib::RefPtr< Gtk::ToggleAction > presets
Glib::RefPtr< Gtk::Action > osc_buffer_menu
Glib::RefPtr< Gtk::ToggleAction > show_plugin_bar
Glib::RefPtr< Gtk::ToggleAction > jackserverconnection
Glib::RefPtr< Gtk::ToggleAction > engine_mute
Gxw::RackTuner & get_tuner()
Glib::RefPtr< Gtk::ToggleAction > jackports
const char * get_category()
std::map< std::string, PluginUI * >::iterator iterator
bool use_animations()
RackBox * rackbox
Glib::ListHandle< RackBox * > rackbox_list
Glib::RefPtr< Gtk::Action > compress
Glib::RefPtr< Gtk::ToggleAction > loggingbox
RackContainer & get_monorackcontainer()
bool empty() const