13
0

fix position where rubberband rect is drawn

This commit is contained in:
Paul Davis 2014-06-06 08:32:35 -04:00
parent b54a2713a1
commit 5285bb587f
2 changed files with 18 additions and 15 deletions

View File

@ -118,6 +118,15 @@ Editor::initialize_canvas ()
_trackview_group = new ArdourCanvas::Group (hv_scroll_group);
CANVAS_DEBUG_NAME (_trackview_group, "Canvas TrackViews");
// used to show zoom mode active zooming
zoom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
zoom_rect->hide();
zoom_rect->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
// used as rubberband rect
rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
rubberband_rect->hide();
/* a group to hold stuff while it gets dragged around. Must be the
* uppermost (last) group with hv_scroll_group as a parent
*/
@ -202,15 +211,6 @@ Editor::initialize_canvas ()
transport_punchout_line->set_y1 (ArdourCanvas::COORD_MAX);
transport_punchout_line->hide();
// used to show zoom mode active zooming
zoom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
zoom_rect->hide();
zoom_rect->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
// used as rubberband rect
rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
rubberband_rect->hide();
tempo_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
meter_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_meter_bar_event), meter_bar));
marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_marker_bar_event), marker_bar));

View File

@ -181,6 +181,9 @@ DragManager::motion_handler (GdkEvent* e, bool from_autoscroll)
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
bool const t = (*i)->motion_handler (e, from_autoscroll);
/* run all handlers; return true if at least one of them
returns true (indicating that the event has been handled).
*/
if (t) {
r = true;
}
@ -3577,28 +3580,28 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
double x2 = _editor->sample_to_pixel (end);
const double min_dimension = 2.0;
_editor->rubberband_rect->set_x0 (x1);
if (_vertical_only) {
/* fixed 10 pixel width */
_editor->rubberband_rect->set_x1 (x1 + 10);
x2 = x1 + 10;
} else {
if (x2 < x1) {
x2 = min (x1 - min_dimension, x2);
} else {
x2 = max (x1 + min_dimension, x2);
}
_editor->rubberband_rect->set_x1 (x2);
}
_editor->rubberband_rect->set_y0 (y1);
if (y2 < y1) {
y2 = min (y1 - min_dimension, y2);
} else {
y2 = max (y1 + min_dimension, y2);
}
_editor->rubberband_rect->set_y1 (y2);
/* translate rect into item space and set */
Rect r (x1, y1, x2, y2);
_editor->rubberband_rect->set (_editor->rubberband_rect->canvas_to_item (r));
_editor->rubberband_rect->show();
_editor->rubberband_rect->raise_to_top();