mirror of https://github.com/stella-emu/stella.git
fixed rendering, all dialogs are always re-rendered
This commit is contained in:
parent
e39be62c54
commit
4061dee480
|
@ -88,9 +88,14 @@ class FrameBuffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
There is a dedicated update method for emulation mode.
|
There is a dedicated update method for emulation mode.
|
||||||
*/
|
*/
|
||||||
void updateInEmulationMode(float framesPerSecond);
|
void updateInEmulationMode(float framesPerSecond);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Render backend to screen.
|
||||||
|
*/
|
||||||
|
void renderToScreen() { myBackend->renderToScreen(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Shows a text message onscreen.
|
Shows a text message onscreen.
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,6 @@ void Dialog::open()
|
||||||
loadConfig(); // has to be done AFTER (re)building the focus list
|
loadConfig(); // has to be done AFTER (re)building the focus list
|
||||||
|
|
||||||
_visible = true;
|
_visible = true;
|
||||||
|
|
||||||
setDirty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -227,12 +225,14 @@ void Dialog::redraw()
|
||||||
// Draw this dialog
|
// Draw this dialog
|
||||||
setPosition();
|
setPosition();
|
||||||
drawDialog();
|
drawDialog();
|
||||||
render();
|
// full rendering is caused in dialog container
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Dialog::render()
|
void Dialog::render()
|
||||||
{
|
{
|
||||||
|
cerr << " render " << typeid(*this).name() << endl;
|
||||||
|
|
||||||
// Update dialog surface; also render any extra surfaces
|
// Update dialog surface; also render any extra surfaces
|
||||||
// Extra surfaces must be rendered afterwards, so they are drawn on top
|
// Extra surfaces must be rendered afterwards, so they are drawn on top
|
||||||
if(_surface->render())
|
if(_surface->render())
|
||||||
|
@ -242,15 +242,17 @@ void Dialog::render()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//cerr << "is ContextMenu "
|
// Dialog is still on top if e.g a dialog without title is opened
|
||||||
// << (typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)) << endl;
|
// (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(!onTop)
|
||||||
if(!(parent().myDialogStack.top() == this)
|
|
||||||
&& !((parent().myDialogStack.get(parent().myDialogStack.size() - 2) == this
|
|
||||||
//&& !(typeid(*parent().myDialogStack.top()) == typeid(ContextMenu)))
|
|
||||||
&& !parent().myDialogStack.top()->hasTitle())))
|
|
||||||
{
|
{
|
||||||
|
cerr << " shade " << typeid(*this).name() << endl;
|
||||||
|
|
||||||
if(_shadeSurface == nullptr)
|
if(_shadeSurface == nullptr)
|
||||||
{
|
{
|
||||||
uInt32 data = 0xff000000;
|
uInt32 data = 0xff000000;
|
||||||
|
|
|
@ -119,6 +119,10 @@ class Dialog : public GuiObject
|
||||||
*/
|
*/
|
||||||
bool shouldResize(uInt32& w, uInt32& h) const;
|
bool shouldResize(uInt32& w, uInt32& h) const;
|
||||||
|
|
||||||
|
//bool enableToolTip();
|
||||||
|
//void showToolTip(int x, int y);
|
||||||
|
//void hideToolTip();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void draw() override { }
|
void draw() override { }
|
||||||
void releaseFocus() override;
|
void releaseFocus() override;
|
||||||
|
@ -197,6 +201,7 @@ class Dialog : public GuiObject
|
||||||
string _title;
|
string _title;
|
||||||
int _th{0};
|
int _th{0};
|
||||||
int _layer{0};
|
int _layer{0};
|
||||||
|
int _toolTipTimer{0};
|
||||||
|
|
||||||
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;
|
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;
|
||||||
|
|
||||||
|
|
|
@ -97,14 +97,16 @@ void DialogContainer::draw(bool full)
|
||||||
cerr << "draw " << full << " " << typeid(*this).name() << endl;
|
cerr << "draw " << full << " " << typeid(*this).name() << endl;
|
||||||
|
|
||||||
// Make the top dialog dirty if a full redraw is requested
|
// Make the top dialog dirty if a full redraw is requested
|
||||||
if(full)
|
//if(full)
|
||||||
myDialogStack.top()->setDirty();
|
// myDialogStack.top()->setDirty();
|
||||||
|
|
||||||
// Draw and render all dirty dialogs
|
// Draw and render all dirty dialogs
|
||||||
myDialogStack.applyAll([&](Dialog*& d) {
|
myDialogStack.applyAll([&](Dialog*& d) {
|
||||||
if(d->needsRedraw())
|
if(d->needsRedraw())
|
||||||
d->redraw();
|
d->redraw();
|
||||||
});
|
});
|
||||||
|
// Always render all surfaces, bottom to top
|
||||||
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -120,9 +122,9 @@ void DialogContainer::render()
|
||||||
if(myDialogStack.empty())
|
if(myDialogStack.empty())
|
||||||
return;
|
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) {
|
myDialogStack.applyAll([&](Dialog*& d) {
|
||||||
d->render();
|
d->render();
|
||||||
});
|
});
|
||||||
|
@ -153,10 +155,6 @@ int DialogContainer::addDialog(Dialog* d)
|
||||||
"Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
|
"Unable to show dialog box; FIX THE CODE", MessagePosition::BottomCenter, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//// "shade" current top dialog
|
|
||||||
//if(!myDialogStack.empty())
|
|
||||||
// myDialogStack.top()->setDirty();
|
|
||||||
|
|
||||||
d->setDirty();
|
d->setDirty();
|
||||||
myDialogStack.push(d);
|
myDialogStack.push(d);
|
||||||
}
|
}
|
||||||
|
@ -168,20 +166,16 @@ void DialogContainer::removeDialog()
|
||||||
{
|
{
|
||||||
if(!myDialogStack.empty())
|
if(!myDialogStack.empty())
|
||||||
{
|
{
|
||||||
|
cerr << "remove dialog" << endl;
|
||||||
myDialogStack.pop();
|
myDialogStack.pop();
|
||||||
|
|
||||||
if(!myDialogStack.empty())
|
if(!myDialogStack.empty())
|
||||||
{
|
{
|
||||||
//// this "unshades" the top dialog
|
// Rerender all dialogs
|
||||||
//myDialogStack.top()->setDirty();
|
|
||||||
|
|
||||||
// Rerender all dialogs (TODO: top dialog is rendered twice)
|
|
||||||
myDialogStack.applyAll([&](Dialog*& d){
|
myDialogStack.applyAll([&](Dialog*& d){
|
||||||
//d->setDirty();
|
d->render();
|
||||||
d->render();
|
|
||||||
});
|
});
|
||||||
// TODO: the screen is not updated until an event happens
|
myOSystem.frameBuffer().renderToScreen();
|
||||||
// FrameBuffer::myBackend->renderToScreen() doesn't help
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
@ -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
|
|
@ -71,13 +71,22 @@ bool Widget::isChainDirty() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Widget::tick()
|
void Widget::tick()
|
||||||
{
|
{
|
||||||
// Recursively tick widget and all child dialogs and widgets
|
if(isEnabled())
|
||||||
Widget* w = _firstWidget;
|
|
||||||
|
|
||||||
while(w)
|
|
||||||
{
|
{
|
||||||
w->tick();
|
//if(_hasFocus && hasToolTip())
|
||||||
w = w->_next;
|
//{
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,9 @@ class Widget : public GuiObject
|
||||||
void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); }
|
void setBGColorHi(ColorId color) { _bgcolorhi = color; setDirty(); }
|
||||||
void setShadowColor(ColorId color) { _shadowcolor = 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() { }
|
virtual void loadConfig() { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -130,6 +133,7 @@ class Widget : public GuiObject
|
||||||
ColorId _textcolorhi{kTextColorHi};
|
ColorId _textcolorhi{kTextColorHi};
|
||||||
ColorId _textcolorlo{kBGColorLo};
|
ColorId _textcolorlo{kBGColorLo};
|
||||||
ColorId _shadowcolor{kShadowColor};
|
ColorId _shadowcolor{kShadowColor};
|
||||||
|
string _toolTipText;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Widget* findWidgetInChain(Widget* start, int x, int y);
|
static Widget* findWidgetInChain(Widget* start, int x, int y);
|
||||||
|
|
|
@ -786,6 +786,7 @@
|
||||||
<ClCompile Include="..\gui\TimeLineWidget.cxx" />
|
<ClCompile Include="..\gui\TimeLineWidget.cxx" />
|
||||||
<ClCompile Include="..\gui\TimeMachine.cxx" />
|
<ClCompile Include="..\gui\TimeMachine.cxx" />
|
||||||
<ClCompile Include="..\gui\TimeMachineDialog.cxx" />
|
<ClCompile Include="..\gui\TimeMachineDialog.cxx" />
|
||||||
|
<ClCompile Include="..\gui\ToolTip.cxx" />
|
||||||
<ClCompile Include="..\gui\UndoHandler.cxx" />
|
<ClCompile Include="..\gui\UndoHandler.cxx" />
|
||||||
<ClCompile Include="..\gui\WhatsNewDialog.cxx" />
|
<ClCompile Include="..\gui\WhatsNewDialog.cxx" />
|
||||||
<ClCompile Include="FSNodeWINDOWS.cxx" />
|
<ClCompile Include="FSNodeWINDOWS.cxx" />
|
||||||
|
@ -1838,6 +1839,7 @@
|
||||||
<ClInclude Include="..\gui\TimeLineWidget.hxx" />
|
<ClInclude Include="..\gui\TimeLineWidget.hxx" />
|
||||||
<ClInclude Include="..\gui\TimeMachine.hxx" />
|
<ClInclude Include="..\gui\TimeMachine.hxx" />
|
||||||
<ClInclude Include="..\gui\TimeMachineDialog.hxx" />
|
<ClInclude Include="..\gui\TimeMachineDialog.hxx" />
|
||||||
|
<ClInclude Include="..\gui\ToolTip.hxx" />
|
||||||
<ClInclude Include="..\gui\UndoHandler.hxx" />
|
<ClInclude Include="..\gui\UndoHandler.hxx" />
|
||||||
<ClInclude Include="..\gui\WhatsNewDialog.hxx" />
|
<ClInclude Include="..\gui\WhatsNewDialog.hxx" />
|
||||||
<ClInclude Include="..\libpng\pngdebug.h" />
|
<ClInclude Include="..\libpng\pngdebug.h" />
|
||||||
|
|
|
@ -1032,6 +1032,9 @@
|
||||||
<ClCompile Include="..\gui\UndoHandler.cxx">
|
<ClCompile Include="..\gui\UndoHandler.cxx">
|
||||||
<Filter>Source Files\gui</Filter>
|
<Filter>Source Files\gui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\gui\ToolTip.cxx">
|
||||||
|
<Filter>Source Files\gui</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\common\bspf.hxx">
|
<ClInclude Include="..\common\bspf.hxx">
|
||||||
|
@ -2123,6 +2126,9 @@
|
||||||
<ClInclude Include="..\gui\UndoHandler.hxx">
|
<ClInclude Include="..\gui\UndoHandler.hxx">
|
||||||
<Filter>Header Files\gui</Filter>
|
<Filter>Header Files\gui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\gui\ToolTip.hxx">
|
||||||
|
<Filter>Header Files\gui</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="stella.ico">
|
<None Include="stella.ico">
|
||||||
|
|
Loading…
Reference in New Issue