Reverse the order of vertical tabs in the port matrix
[ardour.git] / gtk2_ardour / editor_canvas.cc
index adcaa63cad13c576292eaae89ba0ad50b43c93ac..da928a6d9ee888b485e3e843f2ad4ce2730cc635 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "ardour_ui.h"
 #include "editor.h"
+#include "global_signals.h"
 #include "waveview.h"
 #include "simplerect.h"
 #include "simpleline.h"
@@ -53,6 +54,7 @@
 #include "keyboard.h"
 #include "editor_cursors.h"
 #include "mouse_cursors.h"
+#include "verbose_cursor.h"
 
 #include "i18n.h"
 
@@ -115,17 +117,7 @@ Editor::initialize_canvas ()
         gint phys_width = physical_screen_width (Glib::RefPtr<Gdk::Window>());
         gint phys_height = physical_screen_height (Glib::RefPtr<Gdk::Window>());
 
-       /* stuff for the verbose canvas cursor */
-
-       Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
-
-       verbose_canvas_cursor = new ArdourCanvas::NoEventText (*track_canvas->root());
-       verbose_canvas_cursor->property_font_desc() = *font;
-       verbose_canvas_cursor->property_anchor() = ANCHOR_NW;
-
-       delete font;
-
-       verbose_cursor_visible = false;
+       _verbose_cursor = new VerboseCursor (this);
 
        /* on the bottom, an image */
 
@@ -162,64 +154,34 @@ Editor::initialize_canvas ()
        _region_motion_group = new ArdourCanvas::Group (*_trackview_group);
 
        meter_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               meter_bar = new ArdourCanvas::SimpleRect (*meter_bar_group, 0.0, 0.0, phys_width, timebar_height - 1);
-               meter_bar->property_outline_pixels() = 1;
-       } else {
-               meter_bar = new ArdourCanvas::SimpleRect (*meter_bar_group, 0.0, 0.0, phys_width, timebar_height);
-               meter_bar->property_outline_pixels() = 0;
-       }
-       meter_bar->property_outline_what() = (0x1 | 0x8);
+       meter_bar = new ArdourCanvas::SimpleRect (*meter_bar_group, 0.0, 0.0, phys_width, timebar_height - 1);
+       meter_bar->property_outline_pixels() = 1;
+       meter_bar->property_outline_what() = 0x8;
 
        tempo_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               tempo_bar = new ArdourCanvas::SimpleRect (*tempo_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
-               tempo_bar->property_outline_pixels() = 1;
-       } else {
-               tempo_bar = new ArdourCanvas::SimpleRect (*tempo_bar_group, 0.0, 0.0, phys_width, (timebar_height));
-               tempo_bar->property_outline_pixels() = 0;
-       }
-       tempo_bar->property_outline_what() = (0x1 | 0x8);
+       tempo_bar = new ArdourCanvas::SimpleRect (*tempo_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
+       tempo_bar->property_outline_pixels() = 1;
+       tempo_bar->property_outline_what() = 0x8;
 
        range_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               range_marker_bar = new ArdourCanvas::SimpleRect (*range_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
-               range_marker_bar->property_outline_pixels() = 1;
-       } else {
-               range_marker_bar = new ArdourCanvas::SimpleRect (*range_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height));
-               range_marker_bar->property_outline_pixels() = 0;
-       }
-       range_marker_bar->property_outline_what() = (0x1 | 0x8);
+       range_marker_bar = new ArdourCanvas::SimpleRect (*range_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
+       range_marker_bar->property_outline_pixels() = 1;
+       range_marker_bar->property_outline_what() = 0x8;
 
        transport_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               transport_marker_bar = new ArdourCanvas::SimpleRect (*transport_marker_bar_group, 0.0, 0.0,  phys_width, (timebar_height - 1));
-               transport_marker_bar->property_outline_pixels() = 1;
-       } else {
-               transport_marker_bar = new ArdourCanvas::SimpleRect (*transport_marker_bar_group, 0.0, 0.0,  phys_width, (timebar_height));
-               transport_marker_bar->property_outline_pixels() = 0;
-       }
-       transport_marker_bar->property_outline_what() = (0x1 | 0x8);
+       transport_marker_bar = new ArdourCanvas::SimpleRect (*transport_marker_bar_group, 0.0, 0.0,  phys_width, (timebar_height - 1));
+       transport_marker_bar->property_outline_pixels() = 1;
+       transport_marker_bar->property_outline_what() = 0x8;
 
        marker_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               marker_bar = new ArdourCanvas::SimpleRect (*marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
-               marker_bar->property_outline_pixels() = 1;
-       } else {
-               marker_bar = new ArdourCanvas::SimpleRect (*marker_bar_group, 0.0, 0.0, phys_width, (timebar_height));
-               marker_bar->property_outline_pixels() = 0;
-       }
-       marker_bar->property_outline_what() = (0x1 | 0x8);
+       marker_bar = new ArdourCanvas::SimpleRect (*marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
+       marker_bar->property_outline_pixels() = 1;
+       marker_bar->property_outline_what() = 0x8;
 
        cd_marker_bar_group = new ArdourCanvas::Group (*track_canvas->root ());
-       if (Profile->get_sae()) {
-               cd_marker_bar = new ArdourCanvas::SimpleRect (*cd_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
-               cd_marker_bar->property_outline_pixels() = 1;
-       } else {
-               cd_marker_bar = new ArdourCanvas::SimpleRect (*cd_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height));
-               cd_marker_bar->property_outline_pixels() = 0;
-       }
-       cd_marker_bar->property_outline_what() = (0x1 | 0x8);
+       cd_marker_bar = new ArdourCanvas::SimpleRect (*cd_marker_bar_group, 0.0, 0.0, phys_width, (timebar_height - 1));
+       cd_marker_bar->property_outline_pixels() = 1;
+       cd_marker_bar->property_outline_what() = 0x8;
 
        timebar_group =  new ArdourCanvas::Group (*track_canvas->root(), 0.0, 0.0);
        cursor_group = new ArdourCanvas::Group (*track_canvas->root(), 0.0, 0.0);
@@ -366,66 +328,40 @@ Editor::track_canvas_size_allocated ()
        redisplay_tempo (false);
        _summary->set_overlays_dirty ();
 
-       Resized (); /* EMIT_SIGNAL */
-
        return false;
 }
 
 void
