Pull dragging code out of the Editor class into its own hierarchy.

git-svn-id: svn://localhost/ardour2/branches/3.0@5113 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-05-30 18:25:59 +00:00
parent 139d621103
commit 962efaf05e
16 changed files with 4124 additions and 4012 deletions

View File

@ -1,82 +0,0 @@
/*
Copyright (C) 2000-2007 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 __gtk2_ardour_drag_info_h_
#define __gtk2_ardour_drag_info_h_
#include <list>
#include <gdk/gdk.h>
#include <stdint.h>
#include "canvas.h"
#include "editor_items.h"
#include "ardour/types.h"
namespace ARDOUR {
class Location;
}
class Editor;
class TimeAxisView;
struct DragInfo {
ArdourCanvas::Item* item;
ItemType item_type;
void* data;
nframes64_t last_frame_position;
nframes64_t pointer_frame_offset;
nframes64_t grab_frame;
nframes64_t last_pointer_frame;
nframes64_t current_pointer_frame;
double original_x, original_y;
double grab_x, grab_y;
double cumulative_x_drag;
double cumulative_y_drag;
double current_pointer_x;
double current_pointer_y;
double last_pointer_x;
double last_pointer_y;
void (Editor::*motion_callback)(ArdourCanvas::Item*, GdkEvent*);
void (Editor::*finished_callback)(ArdourCanvas::Item*, GdkEvent*);
TimeAxisView* source_trackview;
ARDOUR::layer_t source_layer;
TimeAxisView* dest_trackview;
ARDOUR::layer_t dest_layer;
bool x_constrained;
bool y_constrained;
bool copy;
bool was_rolling;
bool first_move;
bool move_threshold_passed;
bool want_move_threshold;
bool brushing;
std::list<ARDOUR::Location*> copied_locations;
void clear_copied_locations ();
};
struct LineDragInfo {
uint32_t before;
uint32_t after;
};
#endif /* __gtk2_ardour_drag_info_h_ */

View File

