Mercurial > hg > svgui
comparison view/ViewProxy.h @ 1401:28075cc658c9
Scale pen for retina display on macOS as well as for hidpi display elsewhere
author | Chris Cannam |
---|---|
date | Thu, 15 Nov 2018 14:04:32 +0000 |
parents | 344f29e46258 |
children | b0eeec95ab5b |
comparison
equal
deleted
inserted
replaced
1400:decb7741d036 | 1401:28075cc658c9 |
---|---|
141 m_view->update(r.x() / m_scaleFactor, | 141 m_view->update(r.x() / m_scaleFactor, |
142 r.y() / m_scaleFactor, | 142 r.y() / m_scaleFactor, |
143 r.width() / m_scaleFactor, | 143 r.width() / m_scaleFactor, |
144 r.height() / m_scaleFactor); | 144 r.height() / m_scaleFactor); |
145 } | 145 } |
146 | |
147 /** | |
148 * Scale up a size in pixels for a hi-dpi display without pixel | |
149 * doubling. This is like ViewManager::scalePixelSize, but taking | |
150 * and returning floating-point values rather than integer | |
151 * pixels. It is also a little more conservative - it never | |
152 * shrinks the size, it can only increase or leave it unchanged. | |
153 */ | |
154 virtual double scaleSize(double size) const { | |
155 return m_view->scaleSize(size * m_scaleFactor); | |
156 } | |
157 | |
158 /** | |
159 * Scale up pen width for a hi-dpi display without pixel doubling. | |
160 * This is like scaleSize except that it also scales the | |
161 * zero-width case. | |
162 */ | |
163 virtual double scalePenWidth(double width) const { | |
164 if (width <= 0) { // zero-width pen, produce a scaled one-pixel pen | |
165 width = 1; | |
166 } | |
167 width *= sqrt(double(m_scaleFactor)); | |
168 return m_view->scalePenWidth(width); | |
169 } | |
170 | |
171 /** | |
172 * Apply scalePenWidth to a pen. | |
173 */ | |
174 virtual QPen scalePen(QPen pen) const { | |
175 return QPen(pen.color(), scalePenWidth(pen.width())); | |
176 } | |
146 | 177 |
147 virtual View *getView() { return m_view; } | 178 virtual View *getView() { return m_view; } |
148 virtual const View *getView() const { return m_view; } | 179 virtual const View *getView() const { return m_view; } |
149 | 180 |
150 private: | 181 private: |