Change: Use scaled WidgetDimensions.
This commit is contained in:
@@ -76,7 +76,7 @@ struct GoalListWindow : public Window {
|
||||
break;
|
||||
|
||||
case WID_GOAL_LIST: {
|
||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
|
||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
for (const Goal *s : Goal::Iterate()) {
|
||||
if (s->company == this->window_number) {
|
||||
if (y == 0) {
|
||||
@@ -174,11 +174,12 @@ struct GoalListWindow : public Window {
|
||||
if (widget != WID_GOAL_LIST) return;
|
||||
Dimension d = GetStringBoundingBox(STR_GOALS_NONE);
|
||||
|
||||
resize->width = 1;
|
||||
resize->height = d.height;
|
||||
|
||||
d.height *= 5;
|
||||
d.width += padding.width + WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT;
|
||||
d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
d.width += WidgetDimensions::scaled.framerect.Horizontal();
|
||||
d.height += WidgetDimensions::scaled.framerect.Vertical();
|
||||
*size = maxdim(*size, d);
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ struct GoalListWindow : public Window {
|
||||
void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
|
||||
{
|
||||
/* Get column draw area. */
|
||||
Rect r = wid->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
|
||||
Rect r = wid->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
|
||||
int pos = -this->vscroll->GetPosition();
|
||||
@@ -206,7 +207,7 @@ struct GoalListWindow : public Window {
|
||||
case GC_GOAL: {
|
||||
/* Display the goal. */
|
||||
SetDParamStr(0, s->text);
|
||||
uint width_reduction = progress_col_width > 0 ? progress_col_width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT : 0;
|
||||
uint width_reduction = progress_col_width > 0 ? progress_col_width + WidgetDimensions::scaled.framerect.Horizontal() : 0;
|
||||
DrawString(r.Indent(width_reduction, !rtl), STR_GOALS_TEXT);
|
||||
break;
|
||||
}
|
||||
@@ -261,7 +262,7 @@ struct GoalListWindow : public Window {
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST, WidgetDimensions::scaled.framerect.Vertical());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,8 +286,8 @@ static const NWidgetPart _nested_goals_list_widgets[] = {
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_GOAL_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GOAL_SELECT_BUTTONS),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_GLOBAL_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_GLOBAL_BUTTON, STR_GOALS_GLOBAL_BUTTON_HELPTEXT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_COMPANY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_COMPANY_BUTTON, STR_GOALS_COMPANY_BUTTON_HELPTEXT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_GLOBAL_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical()), SetDataTip(STR_GOALS_GLOBAL_BUTTON, STR_GOALS_GLOBAL_BUTTON_HELPTEXT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_COMPANY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical()), SetDataTip(STR_GOALS_COMPANY_BUTTON, STR_GOALS_COMPANY_BUTTON_HELPTEXT),
|
||||
EndContainer(),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
||||
@@ -399,7 +400,7 @@ struct GoalQuestionWindow : public Window {
|
||||
if (widget != WID_GQ_QUESTION) return;
|
||||
|
||||
SetDParamStr(0, this->question);
|
||||
size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE;
|
||||
size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
|
Reference in New Issue
Block a user