From 706f89993a6d35e20662721e3ab541e5495de31d Mon Sep 17 00:00:00 2001 From: Valeriy Kamyshniy Date: Wed, 11 Jun 2014 06:00:48 -0500 Subject: [PATCH] [Summary] Making namespace WavesUI a class. [git-p4: depot-paths = "//Abdaw/dev_main/tracks/": change = 466991] --- gtk2_ardour/ardour_ui2.cc | 2 +- gtk2_ardour/device_connection_control.cc | 48 ++++---- gtk2_ardour/device_connection_control.h | 4 +- gtk2_ardour/editor.cc | 6 +- gtk2_ardour/editor_markers.cc | 2 +- gtk2_ardour/editor_ops.cc | 2 +- gtk2_ardour/editor_selection.cc | 10 +- gtk2_ardour/midi_device_connection_control.cc | 45 +++----- gtk2_ardour/midi_device_connection_control.h | 4 +- gtk2_ardour/public_editor.cc | 9 +- gtk2_ardour/public_editor.h | 6 +- gtk2_ardour/session_dialog.cc | 32 +++--- gtk2_ardour/session_lock_dialog.cc | 2 +- gtk2_ardour/tracks_control_panel.cc | 60 +++++----- gtk2_ardour/waves_dialog.cc | 40 ++----- gtk2_ardour/waves_dialog.h | 9 +- gtk2_ardour/waves_ui.cc | 103 +++++++++++------- gtk2_ardour/waves_ui.h | 58 +++++----- gtk2_ardour/waves_window.cc | 9 -- gtk2_ardour/waves_window.h | 17 --- gtk2_ardour/wscript | 1 - 21 files changed, 205 insertions(+), 264 deletions(-) delete mode 100755 gtk2_ardour/waves_window.cc delete mode 100755 gtk2_ardour/waves_window.h diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 1785549fe0..624ca59be2 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -108,7 +108,7 @@ ARDOUR_UI::setup_windows () editor->get_status_bar_packer().pack_start (*status_bar_packer, true, true); editor->get_status_bar_packer().pack_start (menu_bar_base, false, false, 6); #else - editor->get_hbox ("menu_bar_base").pack_start (menu_bar_base, false, false); + editor->get_h_box ("menu_bar_base").pack_start (menu_bar_base, false, false); #endif if (ARDOUR::Profile->get_trx()) { top_packer.pack_start (tracks_tools_packer, false, false); diff --git a/gtk2_ardour/device_connection_control.cc b/gtk2_ardour/device_connection_control.cc index f992e30300..dd46420bee 100644 --- a/gtk2_ardour/device_connection_control.cc +++ b/gtk2_ardour/device_connection_control.cc @@ -24,7 +24,8 @@ const char * DeviceConnectionControl::id_name = "_id_name"; DeviceConnectionControl::DeviceConnectionControl (const std::string& device_capture_name, bool active, uint16_t capture_number, const std::string& track_name) - : Gtk::Layout() + : Gtk::Layout(), + WavesUI("device_capture_control.xml", *this) , _active(false) , _active_on_button (NULL) , _active_off_button (NULL) @@ -32,18 +33,22 @@ DeviceConnectionControl::DeviceConnectionControl (const std::string& device_capt , _track_name_label (NULL) , _number_label (NULL) { - build_layout("device_capture_control.xml"); - _active_on_button = &_children.get_waves_button ("capture_on_button"); - _active_off_button = &_children.get_waves_button ("capture_off_button"); - _name_label = &_children.get_label ("capture_name_label"); - _number_label = &_children.get_label ("capture_number_label"); - _track_name_label = &_children.get_label ("track_name_label"); + XMLNode* root = xml_tree()->root(); + WavesUI::set_attributes(*this, *root, XMLNodeMap()); + + _active_on_button = &get_waves_button ("capture_on_button"); + _active_off_button = &get_waves_button ("capture_off_button"); + _name_label = &get_label ("capture_name_label"); + _number_label = &get_label ("capture_number_label"); + _track_name_label = &get_label ("track_name_label"); + init(device_capture_name, active, capture_number, track_name); } DeviceConnectionControl::DeviceConnectionControl (const std::string& device_playback_name, bool active, uint16_t playback_number) : Gtk::Layout() + , WavesUI("device_playback_control.xml", *this) , _active(false) , _active_on_button (NULL) , _active_off_button (NULL) @@ -51,11 +56,14 @@ DeviceConnectionControl::DeviceConnectionControl (const std::string& device_play , _track_name_label (NULL) , _number_label (NULL) { - build_layout("device_playback_control.xml"); - _active_on_button = &_children.get_waves_button ("playback_on_button"); - _active_off_button = &_children.get_waves_button ("playback_off_button"); - _name_label = &_children.get_label ("playback_name_label"); - _number_label = &_children.get_label ("playback_number_label"); + XMLNode* root = xml_tree()->root(); + WavesUI::set_attributes(*this, *root, XMLNodeMap()); + + _active_on_button = &get_waves_button ("playback_on_button"); + _active_off_button = &get_waves_button ("playback_off_button"); + _name_label = &get_label ("playback_name_label"); + _number_label = &get_label ("playback_number_label"); + init(device_playback_name, active, playback_number); } @@ -85,22 +93,6 @@ void DeviceConnectionControl::init(const std::string& name, bool active, uint16_ set_active(active); } -bool -DeviceConnectionControl::build_layout (const std::string& file_name) -{ - const XMLTree* layout = WavesUI::load_layout(file_name); - if (layout == NULL) { - return false; - } - - XMLNode* root = layout->root(); - if ((root == NULL) || strcasecmp(root->name().c_str(), "layout")) { - return false; - } - WavesUI::set_attributes(*this, *root, XMLNodeMap()); - WavesUI::create_ui(layout, *this, _children); - return true; -} void DeviceConnectionControl::set_number (uint16_t number) diff --git a/gtk2_ardour/device_connection_control.h b/gtk2_ardour/device_connection_control.h index 86046bb610..9fd6b1c33f 100644 --- a/gtk2_ardour/device_connection_control.h +++ b/gtk2_ardour/device_connection_control.h @@ -25,7 +25,7 @@ #include "waves_ui.h" -class DeviceConnectionControl : public Gtk::Layout +class DeviceConnectionControl : public Gtk::Layout, public WavesUI { public: enum ConnectionNumber { @@ -37,7 +37,6 @@ class DeviceConnectionControl : public Gtk::Layout DeviceConnectionControl (const std::string& device_capture_name, bool active, uint16_t capture_number, const std::string& track_name); DeviceConnectionControl (const std::string& device_playback_name, bool active, uint16_t playback_number); - bool build_layout (const std::string& file_name); void set_number (uint16_t number); void set_active (bool active); void set_track_name (const std::string& new_track_name); @@ -52,7 +51,6 @@ class DeviceConnectionControl : public Gtk::Layout // flag which reflects control "active" state bool _active; - WavesUI::WidgetMap _children; WavesButton* _active_on_button; WavesButton* _active_off_button; Gtk::Label* _name_label; diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index cc7af29838..a2fc9bc712 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -246,7 +246,7 @@ Editor::Editor () , cd_mark_label (_("CD Markers")) , videotl_label (_("Video Timeline")) , edit_packer (4, 4, true) - , vpacker (get_vbox ("vpacker")) + , vpacker (get_v_box ("vpacker")) , _tool_marker_button (get_waves_button ("tool_marker_button")) , _tool_zoom_button (get_waves_button ("tool_zoom_button")) , _tool_arrow_button (get_waves_button ("tool_arrow_button")) @@ -258,7 +258,7 @@ Editor::Editor () * but also any other OS that uses a single * top menubar instead of per window menus */ - , _status_bar_hpacker (get_hbox ("menu_bar_base")) + , _status_bar_hpacker (get_h_box ("menu_bar_base")) #endif /* the values here don't matter: layout widgets @@ -5104,7 +5104,7 @@ Editor::timeaxisview_deleted (TimeAxisView *tv) TrackViewList::iterator i; - if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) { + if ((i = std::find (track_views.begin(), track_views.end(), tv)) != track_views.end()) { i = track_views.erase (i); } diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 3cf3ef83b7..387d9f7138 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -232,7 +232,7 @@ Editor::check_marker_label (Marker* m) /* Get a time-ordered list of markers from the last time anything changed */ std::list& sorted = _sorted_marker_lists[m->get_parent()]; - list::iterator i = find (sorted.begin(), sorted.end(), m); + list::iterator i = std::find (sorted.begin(), sorted.end(), m); list::iterator prev = sorted.end (); list::iterator next = i; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 550c88067d..c4b5309333 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1640,7 +1640,7 @@ Editor::temporal_zoom_region (bool both_axes) _routes->suspend_redisplay (); for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - if (find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) { + if (std::find (tracks.begin(), tracks.end(), (*i)) == tracks.end()) { hide_track_in_display (*i); } } diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index e1027e4e9b..2ed854365e 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -813,7 +813,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) int okey = closest->route()->order_key (); if (okey > key) { - swap (okey, key); + std::swap (okey, key); } for (TrackViewList::iterator x = track_views.begin(); x != track_views.end(); ++x) { @@ -830,7 +830,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) behaviour that feels wrong. */ - if (find (already_in_selection.begin(), + if (std::find (already_in_selection.begin(), already_in_selection.end(), artv) == already_in_selection.end()) { @@ -953,13 +953,13 @@ Editor::track_selection_changed () for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - bool yn = (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()); + bool yn = (std::find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()); (*i)->set_selected (yn); TimeAxisView::Children c = (*i)->get_child_list (); for (TimeAxisView::Children::iterator j = c.begin(); j != c.end(); ++j) { - (*j)->set_selected (find (selection->tracks.begin(), selection->tracks.end(), j->get()) != selection->tracks.end()); + (*j)->set_selected (std::find (selection->tracks.begin(), selection->tracks.end(), j->get()) != selection->tracks.end()); } if (yn) { @@ -1915,7 +1915,7 @@ Editor::get_edit_op_range (framepos_t& start, framepos_t& end) const } if (start > end) { - swap (start, end); + std::swap (start, end); } /* turn range into one delimited by start...end, diff --git a/gtk2_ardour/midi_device_connection_control.cc b/gtk2_ardour/midi_device_connection_control.cc index 10fa332e44..b7437fd211 100644 --- a/gtk2_ardour/midi_device_connection_control.cc +++ b/gtk2_ardour/midi_device_connection_control.cc @@ -27,32 +27,34 @@ const char * MidiDeviceConnectionControl::playback_id_name = "_playback_id_name" MidiDeviceConnectionControl::MidiDeviceConnectionControl (const std::string& midi_device_name, bool has_capture, bool capture_active, bool has_playback, bool playback_active) -: Gtk::Layout() -, _has_capture(has_capture) -, _capture_active(capture_active) -, _has_playback(has_playback) -, _playback_active(playback_active) +: Gtk::Layout () +, WavesUI ("midi_device_control.xml", *this) +, _has_capture (has_capture) +, _capture_active (capture_active) +, _has_playback (has_playback) +, _playback_active (playback_active) { - build_layout("midi_device_control.xml"); - - _capture_on_button = &_children.get_waves_button ("capture_on_button"); - _capture_off_button = &_children.get_waves_button ("capture_off_button"); + XMLNode* root = xml_tree()->root(); + WavesUI::set_attributes(*this, *root, XMLNodeMap()); + + _capture_on_button = &get_waves_button ("capture_on_button"); + _capture_off_button = &get_waves_button ("capture_off_button"); if (!_has_capture) { _capture_on_button->hide(); _capture_off_button->hide(); } - _playback_on_button = &_children.get_waves_button ("playback_on_button"); - _playback_off_button = &_children.get_waves_button ("playback_off_button"); + _playback_on_button = &get_waves_button ("playback_on_button"); + _playback_off_button = &get_waves_button ("playback_off_button"); if (!_has_playback) { _playback_on_button->hide(); _playback_off_button->hide(); } - _name_label = &_children.get_label ("midi_device_name_label"); + _name_label = &get_label ("midi_device_name_label"); init(midi_device_name, capture_active, playback_active); } @@ -77,25 +79,6 @@ void MidiDeviceConnectionControl::init(const std::string& name, bool capture_act } -bool -MidiDeviceConnectionControl::build_layout (const std::string& file_name) -{ - const XMLTree* layout = WavesUI::load_layout(file_name); - if (layout == NULL) { - return false; - } - - XMLNode* root = layout->root(); - if ((root == NULL) || strcasecmp(root->name().c_str(), "layout")) { - return false; - } - - WavesUI::set_attributes(*this, *root, XMLNodeMap()); - WavesUI::create_ui(layout, *this, _children); - return true; -} - - void MidiDeviceConnectionControl::set_capture_active (bool active) { diff --git a/gtk2_ardour/midi_device_connection_control.h b/gtk2_ardour/midi_device_connection_control.h index b435b1e0b0..0c0462e876 100644 --- a/gtk2_ardour/midi_device_connection_control.h +++ b/gtk2_ardour/midi_device_connection_control.h @@ -25,7 +25,7 @@ #include "waves_ui.h" -class MidiDeviceConnectionControl : public Gtk::Layout +class MidiDeviceConnectionControl : public Gtk::Layout, public WavesUI { public: @@ -46,7 +46,6 @@ public: private: void init(const std::string& name, bool capture_active, bool playback_active ); - bool build_layout (const std::string& file_name); void on_capture_active_on(WavesButton*); void on_capture_active_off(WavesButton*); @@ -59,7 +58,6 @@ private: bool _has_playback; bool _playback_active; - WavesUI::WidgetMap _children; WavesButton* _capture_on_button; WavesButton* _capture_off_button; WavesButton* _playback_on_button; diff --git a/gtk2_ardour/public_editor.cc b/gtk2_ardour/public_editor.cc index d8613d42cf..64963b69c8 100644 --- a/gtk2_ardour/public_editor.cc +++ b/gtk2_ardour/public_editor.cc @@ -28,14 +28,9 @@ const int PublicEditor::horizontal_spacing = 6; sigc::signal PublicEditor::DropDownKeys; -PublicEditor::PublicEditor () - : WavesWindow (Gtk::WINDOW_TOPLEVEL) - , VisibilityTracker (*((Gtk::Window*)this)) -{ -} - PublicEditor::PublicEditor (std::string layout_script) - : WavesWindow (Gtk::WINDOW_TOPLEVEL, layout_script) + : Window (Gtk::WINDOW_TOPLEVEL) + , WavesUI (layout_script, *this) , VisibilityTracker (*((Gtk::Window*)this)) { } diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index ac8cc4195e..3792e42021 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -30,10 +30,11 @@ #include #include #include +#include #include #include -#include "waves_window.h" +#include "waves_ui.h" #include "evoral/types.hpp" @@ -95,9 +96,8 @@ using ARDOUR::framecnt_t; * of PublicEditor need not be recompiled if private methods or member variables * change. */ -class PublicEditor : public WavesWindow, public PBD::StatefulDestructible, public Gtkmm2ext::VisibilityTracker { +class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, public Gtkmm2ext::VisibilityTracker, public WavesUI { public: - PublicEditor (); PublicEditor (std::string layout_script); virtual ~PublicEditor (); diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc index b7084e354b..0cacc60b26 100644 --- a/gtk2_ardour/session_dialog.cc +++ b/gtk2_ardour/session_dialog.cc @@ -66,28 +66,28 @@ SessionDialog::SessionDialog (WM::Proxy& system_configuratio const std::string& template_name, bool cancel_not_quit) : WavesDialog (_("session_dialog.xml"), true, false) - , _quit_button (named_children ().get_waves_button ("quit_button")) - , _system_configuration_button (named_children ().get_waves_button ("system_configuration_button")) - , _new_session_button (named_children ().get_waves_button ("new_session_button")) - , _open_selected_button (named_children ().get_waves_button ("open_selected_button")) - , _open_saved_session_button (named_children ().get_waves_button ("open_saved_session_button")) - , _session_details_label(named_children ().get_label("session_details_label")) + , _quit_button (get_waves_button ("quit_button")) + , _system_configuration_button (get_waves_button ("system_configuration_button")) + , _new_session_button (get_waves_button ("new_session_button")) + , _open_selected_button (get_waves_button ("open_selected_button")) + , _open_saved_session_button (get_waves_button ("open_saved_session_button")) + , _session_details_label(get_label("session_details_label")) , _new_only (require_new) , _provided_session_name (session_name) , _provided_session_path (session_path) , _existing_session_chooser_used (false) , _system_configuration_dialog(system_configuration_dialog) { - _recent_session_button[0] = &named_children ().get_waves_button ("recent_session_button_0"); - _recent_session_button[1] = &named_children ().get_waves_button ("recent_session_button_1"); - _recent_session_button[2] = &named_children ().get_waves_button ("recent_session_button_2"); - _recent_session_button[3] = &named_children ().get_waves_button ("recent_session_button_3"); - _recent_session_button[4] = &named_children ().get_waves_button ("recent_session_button_4"); - _recent_session_button[5] = &named_children ().get_waves_button ("recent_session_button_5"); - _recent_session_button[6] = &named_children ().get_waves_button ("recent_session_button_6"); - _recent_session_button[7] = &named_children ().get_waves_button ("recent_session_button_7"); - _recent_session_button[8] = &named_children ().get_waves_button ("recent_session_button_8"); - _recent_session_button[9] = &named_children ().get_waves_button ("recent_session_button_9"); + _recent_session_button[0] = &get_waves_button ("recent_session_button_0"); + _recent_session_button[1] = &get_waves_button ("recent_session_button_1"); + _recent_session_button[2] = &get_waves_button ("recent_session_button_2"); + _recent_session_button[3] = &get_waves_button ("recent_session_button_3"); + _recent_session_button[4] = &get_waves_button ("recent_session_button_4"); + _recent_session_button[5] = &get_waves_button ("recent_session_button_5"); + _recent_session_button[6] = &get_waves_button ("recent_session_button_6"); + _recent_session_button[7] = &get_waves_button ("recent_session_button_7"); + _recent_session_button[8] = &get_waves_button ("recent_session_button_8"); + _recent_session_button[9] = &get_waves_button ("recent_session_button_9"); init(); } diff --git a/gtk2_ardour/session_lock_dialog.cc b/gtk2_ardour/session_lock_dialog.cc index 90ad90b065..1e86288e35 100644 --- a/gtk2_ardour/session_lock_dialog.cc +++ b/gtk2_ardour/session_lock_dialog.cc @@ -43,7 +43,7 @@ using namespace ARDOUR; SessionLockDialog::SessionLockDialog () : WavesDialog (_("session_lock_dialog.xml"), true, false) - , _ok_button (named_children ().get_waves_button ("ok_button")) + , _ok_button (get_waves_button ("ok_button")) { set_keep_above (true); set_position (WIN_POS_CENTER); diff --git a/gtk2_ardour/tracks_control_panel.cc b/gtk2_ardour/tracks_control_panel.cc index 458b0a5198..d4d7857cc1 100644 --- a/gtk2_ardour/tracks_control_panel.cc +++ b/gtk2_ardour/tracks_control_panel.cc @@ -60,36 +60,36 @@ using namespace Glib; TracksControlPanel::TracksControlPanel () : WavesDialog ("tracks_preferences.xml") - , _device_capture_list (named_children ().get_vbox("device_capture_list")) - , _device_playback_list (named_children ().get_vbox("device_playback_list")) - , _midi_device_list (named_children ().get_vbox("midi_device_list")) - , _all_inputs_on_button (named_children ().get_waves_button("all_inputs_on_button")) - , _all_inputs_off_button (named_children ().get_waves_button("all_inputs_off_button")) - , _all_outputs_on_button (named_children ().get_waves_button("all_outputs_on_button")) - , _all_outputs_off_button (named_children ().get_waves_button("all_outputs_off_button")) - , _audio_settings_layout (named_children ().get_layout ("audio_settings_layout")) - , _midi_settings_layout (named_children ().get_layout ("midi_settings_layout")) - , _session_settings_layout (named_children ().get_layout ("session_settings_layout")) - , _audio_settings_tab_button (named_children ().get_waves_button ("audio_settings_tab_button")) - , _midi_settings_tab_button (named_children ().get_waves_button ("midi_settings_tab_button")) - , _session_settings_tab_button (named_children ().get_waves_button ("session_settings_tab_button")) - , _ok_button (named_children ().get_waves_button ("ok_button")) - , _cancel_button (named_children ().get_waves_button ("cancel_button")) - , _apply_button (named_children ().get_waves_button ("apply_button")) - , _control_panel_button (named_children ().get_waves_button ("control_panel_button")) - , _no_button (named_children ().get_waves_button ("no_button")) - , _yes_button (named_children ().get_waves_button ("yes_button")) - , _engine_combo (named_children ().get_combo_box_text ("engine_combo")) - , _device_combo (named_children ().get_combo_box_text ("device_combo")) - , _sample_rate_combo (named_children ().get_combo_box_text ("sample_rate_combo")) - , _buffer_size_combo (named_children ().get_combo_box_text ("buffer_size_combo")) - , _latency_label (named_children ().get_label("latency_label")) - , _default_open_path (named_children ().get_label("default_open_path")) - , _multi_out_button(named_children ().get_waves_button ("multi_out_button")) - , _stereo_out_button(named_children ().get_waves_button ("stereo_out_button")) - , _name_tracks_after_driver(named_children ().get_waves_button ("name_tracks_after_driver_button")) - , _reset_tracks_name_to_default(named_children ().get_waves_button ("reset_tracks_name_to_default_button")) - , _browse_button(named_children ().get_waves_button("browse_default_folder")) + , _device_capture_list (get_v_box("device_capture_list")) + , _device_playback_list (get_v_box("device_playback_list")) + , _midi_device_list (get_v_box("midi_device_list")) + , _all_inputs_on_button (get_waves_button("all_inputs_on_button")) + , _all_inputs_off_button (get_waves_button("all_inputs_off_button")) + , _all_outputs_on_button (get_waves_button("all_outputs_on_button")) + , _all_outputs_off_button (get_waves_button("all_outputs_off_button")) + , _audio_settings_layout (get_layout ("audio_settings_layout")) + , _midi_settings_layout (get_layout ("midi_settings_layout")) + , _session_settings_layout (get_layout ("session_settings_layout")) + , _audio_settings_tab_button (get_waves_button ("audio_settings_tab_button")) + , _midi_settings_tab_button (get_waves_button ("midi_settings_tab_button")) + , _session_settings_tab_button (get_waves_button ("session_settings_tab_button")) + , _ok_button (get_waves_button ("ok_button")) + , _cancel_button (get_waves_button ("cancel_button")) + , _apply_button (get_waves_button ("apply_button")) + , _control_panel_button (get_waves_button ("control_panel_button")) + , _no_button (get_waves_button ("no_button")) + , _yes_button (get_waves_button ("yes_button")) + , _engine_combo (get_combo_box_text ("engine_combo")) + , _device_combo (get_combo_box_text ("device_combo")) + , _sample_rate_combo (get_combo_box_text ("sample_rate_combo")) + , _buffer_size_combo (get_combo_box_text ("buffer_size_combo")) + , _latency_label (get_label("latency_label")) + , _default_open_path (get_label("default_open_path")) + , _multi_out_button(get_waves_button ("multi_out_button")) + , _stereo_out_button(get_waves_button ("stereo_out_button")) + , _name_tracks_after_driver(get_waves_button ("name_tracks_after_driver_button")) + , _reset_tracks_name_to_default(get_waves_button ("reset_tracks_name_to_default_button")) + , _browse_button(get_waves_button("browse_default_folder")) , _have_control (false) , _ignore_changes (0) { diff --git a/gtk2_ardour/waves_dialog.cc b/gtk2_ardour/waves_dialog.cc index a7c270345e..242643c6b0 100644 --- a/gtk2_ardour/waves_dialog.cc +++ b/gtk2_ardour/waves_dialog.cc @@ -37,13 +37,13 @@ #include "utils.h" #include "window_manager.h" -using namespace Gtk; using namespace Gtkmm2ext; using namespace PBD; using namespace ARDOUR; WavesDialog::WavesDialog (std::string layout_script_file, bool modal, bool use_seperator) - : Dialog ("", modal, use_seperator) + : Gtk::Dialog ("", modal, use_seperator) + , WavesUI (layout_script_file, *get_vbox()) , _proxy (0) , _splash_pushed (false) { @@ -76,7 +76,7 @@ WavesDialog::WavesDialog (std::string layout_script_file, bool modal, bool use_s set_transient_for (*parent_window); } - ARDOUR_UI::CloseAllDialogs.connect (sigc::bind (sigc::mem_fun (*this, &WavesDialog::response), RESPONSE_CANCEL)); + ARDOUR_UI::CloseAllDialogs.connect (sigc::bind (sigc::mem_fun (*this, &WavesDialog::response), Gtk::RESPONSE_CANCEL)); _proxy = new WM::ProxyTemporary (get_title(), this); WM::Manager::instance().register_window (_proxy); @@ -84,7 +84,13 @@ WavesDialog::WavesDialog (std::string layout_script_file, bool modal, bool use_s get_vbox()->set_spacing (0); get_vbox()->set_border_width (0); - read_layout(layout_script_file); + XMLNode* root = xml_tree()->root(); + std::string title = xml_property (*root, "title", ""); + set_title(title); + + bool resizeable = xml_property (*root, "resizeable", false); + property_allow_grow().set_value(resizeable); + set_position (Gtk::WIN_POS_MOUSE); } @@ -148,29 +154,3 @@ WavesDialog::on_delete_event (GdkEventAny*) hide (); return false; } - - -// Layout - -bool -WavesDialog::read_layout (std::string file_name) -{ - const XMLTree* layout = WavesUI::load_layout(file_name); - if (layout == NULL) { - return false; - } - XMLNode* root = layout->root(); - if ((root == NULL) || strcasecmp(root->name().c_str(), "dialog")) { - return false; - } - - std::string title = xml_property (*root, "title", ""); - set_title(title); - bool resizeable = xml_property (*root, "resizeable", false); - property_allow_grow().set_value(resizeable); - - set_border_width(0); - - WavesUI::create_ui(layout, *get_vbox(), _children); - return true; -} diff --git a/gtk2_ardour/waves_dialog.h b/gtk2_ardour/waves_dialog.h index 2299ef4ecb..9071a578da 100644 --- a/gtk2_ardour/waves_dialog.h +++ b/gtk2_ardour/waves_dialog.h @@ -41,7 +41,7 @@ class XMLNode; * method of connecting and disconnecting from a Session with * all other objects that have a handle on a Session. */ -class WavesDialog : public Gtk::Dialog, public ARDOUR::SessionHandlePtr +class WavesDialog : public Gtk::Dialog, public ARDOUR::SessionHandlePtr, public WavesUI { public: @@ -55,18 +55,11 @@ class WavesDialog : public Gtk::Dialog, public ARDOUR::SessionHandlePtr void on_unmap (); void on_show (); - protected: - - bool read_layout (std::string file_name); - WavesUI::WidgetMap& named_children() { return _children; } - private: WM::ProxyTemporary* _proxy; bool _splash_pushed; - WavesUI::WidgetMap _children; - static sigc::signal CloseAllDialogs; }; diff --git a/gtk2_ardour/waves_ui.cc b/gtk2_ardour/waves_ui.cc index 89c1d095e8..e2473329cf 100644 --- a/gtk2_ardour/waves_ui.cc +++ b/gtk2_ardour/waves_ui.cc @@ -21,6 +21,7 @@ #include "waves_ui.h" #include "pbd/file_utils.h" +#include "pbd/failed_constructor.h" #include "ardour/filesystem_paths.h" #include "utils.h" @@ -30,8 +31,34 @@ using namespace PBD; using namespace ARDOUR; +std::map WavesUI::__xml_tree_cache; + +WavesUI::WavesUI (std::string layout_script_file, Gtk::Container& root) + : _xml_tree (NULL) +{ + // To avoid a need of reading the same file many times: + std::map::const_iterator it = __xml_tree_cache.find(layout_script_file); + if (it != __xml_tree_cache.end()) { + _xml_tree = (*it).second; + } else { + std::string layout_file; + Searchpath spath (ardour_data_search_path()); + spath.add_subdirectory_to_paths("ui"); + + if (!find_file_in_search_path (spath, layout_script_file, layout_file)) { + dbg_msg("File not found: " + layout_script_file); + throw failed_constructor (); + } + + _xml_tree = new XMLTree (layout_file, false); + __xml_tree_cache[layout_script_file] = _xml_tree; + } + + create_ui(_xml_tree, root); +} + Gtk::Widget* -WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles) { Gtk::Object* child = NULL; std::string widget_type = definition.name(); @@ -102,7 +129,7 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, Wid int minposy = xml_property (definition, "minposy", styles, -1); int maxposx = xml_property (definition, "maxposx", styles, minposx); int maxposy = xml_property (definition, "maxposy", styles, minposy); - Gtk::Adjustment& adjustment = named_widgets.get_adjustment(adjustment_id.c_str()); + Gtk::Adjustment& adjustment = get_adjustment(adjustment_id.c_str()); child = manage (new Gtkmm2ext::Fader(adjustment, face_image, handle_image, active_handle_image, minposx, minposy, maxposx, maxposy)); } else if (widget_type == "ADJUSTMENT") { //dbg_msg("Creating ADJUSTMENT"); @@ -121,7 +148,7 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, Wid if (child != NULL) { if (!widget_id.empty()) { - named_widgets[widget_id] = child; + (*this)[widget_id] = child; } if (dynamic_cast(child)) { set_attributes(*dynamic_cast(child), definition, styles); @@ -132,9 +159,9 @@ WavesUI::create_widget (const XMLNode& definition, const XMLNodeMap& styles, Wid Gtk::Widget* -WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles) { - Gtk::Widget* child = create_widget(definition, styles, named_widgets); + Gtk::Widget* child = create_widget(definition, styles); if (child != NULL) { @@ -155,9 +182,9 @@ WavesUI::add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeM Gtk::Widget* -WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles) { - Gtk::Widget* child = create_widget(definition, styles, named_widgets); + Gtk::Widget* child = create_widget(definition, styles); if (child != NULL) { @@ -168,9 +195,9 @@ WavesUI::add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, con Gtk::Widget* -WavesUI::add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNodeMap& styles) { - Gtk::Widget* child = create_widget(definition, styles, named_widgets); + Gtk::Widget* child = create_widget(definition, styles); if (child != NULL) { @@ -181,9 +208,9 @@ WavesUI::add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNo Gtk::Widget* -WavesUI::add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XMLNodeMap& styles) { - Gtk::Widget* child = create_widget(definition, styles, named_widgets); + Gtk::Widget* child = create_widget(definition, styles); if (child != NULL) { @@ -194,9 +221,9 @@ WavesUI::add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XML Gtk::Widget* -WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles) { - Gtk::Widget* child = create_widget(definition, styles, named_widgets); + Gtk::Widget* child = create_widget(definition, styles); if (child != NULL) { @@ -209,25 +236,25 @@ WavesUI::add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNo Gtk::Widget* -WavesUI::add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets) +WavesUI::add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles) { Gtk::Widget* child = NULL; if(dynamic_cast (&parent)) { - child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles, named_widgets); + child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles); } else if(dynamic_cast (&parent)) { - child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles, named_widgets); + child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles); } else if(dynamic_cast (&parent)) { - child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles, named_widgets); + child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles); } else if(dynamic_cast (&parent)) { - child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles, named_widgets); + child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles); } else if(dynamic_cast (&parent)) { - child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles, named_widgets); + child = WavesUI::add_widget (*dynamic_cast (&parent), definition, styles); } Gtk::Container* container = dynamic_cast(child); if (container != NULL) { - WavesUI::create_ui (definition.children(), styles, *container, named_widgets); + WavesUI::create_ui (definition.children(), styles, *container); Gtk::ScrolledWindow* sw = dynamic_cast(child); if (sw != NULL) { Gtk::Viewport* vp = (Gtk::Viewport*)sw->get_child(); @@ -241,29 +268,27 @@ WavesUI::add_widget (Gtk::Container& parent, const XMLNode& definition, const XM } void -WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root, WidgetMap& named_widgets) +WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root) { for (XMLNodeList::const_iterator i = definition.begin(); i != definition.end(); ++i) { - WavesUI::add_widget (root, **i, styles, named_widgets); + WavesUI::add_widget (root, **i, styles); } } void -WavesUI::create_ui (const XMLTree& layout, Gtk::Container& root, WidgetMap& named_widgets) +WavesUI::create_ui (const XMLTree& layout, Gtk::Container& root) { XMLNodeMap styles; get_styles(layout, styles); const XMLNodeList& definition = layout.root()->children(); - WavesUI::create_ui (definition, styles, root, named_widgets); + WavesUI::create_ui (definition, styles, root); } -static std::map xml_tree_cache; - const XMLTree* WavesUI::load_layout (const std::string xml_file_name) { - std::map::const_iterator it = xml_tree_cache.find(xml_file_name); - if (it != xml_tree_cache.end()) { + std::map::const_iterator it = __xml_tree_cache.find(xml_file_name); + if (it != __xml_tree_cache.end()) { return (*it).second; } @@ -277,7 +302,7 @@ WavesUI::load_layout (const std::string xml_file_name) } const XMLTree* tree = new XMLTree (layout_file, false); - xml_tree_cache[xml_file_name] = tree; + __xml_tree_cache[xml_file_name] = tree; return tree; } @@ -412,10 +437,10 @@ WavesUI::set_attributes (Gtk::Widget& widget, const XMLNode& definition, const X } Gtk::Object* -WavesUI::WidgetMap::get_object(const char *id) +WavesUI::get_object(const char *id) { Gtk::Object* object = NULL; - WidgetMap::iterator it = find(id); + WavesUI::iterator it = find(id); if(it != end()) object = it->second; @@ -423,7 +448,7 @@ WavesUI::WidgetMap::get_object(const char *id) } Gtk::Adjustment& -WavesUI::WidgetMap::get_adjustment(const char* id) +WavesUI::get_adjustment(const char* id) { Gtk::Adjustment* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -434,7 +459,7 @@ WavesUI::WidgetMap::get_adjustment(const char* id) } Gtk::VBox& -WavesUI::WidgetMap::get_vbox (const char* id) +WavesUI::get_v_box (const char* id) { Gtk::VBox* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -446,7 +471,7 @@ WavesUI::WidgetMap::get_vbox (const char* id) Gtk::HBox& -WavesUI::WidgetMap::get_hbox (const char* id) +WavesUI::get_h_box (const char* id) { Gtk::HBox* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -458,7 +483,7 @@ WavesUI::WidgetMap::get_hbox (const char* id) Gtk::Layout& -WavesUI::WidgetMap::get_layout (const char* id) +WavesUI::get_layout (const char* id) { Gtk::Layout* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -470,7 +495,7 @@ WavesUI::WidgetMap::get_layout (const char* id) Gtk::Label& -WavesUI::WidgetMap::get_label (const char* id) +WavesUI::get_label (const char* id) { Gtk::Label* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -482,7 +507,7 @@ WavesUI::WidgetMap::get_label (const char* id) Gtk::ComboBoxText& -WavesUI::WidgetMap::get_combo_box_text (const char* id) +WavesUI::get_combo_box_text (const char* id) { Gtk::ComboBoxText* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -494,7 +519,7 @@ WavesUI::WidgetMap::get_combo_box_text (const char* id) WavesButton& -WavesUI::WidgetMap::get_waves_button (const char* id) +WavesUI::get_waves_button (const char* id) { WavesButton* child = dynamic_cast (get_object(id)); if (child == NULL ) { @@ -505,7 +530,7 @@ WavesUI::WidgetMap::get_waves_button (const char* id) } Gtkmm2ext::Fader& -WavesUI::WidgetMap::get_fader (const char* id) +WavesUI::get_fader (const char* id) { Gtkmm2ext::Fader* child = dynamic_cast (get_object(id)); if (child == NULL ) { diff --git a/gtk2_ardour/waves_ui.h b/gtk2_ardour/waves_ui.h index 726f2fdd77..86fdadad8f 100644 --- a/gtk2_ardour/waves_ui.h +++ b/gtk2_ardour/waves_ui.h @@ -36,36 +36,40 @@ #include "waves_icon_button.h" using namespace ArdourCanvas::XMLUI; -namespace WavesUI { +class WavesUI : public std::map { - class WidgetMap : public std::map - { - public: - Gtk::Adjustment& get_adjustment (const char* id); - Gtk::VBox& get_vbox (const char* id); - Gtk::HBox& get_hbox (const char* id); - Gtk::Layout& get_layout (const char* id); - Gtk::Label& get_label (const char* id); - Gtk::Image& get_image (const char* id); - Gtk::ComboBoxText& get_combo_box_text (const char* id); - WavesButton& get_waves_button (const char* id); - Gtkmm2ext::Fader& get_fader (const char* id); - private: - Gtk::Object* get_object(const char *id); - }; + public: + WavesUI (std::string layout_script_file, Gtk::Container& root); - const XMLTree* load_layout (const std::string xml_file_name); - void create_ui (const XMLTree& layout, Gtk::Container& root, WidgetMap& named_widgets); - void create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root, WidgetMap& named_widgets); - Gtk::Widget* create_widget (const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); - Gtk::Widget* add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XMLNodeMap& styles, WidgetMap& named_widgets); + Gtk::Adjustment& get_adjustment (const char* id); + Gtk::VBox& get_v_box (const char* id); + Gtk::HBox& get_h_box (const char* id); + Gtk::Layout& get_layout (const char* id); + Gtk::Label& get_label (const char* id); + Gtk::Image& get_image (const char* id); + Gtk::ComboBoxText& get_combo_box_text (const char* id); + WavesButton& get_waves_button (const char* id); + Gtkmm2ext::Fader& get_fader (const char* id); + const XMLTree* xml_tree() { return _xml_tree; } + + protected: void set_attributes (Gtk::Widget& widget, const XMLNode& definition, const XMLNodeMap& styles); -} + private: + static std::map __xml_tree_cache; + const XMLTree* _xml_tree; + + Gtk::Object* get_object(const char *id); + const XMLTree* load_layout (const std::string xml_file_name); + void create_ui (const XMLTree& layout, Gtk::Container& root); + void create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root); + Gtk::Widget* create_widget (const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::Box& parent, const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::ScrolledWindow& parent, const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::Window& parent, const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::Layout& parent, const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::Container& parent, const XMLNode& definition, const XMLNodeMap& styles); + Gtk::Widget* add_widget (Gtk::EventBox& parent, const XMLNode& definition, const XMLNodeMap& styles); +}; #endif //__WAVES_UI_H__ \ No newline at end of file diff --git a/gtk2_ardour/waves_window.cc b/gtk2_ardour/waves_window.cc deleted file mode 100755 index d3d613cd7e..0000000000 --- a/gtk2_ardour/waves_window.cc +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (C) 2014 Waves Audio Ltd. - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "waves_window.h" #include "dbg_msg.h" -WavesWindow::WavesWindow (Gtk::WindowType window_type) : Gtk::Window (window_type) { } -WavesWindow::WavesWindow (Gtk::WindowType window_type, std::string layout_script) : Gtk::Window (window_type) { const XMLTree* layout = WavesUI::load_layout(layout_script); if (layout == NULL) { return; } - XMLNode* root = layout->root(); if ((root == NULL) || strcasecmp(root->name().c_str(), "Window")) { return; } - WavesUI::create_ui(layout, *this, _children); } \ No newline at end of file diff --git a/gtk2_ardour/waves_window.h b/gtk2_ardour/waves_window.h deleted file mode 100755 index 7d0fb57061..0000000000 --- a/gtk2_ardour/waves_window.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (C) 2014 Waves Audio Ltd. - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __waves_window_h__ #define __waves_window_h__ #include -#include -#include "waves_ui.h" - -class WavesWindow : public Gtk::Window { public: WavesWindow (Gtk::WindowType window_type); WavesWindow (Gtk::WindowType window_type, std::string layout_script); Gtk::VBox& get_vbox (const char* id) { return _children.get_vbox (id); } - Gtk::HBox& get_hbox (const char* id) { return _children.get_hbox (id); } - Gtk::Layout& get_layout (const char* id) { return _children.get_layout (id); } - Gtk::Label& get_label (const char* id) { return _children.get_label (id); } - Gtk::ComboBoxText& get_combo_box_text (const char* id) { return _children.get_combo_box_text (id); } - WavesButton& get_waves_button (const char* id) { return _children.get_waves_button (id); } - Gtk::Adjustment& get_adjustment (const char* id) { return _children.get_adjustment (id); } - private: WavesUI::WidgetMap _children; }; -#endif // __waves_window_h__ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 39e417e8af..a452984b99 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -38,7 +38,6 @@ gtk2_ardour_sources = [ 'waves_icon_button.cc', 'ardour_dialog.cc', 'waves_dialog.cc', - 'waves_window.cc', 'ardour_ui.cc', 'ardour_ui2.cc', 'ardour_ui_dependents.cc',