]> granicus.if.org Git - nethack/commitdiff
Qt screen layout
authorPatR <rankin@nethack.org>
Sun, 15 Nov 2020 16:59:08 +0000 (08:59 -0800)
committerPatR <rankin@nethack.org>
Sun, 15 Nov 2020 16:59:08 +0000 (08:59 -0800)
Simplify a recent change to the screen layout.  Qt can calculate
the details and the recent code resulted in a slight amount of
blank space between the paperdoll and its resize hotspot.

Fix an off-by-one bug in the paperdoll resize routine.  (The one
pixel margin at the top was being overlooked.)

win/Qt/qt_inv.cpp
win/Qt/qt_main.cpp

index e32a825221388dda33d2d473f1cc8cd0ab51cfb6..da2469ed48d99fda539fe6656ab3a27ed03def2a 100644 (file)
@@ -222,13 +222,13 @@ QSize NetHackQtInvUsageWindow::sizeHint(void) const
         if (iflags.wc_ascii_map)
             qt_settings->doll_is_shown = false;
         if (qt_settings->doll_is_shown) {
-            w = (1 + qt_settings->dollWidth + 1) * 3;
-            h = (1 + qt_settings->dollHeight + 1) * 6;
+            w += (1 + qt_settings->dollWidth + 1) * 3;
+            h += (1 + qt_settings->dollHeight + 1) * 6;
         }
 #else
         if (iflags.wc_tiled_map) {
-            w = (1 + qt_settings->glyphs().width() + 1) * 3;
-            h = (1 + qt_settings->glyphs().height() + 1) * 6;
+            w += (1 + qt_settings->glyphs().width() + 1) * 3;
+            h += (1 + qt_settings->glyphs().height() + 1) * 6;
         }
 #endif
         return QSize(w, h);
index 69a2729dc83ad45df2b2966f3250e1be417885f9..3920a610ff41d52275c76ca967d39916d721523d 100644 (file)
@@ -1140,12 +1140,9 @@ void NetHackQtMainWindow::layout()
 #endif
         // reset widths
         int w = width(); /* of main window */
-        // 10: approximate size of resizing hotspots
-        int d = qt_settings->doll_is_shown ? 10 + invusage->width() + 10 : 10;
-        if (d % 4)
-            d += 4 - d % 4;
+        int d = invusage->width();
         splittersizes[2] = w / 2 - (d * 1 / 4); // status
-        splittersizes[1] = d - 10;              // invusage
+        splittersizes[1] = d;                   // invusage
         splittersizes[0] = w / 2 - (d * 3 / 4); // messages
         hsplitter->setSizes(splittersizes);
     }
@@ -1173,7 +1170,9 @@ void NetHackQtMainWindow::resizePaperDoll(bool showdoll)
     }
 
     // Height limit is 48+2 pixels per doll cell plus 1 pixel margin at top;
-    // values greater than 42+2 need taller window which pushes the map down.
+    // values greater than 44+2 need taller window which pushes the map down
+    // (when font size 'Large' is used for messages and status; threshold
+    // may vary by 1 or 2 for other sizes).
     // FIXME: this doesn't shrink the window back if size is reduced from 45+
     int oldheight = vsplittersizes[0],
         newheight = w->height();