mirror of https://github.com/stella-emu/stella.git
generic shadowed char/string drawing added
TimeMachineDialog fully transparent now (experimental) info stats indicates scanline/frame rate changes in red
This commit is contained in:
parent
72ff2a40fa
commit
6f7ff023a6
|
@ -154,8 +154,15 @@ void FBSurface::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, uInt32 color)
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
|
void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
|
||||||
uInt32 tx, uInt32 ty, uInt32 color)
|
uInt32 tx, uInt32 ty, uInt32 color, uInt32 shadowColor)
|
||||||
{
|
{
|
||||||
|
if(shadowColor != 0)
|
||||||
|
{
|
||||||
|
drawChar(font, chr, tx + 1, ty + 0, shadowColor);
|
||||||
|
drawChar(font, chr, tx + 0, ty + 1, shadowColor);
|
||||||
|
drawChar(font, chr, tx + 1, ty + 1, shadowColor);
|
||||||
|
}
|
||||||
|
|
||||||
const FontDesc& desc = font.desc();
|
const FontDesc& desc = font.desc();
|
||||||
|
|
||||||
// If this character is not included in the font, use the default char.
|
// If this character is not included in the font, use the default char.
|
||||||
|
@ -300,7 +307,7 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
||||||
void FBSurface::drawString(const GUI::Font& font, const string& s,
|
void FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||||
int x, int y, int w,
|
int x, int y, int w,
|
||||||
uInt32 color, TextAlign align,
|
uInt32 color, TextAlign align,
|
||||||
int deltax, bool useEllipsis)
|
int deltax, bool useEllipsis, uInt32 shadowColor)
|
||||||
{
|
{
|
||||||
const string ELLIPSIS = "\x1d"; // "..."
|
const string ELLIPSIS = "\x1d"; // "..."
|
||||||
const int leftX = x, rightX = x + w;
|
const int leftX = x, rightX = x + w;
|
||||||
|
@ -367,7 +374,7 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||||
if(x+w > rightX)
|
if(x+w > rightX)
|
||||||
break;
|
break;
|
||||||
if(x >= leftX)
|
if(x >= leftX)
|
||||||
drawChar(font, str[i], x, y, color);
|
drawChar(font, str[i], x, y, color, shadowColor);
|
||||||
|
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ class FBSurface
|
||||||
@param color The color of the character
|
@param color The color of the character
|
||||||
*/
|
*/
|
||||||
virtual void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y,
|
virtual void drawChar(const GUI::Font& font, uInt8 c, uInt32 x, uInt32 y,
|
||||||
uInt32 color);
|
uInt32 color, uInt32 shadowColor = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method should be called to draw the bitmap image.
|
This method should be called to draw the bitmap image.
|
||||||
|
@ -217,7 +217,7 @@ class FBSurface
|
||||||
virtual void drawString(
|
virtual void drawString(
|
||||||
const GUI::Font& font, const string& s, int x, int y, int w,
|
const GUI::Font& font, const string& s, int x, int y, int w,
|
||||||
uInt32 color, TextAlign align = TextAlign::Left,
|
uInt32 color, TextAlign align = TextAlign::Left,
|
||||||
int deltax = 0, bool useEllipsis = true);
|
int deltax = 0, bool useEllipsis = true, uInt32 shadowColor = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method should be called to indicate that the surface has been
|
This method should be called to indicate that the surface has been
|
||||||
|
|
|
@ -229,7 +229,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
||||||
|
|
||||||
// Create surfaces for TIA statistics and general messages
|
// Create surfaces for TIA statistics and general messages
|
||||||
myStatsMsg.color = kColorInfo;
|
myStatsMsg.color = kColorInfo;
|
||||||
myStatsMsg.w = infoFont().getMaxCharWidth() * 24 + 2;
|
myStatsMsg.w = infoFont().getMaxCharWidth() * 30 + 2;
|
||||||
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
||||||
|
|
||||||
if(!myStatsMsg.surface)
|
if(!myStatsMsg.surface)
|
||||||
|
@ -288,33 +288,32 @@ void FrameBuffer::update()
|
||||||
{
|
{
|
||||||
const ConsoleInfo& info = myOSystem.console().about();
|
const ConsoleInfo& info = myOSystem.console().about();
|
||||||
char msg[30];
|
char msg[30];
|
||||||
std::snprintf(msg, 30, "%3u @ %3.2ffps => %s",
|
uInt32 color;
|
||||||
myOSystem.console().tia().scanlinesLastFrame(),
|
|
||||||
myOSystem.console().getFramerate(), info.DisplayFormat.c_str());
|
|
||||||
myStatsMsg.surface->invalidate();
|
myStatsMsg.surface->invalidate();
|
||||||
string bsinfo = info.BankSwitch +
|
string bsinfo = info.BankSwitch +
|
||||||
(myOSystem.settings().getBool("dev.settings") ? "| Developer" : "| Player");
|
(myOSystem.settings().getBool("dev.settings") ? "| Developer" : "| Player");
|
||||||
// draw shadowed text
|
// draw shadowed text
|
||||||
myStatsMsg.surface->drawString(infoFont(), msg, 1 + 1, 1 + 0,
|
color = myOSystem.console().tia().scanlinesLastFrame() != myLastScanlines ? kDbgColorRed : myStatsMsg.color;
|
||||||
myStatsMsg.w, kBGColor);
|
std::snprintf(msg, 30, "%3u", myOSystem.console().tia().scanlinesLastFrame());
|
||||||
myStatsMsg.surface->drawString(infoFont(), msg, 1 + 0, 1 + 1,
|
|
||||||
myStatsMsg.w, kBGColor);
|
|
||||||
myStatsMsg.surface->drawString(infoFont(), msg, 1 + 1, 1 + 1,
|
|
||||||
myStatsMsg.w, kBGColor);
|
|
||||||
myStatsMsg.surface->drawString(infoFont(), msg, 1, 1,
|
myStatsMsg.surface->drawString(infoFont(), msg, 1, 1,
|
||||||
myStatsMsg.w, myStatsMsg.color);
|
myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor);
|
||||||
myStatsMsg.surface->drawString(infoFont(), bsinfo, 1 + 1, 15 + 0,
|
color = myOSystem.console().getFramerate() != myLastFrameRate ? kDbgColorRed : myStatsMsg.color;
|
||||||
myStatsMsg.w, kBGColor);
|
std::snprintf(msg, 30, "@ %3.2ffps", myOSystem.console().getFramerate());
|
||||||
myStatsMsg.surface->drawString(infoFont(), bsinfo, 1 + 0, 15 + 1,
|
myStatsMsg.surface->drawString(infoFont(), msg, 1 + infoFont().getStringWidth("262 "), 1,
|
||||||
myStatsMsg.w, kBGColor);
|
myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor);
|
||||||
myStatsMsg.surface->drawString(infoFont(), bsinfo, 1 + 1, 15 + 1,
|
std::snprintf(msg, 30, "=> %s", info.DisplayFormat.c_str());
|
||||||
myStatsMsg.w, kBGColor);
|
myStatsMsg.surface->drawString(infoFont(), msg, 1+ infoFont().getStringWidth("262 @ 60.00fps "), 1,
|
||||||
|
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
|
||||||
|
|
||||||
myStatsMsg.surface->drawString(infoFont(), bsinfo, 1, 15,
|
myStatsMsg.surface->drawString(infoFont(), bsinfo, 1, 15,
|
||||||
myStatsMsg.w, myStatsMsg.color);
|
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
|
||||||
myStatsMsg.surface->setDirty();
|
myStatsMsg.surface->setDirty();
|
||||||
myStatsMsg.surface->setDstPos(myImageRect.x() + 1, myImageRect.y() + 1);
|
myStatsMsg.surface->setDstPos(myImageRect.x() + 1, myImageRect.y() + 1);
|
||||||
myStatsMsg.surface->render();
|
myStatsMsg.surface->render();
|
||||||
}
|
}
|
||||||
|
myLastScanlines = myOSystem.console().tia().scanlinesLastFrame();
|
||||||
|
myLastFrameRate = myOSystem.console().getFramerate();
|
||||||
myPausedCount = 0;
|
myPausedCount = 0;
|
||||||
break; // EventHandlerState::EMULATION
|
break; // EventHandlerState::EMULATION
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,6 +510,9 @@ class FrameBuffer
|
||||||
Message myMsg;
|
Message myMsg;
|
||||||
Message myStatsMsg;
|
Message myStatsMsg;
|
||||||
bool myStatsEnabled;
|
bool myStatsEnabled;
|
||||||
|
uInt32 myLastScanlines;
|
||||||
|
float myLastFrameRate;
|
||||||
|
|
||||||
|
|
||||||
bool myGrabMouse;
|
bool myGrabMouse;
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,8 @@ void Dialog::drawDialog()
|
||||||
if(_flags & WIDGET_CLEARBG)
|
if(_flags & WIDGET_CLEARBG)
|
||||||
// cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl;
|
// cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << " @ " << &s << endl << endl;
|
||||||
s.fillRect(_x, _y, _w, _h, kDlgColor);
|
s.fillRect(_x, _y, _w, _h, kDlgColor);
|
||||||
|
else
|
||||||
|
s.invalidate();
|
||||||
if(_flags & WIDGET_BORDER)
|
if(_flags & WIDGET_BORDER)
|
||||||
#ifndef FLAT_UI
|
#ifndef FLAT_UI
|
||||||
s.box(_x, _y, _w, _h, kColor, kShadowColor);
|
s.box(_x, _y, _w, _h, kColor, kShadowColor);
|
||||||
|
|
|
@ -193,23 +193,26 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
_w = 20 * (buttonWidth + BUTTON_GAP) + 20;
|
_w = 20 * (buttonWidth + BUTTON_GAP) + 20;
|
||||||
_h = V_BORDER * 2 + rowHeight + buttonHeight + 2;
|
_h = V_BORDER * 2 + rowHeight + buttonHeight + 2;
|
||||||
|
|
||||||
//this->clearFlags(WIDGET_CLEARBG); // does only work combined with blending!
|
this->clearFlags(WIDGET_CLEARBG); // does only work combined with blending (0..100)!
|
||||||
//this->clearFlags(WIDGET_BORDER);
|
this->clearFlags(WIDGET_BORDER);
|
||||||
|
|
||||||
xpos = H_BORDER;
|
xpos = H_BORDER;
|
||||||
ypos = V_BORDER;
|
ypos = V_BORDER;
|
||||||
|
|
||||||
// Add index info
|
// Add index info
|
||||||
myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, " ");
|
myCurrentIdxWidget = new StaticTextWidget(this, font, xpos, ypos, " ", TextAlign::Left, kBGColor);
|
||||||
|
myCurrentIdxWidget->setTextColor(kWidColor);
|
||||||
myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("8888"), ypos,
|
myLastIdxWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("8888"), ypos,
|
||||||
" ", TextAlign::Right);
|
" ", TextAlign::Right, kBGColor);
|
||||||
|
myLastIdxWidget->setTextColor(kWidColor);
|
||||||
ypos += rowHeight;
|
ypos += rowHeight;
|
||||||
|
|
||||||
// Add time info
|
// Add time info
|
||||||
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos + 3, "04:32 59");
|
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos + 3, "04:32 59", TextAlign::Left, kBGColor);
|
||||||
//myCurrentTimeWidget->setFlags(WIDGET_CLEARBG);
|
myCurrentTimeWidget->setTextColor(kWidColor);
|
||||||
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("XX:XX XX"), ypos + 3,
|
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("XX:XX XX"), ypos + 3,
|
||||||
"12:25 59");
|
"12:25 59", TextAlign::Right, kBGColor);
|
||||||
|
myLastTimeWidget->setTextColor(kWidColor);
|
||||||
xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4;
|
xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4;
|
||||||
|
|
||||||
// Add buttons
|
// Add buttons
|
||||||
|
@ -253,7 +256,9 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 3;
|
xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 3;
|
||||||
|
|
||||||
// Add message
|
// Add message
|
||||||
myMessageWidget = new StaticTextWidget(this, font, xpos, ypos + 3, " ");
|
myMessageWidget = new StaticTextWidget(this, font, xpos, ypos + 3, " ",
|
||||||
|
TextAlign::Left, kBGColor);
|
||||||
|
myMessageWidget->setTextColor(kWidColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -304,7 +304,8 @@ void Widget::setDirtyInChain(Widget* start)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, int w, int h,
|
int x, int y, int w, int h,
|
||||||
const string& text, TextAlign align)
|
const string& text, TextAlign align,
|
||||||
|
uInt32 shadowColor)
|
||||||
: Widget(boss, font, x, y, w, h),
|
: Widget(boss, font, x, y, w, h),
|
||||||
_align(align)
|
_align(align)
|
||||||
{
|
{
|
||||||
|
@ -313,6 +314,7 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
_bgcolorhi = kDlgColor;
|
_bgcolorhi = kDlgColor;
|
||||||
_textcolor = kTextColor;
|
_textcolor = kTextColor;
|
||||||
_textcolorhi = kTextColor;
|
_textcolorhi = kTextColor;
|
||||||
|
_shadowcolor = shadowColor;
|
||||||
|
|
||||||
_label = text;
|
_label = text;
|
||||||
_editable = false;
|
_editable = false;
|
||||||
|
@ -321,8 +323,9 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
const string& text, TextAlign align)
|
const string& text, TextAlign align,
|
||||||
: StaticTextWidget(boss, font, x, y, font.getStringWidth(text), font.getLineHeight(), text, align)
|
uInt32 shadowColor)
|
||||||
|
: StaticTextWidget(boss, font, x, y, font.getStringWidth(text), font.getLineHeight(), text, align, shadowColor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +352,7 @@ void StaticTextWidget::drawWidget(bool hilite)
|
||||||
{
|
{
|
||||||
FBSurface& s = _boss->dialog().surface();
|
FBSurface& s = _boss->dialog().surface();
|
||||||
s.drawString(_font, _label, _x, _y, _w,
|
s.drawString(_font, _label, _x, _y, _w,
|
||||||
isEnabled() ? _textcolor : uInt32(kColor), _align);
|
isEnabled() ? _textcolor : uInt32(kColor), _align, 0, true, _shadowcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -111,6 +111,7 @@ class Widget : public GuiObject
|
||||||
void setTextColorHi(uInt32 color) { _textcolorhi = color; }
|
void setTextColorHi(uInt32 color) { _textcolorhi = color; }
|
||||||
void setBGColor(uInt32 color) { _bgcolor = color; }
|
void setBGColor(uInt32 color) { _bgcolor = color; }
|
||||||
void setBGColorHi(uInt32 color) { _bgcolorhi = color; }
|
void setBGColorHi(uInt32 color) { _bgcolorhi = color; }
|
||||||
|
void setShadowColor(uInt32 color) { _shadowcolor = color; }
|
||||||
|
|
||||||
virtual void loadConfig() { }
|
virtual void loadConfig() { }
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ class Widget : public GuiObject
|
||||||
uInt32 _bgcolorhi;
|
uInt32 _bgcolorhi;
|
||||||
uInt32 _textcolor;
|
uInt32 _textcolor;
|
||||||
uInt32 _textcolorhi;
|
uInt32 _textcolorhi;
|
||||||
|
uInt32 _shadowcolor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Widget* findWidgetInChain(Widget* start, int x, int y);
|
static Widget* findWidgetInChain(Widget* start, int x, int y);
|
||||||
|
@ -176,10 +178,12 @@ class StaticTextWidget : public Widget
|
||||||
public:
|
public:
|
||||||
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, int w, int h,
|
int x, int y, int w, int h,
|
||||||
const string& text, TextAlign align = TextAlign::Left);
|
const string& text, TextAlign align = TextAlign::Left,
|
||||||
|
uInt32 shadowColor = 0);
|
||||||
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y,
|
int x, int y,
|
||||||
const string& text, TextAlign align = TextAlign::Left);
|
const string& text, TextAlign align = TextAlign::Left,
|
||||||
|
uInt32 shadowColor = 0);
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
void setLabel(const string& label);
|
void setLabel(const string& label);
|
||||||
void setAlign(TextAlign align) { _align = align; }
|
void setAlign(TextAlign align) { _align = align; }
|
||||||
|
|
Loading…
Reference in New Issue