Mercurial > hg > svgui
comparison view/LayerGeometryProvider.h @ 916:94e4952a6774 osx-retina
Start trying to introduce LayerGeometryProvider as proxyable interface for View methods that the Layer wants to use
author | Chris Cannam |
---|---|
date | Tue, 17 Mar 2015 15:05:25 +0000 |
parents | |
children | 4fe7a09be0fe |
comparison
equal
deleted
inserted
replaced
915:f6d9f28f37cb | 916:94e4952a6774 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef LAYER_GEOMETRY_PROVIDER_H | |
16 #define LAYER_GEOMETRY_PROVIDER_H | |
17 | |
18 #include "base/BaseTypes.h" | |
19 | |
20 class ViewManager; | |
21 class Layer; | |
22 | |
23 class LayerGeometryProvider | |
24 { | |
25 public: | |
26 /** | |
27 * Retrieve the first visible sample frame on the widget. | |
28 * This is a calculated value based on the centre-frame, widget | |
29 * width and zoom level. The result may be negative. | |
30 */ | |
31 virtual sv_frame_t getStartFrame() const = 0; | |
32 | |
33 /** | |
34 * Return the centre frame of the visible widget. This is an | |
35 * exact value that does not depend on the zoom block size. Other | |
36 * frame values (start, end) are calculated from this based on the | |
37 * zoom and other factors. | |
38 */ | |
39 virtual sv_frame_t getCentreFrame() const = 0; | |
40 | |
41 /** | |
42 * Retrieve the last visible sample frame on the widget. | |
43 * This is a calculated value based on the centre-frame, widget | |
44 * width and zoom level. | |
45 */ | |
46 virtual sv_frame_t getEndFrame() const = 0; | |
47 | |
48 /** | |
49 * Return the pixel x-coordinate corresponding to a given sample | |
50 * frame (which may be negative). | |
51 */ | |
52 virtual int getXForFrame(sv_frame_t frame) const = 0; | |
53 | |
54 /** | |
55 * Return the closest frame to the given pixel x-coordinate. | |
56 */ | |
57 virtual sv_frame_t getFrameForX(int x) const = 0; | |
58 | |
59 /** | |
60 * Return the pixel y-coordinate corresponding to a given | |
61 * frequency, if the frequency range is as specified. This does | |
62 * not imply any policy about layer frequency ranges, but it might | |
63 * be useful for layers to match theirs up if desired. | |
64 * | |
65 * Not thread-safe in logarithmic mode. Call only from GUI thread. | |
66 */ | |
67 virtual double getYForFrequency(double frequency, double minFreq, double maxFreq, | |
68 bool logarithmic) const = 0; | |
69 | |
70 /** | |
71 * Return the closest frequency to the given pixel y-coordinate, | |
72 * if the frequency range is as specified. | |
73 * | |
74 * Not thread-safe in logarithmic mode. Call only from GUI thread. | |
75 */ | |
76 virtual double getFrequencyForY(int y, double minFreq, double maxFreq, | |
77 bool logarithmic) const = 0; | |
78 | |
79 /** | |
80 * Return the zoom level, i.e. the number of frames per pixel | |
81 */ | |
82 virtual int getZoomLevel() const = 0; | |
83 | |
84 /** | |
85 * To be called from a layer, to obtain the extent of the surface | |
86 * that the layer is currently painting to. This may be the extent | |
87 * of the view (if 1x display scaling is in effect) or of a larger | |
88 * cached pixmap (if greater display scaling is in effect). | |
89 */ | |
90 virtual QRect getPaintRect() const = 0; | |
91 | |
92 virtual QSize getPaintSize() const { return getPaintRect().size(); } | |
93 virtual int getPaintWidth() const { return getPaintRect().width(); } | |
94 virtual int getPaintHeight() const { return getPaintRect().height(); } | |
95 | |
96 virtual bool hasLightBackground() const = 0; | |
97 virtual QColor getForeground() const = 0; | |
98 virtual QColor getBackground() const = 0; | |
99 | |
100 virtual ViewManager *getViewManager() const = 0; | |
101 | |
102 virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const = 0; | |
103 | |
104 enum TextStyle { | |
105 BoxedText, | |
106 OutlinedText, | |
107 OutlinedItalicText | |
108 }; | |
109 | |
110 virtual void drawVisibleText(QPainter &p, int x, int y, | |
111 QString text, TextStyle style) const = 0; | |
112 | |
113 virtual void drawMeasurementRect(QPainter &p, const Layer *, | |
114 QRect rect, bool focus) const = 0; | |
115 | |
116 virtual QWidget *getWidget() const = 0; | |
117 }; | |
118 | |
119 #endif |