From 8ba16c972a1fdccbd76871712b48a9a2f03fc75a Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Sat, 23 May 2020 21:53:49 -0700 Subject: [PATCH] Scale buttons and toggle buttons with screen pitch also. --- data/gui/macros/_initial.cfg | 22 +++++++++++++++++++++ data/gui/widget/button_default.cfg | 16 +++++++++++++++ data/gui/widget/label_default.cfg | 24 ++--------------------- data/gui/widget/toggle_button_default.cfg | 3 +++ 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/data/gui/macros/_initial.cfg b/data/gui/macros/_initial.cfg index 546ad68690e..49c54fc795f 100644 --- a/data/gui/macros/_initial.cfg +++ b/data/gui/macros/_initial.cfg @@ -349,6 +349,28 @@ hint_image = "icons/action/zoomdefault_25.png~FL(horiz)" #enddef +# The following is a more-or-less arbitrary resolution, larger than 1024x768 +# in both dimensions, at which to switch over from the traditional +# everything-is-fixed-size layout to one that scales proportionally to +# the screen_pitch_microns. + +#define GUI_BIG_RESOLUTION + window_width = 1200 + window_height = 900 +#enddef + +# The magic number 265 in the below formula is the pixel pitch in microns +# corresponding to 96 dpi, which the old layout seems to have been based on. +# The extra factor of 2/3 in the formula is a fudge factor based on the guess +# that the old fonts took up approximately 1.5 pixels per point size at 96 +# dpi. It came out looking pretty decent on my 90-micron monitor. + +#define GUI_SCALE_RESOLUTION SIZE + "(max({SIZE}, floor({SIZE} * 265 * 2 / (3 * screen_pitch_microns))))" +#enddef + + + ############################################################################### ### ### ### Macros for the normal gui. ### diff --git a/data/gui/widget/button_default.cfg b/data/gui/widget/button_default.cfg index 3ac5fbe34a3..487c26f1ebf 100644 --- a/data/gui/widget/button_default.cfg +++ b/data/gui/widget/button_default.cfg @@ -156,6 +156,10 @@ description = "Default button" {_GUI_RESOLUTION () 40 112 26 13 4 ({_GUI_BUTTON_FONT_SIZE}) () 255} + {_GUI_RESOLUTION ({GUI_BIG_RESOLUTION}) + 50 128 30 16 6 + ({GUI_SCALE_RESOLUTION {_GUI_BUTTON_FONT_SIZE}}) + () 255} [/button_definition] @@ -165,6 +169,10 @@ description = "Large button" {_GUI_RESOLUTION () 40 116 30 13 4 ({_GUI_BUTTON_FONT_SIZE}) () 255} + {_GUI_RESOLUTION ({GUI_BIG_RESOLUTION}) + 50 136 32 16 6 + ({GUI_SCALE_RESOLUTION {_GUI_BUTTON_FONT_SIZE}}) + () 255} [/button_definition] @@ -174,6 +182,10 @@ description = "Large button" {_GUI_RESOLUTION () 40 172 40 13 4 ({GUI_FONT_SIZE_LARGE}) () 255} + {_GUI_RESOLUTION ({GUI_BIG_RESOLUTION}) + 50 192 44 16 6 + ({GUI_SCALE_RESOLUTION {GUI_FONT_SIZE_LARGE}}) + () 255} [/button_definition] @@ -183,6 +195,10 @@ description = "Default transparent button" {_GUI_RESOLUTION () 40 112 26 13 4 ({_GUI_BUTTON_FONT_SIZE}) "~O(65%)" 165} + {_GUI_RESOLUTION ({GUI_BIG_RESOLUTION}) + 50 128 30 16 6 + ({GUI_SCALE_RESOLUTION {_GUI_BUTTON_FONT_SIZE}}) + "~O(65%)" 165} [/button_definition] diff --git a/data/gui/widget/label_default.cfg b/data/gui/widget/label_default.cfg index f31883b9b33..615cbf8fe23 100644 --- a/data/gui/widget/label_default.cfg +++ b/data/gui/widget/label_default.cfg @@ -80,26 +80,6 @@ [/resolution] #enddef -# The following is a more-or-less arbitrary resolution, larger than 1024x768 -# in both dimensions, at which to switch over from the traditional -# everything-is-fixed-size layout to one that scales proportionally to -# the screen_pitch_microns. - -#define _GUI_BIG_RES - window_width = 1200 - window_height = 900 -#enddef - -# The magic number 265 in the below formula is the pixel pitch in microns -# corresponding to 96 dpi, which the old layout seems to have been based on. -# The extra factor of 2/3 in the formula is a fudge factor based on the guess -# that the old fonts took up approximately 1.5 pixels per point size at 96 -# dpi. It came out looking pretty decent on my 90-micron monitor. - -#define _GUI_SCALE_RES SIZE - "(max({SIZE}, floor({SIZE} * 265 * 2 / (3 * screen_pitch_microns))))" -#enddef - #define _GUI_DEFINITION ID DESCRIPTION FONT_FAMILY FONT_SIZE FONT_STYLE FONT_COLOR [label_definition] id = {ID} @@ -115,9 +95,9 @@ } {_GUI_RESOLUTION - ({_GUI_BIG_RES}) + ({GUI_BIG_RESOLUTION}) ({FONT_FAMILY}) - ({_GUI_SCALE_RES {GUI_FONT_SIZE_{FONT_SIZE}}}) + ({GUI_SCALE_RESOLUTION {GUI_FONT_SIZE_{FONT_SIZE}}}) ({FONT_STYLE}) ({GUI__FONT_COLOR_ENABLED__{FONT_COLOR} ALPHA=""}) ({GUI__FONT_COLOR_DISABLED__{FONT_COLOR} ALPHA=""}) diff --git a/data/gui/widget/toggle_button_default.cfg b/data/gui/widget/toggle_button_default.cfg index 3d57a8cf7bb..87c9411c6f5 100644 --- a/data/gui/widget/toggle_button_default.cfg +++ b/data/gui/widget/toggle_button_default.cfg @@ -134,6 +134,9 @@ description = "Checkbox." {_GUI_RESOLUTION () 30 18 25 ({GUI_FONT_SIZE_SMALL}) } + {_GUI_RESOLUTION ({GUI_BIG_RESOLUTION}) + 36 20 28 + ({GUI_SCALE_RESOLUTION {GUI_FONT_SIZE_SMALL}}) } [/toggle_button_definition]