X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui2.cc;h=c4404b824358f7030b86d6d7d93dfd3c09ae838b;hb=cef341631b55526e4b2bad940064491922c07701;hp=c7fb167b7ce2602870f27db86c00e7c4892b312a;hpb=5c8e239f95138d2a0fa989da7ccbf77a7716fdf4;p=ardour.git diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index c7fb167b7c..c4404b8243 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -29,13 +29,16 @@ #include #include +#include "canvas/canvas.h" + #include "pbd/error.h" #include "pbd/basename.h" #include "pbd/fastlog.h" -#include -#include -#include -#include + +#include "gtkmm2ext/cairocell.h" +#include "gtkmm2ext/utils.h" +#include "gtkmm2ext/click_box.h" +#include "gtkmm2ext/window_title.h" #include "ardour/profile.h" #include "ardour/session.h" @@ -47,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" @@ -56,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; @@ -66,65 +70,12 @@ using namespace Gtk; using namespace Glib; using namespace ARDOUR_UI_UTILS; -int -ARDOUR_UI::setup_windows () -{ - 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; - } - - /* all other dialogs are created conditionally */ - - we_have_dependents (); - -#ifdef TOP_MENUBAR - HBox* status_bar_packer = manage (new HBox); - 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_packer->pack_start (*status_bar_event_box, true, true, 6); - - status_bar_label.show (); - status_bar_event_box->show (); - status_bar_packer->show (); - - status_bar_event_box->signal_button_press_event().connect (mem_fun (*this, &ARDOUR_UI::status_bar_button_press)); - - editor->get_status_bar_packer().pack_start (*status_bar_packer, true, true); - editor->get_status_bar_packer().pack_start (menu_bar_base, false, false, 2); -#else - top_packer.pack_start (menu_bar_base, false, false); -#endif - - editor->add_toplevel_menu (top_packer); - - editor->add_transport_frame (transport_frame); - - setup_transport(); - - build_menu_bar (); - - setup_tooltips (); - - return 0; -} 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")); @@ -134,11 +85,11 @@ ARDOUR_UI::setup_tooltips () set_tip (auto_loop_button, _("Play loop range")); set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels")); set_tip (auto_return_button, _("Return to last playback start when stopped")); - set_tip (follow_edits_button, _("Playhead follows Range Selections and Edits")); + set_tip (follow_edits_button, _("Playhead follows range selections and edits")); set_tip (auto_input_button, _("Be sensible about input monitoring")); set_tip (click_button, _("Enable/Disable audio click")); set_tip (solo_alert_button, _("When active, something is soloed.\nClick to de-solo everything")); - set_tip (auditioning_alert_button, _("When active, auditioning is taking place\nClick to stop the audition")); + set_tip (auditioning_alert_button, _("When active, auditioning is taking place.\nClick to stop the audition")); set_tip (feedback_alert_button, _("When active, there is a feedback loop.")); set_tip (primary_clock, _("Primary Clock right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite Esc: cancel; Enter: confirm; postfix the edit with '+' or '-' to enter delta times.\n")); set_tip (secondary_clock, _("Secondary Clock right-click to set display mode. Click to edit, click+drag a digit or mouse-over+scroll wheel to modify.\nText edits: right-to-left overwrite Esc: cancel; Enter: confirm; postfix the edit with '+' or '-' to enter delta times.\n")); @@ -216,25 +167,25 @@ ARDOUR_UI::tearoff_settings (const char* name) const return 0; } -#define PX_SCALE(px) std::max((float)px, rintf((float)px * ARDOUR_UI::ui_scale)) +#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); @@ -243,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")); @@ -324,7 +266,8 @@ ARDOUR_UI::setup_transport () /* CANNOT sigc::bind these to clicked or toggled, must use pressed or released */ solo_alert_button.set_name ("rude solo"); - solo_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::solo_alert_press), false); + act = ActionManager::get_action (X_("Main"), X_("cancel-solo")); + solo_alert_button.set_related_action (act); auditioning_alert_button.set_name ("rude audition"); auditioning_alert_button.signal_button_press_event().connect (sigc::mem_fun(*this,&ARDOUR_UI::audition_alert_press), false); feedback_alert_button.set_name ("feedback alert"); @@ -342,7 +285,7 @@ ARDOUR_UI::setup_transport () alert_box.pack_start (feedback_alert_button, true, true); /* all transport buttons should be the same size vertically and - * horizontally + * horizontally */ Glib::RefPtr transport_button_size_group = SizeGroup::create (SIZE_GROUP_BOTH); @@ -411,7 +354,7 @@ ARDOUR_UI::setup_transport () shuttle_box = manage (new ShuttleControl); shuttle_box->show (); - + VBox* transport_vbox = manage (new VBox); transport_vbox->set_name ("TransportBase"); transport_vbox->set_border_width (0); @@ -424,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 */ @@ -442,60 +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) -{ -// editor->ensure_float (transport_tearoff->tearoff_window()); - 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) @@ -527,19 +473,6 @@ ARDOUR_UI::audition_alert_press (GdkEventButton*) return true; } -bool -ARDOUR_UI::solo_alert_press (GdkEventButton*) -{ - if (_session) { - if (_session->soloing()) { - _session->set_solo (_session->get_routes(), false); - } else if (_session->listening()) { - _session->set_listen (_session->get_routes(), false); - } - } - return true; -} - bool ARDOUR_UI::feedback_alert_press (GdkEventButton *) { @@ -678,15 +611,7 @@ ARDOUR_UI::editor_realized () boost::function pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1)); Config->map_parameters (pc); - reset_dpi (); -} - -void -ARDOUR_UI::update_tearoff_visibility () -{ - if (editor) { - editor->update_tearoff_visibility (); - } + UIConfiguration::instance().reset_dpi (); } void @@ -708,15 +633,12 @@ ARDOUR_UI::restore_editing_space () void ARDOUR_UI::show_ui_prefs () { - RefPtr act = ActionManager::get_action (X_("Window"), X_("toggle-rc-options-editor")); - assert (act); - - act->activate(); - - 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) { @@ -725,12 +647,8 @@ ARDOUR_UI::click_button_clicked (GdkEventButton* ev) return false; } - RefPtr act = ActionManager::get_action (X_("Window"), X_("toggle-rc-options-editor")); - assert (act); - - act->activate(); - - rc_option_editor->set_current_page (_("Misc")); + show_tabbable (rc_option_editor); + rc_option_editor->set_current_page (_("Misc/Click")); return true; } @@ -743,7 +661,33 @@ ARDOUR_UI::toggle_follow_edits () RefPtr tact = RefPtr::cast_dynamic (act); assert (tact); - ui_config->set_follow_edits (tact->get_active ()); + UIConfiguration::instance().set_follow_edits (tact->get_active ()); } - +void +ARDOUR_UI::update_title () +{ + if (_session) { + bool dirty = _session->dirty(); + + string session_name; + + if (_session->snap_name() != _session->name()) { + session_name = _session->snap_name(); + } else { + session_name = _session->name(); + } + + if (dirty) { + session_name = "*" + session_name; + } + + WindowTitle title (session_name); + title += Glib::get_application_name(); + _main_window.set_title (title.get_string()); + } else { + WindowTitle title (Glib::get_application_name()); + _main_window.set_title (title.get_string()); + } + +}