Change: Use scaled WidgetDimensions.
This commit is contained in:
@@ -88,7 +88,7 @@ uint TextfileWindow::ReflowContent()
|
||||
line.bottom = height;
|
||||
}
|
||||
} else {
|
||||
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
|
||||
int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WidgetDimensions::scaled.frametext.Horizontal();
|
||||
for (auto &line : this->lines) {
|
||||
line.top = height;
|
||||
height += GetStringHeight(line.text, max_width, FS_MONO) / FONT_HEIGHT_MONO;
|
||||
@@ -111,7 +111,7 @@ uint TextfileWindow::GetContentHeight()
|
||||
case WID_TF_BACKGROUND:
|
||||
resize->height = FONT_HEIGHT_MONO;
|
||||
|
||||
size->height = 4 * resize->height + TOP_SPACING + BOTTOM_SPACING; // At least 4 lines are visible.
|
||||
size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible.
|
||||
size->width = std::max(200u, size->width); // At least 200 pixels wide.
|
||||
break;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
|
||||
} else {
|
||||
uint height = force_reflow ? this->ReflowContent() : this->GetContentHeight();
|
||||
this->vscroll->SetCount(std::min<uint>(UINT16_MAX, height));
|
||||
this->hscroll->SetCount(this->max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
|
||||
this->hscroll->SetCount(this->max_length + WidgetDimensions::scaled.frametext.Horizontal());
|
||||
}
|
||||
|
||||
this->SetWidgetDisabledState(WID_TF_HSCROLLBAR, IsWidgetLowered(WID_TF_WRAPTEXT));
|
||||
@@ -148,7 +148,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
|
||||
{
|
||||
if (widget != WID_TF_BACKGROUND) return;
|
||||
|
||||
Rect fr = r.Shrink(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM);
|
||||
Rect fr = r.Shrink(WidgetDimensions::scaled.frametext);
|
||||
|
||||
DrawPixelInfo new_dpi;
|
||||
if (!FillDrawPixelInfo(&new_dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
|
||||
@@ -178,7 +178,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
|
||||
|
||||
/* virtual */ void TextfileWindow::OnResize()
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND, TOP_SPACING + BOTTOM_SPACING);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND, WidgetDimensions::scaled.frametext.Vertical());
|
||||
this->hscroll->SetCapacityFromWidget(this, WID_TF_BACKGROUND);
|
||||
|
||||
this->SetupScrollbars(false);
|
||||
|
Reference in New Issue
Block a user