return false;
}
+/** This is called when something is dropped onto the track canvas */
void
Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context,
int x, int y,
boost::shared_ptr<Region> region = _regions->get_dragged_region ();
+ if (!region) {
+ return true;
+ }
+
boost::shared_ptr<Region> region_copy = RegionFactory::create (region);
if (boost::dynamic_pointer_cast<AudioRegion> (region_copy) != 0 &&
abort ();
}
+/** Call abort for each active drag */
void
DragManager::abort ()
-{
- for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
- (*i)->end_grab (0);
- delete *i;
- }
-
- _drags.clear ();
-}
-
-void
-DragManager::break_drag ()
{
_ending = true;
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
- (*i)->break_drag ();
+ (*i)->abort ();
delete *i;
}
}
}
+/** Call end_grab for each active drag.
+ * @return true if any drag reported movement having occurred.
+ */
bool
DragManager::end_grab (GdkEvent* e)
{
}
}
-/** @param event GDK event, or 0.
+/** Call to end a drag `successfully'. Ungrabs item and calls
+ * subclass' finished() method.
+ *
+ * @param event GDK event, or 0.
* @return true if some movement occurred, otherwise false.
*/
bool
return false;
}
+/** Call to abort a drag. Ungrabs item and calls subclass's aborted () */
void
-Drag::break_drag ()
+Drag::abort ()
{
if (_item) {
_item->ungrab (0);
void
RegionInsertDrag::aborted ()
{
- /* XXX: TODO */
+ delete _primary;
+ _primary = 0;
+ _views.clear ();
}
RegionSpliceDrag::RegionSpliceDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v)
bool motion_handler (GdkEvent *, bool);
void abort ();
- void break_drag ();
void add (Drag *);
void set (Drag *, GdkEvent *, Gdk::Cursor* c = 0);
void start_grab (GdkEvent *);
bool end_grab (GdkEvent *);
bool have_item (ArdourCanvas::Item *) const;
- /** @return true if an end drag or break_drag is in progress */
+ /** @return true if an end drag or abort is in progress */
bool ending () const {
return _ending;
}
private:
Editor* _editor;
std::list<Drag*> _drags;
- bool _ending; ///< true if end_grab or break_drag is in progress, otherwise false
+ bool _ending; ///< true if end_grab or abort is in progress, otherwise false
double _current_pointer_x; ///< trackview x of the current pointer
double _current_pointer_y; ///< trackview y of the current pointer
nframes64_t _current_pointer_frame; ///< frame that the pointer is now at
void swap_grab (ArdourCanvas::Item *, Gdk::Cursor *, uint32_t);
bool motion_handler (GdkEvent*, bool);
- void break_drag ();
+ void abort ();
nframes64_t adjusted_frame (nframes64_t, GdkEvent const *, bool snap = true) const;
nframes64_t adjusted_current_frame (GdkEvent const *, bool snap = true) const;
// hide rects
transport_bar_drag_rect->hide();
- _drags->break_drag ();
+ _drags->abort ();
}
void
Editor::escape ()
{
if (_drags->active ()) {
- _drags->break_drag ();
+ _drags->abort ();
} else {
selection->clear ();
}
Glib::signal_idle().connect (sigc::bind (sigc::mem_fun(*this, &Editor::really_remove_marker), loc));
}
- _drags->break_drag ();
+ _drags->abort ();
return;
}
}
if (op == Cut || op == Clear) {
- _drags->break_drag ();
+ _drags->abort ();
}
}
#include "region_view.h"
#include "utils.h"
#include "editor_regions.h"
+#include "editor_drag.h"
#include "i18n.h"
vector<ustring> paths;
if (data.get_target() == "GTK_TREE_MODEL_ROW") {
+ /* something is being dragged over the region list */
+ _editor->_drags->abort ();
_display.on_drag_data_received (context, x, y, data, info, time);
return;
}
}
+/** @return Region that has been dragged out of the list, or 0 */
boost::shared_ptr<Region>
EditorRegions::get_dragged_region ()
{
list<boost::shared_ptr<Region> > regions;
TreeView* source;
_display.get_object_drag_data (regions, &source);
+
+ if (regions.empty()) {
+ return boost::shared_ptr<Region> ();
+ }
+
assert (regions.size() == 1);
return regions.front ();
}