@ -90,6 +90,7 @@
#include "analysis_window.h"
#include "bundle_manager.h"
#include "global_port_matrix.h"
#include "editor_drag.h"
#include "i18n.h"
@ -196,15 +197,6 @@ show_me_the_size (Requisition* r, const char* what)
cerr << "size of " << what << " = " << r->width << " x " << r->height << endl;
}
void
DragInfo::clear_copied_locations ()
{
for (list<Location*>::iterator i = copied_locations.begin(); i != copied_locations.end(); ++i) {
delete *i;
}
copied_locations.clear ();
}
Editor::Editor ()
:
/* time display buttons */
@ -270,7 +262,7 @@ Editor::Editor ()
clicked_crossfadeview = 0;
clicked_control_point = 0;
last_update_frame = 0;
drag_info.item = 0;
_drag = 0;
current_mixer_strip = 0;
current_bbt_points = 0;
tempo_lines = 0;
@ -373,8 +365,6 @@ Editor::Editor ()
location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
range_marker_drag_rect = 0;
marker_drag_line = 0;
set_midi_edit_mode (MidiEditPencil, true);
_edit_point = EditAtMouse;
set_mouse_mode (MouseObject, true);
@ -894,7 +884,7 @@ Editor::~Editor()
#endif
delete track_canvas;
track_canvas = 0;
delete _drag;
}
void
@ -911,8 +901,10 @@ Editor::catch_vanishing_regionview (RegionView *rv)
audioregionview by itself.
*/
if (rv->get_canvas_group() == drag_info.item) {
end_grab (drag_info.item, 0);
if (_drag && rv->get_canvas_group() == _drag->item() && !_drag->ending()) {
_drag->end_grab (0);
delete _drag;
_drag = 0;
}
if (clicked_regionview == rv) {

View File

@ -63,7 +63,6 @@
#include "editor_items.h"
#include "region_selection.h"
#include "canvas.h"
#include "draginfo.h"
namespace Gtkmm2ext {
class TearOff;
@ -98,6 +97,7 @@ class AutomationTimeAxisView;
class BundleManager;
class ControlPoint;
class CrossfadeView;
class Drag;
class GlobalPortMatrixWindow;
class GroupedButtons;
class Marker;
@ -124,6 +124,20 @@ class ImageFrameSocketHandler ;
class TimeAxisViewItem ;
/* </CMT Additions> */
struct EditorCursor {
Editor& editor;
ArdourCanvas::Points points;
ArdourCanvas::Line canvas_item;
nframes64_t current_frame;
double length;
EditorCursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
~EditorCursor ();
void set_position (nframes64_t);
void set_length (double units);
void set_y_axis (double position);
};
class Editor : public PublicEditor
{
@ -795,22 +809,9 @@ class Editor : public PublicEditor
Gtk::VBox time_button_vbox;
Gtk::HBox time_button_hbox;
struct Cursor {
Editor& editor;
ArdourCanvas::Points points;
ArdourCanvas::Line canvas_item;
nframes64_t current_frame;
double length;
Cursor (Editor&, bool (Editor::*)(GdkEvent*,ArdourCanvas::Item*));
~Cursor ();
void set_position (nframes64_t);
void set_length (double units);
void set_y_axis (double position);
};
Cursor* playhead_cursor;
friend class EditorCursor;
EditorCursor* playhead_cursor;
ArdourCanvas::Group* cursor_group;
nframes64_t get_region_boundary (nframes64_t pos, int32_t dir, bool with_selection, bool only_onscreen);
@ -818,11 +819,11 @@ class Editor : public PublicEditor
void cursor_to_region_boundary (bool with_selection, int32_t dir);
void cursor_to_next_region_boundary (bool with_selection);
void cursor_to_previous_region_boundary (bool with_selection);
void cursor_to_next_region_point (Cursor*, ARDOUR::RegionPoint);
void cursor_to_previous_region_point (Cursor*, ARDOUR::RegionPoint);
void cursor_to_region_point (Cursor*, ARDOUR::RegionPoint, int32_t dir);
void cursor_to_selection_start (Cursor *);
void cursor_to_selection_end (Cursor *);
void cursor_to_next_region_point (EditorCursor*, ARDOUR::RegionPoint);
void cursor_to_previous_region_point (EditorCursor*, ARDOUR::RegionPoint);
void cursor_to_region_point (EditorCursor*, ARDOUR::RegionPoint, int32_t dir);
void cursor_to_selection_start (EditorCursor *);
void cursor_to_selection_end (EditorCursor *);
void selected_marker_to_region_boundary (bool with_selection, int32_t dir);
void selected_marker_to_next_region_boundary (bool with_selection);
@ -833,7 +834,7 @@ class Editor : public PublicEditor
void selected_marker_to_selection_start ();
void selected_marker_to_selection_end ();
void select_all_selectables_using_cursor (Cursor *, bool);
void select_all_selectables_using_cursor (EditorCursor *, bool);
void select_all_selectables_using_edit (bool);
void select_all_selectables_between (bool within);
void select_range_between ();
@ -1089,7 +1090,7 @@ class Editor : public PublicEditor
bool typed_event (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool motion_handler (ArdourCanvas::Item*, GdkEvent*, ItemType, bool from_autoscroll = false);
bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
@ -1390,27 +1391,13 @@ class Editor : public PublicEditor
void hide_all_tracks (bool with_select);
DragInfo drag_info;
LineDragInfo current_line_drag_info;
Drag* _drag;
void start_grab (GdkEvent*, Gdk::Cursor* cursor = 0);
bool end_grab (ArdourCanvas::Item*, GdkEvent*);
void swap_grab (ArdourCanvas::Item*, Gdk::Cursor* cursor, uint32_t time);
void break_drag ();
void finalize_drag ();
Gtk::Menu fade_context_menu;
void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
void region_gain_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void start_fade_in_grab (ArdourCanvas::Item*, GdkEvent*);
void start_fade_out_grab (ArdourCanvas::Item*, GdkEvent*);
void fade_in_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void fade_out_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void fade_in_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void fade_out_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
@ -1421,51 +1408,20 @@ class Editor : public PublicEditor
std::set<boost::shared_ptr<ARDOUR::Playlist> > motion_frozen_playlists;
RegionSelection pre_drag_region_selection;
void region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void create_region_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void create_region_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
bool check_region_drag_possible (RouteTimeAxisView**, ARDOUR::layer_t*);
void possibly_copy_regions_during_grab (GdkEvent*);
void region_drag_splice_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void region_drag_splice_finished_callback (ArdourCanvas::Item*, GdkEvent*);
bool _dragging_playhead;
bool _dragging_edit_point;
void cursor_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void cursor_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void cursor_drag_finished_ensure_locate_callback (ArdourCanvas::Item*, GdkEvent*);
void marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void control_point_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void control_point_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void line_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void line_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void tempo_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void tempo_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void meter_marker_drag_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void meter_marker_drag_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void marker_drag_motion_callback (GdkEvent*);
void marker_drag_finished_callback (GdkEvent*);
gint mouse_rename_region (ArdourCanvas::Item*, GdkEvent*);
void start_region_grab (ArdourCanvas::Item*, GdkEvent*);
void start_region_grab (ArdourCanvas::Item*, GdkEvent*, RegionView*);
void start_create_region_grab (ArdourCanvas::Item*, GdkEvent*);
void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*);
void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*);
void start_region_copy_grab (ArdourCanvas::Item*, GdkEvent*, RegionView*);
void start_region_brush_grab (ArdourCanvas::Item*, GdkEvent*, RegionView*);
void start_selection_grab (ArdourCanvas::Item*, GdkEvent*);
void start_cursor_grab (ArdourCanvas::Item*, GdkEvent*);
void start_cursor_grab_no_stop (ArdourCanvas::Item*, GdkEvent*);
void start_marker_grab (ArdourCanvas::Item*, GdkEvent*);
void start_control_point_grab (ArdourCanvas::Item*, GdkEvent*);
void start_line_grab_from_regionview (ArdourCanvas::Item*, GdkEvent*);
void start_line_grab_from_line (ArdourCanvas::Item*, GdkEvent*);
void start_line_grab (AutomationLine *, GdkEvent*);
void start_tempo_marker_grab (ArdourCanvas::Item*, GdkEvent*);
void start_tempo_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
void start_meter_marker_grab (ArdourCanvas::Item*, GdkEvent*);
void start_meter_marker_copy_grab (ArdourCanvas::Item*, GdkEvent*);
void region_view_item_click (AudioRegionView&, GdkEventButton*);
@ -1761,16 +1717,6 @@ public:
void point_selection_changed ();
void marker_selection_changed ();
enum SelectionOp {
CreateSelection,
SelectionStartTrim,
SelectionEndTrim,
SelectionMove
} selection_op;
void start_selection_op (ArdourCanvas::Item* item, GdkEvent* event, SelectionOp);
void drag_selection (ArdourCanvas::Item* item, GdkEvent* event);
void end_selection_op (ArdourCanvas::Item* item, GdkEvent* event);
void cancel_selection ();
void region_selection_op (void (ARDOUR::Region::*pmf)(void));
@ -1780,24 +1726,11 @@ public:
bool audio_region_selection_covers (nframes64_t where);
/* transport range select process */
enum RangeMarkerOp {
CreateRangeMarker,
CreateTransportMarker,
CreateCDMarker
} range_marker_op;
void start_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event, RangeMarkerOp);
void drag_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
void end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event);
ArdourCanvas::SimpleRect* cd_marker_bar_drag_rect;
ArdourCanvas::SimpleRect* range_bar_drag_rect;
ArdourCanvas::SimpleRect* transport_bar_drag_rect;
ArdourCanvas::Line* marker_drag_line;
ArdourCanvas::Points marker_drag_line_points;
ArdourCanvas::SimpleRect* range_marker_drag_rect;
void update_marker_drag_item (ARDOUR::Location *);
#ifdef GTKOSX
ArdourCanvas::SimpleRect *bogus_background_rect;
#endif
@ -1818,20 +1751,12 @@ public:
/* object rubberband select process */
void start_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
void drag_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
void end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event);
bool select_all_within (nframes64_t start, nframes64_t end, gdouble topy, gdouble boty, const TrackViewList&, Selection::Operation op);
ArdourCanvas::SimpleRect *rubberband_rect;
/* mouse zoom process */
void start_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
void drag_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
void end_mouse_zoom (ArdourCanvas::Item* item, GdkEvent* event);
ArdourCanvas::SimpleRect *zoom_rect;
void reposition_zoom_rect (nframes64_t start, nframes64_t end);
@ -1957,24 +1882,14 @@ public:
void start_canvas_autoscroll (int x, int y);
void stop_canvas_autoscroll ();
void maybe_autoscroll (GdkEventMotion*);
void maybe_autoscroll_horizontally (GdkEventMotion*);
bool allow_vertical_scroll;
/* trimming */
enum TrimOp {
StartTrim,
EndTrim,
ContentsTrim,
} trim_op;
void start_trim (ArdourCanvas::Item*, GdkEvent*);
void point_trim (GdkEvent*);
void trim_motion_callback (ArdourCanvas::Item*, GdkEvent*);
void single_contents_trim (RegionView&, nframes64_t, bool, bool, bool);
void single_start_trim (RegionView&, nframes64_t, bool, bool, bool);
void single_end_trim (RegionView&, nframes64_t, bool, bool, bool);
void trim_finished_callback (ArdourCanvas::Item*, GdkEvent*);
void thaw_region_after_trim (RegionView& rv);
void trim_region_front();
@ -2105,10 +2020,6 @@ public:
*/
bool mouse_frame (nframes64_t&, bool& in_track_canvas) const;
void time_fx_motion (ArdourCanvas::Item*, GdkEvent*);
void start_time_fx (ArdourCanvas::Item*, GdkEvent*);
void end_time_fx (ArdourCanvas::Item*, GdkEvent*);
/* "whats mine is yours" */
TimeFXDialog* current_timefx;
@ -2309,10 +2220,30 @@ public:
std::vector<TimeAxisView*> pending_resizes;
void visible_order_range (int*, int*) const;
bool y_movement_disallowed (int, int, int, int, int, std::bitset<512> const &, std::vector<int32_t> const &) const;
void located ();
bool _pending_locate_request;
friend class Drag;
friend class RegionDrag;
friend class RegionMoveDrag;
friend class RegionSpliceDrag;
friend class TrimDrag;
friend class MeterMarkerDrag;
friend class TempoMarkerDrag;
friend class CursorDrag;
friend class FadeInDrag;
friend class FadeOutDrag;
friend class MarkerDrag;
friend class RegionGainDrag;
friend class ControlPointDrag;
friend class LineDrag;
friend class RubberbandSelectDrag;
friend class TimeFXDrag;
friend class SelectionDrag;
friend class RangeMarkerBarDrag;
friend class MouseZoomDrag;
friend class RegionCreateDrag;
};
#endif /* __ardour_editor_h__ */

