From 41c1f447e567e0cb24dede007464e86e526afac2 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sat, 15 Aug 2020 22:47:58 +0200 Subject: [PATCH] Refactor define for shared widgets to use MakeWidget This commis also fixes a few pixel-perfect alignment issues. --- src/openrct2-ui/windows/TileInspector.cpp | 47 +++++++++++------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 69519de644..eca5cac758 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -180,11 +180,8 @@ constexpr int32_t MIN_WH = 130; constexpr int32_t MAX_WH = 800; // Button space for top buttons -constexpr int32_t BW = WW - 5; // Button's right side -constexpr int32_t BX = BW - 23; // Button's left side +constexpr int32_t BX = WW - 27; // Button's left side constexpr int32_t BY = 17; // Button's Top -constexpr int32_t BH = BY + 23; // Button's Bottom -constexpr int32_t BS = 24; // Column offsets for the table headers constexpr int32_t COL_X_TYPE = 3; // Type @@ -219,26 +216,28 @@ constexpr int32_t BUTTONH = 17; #define MAIN_TILE_INSPECTOR_WIDGETS \ WINDOW_SHIM(WINDOW_TITLE, WW, WH), \ - { WindowWidgetType::Scroll, 1, 3, WW - 4, 57, WH - PADDING_BOTTOM, 2, STR_NONE }, /* Element list */ \ - SPINNER_WIDGETS (1, 20, 70, 23, 34, STR_NONE, STR_NONE), /* Spinner X (3 widgets) */ \ - SPINNER_WIDGETS (1, 90, 140, 23, 34, STR_NONE, STR_NONE), /* Spinner Y (3 widgets) */ \ - /* Buttons */ \ - { WindowWidgetType::FlatBtn, 1, BX, BW, BY, BH, SPR_MAP, STR_INSERT_CORRUPT_TIP }, /* Insert corrupt button */ \ - { WindowWidgetType::FlatBtn, 1, BX - BS * 1, BW - BS * 1, BY, BH, SPR_DEMOLISH, STR_REMOVE_SELECTED_ELEMENT_TIP }, /* Remove button */ \ - { WindowWidgetType::Button, 1, BX - BS * 2, BW - BS * 2, BY, BY + 11, STR_UP, STR_MOVE_SELECTED_ELEMENT_UP_TIP }, /* Move up */ \ - { WindowWidgetType::Button, 1, BX - BS * 2, BW - BS * 2, BH - 11, BH, STR_DOWN, STR_MOVE_SELECTED_ELEMENT_DOWN_TIP }, /* Move down */ \ - { WindowWidgetType::FlatBtn, 1, BX - BS * 3, BW - BS * 3, BY, BH, SPR_ROTATE_ARROW, STR_ROTATE_SELECTED_ELEMENT_TIP }, /* Rotate button */ \ - { WindowWidgetType::FlatBtn, 1, BX - BS * 4, BW - BS * 4, BY, BH, SPR_G2_SORT, STR_TILE_INSPECTOR_SORT_TIP }, /* Sort button */ \ - { WindowWidgetType::FlatBtn, 1, BX - BS * 5, BW - BS * 5, BY, BH, SPR_G2_PASTE, STR_TILE_INSPECTOR_PASTE_TIP }, /* Paste button */ \ - { WindowWidgetType::FlatBtn, 1, BX - BS * 6, BW - BS * 6, BY, BH, SPR_G2_COPY, STR_TILE_INSPECTOR_COPY_TIP }, /* Copy button */ \ - /* Column headers */ \ - { WindowWidgetType::TableHeader, 1, COL_X_TYPE, COL_X_BH - 1, 42, 42 + 13, STR_NONE, STR_NONE }, /* Type */ \ - { WindowWidgetType::TableHeader, 1, COL_X_BH, COL_X_CH - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_BASE_HEIGHT }, /* Base height */ \ - { WindowWidgetType::TableHeader, 1, COL_X_CH, COL_X_GF - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_CLEARANCE_HEIGHT }, /* Clearance height */ \ - { WindowWidgetType::TableHeader, 1, COL_X_GF, COL_X_LF - 1, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_FLAG_GHOST }, /* Ghost flag */ \ - { WindowWidgetType::TableHeader, 1, COL_X_LF, WW - 3, 42, 42 + 13, STR_NONE, STR_TILE_INSPECTOR_FLAG_LAST }, /* Last of tile flag */ \ - { WindowWidgetType::Groupbox, 1, 6, WW - 6, -1, -1, STR_NONE, STR_NONE }, /* Details group box */ \ - { WindowWidgetType::Groupbox, 1, 6, WW - 6, -1, -1, STR_TILE_INSPECTOR_GROUPBOX_PROPERTIES, STR_NONE } /* Properties group box */ + { WindowWidgetType::Scroll, 1, 3, WW - 4, 57, WH - PADDING_BOTTOM, 2, STR_NONE }, /* Element list */ \ + /* X and Y spinners */ \ + SPINNER_WIDGETS (1, 20, 70, 23, 34, STR_NONE, STR_NONE), /* Spinner X (3 widgets) */ \ + SPINNER_WIDGETS (1, 90, 140, 23, 34, STR_NONE, STR_NONE), /* Spinner Y (3 widgets) */ \ + /* Top buttons */ \ + MakeWidget({BX, BY}, {24, 24}, WindowWidgetType::FlatBtn , WindowColour::Secondary, SPR_MAP, STR_INSERT_CORRUPT_TIP), /* Insert corrupt button */ \ + MakeWidget({BX - 24, BY}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_DEMOLISH, STR_REMOVE_SELECTED_ELEMENT_TIP ), /* Remove button */ \ + MakeWidget({BX - 48, BY}, {24, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_UP, STR_MOVE_SELECTED_ELEMENT_UP_TIP), /* Move up */ \ + MakeWidget({BX - 48, BY + 12}, {24, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_DOWN, STR_MOVE_SELECTED_ELEMENT_DOWN_TIP), /* Move down */ \ + MakeWidget({BX - 72, BY}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_ROTATE_ARROW, STR_ROTATE_SELECTED_ELEMENT_TIP), /* Rotate button */ \ + MakeWidget({BX - 96, BY}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_SORT, STR_TILE_INSPECTOR_SORT_TIP), /* Sort button */ \ + MakeWidget({BX - 120, BY}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_PASTE, STR_TILE_INSPECTOR_PASTE_TIP), /* Paste button */ \ + MakeWidget({BX - 144, BY}, {24, 24}, WindowWidgetType::FlatBtn, WindowColour::Secondary, SPR_G2_COPY, STR_TILE_INSPECTOR_COPY_TIP), /* Copy button */ \ + /* Column headers */ \ + MakeWidget({COL_X_TYPE, 42}, {312, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_NONE, STR_NONE), /* Type */ \ + MakeWidget({COL_X_BH, 42}, {20, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_NONE, STR_TILE_INSPECTOR_BASE_HEIGHT), /* Base height */ \ + MakeWidget({COL_X_CH, 42}, {20, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_NONE, STR_TILE_INSPECTOR_CLEARANCE_HEIGHT), /* Clearance height */ \ + MakeWidget({COL_X_GF, 42}, {12, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_NONE, STR_TILE_INSPECTOR_FLAG_GHOST), /* Ghost flag */ \ + MakeWidget({COL_X_LF, 42}, {30, 14}, WindowWidgetType::TableHeader, WindowColour::Secondary, STR_NONE, STR_TILE_INSPECTOR_FLAG_LAST), /* Last of tile flag */ \ + /* Group boxes */ \ + MakeWidget({6, 0}, {WW - 12, 0}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_NONE, STR_NONE ), /* Details group box */ \ + MakeWidget({6, 0}, {WW - 12, 0}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_TILE_INSPECTOR_GROUPBOX_PROPERTIES, STR_NONE ) /* Properties group box */ static rct_widget DefaultWidgets[] = { MAIN_TILE_INSPECTOR_WIDGETS,