Mercurial > hg > svgui
comparison view/Pane.cpp @ 1193:54e6be7ebe11 levelpanwidget
Some adjustments to make view elements clearer and more correctly sized, especially on hidpi (non-pixel-doubling) systems
author | Chris Cannam |
---|---|
date | Thu, 15 Dec 2016 15:34:33 +0000 |
parents | 97d0c798c2ac |
children | 6828735468c9 |
comparison
equal
deleted
inserted
replaced
1192:bf509e47e324 | 1193:54e6be7ebe11 |
---|---|
20 #include "base/RealTime.h" | 20 #include "base/RealTime.h" |
21 #include "base/Profiler.h" | 21 #include "base/Profiler.h" |
22 #include "ViewManager.h" | 22 #include "ViewManager.h" |
23 #include "widgets/CommandHistory.h" | 23 #include "widgets/CommandHistory.h" |
24 #include "widgets/TextAbbrev.h" | 24 #include "widgets/TextAbbrev.h" |
25 #include "widgets/IconLoader.h" | |
25 #include "base/Preferences.h" | 26 #include "base/Preferences.h" |
26 #include "layer/WaveformLayer.h" | 27 #include "layer/WaveformLayer.h" |
27 #include "layer/TimeRulerLayer.h" | 28 #include "layer/TimeRulerLayer.h" |
28 #include "layer/PaintAssistant.h" | 29 #include "layer/PaintAssistant.h" |
29 | 30 |
140 | 141 |
141 m_hthumb = new Thumbwheel(Qt::Horizontal); | 142 m_hthumb = new Thumbwheel(Qt::Horizontal); |
142 m_hthumb->setObjectName(tr("Horizontal Zoom")); | 143 m_hthumb->setObjectName(tr("Horizontal Zoom")); |
143 m_hthumb->setCursor(Qt::ArrowCursor); | 144 m_hthumb->setCursor(Qt::ArrowCursor); |
144 layout->addWidget(m_hthumb, 1, 0, 1, 2); | 145 layout->addWidget(m_hthumb, 1, 0, 1, 2); |
145 m_hthumb->setFixedWidth(70); | 146 m_hthumb->setFixedWidth(m_manager->scalePixelSize(70)); |
146 m_hthumb->setFixedHeight(16); | 147 m_hthumb->setFixedHeight(m_manager->scalePixelSize(16)); |
147 m_hthumb->setDefaultValue(0); | 148 m_hthumb->setDefaultValue(0); |
148 m_hthumb->setSpeed(0.6f); | 149 m_hthumb->setSpeed(0.6f); |
149 connect(m_hthumb, SIGNAL(valueChanged(int)), this, | 150 connect(m_hthumb, SIGNAL(valueChanged(int)), this, |
150 SLOT(horizontalThumbwheelMoved(int))); | 151 SLOT(horizontalThumbwheelMoved(int))); |
151 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 152 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
152 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 153 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
153 | 154 |
154 m_vpan = new Panner; | 155 m_vpan = new Panner; |
155 m_vpan->setCursor(Qt::ArrowCursor); | 156 m_vpan->setCursor(Qt::ArrowCursor); |
156 layout->addWidget(m_vpan, 0, 1); | 157 layout->addWidget(m_vpan, 0, 1); |
157 m_vpan->setFixedWidth(12); | 158 m_vpan->setFixedWidth(m_manager->scalePixelSize(12)); |
158 m_vpan->setFixedHeight(70); | 159 m_vpan->setFixedHeight(m_manager->scalePixelSize(70)); |
159 m_vpan->setAlpha(80, 130); | 160 m_vpan->setAlpha(80, 130); |
160 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), | 161 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)), |
161 this, SLOT(verticalPannerMoved(float, float, float, float))); | 162 this, SLOT(verticalPannerMoved(float, float, float, float))); |
162 connect(m_vpan, SIGNAL(doubleClicked()), | 163 connect(m_vpan, SIGNAL(doubleClicked()), |
163 this, SLOT(editVerticalPannerExtents())); | 164 this, SLOT(editVerticalPannerExtents())); |
166 | 167 |
167 m_vthumb = new Thumbwheel(Qt::Vertical); | 168 m_vthumb = new Thumbwheel(Qt::Vertical); |
168 m_vthumb->setObjectName(tr("Vertical Zoom")); | 169 m_vthumb->setObjectName(tr("Vertical Zoom")); |
169 m_vthumb->setCursor(Qt::ArrowCursor); | 170 m_vthumb->setCursor(Qt::ArrowCursor); |
170 layout->addWidget(m_vthumb, 0, 2); | 171 layout->addWidget(m_vthumb, 0, 2); |
171 m_vthumb->setFixedWidth(16); | 172 m_vthumb->setFixedWidth(m_manager->scalePixelSize(16)); |
172 m_vthumb->setFixedHeight(70); | 173 m_vthumb->setFixedHeight(m_manager->scalePixelSize(70)); |
173 connect(m_vthumb, SIGNAL(valueChanged(int)), this, | 174 connect(m_vthumb, SIGNAL(valueChanged(int)), this, |
174 SLOT(verticalThumbwheelMoved(int))); | 175 SLOT(verticalThumbwheelMoved(int))); |
175 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 176 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
176 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 177 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
177 | 178 |
181 } | 182 } |
182 | 183 |
183 m_reset = new NotifyingPushButton; | 184 m_reset = new NotifyingPushButton; |
184 m_reset->setFlat(true); | 185 m_reset->setFlat(true); |
185 m_reset->setCursor(Qt::ArrowCursor); | 186 m_reset->setCursor(Qt::ArrowCursor); |
186 m_reset->setFixedHeight(16); | 187 m_reset->setFixedHeight(m_manager->scalePixelSize(16)); |
187 m_reset->setFixedWidth(16); | 188 m_reset->setFixedWidth(m_manager->scalePixelSize(16)); |
188 m_reset->setIcon(QPixmap(":/icons/zoom-reset.png")); | 189 m_reset->setIcon(IconLoader().load("zoom-reset")); |
189 m_reset->setToolTip(tr("Reset zoom to default")); | 190 m_reset->setToolTip(tr("Reset zoom to default")); |
190 layout->addWidget(m_reset, 1, 2); | 191 layout->addWidget(m_reset, 1, 2); |
191 | 192 |
192 layout->setColumnStretch(0, 20); | 193 layout->setColumnStretch(0, 20); |
193 | 194 |
282 } | 283 } |
283 | 284 |
284 updateVerticalPanner(); | 285 updateVerticalPanner(); |
285 | 286 |
286 if (m_manager && m_manager->getZoomWheelsEnabled() && | 287 if (m_manager && m_manager->getZoomWheelsEnabled() && |
287 width() > 120 && height() > 100) { | 288 width() > m_manager->scalePixelSize(120) && |
289 height() > m_manager->scalePixelSize(100)) { | |
288 if (!m_headsUpDisplay->isVisible()) { | 290 if (!m_headsUpDisplay->isVisible()) { |
289 m_headsUpDisplay->show(); | 291 m_headsUpDisplay->show(); |
290 } | 292 } |
293 int shift = m_manager->scalePixelSize(86); | |
291 if (haveVThumb) { | 294 if (haveVThumb) { |
292 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); | 295 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height()); |
293 m_headsUpDisplay->move(width() - 86, height() - 86); | 296 m_headsUpDisplay->move(width() - shift, height() - shift); |
294 } else { | 297 } else { |
295 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); | 298 m_headsUpDisplay->setFixedHeight(m_hthumb->height()); |
296 m_headsUpDisplay->move(width() - 86, height() - 16); | 299 m_headsUpDisplay->move(width() - shift, |
300 height() - m_manager->scalePixelSize(16)); | |
297 } | 301 } |
298 } else { | 302 } else { |
299 m_headsUpDisplay->hide(); | 303 m_headsUpDisplay->hide(); |
300 } | 304 } |
301 } | 305 } |
918 int fontHeight = paint.fontMetrics().height(); | 922 int fontHeight = paint.fontMetrics().height(); |
919 int fontAscent = paint.fontMetrics().ascent(); | 923 int fontAscent = paint.fontMetrics().ascent(); |
920 | 924 |
921 int lly = height() - 6; | 925 int lly = height() - 6; |
922 if (m_manager->getZoomWheelsEnabled()) { | 926 if (m_manager->getZoomWheelsEnabled()) { |
923 lly -= 20; | 927 lly -= m_manager->scalePixelSize(20); |
924 } | 928 } |
925 | 929 |
926 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { | 930 if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { |
927 return; | 931 return; |
928 } | 932 } |
940 int maxTextWidth = width() / 3; | 944 int maxTextWidth = width() / 3; |
941 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); | 945 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); |
942 | 946 |
943 int llx = width() - maxTextWidth - 5; | 947 int llx = width() - maxTextWidth - 5; |
944 if (m_manager->getZoomWheelsEnabled()) { | 948 if (m_manager->getZoomWheelsEnabled()) { |
945 llx -= 36; | 949 llx -= m_manager->scalePixelSize(36); |
946 } | 950 } |
947 | 951 |
948 if (r.x() + r.width() >= llx - fontAscent - 3) { | 952 if (r.x() + r.width() >= llx - fontAscent - 3) { |
949 | 953 |
950 for (int i = 0; i < texts.size(); ++i) { | 954 for (int i = 0; i < texts.size(); ++i) { |