Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/ci-build.yml # src/ai/ai_gui.cpp # src/blitter/32bpp_optimized.cpp # src/blitter/32bpp_simple.cpp # src/blitter/32bpp_sse2.cpp # src/blitter/8bpp_optimized.cpp # src/blitter/8bpp_simple.cpp # src/blitter/null.cpp # src/blitter/null.hpp # src/company_gui.cpp # src/game/game_gui.cpp # src/genworld_gui.cpp # src/gfx.cpp # src/gfx_func.h # src/graph_gui.cpp # src/industry_gui.cpp # src/linkgraph/linkgraphjob.cpp # src/network/network_gui.cpp # src/newgrf_debug_gui.cpp # src/openttd.cpp # src/pathfinder/npf/aystar.h # src/road_gui.cpp # src/saveload/order_sl.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/script/api/script_log.cpp # src/script/api/script_town.cpp # src/script/script_gui.cpp # src/settings.cpp # src/settings_gui.cpp # src/settings_table.cpp # src/settings_type.h # src/smallmap_gui.cpp # src/sortlist_type.h # src/spritecache.cpp # src/spriteloader/grf.cpp # src/spriteloader/grf.hpp # src/spriteloader/spriteloader.hpp # src/station_cmd.cpp # src/station_cmd.h # src/station_gui.cpp # src/strings.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/town_gui.cpp # src/vehicle_gui.cpp # src/vehicle_gui_base.h # src/video/opengl.cpp # src/video/opengl.h # src/widgets/dropdown.cpp # src/widgets/dropdown_type.h # src/window_gui.h
This commit is contained in:
@@ -29,9 +29,9 @@
|
||||
enum WidgetDrawDistances {
|
||||
/* WWT_IMGBTN(_2) */
|
||||
WD_IMGBTN_LEFT = 1, ///< Left offset of the image in the button.
|
||||
WD_IMGBTN_RIGHT = 2, ///< Right offset of the image in the button.
|
||||
WD_IMGBTN_RIGHT = 1, ///< Right offset of the image in the button.
|
||||
WD_IMGBTN_TOP = 1, ///< Top offset of image in the button.
|
||||
WD_IMGBTN_BOTTOM = 2, ///< Bottom offset of image in the button.
|
||||
WD_IMGBTN_BOTTOM = 1, ///< Bottom offset of image in the button.
|
||||
|
||||
/* WWT_INSET */
|
||||
WD_INSET_LEFT = 2, ///< Left offset of string.
|
||||
@@ -150,11 +150,11 @@ const WidgetDimensions WidgetDimensions::unscaled = {
|
||||
{WD_CLOSEBOX_LEFT, WD_CLOSEBOX_TOP, WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_BOTTOM}, ///< closebox
|
||||
{WD_CAPTIONTEXT_LEFT, WD_CAPTIONTEXT_TOP, WD_CAPTIONTEXT_RIGHT, WD_CAPTIONTEXT_BOTTOM}, ///< captiontext
|
||||
{WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_BOTTOM}, ///< dropdowntext
|
||||
{WD_BEVEL_LEFT, WD_BEVEL_TOP * 2, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM * 2}, ///< dropdownmenu
|
||||
{20, 10, 20, 10}, ///< modalpopup
|
||||
{3, 3, 3, 3}, ///< picker
|
||||
{10, 8, 10, 8}, ///< sparse window padding
|
||||
{10, 8, 10, 1}, ///< resizable sparse window padding
|
||||
1, ///< pressed
|
||||
{10, 8, 10, 0}, ///< resizable sparse window padding
|
||||
1, ///< vsep_picker
|
||||
WD_PAR_VSEP_NORMAL, ///< vsep_normal
|
||||
4, ///< vsep_sparse
|
||||
@@ -225,9 +225,9 @@ void SetupWidgetDimensions()
|
||||
WidgetDimensions::scaled.closebox = ScaleGUITrad(WidgetDimensions::unscaled.closebox);
|
||||
WidgetDimensions::scaled.captiontext = ScaleGUITrad(WidgetDimensions::unscaled.captiontext);
|
||||
WidgetDimensions::scaled.dropdowntext = ScaleGUITrad(WidgetDimensions::unscaled.dropdowntext);
|
||||
WidgetDimensions::scaled.dropdownlist = ScaleGUITrad(WidgetDimensions::unscaled.dropdownlist);
|
||||
WidgetDimensions::scaled.modalpopup = ScaleGUITrad(WidgetDimensions::unscaled.modalpopup);
|
||||
|
||||
WidgetDimensions::scaled.pressed = ScaleGUITrad(WidgetDimensions::unscaled.pressed);
|
||||
WidgetDimensions::scaled.vsep_normal = ScaleGUITrad(WidgetDimensions::unscaled.vsep_normal);
|
||||
WidgetDimensions::scaled.vsep_wide = ScaleGUITrad(WidgetDimensions::unscaled.vsep_wide);
|
||||
WidgetDimensions::scaled.hsep_normal = ScaleGUITrad(WidgetDimensions::unscaled.hsep_normal);
|
||||
@@ -453,7 +453,7 @@ void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, Fra
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align)
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringAlignment align)
|
||||
{
|
||||
Point offset;
|
||||
Dimension d = GetSpriteSize(img, &offset);
|
||||
@@ -461,8 +461,7 @@ void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool cl
|
||||
d.height -= offset.y;
|
||||
|
||||
Point p = GetAlignedPosition(r, d, align);
|
||||
int o = clicked ? WidgetDimensions::scaled.pressed : 0;
|
||||
DrawSprite(img, pal, p.x + o - offset.x, p.y + o - offset.y);
|
||||
DrawSprite(img, pal, p.x - offset.x, p.y - offset.y);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,7 +469,7 @@ void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool cl
|
||||
* @param r Rectangle of the button.
|
||||
* @param type Widget type (#WWT_IMGBTN or #WWT_IMGBTN_2).
|
||||
* @param colour Colour of the button.
|
||||
* @param clicked Button is lowered.
|
||||
* @param clicked Button is clicked.
|
||||
* @param img Sprite to draw.
|
||||
* @param align Alignment of the sprite.
|
||||
*/
|
||||
@@ -480,14 +479,14 @@ static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colo
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
|
||||
if ((type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; // Show different image when clicked for #WWT_IMGBTN_2.
|
||||
DrawSpriteIgnorePadding(img, PAL_NONE, r, clicked, align);
|
||||
DrawSpriteIgnorePadding(img, PAL_NONE, r, align);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the label-part of a widget.
|
||||
* @param r Rectangle of the label background.
|
||||
* @param type Widget type (#WWT_TEXTBTN, #WWT_TEXTBTN_2, or #WWT_LABEL).
|
||||
* @param clicked Label is rendered lowered.
|
||||
* @param clicked Label is clicked.
|
||||
* @param colour Colour of the text.
|
||||
* @param str Text to draw.
|
||||
* @param align Alignment of the text.
|
||||
@@ -499,8 +498,7 @@ static inline void DrawLabel(const Rect &r, WidgetType type, bool clicked, TextC
|
||||
if ((type & WWT_MASK) == WWT_TEXTBTN_2 && clicked) str++;
|
||||
Dimension d = GetStringBoundingBox(str, fs);
|
||||
Point p = GetAlignedPosition(r, d, align);
|
||||
int o = clicked ? WidgetDimensions::scaled.pressed : 0;
|
||||
DrawString(r.left + o, r.right + o, p.y + o, str, colour, align, false, fs);
|
||||
DrawString(r.left, r.right, p.y, str, colour, align, false, fs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -779,11 +777,16 @@ static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked)
|
||||
* @param colour Colour of the resize box.
|
||||
* @param at_left Resize box is at left-side of the window,
|
||||
* @param clicked Box is lowered.
|
||||
* @param bevel Draw bevel iff set.
|
||||
*/
|
||||
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked)
|
||||
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked, bool bevel)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawSpriteIgnorePadding(at_left ? SPR_WINDOW_RESIZE_LEFT : SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.Shrink(ScaleGUITrad(2)), clicked, at_left ? (SA_LEFT | SA_BOTTOM | SA_FORCE) : (SA_RIGHT | SA_BOTTOM | SA_FORCE));
|
||||
if (bevel) {
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
} else if (clicked) {
|
||||
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), _colour_gradient[colour][6]);
|
||||
}
|
||||
DrawSpriteIgnorePadding(at_left ? SPR_WINDOW_RESIZE_LEFT : SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.Shrink(ScaleGUITrad(2)), at_left ? (SA_LEFT | SA_BOTTOM | SA_FORCE) : (SA_RIGHT | SA_BOTTOM | SA_FORCE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -835,8 +838,8 @@ void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_col
|
||||
* Draw a button with a dropdown (#WWT_DROPDOWN and #NWID_BUTTON_DROPDOWN).
|
||||
* @param r Rectangle containing the widget.
|
||||
* @param colour Background colour of the widget.
|
||||
* @param clicked_button The button-part is lowered.
|
||||
* @param clicked_dropdown The drop-down part is lowered.
|
||||
* @param clicked_button The button-part is clicked.
|
||||
* @param clicked_dropdown The drop-down part is clicked.
|
||||
* @param str Text of the button.
|
||||
* @param align Alignment of the text within the dropdown.
|
||||
*
|
||||
@@ -850,15 +853,13 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke
|
||||
DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
||||
DrawImageButtons(r.WithWidth(dd_width, true), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
|
||||
if (str != STR_NULL) {
|
||||
int o = clicked_button ? WidgetDimensions::scaled.pressed : 0;
|
||||
DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left + o, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align);
|
||||
DrawString(r.left + WidgetDimensions::scaled.dropdowntext.left, r.right - dd_width - WidgetDimensions::scaled.dropdowntext.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), str, TC_BLACK, align);
|
||||
}
|
||||
} else {
|
||||
DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
||||
DrawImageButtons(r.WithWidth(dd_width, false), WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER);
|
||||
if (str != STR_NULL) {
|
||||
int o = clicked_button ? WidgetDimensions::scaled.pressed : 0;
|
||||
DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left + o, r.right - WidgetDimensions::scaled.dropdowntext.right + o, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)) + o, str, TC_BLACK, align);
|
||||
DrawString(r.left + dd_width + WidgetDimensions::scaled.dropdowntext.left, r.right - WidgetDimensions::scaled.dropdowntext.right, CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)), str, TC_BLACK, align);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -908,7 +909,7 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const
|
||||
/* Sort button uses the same sprites as vertical scrollbar */
|
||||
Dimension dim = NWidgetScrollbar::GetVerticalDimension();
|
||||
|
||||
DrawSpriteIgnorePadding(state == SBS_DOWN ? SPR_ARROW_DOWN : SPR_ARROW_UP, PAL_NONE, r.WithWidth(dim.width, _current_text_dir == TD_LTR), this->IsWidgetLowered(widget), SA_CENTER);
|
||||
DrawSpriteIgnorePadding(state == SBS_DOWN ? SPR_ARROW_DOWN : SPR_ARROW_UP, PAL_NONE, r.WithWidth(dim.width, _current_text_dir == TD_LTR), SA_CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1534,10 +1535,13 @@ void NWidgetStacked::FillDirtyWidgets(std::vector<NWidgetBase *> &dirty_widgets)
|
||||
/**
|
||||
* Select which plane to show (for #NWID_SELECTION only).
|
||||
* @param plane Plane number to display.
|
||||
* @return true iff the shown plane changed.
|
||||
*/
|
||||
void NWidgetStacked::SetDisplayedPlane(int plane)
|
||||
bool NWidgetStacked::SetDisplayedPlane(int plane)
|
||||
{
|
||||
if (this->shown_plane == plane) return false;
|
||||
this->shown_plane = plane;
|
||||
return true;
|
||||
}
|
||||
|
||||
NWidgetPIPContainer::NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags) : NWidgetContainer(tp)
|
||||
@@ -2810,7 +2814,7 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data,
|
||||
this->SetFill(1, 0);
|
||||
this->SetResize(1, 0);
|
||||
this->SetMinimalSize(0, WD_CAPTION_HEIGHT);
|
||||
this->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL);
|
||||
this->SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical(), FS_NORMAL);
|
||||
this->SetDataTip(data, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||
break;
|
||||
|
||||
@@ -2841,7 +2845,7 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data,
|
||||
case WWT_RESIZEBOX:
|
||||
this->SetFill(0, 0);
|
||||
this->SetMinimalSize(WD_RESIZEBOX_WIDTH, 12);
|
||||
this->SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE);
|
||||
this->SetDataTip(RWV_SHOW_BEVEL, STR_TOOLTIP_RESIZE);
|
||||
break;
|
||||
|
||||
case WWT_CLOSEBOX:
|
||||
@@ -3149,8 +3153,7 @@ void NWidgetLeaf::Draw(const Window *w)
|
||||
break;
|
||||
|
||||
case WWT_RESIZEBOX:
|
||||
assert(this->widget_data == 0);
|
||||
DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING));
|
||||
DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING), this->widget_data == 0);
|
||||
break;
|
||||
|
||||
case WWT_CLOSEBOX:
|
||||
|
Reference in New Issue
Block a user