X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui2.cc;h=00a1bde046977aabdfdcf71c6c9c2bb67dd2827c;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=eaae3c0e03a6e045e92dd8e4bb10c9e327938112;hpb=1be30e040169863006eb37d8ee2b8ad919febfa3;p=ardour.git diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index eaae3c0e03..00a1bde046 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -29,6 +29,8 @@ #include #include +#include "canvas/canvas.h" + #include "pbd/error.h" #include "pbd/basename.h" #include "pbd/fastlog.h" @@ -36,7 +38,6 @@ #include "gtkmm2ext/cairocell.h" #include "gtkmm2ext/utils.h" #include "gtkmm2ext/click_box.h" -#include "gtkmm2ext/tearoff.h" #include "gtkmm2ext/window_title.h" #include "ardour/profile.h" @@ -49,6 +50,7 @@ #include "audio_clock.h" #include "actions.h" #include "main_clock.h" +#include "mixer_ui.h" #include "utils.h" #include "theme_manager.h" #include "midi_tracer.h" @@ -58,7 +60,7 @@ #include "rc_option_editor.h" #include "time_info_box.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -69,217 +71,11 @@ using namespace Glib; using namespace ARDOUR_UI_UTILS; -static GtkNotebook* -tab_window_root_drop (GtkNotebook* src, - GtkWidget* w, - gint x, - gint y, - gpointer user_data) -{ - return ARDOUR_UI::instance()->tab_window_root_drop (src, w, x, y, user_data); -} - -bool -ARDOUR_UI::tabs_button_event (GdkEventButton* ev) -{ - std::vector children = _tabs.get_children(); - - for (std::vector::iterator w = children.begin(); w != children.end(); ++w) { - - Gtk::Widget* close_button = reinterpret_cast ((*w)->get_data ("close-button")); - - if (close_button) { - - Gtk::Allocation alloc (close_button->get_allocation()); - int dx, dy; - - /* Allocation origin uses toplevel window coordinates; - * event origin uses _tabs-centric coordinate space, so - * translate before computing if event is inside the - * close button. - */ - - close_button->get_toplevel()->translate_coordinates (_tabs, alloc.get_x(), alloc.get_y(), dx, dy); - - if (ev->x >= dx && - ev->y >= dy && - ev->x < dx + alloc.get_width() && - ev->y < dy + alloc.get_height()) { - if (close_button->event ((GdkEvent*) ev)) { - return true; - } - } - } - } - - return false; -} - -int -ARDOUR_UI::setup_windows () -{ - /* we don't use a widget with its own window for the tab close button, - which makes it impossible to rely on GTK+ to generate signals for - events occuring "in" this widget. Instead, we pre-connect a - handler to the relevant events on the notebook and then check - to see if the event coordinates tell us that it occured "in" - the close button. - */ - _tabs.signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false); - _tabs.signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_button_event), false); - - if (create_editor ()) { - error << _("UI: cannot setup editor") << endmsg; - return -1; - } - - if (create_mixer ()) { - error << _("UI: cannot setup mixer") << endmsg; - return -1; - } - - if (create_meterbridge ()) { - error << _("UI: cannot setup meterbridge") << endmsg; - return -1; - } - - rc_option_editor = new RCOptionEditor; - rc_option_editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change)); - rc_option_editor->add_to_notebook (_tabs, _("Preferences")); - - /* all other dialogs are created conditionally */ - - we_have_dependents (); - -#ifdef TOP_MENUBAR - EventBox* status_bar_event_box = manage (new EventBox); - - status_bar_event_box->add (status_bar_label); - status_bar_event_box->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); - status_bar_label.set_size_request (300, -1); - - status_bar_label.show (); - status_bar_event_box->show (); - - status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press)); - - status_bar_hpacker.pack_start (*status_bar_event_box, true, true, 6); - status_bar_hpacker.pack_start (menu_bar_base, false, false, 2); -#else - top_packer.pack_start (menu_bar_base, false, false); -#endif - - main_vpacker.pack_start (top_packer, false, false); - - /* now add the transport frame to the top of main window */ - - main_vpacker.pack_start (transport_frame, false, false); - main_vpacker.pack_start (_tabs, true, true); - -#ifdef TOP_MENUBAR - main_vpacker.pack_start (status_bar_hpacker, false, false); -#endif - - setup_transport(); - build_menu_bar (); - setup_tooltips (); - - _main_window.signal_delete_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::main_window_delete_event)); - - /* pack the main vpacker into the main window and show everything - */ - - _main_window.add (main_vpacker); - transport_frame.show_all (); - - const XMLNode* mnode = main_window_settings (); - - if (mnode) { - const XMLProperty* prop; - gint x = -1; - gint y = -1; - gint w = -1; - gint h = -1; - - if ((prop = mnode->property (X_("x"))) != 0) { - x = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("y"))) != 0) { - y = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("w"))) != 0) { - w = atoi (prop->value()); - } - - if ((prop = mnode->property (X_("h"))) != 0) { - h = atoi (prop->value()); - } - - if (x >= 0 && y >= 0 && w >= 0 && h >= 0) { - _main_window.set_position (Gtk::WIN_POS_NONE); - } - - if (x >= 0 && y >= 0) { - _main_window.move (x, y); - } - - if (w > 0 && h > 0) { - _main_window.set_default_size (w, h); - } - } - - _main_window.show_all (); - setup_toplevel_window (_main_window, "", this); - - _tabs.signal_switch_page().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_switch)); - _tabs.signal_page_removed().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_removed)); - _tabs.signal_page_added().connect (sigc::mem_fun (*this, &ARDOUR_UI::tabs_page_added)); - - /* It would be nice if Gtkmm had wrapped this rather than just - * deprecating the old set_window_creation_hook() method, but oh well... - */ - g_signal_connect (_tabs.gobj(), "create-window", (GCallback) ::tab_window_root_drop, this); - - return 0; -} - -void -ARDOUR_UI::tabs_page_removed (Gtk::Widget*, guint) -{ - if (_tabs.get_n_pages() == 1) { - _tabs.set_show_tabs (false); - } else { - _tabs.set_show_tabs (true); - } -} - -void -ARDOUR_UI::tabs_page_added (Gtk::Widget*, guint) -{ - if (_tabs.get_n_pages() == 1) { - _tabs.set_show_tabs (false); - } else { - _tabs.set_show_tabs (true); - } -} - -void -ARDOUR_UI::tabs_switch (GtkNotebookPage*, guint page_number) -{ - if (page_number == 2) { - if (!rc_option_editor) { - rc_option_editor = new RCOptionEditor; - rc_option_editor_placeholder.pack_start (*rc_option_editor, true, true); - rc_option_editor_placeholder.show_all (); - } - } -} - void ARDOUR_UI::setup_tooltips () { + ArdourCanvas::Canvas::set_tooltip_timeout (Gtk::Settings::get_default()->property_gtk_tooltip_timeout ()); + set_tip (roll_button, _("Play from playhead")); set_tip (stop_button, _("Stop playback")); set_tip (rec_button, _("Toggle record")); @@ -373,23 +169,23 @@ ARDOUR_UI::tearoff_settings (const char* name) const #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale())) +static +bool drag_failed (const Glib::RefPtr& context, DragResult result, Tabbable* tab) +{ + if (result == Gtk::DRAG_RESULT_NO_TARGET) { + tab->detach (); + return true; + } + return false; +} + void ARDOUR_UI::setup_transport () { RefPtr act; - transport_tearoff_hbox.set_border_width (PX_SCALE(3)); - transport_tearoff_hbox.set_spacing (PX_SCALE(3)); - - transport_tearoff = manage (new TearOff (transport_tearoff_hbox)); - transport_tearoff->set_name ("TransportBase"); - transport_tearoff->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), &transport_tearoff->tearoff_window()), false); - - if (Profile->get_sae() || Profile->get_mixbus()) { - transport_tearoff->set_can_be_torn_off (false); - } - - transport_hbox.pack_start (*transport_tearoff, true, false); + transport_hbox.set_border_width (PX_SCALE(3)); + transport_hbox.set_spacing (PX_SCALE(3)); transport_base.set_name ("TransportBase"); transport_base.add (transport_hbox); @@ -398,15 +194,6 @@ ARDOUR_UI::setup_transport () transport_frame.set_name ("BaseFrame"); transport_frame.add (transport_base); - transport_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast(&top_packer), - static_cast(&transport_frame))); - transport_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast (&top_packer), - static_cast (&transport_frame), 1)); - transport_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast(&top_packer), - static_cast(&transport_frame))); - transport_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast (&top_packer), - static_cast (&transport_frame), 1)); - auto_return_button.set_text(_("Auto Return")); follow_edits_button.set_text(_("Follow Edits")); @@ -580,11 +367,7 @@ ARDOUR_UI::setup_transport () time_info_box = manage (new TimeInfoBox); - if (ARDOUR::Profile->get_trx()) { - transport_tearoff_hbox.pack_start (*time_info_box, false, false); - } - - transport_tearoff_hbox.pack_start (*transport_vbox, false, false); + transport_hbox.pack_start (*transport_vbox, false, true); /* transport related toggle controls */ @@ -598,59 +381,67 @@ ARDOUR_UI::setup_transport () } if (!ARDOUR::Profile->get_trx()) { - transport_tearoff_hbox.pack_start (*auto_box, false, false); + transport_hbox.pack_start (*auto_box, false, false); } - transport_tearoff_hbox.pack_start (*clock_box, true, true); + transport_hbox.pack_start (*clock_box, true, true); if (ARDOUR::Profile->get_trx()) { - transport_tearoff_hbox.pack_start (*auto_box, false, false); + transport_hbox.pack_start (*auto_box, false, false); } if (!ARDOUR::Profile->get_trx()) { - transport_tearoff_hbox.pack_start (*time_info_box, false, false); + transport_hbox.pack_start (*time_info_box, false, false); } if (!ARDOUR::Profile->get_trx()) { - transport_tearoff_hbox.pack_start (alert_box, false, false); - transport_tearoff_hbox.pack_start (meter_box, false, false); - transport_tearoff_hbox.pack_start (editor_meter_peak_display, false, false); + transport_hbox.pack_start (alert_box, false, false); + transport_hbox.pack_start (meter_box, false, false); + transport_hbox.pack_start (editor_meter_peak_display, false, false); } - if (Profile->get_sae()) { - Image* img = manage (new Image ((::get_icon (X_("sae"))))); - transport_tearoff_hbox.pack_end (*img, false, false); - } + Gtk::VBox* window_button_box = manage (new Gtk::VBox); - /* desensitize */ + editor_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), editor)); + mixer_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), mixer)); + prefs_visibility_button.signal_drag_failed().connect (sigc::bind (sigc::ptr_fun (drag_failed), rc_option_editor)); - set_transport_sensitivity (false); + /* catch context clicks so that we can show a menu on these buttons */ - XMLNode* tnode = tearoff_settings ("transport"); - if (tnode) { - transport_tearoff->set_state (*tnode); - } -} -#undef PX_SCALE + editor_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("editor")), false); + mixer_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("mixer")), false); + prefs_visibility_button.signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_visibility_button_press), X_("preferences")), false); -void -ARDOUR_UI::detach_tearoff (Box* b, Widget* w) -{ - b->remove (*w); -} + editor_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-editor-visibility"))); + editor_visibility_button.set_name (X_("page switch button")); + mixer_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-mixer-visibility"))); + mixer_visibility_button.set_name (X_("page switch button")); + prefs_visibility_button.set_related_action (ActionManager::get_action (X_("Common"), X_("change-preferences-visibility"))); + prefs_visibility_button.set_name (X_("page switch button")); -void -ARDOUR_UI::reattach_tearoff (Box* b, Widget* w, int32_t n) -{ - b->pack_start (*w); - b->reorder_child (*w, n); -} + Gtkmm2ext::UI::instance()->set_tip (editor_visibility_button, + string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n" + "To put the window back, use the Window > %1 > Attach menu action"), editor->name())); -void -ARDOUR_UI::reattach_all_tearoffs () -{ - if (transport_tearoff) transport_tearoff->put_it_back(); - if (editor) editor->reattach_all_tearoffs (); + Gtkmm2ext::UI::instance()->set_tip (mixer_visibility_button, + string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n" + "To put the window back, use the Window > %1 > Attach menu action"), mixer->name())); + + Gtkmm2ext::UI::instance()->set_tip (prefs_visibility_button, + string_compose (_("Drag this tab to the desktop to show %1 in its own window\n\n" + "To put the window back, use the Window > %1 > Attach menu action"), rc_option_editor->name())); + + window_button_box->pack_start (editor_visibility_button, true, false); + window_button_box->pack_start (mixer_visibility_button, true, false); + window_button_box->pack_start (prefs_visibility_button, true, false); + + transport_hbox.pack_end (*window_button_box, false, false); + transport_hbox.pack_end (action_script_table, false, false); + + /* desensitize */ + + set_transport_sensitivity (false); } +#undef PX_SCALE void ARDOUR_UI::soloing_changed (bool onoff) @@ -823,14 +614,6 @@ ARDOUR_UI::editor_realized () UIConfiguration::instance().reset_dpi (); } -void -ARDOUR_UI::update_tearoff_visibility () -{ - if (editor) { - editor->update_tearoff_visibility (); - } -} - void ARDOUR_UI::maximise_editing_space () { @@ -850,11 +633,12 @@ ARDOUR_UI::restore_editing_space () void ARDOUR_UI::show_ui_prefs () { - tabs().set_current_page (2); - rc_option_editor->set_current_page (_("GUI")); + if (rc_option_editor) { + show_tabbable (rc_option_editor); + rc_option_editor->set_current_page (_("GUI")); + } } - bool ARDOUR_UI::click_button_clicked (GdkEventButton* ev) { @@ -863,7 +647,7 @@ ARDOUR_UI::click_button_clicked (GdkEventButton* ev) return false; } - tabs().set_current_page (2); + show_tabbable (rc_option_editor); rc_option_editor->set_current_page (_("Misc")); return true; } @@ -907,4 +691,3 @@ ARDOUR_UI::update_title () } } -