comparison view/View.h @ 978:64c2b3a4435a 3.0-integration

Merge from branch osx-retina
author Chris Cannam
date Fri, 26 Jun 2015 14:10:40 +0100
parents 092de22db207
children 0be17aafa935
comparison
equal deleted inserted replaced
977:f40ccbf228c2 978:64c2b3a4435a
17 #define _VIEW_H_ 17 #define _VIEW_H_
18 18
19 #include <QFrame> 19 #include <QFrame>
20 #include <QProgressBar> 20 #include <QProgressBar>
21 21
22 #include "LayerGeometryProvider.h"
23
22 #include "base/ZoomConstraint.h" 24 #include "base/ZoomConstraint.h"
23 #include "base/PropertyContainer.h" 25 #include "base/PropertyContainer.h"
24 #include "ViewManager.h" 26 #include "ViewManager.h"
25 #include "base/XmlExportable.h" 27 #include "base/XmlExportable.h"
26 #include "base/BaseTypes.h" 28 #include "base/BaseTypes.h"
47 * mechanisms for doing so (as well as any other operations and 49 * mechanisms for doing so (as well as any other operations and
48 * properties available) depend on the subclass. 50 * properties available) depend on the subclass.
49 */ 51 */
50 52
51 class View : public QFrame, 53 class View : public QFrame,
52 public XmlExportable 54 public XmlExportable,
55 public LayerGeometryProvider
53 { 56 {
54 Q_OBJECT 57 Q_OBJECT
55 58
56 public: 59 public:
57 /** 60 /**
240 virtual bool getFollowGlobalZoom() const { return m_followZoom; } 243 virtual bool getFollowGlobalZoom() const { return m_followZoom; }
241 244
242 virtual bool hasLightBackground() const; 245 virtual bool hasLightBackground() const;
243 virtual QColor getForeground() const; 246 virtual QColor getForeground() const;
244 virtual QColor getBackground() const; 247 virtual QColor getBackground() const;
245
246 enum TextStyle {
247 BoxedText,
248 OutlinedText,
249 OutlinedItalicText
250 };
251 248
252 virtual void drawVisibleText(QPainter &p, int x, int y, 249 virtual void drawVisibleText(QPainter &p, int x, int y,
253 QString text, TextStyle style) const; 250 QString text, TextStyle style) const;
254 251
255 virtual void drawMeasurementRect(QPainter &p, const Layer *, 252 virtual void drawMeasurementRect(QPainter &p, const Layer *,
313 virtual sv_frame_t getLastVisibleFrame() const; 310 virtual sv_frame_t getLastVisibleFrame() const;
314 311
315 sv_frame_t getModelsStartFrame() const; 312 sv_frame_t getModelsStartFrame() const;
316 sv_frame_t getModelsEndFrame() const; 313 sv_frame_t getModelsEndFrame() const;
317 314
315 /**
316 * To be called from a layer, to obtain the extent of the surface
317 * that the layer is currently painting to. This may be the extent
318 * of the view (if 1x display scaling is in effect) or of a larger
319 * cached pixmap (if greater display scaling is in effect).
320 */
321 QRect getPaintRect() const;
322
323 QSize getPaintSize() const { return getPaintRect().size(); }
324 int getPaintWidth() const { return getPaintRect().width(); }
325 int getPaintHeight() const { return getPaintRect().height(); }
326
318 typedef std::set<Model *> ModelSet; 327 typedef std::set<Model *> ModelSet;
319 ModelSet getModels(); 328 ModelSet getModels();
320 329
321 //!!! 330 //!!!
322 Model *getAligningModel() const; 331 Model *getAligningModel() const;
323 sv_frame_t alignFromReference(sv_frame_t) const; 332 sv_frame_t alignFromReference(sv_frame_t) const;
324 sv_frame_t alignToReference(sv_frame_t) const; 333 sv_frame_t alignToReference(sv_frame_t) const;
325 sv_frame_t getAlignedPlaybackFrame() const; 334 sv_frame_t getAlignedPlaybackFrame() const;
326 335
336 View *getView() { return this; }
337 const View *getView() const { return this; }
338
327 signals: 339 signals:
328 void propertyContainerAdded(PropertyContainer *pc); 340 void propertyContainerAdded(PropertyContainer *pc);
329 void propertyContainerRemoved(PropertyContainer *pc); 341 void propertyContainerRemoved(PropertyContainer *pc);
330 void propertyContainerPropertyChanged(PropertyContainer *pc); 342 void propertyContainerPropertyChanged(PropertyContainer *pc);
331 void propertyContainerPropertyRangeChanged(PropertyContainer *pc); 343 void propertyContainerPropertyRangeChanged(PropertyContainer *pc);
375 virtual void paintEvent(QPaintEvent *e); 387 virtual void paintEvent(QPaintEvent *e);
376 virtual void drawSelections(QPainter &); 388 virtual void drawSelections(QPainter &);
377 virtual bool shouldLabelSelections() const { return true; } 389 virtual bool shouldLabelSelections() const { return true; }
378 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); 390 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1);
379 virtual void setPaintFont(QPainter &paint); 391 virtual void setPaintFont(QPainter &paint);
392
393 QSize scaledSize(const QSize &s, int factor) {
394 return QSize(s.width() * factor, s.height() * factor);
395 }
396 QRect scaledRect(const QRect &r, int factor) {
397 return QRect(r.x() * factor, r.y() * factor,
398 r.width() * factor, r.height() * factor);
399 }
380 400
381 typedef std::vector<Layer *> LayerList; 401 typedef std::vector<Layer *> LayerList;
382 402
383 sv_samplerate_t getModelsSampleRate() const; 403 sv_samplerate_t getModelsSampleRate() const;
384 bool areLayersScrollable() const; 404 bool areLayersScrollable() const;
403 423
404 void movePlayPointer(sv_frame_t f); 424 void movePlayPointer(sv_frame_t f);
405 425
406 void checkProgress(void *object); 426 void checkProgress(void *object);
407 int getProgressBarWidth() const; // if visible 427 int getProgressBarWidth() const; // if visible
428
429 int effectiveDevicePixelRatio() const;
408 430
409 sv_frame_t m_centreFrame; 431 sv_frame_t m_centreFrame;
410 int m_zoomLevel; 432 int m_zoomLevel;
411 bool m_followPan; 433 bool m_followPan;
412 bool m_followZoom; 434 bool m_followZoom;
415 sv_frame_t m_playPointerFrame; 437 sv_frame_t m_playPointerFrame;
416 bool m_lightBackground; 438 bool m_lightBackground;
417 bool m_showProgress; 439 bool m_showProgress;
418 440
419 QPixmap *m_cache; 441 QPixmap *m_cache;
442 QPixmap *m_buffer;
420 sv_frame_t m_cacheCentreFrame; 443 sv_frame_t m_cacheCentreFrame;
421 int m_cacheZoomLevel; 444 int m_cacheZoomLevel;
422 bool m_selectionCached; 445 bool m_selectionCached;
423 446
424 bool m_deleting; 447 bool m_deleting;