mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-22 18:37:01 +00:00
GUI: Make PopUpWidget clip
This commit is contained in:
parent
8f2d35b0b8
commit
fca0f0ed34
@ -270,6 +270,8 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) {
|
||||
}
|
||||
}
|
||||
|
||||
extendedRect.clip(_clip);
|
||||
|
||||
_engine->addDirtyRect(extendedRect);
|
||||
}
|
||||
|
||||
@ -1180,6 +1182,27 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
||||
DrawData dd = kDDPopUpIdle;
|
||||
|
||||
if (state == kStateEnabled)
|
||||
dd = kDDPopUpIdle;
|
||||
else if (state == kStateHighlight)
|
||||
dd = kDDPopUpHover;
|
||||
else if (state == kStateDisabled)
|
||||
dd = kDDPopUpDisabled;
|
||||
|
||||
queueDDClip(dd, r, clip);
|
||||
|
||||
if (!sel.empty()) {
|
||||
Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
|
||||
queueDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
|
||||
if (!ready())
|
||||
return;
|
||||
@ -1210,6 +1233,29 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, Widg
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeEngine::drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clip, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
||||
switch (background) {
|
||||
case kWidgetBackgroundBorderSmall:
|
||||
queueDDClip(kDDWidgetBackgroundSmall, r, clip);
|
||||
break;
|
||||
|
||||
case kWidgetBackgroundEditText:
|
||||
queueDDClip(kDDWidgetBackgroundEditText, r, clip);
|
||||
break;
|
||||
|
||||
case kWidgetBackgroundSlider:
|
||||
queueDDClip(kDDWidgetBackgroundSlider, r, clip);
|
||||
break;
|
||||
|
||||
default:
|
||||
queueDDClip(kDDWidgetBackgroundDefault, r, clip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
|
||||
if (!ready())
|
||||
return;
|
||||
|
@ -341,6 +341,9 @@ public:
|
||||
void drawWidgetBackground(const Common::Rect &r, uint16 hints,
|
||||
WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
|
||||
|
||||
void drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clippingArea, uint16 hints,
|
||||
WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
|
||||
|
||||
void drawButton(const Common::Rect &r, const Common::String &str,
|
||||
WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
|
||||
|
||||
@ -368,6 +371,8 @@ public:
|
||||
|
||||
void drawPopUpWidget(const Common::Rect &r, const Common::String &sel,
|
||||
int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft);
|
||||
void drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &sel,
|
||||
int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft);
|
||||
|
||||
void drawCaret(const Common::Rect &r, bool erase,
|
||||
WidgetStateInfo state = kStateEnabled);
|
||||
|
@ -280,11 +280,8 @@ void StaticTextWidget::setAlign(Graphics::TextAlign align) {
|
||||
|
||||
|
||||
void StaticTextWidget::drawWidget() {
|
||||
int px = _boss->getAbsX();
|
||||
int py = _boss->getAbsY();
|
||||
g_gui.theme()->drawTextClip(
|
||||
Common::Rect(_x, _y, _x+_w, _y+_h),
|
||||
Common::Rect(px, py, px + _boss->getWidth(), py + _boss->getHeight()),
|
||||
Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(),
|
||||
_label, _state, _align, ThemeEngine::kTextInversionNone, 0, true, _font
|
||||
);
|
||||
}
|
||||
@ -324,12 +321,9 @@ void ButtonWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||
setPressedState();
|
||||
}
|
||||
|
||||
void ButtonWidget::drawWidget() {
|
||||
int px = _boss->getAbsX();
|
||||
int py = _boss->getAbsY();
|
||||
void ButtonWidget::drawWidget() {
|
||||
g_gui.theme()->drawButtonClip(
|
||||
Common::Rect(_x, _y, _x + _w, _y + _h),
|
||||
Common::Rect(px, py, px + _boss->getWidth(), py + _boss->getHeight()),
|
||||
Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(),
|
||||
_label, _state, getFlags()
|
||||
);
|
||||
}
|
||||
|
@ -112,6 +112,11 @@ public:
|
||||
|
||||
virtual int16 getAbsX() const { return _x + _boss->getChildX(); }
|
||||
virtual int16 getAbsY() const { return _y + _boss->getChildY(); }
|
||||
virtual Common::Rect getBossClipRect() const {
|
||||
int px = _boss->getAbsX();
|
||||
int py = _boss->getAbsY();
|
||||
return Common::Rect(px, py, px + _boss->getWidth(), py + _boss->getHeight());
|
||||
}
|
||||
|
||||
virtual void setPos(int x, int y) { _x = x; _y = y; }
|
||||
virtual void setSize(int w, int h) { _w = w; _h = h; }
|
||||
|
@ -150,7 +150,7 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY)
|
||||
|
||||
void PopUpDialog::drawDialog() {
|
||||
// Draw the menu border
|
||||
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0);
|
||||
g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), _popUpBoss->getBossClipRect(), 0);
|
||||
|
||||
/*if (_twoColumns)
|
||||
g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/
|
||||
@ -364,8 +364,11 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
|
||||
// Draw a separator
|
||||
g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x+w, y+kLineHeight));
|
||||
} else {
|
||||
g_gui.theme()->drawText(Common::Rect(x+1, y+2, x+w, y+2+kLineHeight), name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled,
|
||||
Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, _leftPadding);
|
||||
g_gui.theme()->drawTextClip(
|
||||
Common::Rect(x+1, y+2, x+w, y+2+kLineHeight), _popUpBoss->getBossClipRect(),
|
||||
name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled,
|
||||
Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, _leftPadding
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +473,10 @@ void PopUpWidget::drawWidget() {
|
||||
Common::String sel;
|
||||
if (_selectedItem >= 0)
|
||||
sel = _entries[_selectedItem].name;
|
||||
g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state, Graphics::kTextAlignLeft);
|
||||
g_gui.theme()->drawPopUpWidgetClip(
|
||||
Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(),
|
||||
sel, _leftPadding, _state, Graphics::kTextAlignLeft
|
||||
);
|
||||
}
|
||||
|
||||
} // End of namespace GUI
|
||||
|
Loading…
x
Reference in New Issue
Block a user