improve dialog stacking

This commit is contained in:
thrust26 2019-05-05 08:55:24 +02:00
parent ed5f8cb9de
commit 60260843ff
4 changed files with 13 additions and 9 deletions

View File

@ -64,7 +64,8 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
_tabID(0), _tabID(0),
_flags(Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG), _flags(Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG),
_max_w(0), _max_w(0),
_max_h(0) _max_h(0),
_layer(0)
{ {
setTitle(title); setTitle(title);
setDirty(); setDirty();
@ -97,7 +98,7 @@ void Dialog::open()
// dialogs cause drawing to occur within loadConfig() // dialogs cause drawing to occur within loadConfig()
if (_surface == nullptr) if (_surface == nullptr)
_surface = instance().frameBuffer().allocateSurface(_w, _h); _surface = instance().frameBuffer().allocateSurface(_w, _h);
parent().addDialog(this); _layer = parent().addDialog(this);
center(); center();
@ -164,11 +165,12 @@ void Dialog::positionAt(uInt32 pos)
{ {
const Common::Size& screen = instance().frameBuffer().screenSize(); const Common::Size& screen = instance().frameBuffer().screenSize();
const Common::Rect& dst = _surface->dstRect(); const Common::Rect& dst = _surface->dstRect();
// shift stacked dialogs
int top = std::min(screen.h - dst.height(), screen.h >> 5); uInt32 gap = (screen.w >> 6) * _layer;
int btm = std::min(screen.h - dst.height(), screen.h - dst.height() - (screen.h >> 5)); int top = std::min(screen.h - dst.height(), gap);
int left = std::min(screen.w - dst.width(), screen.w >> 5); int btm = std::min(screen.h - dst.height(), screen.h - dst.height() - gap);
int right = std::min(screen.w - dst.width(), screen.w - dst.width() - (screen.w >> 5)); int left = std::min(screen.w - dst.width(), gap);
int right = std::min(screen.w - dst.width(), screen.w - dst.width() - gap);
switch (pos) switch (pos)
{ {

View File

@ -186,6 +186,7 @@ class Dialog : public GuiObject
bool _processCancel; bool _processCancel;
string _title; string _title;
int _th; int _th;
int _layer;
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack; Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;

View File

@ -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(); const Common::Rect& r = myOSystem.frameBuffer().imageRect();
if(uInt32(d->getWidth()) > r.width() || uInt32(d->getHeight()) > r.height()) if(uInt32(d->getWidth()) > r.width() || uInt32(d->getHeight()) > r.height())
@ -137,6 +137,7 @@ void DialogContainer::addDialog(Dialog* d)
d->setDirty(); d->setDirty();
myDialogStack.push(d); myDialogStack.push(d);
} }
return myDialogStack.size();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -160,7 +160,7 @@ class DialogContainer
/** /**
Add a dialog box to the stack. Add a dialog box to the stack.
*/ */
void addDialog(Dialog* d); int addDialog(Dialog* d);
/** /**
Remove the topmost dialog box from the stack. Remove the topmost dialog box from the stack.