Change: Split vscroll and hscroll padding.

Vertical and horizontal scrollbars are different sizes, this allows
different padding for each type.
This commit is contained in:
Peter Nelson 2022-10-01 16:49:37 +01:00 committed by PeterN
parent 90ce704366
commit 23a8222200
2 changed files with 19 additions and 11 deletions

View File

@ -27,7 +27,8 @@
const WidgetDimensions WidgetDimensions::unscaled = { const WidgetDimensions WidgetDimensions::unscaled = {
{WD_IMGBTN_LEFT, WD_IMGBTN_TOP, WD_IMGBTN_RIGHT, WD_IMGBTN_BOTTOM}, ///< imgbtn {WD_IMGBTN_LEFT, WD_IMGBTN_TOP, WD_IMGBTN_RIGHT, WD_IMGBTN_BOTTOM}, ///< imgbtn
{WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, WD_BEVEL_BOTTOM}, ///< inset {WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, WD_BEVEL_BOTTOM}, ///< inset
{WD_SCROLLBAR_LEFT, WD_SCROLLBAR_TOP, WD_SCROLLBAR_RIGHT, WD_SCROLLBAR_BOTTOM}, ///< scrollbar {WD_VSCROLLBAR_LEFT, WD_VSCROLLBAR_TOP, WD_VSCROLLBAR_RIGHT, WD_VSCROLLBAR_BOTTOM}, ///< vscrollbar
{WD_HSCROLLBAR_LEFT, WD_HSCROLLBAR_TOP, WD_HSCROLLBAR_RIGHT, WD_HSCROLLBAR_BOTTOM}, ///< hscrollbar
{WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< bevel {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< bevel
{WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< fullbevel {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< fullbevel
{WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM}, ///< framerect {WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM}, ///< framerect
@ -92,7 +93,8 @@ void SetupWidgetDimensions()
{ {
WidgetDimensions::scaled.imgbtn = ScaleGUITrad(WidgetDimensions::unscaled.imgbtn); WidgetDimensions::scaled.imgbtn = ScaleGUITrad(WidgetDimensions::unscaled.imgbtn);
WidgetDimensions::scaled.inset = ScaleGUITrad(WidgetDimensions::unscaled.inset); WidgetDimensions::scaled.inset = ScaleGUITrad(WidgetDimensions::unscaled.inset);
WidgetDimensions::scaled.scrollbar = ScaleGUITrad(WidgetDimensions::unscaled.scrollbar); WidgetDimensions::scaled.vscrollbar = ScaleGUITrad(WidgetDimensions::unscaled.vscrollbar);
WidgetDimensions::scaled.hscrollbar = ScaleGUITrad(WidgetDimensions::unscaled.hscrollbar);
WidgetDimensions::scaled.bevel = WidgetDimensions::unscaled.bevel; WidgetDimensions::scaled.bevel = WidgetDimensions::unscaled.bevel;
WidgetDimensions::scaled.fullbevel = ScaleGUITrad(WidgetDimensions::unscaled.fullbevel); WidgetDimensions::scaled.fullbevel = ScaleGUITrad(WidgetDimensions::unscaled.fullbevel);
WidgetDimensions::scaled.framerect = ScaleGUITrad(WidgetDimensions::unscaled.framerect); WidgetDimensions::scaled.framerect = ScaleGUITrad(WidgetDimensions::unscaled.framerect);
@ -2408,8 +2410,8 @@ void NWidgetScrollbar::Draw(const Window *w)
{ {
if (vertical_dimension.width == 0) { if (vertical_dimension.width == 0) {
vertical_dimension = maxdim(GetScaledSpriteSize(SPR_ARROW_UP), GetScaledSpriteSize(SPR_ARROW_DOWN)); vertical_dimension = maxdim(GetScaledSpriteSize(SPR_ARROW_UP), GetScaledSpriteSize(SPR_ARROW_DOWN));
vertical_dimension.width += WidgetDimensions::scaled.scrollbar.Horizontal(); vertical_dimension.width += WidgetDimensions::scaled.vscrollbar.Horizontal();
vertical_dimension.height += WidgetDimensions::scaled.scrollbar.Vertical(); vertical_dimension.height += WidgetDimensions::scaled.vscrollbar.Vertical();
} }
return vertical_dimension; return vertical_dimension;
} }
@ -2418,8 +2420,8 @@ void NWidgetScrollbar::Draw(const Window *w)
{ {
if (horizontal_dimension.width == 0) { if (horizontal_dimension.width == 0) {
horizontal_dimension = maxdim(GetScaledSpriteSize(SPR_ARROW_LEFT), GetScaledSpriteSize(SPR_ARROW_RIGHT)); horizontal_dimension = maxdim(GetScaledSpriteSize(SPR_ARROW_LEFT), GetScaledSpriteSize(SPR_ARROW_RIGHT));
horizontal_dimension.width += WidgetDimensions::scaled.scrollbar.Horizontal(); horizontal_dimension.width += WidgetDimensions::scaled.hscrollbar.Horizontal();
horizontal_dimension.height += WidgetDimensions::scaled.scrollbar.Vertical(); horizontal_dimension.height += WidgetDimensions::scaled.hscrollbar.Vertical();
} }
return horizontal_dimension; return horizontal_dimension;
} }

View File

@ -37,7 +37,8 @@ DECLARE_ENUM_AS_BIT_SET(FrameFlags)
struct WidgetDimensions { struct WidgetDimensions {
RectPadding imgbtn; RectPadding imgbtn;
RectPadding inset; RectPadding inset;
RectPadding scrollbar; RectPadding vscrollbar;
RectPadding hscrollbar;
RectPadding bevel; ///< Widths of bevel border. RectPadding bevel; ///< Widths of bevel border.
RectPadding fullbevel; ///< Always-scaled bevel border. RectPadding fullbevel; ///< Always-scaled bevel border.
RectPadding framerect; ///< Offsets within frame area. RectPadding framerect; ///< Offsets within frame area.
@ -77,10 +78,15 @@ enum WidgetDrawDistances {
WD_INSET_RIGHT = 2, ///< Right offset of string. WD_INSET_RIGHT = 2, ///< Right offset of string.
WD_INSET_TOP = 1, ///< Top offset of string. WD_INSET_TOP = 1, ///< Top offset of string.
WD_SCROLLBAR_LEFT = 2, ///< Left offset of scrollbar. WD_VSCROLLBAR_LEFT = 2, ///< Left offset of vertical scrollbar.
WD_SCROLLBAR_RIGHT = 2, ///< Right offset of scrollbar. WD_VSCROLLBAR_RIGHT = 2, ///< Right offset of vertical scrollbar.
WD_SCROLLBAR_TOP = 2, ///< Top offset of scrollbar. WD_VSCROLLBAR_TOP = 3, ///< Top offset of vertical scrollbar.
WD_SCROLLBAR_BOTTOM = 2, ///< Bottom offset of scrollbar. WD_VSCROLLBAR_BOTTOM = 3, ///< Bottom offset of vertical scrollbar.
WD_HSCROLLBAR_LEFT = 3, ///< Left offset of horizontal scrollbar.
WD_HSCROLLBAR_RIGHT = 3, ///< Right offset of horizontal scrollbar.
WD_HSCROLLBAR_TOP = 2, ///< Top offset of horizontal scrollbar.
WD_HSCROLLBAR_BOTTOM = 2, ///< Bottom offset of horizontal scrollbar.
/* Size of the pure frame bevel without any padding. */ /* Size of the pure frame bevel without any padding. */
WD_BEVEL_LEFT = 1, ///< Width of left bevel border. WD_BEVEL_LEFT = 1, ///< Width of left bevel border.