Merge tag '13.0-beta2' into jgrpp

# Conflicts:
#	src/cheat_gui.cpp
#	src/company_gui.cpp
#	src/console_gui.cpp
#	src/depot_gui.cpp
#	src/error_gui.cpp
#	src/gfx.cpp
#	src/graph_gui.cpp
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/lang/korean.txt
#	src/lang/polish.txt
#	src/misc_gui.cpp
#	src/network/network_content_gui.h
#	src/newgrf_debug_gui.cpp
#	src/order_gui.cpp
#	src/rail_gui.cpp
#	src/road_gui.cpp
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/station_gui.cpp
#	src/subsidy_gui.cpp
#	src/table/settings/gui_settings.ini
#	src/timetable_gui.cpp
#	src/town_gui.cpp
#	src/train_cmd.cpp
#	src/vehicle_gui.cpp
#	src/viewport.cpp
#	src/water_cmd.cpp
#	src/widgets/dropdown.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2022-12-04 20:25:38 +00:00
172 changed files with 3061 additions and 2809 deletions

View File

@@ -1740,7 +1740,7 @@ static Point GetAutoPlacePosition(int width, int height)
*/
int left = rtl ? _screen.width - width : 0, top = toolbar_y;
int offset_x = rtl ? -(int)NWidgetLeaf::closebox_dimension.width : (int)NWidgetLeaf::closebox_dimension.width;
int offset_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
int offset_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical());
restart:
for (const Window *w : Window::IterateFromBack()) {
@@ -1806,7 +1806,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
* - Y position: closebox of parent + closebox of child + statusbar
* - X position: closebox on left/right, resizebox on right/left (depending on ltr/rtl)
*/
int indent_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM);
int indent_y = std::max<int>(NWidgetLeaf::closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical());
if (w->top + 3 * indent_y < _screen.height) {
pt.y = w->top + indent_y;
int indent_close = NWidgetLeaf::closebox_dimension.width;
@@ -2106,28 +2106,30 @@ static void PreventHiding(int *nx, int *ny, const Rect &rect, const Window *v, i
{
if (v == nullptr) return;
const int min_visible = ScaleGUITrad(MIN_VISIBLE_TITLE_BAR);
int v_bottom = v->top + v->height;
int v_right = v->left + v->width;
int safe_y = (dir == PHD_UP) ? (v->top - MIN_VISIBLE_TITLE_BAR - rect.top) : (v_bottom + MIN_VISIBLE_TITLE_BAR - rect.bottom); // Compute safe vertical position.
int safe_y = (dir == PHD_UP) ? (v->top - min_visible - rect.top) : (v_bottom + min_visible - rect.bottom); // Compute safe vertical position.
if (*ny + rect.top <= v->top - MIN_VISIBLE_TITLE_BAR) return; // Above v is enough space
if (*ny + rect.bottom >= v_bottom + MIN_VISIBLE_TITLE_BAR) return; // Below v is enough space
if (*ny + rect.top <= v->top - min_visible) return; // Above v is enough space
if (*ny + rect.bottom >= v_bottom + min_visible) return; // Below v is enough space
/* Vertically, the rectangle is hidden behind v. */
if (*nx + rect.left + MIN_VISIBLE_TITLE_BAR < v->left) { // At left of v.
if (v->left < MIN_VISIBLE_TITLE_BAR) *ny = safe_y; // But enough room, force it to a safe position.
if (*nx + rect.left + min_visible < v->left) { // At left of v.
if (v->left < min_visible) *ny = safe_y; // But enough room, force it to a safe position.
return;
}
if (*nx + rect.right - MIN_VISIBLE_TITLE_BAR > v_right) { // At right of v.
if (v_right > _screen.width - MIN_VISIBLE_TITLE_BAR) *ny = safe_y; // Not enough room, force it to a safe position.
if (*nx + rect.right - min_visible > v_right) { // At right of v.
if (v_right > _screen.width - min_visible) *ny = safe_y; // Not enough room, force it to a safe position.
return;
}
/* Horizontally also hidden, force movement to a safe area. */
if (px + rect.left < v->left && v->left >= MIN_VISIBLE_TITLE_BAR) { // Coming from the left, and enough room there.
*nx = v->left - MIN_VISIBLE_TITLE_BAR - rect.left;
} else if (px + rect.right > v_right && v_right <= _screen.width - MIN_VISIBLE_TITLE_BAR) { // Coming from the right, and enough room there.
*nx = v_right + MIN_VISIBLE_TITLE_BAR - rect.right;
if (px + rect.left < v->left && v->left >= min_visible) { // Coming from the left, and enough room there.
*nx = v->left - min_visible - rect.left;
} else if (px + rect.right > v_right && v_right <= _screen.width - min_visible) { // Coming from the right, and enough room there.
*nx = v_right + min_visible - rect.right;
} else {
*ny = safe_y;
}
@@ -2148,9 +2150,11 @@ static void EnsureVisibleCaption(Window *w, int nx, int ny)
if (caption != nullptr) {
caption_rect = caption->GetCurrentRect();
const int min_visible = ScaleGUITrad(MIN_VISIBLE_TITLE_BAR);
/* Make sure the window doesn't leave the screen */
nx = Clamp(nx, MIN_VISIBLE_TITLE_BAR - caption_rect.right, _screen.width - MIN_VISIBLE_TITLE_BAR - caption_rect.left);
ny = Clamp(ny, 0, _screen.height - MIN_VISIBLE_TITLE_BAR);
nx = Clamp(nx, min_visible - caption_rect.right, _screen.width - min_visible - caption_rect.left);
ny = Clamp(ny, 0, _screen.height - min_visible);
/* Make sure the title bar isn't hidden behind the main tool bar or the status bar. */
PreventHiding(&nx, &ny, caption_rect, FindWindowById(WC_MAIN_TOOLBAR, 0), w->left, PHD_DOWN);