mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Some small bug fixes. Make click (but not drag) inside the view box behave like a click outside.
git-svn-id: svn://localhost/ardour2/branches/3.0@5183 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6764ab7856
commit
eed07f4516
2 changed files with 42 additions and 26 deletions
|
|
@ -22,7 +22,8 @@ EditorSummary::EditorSummary (Editor* e)
|
||||||
_height (64),
|
_height (64),
|
||||||
_pixels_per_frame (1),
|
_pixels_per_frame (1),
|
||||||
_vertical_scale (1),
|
_vertical_scale (1),
|
||||||
_dragging (false)
|
_dragging (false),
|
||||||
|
_moved (false)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -148,16 +149,16 @@ EditorSummary::render (cairo_t* cr)
|
||||||
cairo_rectangle (cr, 0, 0, _width, _height);
|
cairo_rectangle (cr, 0, 0, _width, _height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
int N = 0;
|
|
||||||
|
|
||||||
/* compute total height of all tracks */
|
/* compute total height of all tracks */
|
||||||
|
|
||||||
|
int h = 0;
|
||||||
for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
||||||
N += (*i)->effective_height ();
|
h += (*i)->effective_height ();
|
||||||
}
|
}
|
||||||
|
|
||||||
nframes_t const start = _session->current_start_frame ();
|
nframes_t const start = _session->current_start_frame ();
|
||||||
_pixels_per_frame = static_cast<double> (_width) / (_session->current_end_frame() - start);
|
_pixels_per_frame = static_cast<double> (_width) / (_session->current_end_frame() - start);
|
||||||
_vertical_scale = static_cast<double> (_height) / N;
|
_vertical_scale = static_cast<double> (_height) / h;
|
||||||
|
|
||||||
/* render regions */
|
/* render regions */
|
||||||
|
|
||||||
|
|
@ -196,7 +197,7 @@ void
|
||||||
EditorSummary::render_region (RegionView* r, cairo_t* cr, nframes_t start, double y) const
|
EditorSummary::render_region (RegionView* r, cairo_t* cr, nframes_t start, double y) const
|
||||||
{
|
{
|
||||||
cairo_move_to (cr, (r->region()->position() - start) * _pixels_per_frame, y);
|
cairo_move_to (cr, (r->region()->position() - start) * _pixels_per_frame, y);
|
||||||
cairo_line_to (cr, (r->region()->position() - start + r->region()->length()) * _pixels_per_frame, y);
|
cairo_line_to (cr, ((r->region()->position() - start + r->region()->length())) * _pixels_per_frame, y);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,6 +244,30 @@ EditorSummary::on_size_allocate (Gtk::Allocation& alloc)
|
||||||
set_dirty ();
|
set_dirty ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EditorSummary::centre_on_click (GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
nframes_t x = (ev->x / _pixels_per_frame) + _session->current_start_frame();
|
||||||
|
nframes_t const xh = _editor->current_page_frames () / 2;
|
||||||
|
if (x > xh) {
|
||||||
|
x -= xh;
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_editor->reset_x_origin (x);
|
||||||
|
|
||||||
|
double y = ev->y / _vertical_scale;
|
||||||
|
double const yh = _editor->canvas_height () / 2;
|
||||||
|
if (y > yh) {
|
||||||
|
y -= yh;
|
||||||
|
} else {
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_editor->reset_y_origin (y);
|
||||||
|
}
|
||||||
|
|
||||||
/** Handle a button press.
|
/** Handle a button press.
|
||||||
* @param ev GTK event.
|
* @param ev GTK event.
|
||||||
*/
|
*/
|
||||||
|
|
@ -259,32 +284,15 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
|
||||||
|
|
||||||
/* click inside the view rectangle: drag it */
|
/* click inside the view rectangle: drag it */
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
|
_moved = false;
|
||||||
_x_offset = ev->x - xr.first;
|
_x_offset = ev->x - xr.first;
|
||||||
_y_offset = ev->y - yr.first;
|
_y_offset = ev->y - yr.first;
|
||||||
_editor->_dragging_playhead = true;
|
_editor->_dragging_playhead = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* click outside the view rectangle: centre the view around the mouse click */
|
/* click outside the view rectangle: centre the view around the mouse click */
|
||||||
|
centre_on_click (ev);
|
||||||
nframes_t x = (ev->x / _pixels_per_frame) + _session->current_start_frame();
|
|
||||||
nframes_t const xh = _editor->current_page_frames () / 2;
|
|
||||||
if (x > xh) {
|
|
||||||
x -= xh;
|
|
||||||
} else {
|
|
||||||
x = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_editor->reset_x_origin (x);
|
|
||||||
|
|
||||||
double y = ev->y / _vertical_scale;
|
|
||||||
double const yh = _editor->canvas_height () / 2;
|
|
||||||
if (y > yh) {
|
|
||||||
y -= yh;
|
|
||||||
} else {
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_editor->reset_y_origin (y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,6 +316,8 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_moved = true;
|
||||||
|
|
||||||
_editor->reset_x_origin (((ev->x - _x_offset) / _pixels_per_frame) + _session->current_start_frame ());
|
_editor->reset_x_origin (((ev->x - _x_offset) / _pixels_per_frame) + _session->current_start_frame ());
|
||||||
_editor->reset_y_origin ((ev->y - _y_offset) / _vertical_scale);
|
_editor->reset_y_origin ((ev->y - _y_offset) / _vertical_scale);
|
||||||
|
|
||||||
|
|
@ -317,6 +327,10 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
|
||||||
bool
|
bool
|
||||||
EditorSummary::on_button_release_event (GdkEventButton* ev)
|
EditorSummary::on_button_release_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
|
if (_dragging && !_moved) {
|
||||||
|
centre_on_click (ev);
|
||||||
|
}
|
||||||
|
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
_editor->_dragging_playhead = false;
|
_editor->_dragging_playhead = false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
void set_bounds_dirty ();
|
void set_bounds_dirty ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void centre_on_click (GdkEventButton *);
|
||||||
bool on_expose_event (GdkEventExpose *);
|
bool on_expose_event (GdkEventExpose *);
|
||||||
void on_size_request (Gtk::Requisition *);
|
void on_size_request (Gtk::Requisition *);
|
||||||
void on_size_allocate (Gtk::Allocation &);
|
void on_size_allocate (Gtk::Allocation &);
|
||||||
|
|
@ -46,6 +47,7 @@ private:
|
||||||
bool _dragging;
|
bool _dragging;
|
||||||
double _x_offset;
|
double _x_offset;
|
||||||
double _y_offset;
|
double _y_offset;
|
||||||
|
bool _moved;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue