mirror of https://github.com/stella-emu/stella.git
Part 2 of the changes for #600 (UI fonts)
This commit is contained in:
parent
15ead58aa7
commit
17354af0f3
|
@ -307,7 +307,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
|||
}
|
||||
|
||||
if(!myMsg.surface)
|
||||
myMsg.surface = allocateSurface(FBMinimum::Width, font().getFontHeight()+10);
|
||||
myMsg.surface = allocateSurface(FBMinimum::Width, font().getFontHeight() * 1.5);
|
||||
#endif
|
||||
|
||||
// Print initial usage message, but only print it later if the status has changed
|
||||
|
@ -493,14 +493,20 @@ void FrameBuffer::showMessage(const string& message, MessagePosition position,
|
|||
if(myMsg.surface == nullptr || !(force || myOSystem.settings().getBool("uimessages")))
|
||||
return;
|
||||
|
||||
const int fontWidth = font().getMaxCharWidth(),
|
||||
fontHeight = font().getFontHeight();
|
||||
const int VBORDER = fontHeight / 4;
|
||||
const int HBORDER = fontWidth * 1.25 / 2.0;
|
||||
|
||||
// Precompute the message coordinates
|
||||
myMsg.text = message;
|
||||
myMsg.counter = uInt32(myOSystem.frameRate()) << 1; // Show message for 2 seconds
|
||||
if(myMsg.counter == 0) myMsg.counter = 60;
|
||||
myMsg.color = kBtnTextColor;
|
||||
|
||||
myMsg.w = font().getStringWidth(myMsg.text) + 10;
|
||||
myMsg.h = font().getFontHeight() + 8;
|
||||
myMsg.w = font().getStringWidth(myMsg.text) + HBORDER * 2;
|
||||
myMsg.h = fontHeight + VBORDER * 2;
|
||||
|
||||
myMsg.surface->setSrcSize(myMsg.w, myMsg.h);
|
||||
myMsg.surface->setDstSize(myMsg.w * hidpiScaleFactor(), myMsg.h * hidpiScaleFactor());
|
||||
myMsg.position = position;
|
||||
|
@ -619,6 +625,10 @@ inline bool FrameBuffer::drawMessage()
|
|||
|
||||
// Draw the bounded box and text
|
||||
const Common::Rect& dst = myMsg.surface->dstRect();
|
||||
const int fontWidth = font().getMaxCharWidth(),
|
||||
fontHeight = font().getFontHeight();
|
||||
const int VBORDER = fontHeight / 4;
|
||||
const int HBORDER = fontWidth * 1.25 / 2.0;
|
||||
|
||||
switch(myMsg.position)
|
||||
{
|
||||
|
@ -669,10 +679,10 @@ inline bool FrameBuffer::drawMessage()
|
|||
}
|
||||
|
||||
myMsg.surface->setDstPos(myMsg.x + myImageRect.x(), myMsg.y + myImageRect.y());
|
||||
myMsg.surface->fillRect(1, 1, myMsg.w-2, myMsg.h-2, kBtnColor);
|
||||
myMsg.surface->fillRect(1, 1, myMsg.w - 2, myMsg.h - 2, kBtnColor);
|
||||
myMsg.surface->frameRect(0, 0, myMsg.w, myMsg.h, kColor);
|
||||
myMsg.surface->drawString(font(), myMsg.text, 5, 4,
|
||||
myMsg.w, myMsg.color, TextAlign::Left);
|
||||
myMsg.surface->drawString(font(), myMsg.text, HBORDER, VBORDER,
|
||||
myMsg.w, myMsg.color);
|
||||
myMsg.surface->render();
|
||||
myMsg.counter--;
|
||||
#endif
|
||||
|
|
|
@ -42,13 +42,19 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
_h = max_h;
|
||||
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4,
|
||||
selectHeight = lineHeight + 12;
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonHeight = font.getLineHeight() * 1.25,
|
||||
buttonWidth = font.getStringWidth("Base Dir") + fontWidth * 2.5;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int VGAP = fontHeight / 4;
|
||||
const int BUTTON_GAP = fontWidth;
|
||||
const int selectHeight = lineHeight + VGAP * 3;
|
||||
int xpos, ypos;
|
||||
ButtonWidget* b;
|
||||
|
||||
xpos = 10; ypos = 4 + _th;
|
||||
xpos = HBORDER; ypos = VBORDER + _th;
|
||||
|
||||
// Current path - TODO: handle long paths ?
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos + 2, "Path ");
|
||||
|
@ -56,14 +62,14 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
_w - t->getWidth() - 2 * xpos, lineHeight);
|
||||
_currentPath->setEditable(false);
|
||||
// Add file list
|
||||
ypos += lineHeight + 8;
|
||||
ypos += lineHeight + VGAP * 2;
|
||||
_fileList = new FileListWidget(this, font, xpos, ypos, _w - 2 * xpos,
|
||||
_h - selectHeight - buttonHeight - ypos - 20);
|
||||
_h - selectHeight - buttonHeight - ypos - VBORDER * 2);
|
||||
_fileList->setEditable(false);
|
||||
addFocusWidget(_fileList);
|
||||
|
||||
// Add currently selected item
|
||||
ypos += _fileList->getHeight() + 8;
|
||||
ypos += _fileList->getHeight() + VGAP * 2;
|
||||
|
||||
_type = new StaticTextWidget(this, font, xpos, ypos + 2, "Name ");
|
||||
_selected = new EditTextWidget(this, font, xpos + _type->getWidth(), ypos,
|
||||
|
@ -71,30 +77,30 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
_selected->setEditable(false);
|
||||
|
||||
// Buttons
|
||||
_goUpButton = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
|
||||
_goUpButton = new ButtonWidget(this, font, xpos, _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Go up", kGoUpCmd);
|
||||
addFocusWidget(_goUpButton);
|
||||
|
||||
_basedirButton =
|
||||
new ButtonWidget(this, font, 15 + buttonWidth, _h - buttonHeight - 10,
|
||||
new ButtonWidget(this, font, _goUpButton->getRight() + BUTTON_GAP, _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Base Dir", kBaseDirCmd);
|
||||
addFocusWidget(_basedirButton);
|
||||
|
||||
#ifndef BSPF_MACOS
|
||||
b = new ButtonWidget(this, font, _w - 2 * (buttonWidth + 7), _h - buttonHeight - 10,
|
||||
b = new ButtonWidget(this, font, _w - (2 * buttonWidth + BUTTON_GAP + HBORDER), _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Choose", kChooseCmd);
|
||||
addFocusWidget(b);
|
||||
addOKWidget(b);
|
||||
b = new ButtonWidget(this, font, _w - (buttonWidth + 10), _h - buttonHeight - 10,
|
||||
b = new ButtonWidget(this, font, _w - (buttonWidth + HBORDER), _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Cancel", GuiObject::kCloseCmd);
|
||||
addFocusWidget(b);
|
||||
addCancelWidget(b);
|
||||
#else
|
||||
b = new ButtonWidget(this, font, _w - 2 * (buttonWidth + 7), _h - buttonHeight - 10,
|
||||
b = new ButtonWidget(this, font, _w - (2 * buttonWidth + BUTTON_GAP + HBORDER), _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Cancel", GuiObject::kCloseCmd);
|
||||
addFocusWidget(b);
|
||||
addCancelWidget(b);
|
||||
b = new ButtonWidget(this, font, _w - (buttonWidth + 10), _h - buttonHeight - 10,
|
||||
b = new ButtonWidget(this, font, _w - (buttonWidth + HBORDER), _h - buttonHeight - VBORDER,
|
||||
buttonWidth, buttonHeight, "Choose", kChooseCmd);
|
||||
addFocusWidget(b);
|
||||
addOKWidget(b);
|
||||
|
|
|
@ -32,7 +32,14 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
|
|||
: Dialog(boss->instance(), boss->parent(), font, "Add...")
|
||||
{
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth();
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonHeight = font.getLineHeight() * 1.25;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int INDENT = fontWidth * 2;
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
int xpos, ypos;
|
||||
WidgetArray wid;
|
||||
|
||||
|
@ -42,10 +49,10 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
|
|||
pwidth = std::max(font.getStringWidth(s.first), pwidth);
|
||||
|
||||
// Set real dimensions
|
||||
_w = 11 * fontWidth + pwidth-4 + 10 * 2;
|
||||
_h = 10 * (lineHeight + 4) + 10 + _th;
|
||||
xpos = 10;
|
||||
ypos = 10 + _th;
|
||||
_w = 8 * fontWidth + pwidth + PopUpWidget::dropDownWidth(font) + HBORDER * 2;
|
||||
_h = 8 * (lineHeight + VGAP) + VGAP + buttonHeight + VBORDER * 2 + _th;
|
||||
xpos = HBORDER;
|
||||
ypos = VBORDER + _th;
|
||||
|
||||
// Add event popup for 8 events
|
||||
myEvents.fill(nullptr);
|
||||
|
@ -54,7 +61,7 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
|
|||
myEvents[idx] = new PopUpWidget(this, font, xpos, ypos,
|
||||
pwidth, lineHeight, combolist, label);
|
||||
wid.push_back(myEvents[idx]);
|
||||
ypos += lineHeight + 4;
|
||||
ypos += lineHeight + VGAP;
|
||||
};
|
||||
ADD_EVENT_POPUP(0, "Event 1 ");
|
||||
ADD_EVENT_POPUP(1, "Event 2 ");
|
||||
|
|
|
@ -40,9 +40,8 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
|
|||
buttonWidth = _font.getStringWidth("Time Machine On") + fontWidth * 2;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int INDENT = fontWidth * 2;
|
||||
const int VGAP = fontHeight / 4;
|
||||
const int HGAP = VGAP * 2;
|
||||
const int HGAP = fontWidth;
|
||||
const int rowHeight = buttonHeight + VGAP;
|
||||
|
||||
// Set real dimensions
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "Dialog.hxx"
|
||||
#include "DialogContainer.hxx"
|
||||
#include "ScrollBarWidget.hxx"
|
||||
#include "PopUpWidget.hxx"
|
||||
#include "ContextMenu.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -35,6 +36,7 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font,
|
|||
_maxWidth(width)
|
||||
{
|
||||
addItems(items);
|
||||
setArrows();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -49,7 +51,7 @@ void ContextMenu::addItems(const VariantList& items)
|
|||
maxwidth = std::max(maxwidth, _font.getStringWidth(e.first));
|
||||
|
||||
_x = _y = 0;
|
||||
_w = maxwidth + 23;
|
||||
_w = maxwidth + PopUpWidget::dropDownWidth(_font); // 23;
|
||||
_h = 1; // recalculate this in ::recalc()
|
||||
|
||||
_scrollUpColor = _firstEntry > 0 ? kScrollColor : kColor;
|
||||
|
@ -509,7 +511,7 @@ void ContextMenu::scrollDown(int distance)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ContextMenu::drawDialog()
|
||||
void ContextMenu::setArrows()
|
||||
{
|
||||
static constexpr std::array<uInt32, 8> up_arrow = {
|
||||
0b00011000,
|
||||
|
@ -532,6 +534,55 @@ void ContextMenu::drawDialog()
|
|||
0b00011000
|
||||
};
|
||||
|
||||
static constexpr std::array<uInt32, 12> up_arrow_large = {
|
||||
0b000001100000,
|
||||
0b000001100000,
|
||||
0b000011110000,
|
||||
0b000011110000,
|
||||
0b000111111000,
|
||||
0b000111111000,
|
||||
0b001111111100,
|
||||
0b001111111100,
|
||||
0b011111111110,
|
||||
0b011111111110,
|
||||
0b111111111111,
|
||||
0b111111111111
|
||||
};
|
||||
static constexpr std::array<uInt32, 12> down_arrow_large = {
|
||||
0b111111111111,
|
||||
0b111111111111,
|
||||
0b011111111110,
|
||||
0b011111111110,
|
||||
0b001111111100,
|
||||
0b001111111100,
|
||||
0b000111111000,
|
||||
0b000111111000,
|
||||
0b000011110000,
|
||||
0b000011110000,
|
||||
0b000001100000,
|
||||
0b000001100000
|
||||
};
|
||||
|
||||
if(_font.getFontHeight() < 24)
|
||||
{
|
||||
_textOfs = 2;
|
||||
_arrowSize = 8;
|
||||
_upImg = up_arrow.data();
|
||||
_downImg = down_arrow.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
_textOfs = 4;
|
||||
_arrowSize = 12;
|
||||
_upImg = up_arrow_large.data();
|
||||
_downImg = down_arrow_large.data();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ContextMenu::drawDialog()
|
||||
{
|
||||
|
||||
// Normally we add widgets and let Dialog::draw() take care of this
|
||||
// logic. But for some reason, this Dialog was written differently
|
||||
// by the ScummVM guys, so I'm not going to mess with it.
|
||||
|
@ -549,7 +600,7 @@ void ContextMenu::drawDialog()
|
|||
if(_showScroll)
|
||||
{
|
||||
s.hLine(x, y+_rowHeight-1, w+2, kColor);
|
||||
s.drawBitmap(up_arrow.data(), ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollUpColor, 8);
|
||||
s.drawBitmap(_upImg, ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollUpColor, _arrowSize);
|
||||
y += _rowHeight;
|
||||
offset--;
|
||||
}
|
||||
|
@ -558,7 +609,7 @@ void ContextMenu::drawDialog()
|
|||
{
|
||||
bool hilite = offset == current;
|
||||
if(hilite) s.fillRect(x, y, w, _rowHeight, kTextColorHi);
|
||||
s.drawString(_font, _entries[i].first, x + 1, y + 2, w,
|
||||
s.drawString(_font, _entries[i].first, x + _textOfs, y + 2, w,
|
||||
!hilite ? kTextColor : kTextColorInv);
|
||||
y += _rowHeight;
|
||||
}
|
||||
|
@ -567,7 +618,7 @@ void ContextMenu::drawDialog()
|
|||
if(_showScroll)
|
||||
{
|
||||
s.hLine(x, y, w+2, kColor);
|
||||
s.drawBitmap(down_arrow.data(), ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollDnColor, 8);
|
||||
s.drawBitmap(_downImg, ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollDnColor, _arrowSize);
|
||||
}
|
||||
|
||||
setDirty();
|
||||
|
|
|
@ -95,6 +95,7 @@ class ContextMenu : public Dialog, public CommandSender
|
|||
bool handleJoyHat(int stick, int hat, JoyHatDir vahdirlue, int button) override;
|
||||
void handleEvent(Event::Type e);
|
||||
|
||||
void setArrows();
|
||||
void drawDialog() override;
|
||||
|
||||
void recalc(const Common::Rect& image);
|
||||
|
@ -129,6 +130,11 @@ class ContextMenu : public Dialog, public CommandSender
|
|||
uInt32 _xorig{0}, _yorig{0};
|
||||
uInt32 _maxWidth{0};
|
||||
|
||||
int _textOfs{0};
|
||||
int _arrowSize{0};
|
||||
const uInt32* _upImg{nullptr};
|
||||
const uInt32* _downImg{nullptr};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
ContextMenu() = delete;
|
||||
|
|
|
@ -45,14 +45,14 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
const int fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 10,
|
||||
buttonWidth = font.getStringWidth("Defaults") + fontWidth * 1.25,
|
||||
buttonHeight = font.getLineHeight() * 1.25;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int VGAP = fontHeight / 4;
|
||||
const int ACTION_LINES = 2;
|
||||
int xpos = HBORDER, ypos = VBORDER;
|
||||
const int listWidth = _w - buttonWidth - HBORDER * 2 - 8;
|
||||
const int listWidth = _w - buttonWidth - HBORDER * 2 - fontWidth;
|
||||
int listHeight = _h - (2 + ACTION_LINES) * lineHeight - VBORDER + 2;
|
||||
|
||||
if(mode == EventMode::kEmulationMode)
|
||||
|
@ -72,8 +72,8 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
VarList::push_back(items, "Debug", Event::Group::Debug);
|
||||
|
||||
myFilterPopup = new PopUpWidget(boss, font, xpos, ypos,
|
||||
listWidth - font.getStringWidth("Events ") - 23, lineHeight,
|
||||
items, "Events ", 0, kFilterCmd);
|
||||
listWidth - font.getStringWidth("Events ") - PopUpWidget::dropDownWidth(font),
|
||||
lineHeight, items, "Events ", 0, kFilterCmd);
|
||||
myFilterPopup->setTarget(this);
|
||||
addFocusWidget(myFilterPopup);
|
||||
ypos += lineHeight * 1.5;
|
||||
|
@ -136,7 +136,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
fontHeight, "Action", TextAlign::Left);
|
||||
|
||||
myKeyMapping = new EditTextWidget(boss, font, xpos + t->getWidth() + fontWidth, ypos,
|
||||
_w - xpos - t->getWidth() - fontWidth - HBORDER,
|
||||
_w - xpos - t->getWidth() - fontWidth - HBORDER + 2,
|
||||
lineHeight + font.getFontHeight() * (ACTION_LINES - 1), "");
|
||||
myKeyMapping->setEditable(false, true);
|
||||
myKeyMapping->clearFlags(Widget::FLAG_RETAIN_FOCUS);
|
||||
|
|
|
@ -36,20 +36,25 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font)
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
buttonHeight = lineHeight * 1.25;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int INDENT = fontWidth * 2;
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
int xpos, ypos;
|
||||
int lwidth = font.getStringWidth("Right difficulty "),
|
||||
pwidth = font.getStringWidth("CM (SpectraVideo CompuMate)");
|
||||
const int VGAP = 4;
|
||||
WidgetArray wid;
|
||||
VariantList items;
|
||||
const GUI::Font& infofont = instance().frameBuffer().infoFont();
|
||||
|
||||
// Set real dimensions
|
||||
_w = lwidth + pwidth + fontWidth*3 + 15;
|
||||
_h = 15 * (lineHeight + 4) + buttonHeight + 16 + _th;
|
||||
_w = HBORDER * 2 + std::max(lwidth + pwidth + PopUpWidget::dropDownWidth(font),
|
||||
49 * infofont.getMaxCharWidth());
|
||||
_h = _th + 11 * (lineHeight + VGAP) + 3 * infofont.getLineHeight() + VGAP * 12 + buttonHeight + VBORDER * 2;
|
||||
|
||||
xpos = 10; ypos = 10 + _th;
|
||||
xpos = HBORDER; ypos = VBORDER + _th;
|
||||
|
||||
// Bankswitch type
|
||||
new StaticTextWidget(this, font, xpos, ypos+1, "Bankswitch type");
|
||||
|
@ -112,12 +117,12 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font)
|
|||
"(automatically released shortly after start)");
|
||||
|
||||
// Start with console joystick direction/buttons held down
|
||||
xpos = 32; ypos += infofont.getLineHeight() + VGAP * 2;
|
||||
xpos = fontWidth * 4; ypos += infofont.getLineHeight() + VGAP * 2;
|
||||
ypos = addHoldWidgets(font, xpos, ypos, wid);
|
||||
|
||||
// Add message concerning usage
|
||||
xpos = 10; ypos += 2 * fontHeight;
|
||||
ypos = _h - fontHeight * 2 - infofont.getLineHeight() - 24;
|
||||
xpos = HBORDER;
|
||||
ypos = _h - VBORDER - buttonHeight - VGAP * 3 - infofont.getLineHeight() * 2;
|
||||
new StaticTextWidget(this, infofont, xpos, ypos,
|
||||
"(*) These options are not saved, but apply to all");
|
||||
ypos += infofont.getLineHeight();
|
||||
|
@ -134,21 +139,24 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font)
|
|||
int GlobalPropsDialog::addHoldWidgets(const GUI::Font& font, int x, int y,
|
||||
WidgetArray& wid)
|
||||
{
|
||||
int xpos = x, ypos = y;
|
||||
const int VGAP = 4;
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight();
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
int xpos = x, ypos = y, xdiff = CheckboxWidget::boxSize(font) - 9;
|
||||
|
||||
// Left joystick
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos+2, "Left joy");
|
||||
xpos += t->getWidth()/2 - 7; ypos += t->getHeight() + VGAP;
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos + 2, "Left joy");
|
||||
xpos += t->getWidth()/2 - xdiff - 2; ypos += t->getHeight() + VGAP;
|
||||
myJoy[kJ0Up] = new CheckboxWidget(this, font, xpos, ypos, "", kJ0Up);
|
||||
ypos += myJoy[kJ0Up]->getHeight() * 2 + VGAP * 2;
|
||||
myJoy[kJ0Down] = new CheckboxWidget(this, font, xpos, ypos, "", kJ0Down);
|
||||
xpos -= myJoy[kJ0Up]->getWidth() + 5;
|
||||
xpos -= myJoy[kJ0Up]->getWidth() + xdiff;
|
||||
ypos -= myJoy[kJ0Up]->getHeight() + VGAP;
|
||||
myJoy[kJ0Left] = new CheckboxWidget(this, font, xpos, ypos, "", kJ0Left);
|
||||
xpos += (myJoy[kJ0Up]->getWidth() + 5) * 2;
|
||||
xpos += (myJoy[kJ0Up]->getWidth() + xdiff) * 2;
|
||||
myJoy[kJ0Right] = new CheckboxWidget(this, font, xpos, ypos, "", kJ0Right);
|
||||
xpos -= (myJoy[kJ0Up]->getWidth() + 5) * 2;
|
||||
xpos -= (myJoy[kJ0Up]->getWidth() + xdiff) * 2;
|
||||
ypos += myJoy[kJ0Down]->getHeight() * 2 + VGAP * 2;
|
||||
myJoy[kJ0Fire] = new CheckboxWidget(this, font, xpos, ypos, "Fire", kJ0Fire);
|
||||
|
||||
|
@ -157,20 +165,20 @@ int GlobalPropsDialog::addHoldWidgets(const GUI::Font& font, int x, int y,
|
|||
|
||||
// Right joystick
|
||||
t = new StaticTextWidget(this, font, xpos, ypos + 2, "Right joy");
|
||||
xpos += t->getWidth()/2 - 7; ypos += t->getHeight() + VGAP;
|
||||
xpos += t->getWidth()/2 - xdiff - 2; ypos += t->getHeight() + VGAP;
|
||||
myJoy[kJ1Up] = new CheckboxWidget(this, font, xpos, ypos, "", kJ1Up);
|
||||
ypos += myJoy[kJ1Up]->getHeight() * 2 + VGAP * 2;
|
||||
myJoy[kJ1Down] = new CheckboxWidget(this, font, xpos, ypos, "", kJ1Down);
|
||||
xpos -= myJoy[kJ1Up]->getWidth() + 5;
|
||||
xpos -= myJoy[kJ1Up]->getWidth() + xdiff;
|
||||
ypos -= myJoy[kJ1Up]->getHeight() + VGAP;
|
||||
myJoy[kJ1Left] = new CheckboxWidget(this, font, xpos, ypos, "", kJ1Left);
|
||||
xpos += (myJoy[kJ1Up]->getWidth() + 5) * 2;
|
||||
xpos += (myJoy[kJ1Up]->getWidth() + xdiff) * 2;
|
||||
myJoy[kJ1Right] = new CheckboxWidget(this, font, xpos, ypos, "", kJ1Right);
|
||||
xpos -= (myJoy[kJ1Up]->getWidth() + 5) * 2;
|
||||
xpos -= (myJoy[kJ1Up]->getWidth() + xdiff) * 2;
|
||||
ypos += myJoy[kJ1Down]->getHeight() * 2 + VGAP * 2;
|
||||
myJoy[kJ1Fire] = new CheckboxWidget(this, font, xpos, ypos, "Fire", kJ1Fire);
|
||||
|
||||
xpos = 2 * _w / 3 + 8; ypos = y;
|
||||
xpos = 2 * _w / 3 + fontWidth; ypos = y;
|
||||
|
||||
// Console Select/Reset
|
||||
t = new StaticTextWidget(this, font, xpos, ypos+2, "Console");
|
||||
|
|
|
@ -50,15 +50,20 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& lfont,
|
|||
void InputTextDialog::initialize(const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
const StringList& labels)
|
||||
{
|
||||
const int fontWidth = lfont.getMaxCharWidth(),
|
||||
fontHeight = lfont.getFontHeight(),
|
||||
lineHeight = lfont.getLineHeight();
|
||||
const int lineHeight = lfont.getLineHeight(),
|
||||
fontWidth = lfont.getMaxCharWidth(),
|
||||
fontHeight = lfont.getFontHeight(),
|
||||
buttonHeight = lfont.getLineHeight() * 1.25;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
uInt32 xpos, ypos, i, lwidth = 0, maxIdx = 0;
|
||||
WidgetArray wid;
|
||||
|
||||
// Calculate real dimensions
|
||||
_w = fontWidth * 41;
|
||||
_h = lineHeight * 4 + int(labels.size()) * (lineHeight + 5) + _th;
|
||||
_w = HBORDER * 2 + fontWidth * 39;
|
||||
_h = buttonHeight + lineHeight + VGAP + int(labels.size()) * (lineHeight + VGAP) + _th + VBORDER * 2;
|
||||
|
||||
// Determine longest label
|
||||
for(i = 0; i < labels.size(); ++i)
|
||||
|
@ -72,25 +77,25 @@ void InputTextDialog::initialize(const GUI::Font& lfont, const GUI::Font& nfont,
|
|||
lwidth = lfont.getStringWidth(labels[maxIdx]);
|
||||
|
||||
// Create editboxes for all labels
|
||||
ypos = lineHeight + _th;
|
||||
ypos = VBORDER + _th;
|
||||
for(i = 0; i < labels.size(); ++i)
|
||||
{
|
||||
xpos = 10;
|
||||
xpos = HBORDER;
|
||||
new StaticTextWidget(this, lfont, xpos, ypos + 2,
|
||||
lwidth, fontHeight,
|
||||
labels[i], TextAlign::Left);
|
||||
|
||||
xpos += lwidth + fontWidth;
|
||||
EditTextWidget* w = new EditTextWidget(this, nfont, xpos, ypos,
|
||||
_w - xpos - 10, lineHeight, "");
|
||||
_w - xpos - HBORDER, lineHeight, "");
|
||||
wid.push_back(w);
|
||||
|
||||
myInput.push_back(w);
|
||||
ypos += lineHeight + 5;
|
||||
ypos += lineHeight + VGAP;
|
||||
}
|
||||
|
||||
xpos = 10;
|
||||
myMessage = new StaticTextWidget(this, lfont, xpos, ypos, _w - 2*xpos, fontHeight,
|
||||
xpos = HBORDER; ypos += VGAP;
|
||||
myMessage = new StaticTextWidget(this, lfont, xpos, ypos, _w - 2 * xpos, fontHeight,
|
||||
"", TextAlign::Left);
|
||||
myMessage->setTextColor(kTextColorEm);
|
||||
|
||||
|
|
|
@ -32,33 +32,40 @@ JoystickDialog::JoystickDialog(GuiObject* boss, const GUI::Font& font,
|
|||
int xpos, ypos;
|
||||
WidgetArray wid;
|
||||
|
||||
int buttonWidth = font.getStringWidth("Remove ") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4;
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
buttonWidth = font.getStringWidth("Remove") + fontWidth * 2.5,
|
||||
buttonHeight = font.getLineHeight() * 1.25;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
const int INDENT = fontWidth * 2;
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
// Joystick list
|
||||
xpos = 10; ypos = 10 + _th;
|
||||
xpos = HBORDER; ypos = VBORDER + _th;
|
||||
int w = _w - 2 * xpos;
|
||||
int h = _h - buttonHeight - ypos - 20;
|
||||
int h = _h - buttonHeight - ypos - VBORDER * 2;
|
||||
myJoyList = new StringListWidget(this, font, xpos, ypos, w, h);
|
||||
myJoyList->setEditable(false);
|
||||
wid.push_back(myJoyList);
|
||||
|
||||
// Joystick ID
|
||||
ypos = _h - buttonHeight - 10;
|
||||
ypos = _h - VBORDER - (buttonHeight + lineHeight) / 2;
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos+2, "Joystick ID ");
|
||||
xpos += t->getWidth() + 4;
|
||||
xpos += t->getWidth();
|
||||
myJoyText = new EditTextWidget(this, font, xpos, ypos,
|
||||
font.getStringWidth("Unplugged")+8, font.getLineHeight(), "");
|
||||
font.getStringWidth("Unplugged "), font.getLineHeight(), "");
|
||||
myJoyText->setEditable(false);
|
||||
|
||||
// Add buttons at bottom
|
||||
xpos = _w - buttonWidth - 10;
|
||||
xpos = _w - buttonWidth - HBORDER;
|
||||
ypos = _h - VBORDER - buttonHeight;
|
||||
myCloseBtn = new ButtonWidget(this, font, xpos, ypos,
|
||||
buttonWidth, buttonHeight, "Close", GuiObject::kCloseCmd);
|
||||
addOKWidget(myCloseBtn); addCancelWidget(myCloseBtn);
|
||||
|
||||
buttonWidth = font.getStringWidth("Remove") + 20;
|
||||
xpos -= buttonWidth + 8;
|
||||
xpos -= buttonWidth + fontWidth;
|
||||
myRemoveBtn = new ButtonWidget(this, font, xpos, ypos,
|
||||
buttonWidth, buttonHeight, "Remove", kRemoveCmd);
|
||||
myRemoveBtn->clearFlags(Widget::FLAG_ENABLED);
|
||||
|
|
|
@ -60,25 +60,26 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
myUseMinimalUI = instance().settings().getBool("minimal_ui");
|
||||
|
||||
const GUI::Font& font = instance().frameBuffer().launcherFont();
|
||||
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight(),
|
||||
bheight = myUseMinimalUI ? lineHeight - 4 : lineHeight + 4,
|
||||
LBL_GAP = fontWidth,
|
||||
HBORDER = 10,//fontWidth * 1.25,
|
||||
HBORDER = fontWidth * 1.25,
|
||||
VBORDER = fontHeight / 2,
|
||||
BUTTON_GAP = fontWidth,
|
||||
bwidth = (_w - 2 * HBORDER - BUTTON_GAP * (4 - 1));
|
||||
int xpos = 0, ypos = 0, lwidth = 0, lwidth2 = 0;
|
||||
WidgetArray wid;
|
||||
LBL_GAP = fontWidth,
|
||||
VGAP = fontHeight / 4,
|
||||
buttonHeight = myUseMinimalUI ? lineHeight - VGAP * 2: lineHeight * 1.25,
|
||||
buttonWidth = (_w - 2 * HBORDER - BUTTON_GAP * (4 - 1));
|
||||
|
||||
int xpos = HBORDER, ypos = VBORDER, lwidth = 0, lwidth2 = 0;
|
||||
WidgetArray wid;
|
||||
string lblRom = "Select a ROM from the list" + ELLIPSIS;
|
||||
const string& lblFilter = "Filter";
|
||||
const string& lblAllFiles = "Show all files";
|
||||
const string& lblFound = "XXXX items found";
|
||||
|
||||
lwidth = font.getStringWidth(lblRom);
|
||||
lwidth2 = font.getStringWidth(lblAllFiles) + 20;
|
||||
lwidth2 = font.getStringWidth(lblAllFiles) + CheckboxWidget::boxSize(font);
|
||||
int lwidth3 = font.getStringWidth(lblFilter);
|
||||
int lwidth4 = font.getStringWidth(lblFound);
|
||||
|
||||
|
@ -97,14 +98,12 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
#if defined(RETRON77)
|
||||
ver << " for RetroN 77";
|
||||
#endif
|
||||
ypos += 8;
|
||||
new StaticTextWidget(this, font, xpos, ypos, _w - 20, fontHeight,
|
||||
new StaticTextWidget(this, font, 0, ypos, _w, fontHeight,
|
||||
ver.str(), TextAlign::Center);
|
||||
ypos += fontHeight - 4;
|
||||
ypos += lineHeight;
|
||||
}
|
||||
|
||||
// Show the header
|
||||
xpos += HBORDER; ypos += 8;
|
||||
new StaticTextWidget(this, font, xpos, ypos, lblRom);
|
||||
// Shop the files counter
|
||||
xpos = _w - HBORDER - lwidth4;
|
||||
|
@ -132,12 +131,12 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
// Add list with game titles
|
||||
// Before we add the list, we need to know the size of the RomInfoWidget
|
||||
int listHeight = _h - 43 - bheight - fontHeight - lineHeight;
|
||||
int listHeight = _h - VBORDER * 2 - buttonHeight - lineHeight * 2 - VGAP * 6;
|
||||
float imgZoom = getRomInfoZoom(listHeight);
|
||||
int romWidth = imgZoom * TIAConstants::viewableWidth;
|
||||
if(romWidth > 0) romWidth += 10;
|
||||
int listWidth = _w - (romWidth > 0 ? romWidth+8 : 0) - 20;
|
||||
xpos = HBORDER; ypos += lineHeight + 4;
|
||||
if(romWidth > 0) romWidth += HBORDER;
|
||||
int listWidth = _w - (romWidth > 0 ? romWidth + fontWidth : 0) - HBORDER * 2;
|
||||
xpos = HBORDER; ypos += lineHeight + VGAP;
|
||||
myList = new FileListWidget(this, font, xpos, ypos, listWidth, listHeight);
|
||||
myList->setEditable(false);
|
||||
myList->setListMode(FilesystemNode::ListMode::All);
|
||||
|
@ -146,14 +145,14 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
// Add ROM info area (if enabled)
|
||||
if(romWidth > 0)
|
||||
{
|
||||
xpos += myList->getWidth() + 8;
|
||||
xpos += myList->getWidth() + fontWidth;
|
||||
|
||||
// Initial surface size is the same as the viewable area
|
||||
Common::Size imgSize(TIAConstants::viewableWidth*imgZoom,
|
||||
TIAConstants::viewableHeight*imgZoom);
|
||||
|
||||
// Calculate font area, and in the process the font that can be used
|
||||
Common::Size fontArea(romWidth - 16, myList->getHeight() - imgSize.h - 12);
|
||||
Common::Size fontArea(romWidth - fontWidth * 2, myList->getHeight() - imgSize.h - VGAP * 3);
|
||||
|
||||
setRomInfoFont(fontArea);
|
||||
myRomInfoWidget = new RomInfoWidget(this, *myROMInfoFont,
|
||||
|
@ -162,7 +161,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
|
||||
// Add textfield to show current directory
|
||||
xpos = HBORDER;
|
||||
ypos += myList->getHeight() + 8;
|
||||
ypos += myList->getHeight() + VGAP * 2;
|
||||
lwidth = font.getStringWidth("Path") + LBL_GAP;
|
||||
myDirLabel = new StaticTextWidget(this, font, xpos, ypos+2, lwidth, fontHeight,
|
||||
"Path", TextAlign::Left);
|
||||
|
@ -174,43 +173,43 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
if(!myUseMinimalUI)
|
||||
{
|
||||
// Add four buttons at the bottom
|
||||
xpos = HBORDER; ypos += myDir->getHeight() + 8;
|
||||
xpos = HBORDER; ypos = _h - VBORDER - buttonHeight;
|
||||
#ifndef BSPF_MACOS
|
||||
myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 4, bheight,
|
||||
myStartButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 0) / 4, buttonHeight,
|
||||
"Select", kLoadROMCmd);
|
||||
wid.push_back(myStartButton);
|
||||
|
||||
xpos += (bwidth + 0) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 4, bheight,
|
||||
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
|
||||
"Go Up", kPrevDirCmd);
|
||||
wid.push_back(myPrevDirButton);
|
||||
|
||||
xpos += (bwidth + 1) / 4 + BUTTON_GAP;
|
||||
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 4, bheight,
|
||||
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
|
||||
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight,
|
||||
"Options" + ELLIPSIS, kOptionsCmd);
|
||||
wid.push_back(myOptionsButton);
|
||||
|
||||
xpos += (bwidth + 2) / 4 + BUTTON_GAP;
|
||||
myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 4) / 4, bheight,
|
||||
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
|
||||
myQuitButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 4) / 4, buttonHeight,
|
||||
"Quit", kQuitCmd);
|
||||
wid.push_back(myQuitButton);
|
||||
#else
|
||||
myQuitButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 0) / 4, bheight,
|
||||
myQuitButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 0) / 4, buttonHeight,
|
||||
"Quit", kQuitCmd);
|
||||
wid.push_back(myQuitButton);
|
||||
|
||||
xpos += (bwidth + 0) / 4 + BUTTON_GAP;
|
||||
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 1) / 4, bheight,
|
||||
xpos += (buttonWidth + 0) / 4 + BUTTON_GAP;
|
||||
myOptionsButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 1) / 4, buttonHeight,
|
||||
"Options" + ELLIPSIS, kOptionsCmd);
|
||||
wid.push_back(myOptionsButton);
|
||||
|
||||
xpos += (bwidth + 1) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 2) / 4, bheight,
|
||||
xpos += (buttonWidth + 1) / 4 + BUTTON_GAP;
|
||||
myPrevDirButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 2) / 4, buttonHeight,
|
||||
"Go Up", kPrevDirCmd);
|
||||
wid.push_back(myPrevDirButton);
|
||||
|
||||
xpos += (bwidth + 2) / 4 + BUTTON_GAP;
|
||||
myStartButton = new ButtonWidget(this, font, xpos, ypos, (bwidth + 3) / 4, bheight,
|
||||
xpos += (buttonWidth + 2) / 4 + BUTTON_GAP;
|
||||
myStartButton = new ButtonWidget(this, font, xpos, ypos, (buttonWidth + 3) / 4, buttonHeight,
|
||||
"Select", kLoadROMCmd);
|
||||
wid.push_back(myStartButton);
|
||||
#endif
|
||||
|
@ -223,7 +222,7 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
addToFocusList(wid);
|
||||
|
||||
// Create (empty) context menu for ROM list options
|
||||
myMenu = make_unique<ContextMenu>(this, osystem.frameBuffer().font(), EmptyVarList);
|
||||
myMenu = make_unique<ContextMenu>(this, osystem.frameBuffer().launcherFont(), EmptyVarList);
|
||||
|
||||
// Create global props dialog, which is used to temporarily override
|
||||
// ROM properties
|
||||
|
@ -363,28 +362,33 @@ float LauncherDialog::getRomInfoZoom(int listHeight) const
|
|||
|
||||
if(zoom > 0.F)
|
||||
{
|
||||
// upper zoom limit - at least 24 launchers chars/line and 8 ROM info lines
|
||||
if((_w - 58 - zoom * TIAConstants::viewableWidth)
|
||||
/ instance().frameBuffer().launcherFont().getMaxCharWidth() < MIN_LAUNCHER_CHARS)
|
||||
const GUI::Font& font = instance().frameBuffer().launcherFont();
|
||||
const GUI::Font& smallFont = instance().frameBuffer().smallFont();
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
HBORDER = fontWidth * 1.25;
|
||||
|
||||
// upper zoom limit - at least 24 launchers chars/line and 7 + 4 ROM info lines
|
||||
if((_w - (HBORDER * 2 + fontWidth + 30) - zoom * TIAConstants::viewableWidth)
|
||||
/ font.getMaxCharWidth() < MIN_LAUNCHER_CHARS)
|
||||
{
|
||||
zoom = float(_w - 58 - MIN_LAUNCHER_CHARS * instance().frameBuffer().launcherFont().getMaxCharWidth())
|
||||
zoom = float(_w - (HBORDER * 2 + fontWidth + 30) - MIN_LAUNCHER_CHARS * font.getMaxCharWidth())
|
||||
/ TIAConstants::viewableWidth;
|
||||
}
|
||||
if((listHeight - 12 - zoom * TIAConstants::viewableHeight) <
|
||||
MIN_ROMINFO_ROWS * instance().frameBuffer().smallFont().getLineHeight() +
|
||||
MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getFontHeight())
|
||||
MIN_ROMINFO_ROWS * smallFont.getLineHeight() +
|
||||
MIN_ROMINFO_LINES * smallFont.getFontHeight())
|
||||
{
|
||||
zoom = float(listHeight - 12 -
|
||||
MIN_ROMINFO_ROWS * instance().frameBuffer().smallFont().getLineHeight() -
|
||||
MIN_ROMINFO_LINES * instance().frameBuffer().smallFont().getFontHeight())
|
||||
MIN_ROMINFO_ROWS * smallFont.getLineHeight() -
|
||||
MIN_ROMINFO_LINES * smallFont.getFontHeight())
|
||||
/ TIAConstants::viewableHeight;
|
||||
}
|
||||
|
||||
// lower zoom limit - at least 24 ROM info chars/line
|
||||
// lower zoom limit - at least 30 ROM info chars/line
|
||||
if((zoom * TIAConstants::viewableWidth)
|
||||
/ instance().frameBuffer().smallFont().getMaxCharWidth() < MIN_ROMINFO_CHARS + 6)
|
||||
/ smallFont.getMaxCharWidth() < MIN_ROMINFO_CHARS + 6)
|
||||
{
|
||||
zoom = float(MIN_ROMINFO_CHARS * instance().frameBuffer().smallFont().getMaxCharWidth() + 6)
|
||||
zoom = float(MIN_ROMINFO_CHARS * smallFont.getMaxCharWidth() + 6)
|
||||
/ TIAConstants::viewableWidth;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,21 +79,24 @@ MessageBox::MessageBox(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void MessageBox::addText(const GUI::Font& font, const StringList& text)
|
||||
{
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight();
|
||||
int xpos, ypos;
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight();
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
|
||||
int xpos, ypos;
|
||||
// Set real dimensions
|
||||
int str_w = 0;
|
||||
|
||||
for(const auto& s: text)
|
||||
str_w = std::max(int(s.length()), str_w);
|
||||
_w = std::min(str_w * fontWidth + 20, _w);
|
||||
_h = std::min(uInt32((text.size() + 2) * fontHeight + 20 + _th), uInt32(_h));
|
||||
_w = std::min(str_w * fontWidth + HBORDER * 2, _w);
|
||||
_h = std::min(uInt32((text.size() + 2) * fontHeight + VBORDER * 2 + _th), uInt32(_h));
|
||||
|
||||
xpos = 10; ypos = 10 + _th;
|
||||
xpos = HBORDER; ypos = VBORDER + _th;
|
||||
for(const auto& s: text)
|
||||
{
|
||||
new StaticTextWidget(this, font, xpos, ypos, _w - 20,
|
||||
new StaticTextWidget(this, font, xpos, ypos, _w - HBORDER * 2,
|
||||
fontHeight, s, TextAlign::Left);
|
||||
ypos += fontHeight;
|
||||
}
|
||||
|
|
|
@ -58,14 +58,15 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
|
|||
fontWidth = _font.getMaxCharWidth(),
|
||||
fontHeight = _font.getFontHeight(),
|
||||
buttonHeight = _font.getLineHeight() * 1.25,
|
||||
GAP = fontWidth / 2,
|
||||
rowHeight = buttonHeight + GAP;
|
||||
VGAP = fontHeight / 4,
|
||||
HGAP = fontWidth,
|
||||
rowHeight = buttonHeight + VGAP;
|
||||
const int VBORDER = fontHeight / 2;
|
||||
const int HBORDER = fontWidth * 1.25;
|
||||
int buttonWidth = _font.getStringWidth("Game Properties" + ELLIPSIS) + GAP * 5;
|
||||
int buttonWidth = _font.getStringWidth("Game Properties" + ELLIPSIS) + fontWidth * 2.5;
|
||||
|
||||
_w = 2 * buttonWidth + HBORDER * 3;
|
||||
_h = 7 * rowHeight + VBORDER * 2 - GAP + _th;
|
||||
_w = 2 * buttonWidth + HBORDER * 2 + HGAP;
|
||||
_h = 7 * rowHeight + VBORDER * 2 - VGAP + _th;
|
||||
|
||||
int xoffset = HBORDER, yoffset = VBORDER + _th;
|
||||
WidgetArray wid;
|
||||
|
@ -76,8 +77,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
|
|||
ButtonWidget* bw = new ButtonWidget(this, _font, xoffset, yoffset,
|
||||
_w - HBORDER * 2, buttonHeight, "Use Basic Settings", kBasSetCmd);
|
||||
wid.push_back(bw);
|
||||
yoffset += rowHeight + GAP * 2;
|
||||
_h += rowHeight + GAP * 2;
|
||||
yoffset += rowHeight + VGAP * 2;
|
||||
_h += rowHeight + VGAP * 2;
|
||||
}
|
||||
|
||||
auto ADD_OD_BUTTON = [&](const string& label, int cmd)
|
||||
|
@ -111,8 +112,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
|
|||
wid.push_back(b);
|
||||
|
||||
// Move to second column
|
||||
xoffset += buttonWidth + HBORDER;
|
||||
yoffset = minSettings ? VBORDER + _th + rowHeight + GAP * 2 : VBORDER + _th;
|
||||
xoffset += buttonWidth + HGAP;
|
||||
yoffset = minSettings ? VBORDER + _th + rowHeight + VGAP * 2 : VBORDER + _th;
|
||||
|
||||
myGameInfoButton = ADD_OD_BUTTON("Game Properties" + ELLIPSIS, kInfoCmd);
|
||||
wid.push_back(myGameInfoButton);
|
||||
|
@ -135,8 +136,8 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
|
|||
b = ADD_OD_BUTTON("About" + ELLIPSIS, kAboutCmd);
|
||||
wid.push_back(b);
|
||||
|
||||
buttonWidth = _font.getStringWidth(" Close ") + GAP * 5;
|
||||
xoffset -= (buttonWidth + HBORDER) / 2;
|
||||
buttonWidth = _font.getStringWidth(" Close ") + fontWidth * 2.5;
|
||||
xoffset -= (buttonWidth + HGAP) / 2;
|
||||
b = ADD_OD_BUTTON("Close", kExitCmd);
|
||||
wid.push_back(b);
|
||||
addCancelWidget(b);
|
||||
|
|
|
@ -41,11 +41,13 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
|
|||
if(!_label.empty() && _labelWidth == 0)
|
||||
_labelWidth = _font.getStringWidth(_label);
|
||||
|
||||
_w = w + _labelWidth + 23;
|
||||
setArrow();
|
||||
|
||||
_w = w + _labelWidth + dropDownWidth(font); // 23
|
||||
|
||||
// vertically center the arrows and text
|
||||
myTextY = (_h - _font.getFontHeight()) / 2;
|
||||
myArrowsY = (_h - 8) / 2;
|
||||
myArrowsY = (_h - _arrowHeight) / 2;
|
||||
|
||||
myMenu = make_unique<ContextMenu>(this, font, list, cmd, w);
|
||||
}
|
||||
|
@ -185,10 +187,10 @@ void PopUpWidget::handleCommand(CommandSender* sender, int cmd, int data, int id
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PopUpWidget::drawWidget(bool hilite)
|
||||
void PopUpWidget::setArrow()
|
||||
{
|
||||
// Small down arrow
|
||||
static constexpr std::array<uInt32, 8> down_arrow = {
|
||||
static constexpr std::array<uInt32, 7> down_arrow = {
|
||||
0b100000001,
|
||||
0b110000011,
|
||||
0b111000111,
|
||||
|
@ -196,24 +198,40 @@ void PopUpWidget::drawWidget(bool hilite)
|
|||
0b001111100,
|
||||
0b000111000,
|
||||
0b000010000,
|
||||
0b000000000
|
||||
};
|
||||
// Large down arrow
|
||||
static constexpr std::array<uInt32, 11> down_arrow_large = {
|
||||
0b00000000000,
|
||||
0b10000000001,
|
||||
0b11000000011,
|
||||
0b11100000111,
|
||||
0b11110001111,
|
||||
0b01111011110,
|
||||
0b00111111100,
|
||||
0b00011111000,
|
||||
0b00001110000,
|
||||
0b00000100000,
|
||||
0b00000000000
|
||||
static constexpr std::array<uInt32, 10> down_arrow_large = {
|
||||
0b1000000000001,
|
||||
0b1100000000011,
|
||||
0b1110000000111,
|
||||
0b1111000001111,
|
||||
0b0111100011110,
|
||||
0b0011110111100,
|
||||
0b0001111111000,
|
||||
0b0000111110000,
|
||||
0b0000011100000,
|
||||
0b0000001000000
|
||||
};
|
||||
|
||||
if(_font.getFontHeight() < 24)
|
||||
{
|
||||
_textOfs = 3;
|
||||
_arrowWidth = 9;
|
||||
_arrowHeight = 7;
|
||||
_arrowImg = down_arrow.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
_textOfs = 5;
|
||||
_arrowWidth = 13;
|
||||
_arrowHeight = 10;
|
||||
_arrowImg = down_arrow_large.data();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PopUpWidget::drawWidget(bool hilite)
|
||||
{
|
||||
//cerr << "PopUpWidget::drawWidget\n";
|
||||
FBSurface& s = dialog().surface();
|
||||
bool onTop = _boss->dialog().isOnTop();
|
||||
|
@ -228,19 +246,22 @@ void PopUpWidget::drawWidget(bool hilite)
|
|||
|
||||
// Draw a thin frame around us.
|
||||
s.frameRect(x, _y, w, _h, isEnabled() && hilite ? kWidColorHi : kColor);
|
||||
s.frameRect(x + w - 16, _y + 1, 15, _h - 2, isEnabled() && hilite ? kWidColorHi : kBGColorLo);
|
||||
s.frameRect(x + w - (_arrowWidth * 2 - 2), _y + 1, (_arrowWidth * 2 - 3), _h - 2,
|
||||
isEnabled() && hilite ? kWidColorHi : kBGColorLo);
|
||||
|
||||
// Fill the background
|
||||
s.fillRect(x + 1, _y + 1, w - 17, _h - 2, onTop ? _changed ? kDbgChangedColor : kWidColor : kDlgColor);
|
||||
s.fillRect(x + w - 15, _y + 2, 13, _h - 4, onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo);
|
||||
s.fillRect(x + 1, _y + 1, w - (_arrowWidth * 2 - 1), _h - 2,
|
||||
onTop ? _changed ? kDbgChangedColor : kWidColor : kDlgColor);
|
||||
s.fillRect(x + w - (_arrowWidth * 2 - 3), _y + 2, (_arrowWidth * 2 - 5), _h - 4,
|
||||
onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo);
|
||||
// Draw an arrow pointing down at the right end to signal this is a dropdown/popup
|
||||
s.drawBitmap(down_arrow.data(), x + w - 13, _y + myArrowsY + 1,
|
||||
!(isEnabled() && onTop) ? kColor : kTextColor, 9U, 8U);
|
||||
s.drawBitmap(_arrowImg, x + w - (_arrowWidth * 1.5 - 1), _y + myArrowsY + 1,
|
||||
!(isEnabled() && onTop) ? kColor : kTextColor, _arrowWidth, _arrowHeight);
|
||||
|
||||
// Draw the selected entry, if any
|
||||
const string& name = myMenu->getSelectedName();
|
||||
TextAlign align = (_font.getStringWidth(name) > w-6) ?
|
||||
TextAlign align = (_font.getStringWidth(name) > w - 6) ?
|
||||
TextAlign::Right : TextAlign::Left;
|
||||
s.drawString(_font, name, x+2, _y+myTextY, w-6,
|
||||
s.drawString(_font, name, x + _textOfs, _y + myTextY, w - 6,
|
||||
!(isEnabled() && onTop) ? kColor : _changed ? kDbgChangedTextColor : kTextColor, align);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,10 @@ class PopUpWidget : public Widget, public CommandSender
|
|||
const Variant& getSelectedTag() const;
|
||||
|
||||
bool wantsFocus() const override { return true; }
|
||||
static int dropDownWidth(const GUI::Font& font)
|
||||
{
|
||||
return font.getFontHeight() < 24 ? (9 * 2 + 3) : (13 * 2 + 7);
|
||||
}
|
||||
|
||||
protected:
|
||||
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
|
||||
|
@ -70,6 +74,8 @@ class PopUpWidget : public Widget, public CommandSender
|
|||
void handleMouseLeft() override;
|
||||
bool handleEvent(Event::Type e) override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
void setArrow();
|
||||
void drawWidget(bool hilite) override;
|
||||
|
||||
private:
|
||||
|
@ -81,6 +87,11 @@ class PopUpWidget : public Widget, public CommandSender
|
|||
int _labelWidth{0};
|
||||
bool _changed{false};
|
||||
|
||||
int _textOfs{0};
|
||||
int _arrowWidth{0};
|
||||
int _arrowHeight{0};
|
||||
const uInt32* _arrowImg{nullptr};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
PopUpWidget() = delete;
|
||||
|
|
|
@ -31,20 +31,23 @@ ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font,
|
|||
{
|
||||
const int fontWidth = font.getMaxCharWidth(),
|
||||
fontHeight = font.getFontHeight(),
|
||||
lineHeight = font.getLineHeight();
|
||||
lineHeight = font.getLineHeight(),
|
||||
VBORDER = fontHeight / 2,
|
||||
HBORDER = fontWidth * 1.25,
|
||||
VGAP = fontHeight / 4;
|
||||
int xpos, ypos, lwidth;
|
||||
|
||||
// Calculate real dimensions
|
||||
lwidth = font.getStringWidth(message);
|
||||
_w = lwidth + 2 * fontWidth;
|
||||
_h = lineHeight * 5;
|
||||
_w = HBORDER * 2 + lwidth;
|
||||
_h = VBORDER * 2 + lineHeight * 2 + VGAP * 2;
|
||||
|
||||
xpos = fontWidth; ypos = lineHeight;
|
||||
xpos = HBORDER; ypos = VBORDER;
|
||||
myMessage = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
|
||||
message, TextAlign::Center);
|
||||
myMessage->setTextColor(kTextColorEm);
|
||||
|
||||
xpos = fontWidth; ypos += 2 * lineHeight;
|
||||
xpos = HBORDER; ypos += lineHeight + VGAP * 2;
|
||||
mySlider = new SliderWidget(this, font, xpos, ypos, lwidth, lineHeight, "", 0, 0);
|
||||
mySlider->setMinValue(1);
|
||||
mySlider->setMaxValue(100);
|
||||
|
|
|
@ -38,7 +38,7 @@ class ScrollBarWidget : public Widget, public CommandSender
|
|||
static int getWheelLines() { return _WHEEL_LINES; }
|
||||
static int scrollBarWidth(const GUI::Font& font)
|
||||
{
|
||||
return ((int(font.getMaxCharWidth() * 1.67) >> 1) << 1) + 1;
|
||||
return font.getFontHeight() < 24 ? 15 : 23;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue