changeset 1270:7527701c8076

Make selection extents more visible on hi-dpi
author Chris Cannam
date Thu, 19 Apr 2018 14:36:16 +0100
parents f2894944c6b8
children d967e21fe995
files view/Pane.cpp view/PaneStack.h view/View.cpp view/ViewManager.h
diffstat 4 files changed, 28 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/view/Pane.cpp	Thu Apr 19 14:35:59 2018 +0100
+++ b/view/Pane.cpp	Thu Apr 19 14:36:16 2018 +0100
@@ -1215,7 +1215,7 @@
 
     if (!m_manager) return Selection();
 
-    sv_frame_t testFrame = getFrameForX(x - 5);
+    sv_frame_t testFrame = getFrameForX(x - ViewManager::scalePixelSize(5));
     if (testFrame < 0) {
         testFrame = getFrameForX(x);
         if (testFrame < 0) return Selection();
@@ -1227,13 +1227,15 @@
     int lx = getXForFrame(selection.getStartFrame());
     int rx = getXForFrame(selection.getEndFrame());
     
-    int fuzz = 2;
+    int fuzz = ViewManager::scalePixelSize(2);
     if (x < lx - fuzz || x > rx + fuzz) return Selection();
 
     int width = rx - lx;
-    fuzz = 3;
+    fuzz = ViewManager::scalePixelSize(3);
     if (width < 12) fuzz = width / 4;
-    if (fuzz < 1) fuzz = 1;
+    if (fuzz < ViewManager::scalePixelSize(1)) {
+        fuzz = ViewManager::scalePixelSize(1);
+    }
 
     if (x < lx + fuzz) closeToLeftEdge = true;
     if (x > rx - fuzz) closeToRightEdge = true;
--- a/view/PaneStack.h	Thu Apr 19 14:35:59 2018 +0100
+++ b/view/PaneStack.h	Thu Apr 19 14:36:16 2018 +0100
@@ -13,8 +13,8 @@
     COPYING included with this distribution for more information.
 */
 
-#ifndef _PANESTACK_H_
-#define _PANESTACK_H_
+#ifndef SV_PANESTACK_H
+#define SV_PANESTACK_H
 
 #include <QFrame>
 
--- a/view/View.cpp	Thu Apr 19 14:35:59 2018 +0100
+++ b/view/View.cpp	Thu Apr 19 14:36:16 2018 +0100
@@ -2023,32 +2023,38 @@
         bool illuminateThis =
             (illuminateFrame >= 0 && i->contains(illuminateFrame));
 
-        paint.setPen(QColor(150, 150, 255));
+        double h = height();
+        double penWidth = PaintAssistant::scalePenWidth(1.0);
+        double half = penWidth/2.0;
+
+        paint.setPen(QPen(QColor(150, 150, 255), penWidth));
 
         if (translucent && shouldLabelSelections()) {
-            paint.drawRect(p0, -1, p1 - p0, height() + 1);
+            paint.drawRect(QRectF(p0, -penWidth, p1 - p0, h + 2*penWidth));
         } else {
             // Make the top & bottom lines of the box visible if we
             // are lacking some of the other visual cues.  There's no
             // particular logic to this, it's just a question of what
             // I happen to think looks nice.
-            paint.drawRect(p0, 0, p1 - p0, height() - 1);
+            paint.drawRect(QRectF(p0, half, p1 - p0, h - penWidth));
         }
 
         if (illuminateThis) {
             paint.save();
-            paint.setPen(QPen(getForeground(), 2));
+            penWidth = PaintAssistant::scalePenWidth(2.0);
+            half = penWidth/2.0;
+            paint.setPen(QPen(getForeground(), penWidth));
             if (closeToLeft) {
-                paint.drawLine(p0, 1, p1, 1);
-                paint.drawLine(p0, 0, p0, height());
-                paint.drawLine(p0, height() - 1, p1, height() - 1);
+                paint.drawLine(QLineF(p0, half, p1, half));
+                paint.drawLine(QLineF(p0, half, p0, h - half));
+                paint.drawLine(QLineF(p0, h - half, p1, h - half));
             } else if (closeToRight) {
-                paint.drawLine(p0, 1, p1, 1);
-                paint.drawLine(p1, 0, p1, height());
-                paint.drawLine(p0, height() - 1, p1, height() - 1);
+                paint.drawLine(QLineF(p0, half, p1, half));
+                paint.drawLine(QLineF(p1, half, p1, h - half));
+                paint.drawLine(QLineF(p0, h - half, p1, h - half));
             } else {
                 paint.setBrush(Qt::NoBrush);
-                paint.drawRect(p0, 1, p1 - p0, height() - 2);
+                paint.drawRect(QRectF(p0, half, p1 - p0, h - penWidth));
             }
             paint.restore();
         }
--- a/view/ViewManager.h	Thu Apr 19 14:35:59 2018 +0100
+++ b/view/ViewManager.h	Thu Apr 19 14:36:16 2018 +0100
@@ -13,8 +13,8 @@
     COPYING included with this distribution for more information.
 */
 
-#ifndef _VIEW_MANAGER_H_
-#define _VIEW_MANAGER_H_
+#ifndef SV_VIEW_MANAGER_H
+#define SV_VIEW_MANAGER_H
 
 #include <QObject>
 #include <QTimer>
@@ -193,7 +193,7 @@
      * display. This is relevant to hi-dpi systems that do not do
      * pixel doubling (i.e. Windows and Linux rather than OS/X).
      */
-    int scalePixelSize(int pixels);
+    static int scalePixelSize(int pixels);
     
     enum OverlayMode {
         NoOverlays,