mirror of https://github.com/stella-emu/stella.git
replaced shaded UI redraws with shading surface
This commit is contained in:
parent
3063752f60
commit
090c480e1a
|
@ -227,8 +227,6 @@ void Dialog::redraw()
|
|||
center();
|
||||
drawDialog();
|
||||
render();
|
||||
|
||||
// return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -242,6 +240,28 @@ void Dialog::render()
|
|||
surface->render();
|
||||
});
|
||||
}
|
||||
if(parent().myDialogStack.top() != this)
|
||||
{
|
||||
if(_shadeSurface == nullptr)
|
||||
{
|
||||
uInt32 data = 0xff000000;
|
||||
|
||||
_shadeSurface = instance().frameBuffer().allocateSurface(
|
||||
1, 1, ScalingInterpolation::sharp, &data);
|
||||
|
||||
FBSurface::Attributes& attr = _shadeSurface->attributes();
|
||||
|
||||
attr.blending = true;
|
||||
attr.blendalpha = 25; // darken background dialogs by 25%
|
||||
_shadeSurface->applyAttributes();
|
||||
}
|
||||
|
||||
const Common::Rect& rect = _surface->dstRect();
|
||||
_shadeSurface->setDstPos(rect.x(), rect.y());
|
||||
_shadeSurface->setDstSize(rect.w(), rect.h());
|
||||
|
||||
_shadeSurface->render();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -408,7 +428,7 @@ void Dialog::drawDialog()
|
|||
//cerr << "*** draw dialog " << typeid(*this).name() << " ***" << endl;
|
||||
|
||||
// Dialog is still on top if e.g a ContextMenu is opened
|
||||
_onTop = parent().myDialogStack.top() == this
|
||||
_onTop = true/*parent().myDialogStack.top() == this*/
|
||||
|| (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
|
||||
&& !parent().myDialogStack.top()->hasTitle());
|
||||
|
||||
|
|
|
@ -230,6 +230,7 @@ class Dialog : public GuiObject
|
|||
|
||||
WidgetArray _buttonGroup;
|
||||
shared_ptr<FBSurface> _surface;
|
||||
shared_ptr<FBSurface> _shadeSurface;
|
||||
|
||||
int _tabID{0};
|
||||
uInt32 _max_w{0}; // maximum wanted width
|
||||
|
|
|
@ -146,9 +146,10 @@ int DialogContainer::addDialog(Dialog* d)
|
|||
"Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
|
||||
else
|
||||
{
|
||||
// "darken" current top dialog
|
||||
if(!myDialogStack.empty())
|
||||
myDialogStack.top()->setDirty();
|
||||
//// "shade" current top dialog
|
||||
//if(!myDialogStack.empty())
|
||||
// myDialogStack.top()->setDirty();
|
||||
|
||||
d->setDirty();
|
||||
myDialogStack.push(d);
|
||||
}
|
||||
|
@ -164,14 +165,16 @@ void DialogContainer::removeDialog()
|
|||
|
||||
if(!myDialogStack.empty())
|
||||
{
|
||||
// this "undarkens" the top dialog
|
||||
myDialogStack.top()->setDirty();
|
||||
//// this "unshades" the top dialog
|
||||
//myDialogStack.top()->setDirty();
|
||||
|
||||
// Rerender all dialogs (TODO: top dialog is rendered twice)
|
||||
myDialogStack.applyAll([&](Dialog*& d){
|
||||
//d->setDirty();
|
||||
d->render();
|
||||
});
|
||||
// TODO: the screen is not updated until an event happens
|
||||
// FrameBuffer::myBackend->renderToScreen() doesn't help
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue