annotate view/View.h @ 1386:fc3d89f88690 spectrogramparam

Use log-frequency rather than log-bin for calculating x coord in spectrum. This has the advantage that frequency positions don't move when we change the window size or oversampling ratio, but it does give us an unhelpfully large amount of space for very low frequencies - to be considered
author Chris Cannam
date Mon, 12 Nov 2018 11:34:34 +0000
parents 694004228ab7
children 28075cc658c9
rev   line source
Chris@127 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 2
Chris@127 3 /*
Chris@127 4 Sonic Visualiser
Chris@127 5 An audio file viewer and annotation editor.
Chris@127 6 Centre for Digital Music, Queen Mary, University of London.
Chris@127 7 This file copyright 2006 Chris Cannam.
Chris@127 8
Chris@127 9 This program is free software; you can redistribute it and/or
Chris@127 10 modify it under the terms of the GNU General Public License as
Chris@127 11 published by the Free Software Foundation; either version 2 of the
Chris@127 12 License, or (at your option) any later version. See the file
Chris@127 13 COPYING included with this distribution for more information.
Chris@127 14 */
Chris@127 15
Chris@1225 16 #ifndef SV_VIEW_H
Chris@1225 17 #define SV_VIEW_H
Chris@127 18
Chris@127 19 #include <QFrame>
Chris@127 20 #include <QProgressBar>
Chris@127 21
Chris@1077 22 #include "layer/LayerGeometryProvider.h"
Chris@916 23
Chris@127 24 #include "base/ZoomConstraint.h"
Chris@127 25 #include "base/PropertyContainer.h"
Chris@128 26 #include "ViewManager.h"
Chris@127 27 #include "base/XmlExportable.h"
Chris@902 28 #include "base/BaseTypes.h"
Chris@127 29
Chris@127 30 // #define DEBUG_VIEW_WIDGET_PAINT 1
Chris@127 31
Chris@127 32 class Layer;
Chris@127 33 class ViewPropertyContainer;
Chris@127 34
Chris@797 35 class QPushButton;
Chris@797 36
Chris@127 37 #include <map>
Chris@315 38 #include <set>
Chris@127 39
Chris@127 40 /**
Chris@127 41 * View is the base class of widgets that display one or more
Chris@127 42 * overlaid views of data against a horizontal time scale.
Chris@127 43 *
Chris@127 44 * A View may have any number of attached Layers, each of which
Chris@127 45 * is expected to have one data Model (although multiple views may
Chris@127 46 * share the same model).
Chris@127 47 *
Chris@127 48 * A View may be panned in time and zoomed, although the
Chris@127 49 * mechanisms for doing so (as well as any other operations and
Chris@127 50 * properties available) depend on the subclass.
Chris@127 51 */
Chris@127 52
Chris@127 53 class View : public QFrame,
Chris@1266 54 public XmlExportable,
Chris@916 55 public LayerGeometryProvider
Chris@127 56 {
Chris@127 57 Q_OBJECT
Chris@127 58
Chris@127 59 public:
Chris@127 60 /**
Chris@127 61 * Deleting a View does not delete any of its layers. They should
Chris@127 62 * be managed elsewhere (e.g. by the Document).
Chris@127 63 */
Chris@127 64 virtual ~View();
Chris@1044 65
Chris@1044 66 /**
Chris@1044 67 * Retrieve the id of this object. Views have their own unique
Chris@1044 68 * ids, but ViewProxy objects share the id of their View.
Chris@1044 69 */
Chris@1044 70 int getId() const { return m_id; }
Chris@1030 71
Chris@127 72 /**
Chris@127 73 * Retrieve the first visible sample frame on the widget.
Chris@127 74 * This is a calculated value based on the centre-frame, widget
Chris@127 75 * width and zoom level. The result may be negative.
Chris@127 76 */
Chris@902 77 sv_frame_t getStartFrame() const;
Chris@127 78
Chris@127 79 /**
Chris@127 80 * Set the widget pan based on the given first visible frame. The
Chris@127 81 * frame value may be negative.
Chris@127 82 */
Chris@902 83 void setStartFrame(sv_frame_t);
Chris@127 84
Chris@127 85 /**
Chris@127 86 * Return the centre frame of the visible widget. This is an
Chris@127 87 * exact value that does not depend on the zoom block size. Other
Chris@127 88 * frame values (start, end) are calculated from this based on the
Chris@127 89 * zoom and other factors.
Chris@127 90 */
Chris@902 91 sv_frame_t getCentreFrame() const { return m_centreFrame; }
Chris@127 92
Chris@127 93 /**
Chris@127 94 * Set the centre frame of the visible widget.
Chris@127 95 */
Chris@902 96 void setCentreFrame(sv_frame_t f) { setCentreFrame(f, true); }
Chris@127 97
Chris@127 98 /**
Chris@127 99 * Retrieve the last visible sample frame on the widget.
Chris@127 100 * This is a calculated value based on the centre-frame, widget
Chris@127 101 * width and zoom level.
Chris@127 102 */
Chris@902 103 sv_frame_t getEndFrame() const;
Chris@127 104
Chris@127 105 /**
Chris@127 106 * Return the pixel x-coordinate corresponding to a given sample
Chris@1375 107 * frame. The frame is permitted to be negative, and the result
Chris@1375 108 * may be outside the currently visible area. But this should not
Chris@1375 109 * be called with frame values very far away from the currently
Chris@1375 110 * visible area, as that could lead to overflow. In that situation
Chris@1375 111 * an error will be logged and 0 returned.
Chris@127 112 */
Chris@902 113 int getXForFrame(sv_frame_t frame) const;
Chris@127 114
Chris@127 115 /**
Chris@127 116 * Return the closest frame to the given pixel x-coordinate.
Chris@127 117 */
Chris@902 118 sv_frame_t getFrameForX(int x) const;
Chris@127 119
Chris@127 120 /**
Chris@1030 121 * Return the closest pixel x-coordinate corresponding to a given
Chris@1030 122 * view x-coordinate. Default is no scaling, ViewProxy handles
Chris@1030 123 * scaling case.
Chris@1030 124 */
Chris@1030 125 int getXForViewX(int viewx) const { return viewx; }
Chris@1030 126
Chris@1030 127 /**
Chris@1030 128 * Return the closest view x-coordinate corresponding to a given
Chris@1030 129 * pixel x-coordinate. Default is no scaling, ViewProxy handles
Chris@1030 130 * scaling case.
Chris@1030 131 */
Chris@1030 132 int getViewXForX(int x) const { return x; }
Chris@1030 133
Chris@1030 134 /**
Chris@127 135 * Return the pixel y-coordinate corresponding to a given
Chris@127 136 * frequency, if the frequency range is as specified. This does
Chris@127 137 * not imply any policy about layer frequency ranges, but it might
Chris@127 138 * be useful for layers to match theirs up if desired.
Chris@127 139 *
Chris@127 140 * Not thread-safe in logarithmic mode. Call only from GUI thread.
Chris@127 141 */
Chris@904 142 double getYForFrequency(double frequency, double minFreq, double maxFreq,
Chris@1266 143 bool logarithmic) const;
Chris@127 144
Chris@127 145 /**
Chris@127 146 * Return the closest frequency to the given pixel y-coordinate,
Chris@127 147 * if the frequency range is as specified.
Chris@127 148 *
Chris@127 149 * Not thread-safe in logarithmic mode. Call only from GUI thread.
Chris@127 150 */
Chris@1085 151 double getFrequencyForY(double y, double minFreq, double maxFreq,
Chris@1085 152 bool logarithmic) const;
Chris@127 153
Chris@127 154 /**
Chris@1183 155 * Return the zoom level, i.e. the number of frames per pixel or
Chris@1183 156 * pixels per frame
Chris@127 157 */
Chris@1183 158 ZoomLevel getZoomLevel() const;
Chris@127 159
Chris@127 160 /**
Chris@1183 161 * Set the zoom level, i.e. the number of frames per pixel or
Chris@1183 162 * pixels per frame. The centre frame will be unchanged; the
Chris@1183 163 * start and end frames will change.
Chris@127 164 */
Chris@1183 165 virtual void setZoomLevel(ZoomLevel z);
Chris@127 166
Chris@127 167 /**
Chris@127 168 * Zoom in or out.
Chris@127 169 */
Chris@127 170 virtual void zoom(bool in);
Chris@127 171
Chris@127 172 /**
Chris@127 173 * Scroll left or right by a smallish or largish amount.
Chris@127 174 */
Chris@510 175 virtual void scroll(bool right, bool lots, bool doEmit = true);
Chris@127 176
Chris@834 177 /**
Chris@834 178 * Add a layer to the view. (Normally this should be handled
Chris@834 179 * through some command abstraction instead of using this function
Chris@834 180 * directly.)
Chris@834 181 */
Chris@127 182 virtual void addLayer(Layer *v);
Chris@834 183
Chris@834 184 /**
Chris@834 185 * Remove a layer from the view. Does not delete the
Chris@834 186 * layer. (Normally this should be handled through some command
Chris@834 187 * abstraction instead of using this function directly.)
Chris@834 188 */
Chris@834 189 virtual void removeLayer(Layer *v);
Chris@834 190
Chris@834 191 /**
Chris@834 192 * Return the number of layers, regardless of whether visible or
Chris@834 193 * dormant, i.e. invisible, in this view.
Chris@834 194 */
Chris@902 195 virtual int getLayerCount() const { return int(m_layerStack.size()); }
Chris@127 196
Chris@127 197 /**
Chris@834 198 * Return the nth layer, counted in stacking order. That is,
Chris@834 199 * layer 0 is the bottom layer and layer "getLayerCount()-1" is
Chris@834 200 * the top one. The returned layer may be visible or it may be
Chris@834 201 * dormant, i.e. invisible.
Chris@127 202 */
Chris@277 203 virtual Layer *getLayer(int n) {
Chris@902 204 if (in_range_for(m_layerStack, n)) return m_layerStack[n];
Chris@835 205 else return 0;
Chris@277 206 }
Chris@127 207
Chris@127 208 /**
Chris@835 209 * Return the nth layer, counted in the order they were
Chris@835 210 * added. Unlike the stacking order used in getLayer(), which
Chris@835 211 * changes each time a layer is selected, this ordering remains
Chris@835 212 * fixed. The returned layer may be visible or it may be dormant,
Chris@835 213 * i.e. invisible.
Chris@268 214 */
Chris@835 215 virtual Layer *getFixedOrderLayer(int n) {
Chris@835 216 if (n < int(m_fixedOrderLayers.size())) return m_fixedOrderLayers[n];
Chris@835 217 else return 0;
Chris@268 218 }
Chris@268 219
Chris@268 220 /**
Chris@834 221 * Return the layer currently active for tool interaction. This is
Chris@834 222 * the topmost non-dormant (i.e. visible) layer in the view. If
Chris@834 223 * there are no visible layers in the view, return 0.
Chris@834 224 */
Chris@834 225 virtual Layer *getInteractionLayer();
Chris@834 226
Chris@841 227 virtual const Layer *getInteractionLayer() const;
Chris@841 228
Chris@834 229 /**
Chris@835 230 * Return the layer most recently selected by the user. This is
Chris@835 231 * the layer that any non-tool-driven commands should operate on,
Chris@835 232 * in the case where this view is the "current" one.
Chris@835 233 *
Chris@835 234 * If the user has selected the view itself more recently than any
Chris@835 235 * of the layers on it, this function will return 0, and any
Chris@835 236 * non-tool-driven layer commands should be deactivated while this
Chris@835 237 * view is current. It will also return 0 if there are no layers
Chris@835 238 * in the view.
Chris@834 239 *
Chris@834 240 * Note that, unlike getInteractionLayer(), this could return an
Chris@834 241 * invisible (dormant) layer.
Chris@127 242 */
Chris@127 243 virtual Layer *getSelectedLayer();
Chris@834 244
Chris@127 245 virtual const Layer *getSelectedLayer() const;
Chris@127 246
Chris@835 247 /**
Chris@835 248 * Return the "top" layer in the view, whether visible or dormant.
Chris@835 249 * This is the same as getLayer(getLayerCount()-1) if there is at
Chris@835 250 * least one layer, and 0 otherwise.
Chris@835 251 *
Chris@835 252 * For most purposes involving interaction or commands, you
Chris@835 253 * probably want either getInteractionLayer() or
Chris@835 254 * getSelectedLayer() instead.
Chris@835 255 */
Chris@835 256 virtual Layer *getTopLayer() {
Chris@835 257 return m_layerStack.empty() ? 0 : m_layerStack[m_layerStack.size()-1];
Chris@835 258 }
Chris@835 259
Chris@127 260 virtual void setViewManager(ViewManager *m);
Chris@908 261 virtual void setViewManager(ViewManager *m, sv_frame_t initialFrame);
Chris@127 262 virtual ViewManager *getViewManager() const { return m_manager; }
Chris@127 263
Chris@127 264 virtual void setFollowGlobalPan(bool f);
Chris@127 265 virtual bool getFollowGlobalPan() const { return m_followPan; }
Chris@127 266
Chris@127 267 virtual void setFollowGlobalZoom(bool f);
Chris@127 268 virtual bool getFollowGlobalZoom() const { return m_followZoom; }
Chris@127 269
Chris@224 270 virtual bool hasLightBackground() const;
Chris@287 271 virtual QColor getForeground() const;
Chris@287 272 virtual QColor getBackground() const;
Chris@127 273
Chris@270 274 virtual void drawMeasurementRect(QPainter &p, const Layer *,
Chris@270 275 QRect rect, bool focus) const;
Chris@127 276
Chris@741 277 virtual bool shouldShowFeatureLabels() const {
Chris@741 278 return m_manager && m_manager->shouldShowFeatureLabels();
Chris@741 279 }
Chris@127 280 virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const {
Chris@1266 281 return false;
Chris@127 282 }
Chris@127 283 virtual bool shouldIlluminateLocalSelection(QPoint &, bool &, bool &) const {
Chris@1266 284 return false;
Chris@127 285 }
Chris@127 286
Chris@127 287 virtual void setPlaybackFollow(PlaybackFollowMode m);
Chris@127 288 virtual PlaybackFollowMode getPlaybackFollow() const { return m_followPlay; }
Chris@127 289
Chris@127 290 typedef PropertyContainer::PropertyName PropertyName;
Chris@127 291
Chris@127 292 // We implement the PropertyContainer API, although we don't
Chris@127 293 // actually subclass PropertyContainer. We have our own
Chris@127 294 // PropertyContainer that we can return on request that just
Chris@127 295 // delegates back to us.
Chris@127 296 virtual PropertyContainer::PropertyList getProperties() const;
Chris@127 297 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@127 298 virtual PropertyContainer::PropertyType getPropertyType(const PropertyName &) const;
Chris@127 299 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@1266 300 int *min, int *max, int *deflt) const;
Chris@127 301 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@1266 302 int value) const;
Chris@127 303 virtual void setProperty(const PropertyName &, int value);
Chris@127 304 virtual QString getPropertyContainerName() const {
Chris@1266 305 return objectName();
Chris@127 306 }
Chris@127 307 virtual QString getPropertyContainerIconName() const = 0;
Chris@127 308
Chris@806 309 virtual int getPropertyContainerCount() const;
Chris@127 310
Chris@837 311 // The 0th property container is the view's own; the rest are the
Chris@837 312 // layers in fixed-order series
Chris@806 313 virtual const PropertyContainer *getPropertyContainer(int i) const;
Chris@806 314 virtual PropertyContainer *getPropertyContainer(int i);
Chris@127 315
Chris@1202 316 /**
Chris@1202 317 * Render the view contents to a new QImage (which may be wider
Chris@1202 318 * than the visible View).
Chris@1202 319 */
Chris@1202 320 virtual QImage *renderToNewImage();
Chris@226 321
Chris@1202 322 /**
Chris@1202 323 * Render the view contents between the given frame extents to a
Chris@1202 324 * new QImage (which may be wider than the visible View).
Chris@1202 325 */
Chris@1202 326 virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1);
Chris@1202 327
Chris@1202 328 /**
Chris@1202 329 * Calculate and return the size of image that will be generated
Chris@1202 330 * by renderToNewImage().
Chris@1202 331 */
Chris@1202 332 virtual QSize getRenderedImageSize();
Chris@1202 333
Chris@1202 334 /**
Chris@1202 335 * Calculate and return the size of image that will be generated
Chris@1202 336 * by renderPartToNewImage(f0, f1).
Chris@1202 337 */
Chris@1202 338 virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1);
Chris@1202 339
Chris@1202 340 /**
Chris@1202 341 * Render the view contents to a new SVG file.
Chris@1202 342 */
Chris@1202 343 virtual bool renderToSvgFile(QString filename);
Chris@1202 344
Chris@1202 345 /**
Chris@1202 346 * Render the view contents between the given frame extents to a
Chris@1202 347 * new SVG file.
Chris@1202 348 */
Chris@1202 349 virtual bool renderPartToSvgFile(QString filename,
Chris@1202 350 sv_frame_t f0, sv_frame_t f1);
Chris@1202 351
Chris@127 352 virtual int getTextLabelHeight(const Layer *layer, QPainter &) const;
Chris@127 353
Chris@904 354 virtual bool getValueExtents(QString unit, double &min, double &max,
Chris@127 355 bool &log) const;
Chris@127 356
Chris@316 357 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 358 QString extraAttributes = "") const;
Chris@127 359
Chris@222 360 // First frame actually in model, to right of scale, if present
Chris@902 361 virtual sv_frame_t getFirstVisibleFrame() const;
Chris@902 362 virtual sv_frame_t getLastVisibleFrame() const;
Chris@222 363
Chris@902 364 sv_frame_t getModelsStartFrame() const;
Chris@902 365 sv_frame_t getModelsEndFrame() const;
Chris@127 366
Chris@915 367 /**
Chris@915 368 * To be called from a layer, to obtain the extent of the surface
Chris@915 369 * that the layer is currently painting to. This may be the extent
Chris@915 370 * of the view (if 1x display scaling is in effect) or of a larger
Chris@915 371 * cached pixmap (if greater display scaling is in effect).
Chris@915 372 */
Chris@915 373 QRect getPaintRect() const;
Chris@915 374
Chris@915 375 QSize getPaintSize() const { return getPaintRect().size(); }
Chris@915 376 int getPaintWidth() const { return getPaintRect().width(); }
Chris@915 377 int getPaintHeight() const { return getPaintRect().height(); }
Chris@915 378
Chris@315 379 typedef std::set<Model *> ModelSet;
Chris@315 380 ModelSet getModels();
Chris@315 381
Chris@301 382 //!!!
Chris@320 383 Model *getAligningModel() const;
Chris@902 384 sv_frame_t alignFromReference(sv_frame_t) const;
Chris@902 385 sv_frame_t alignToReference(sv_frame_t) const;
Chris@902 386 sv_frame_t getAlignedPlaybackFrame() const;
Chris@301 387
Chris@1030 388 void updatePaintRect(QRect r) { update(r); }
Chris@1030 389
Chris@918 390 View *getView() { return this; }
Chris@918 391 const View *getView() const { return this; }
Chris@918 392
Chris@127 393 signals:
Chris@127 394 void propertyContainerAdded(PropertyContainer *pc);
Chris@127 395 void propertyContainerRemoved(PropertyContainer *pc);
Chris@127 396 void propertyContainerPropertyChanged(PropertyContainer *pc);
Chris@197 397 void propertyContainerPropertyRangeChanged(PropertyContainer *pc);
Chris@127 398 void propertyContainerNameChanged(PropertyContainer *pc);
Chris@298 399 void propertyContainerSelected(PropertyContainer *pc);
Chris@127 400 void propertyChanged(PropertyContainer::PropertyName);
Chris@127 401
Chris@336 402 void layerModelChanged();
Chris@336 403
Chris@902 404 void centreFrameChanged(sv_frame_t frame,
Chris@211 405 bool globalScroll,
Chris@211 406 PlaybackFollowMode followMode);
Chris@211 407
Chris@1183 408 void zoomLevelChanged(ZoomLevel level, bool locked);
Chris@127 409
Chris@189 410 void contextHelpChanged(const QString &);
Chris@189 411
Chris@127 412 public slots:
Chris@127 413 virtual void modelChanged();
Chris@902 414 virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame);
Chris@127 415 virtual void modelCompletionChanged();
Chris@320 416 virtual void modelAlignmentCompletionChanged();
Chris@127 417 virtual void modelReplaced();
Chris@127 418 virtual void layerParametersChanged();
Chris@197 419 virtual void layerParameterRangesChanged();
Chris@268 420 virtual void layerMeasurementRectsChanged();
Chris@127 421 virtual void layerNameChanged();
Chris@127 422
Chris@902 423 virtual void globalCentreFrameChanged(sv_frame_t);
Chris@902 424 virtual void viewCentreFrameChanged(View *, sv_frame_t);
Chris@902 425 virtual void viewManagerPlaybackFrameChanged(sv_frame_t);
Chris@1183 426 virtual void viewZoomLevelChanged(View *, ZoomLevel, bool);
Chris@127 427
Chris@127 428 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
Chris@127 429
Chris@127 430 virtual void selectionChanged();
Chris@127 431 virtual void toolModeChanged();
Chris@133 432 virtual void overlayModeChanged();
Chris@133 433 virtual void zoomWheelsEnabledChanged();
Chris@127 434
Chris@797 435 virtual void cancelClicked();
Chris@797 436
Chris@555 437 virtual void progressCheckStalledTimerElapsed();
Chris@555 438
Chris@127 439 protected:
Chris@127 440 View(QWidget *, bool showProgress);
Chris@1030 441
Chris@1030 442 int m_id;
Chris@1030 443
Chris@127 444 virtual void paintEvent(QPaintEvent *e);
Chris@127 445 virtual void drawSelections(QPainter &);
Chris@127 446 virtual bool shouldLabelSelections() const { return true; }
Chris@1357 447 virtual void drawPlayPointer(QPainter &);
Chris@908 448 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1);
Chris@339 449 virtual void setPaintFont(QPainter &paint);
Chris@952 450
Chris@952 451 QSize scaledSize(const QSize &s, int factor) {
Chris@952 452 return QSize(s.width() * factor, s.height() * factor);
Chris@952 453 }
Chris@952 454 QRect scaledRect(const QRect &r, int factor) {
Chris@952 455 return QRect(r.x() * factor, r.y() * factor,
Chris@952 456 r.width() * factor, r.height() * factor);
Chris@952 457 }
Chris@339 458
Chris@127 459 typedef std::vector<Layer *> LayerList;
Chris@127 460
Chris@908 461 sv_samplerate_t getModelsSampleRate() const;
Chris@127 462 bool areLayersScrollable() const;
Chris@127 463 LayerList getScrollableBackLayers(bool testChanged, bool &changed) const;
Chris@127 464 LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const;
Chris@1354 465
Chris@1183 466 ZoomLevel getZoomConstraintLevel(ZoomLevel level,
Chris@1183 467 ZoomConstraint::RoundingDirection dir =
Chris@1183 468 ZoomConstraint::RoundNearest) const;
Chris@127 469
Chris@1354 470 // These three are slow, intended for indexing GUI thumbwheel stuff
Chris@1354 471 int countZoomLevels() const;
Chris@1354 472 int getZoomLevelIndex(ZoomLevel level) const;
Chris@1354 473 ZoomLevel getZoomLevelByIndex(int ix) const;
Chris@1354 474
Chris@183 475 // True if the top layer(s) use colours for meaningful things. If
Chris@183 476 // this is the case, selections will be shown using unfilled boxes
Chris@183 477 // rather than with a translucent fill.
Chris@183 478 bool areLayerColoursSignificant() const;
Chris@183 479
Chris@217 480 // True if the top layer has a time axis on the x coordinate (this
Chris@217 481 // is generally the case except for spectrum/slice layers). It
Chris@217 482 // will not be possible to make or display selections if this is
Chris@217 483 // false.
Chris@217 484 bool hasTopLayerTimeXAxis() const;
Chris@217 485
Chris@902 486 bool setCentreFrame(sv_frame_t f, bool doEmit);
Chris@127 487
Chris@902 488 void movePlayPointer(sv_frame_t f);
Chris@511 489
Chris@127 490 void checkProgress(void *object);
Chris@384 491 int getProgressBarWidth() const; // if visible
Chris@127 492
Chris@956 493 int effectiveDevicePixelRatio() const;
Chris@956 494
Chris@902 495 sv_frame_t m_centreFrame;
Chris@1183 496 ZoomLevel m_zoomLevel;
Chris@127 497 bool m_followPan;
Chris@127 498 bool m_followZoom;
Chris@127 499 PlaybackFollowMode m_followPlay;
Chris@789 500 bool m_followPlayIsDetached;
Chris@902 501 sv_frame_t m_playPointerFrame;
Chris@127 502 bool m_lightBackground;
Chris@127 503 bool m_showProgress;
Chris@127 504
Chris@1215 505 QPixmap *m_cache; // I own this
Chris@1215 506 QPixmap *m_buffer; // I own this
Chris@1357 507 bool m_cacheValid;
Chris@902 508 sv_frame_t m_cacheCentreFrame;
Chris@1183 509 ZoomLevel m_cacheZoomLevel;
Chris@127 510 bool m_selectionCached;
Chris@127 511
Chris@127 512 bool m_deleting;
Chris@127 513
Chris@835 514 LayerList m_layerStack; // I don't own these, but see dtor note above
Chris@835 515 LayerList m_fixedOrderLayers;
Chris@127 516 bool m_haveSelectedLayer;
Chris@127 517
Chris@583 518 QString m_lastError;
Chris@583 519
Chris@127 520 // caches for use in getScrollableBackLayers, getNonScrollableFrontLayers
Chris@127 521 mutable LayerList m_lastScrollableBackLayers;
Chris@127 522 mutable LayerList m_lastNonScrollableBackLayers;
Chris@127 523
Chris@555 524 struct ProgressBarRec {
Chris@797 525 QPushButton *cancel;
Chris@555 526 QProgressBar *bar;
Chris@555 527 int lastCheck;
Chris@555 528 QTimer *checkTimer;
Chris@555 529 };
Chris@555 530 typedef std::map<Layer *, ProgressBarRec> ProgressMap;
Chris@127 531 ProgressMap m_progressBars; // I own the ProgressBars
Chris@127 532
Chris@127 533 ViewManager *m_manager; // I don't own this
Chris@127 534 ViewPropertyContainer *m_propertyContainer; // I own this
Chris@127 535 };
Chris@127 536
Chris@127 537
Chris@127 538 // Use this for delegation, because we can't subclass from
Chris@127 539 // PropertyContainer (which is a QObject) ourselves because of
Chris@127 540 // ambiguity with QFrame parent
Chris@127 541
Chris@127 542 class ViewPropertyContainer : public PropertyContainer
Chris@127 543 {
Chris@127 544 Q_OBJECT
Chris@127 545
Chris@127 546 public:
Chris@127 547 ViewPropertyContainer(View *v);
Chris@728 548 virtual ~ViewPropertyContainer();
Chris@728 549
Chris@127 550 PropertyList getProperties() const { return m_v->getProperties(); }
Chris@127 551 QString getPropertyLabel(const PropertyName &n) const {
Chris@127 552 return m_v->getPropertyLabel(n);
Chris@127 553 }
Chris@127 554 PropertyType getPropertyType(const PropertyName &n) const {
Chris@1266 555 return m_v->getPropertyType(n);
Chris@127 556 }
Chris@216 557 int getPropertyRangeAndValue(const PropertyName &n, int *min, int *max,
Chris@216 558 int *deflt) const {
Chris@1266 559 return m_v->getPropertyRangeAndValue(n, min, max, deflt);
Chris@127 560 }
Chris@127 561 QString getPropertyValueLabel(const PropertyName &n, int value) const {
Chris@1266 562 return m_v->getPropertyValueLabel(n, value);
Chris@127 563 }
Chris@127 564 QString getPropertyContainerName() const {
Chris@1266 565 return m_v->getPropertyContainerName();
Chris@127 566 }
Chris@127 567 QString getPropertyContainerIconName() const {
Chris@1266 568 return m_v->getPropertyContainerIconName();
Chris@127 569 }
Chris@127 570
Chris@127 571 public slots:
Chris@127 572 virtual void setProperty(const PropertyName &n, int value) {
Chris@1266 573 m_v->setProperty(n, value);
Chris@127 574 }
Chris@127 575
Chris@127 576 protected:
Chris@127 577 View *m_v;
Chris@127 578 };
Chris@127 579
Chris@127 580 #endif
Chris@127 581