Window: Add accessors for cached NWidgetLeaf dimensions
This commit is contained in:
@@ -1791,8 +1791,9 @@ static Point GetAutoPlacePosition(int width, int height)
|
||||
* of the closebox
|
||||
*/
|
||||
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 + WidgetDimensions::scaled.captiontext.Vertical());
|
||||
const Dimension &closebox_dimension = NWidgetLeaf::GetCloseBoxDimension();
|
||||
int offset_x = rtl ? -(int)closebox_dimension.width : (int)closebox_dimension.width;
|
||||
int offset_y = std::max<int>(closebox_dimension.height, FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.captiontext.Vertical());
|
||||
|
||||
restart:
|
||||
for (const Window *w : Window::IterateFromBack()) {
|
||||
@@ -1858,11 +1859,12 @@ 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 + WidgetDimensions::scaled.captiontext.Vertical());
|
||||
const Dimension &closebox_dimension = NWidgetLeaf::GetCloseBoxDimension();
|
||||
int indent_y = std::max<int>(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;
|
||||
int indent_resize = NWidgetLeaf::resizebox_dimension.width;
|
||||
int indent_close = closebox_dimension.width;
|
||||
int indent_resize = NWidgetLeaf::GetResizeBoxDimension().width;
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
pt.x = std::max(w->left + w->width - default_width - indent_close, 0);
|
||||
if (pt.x + default_width >= indent_close && pt.x + indent_resize <= _screen.width) return pt;
|
||||
|
Reference in New Issue
Block a user