#include <libgnomecanvasmm/init.h>
#include <libgnomecanvasmm/pixbuf.h>
#include <jack/types.h>
-#include <gtkmm2ext/utils.h>
+
+#include "gtkmm2ext/utils.h"
#include "ardour/profile.h"
#include "ardour/rc_configuration.h"
#include "editor_drag.h"
#include "region_view.h"
#include "editor_group_tabs.h"
-#include "editor_routes.h"
#include "editor_summary.h"
#include "keyboard.h"
#include "editor_cursors.h"
#include "mouse_cursors.h"
+#include "verbose_cursor.h"
#include "i18n.h"
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 */
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;
+ GtkRequisition req;
+ gint w;
- 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());
+ edit_controls_vbox.size_request (req);
+ w = req.width;
- /* don't get too big. the fudge factors here are just guesses */
+ if (_group_tabs->is_mapped()) {
+ _group_tabs->size_request (req);
+ w += req.width;
+ }
- width = min (width, (gint) (physical_screen_width(get_window()) - 300));
+ /* the controls layout has no horizontal scrolling, its visible
+ width is always equal to the total width of its contents.
+ */
- 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;
-
- /* 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
_drags->end_grab (0);
}
+/** If the editor window is arranged such that the edge of the trackview is right up
+ * against the edge of the screen, autoscroll will not work very well. In this situation,
+ * we start autoscrolling some distance in from the right-hand-side of the screen edge;
+ * this is the distance at which that happens.
+ */
+int
+Editor::autoscroll_fudge_threshold () const
+{
+ return current_page_frames() / 6;
+}
+
void
Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert)
{
- framepos_t rightmost_frame = leftmost_frame + current_page_frames();
bool startit = false;
+ /* Work out the distance between the right hand edge of the trackview and the edge of
+ the monitor that it is on.
+ */
+
+ Glib::RefPtr<Gdk::Window> gdk_window = get_window ();
+ Gdk::Rectangle window_rect;
+ gdk_window->get_frame_extents (window_rect);
+
+ Glib::RefPtr<Gdk::Screen> screen = get_screen ();
+ Gdk::Rectangle root_rect;
+ screen->get_root_window()->get_frame_extents (root_rect);
+
+ Gtk::Allocation editor_list = _the_notebook.get_allocation ();
+
+ framecnt_t distance = pixel_to_frame (root_rect.get_x() + root_rect.get_width() - window_rect.get_x() - window_rect.get_width());
+ if (_the_notebook.is_visible ()) {
+ distance += pixel_to_frame (editor_list.get_width());
+ }
+
+ /* Note whether we're fudging the autoscroll (see autoscroll_fudge_threshold) */
+ _autoscroll_fudging = (distance < autoscroll_fudge_threshold ());
+
double const ty = _drags->current_pointer_y() - get_trackview_group_vertical_offset ();
autoscroll_y = 0;
startit = true;
}
+ framepos_t rightmost_frame = leftmost_frame + current_page_frames();
+ if (_autoscroll_fudging) {
+ rightmost_frame -= autoscroll_fudge_threshold ();
+ }
+
if (_drags->current_pointer_frame() > rightmost_frame && allow_horiz) {
if (rightmost_frame < max_framepos) {
autoscroll_x = 1;
GdkEventMotion ev;
double new_pixel;
double target_pixel;
-
+
if (autoscroll_x_distance != 0) {
if (autoscroll_x > 0) {
autoscroll_x_distance = (_drags->current_pointer_frame() - (leftmost_frame + current_page_frames())) / 3;
+ if (_autoscroll_fudging) {
+ autoscroll_x_distance += autoscroll_fudge_threshold () / 3;
+ }
} else if (autoscroll_x < 0) {
autoscroll_x_distance = (leftmost_frame - _drags->current_pointer_frame()) / 3;
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 ()
{
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();
{
return frame_to_unit (leftmost_frame);
}
+
void
Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save)
{
current_canvas_cursor = cursor;
}
- if (is_drawable()) {
+ Glib::RefPtr<Gdk::Window> win = track_canvas->get_window();
+
+ if (win) {
track_canvas->get_window()->set_cursor (*cursor);
}
}
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;