mirror of https://github.com/stella-emu/stella.git
improve dialog stacking
This commit is contained in:
parent
ed5f8cb9de
commit
60260843ff
|
@ -64,7 +64,8 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
|
|||
_tabID(0),
|
||||
_flags(Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG),
|
||||
_max_w(0),
|
||||
_max_h(0)
|
||||
_max_h(0),
|
||||
_layer(0)
|
||||
{
|
||||
setTitle(title);
|
||||
setDirty();
|
||||
|
@ -97,7 +98,7 @@ void Dialog::open()
|
|||
// dialogs cause drawing to occur within loadConfig()
|
||||
if (_surface == nullptr)
|
||||
_surface = instance().frameBuffer().allocateSurface(_w, _h);
|
||||
parent().addDialog(this);
|
||||
_layer = parent().addDialog(this);
|
||||
|
||||
center();
|
||||
|
||||
|
@ -164,11 +165,12 @@ void Dialog::positionAt(uInt32 pos)
|
|||
{
|
||||
const Common::Size& screen = instance().frameBuffer().screenSize();
|
||||
const Common::Rect& dst = _surface->dstRect();
|
||||
|
||||
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));
|
||||
// shift stacked dialogs
|
||||
uInt32 gap = (screen.w >> 6) * _layer;
|
||||
int top = std::min(screen.h - dst.height(), gap);
|
||||
int btm = std::min(screen.h - dst.height(), screen.h - dst.height() - gap);
|
||||
int left = std::min(screen.w - dst.width(), gap);
|
||||
int right = std::min(screen.w - dst.width(), screen.w - dst.width() - gap);
|
||||
|
||||
switch (pos)
|
||||
{
|
||||
|
|
|
@ -186,6 +186,7 @@ class Dialog : public GuiObject
|
|||
bool _processCancel;
|
||||
string _title;
|
||||
int _th;
|
||||
int _layer;
|
||||
|
||||
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ bool DialogContainer::needsRedraw() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DialogContainer::addDialog(Dialog* d)
|
||||
int DialogContainer::addDialog(Dialog* d)
|
||||
{
|
||||
const Common::Rect& r = myOSystem.frameBuffer().imageRect();
|
||||
if(uInt32(d->getWidth()) > r.width() || uInt32(d->getHeight()) > r.height())
|
||||
|
@ -137,6 +137,7 @@ void DialogContainer::addDialog(Dialog* d)
|
|||
d->setDirty();
|
||||
myDialogStack.push(d);
|
||||
}
|
||||
return myDialogStack.size();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -160,7 +160,7 @@ class DialogContainer
|
|||
/**
|
||||
Add a dialog box to the stack.
|
||||
*/
|
||||
void addDialog(Dialog* d);
|
||||
int addDialog(Dialog* d);
|
||||
|
||||
/**
|
||||
Remove the topmost dialog box from the stack.
|
||||
|
|
Loading…
Reference in New Issue