Mercurial > hg > svgui
changeset 255:e175ade2d6b0
* double-click in navigate mode relocates the centre frame (closing #1734854)
author | Chris Cannam |
---|---|
date | Wed, 13 Jun 2007 09:19:33 +0000 |
parents | a2ae3d93c645 |
children | c492902dba40 |
files | layer/Layer.h layer/NoteLayer.cpp layer/NoteLayer.h layer/TextLayer.cpp layer/TextLayer.h layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h view/Pane.cpp |
diffstat | 10 files changed, 47 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- 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 */) { }
--- 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
--- 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);
--- 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
--- 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);
--- 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
--- 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);
--- 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
--- 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);
--- 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