From: PatR Date: Sun, 15 Nov 2020 16:59:08 +0000 (-0800) Subject: Qt screen layout X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=560d324a2f562346173bcf05d19ee3391de9ec4d;p=nethack Qt screen layout 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.) --- diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index e32a82522..da2469ed4 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -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); diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index 69a2729dc..3920a610f 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -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();