/*
- Copyright (C) 2009 Paul Davis
+ Copyright (C) 2009 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_move_dragging (false),
_moved (false),
_zoom_dragging (false)
-
+
{
-
+
}
/** Connect to a session.
cairo_t* cr = gdk_cairo_create (get_window()->gobj());
/* Render the view rectangle */
-
+
pair<double, double> x;
pair<double, double> y;
get_editor (&x, &y);
-
+
cairo_move_to (cr, x.first, y.first);
cairo_line_to (cr, x.second, y.first);
cairo_line_to (cr, x.second, y.second);
_last_playhead = p;
cairo_destroy (cr);
-
+
return true;
}
EditorSummary::render (cairo_t* cr)
{
/* background */
-
+
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, _width, _height);
cairo_fill (cr);
}
/* compute total height of all tracks */
-
+
int h = 0;
int max_height = 0;
for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
{
uint32_t const c = r->get_fill_color ();
cairo_set_source_rgb (cr, UINT_RGBA_R (c) / 255.0, UINT_RGBA_G (c) / 255.0, UINT_RGBA_B (c) / 255.0);
-
+
cairo_move_to (cr, (r->region()->position() - start) * _x_scale, y);
cairo_line_to (cr, ((r->region()->position() - start + r->region()->length())) * _x_scale, y);
cairo_stroke (cr);
double const w = xr.second - xr.first;
double const h = yr.second - yr.first;
-
+
xr.first = ev->x - w / 2;
xr.second = ev->x + w / 2;
yr.first = ev->y - h / 2;
_start_editor_x = xr;
_start_editor_y = yr;
_start_mouse_x = ev->x;
- _start_mouse_y = ev->y;
-
+ _start_mouse_y = ev->y;
+
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
/* primary-modifier-click: start a zoom drag */
-
+
double const hx = (xr.first + xr.second) * 0.5;
_zoom_left = ev->x < hx;
_zoom_dragging = true;
_editor->_dragging_playhead = true;
-
-
+
+
/* In theory, we could support vertical dragging, which logically
might scale track heights in order to make the editor reflect
the dragged viewbox. However, having tried this:
b) it's quite slow
c) it doesn't seem particularly useful, especially with the
limited height of the summary
-
+
So at the moment we don't support that...
- */
+ */
+
-
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
-
+
/* secondary-modifier-click: locate playhead */
if (_session) {
_session->request_locate (ev->x / _x_scale + _session->current_start_frame());
}
-
- } else if (xr.first <= ev->x && ev->x <= xr.second && yr.first <= ev->y && ev->y <= yr.second) {
-
- /* ordinary click inside the view rectangle: start a move drag */
-
+
+ } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+
+ centre_on_click (ev);
+
+ } else {
+
+ /* ordinary click: start a move drag */
+
_move_dragging = true;
_moved = false;
_editor->_dragging_playhead = true;
}
}
-
+
return true;
}
{
pair<double, double> xr = _start_editor_x;
pair<double, double> yr = _start_editor_y;
-
+
if (_move_dragging) {
_moved = true;
xr.second += ev->x - _start_mouse_x;
yr.first += ev->y - _start_mouse_y;
yr.second += ev->y - _start_mouse_y;
-
+
set_editor (xr, yr);
} else if (_zoom_dragging) {
set_editor (xr, yr);
}
-
+
return true;
}
bool
-EditorSummary::on_button_release_event (GdkEventButton* ev)
+EditorSummary::on_button_release_event (GdkEventButton*)
{
- if (_move_dragging && !_moved) {
- centre_on_click (ev);
- }
-
_move_dragging = false;
_zoom_dragging = false;
_editor->_dragging_playhead = false;
EditorSummary::on_scroll_event (GdkEventScroll* ev)
{
/* mouse wheel */
-
+
pair<double, double> xr;
pair<double, double> yr;
get_editor (&xr, &yr);
double const amount = 8;
-
+
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-
+
if (ev->direction == GDK_SCROLL_UP) {
xr.first += amount;
xr.second += amount;
}
} else {
-
+
if (ev->direction == GDK_SCROLL_DOWN) {
yr.first += amount;
yr.second += amount;
yr.first -= amount;
yr.second -= amount;
}
-
+
}
-
+
set_editor (xr, yr);
return true;
}
}
}
-
+