void
Editor::queue_visual_change (nframes64_t where)
{
- pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::TimeOrigin);
+ pending_visual_change.add (VisualChange::TimeOrigin);
/* if we're moving beyond the end, make sure the upper limit of the horizontal adjustment
can reach.
pending_visual_change.time_origin = where;
- if (pending_visual_change.idle_handler_id < 0) {
- pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
- }
+ ensure_visual_change_idle_handler ();
}
void
Editor::queue_visual_change (double fpu)
{
- pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::ZoomLevel);
+ pending_visual_change.add (VisualChange::ZoomLevel);
pending_visual_change.frames_per_unit = fpu;
- if (pending_visual_change.idle_handler_id < 0) {
- pending_visual_change.idle_handler_id = g_idle_add ( _idle_visual_changer, this);
- }
+ ensure_visual_change_idle_handler ();
}
void
Editor::queue_visual_change_y (double y)
{
- pending_visual_change.pending = VisualChange::Type (pending_visual_change.pending | VisualChange::YOrigin);
+ pending_visual_change.add (VisualChange::YOrigin);
pending_visual_change.y_origin = y;
+ ensure_visual_change_idle_handler ();
+}
+
+void
+Editor::ensure_visual_change_idle_handler ()
+{
if (pending_visual_change.idle_handler_id < 0) {
- pending_visual_change.idle_handler_id = g_idle_add ( _idle_visual_changer, this);
- }
+ pending_visual_change.idle_handler_id = g_idle_add (_idle_visual_changer, this);
+ }
}
int
+/*
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
#include "ardour/session.h"
#include "time_axis_view.h"
#include "streamview.h"
_regions_dirty (true),
_width (512),
_height (64),
- _pixels_per_frame (1),
- _vertical_scale (1),
+ _x_scale (1),
+ _y_scale (1),
_move_dragging (false),
_moved (false),
_zoom_dragging (false)
}
nframes_t const start = _session->current_start_frame ();
- _pixels_per_frame = static_cast<double> (_width) / (_session->current_end_frame() - start);
- _vertical_scale = static_cast<double> (_height) / h;
+ _x_scale = static_cast<double> (_width) / (_session->current_end_frame() - start);
+ _y_scale = static_cast<double> (_height) / h;
/* tallest a region should ever be in the summary, in pixels */
int const tallest_region_pixels = 12;
- if (max_height * _vertical_scale > tallest_region_pixels) {
- _vertical_scale = static_cast<double> (tallest_region_pixels) / max_height;
+ if (max_height * _y_scale > tallest_region_pixels) {
+ _y_scale = static_cast<double> (tallest_region_pixels) / max_height;
}
/* render regions */
StreamView* s = (*i)->view ();
if (s) {
- double const h = (*i)->effective_height () * _vertical_scale;
+ double const h = (*i)->effective_height () * _y_scale;
cairo_set_line_width (cr, h);
s->foreach_regionview (bind (
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) * _pixels_per_frame, y);
- cairo_line_to (cr, ((r->region()->position() - start + r->region()->length())) * _pixels_per_frame, y);
+ 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);
}
void
EditorSummary::centre_on_click (GdkEventButton* ev)
{
- nframes_t x = (ev->x / _pixels_per_frame) + _session->current_start_frame();
+ nframes_t x = (ev->x / _x_scale) + _session->current_start_frame();
nframes_t const xh = _editor->current_page_frames () / 2;
if (x > xh) {
x -= xh;
_editor->reset_x_origin (x);
- double y = ev->y / _vertical_scale;
+ double y = ev->y / _y_scale;
double const yh = _editor->canvas_height () / 2;
if (y > yh) {
y -= yh;
EditorSummary::on_button_press_event (GdkEventButton* ev)
{
if (ev->button == 1) {
-
+
pair<double, double> xr;
pair<double, double> yr;
editor_view (&xr, &yr);
-
+
if (xr.first <= ev->x && ev->x <= xr.second && yr.first <= ev->y && ev->y <= yr.second) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
void
EditorSummary::editor_view (pair<double, double>* x, pair<double, double>* y) const
{
- x->first = (_editor->leftmost_position () - _session->current_start_frame ()) * _pixels_per_frame;
- x->second = x->first + _editor->current_page_frames() * _pixels_per_frame;
+ x->first = (_editor->leftmost_position () - _session->current_start_frame ()) * _x_scale;
+ x->second = x->first + _editor->current_page_frames() * _x_scale;
- y->first = _editor->get_trackview_group_vertical_offset () * _vertical_scale;
- y->second = y->first + _editor->canvas_height () * _vertical_scale;
+ y->first = _editor->get_trackview_group_vertical_offset () * _y_scale;
+ y->second = y->first + _editor->canvas_height () * _y_scale;
}
bool
if (_move_dragging) {
_moved = true;
- _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_x_origin (((ev->x - _x_offset) / _x_scale) + _session->current_start_frame ());
+ _editor->reset_y_origin ((ev->y - _y_offset) / _y_scale);
return true;
} else if (_zoom_dragging) {
switch (_zoom_position) {
case LEFT:
f = 1 - (dx / _width_start);
- rx += (dx / _pixels_per_frame);
+ rx += (dx / _x_scale);
break;
case RIGHT:
f = 1 + (dx / _width_start);
_editor->_dragging_playhead = false;
return true;
}
+
+bool
+EditorSummary::on_scroll_event (GdkEventScroll* ev)
+{
+ /* mouse wheel */
+
+ pair<double, double> xr;
+ pair<double, double> yr;
+ editor_view (&xr, &yr);
+
+ if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+
+ double x = xr.first;
+
+ if (ev->direction == GDK_SCROLL_UP) {
+ x += 16;
+ } else {
+ x -= 16;
+ }
+
+ _editor->reset_x_origin (x / _x_scale);
+
+ } else {
+
+ double y = yr.first;
+
+ if (ev->direction == GDK_SCROLL_DOWN) {
+ y += 16;
+ } else {
+ y -= 16;
+ }
+
+
+ _editor->reset_y_origin (y / _y_scale);
+ }
+
+ return true;
+}
+/*
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
#ifndef __gtk_ardour_editor_summary_h__
#define __gtk_ardour_editor_summary_h__
bool on_button_press_event (GdkEventButton *);
bool on_button_release_event (GdkEventButton *);
bool on_motion_notify_event (GdkEventMotion *);
+ bool on_scroll_event (GdkEventScroll *);
void render (cairo_t *);
GdkPixmap* get_pixmap (GdkDrawable *);
bool _regions_dirty; ///< true if _pixmap requires re-rendering, otherwise false
int _width; ///< pixmap width
int _height; ///< pixmap height
- double _pixels_per_frame; ///< pixels per frame for the x axis of the pixmap
- double _vertical_scale;
+ double _x_scale; ///< pixels per frame for the x axis of the pixmap
+ double _y_scale;
bool _move_dragging;
double _x_offset;