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  int get_unseen_msg_level() { return highest_unseen_msg_level; }
432  sigc::signal<void>& signal_msg_level_changed() { return msg_level_changed; }
433 };
434 
435 
436 /****************************************************************
437  ** class MainWindow
438  */
439 
440 class Freezer {
441 private:
442  Gtk::Window *window;
443  sigc::connection tag;
444  bool need_thaw;
445  int size_x;
446  int size_y;
447  sigc::slot<void> work;
448 private:
449  void do_thaw();
450  bool thaw_timeout();
451  void freeze(Gtk::Window *w, int width, int height);
452  void thaw();
453 public:
454  Freezer();
455  ~Freezer();
456  void freeze_until_width_update(Gtk::Window *w, int width);
457  void set_slot(sigc::slot<void> w);
458  void freeze_and_size_request(Gtk::Window *w, int width, int height);
459  bool check_thaw(int width, int height);
460 };
461 
462 
463 /****************************************************************
464  ** class PluginPresetPopup
465  */
466 
467 class PluginPresetPopup: public Gtk::Menu {
468 private:
469  const PluginDef *pdef;
470  gx_engine::GxMachineBase& machine;
471  const Glib::ustring save_name_default;
472  gx_preset::UnitPresetList presetnames;
473  void set_plugin_std_preset();
474  void set_plugin_preset(bool factory, const Glib::ustring& name);
475  bool add_plugin_preset_list(bool *found);
476  void save_plugin_preset();
477  void remove_plugin_preset();
478 protected:
479  virtual void on_selection_done();
480 public:
482  const Glib::ustring& save_name_default = "");
483  gx_preset::UnitPresetList::const_iterator begin() { return presetnames.begin(); }
484  gx_preset::UnitPresetList::const_iterator end() { return presetnames.end(); }
485  const PluginDef *get_pdef() { return pdef; }
486  gx_engine::GxMachineBase& get_machine() { return machine; }
487 };
488 
489 
490 /****************************************************************
491  ** GxUiRadioMenu
492  ** adds the values of an EnumParameter as Gtk::RadioMenuItem's
493  ** to a Gtk::MenuShell
494  */
495 
497 private:
498  gx_engine::GxMachineBase& machine;
499  const std::string id;
500  Glib::RefPtr<Gtk::RadioAction> action;
501  void set_value(unsigned int v);
502  void on_changed(Glib::RefPtr<Gtk::RadioAction> act);
503 public:
504  GxUiRadioMenu(gx_engine::GxMachineBase& machine, const std::string& id);
505  void setup(const Glib::ustring& prefix, const Glib::ustring& postfix,
506  Glib::RefPtr<Gtk::UIManager>& uimanager, Glib::RefPtr<Gtk::ActionGroup>& actiongroup);
507 };
508 
509 
510 struct GxActions {
511  // Main Window
512  Glib::RefPtr<Gtk::ActionGroup> group;
513  Glib::RefPtr<Gtk::AccelGroup> accels;
514 
515  Glib::RefPtr<Gtk::Action> quit;
516  Glib::RefPtr<Gtk::Action> compress;
517  Glib::RefPtr<Gtk::Action> expand;
518  Glib::RefPtr<Gtk::Action> jack_latency_menu;
519  Glib::RefPtr<Gtk::Action> osc_buffer_menu;
520  Glib::RefPtr<Gtk::Action> jackstartup;
521  Glib::RefPtr<Gtk::Action> loadladspa;
522 
523  Glib::RefPtr<Gtk::ToggleAction> rack_config;
524  Glib::RefPtr<Gtk::ToggleAction> live_play;
525  Glib::RefPtr<Gtk::ToggleAction> engine_mute;
526  sigc::connection engine_mute_conn;
527  Glib::RefPtr<Gtk::ToggleAction> engine_bypass;
528  sigc::connection engine_bypass_conn;
529  Glib::RefPtr<Gtk::ToggleAction> jackserverconnection;
530  Glib::RefPtr<Gtk::ToggleAction> jackports;
531  Glib::RefPtr<Gtk::ToggleAction> midicontroller;
532  Glib::RefPtr<Gtk::ToggleAction> meterbridge;
533  Glib::RefPtr<Gtk::ToggleAction> loggingbox;
534  Glib::RefPtr<Gtk::ToggleAction> animations;
535 
536  Glib::RefPtr<Gtk::ToggleAction> show_plugin_bar;
537  Glib::RefPtr<Gtk::ToggleAction> presets;
538  Glib::RefPtr<Gtk::ToggleAction> show_rack;
539  Glib::RefPtr<UiBoolToggleAction> tuner;
540  Glib::RefPtr<UiBoolToggleAction> livetuner;
541  Glib::RefPtr<UiBoolToggleAction> midi_out;
542  Glib::RefPtr<UiBoolToggleAction> midi_out_plug;
543  Glib::RefPtr<Gtk::ToggleAction> show_values;
544  Glib::RefPtr<Gtk::ToggleAction> tooltips;
545  Glib::RefPtr<UiSwitchToggleAction> midi_in_presets;
546  Glib::RefPtr<Gtk::ToggleAction> rackh;
547 
548  Glib::RefPtr<Gtk::RadioAction> skin;
549  Glib::RefPtr<Gtk::RadioAction> latency;
550  Glib::RefPtr<Gtk::RadioAction> osc_buffer_size;
551 
552  // preset window
553  Glib::RefPtr<Gtk::Action> new_bank;
554  Glib::RefPtr<Gtk::Action> save_changes;
555  Glib::RefPtr<Gtk::ToggleAction> organize;
556  Glib::RefPtr<Gtk::Action> online_preset_bank;
557 };
558 
559 class MainWindow: public sigc::trackable {
560 private:
561  gx_system::CmdlineOptions& options;
562  gx_engine::GxMachineBase& machine;
563  Glib::RefPtr<gx_gui::GxBuilder> bld;
564  Freezer freezer;
565  PluginDict plugin_dict;
566  int oldpos;
567  int scrl_size_x;
568  int scrl_size_y;
569  RackContainer monorackcontainer;
570  RackContainer stereorackcontainer;
571  int pre_act;
572  bool is_visible;
573  // bool ui_sleep();
574  DragIcon *drag_icon;
575  Glib::ustring preset_list_menu_bank;
576  Gtk::UIManager::ui_merge_id preset_list_merge_id;
577  Glib::RefPtr<Gtk::ActionGroup> preset_list_actiongroup;
578  Glib::RefPtr<Gtk::UIManager> uimanager;
579  Liveplay *live_play;
580  PresetWindow *preset_window;
581  Gxw::WaveView fWaveView;
582  Gtk::Label convolver_filename_label;
583  Gtk::Label convolver_mono_filename_label;
584  Glib::RefPtr<Gdk::Pixbuf> gx_head_icon;
585  gx_gui::StackBoxBuilder boxbuilder;
586  gx_portmap::PortMapWindow* portmap_window;
587  gx_gui::SelectJackControlPgm *select_jack_control;
588  TextLoggingBox fLoggingWindow;
589  GxUiRadioMenu amp_radio_menu;
590  Glib::RefPtr<Gdk::Pixbuf> pixbuf_insert_on;
591  Glib::RefPtr<Gdk::Pixbuf> pixbuf_insert_off;
592  Glib::RefPtr<Gdk::Pixbuf> pixbuf_on;
593  Glib::RefPtr<Gdk::Pixbuf> pixbuf_off;
594  Glib::RefPtr<Gdk::Pixbuf> pixbuf_bypass;
595  Glib::RefPtr<Gdk::Pixbuf> pixbuf_jack_connected;
596  Glib::RefPtr<Gdk::Pixbuf> pixbuf_jack_disconnected;
597  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_grey;
598  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_yellow;
599  Glib::RefPtr<Gdk::Pixbuf> pixbuf_log_red;
600  bool in_session;
601  Glib::RefPtr<Gtk::StatusIcon> status_icon;
602  Glib::RefPtr<Gdk::Pixbuf> gx_head_midi;
603  Glib::RefPtr<Gdk::Pixbuf> gx_head_warn;
604  GxActions actions;
605  KeySwitcher keyswitch;
606  std::map<Glib::ustring, Gtk::ToolItemGroup*> groupmap;
607  ladspa::PluginDisplay *ladspalist_window;
608  Glib::RefPtr<Gtk::SizeGroup> szg_rack_units;
609 
610  // Widget pointers
611  Gxw::PaintBox *tunerbox;
612  Gtk::ScrolledWindow *vrack_scrolledbox;
613  Gtk::HBox *stereorackcontainerH;
614  Gtk::HBox *stereorackcontainerV;
615  Gxw::PaintBox *rackcontainer;
616  Gtk::ScrolledWindow *stereorackbox;
617  Gtk::VBox *monocontainer;
618  Gxw::PaintBox *monoampcontainer;
619  Gtk::VPaned *main_vpaned;
620  Gtk::HBox *amp_toplevel_box;
621  Gtk::VBox *monobox;
622  Gtk::VBox *upper_rackbox;
623  Gtk::ScrolledWindow *preset_scrolledbox;
624  Gtk::Box *preset_box_no_rack;
625  Gxw::PaintBox *effects_frame_paintbox;
626  Gtk::Image *insert_image;
627  Gtk::Image *status_image;
628  Gtk::Image *jackd_image;
629  Gtk::Image *logstate_image;
630  Gtk::Window *window;
631  Gtk::HBox *menubox;
632  Gtk::ToggleButton *show_rack_button;
633  Gtk::ToggleButton *rack_order_h_button;
634  Gtk::ToggleButton *config_mode_button;
635  Gtk::ToggleButton *liveplay_button;
636  Gtk::ToggleButton *tuner_button;
637  Gtk::ToggleButton *effects_button;
638  Gtk::ToggleButton *presets_button;
639  Gtk::Button *compress_button;
640  Gtk::Button *expand_button;
641  Gtk::ToolPalette *effects_toolpalette;
642  Gxw::PaintBox *amp_background;
643  Gxw::Switch *tuner_on_off;
644  Gxw::Selector *tuner_mode;
645  Gxw::ValueDisplay *tuner_reference_pitch;
646  Gxw::Selector *tuner_tuning;
647  Gxw::Selector *tuner_temperament;
648  Gxw::RackTuner *racktuner;
649  Gtk::Button *ampdetail_compress;
650  Gtk::Button *ampdetail_expand;
651  Gtk::Widget *ampdetail_mini;
652  Gtk::Widget *ampdetail_normal;
653  Gxw::FastMeter *fastmeter[2];
654  Gtk::Entry *preset_status;
655  Gtk::Container *midi_out_box;
656  Gtk::Container *midi_out_normal;
657  Gtk::Container *midi_out_mini;
658  Gtk::Button *midi_out_compress;
659  Gtk::Button *midi_out_expand;
660  Gtk::Button *midi_out_presets_mini;
661  Gtk::Button *midi_out_presets_normal;
662  Gtk::RadioButton *channel1_button;
663  Gtk::Container *channel1_box;
664  Gtk::RadioButton *channel2_button;
665  Gtk::Container *channel2_box;
666  Gtk::RadioButton *channel3_button;
667  Gtk::Container *channel3_box;
668  Gtk::Alignment *vbam;
669  GdkPixbuf *hanl;
670  GdkPixbuf *hanr;
671 
672 private:
673  bool on_my_leave_out(GdkEventCrossing *focus);
674  bool on_my_enter_in(GdkEventCrossing *focus);
675  void load_widget_pointers();
676  void maybe_shrink_horizontally(bool preset_no_rack=false);
677  void on_show_tuner();
678  bool is_variable_size();
679  void maybe_change_resizable(void);
680  void on_show_rack();
681  void on_preset_action();
682  void on_compress_all();
683  void on_expand_all();
684  void on_show_plugin_bar();
685  void on_rack_configuration();
686  void set_tooltips();
687  void set_animations();
688  void move_widget(Gtk::Widget& w, Gtk::Box& b1, Gtk::Box& b2);
689  int rackbox_stacked_vertical() const;
690  void change_expand(Gtk::Widget& w, bool value);
691  void on_dir_changed();
692  void on_configure_event(GdkEventConfigure *ev);
693  void clear_box(Gtk::Container& box);
694  RackBox *add_rackbox_internal(PluginUI& plugin, Gtk::Widget *mainwidget, Gtk::Widget *miniwidget,
695  bool mini=false, int pos=-1, bool animate=false, Gtk::Widget *bare=0);
696  void on_show_values();
697  void create_actions();
698  void add_toolitem(PluginUI& pl, Gtk::ToolItemGroup *gw);
699  bool on_visibility_notify(GdkEventVisibility *ev);
700  void on_live_play();
701  void on_ti_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, const PluginUI& plugin);
702  void on_ti_drag_end(const Glib::RefPtr<Gdk::DragContext>& context);
703  void on_ti_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection, int info, int timestamp, const char *effect_id);
704  void on_ti_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context, const char *effect_id);
705  bool on_ti_button_press(GdkEventButton *ev, const char *effect_id);
706  void on_tp_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, int info, int timestamp);
707  void fill_pluginlist();
708  void make_icons(bool force=true);
709  void jack_connection();
710  void on_miditable_toggle();
711  void on_portmap_activate();
712  void on_portmap_response(int);
713  bool connect_jack(bool v, Gtk::Window *splash = 0);
714  int start_jack();
715  void add_skin_menu();
716  void change_skin(Glib::RefPtr<Gtk::RadioAction> action);
717  void on_jack_client_changed();
718  void add_latency_menu();
719  void change_latency(Glib::RefPtr<Gtk::RadioAction> action);
720  void user_disable_latency_warn(Gtk::CheckButton* disable_warn);
721  int gx_wait_latency_warn();
722  void set_latency();
723  void set_osc_size();
724  void add_osc_size_menu();
725  void change_osc_buffer(Glib::RefPtr<Gtk::RadioAction> action);
726  void on_select_jack_control();
727  void on_load_ladspa();
728  void delete_select_jack_control();
729  void on_log_activate();
730  bool on_log_activated(GdkEventButton* ev);
731  void do_program_change(int pgm);
732  void on_engine_toggled();
733  void on_engine_state_change(gx_engine::GxEngineState state);
734  void set_new_skin(const Glib::ustring& skin_name);
735  void set_tuning(Gxw::RackTuner& tuner);
736  void set_tuner_tet(Gxw::RackTuner& tuner);
737  void set_tuner_ref(Gxw::RackTuner& tuner);
738  void setup_tuner_temperament(Gxw::RackTuner& tuner);
739  void setup_tuner(Gxw::RackTuner& tuner);
740  bool on_toggle_mute(GdkEventButton* ev);
741  bool on_toggle_insert(GdkEventButton* ev);
742  bool on_jackserverconnection(GdkEventButton* ev);
743  void on_msg_level_changed();
744  void on_ampdetail_switch(bool compress, bool setparam);
745  void on_show_oscilloscope(bool v);
746  void set_waveview_buffer(unsigned int size);
747  void on_oscilloscope_post_pre(int post_pre);
748  int on_oscilloscope_activate(bool start);
749  bool on_refresh_oscilloscope();
750  bool refresh_meter_level(float falloff);
751  bool survive_jack_shutdown();
752  void gx_jack_is_down();
753  void jack_session_event();
754  void jack_session_event_ins();
755  void set_in_session();
756  void hide_extended_settings();
757  void systray_menu(guint button, guint32 activate_time);
758  void overload_status_changed(gx_engine::MidiAudioBuffer::Load l);
759  bool on_window_state_changed(GdkEventWindowState* event);
760  bool on_meter_button_release(GdkEventButton* ev);
761  void show_selected_preset();
762  void on_select_preset(int idx);
763  void set_switcher_controller();
764  void set_vpaned_handle();
765  void rebuild_preset_menu();
766  bool on_key_press_event(GdkEventKey *event);
767  void display_preset_msg(const Glib::ustring& bank, const Glib::ustring& preset);
768  void on_show_midi_out();
769  void on_show_midi_out_plug();
770  void on_midi_out_channel_toggled(Gtk::RadioButton *rb, Gtk::Container *c);
771  void on_livetuner_toggled();
772  Gtk::ToolItemGroup *add_plugin_category(const char *cat, bool collapse = true);
773  Glib::ustring add_plugin_menu_entry(PluginUI *pui);
774  void register_plugin(PluginUI *pui);
775  void on_ladspa_finished(bool reload, bool quit);
776  bool delete_ladspalist_window();
777  bool on_quit();
778  void amp_controls_visible(Gtk::Range *rr);
779  void on_plugin_changed(gx_engine::Plugin *pl, gx_engine::PluginChange::pc c);
780 public:
781  GtkSizeGroup *left_column;
783  Gtk::Window *splash, const Glib::ustring& title);
784  ~MainWindow();
785  void hide_effect(const std::string& name);
786  RackContainer& get_monorackcontainer() { return monorackcontainer; }
787  RackBox *add_rackbox(PluginUI& pl, bool mini=false, int pos=-1, bool animate=false);
788  void add_icon(const std::string& name);
789  PluginUI *get_plugin(const std::string& name) { return plugin_dict[name]; }
790  PluginDict::iterator plugins_begin() { return plugin_dict.begin(); }
791  PluginDict::iterator plugins_end() { return plugin_dict.end(); }
792  void run();
793  gx_system::CmdlineOptions& get_options() { return options; }
794  void plugin_preset_popup(const PluginDef *pdef);
795  void plugin_preset_popup(const PluginDef *pdef, const Glib::ustring& name);
796  gx_engine::GxMachineBase& get_machine() { return machine; }
797  void add_plugin(std::vector<PluginUI*>& p, const char *id, const Glib::ustring& tooltip_="");
798  void set_rackbox_expansion();
799  double stop_at_stereo_bottom(double off, double step_size, double pagesize);
800  double stop_at_mono_top(double off, double step_size);
801  bool use_animations() { return actions.animations->get_active(); }
803  void resize_finished(RackContainer *ch);
804  void update_width();
805 };
806 
807 inline bool RackContainer::check_if_animate(const RackBox& rackbox) { return main.use_animations(); }
808 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