Part 3 of the changes for #600 (UI fonts)

This commit is contained in:
thrust26 2020-04-30 09:39:42 +02:00
parent 17354af0f3
commit 78741b8906
11 changed files with 38 additions and 17 deletions

View File

@ -30,7 +30,6 @@ FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y)
{
const GUI::Font& ifont = instance().frameBuffer().infoFont();
const int lineHeight = font.getLineHeight();
int xpos = x, ypos = y;
@ -38,14 +37,14 @@ void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y)
ypos += lineHeight + 6;
new StaticTextWidget(boss, ifont, xpos, ypos, "Pages/Ranges used:");
new StaticTextWidget(boss, font, xpos, ypos, "Pages/Ranges used:");
ypos += lineHeight + 2;
xpos += 8;
for(uInt32 page = 0; page < MAX_PAGES; ++page)
{
myPage[page] = new StaticTextWidget(boss, ifont, xpos, ypos,
myPage[page] = new StaticTextWidget(boss, font, xpos, ypos,
page ? " " : "none ");
ypos += lineHeight;
}

View File

@ -214,7 +214,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
// 2600/7800 mode
lwidth = lfont.getStringWidth("Console") + 29;
pwidth = lfont.getStringWidth("Atari 2600") + 4;
pwidth = lfont.getStringWidth("Atari 2600") + 6;
new StaticTextWidget(boss, lfont, 10, ypos+1, "Console");
myConsole = new EditTextWidget(boss, lfont, 10 + lwidth, ypos - 1, pwidth, lineHeight);
myConsole->setEditable(false, true);

View File

@ -616,7 +616,7 @@ void DeveloperDialog::addDebuggerTab(const GUI::Font& font)
// Add message concerning usage
const GUI::Font& infofont = instance().frameBuffer().infoFont();
ypos = myTab->getHeight() - fontHeight - infofont.getFontHeight() - VGAP - VBORDER;
new StaticTextWidget(myTab, infofont, HBORDER, ypos, "(*) Changes require a ROM reload");
new StaticTextWidget(myTab, infofont, HBORDER, ypos, "(*) Change requires a ROM reload");
#if defined(DEBUGGER_SUPPORT) && defined(WINDOWED_SUPPORT)
// Debugger is only realistically available in windowed modes 800x600 or greater

View File

@ -29,6 +29,15 @@ EditTextWidget::EditTextWidget(GuiObject* boss, const GUI::Font& font,
_flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS;
EditableWidget::startEditMode(); // We're always in edit mode
if(_font.getFontHeight() < 24)
{
_textOfs = 3;
}
else
{
_textOfs = 5;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -92,7 +101,7 @@ void EditTextWidget::drawWidget(bool hilite)
// Draw the text
adjustOffset();
s.drawString(_font, editString(), _x + 2, _y + 2, getEditRect().w(), getEditRect().h(),
s.drawString(_font, editString(), _x + _textOfs, _y + 2, getEditRect().w(), getEditRect().h(),
_changed && onTop && isEnabled()
? kDbgChangedTextColor
: onTop && isEnabled() ? _textcolor : kColor,
@ -105,7 +114,7 @@ void EditTextWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Common::Rect EditTextWidget::getEditRect() const
{
return Common::Rect(2, 1, _w - 2, _h);
return Common::Rect(_textOfs, 1, _w - _textOfs, _h);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -49,6 +49,7 @@ class EditTextWidget : public EditableWidget
protected:
string _backupString;
bool _changed{false};
int _textOfs{0};
private:
// Following constructors and assignment operators not supported

View File

@ -156,7 +156,7 @@ GameInfoDialog::GameInfoDialog(
// Add message concerning usage
ypos = myTab->getHeight() - fontHeight - ifont.getFontHeight() - VGAP - VBORDER;
new StaticTextWidget(myTab, ifont, HBORDER, ypos,
"(*) Changes require a ROM reload");
"(*) Change requires a ROM reload");
// Add items for tab 0
addToFocusList(wid, myTab, tabID);

View File

@ -29,6 +29,16 @@ StringListWidget::StringListWidget(GuiObject* boss, const GUI::Font& font,
_hilite(hilite)
{
_bgcolorlo = kDlgColor;
if(_font.getFontHeight() < 24)
{
_textOfs = 3;
}
else
{
_textOfs = 5;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -106,5 +116,5 @@ void StringListWidget::drawWidget(bool hilite)
Common::Rect StringListWidget::getEditRect() const
{
const int offset = std::max(0, (_selectedItem - _currentPos) * _fontHeight);
return Common::Rect(2, 1 + offset, _w - 2, _fontHeight + offset);
return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _fontHeight + offset);
}

View File

@ -39,6 +39,7 @@ class StringListWidget : public ListWidget
protected:
bool _hilite{false};
int _textOfs{0};
private:
// Following constructors and assignment operators not supported

View File

@ -196,7 +196,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
// Set real dimensions
_w = width; // Parent determines our width (based on window size)
_h = V_BORDER * 2 + rowHeight + buttonHeight + 2;
_h = V_BORDER * 2 + rowHeight + std::max(buttonHeight + 2, rowHeight);
this->clearFlags(Widget::FLAG_CLEARBG); // does only work combined with blending (0..100)!
this->clearFlags(Widget::FLAG_BORDER);
@ -221,9 +221,10 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
ypos += rowHeight;
// Add time info
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos + 3, "00:00.00", TextAlign::Left, kBGColor);
int ypos_s = ypos + (buttonHeight - font.getFontHeight() + 1) / 2; // align to button vertical center
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos_s, "00:00.00", TextAlign::Left, kBGColor);
myCurrentTimeWidget->setTextColor(kColorInfo);
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("00:00.00"), ypos + 3,
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("00:00.00"), ypos_s,
"00:00.00", TextAlign::Right, kBGColor);
myLastTimeWidget->setTextColor(kColorInfo);
xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4;

View File

@ -182,10 +182,10 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
// Add message concerning usage
ypos = myTab->getHeight() - fontHeight - ifont.getFontHeight() - VGAP - VBORDER;
lwidth = ifont.getStringWidth("(*) Changes require application restart");
lwidth = ifont.getStringWidth("(*) Change requires an application restart");
new StaticTextWidget(myTab, ifont, xpos, ypos,
std::min(lwidth, _w - HBORDER * 2), ifont.getFontHeight(),
"(*) Changes require application restart");
"(*) Change requires an application restart");
// Add items for tab 0
addToFocusList(wid, myTab, tabID);
@ -286,10 +286,10 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
// Add message concerning usage
xpos = HBORDER;
ypos = myTab->getHeight() - fontHeight - ifont.getFontHeight() - VGAP - VBORDER;
lwidth = ifont.getStringWidth("(*) Changes require application restart");
lwidth = ifont.getStringWidth("(*) Changes require an application restart");
new StaticTextWidget(myTab, ifont, xpos, ypos,
std::min(lwidth, _w - HBORDER * 2), ifont.getFontHeight(),
"(*) Changes require application restart");
"(*) Changes require an application restart");
// Add items for tab 1
addToFocusList(wid, myTab, tabID);

View File

@ -831,7 +831,7 @@ void SliderWidget::drawWidget(bool hilite)
int p = valueToPos(_value),
h = _h - _font.getFontHeight() / 2 - 1,
x = _x + _labelWidth,
y = _y + (_h - h) / 2 + 1;
y = _y + 2 + _font.desc().ascent - (_font.getFontHeight() + 1) / 2 - 1; // align to bottom of font
// Fill the box
s.fillRect(x, y, _w - _labelWidth - _valueLabelGap - _valueLabelWidth, h,