# HG changeset patch # User Chris Cannam # Date 1181726373 0 # Node ID e175ade2d6b0042cdfdf34ef9d164dc7d16dace9 # Parent a2ae3d93c645bf708f9fbd07c0a714a9d9a31b76 * double-click in navigate mode relocates the centre frame (closing #1734854) diff -r a2ae3d93c645 -r e175ade2d6b0 layer/Layer.h --- a/layer/Layer.h Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/Layer.h Wed Jun 13 09:19:33 2007 +0000 @@ -156,7 +156,12 @@ virtual void editDrag(View *, QMouseEvent *) { } virtual void editEnd(View *, QMouseEvent *) { } - virtual void editOpen(View *, QMouseEvent *) { } // on double-click + /** + * Open an editor on the item under the mouse (e.g. on + * double-click). If there is no item or editing is not + * supported, return false. + */ + virtual bool editOpen(View *, QMouseEvent *) { return false; } virtual void moveSelection(Selection, size_t /* newStartFrame */) { } virtual void resizeSelection(Selection, Selection /* newSize */) { } diff -r a2ae3d93c645 -r e175ade2d6b0 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/NoteLayer.cpp Wed Jun 13 09:19:33 2007 +0000 @@ -788,13 +788,13 @@ m_editing = false; } -void +bool NoteLayer::editOpen(View *v, QMouseEvent *e) { - if (!m_model) return; + if (!m_model) return false; NoteModel::PointList points = getLocalPoints(v, e->x()); - if (points.empty()) return; + if (points.empty()) return false; NoteModel::Point note = *points.begin(); @@ -827,6 +827,7 @@ } delete dialog; + return true; } void diff -r a2ae3d93c645 -r e175ade2d6b0 layer/NoteLayer.h --- a/layer/NoteLayer.h Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/NoteLayer.h Wed Jun 13 09:19:33 2007 +0000 @@ -48,7 +48,7 @@ virtual void editDrag(View *v, QMouseEvent *); virtual void editEnd(View *v, QMouseEvent *); - virtual void editOpen(View *v, QMouseEvent *); + virtual bool editOpen(View *v, QMouseEvent *); virtual void moveSelection(Selection s, size_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TextLayer.cpp --- a/layer/TextLayer.cpp Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TextLayer.cpp Wed Jun 13 09:19:33 2007 +0000 @@ -587,15 +587,13 @@ m_editing = false; } -void +bool TextLayer::editOpen(View *v, QMouseEvent *e) { - std::cerr << "TextLayer::editOpen" << std::endl; - - if (!m_model) return; + if (!m_model) return false; TextModel::PointList points = getLocalPoints(v, e->x(), e->y()); - if (points.empty()) return; + if (points.empty()) return false; QString label = points.begin()->label; @@ -608,6 +606,8 @@ new TextModel::RelabelCommand(m_model, *points.begin(), label); CommandHistory::getInstance()->addCommand(command); } + + return true; } void diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TextLayer.h --- a/layer/TextLayer.h Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TextLayer.h Wed Jun 13 09:19:33 2007 +0000 @@ -56,7 +56,7 @@ virtual bool paste(const Clipboard &from, int frameOffset, bool interactive); - virtual void editOpen(View *, QMouseEvent *); // on double-click + virtual bool editOpen(View *, QMouseEvent *); // on double-click virtual const Model *getModel() const { return m_model; } void setModel(TextModel *model); diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TimeInstantLayer.cpp Wed Jun 13 09:19:33 2007 +0000 @@ -591,13 +591,13 @@ m_editing = false; } -void +bool TimeInstantLayer::editOpen(View *v, QMouseEvent *e) { - if (!m_model) return; + if (!m_model) return false; SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); - if (points.empty()) return; + if (points.empty()) return false; SparseOneDimensionalModel::Point point = *points.begin(); @@ -623,6 +623,7 @@ } delete dialog; + return true; } void diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TimeInstantLayer.h --- a/layer/TimeInstantLayer.h Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TimeInstantLayer.h Wed Jun 13 09:19:33 2007 +0000 @@ -48,7 +48,7 @@ virtual void editDrag(View *v, QMouseEvent *); virtual void editEnd(View *v, QMouseEvent *); - virtual void editOpen(View *, QMouseEvent *); + virtual bool editOpen(View *, QMouseEvent *); virtual void moveSelection(Selection s, size_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TimeValueLayer.cpp Wed Jun 13 09:19:33 2007 +0000 @@ -1046,13 +1046,13 @@ m_editing = false; } -void +bool TimeValueLayer::editOpen(View *v, QMouseEvent *e) { - if (!m_model) return; + if (!m_model) return false; SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); - if (points.empty()) return; + if (points.empty()) return false; SparseTimeValueModel::Point point = *points.begin(); @@ -1082,6 +1082,7 @@ } delete dialog; + return true; } void diff -r a2ae3d93c645 -r e175ade2d6b0 layer/TimeValueLayer.h --- a/layer/TimeValueLayer.h Mon Jun 11 12:14:52 2007 +0000 +++ b/layer/TimeValueLayer.h Wed Jun 13 09:19:33 2007 +0000 @@ -51,7 +51,7 @@ virtual void editDrag(View *v, QMouseEvent *); virtual void editEnd(View *v, QMouseEvent *); - virtual void editOpen(View *v, QMouseEvent *); + virtual bool editOpen(View *v, QMouseEvent *); virtual void moveSelection(Selection s, size_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); diff -r a2ae3d93c645 -r e175ade2d6b0 view/Pane.cpp --- a/view/Pane.cpp Mon Jun 11 12:14:52 2007 +0000 +++ b/view/Pane.cpp Wed Jun 13 09:19:33 2007 +0000 @@ -1401,14 +1401,33 @@ ViewManager::ToolMode mode = ViewManager::NavigateMode; if (m_manager) mode = m_manager->getToolMode(); + bool relocate = (mode == ViewManager::NavigateMode || + (e->buttons() & Qt::MidButton)); + if (mode == ViewManager::NavigateMode || mode == ViewManager::EditMode) { Layer *layer = getSelectedLayer(); if (layer && layer->isLayerEditable()) { - layer->editOpen(this, e); + if (layer->editOpen(this, e)) relocate = false; } } + + if (relocate) { + + long f = getFrameForX(e->x()); + + setCentreFrame(f); + + m_dragCentreFrame = f; + m_dragStartMinValue = 0; + m_dragMode = UnresolvedDrag; + + float vmin, vmax, dmin, dmax; + if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { + m_dragStartMinValue = dmin; + } + } } void