diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 9cb5accb2..6f8867cfb 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -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()); diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index b9a924b55..d5405ef70 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -230,6 +230,7 @@ class Dialog : public GuiObject WidgetArray _buttonGroup; shared_ptr _surface; + shared_ptr _shadeSurface; int _tabID{0}; uInt32 _max_w{0}; // maximum wanted width diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 77e163e83..98deae834 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -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 } } }