fixed rendering, all dialogs are always re-rendered

This commit is contained in:
thrust26 2020-11-13 08:58:19 +01:00
parent e39be62c54
commit 4061dee480
10 changed files with 139 additions and 33 deletions

View File

@ -88,9 +88,14 @@ class FrameBuffer
/**
There is a dedicated update method for emulation mode.
*/
*/
void updateInEmulationMode(float framesPerSecond);
/**
Render backend to screen.
*/
void renderToScreen() { myBackend->renderToScreen(); }
/**
Shows a text message onscreen.

View File

@ -110,8 +110,6 @@ void Dialog::open()
loadConfig(); // has to be done AFTER (re)building the focus list
_visible = true;
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -227,12 +225,14 @@ void Dialog::redraw()
// Draw this dialog
setPosition();
drawDialog();
render();
// full rendering is caused in dialog container
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::render()
{
cerr << " render " << typeid(*this).name() << endl;
// Update dialog surface; also render any extra surfaces
// Extra surfaces must be rendered afterwards, so they are drawn on top
if(_surface->render())
@ -242,15 +242,17 @@ void Dialog::render()
});
}
//cerr << "is ContextMenu "
// << (typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)) << endl;
// Dialog is still on top if e.g a dialog without title is opened
// (e.g. ContextMenu)
bool onTop = parent().myDialogStack.top() == this
|| (parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
&& !parent().myDialogStack.top()->hasTitle());
//&& typeid(*parent().myDialogStack.top()) == typeid(ContextMenu))
// Dialog is still on top if e.g a ContextMenu is opened
if(!(parent().myDialogStack.top() == this)
&& !((parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
//&& !(typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)))
&& !parent().myDialogStack.top()->hasTitle())))
if(!onTop)
{
cerr << " shade " << typeid(*this).name() << endl;
if(_shadeSurface == nullptr)
{
uInt32 data = 0xff000000;

View File

@ -119,6 +119,10 @@ class Dialog : public GuiObject
*/
bool shouldResize(uInt32& w, uInt32& h) const;
//bool enableToolTip();
//void showToolTip(int x, int y);
//void hideToolTip();
protected:
void draw() override { }
void releaseFocus() override;
@ -197,6 +201,7 @@ class Dialog : public GuiObject
string _title;
int _th{0};
int _layer{0};
int _toolTipTimer{0};
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;

View File

@ -97,14 +97,16 @@ void DialogContainer::draw(bool full)
cerr << "draw " << full << " " << typeid(*this).name() << endl;
// Make the top dialog dirty if a full redraw is requested
if(full)
myDialogStack.top()->setDirty();
//if(full)
// myDialogStack.top()->setDirty();
// Draw and render all dirty dialogs
myDialogStack.applyAll([&](Dialog*& d) {
if(d->needsRedraw())
d->redraw();
});
// Always render all surfaces, bottom to top
render();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -120,9 +122,9 @@ void DialogContainer::render()
if(myDialogStack.empty())
return;
cerr << "render " << typeid(*this).name() << endl;
cerr << "full re-render " << typeid(*this).name() << endl;
// Render all dirty dialogs
// Render all dialogs
myDialogStack.applyAll([&](Dialog*& d) {
d->render();
});
@ -153,10 +155,6 @@ int DialogContainer::addDialog(Dialog* d)
"Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
else
{
//// "shade" current top dialog
//if(!myDialogStack.empty())
// myDialogStack.top()->setDirty();
d->setDirty();
myDialogStack.push(d);
}
@ -168,20 +166,16 @@ void DialogContainer::removeDialog()
{
if(!myDialogStack.empty())
{
cerr << "remove dialog" << endl;
myDialogStack.pop();
if(!myDialogStack.empty())
{
//// this "unshades" the top dialog
//myDialogStack.top()->setDirty();
// Rerender all dialogs (TODO: top dialog is rendered twice)
// Rerender all dialogs
myDialogStack.applyAll([&](Dialog*& d){
//d->setDirty();
d->render();
d->render();
});
// TODO: the screen is not updated until an event happens
// FrameBuffer::myBackend->renderToScreen() doesn't help
myOSystem.frameBuffer().renderToScreen();
}
}
}