View File

@ -41,6 +41,7 @@
#include "utils.h"
#include "time_axis_view.h"
#include "audio_time_axis.h"
#include "editor_drag.h"
#include "i18n.h"
@ -152,9 +153,6 @@ Editor::initialize_canvas ()
_background_group = new ArdourCanvas::Group (*track_canvas->root());
_master_group = new ArdourCanvas::Group (*track_canvas->root());
range_marker_drag_rect = new ArdourCanvas::SimpleRect (*time_line_group, 0.0, 0.0, 0.0, physical_screen_height);
range_marker_drag_rect->hide ();
_trackview_group = new ArdourCanvas::Group (*_master_group);
_region_motion_group = new ArdourCanvas::Group (*_trackview_group);
@ -228,14 +226,6 @@ Editor::initialize_canvas ()
marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, timebar_height);
cd_marker_group = new ArdourCanvas::Group (*timebar_group, 0.0, 0.0);
marker_drag_line_points.push_back(Gnome::Art::Point(0.0, 0.0));
marker_drag_line_points.push_back(Gnome::Art::Point(0.0, physical_screen_height));
marker_drag_line = new ArdourCanvas::Line (*timebar_group);
marker_drag_line->property_width_pixels() = 1;
marker_drag_line->property_points() = marker_drag_line_points;
marker_drag_line->hide();
cd_marker_bar_drag_rect = new ArdourCanvas::SimpleRect (*cd_marker_group, 0.0, 0.0, 100, timebar_height);
cd_marker_bar_drag_rect->property_outline_pixels() = 0;
cd_marker_bar_drag_rect->hide ();
@ -282,7 +272,7 @@ Editor::initialize_canvas ()
range_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_range_marker_bar_event), range_marker_bar));
transport_marker_bar->signal_event().connect (bind (mem_fun (*this, &Editor::canvas_transport_marker_bar_event), transport_marker_bar));
playhead_cursor = new Cursor (*this, &Editor::canvas_playhead_cursor_event);
playhead_cursor = new EditorCursor (*this, &Editor::canvas_playhead_cursor_event);
if (logo_item) {
logo_item->lower_to_bottom ();
@ -561,9 +551,8 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
void
Editor::maybe_autoscroll (GdkEventMotion* event)
{
nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
nframes64_t frame = drag_info.current_pointer_frame;
nframes64_t frame = _drag->current_pointer_frame();
bool startit = false;
autoscroll_y = 0;
@ -607,43 +596,6 @@ Editor::maybe_autoscroll (GdkEventMotion* event)
last_autoscroll_y = autoscroll_y;
}
void
Editor::maybe_autoscroll_horizontally (GdkEventMotion* event)
{
nframes64_t rightmost_frame = leftmost_frame + current_page_frames();
nframes64_t frame = drag_info.current_pointer_frame;
bool startit = false;
autoscroll_y = 0;
autoscroll_x = 0;
if (frame > rightmost_frame) {
if (rightmost_frame < max_frames) {
autoscroll_x = 1;
startit = true;
}
} else if (frame < leftmost_frame) {
if (leftmost_frame > 0) {
autoscroll_x = -1;
startit = true;
}
}
if ((autoscroll_x != last_autoscroll_x) || (autoscroll_y != last_autoscroll_y) || (autoscroll_x == 0 && autoscroll_y == 0)) {
stop_canvas_autoscroll ();
}
if (startit && autoscroll_timeout_tag < 0) {
start_canvas_autoscroll (autoscroll_x, autoscroll_y);
}
last_autoscroll_x = autoscroll_x;
last_autoscroll_y = autoscroll_y;
}
gint
Editor::_autoscroll_canvas (void *arg)
{
@ -661,19 +613,19 @@ Editor::autoscroll_canvas ()
if (autoscroll_x_distance != 0) {
if (autoscroll_x > 0) {
autoscroll_x_distance = (unit_to_frame (drag_info.current_pointer_x) - (leftmost_frame + current_page_frames())) / 3;
autoscroll_x_distance = (unit_to_frame (_drag->current_pointer_x()) - (leftmost_frame + current_page_frames())) / 3;
} else if (autoscroll_x < 0) {
autoscroll_x_distance = (leftmost_frame - unit_to_frame (drag_info.current_pointer_x)) / 3;
autoscroll_x_distance = (leftmost_frame - unit_to_frame (_drag->current_pointer_x())) / 3;
}
}
if (autoscroll_y_distance != 0) {
if (autoscroll_y > 0) {
autoscroll_y_distance = (drag_info.current_pointer_y - (get_trackview_group_vertical_offset() + canvas_height)) / 3;
autoscroll_y_distance = (_drag->current_pointer_y() - (get_trackview_group_vertical_offset() + canvas_height)) / 3;
} else if (autoscroll_y < 0) {
autoscroll_y_distance = (vertical_adjustment.get_value () - drag_info.current_pointer_y) / 3;
autoscroll_y_distance = (vertical_adjustment.get_value () - _drag->current_pointer_y()) / 3;
}
}
@ -703,7 +655,7 @@ Editor::autoscroll_canvas ()
new_pixel = vertical_pos - autoscroll_y_distance;
}
target_pixel = drag_info.current_pointer_y - autoscroll_y_distance;
target_pixel = _drag->current_pointer_y() - autoscroll_y_distance;
target_pixel = max (target_pixel, 0.0);
} else if (autoscroll_y > 0) {
@ -718,7 +670,7 @@ Editor::autoscroll_canvas ()
new_pixel = min (top_of_bottom_of_canvas, new_pixel);
target_pixel = drag_info.current_pointer_y + autoscroll_y_distance;
target_pixel = _drag->current_pointer_y() + autoscroll_y_distance;
/* don't move to the full canvas height because the item will be invisible
(its top edge will line up with the bottom of the visible canvas.
@ -727,7 +679,7 @@ Editor::autoscroll_canvas ()
target_pixel = min (target_pixel, full_canvas_height - 10);
} else {
target_pixel = drag_info.current_pointer_y;
target_pixel = _drag->current_pointer_y();
new_pixel = vertical_pos;
}
@ -753,7 +705,7 @@ Editor::autoscroll_canvas ()
ev.x = x;
ev.y = y;
motion_handler (drag_info.item, (GdkEvent*) &ev, drag_info.item_type, true);
motion_handler (_drag->item(), (GdkEvent*) &ev, true);
autoscroll_cnt++;
@ -911,11 +863,6 @@ Editor::color_handler()
transport_bar_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
transport_bar_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportDragRect.get();
marker_drag_line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerDragLine.get();
range_marker_drag_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
range_marker_drag_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_RangeDragRect.get();
transport_loop_range_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();
transport_loop_range_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TransportLoopRect.get();

View File

@ -42,6 +42,7 @@
#include "canvas_impl.h"
#include "simplerect.h"
#include "interactive-item.h"
#include "editor_drag.h"
#include "i18n.h"
@ -188,8 +189,10 @@ Editor::track_canvas_button_press_event (GdkEventButton *event)
bool
Editor::track_canvas_button_release_event (GdkEventButton *event)
{
if (drag_info.item) {
end_grab (drag_info.item, (GdkEvent*) event);
if (_drag) {
_drag->end_grab ((GdkEvent*) event);
delete _drag;
_drag = 0;
}
return false;
}
@ -229,7 +232,7 @@ Editor::typed_event (ArdourCanvas::Item* item, GdkEvent *event, ItemType type)
ret = button_release_handler (item, event, type);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, type);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
@ -272,7 +275,7 @@ Editor::canvas_region_view_event (GdkEvent *event, ArdourCanvas::Item* item, Reg
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, RegionItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
@ -353,7 +356,7 @@ Editor::canvas_automation_track_event (GdkEvent *event, ArdourCanvas::Item* item
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, AutomationTrackItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
@ -432,7 +435,7 @@ Editor::canvas_fade_in_handle_event (GdkEvent *event, ArdourCanvas::Item* item,
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, FadeInHandleItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
@ -511,7 +514,7 @@ Editor::canvas_fade_out_handle_event (GdkEvent *event, ArdourCanvas::Item* item,
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, FadeOutHandleItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
@ -662,7 +665,7 @@ Editor::canvas_selection_rect_event (GdkEvent *event, ArdourCanvas::Item* item,
ret = button_release_handler (item, event, SelectionItem);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, SelectionItem);
ret = motion_handler (item, event);
break;
/* Don't need these at the moment. */
case GDK_ENTER_NOTIFY:
@ -696,7 +699,7 @@ Editor::canvas_selection_start_trim_event (GdkEvent *event, ArdourCanvas::Item*
ret = button_release_handler (item, event, StartSelectionTrimItem);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, StartSelectionTrimItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, StartSelectionTrimItem);
@ -729,7 +732,7 @@ Editor::canvas_selection_end_trim_event (GdkEvent *event, ArdourCanvas::Item* it
ret = button_release_handler (item, event, EndSelectionTrimItem);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, EndSelectionTrimItem);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, EndSelectionTrimItem);
@ -770,7 +773,7 @@ Editor::canvas_region_view_name_highlight_event (GdkEvent* event, ArdourCanvas::
ret = button_release_handler (item, event, RegionViewNameHighlight);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, RegionViewNameHighlight);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, RegionViewNameHighlight);
@ -810,7 +813,7 @@ Editor::canvas_region_view_name_event (GdkEvent *event, ArdourCanvas::Item* item
ret = button_release_handler (item, event, RegionViewName);
break;
case GDK_MOTION_NOTIFY:
ret = motion_handler (item, event, RegionViewName);
ret = motion_handler (item, event);
break;
case GDK_ENTER_NOTIFY:
ret = enter_handler (item, event, RegionViewName);

View File

@ -30,7 +30,7 @@ using namespace ARDOUR;
using namespace PBD;
using namespace Gtk;
Editor::Cursor::Cursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
: editor (ed),
canvas_item (*editor.cursor_group),
length(1.0)
@ -51,13 +51,13 @@ Editor::Cursor::Cursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanv
current_frame = 1; /* force redraw at 0 */
}
Editor::Cursor::~Cursor ()
EditorCursor::~EditorCursor ()
{
}
void
Editor::Cursor::set_position (nframes64_t frame)
EditorCursor::set_position (nframes64_t frame)
{
double new_pos = editor.frame_to_unit (frame);
@ -72,7 +72,7 @@ Editor::Cursor::set_position (nframes64_t frame)
}
void
Editor::Cursor::set_length (double units)
EditorCursor::set_length (double units)
{
length = units;
points.back().set_y (points.front().get_y() + length);
@ -80,7 +80,7 @@ Editor::Cursor::set_length (double units)
}
void
Editor::Cursor::set_y_axis (double position)
EditorCursor::set_y_axis (double position)
{
points.front().set_y (position);
points.back().set_y (position + length);

3281
gtk2_ardour/editor_drag.cc Normal file

File diff suppressed because it is too large Load Diff

456
gtk2_ardour/editor_drag.h Normal file
View File

@ -0,0 +1,456 @@
/*
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 __gtk2_ardour_editor_drag_h_
#define __gtk2_ardour_editor_drag_h_
#include <list>
#include <gdk/gdk.h>
#include <stdint.h>
#include "ardour/types.h"
#include "canvas.h"
#include "editor_items.h"
namespace ARDOUR {
class Location;
}
class Editor;
class EditorCursor;
class TimeAxisView;
/** Abstract base class for dragging of things within the editor */
class Drag
{
public:
Drag (Editor *, ArdourCanvas::Item *);
virtual ~Drag () {}
/** @return the canvas item being dragged */
ArdourCanvas::Item* item () const {
return _item;
}
void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
void break_drag ();
bool motion_handler (GdkEvent*, bool);
/** @return true if an end drag is in progress */
bool ending () const {
return _ending;
}
/** @return true if the first move (past any move threshold) has occurred */
bool first_move () const {
return _first_move;
}
/** @return current pointer x position in item coordinates */
double current_pointer_x () const {
return _current_pointer_x;
}
/** @return current pointer y position in item coordinates */
double current_pointer_y () const {
return _current_pointer_y;
}
/** @return current pointer frame */
nframes64_t current_pointer_frame () const {
return _current_pointer_frame;
}
/** Called to start a grab of an item.
* @param e Event that caused the grab to start.
* @param c Cursor to use, or 0.
*/
virtual void start_grab (GdkEvent* e, Gdk::Cursor* c = 0);
virtual bool end_grab (GdkEvent *);
/** Called when a drag motion has occurred.
* @param e Event describing the motion.
*/
virtual void motion (GdkEvent* e) = 0;
/** Called when a drag has finished.
* @param e Event describing the finish.
*/
virtual void finished (GdkEvent *) = 0;
/** @param m Mouse mode.
* @return true if this drag should happen in this mouse mode.
*/
virtual bool active (Editing::MouseMode m) {
return (m != Editing::MouseGain);
}
/** Called when a subclass should update the editor's selection following a drag */
virtual void update_selection () {}
protected:
nframes64_t adjusted_current_frame () const;
Editor* _editor; ///< our editor
ArdourCanvas::Item* _item; ///< our item
nframes64_t _pointer_frame_offset; ///< offset from the mouse's position for the drag
///< to the start of the thing that is being dragged
nframes64_t _last_frame_position; ///< last position of the thing being dragged
nframes64_t _grab_frame; ///< frame that the mouse was at when start_grab was called, or 0
nframes64_t _last_pointer_frame; ///< frame that the pointer was at last time a motion occurred
nframes64_t _current_pointer_frame; ///< frame that the pointer is now at
double _original_x; ///< original world x of the thing being dragged
double _original_y; ///< original world y of the thing being dragged
double _grab_x; ///< item x of the grab start position
double _grab_y; ///< item y of the grab start position
double _current_pointer_x; ///< item x of the current pointer
double _current_pointer_y; ///< item y of the current pointer
double _last_pointer_x; ///< item x of the pointer last time a motion occurred
double _last_pointer_y; ///< item y of the pointer last time a motion occurred
bool _x_constrained; ///< true if x motion is constrained, otherwise false
bool _y_constrained; ///< true if y motion is constrained, otherwise false
bool _copy; ///< true if we're copying the things that we're dragging
bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
bool _first_move; ///< true if some movement has occurred, otherwise false
bool _move_threshold_passed; ///< true if the move threshold has been passed, otherwise false
bool _want_move_threshold; ///< true if a move threshold should be applied, otherwise false
private:
bool _ending; ///< true if end_grab is in progress, otherwise false
};
/** Abstract base class for drags that involve region(s) */
class RegionDrag : public Drag, public sigc::trackable
{
public:
RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
virtual ~RegionDrag () {}
void update_selection ();
protected:
RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag
std::list<RegionView*> _views; ///< all views that are being dragged
private:
void region_going_away (RegionView *);
};
/** Drags to move regions */
class RegionMoveDrag : public RegionDrag
{
public:
RegionMoveDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &, bool, bool);
virtual ~RegionMoveDrag () {}
virtual void start_grab (GdkEvent *, Gdk::Cursor *);
virtual void motion (GdkEvent *);
virtual void finished (GdkEvent *);
protected:
bool check_possible (RouteTimeAxisView **, ARDOUR::layer_t *);
TimeAxisView* _source_trackview;
ARDOUR::layer_t _source_layer;
TimeAxisView* _dest_trackview;
ARDOUR::layer_t _dest_layer;
private:
void copy_regions (GdkEvent *);
bool y_movement_disallowed (int, int, int, int, int, std::bitset<512> const &, std::vector<int32_t> const &) const;
bool _brushing;
};
/** Region drag in splice mode */
class RegionSpliceDrag : public RegionMoveDrag
{
public:
RegionSpliceDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
/** Drags to create regions */
class RegionCreateDrag : public Drag
{
public:
RegionCreateDrag (Editor *, ArdourCanvas::Item *, TimeAxisView *);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
TimeAxisView* _view;
TimeAxisView* _source_trackview;
ARDOUR::layer_t _source_layer;
TimeAxisView* _dest_trackview;
ARDOUR::layer_t _dest_layer;
};
/** Drag of region gain */
class RegionGainDrag : public Drag
{
public:
RegionGainDrag (Editor *e, ArdourCanvas::Item *i) : Drag (e, i) {}
void motion (GdkEvent *);
void finished (GdkEvent *);
bool active (Editing::MouseMode m) {
return (m == Editing::MouseGain);
}
};
/** Drag to trim region(s) */
class TrimDrag : public RegionDrag
{
public:
enum Operation {
StartTrim,
EndTrim,
ContentsTrim,
};
TrimDrag (Editor *, ArdourCanvas::Item *, RegionView*, std::list<RegionView*> const &);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
Operation _operation;
};
/** Meter marker drag */
class MeterMarkerDrag : public Drag
{
public:
MeterMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
MeterMarker* _marker;
};
/** Tempo marker drag */
class TempoMarkerDrag : public Drag
{
public:
TempoMarkerDrag (Editor *, ArdourCanvas::Item *, bool);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
TempoMarker* _marker;
};
/** Drag of a cursor */
class CursorDrag : public Drag
{
public:
CursorDrag (Editor *, ArdourCanvas::Item *, bool);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
EditorCursor* _cursor; ///< cursor being dragged
bool _stop; ///< true to stop the transport on starting the drag, otherwise false
};
/** Region fade-in drag */
class FadeInDrag : public RegionDrag
{
public:
FadeInDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
/** Region fade-out drag */
class FadeOutDrag : public RegionDrag
{
public:
FadeOutDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
/** Marker drag */
class MarkerDrag : public Drag
{
public:
MarkerDrag (Editor *, ArdourCanvas::Item *);
~MarkerDrag ();
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
void update_item (ARDOUR::Location *);
Marker* _marker; ///< marker being dragged
std::list<ARDOUR::Location*> _copied_locations;
ArdourCanvas::Line* _line;
ArdourCanvas::Points _points;
};
/** Control point drag */
class ControlPointDrag : public Drag
{
public:
ControlPointDrag (Editor *, ArdourCanvas::Item *);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
ControlPoint* _point;
double _cumulative_x_drag;
double _cumulative_y_drag;
static double const _zero_gain_fraction;
};
/** Gain or automation line drag */
class LineDrag : public Drag
{
public:
LineDrag (Editor *e, ArdourCanvas::Item *i);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
AutomationLine* _line;
uint32_t _before;
uint32_t _after;
double _cumulative_y_drag;
};
/** Dragging of a rubberband rectangle for selecting things */
class RubberbandSelectDrag : public Drag
{
public:
RubberbandSelectDrag (Editor *e, ArdourCanvas::Item *i) : Drag (e, i) {}
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
/** Region drag in time-FX mode */
class TimeFXDrag : public RegionDrag
{
public:
TimeFXDrag (Editor *e, ArdourCanvas::Item *i, RegionView* p, std::list<RegionView*> const & v) : RegionDrag (e, i, p, v) {}
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
/** Drag in range selection mode */
class SelectionDrag : public Drag
{
public:
enum Operation {
CreateSelection,
SelectionStartTrim,
SelectionEndTrim,
SelectionMove
};
SelectionDrag (Editor *, ArdourCanvas::Item *, Operation);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
Operation _operation;
};
/** Range marker drag */
class RangeMarkerBarDrag : public Drag
{
public:
enum Operation {
CreateRangeMarker,
CreateTransportMarker,
CreateCDMarker
};
RangeMarkerBarDrag (Editor *, ArdourCanvas::Item *, Operation);
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
private:
void update_item (ARDOUR::Location *);
Operation _operation;
ArdourCanvas::SimpleRect* _drag_rect;
};
/* Drag of rectangle to set zoom */
class MouseZoomDrag : public Drag
{
public:
MouseZoomDrag (Editor *e, ArdourCanvas::Item *i) : Drag (e, i) {}
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
void motion (GdkEvent *);
void finished (GdkEvent *);
};
#endif /* __gtk2_ardour_editor_drag_h_ */

View File

@ -27,6 +27,7 @@
#include "region_view.h"
#include "selection.h"
#include "keyboard.h"
#include "editor_drag.h"
#include "i18n.h"
@ -51,9 +52,10 @@ Editor::kbd_driver (sigc::slot<void,GdkEvent*> theslot, bool use_track_canvas, b
/* any use of "keyboard mouse buttons" invalidates an existing grab
*/
if (drag_info.item) {
drag_info.item->ungrab (GDK_CURRENT_TIME);
drag_info.item = 0;
if (_drag) {
_drag->item()->ungrab (GDK_CURRENT_TIME);
delete _drag;
_drag = 0;
}
if (doit) {

View File

@ -1090,7 +1090,8 @@ Editor::new_transport_marker_menu_popdown ()
{
// hide rects
transport_bar_drag_rect->hide();
range_marker_drag_rect->hide();
break_drag ();
}
void

View File

@ -357,7 +357,7 @@ Editor::session_going_away ()
entered_regionview = 0;
entered_track = 0;
last_update_frame = 0;
drag_info.item = 0;
_drag = 0;
playhead_cursor->canvas_item.hide ();

File diff suppressed because it is too large Load Diff

View File

@ -74,6 +74,7 @@
#include "gui_thread.h"
#include "keyboard.h"
#include "utils.h"
#include "editor_drag.h"
#include "strip_silence_dialog.h"
#include "i18n.h"
@ -859,7 +860,7 @@ Editor::cursor_to_previous_region_boundary (bool with_selection)
}
void
Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir)
Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t dir)
{
boost::shared_ptr<Region> r;
nframes64_t pos = cursor->current_frame;
@ -928,19 +929,19 @@ Editor::cursor_to_region_point (Cursor* cursor, RegionPoint point, int32_t dir)
}
void
Editor::cursor_to_next_region_point (Cursor* cursor, RegionPoint point)
Editor::cursor_to_next_region_point (EditorCursor* cursor, RegionPoint point)
{
cursor_to_region_point (cursor, point, 1);
}
void
Editor::cursor_to_previous_region_point (Cursor* cursor, RegionPoint point)
Editor::cursor_to_previous_region_point (EditorCursor* cursor, RegionPoint point)
{
cursor_to_region_point (cursor, point, -1);
}
void
Editor::cursor_to_selection_start (Cursor *cursor)
Editor::cursor_to_selection_start (EditorCursor *cursor)
{
nframes64_t pos = 0;
RegionSelection rs;
@ -972,7 +973,7 @@ Editor::cursor_to_selection_start (Cursor *cursor)
}
void
Editor::cursor_to_selection_end (Cursor *cursor)
Editor::cursor_to_selection_end (EditorCursor *cursor)
{
nframes64_t pos = 0;
RegionSelection rs;
@ -2759,7 +2760,7 @@ Editor::create_region_from_selection (vector<boost::shared_ptr<Region> >& new_re
internal_start = start - current->position();
session->region_name (new_name, current->name(), true);
new_regions.push_back (RegionFactory::create (current,
internal_start, end - start + 1, new_name));
}
@ -3882,9 +3883,10 @@ Editor::cut_copy (CutCopyOp op)
*/
if (op == Cut || op == Clear) {
if (drag_info.item) {
drag_info.item->ungrab (0);
drag_info.item = 0;
if (_drag) {
_drag->item()->ungrab (0);
delete _drag;
_drag = 0;
}
}
@ -3902,6 +3904,8 @@ Editor::cut_copy (CutCopyOp op)
}
break_drag ();
delete _drag;
_drag = 0;
return;
}
@ -3971,6 +3975,8 @@ Editor::cut_copy (CutCopyOp op)
if (op == Cut || op == Clear) {
break_drag ();
delete _drag;
_drag = 0;
}
}

View File

@ -377,7 +377,7 @@ Editor::ruler_mouse_motion (GdkEventMotion* ev)
snap_to (where);
Cursor* cursor = 0;
EditorCursor* cursor = 0;
switch (ruler_pressed_button) {
case 1:

View File

@ -1185,7 +1185,7 @@ Editor::select_all_selectables_using_loop()
}
void
Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after)
Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after)
{
nframes64_t start;
nframes64_t end;

View File

@ -103,6 +103,7 @@ def build(bld):
editor_canvas.cc
editor_canvas_events.cc
editor_cursors.cc
editor_drag.cc
editor_edit_groups.cc
editor_export_audio.cc
editor_hscroller.cc