mirror of https://github.com/stella-emu/stella.git
allow to position dialogs centered and in corners
This commit is contained in:
parent
0e6e54f15c
commit
d4479f4e43
|
@ -74,6 +74,7 @@ class DebuggerDialog : public Dialog
|
|||
void showFatalMessage(const string& msg);
|
||||
|
||||
private:
|
||||
void center() { positionAt(0); }
|
||||
void loadConfig() override;
|
||||
void handleKeyDown(StellaKey key, StellaMod mod) override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
|
|
@ -122,6 +122,7 @@ Settings::Settings()
|
|||
setPermanent("listdelay", "300");
|
||||
setPermanent("mwheel", "4");
|
||||
setPermanent("basic_settings", false);
|
||||
setPermanent("dialogpos", 0);
|
||||
|
||||
// Misc options
|
||||
setPermanent("autoslot", "false");
|
||||
|
@ -463,6 +464,8 @@ void Settings::usage() const
|
|||
<< " (300-1000)\n"
|
||||
<< " -mwheel <lines> Number of lines the mouse wheel will scroll in\n"
|
||||
<< " UI\n"
|
||||
<< " -basic_settings <0|1> Display only a basic settings dialog\n"
|
||||
<< " -dialogpos <0..4> Display all dialogs at given positions\n"
|
||||
<< " -romdir <dir> Directory in which to load ROM files\n"
|
||||
<< " -avoxport <name> The name of the serial port where an AtariVox is\n"
|
||||
<< " connected\n"
|
||||
|
|
|
@ -95,7 +95,7 @@ void Dialog::open()
|
|||
// Make sure we have a valid surface to draw into
|
||||
// Technically, this shouldn't be needed until drawDialog(), but some
|
||||
// dialogs cause drawing to occur within loadConfig()
|
||||
if(_surface == nullptr)
|
||||
if (_surface == nullptr)
|
||||
_surface = instance().frameBuffer().allocateSurface(_w, _h);
|
||||
parent().addDialog(this);
|
||||
|
||||
|
@ -108,6 +108,13 @@ void Dialog::open()
|
|||
else
|
||||
buildCurrentFocusList();
|
||||
|
||||
/*if (!_surface->attributes().blending)
|
||||
{
|
||||
_surface->attributes().blending = true;
|
||||
_surface->attributes().blendalpha = 90;
|
||||
_surface->applyAttributes();
|
||||
}*/
|
||||
|
||||
loadConfig(); // has to be done AFTER (re)building the focus list
|
||||
|
||||
_visible = true;
|
||||
|
@ -148,10 +155,44 @@ void Dialog::setTitle(const string& title)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::center()
|
||||
{
|
||||
positionAt(instance().settings().getInt("dialogpos"));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Dialog::positionAt(uInt32 pos)
|
||||
{
|
||||
const GUI::Size& screen = instance().frameBuffer().screenSize();
|
||||
const GUI::Rect& dst = _surface->dstRect();
|
||||
_surface->setDstPos((screen.w - dst.width()) >> 1, (screen.h - dst.height()) >> 1);
|
||||
|
||||
int top = std::min(screen.h - dst.height(), screen.h >> 5);
|
||||
int btm = std::min(screen.h - dst.height(), screen.h - dst.height() - (screen.h >> 5));
|
||||
int left = std::min(screen.w - dst.width(), screen.w >> 5);
|
||||
int right = std::min(screen.w - dst.width(), screen.w - dst.width() - (screen.w >> 5));
|
||||
|
||||
switch (pos)
|
||||
{
|
||||
case 1:
|
||||
_surface->setDstPos(left, top);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_surface->setDstPos(right, top);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_surface->setDstPos(right, btm);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_surface->setDstPos(left, btm);
|
||||
break;
|
||||
|
||||
default:
|
||||
// center
|
||||
_surface->setDstPos((screen.w - dst.width()) >> 1, (screen.h - dst.height()) >> 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -162,6 +162,7 @@ class Dialog : public GuiObject
|
|||
|
||||
/** Define the size (allowed) for the dialog. */
|
||||
void setSize(uInt32 w, uInt32 h, uInt32 max_w, uInt32 max_h);
|
||||
void positionAt(uInt32 pos);
|
||||
|
||||
private:
|
||||
void buildCurrentFocusList(int tabID = -1);
|
||||
|
|
|
@ -126,6 +126,8 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
// Show the checkbox for all files
|
||||
xpos -= lwidth2 + LBL_GAP * 3;
|
||||
myAllFiles = new CheckboxWidget(this, font, xpos, ypos, lblAllFiles, kAllfilesCmd);
|
||||
wid.push_back(myAllFiles);
|
||||
wid.push_back(myPattern);
|
||||
}
|
||||
|
||||
// Add list with game titles
|
||||
|
@ -143,7 +145,6 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
listWidth, _h - 43 - bheight - fontHeight - lineHeight);
|
||||
myList->setEditable(false);
|
||||
wid.push_back(myList);
|
||||
if(myPattern) wid.push_back(myPattern); // Add after the list for tab order
|
||||
|
||||
// Add ROM info area (if enabled)
|
||||
if(romWidth > 0)
|
||||
|
@ -204,7 +205,10 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
|
|||
wid.push_back(myStartButton);
|
||||
#endif
|
||||
}
|
||||
mySelectedItem = 0; // Highlight 'Rom Listing'
|
||||
if (myUseMinimalUI) // Highlight 'Rom Listing'
|
||||
mySelectedItem = 0;
|
||||
else
|
||||
mySelectedItem = 2;
|
||||
|
||||
// Create a game list, which contains all the information about a ROM that
|
||||
// the launcher needs
|
||||
|
|
|
@ -85,6 +85,7 @@ class LauncherDialog : public Dialog
|
|||
void reload() { updateListing(); }
|
||||
|
||||
private:
|
||||
void center() { positionAt(0); }
|
||||
void handleKeyDown(StellaKey key, StellaMod mod) override;
|
||||
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
|
|
@ -45,13 +45,14 @@ StellaSettingsDialog::StellaSettingsDialog(OSystem& osystem, DialogContainer& pa
|
|||
VariantList items;
|
||||
|
||||
// Set real dimensions
|
||||
setSize(33 * fontWidth + HBORDER * 2, 14 * (lineHeight + VGAP) + VGAP * 9 + 6 + _th, max_w, max_h);
|
||||
setSize(33 * fontWidth + HBORDER * 2 + 3, 15 * (lineHeight + VGAP) + VGAP * 9 + 6 + _th, max_w, max_h);
|
||||
|
||||
xpos = HBORDER;
|
||||
ypos = VBORDER + _th;
|
||||
|
||||
myAdvancedSettings = new ButtonWidget(this, font, xpos, ypos, _w - HBORDER * 2, buttonHeight,
|
||||
"Switch to Advanced Settings" + ELLIPSIS, kAdvancedSettings);
|
||||
wid.push_back(myAdvancedSettings);
|
||||
ypos += lineHeight + VGAP*4;
|
||||
|
||||
new StaticTextWidget(this, font, xpos, ypos + 1, "Global settings:");
|
||||
|
@ -83,15 +84,27 @@ void StellaSettingsDialog::addUIOptions(WidgetArray& wid, int& xpos, int& ypos,
|
|||
const int VGAP = 4;
|
||||
const int lineHeight = font.getLineHeight();
|
||||
VariantList items;
|
||||
int pwidth = font.getStringWidth("Bad adjust"); // align width with other popup
|
||||
int pwidth = font.getStringWidth("Right bottom"); // align width with other popup
|
||||
|
||||
ypos += 1;
|
||||
VarList::push_back(items, "Standard", "standard");
|
||||
VarList::push_back(items, "Classic", "classic");
|
||||
VarList::push_back(items, "Light", "light");
|
||||
myThemePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "UI theme ");
|
||||
myThemePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "UI theme ");
|
||||
wid.push_back(myThemePopup);
|
||||
ypos += lineHeight + VGAP;
|
||||
|
||||
// Dialog position
|
||||
items.clear();
|
||||
VarList::push_back(items, "Centered", 0);
|
||||
VarList::push_back(items, "Left top", 1);
|
||||
VarList::push_back(items, "Right top", 2);
|
||||
VarList::push_back(items, "Right bottom", 3);
|
||||
VarList::push_back(items, "Left bottom", 4);
|
||||
myPositionPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
|
||||
items, "Dialogs position ");
|
||||
wid.push_back(myPositionPopup);
|
||||
ypos += lineHeight + VGAP;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -113,11 +126,11 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypo
|
|||
VarList::push_back(items, "S-Video", static_cast<uInt32>(NTSCFilter::Preset::SVIDEO));
|
||||
VarList::push_back(items, "Composite", static_cast<uInt32>(NTSCFilter::Preset::COMPOSITE));
|
||||
VarList::push_back(items, "Bad adjust", static_cast<uInt32>(NTSCFilter::Preset::BAD));
|
||||
int lwidth = font.getStringWidth("TV mode ");
|
||||
int lwidth = font.getStringWidth("TV mode ");
|
||||
int pwidth = font.getStringWidth("Bad adjust");
|
||||
|
||||
myTVMode = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
|
||||
items, "TV mode ", lwidth);
|
||||
items, "TV mode ");
|
||||
wid.push_back(myTVMode);
|
||||
ypos += lineHeight + VGAP * 2;
|
||||
|
||||
|
@ -128,7 +141,7 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypo
|
|||
myTVScanlines = new StaticTextWidget(this, font, xpos, ypos + 1, "Scanlines:");
|
||||
ypos += lineHeight;
|
||||
myTVScanIntense = new SliderWidget(this, font, xpos + INDENT, ypos-1, swidth, lineHeight,
|
||||
"Intensity ", lwidth, kScanlinesChanged, fontWidth * 3);
|
||||
"Intensity ", lwidth, kScanlinesChanged, fontWidth * 2);
|
||||
myTVScanIntense->setMinValue(0); myTVScanIntense->setMaxValue(10);
|
||||
myTVScanIntense->setTickmarkInterval(2);
|
||||
wid.push_back(myTVScanIntense);
|
||||
|
@ -139,7 +152,7 @@ void StellaSettingsDialog::addVideoOptions(WidgetArray& wid, int& xpos, int& ypo
|
|||
ypos += lineHeight;
|
||||
// TV Phosphor blend level
|
||||
myTVPhosLevel = new SliderWidget(this, font, xpos + INDENT, ypos-1, swidth, lineHeight,
|
||||
"Blend ", lwidth, kPhosphorChanged, fontWidth * 3);
|
||||
"Blend ", lwidth, kPhosphorChanged, fontWidth * 2);
|
||||
myTVPhosLevel->setMinValue(0); myTVPhosLevel->setMaxValue(10);
|
||||
myTVPhosLevel->setTickmarkInterval(2);
|
||||
wid.push_back(myTVPhosLevel);
|
||||
|
@ -195,6 +208,8 @@ void StellaSettingsDialog::loadConfig()
|
|||
// UI palette
|
||||
const string& theme = settings.getString("uipalette");
|
||||
myThemePopup->setSelected(theme, "standard");
|
||||
// Dialog position
|
||||
myPositionPopup->setSelected(settings.getString("dialogpos"), "0");
|
||||
|
||||
// TV Mode
|
||||
myTVMode->setSelected(
|
||||
|
@ -231,6 +246,9 @@ void StellaSettingsDialog::saveConfig()
|
|||
myThemePopup->getSelectedTag().toString());
|
||||
instance().frameBuffer().setUIPalette();
|
||||
|
||||
// Dialog position
|
||||
settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString());
|
||||
|
||||
// TV Mode
|
||||
instance().settings().setValue("tv.filter",
|
||||
myTVMode->getSelectedTag().toString());
|
||||
|
@ -269,6 +287,8 @@ void StellaSettingsDialog::setDefaults()
|
|||
{
|
||||
// UI Theme
|
||||
myThemePopup->setSelected("standard");
|
||||
// Dialog position
|
||||
myPositionPopup->setSelected("0");
|
||||
|
||||
// TV effects
|
||||
myTVMode->setSelected("RGB", static_cast<uInt32>(NTSCFilter::Preset::RGB));
|
||||
|
|
|
@ -63,6 +63,7 @@ class StellaSettingsDialog : public Dialog
|
|||
|
||||
// UI theme
|
||||
PopUpWidget* myThemePopup;
|
||||
PopUpWidget* myPositionPopup;
|
||||
|
||||
// TV effects
|
||||
PopUpWidget* myTVMode;
|
||||
|
|
|
@ -72,7 +72,7 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
wid.clear();
|
||||
tabID = myTab->addTab(" Look & Feel ");
|
||||
lwidth = font.getStringWidth("Mouse wheel scroll ");
|
||||
pwidth = font.getStringWidth("Standard");
|
||||
pwidth = font.getStringWidth("Right bottom");
|
||||
xpos = HBORDER; ypos = VBORDER;
|
||||
|
||||
// UI Palette
|
||||
|
@ -82,8 +82,20 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
|
|||
VarList::push_back(items, "Classic", "classic");
|
||||
VarList::push_back(items, "Light", "light");
|
||||
myPalettePopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
||||
items, "Theme ", lwidth);
|
||||
items, "Theme ", lwidth);
|
||||
wid.push_back(myPalettePopup);
|
||||
ypos += lineHeight + V_GAP;
|
||||
|
||||
// Dialog position
|
||||
items.clear();
|
||||
VarList::push_back(items, "Centered", 0);
|
||||
VarList::push_back(items, "Left top", 1);
|
||||
VarList::push_back(items, "Right top", 2);
|
||||
VarList::push_back(items, "Right bottom", 3);
|
||||
VarList::push_back(items, "Left bottom", 4);
|
||||
myPositionPopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
||||
items, "Dialogs position ", lwidth);
|
||||
wid.push_back(myPositionPopup);
|
||||
ypos += lineHeight + V_GAP * 4;
|
||||
|
||||
// Delay between quick-selecting characters in ListWidget
|
||||
|
@ -264,6 +276,9 @@ void UIDialog::loadConfig()
|
|||
const string& pal = settings.getString("uipalette");
|
||||
myPalettePopup->setSelected(pal, "standard");
|
||||
|
||||
// Dialog position
|
||||
myPositionPopup->setSelected(settings.getString("dialogpos"), "0");
|
||||
|
||||
// Listwidget quick delay
|
||||
int delay = settings.getInt("listdelay");
|
||||
myListDelayPopup->setValue(delay);
|
||||
|
@ -309,6 +324,9 @@ void UIDialog::saveConfig()
|
|||
myPalettePopup->getSelectedTag().toString());
|
||||
instance().frameBuffer().setUIPalette();
|
||||
|
||||
// Dialog position
|
||||
settings.setValue("dialogpos", myPositionPopup->getSelectedTag().toString());
|
||||
|
||||
// Listwidget quick delay
|
||||
settings.setValue("listdelay", myListDelayPopup->getValue());
|
||||
ListWidget::setQuickSelectDelay(myListDelayPopup->getValue());
|
||||
|
@ -329,6 +347,7 @@ void UIDialog::setDefaults()
|
|||
{
|
||||
case 0: // Misc. options
|
||||
myPalettePopup->setSelected("standard");
|
||||
myPositionPopup->setSelected("0");
|
||||
myListDelayPopup->setValue(300);
|
||||
myWheelLinesPopup->setValue(4);
|
||||
break;
|
||||
|
|
|
@ -63,6 +63,7 @@ class UIDialog : public Dialog, public CommandSender
|
|||
|
||||
// Misc options
|
||||
PopUpWidget* myPalettePopup;
|
||||
PopUpWidget* myPositionPopup;
|
||||
SliderWidget* myListDelayPopup;
|
||||
SliderWidget* myWheelLinesPopup;
|
||||
|
||||
|
|
Loading…
Reference in New Issue