-Editor::controls_layout_size_request (Requisition* req)
+Editor::reset_controls_layout_width ()
 {
-       double pos = 0;
-       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
-               pos += (*i)->effective_height ();
-       }
-
-       gint height = min ((gint) pos, (gint) (physical_screen_height(get_window()) - 600));
-
-       bool changed = false;
-
-       gint w = edit_controls_vbox.get_width();
-       if (_group_tabs->is_mapped()) {
-               w += _group_tabs->get_width ();
-       }
-
-       gint width = max (w, controls_layout.get_width());
+       GtkRequisition req;
+       gint w;
 
-       /* don't get too big. the fudge factors here are just guesses */
+       edit_controls_vbox.size_request (req);
+       w = req.width;
 
-       width =  min (width, (gint) (physical_screen_width(get_window()) - 300));
+        if (_group_tabs->is_mapped()) {
+               _group_tabs->size_request (req);
+                w += req.width;
+        }
 
-       if ((req->width != width) || (req->height != height)) {
-               changed = true;
-               controls_layout_size_request_connection.disconnect ();
-       }
-
-       if (req->width != width) {
-               gint vbox_width = edit_controls_vbox.get_width();
-               if (_group_tabs->is_mapped()) {
-                       vbox_width += _group_tabs->get_width();
-               }
-               req->width = width;
+        /* the controls layout has no horizontal scrolling, its visible
+           width is always equal to the total width of its contents.
+        */
 
-               /* this one is important: it determines how big the layout thinks it really is, as
-                  opposed to what it displays on the screen
-               */
-               controls_layout.property_width () = vbox_width;
-               controls_layout.property_width_request () = vbox_width;
+        controls_layout.property_width() = w;
+        controls_layout.property_width_request() = w;
+}
 
-               // time_button_event_box.property_width_request () = vbox_width;
-               // zoom_box.property_width_request () = vbox_width;
-       }
+void
+Editor::reset_controls_layout_height (int32_t h)
+{
+        /* set the height of the scrollable area (i.e. the sum of all contained widgets)
+         */
 
-       if (req->height != height) {
-               req->height = height;
-               controls_layout.property_height () = (guint) floor (pos);
-               controls_layout.property_height_request () = height;
-       }
+        controls_layout.property_height() = h;
 
-       if (changed) {
-               controls_layout_size_request_connection = controls_layout.signal_size_request().connect (sigc::mem_fun (*this, &Editor::controls_layout_size_request));
-       }
-       //cerr << "sizes = " << req->width << " " << edit_controls_vbox.get_width() << " " << controls_layout.get_width() << " " << zoom_box.get_width() << " " << time_button_frame.get_width() << endl;//DEBUG
+        /* size request is set elsewhere, see ::track_canvas_allocate() */
 }
 
 bool
@@ -761,6 +697,22 @@ Editor::entered_track_canvas (GdkEventCrossing */*ev*/)
        return FALSE;
 }
 
+void
+Editor::ensure_time_axis_view_is_visible (const TimeAxisView& tav)
+{
+       double begin = tav.y_position();
+
+       double v = vertical_adjustment.get_value ();
+
+       if (begin < v || begin + tav.current_height() > v + _canvas_height - canvas_timebars_vsize) {
+               /* try to put the TimeAxisView roughly central */
+               if (begin >= _canvas_height/2.0) {
+                       begin -= _canvas_height/2.0;
+               }
+               vertical_adjustment.set_value (begin);
+       }
+}
+
 void
 Editor::tie_vertical_scrolling ()
 {
@@ -834,7 +786,7 @@ void
 Editor::color_handler()
 {
        playhead_cursor->canvas_item.property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_PlayHead.get();
-       verbose_canvas_cursor->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get();
+       _verbose_cursor->set_color (ARDOUR_UI::config()->canvasvar_VerboseCanvasCursor.get());
 
        meter_bar->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MeterBar.get();
        meter_bar->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerBarSeparator.get();
@@ -938,21 +890,21 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save)
 }
 
 bool
-Editor::track_canvas_key_press (GdkEventKey* event)
+Editor::track_canvas_key_press (GdkEventKey*)
 {
        /* XXX: event does not report the modifier key pressed down, AFAICS, so use the Keyboard object instead */
        if (mouse_mode == Editing::MouseZoom && Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
-               set_canvas_cursor (_cursors->zoom_out);
+               set_canvas_cursor (_cursors->zoom_out, true);
        }
 
        return false;
 }
 
 bool
-Editor::track_canvas_key_release (GdkEventKey* event)
+Editor::track_canvas_key_release (GdkEventKey*)
 {
        if (mouse_mode == Editing::MouseZoom && !Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
-               set_canvas_cursor (_cursors->zoom_in);
+               set_canvas_cursor (_cursors->zoom_in, true);
        }
 
        return false;