#include <cmath>
#include <sigc++/bind.h>
+#include "canvas/canvas.h"
+
#include "pbd/error.h"
#include "pbd/basename.h"
#include "pbd/fastlog.h"
#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"
#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"
#include "rc_option_editor.h"
#include "time_info_box.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
-bool
-ARDOUR_UI::tabs_button_event (GdkEventButton* ev)
-{
- std::vector<Widget*> children = _tabs.get_children();
-
- for (std::vector<Widget*>::iterator w = children.begin(); w != children.end(); ++w) {
-
- Gtk::Widget* close_button = reinterpret_cast<Gtk::Widget*> ((*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;
-}
-
-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)
-{
-}
-
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"));
#define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
+static
+bool drag_failed (const Glib::RefPtr<Gdk::DragContext>& context, DragResult result, Tabbable* tab)
+{
+ if (result == Gtk::DRAG_RESULT_NO_TARGET) {
+ tab->detach ();
+ return true;
+ }
+ return false;
+}
+
void
ARDOUR_UI::setup_transport ()
{
RefPtr<Action> 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);
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<Box*>(&top_packer),
- static_cast<Widget*>(&transport_frame)));
- transport_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
- static_cast<Widget*> (&transport_frame), 1));
- transport_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::detach_tearoff), static_cast<Box*>(&top_packer),
- static_cast<Widget*>(&transport_frame)));
- transport_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::reattach_tearoff), static_cast<Box*> (&top_packer),
- static_cast<Widget*> (&transport_frame), 1));
-
auto_return_button.set_text(_("Auto Return"));
follow_edits_button.set_text(_("Follow Edits"));
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 */
}
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)
UIConfiguration::instance().reset_dpi ();
}
-void
-ARDOUR_UI::update_tearoff_visibility ()
-{
- if (editor) {
- editor->update_tearoff_visibility ();
- }
-}
-
void
ARDOUR_UI::maximise_editing_space ()
{
}
}
-