40
src/gui/ToolTip.cxx Normal file
View File

@ -0,0 +1,40 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "OSystem.hxx"
#include "Font.hxx"
#include "Dialog.hxx"
#include "DialogContainer.hxx"
#include "ToolTip.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ToolTip::ToolTip(OSystem& instance, DialogContainer& parent,
const GUI::Font& font)
: Dialog(instance, parent, font)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(),
buttonWidth = font.getStringWidth("Previous") + fontWidth * 2.5,
buttonHeight = font.getLineHeight() * 1.25;
const int VBORDER = fontHeight / 2;
const int HBORDER = fontWidth * 1.25;
const int VGAP = fontHeight / 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

39
src/gui/ToolTip.hxx Normal file
View File

@ -0,0 +1,39 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef TOOL_TIP_HXX
#define TOOL_TIP_HXX
class OSystem;
class DialogContainer;
/**
* Class for providing tooltip functionality
*
* @author Thomas Jentzsch
*/
class ToolTip : public Dialog
{
public:
public:
ToolTip(OSystem& instance, DialogContainer& parent,
const GUI::Font& font);
~ToolTip() override = default;
};
#endif

View File

@ -71,13 +71,22 @@ bool Widget::isChainDirty() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::tick()
{
// Recursively tick widget and all child dialogs and widgets
Widget* w = _firstWidget;
while(w)
if(isEnabled())
{
w->tick();
w = w->_next;
//if(_hasFocus && hasToolTip())
//{
// if(dialog().enableToolTip())
// dialog().showToolTip(10, 10);
//}
// Recursively tick widget and all child dialogs and widgets
Widget* w = _firstWidget;
while(w)
{
w->tick();
w = w->_next;
}
}
}

View File

@ -99,6 +99,9 @@ class Widget : public GuiObject
void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); }
void setShadowColor(ColorId color) { _shadowcolor = color; setDirty(); }
void setToolTip(const string& text) { _toolTipText = text; }
bool hasToolTip() const { return !_toolTipText.empty(); }
virtual void loadConfig() { }
protected:
@ -130,6 +133,7 @@ class Widget : public GuiObject
ColorId _textcolorhi{kTextColorHi};
ColorId _textcolorlo{kBGColorLo};
ColorId _shadowcolor{kShadowColor};
string _toolTipText;
public:
static Widget* findWidgetInChain(Widget* start, int x, int y);

View File

@ -786,6 +786,7 @@
<ClCompile Include="..\gui\TimeLineWidget.cxx" />
<ClCompile Include="..\gui\TimeMachine.cxx" />
<ClCompile Include="..\gui\TimeMachineDialog.cxx" />
<ClCompile Include="..\gui\ToolTip.cxx" />
<ClCompile Include="..\gui\UndoHandler.cxx" />
<ClCompile Include="..\gui\WhatsNewDialog.cxx" />
<ClCompile Include="FSNodeWINDOWS.cxx" />
@ -1838,6 +1839,7 @@
<ClInclude Include="..\gui\TimeLineWidget.hxx" />
<ClInclude Include="..\gui\TimeMachine.hxx" />
<ClInclude Include="..\gui\TimeMachineDialog.hxx" />
<ClInclude Include="..\gui\ToolTip.hxx" />
<ClInclude Include="..\gui\UndoHandler.hxx" />
<ClInclude Include="..\gui\WhatsNewDialog.hxx" />
<ClInclude Include="..\libpng\pngdebug.h" />

View File

@ -1032,6 +1032,9 @@
<ClCompile Include="..\gui\UndoHandler.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
<ClCompile Include="..\gui\ToolTip.cxx">
<Filter>Source Files\gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -2123,6 +2126,9 @@
<ClInclude Include="..\gui\UndoHandler.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
<ClInclude Include="..\gui\ToolTip.hxx">
<Filter>Header Files\gui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">