(svn r18321) -Fix [FS#3331]: make the toolbars also calculate their top location based on the main toolbar's height instead of hardcoding that

This commit is contained in:
rubidium 2009-11-28 14:36:43 +00:00
parent 6a367fda8a
commit b58b058e2b
7 changed files with 14 additions and 22 deletions

View File

@ -147,7 +147,7 @@ static const NWidgetPart _nested_air_toolbar_widgets[] = {
};
static const WindowDesc _air_toolbar_desc(
WDP_ALIGN_TBR, 22, 64, 36,
WDP_ALIGN_TOOLBAR, WDP_ALIGN_TOOLBAR, 64, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets)

View File

@ -279,7 +279,7 @@ static const NWidgetPart _nested_build_docks_toolbar_widgets[] = {
};
static const WindowDesc _build_docks_toolbar_desc(
WDP_ALIGN_TBR, 22, 160, 36,
WDP_ALIGN_TOOLBAR, WDP_ALIGN_TOOLBAR, 160, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets)

View File

@ -856,7 +856,7 @@ static const NWidgetPart _nested_build_rail_widgets[] = {
};
static const WindowDesc _build_rail_desc(
WDP_ALIGN_TBR, 22, 350, 36,
WDP_ALIGN_TOOLBAR, WDP_ALIGN_TOOLBAR, 350, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_rail_widgets, lengthof(_nested_build_rail_widgets)

View File

@ -661,7 +661,7 @@ static const NWidgetPart _nested_build_road_widgets[] = {
};
static const WindowDesc _build_road_desc(
WDP_ALIGN_TBR, 22, 263, 36,
WDP_ALIGN_TOOLBAR, WDP_ALIGN_TOOLBAR, 263, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_road_widgets, lengthof(_nested_build_road_widgets)
@ -700,7 +700,7 @@ static const NWidgetPart _nested_build_tramway_widgets[] = {
};
static const WindowDesc _build_tramway_desc(
WDP_ALIGN_TBR, 22, 241, 36,
WDP_ALIGN_TOOLBAR, WDP_ALIGN_TOOLBAR, 241, 36,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets)

View File

@ -83,7 +83,7 @@ static const NWidgetPart _nested_dropdown_menu_widgets[] = {
};
const WindowDesc _dropdown_desc(
0, 0, 0, 0, // x/y position not used.
WDP_MANUAL, WDP_MANUAL, 0, 0, // x/y position not used.
WC_DROPDOWN_MENU, WC_NONE,
0,
_nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets)

View File

@ -1101,14 +1101,8 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
pt.y = w->top + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? w->height : 10);
} else {
switch (desc->left) {
case WDP_ALIGN_TBR: // Align the right side with the top toolbar
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
pt.x = (w->left + w->width) - default_width;
break;
case WDP_ALIGN_TBL: // Align the left side with the top toolbar
pt.x = FindWindowById(WC_MAIN_TOOLBAR, 0)->left;
break;
case WDP_ALIGN_TOOLBAR: // Align to the toolbar
return GetToolbarAlignedWindowPosition(default_width);
case WDP_AUTO: // Find a good automatic position for the window
return GetAutoPlacePosition(default_width, default_height);
@ -1128,11 +1122,10 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int
break;
/* WDP_AUTO sets the position at once and is controlled by desc->left.
* Both left and top must be set to WDP_AUTO */
* Both left and top must be set to WDP_AUTO. Same for toolbar alignment. */
case WDP_AUTO:
case WDP_ALIGN_TOOLBAR:
NOT_REACHED();
assert(desc->left == WDP_AUTO && desc->top != WDP_AUTO);
/* fallthrough */
default:
pt.y = desc->top;

View File

@ -159,11 +159,10 @@ enum WindowDefaultFlag {
* Special values for 'left' and 'top' to cause a specific placement
*/
enum WindowDefaultPosition {
WDP_MANUAL, ///< Manually align the window (so no automatic location finding)
WDP_AUTO = -1, ///< Find a place automatically
WDP_CENTER = -2, ///< Center the window (left/right or top/bottom)
WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar
WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar
WDP_MANUAL, ///< Manually align the window (so no automatic location finding)
WDP_AUTO = -1, ///< Find a place automatically
WDP_CENTER = -2, ///< Center the window (left/right or top/bottom)
WDP_ALIGN_TOOLBAR = -3, ///< Align to the main toolbar
};
Point GetToolbarAlignedWindowPosition(int window_width);