Change: Use scaled WidgetDimensions.
This commit is contained in:
@@ -194,7 +194,7 @@ struct SignListWindow : Window, SignList {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SIL_LIST: {
|
||||
Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2;
|
||||
/* No signs? */
|
||||
if (this->vscroll->GetCount() == 0) {
|
||||
@@ -209,7 +209,8 @@ struct SignListWindow : Window, SignList {
|
||||
tr = tr.Indent(this->text_offset, rtl);
|
||||
|
||||
/* At least one sign available. */
|
||||
for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
|
||||
for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++)
|
||||
{
|
||||
const Sign *si = this->signs[i];
|
||||
|
||||
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);
|
||||
@@ -232,7 +233,7 @@ struct SignListWindow : Window, SignList {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SIL_LIST: {
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WD_FRAMERECT_TOP);
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
if (id_v == INT_MAX) return;
|
||||
|
||||
const Sign *si = this->signs[id_v];
|
||||
@@ -257,7 +258,7 @@ struct SignListWindow : Window, SignList {
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical());
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
@@ -265,9 +266,9 @@ struct SignListWindow : Window, SignList {
|
||||
switch (widget) {
|
||||
case WID_SIL_LIST: {
|
||||
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
|
||||
this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
|
||||
resize->height = std::max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height + 2);
|
||||
Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
|
||||
Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height};
|
||||
*size = maxdim(*size, d);
|
||||
break;
|
||||
}
|
||||
@@ -367,7 +368,7 @@ static const NWidgetPart _nested_sign_list_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 0),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WidgetDimensions::unscaled.frametext.Horizontal() + 16 + 255, 0),
|
||||
SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
|
||||
|
Reference in New Issue
Block a user