# HG changeset patch # User Chris Cannam # Date 1138292140 0 # Node ID f67ddc287bc31ec7be71b38675c5129b398c20c2 # Parent cb05ba39664ae3e56d6c2d266a1fdca3d2d6d919 * Add ability to create empty layers for editing * Add first basic editing capability (adding points to a time instant layer) * Add various keyboard and mouse shortcuts for navigation &c * Add ability to resize a selection by dragging its edges * Add maximum zoom level diff -r cb05ba39664a -r f67ddc287bc3 base/Layer.cpp --- a/base/Layer.cpp Thu Jan 26 11:56:09 2006 +0000 +++ b/base/Layer.cpp Thu Jan 26 16:15:40 2006 +0000 @@ -27,6 +27,13 @@ m_view->removeLayer(this); } +QString +Layer::getPropertyContainerIconName() const +{ + return LayerFactory::instance()->getLayerIconName + (LayerFactory::instance()->getLayerType(this)); +} + void Layer::setObjectName(const QString &name) { diff -r cb05ba39664a -r f67ddc287bc3 base/Layer.h --- a/base/Layer.h Thu Jan 26 11:56:09 2006 +0000 +++ b/base/Layer.h Thu Jan 26 16:15:40 2006 +0000 @@ -22,6 +22,7 @@ class Model; class QPainter; class View; +class QMouseEvent; /** * The base class for visual representations of the data found in a @@ -53,6 +54,8 @@ return PositionBottom; } + virtual QString getPropertyContainerIconName() const; + virtual QString getPropertyContainerName() const { return objectName(); } @@ -92,11 +95,15 @@ return frame; } - // Paint and edit modes: + // Draw and edit modes: // - // Layer needs to get actual mouse events, I guess. Paint mode is + // Layer needs to get actual mouse events, I guess. Draw mode is // probably the easier. + virtual void drawStart(QMouseEvent *e) { } + virtual void drawDrag(QMouseEvent *e) { } + virtual void drawEnd(QMouseEvent *e) { } + // Text mode: // // Label nearest feature. We need to get the feature coordinates diff -r cb05ba39664a -r f67ddc287bc3 base/View.cpp --- a/base/View.cpp Thu Jan 26 11:56:09 2006 +0000 +++ b/base/View.cpp Thu Jan 26 16:15:40 2006 +0000 @@ -755,6 +755,26 @@ } void +View::scroll(bool right, bool lots) +{ + long delta; + if (lots) { + delta = ((width() / 2) * m_zoomLevel); + } else { + delta = ((width() / 20) * m_zoomLevel); + } + if (right) delta = -delta; + + if (int(m_centreFrame) < delta) { + setCentreFrame(0); + } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) { + setCentreFrame(getModelsEndFrame()); + } else { + setCentreFrame(m_centreFrame - delta); + } +} + +void View::checkProgress(void *object) { // std::cerr << "View::checkProgress(" << object << ")" << std::endl; diff -r cb05ba39664a -r f67ddc287bc3 base/View.h --- a/base/View.h Thu Jan 26 11:56:09 2006 +0000 +++ b/base/View.h Thu Jan 26 16:15:40 2006 +0000 @@ -101,6 +101,11 @@ */ virtual void zoom(bool in); + /** + * Scroll left or right by a smallish or largish amount. + */ + virtual void scroll(bool right, bool lots); + virtual void addLayer(Layer *v); virtual void removeLayer(Layer *v); // does not delete the layer virtual int getLayerCount() const { return m_layers.size(); } diff -r cb05ba39664a -r f67ddc287bc3 base/ZoomConstraint.h --- a/base/ZoomConstraint.h Thu Jan 26 11:56:09 2006 +0000 +++ b/base/ZoomConstraint.h Thu Jan 26 16:15:40 2006 +0000 @@ -17,7 +17,8 @@ * the available zoom sizes for a view, for example based on cache * strategy or a (processing) window-size limitation. * - * The default ZoomConstraint imposes no actual constraint. + * The default ZoomConstraint imposes no actual constraint except for + * a nominal maximum. */ class ZoomConstraint @@ -43,8 +44,11 @@ RoundingDirection = RoundNearest) const { - return requestedBlockSize; + if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel(); + else return requestedBlockSize; } + + virtual size_t getMaxZoomLevel() const { return 262144; } }; #endif