GUI: Unify clip and non-clip draw calls
This commit is contained in:
parent
dcfac42bb3
commit
4d29ce21d0
18 changed files with 156 additions and 573 deletions
|
@ -289,7 +289,7 @@ void EditableWidget::drawCaret(bool erase) {
|
|||
x += getAbsX();
|
||||
y += getAbsY();
|
||||
|
||||
g_gui.theme()->drawCaretClip(Common::Rect(x, y, x + 1, y + editRect.height()), getBossClipRect(), erase);
|
||||
g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height()), erase);
|
||||
|
||||
if (erase) {
|
||||
GUI::EditableWidget::String character;
|
||||
|
@ -318,7 +318,9 @@ void EditableWidget::drawCaret(bool erase) {
|
|||
// possible glitches due to different methods used.
|
||||
width = MIN(editRect.width() - caretOffset, width);
|
||||
if (width > 0) {
|
||||
g_gui.theme()->drawTextClip(Common::Rect(x, y, x + width, y + editRect.height()), getBossClipRect(), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
|
||||
g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character,
|
||||
_state, Graphics::kTextAlignLeft, _inversion, 0, false, _font,
|
||||
ThemeEngine::kFontColorNormal, true, _textDrawableArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
|||
}
|
||||
|
||||
void EditTextWidget::drawWidget() {
|
||||
g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundEditText);
|
||||
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
|
||||
ThemeEngine::kWidgetBackgroundEditText);
|
||||
|
||||
// Draw the text
|
||||
adjustOffset();
|
||||
|
@ -105,7 +106,10 @@ void EditTextWidget::drawWidget() {
|
|||
const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
|
||||
setTextDrawableArea(r);
|
||||
|
||||
g_gui.theme()->drawTextClip(Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h), getBossClipRect(), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
|
||||
g_gui.theme()->drawText(
|
||||
Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
|
||||
_editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone,
|
||||
-_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
|
||||
}
|
||||
|
||||
Common::Rect EditTextWidget::getEditRect() const {
|
||||
|
|
|
@ -495,7 +495,8 @@ void ListWidget::drawWidget() {
|
|||
Common::String buffer;
|
||||
|
||||
// Draw a thin frame around the list.
|
||||
g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);
|
||||
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
|
||||
ThemeEngine::kWidgetBackgroundBorder);
|
||||
|
||||
// Draw the list items
|
||||
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
|
||||
|
@ -513,8 +514,8 @@ void ListWidget::drawWidget() {
|
|||
// If in numbering mode, we first print a number prefix
|
||||
if (_numberingMode != kListNumberingOff) {
|
||||
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
|
||||
g_gui.theme()->drawTextClip(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
|
||||
getBossClipRect(), buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
|
||||
g_gui.theme()->drawText(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
|
||||
buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
|
||||
pad = 0;
|
||||
}
|
||||
|
||||
|
@ -531,14 +532,12 @@ void ListWidget::drawWidget() {
|
|||
buffer = _editString;
|
||||
color = _editColor;
|
||||
adjustOffset();
|
||||
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
|
||||
getBossClipRect(), buffer, _state,
|
||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
|
||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||
} else {
|
||||
buffer = _list[pos];
|
||||
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
|
||||
getBossClipRect(), buffer, _state,
|
||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||
g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
|
||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ void PopUpDialog::drawDialog(DrawLayer layerToDraw) {
|
|||
Dialog::drawDialog(layerToDraw);
|
||||
|
||||
// Draw the menu border
|
||||
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0);
|
||||
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0);
|
||||
|
||||
/*if (_twoColumns)
|
||||
g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/
|
||||
|
@ -367,10 +367,10 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
|
|||
|
||||
if (name.size() == 0) {
|
||||
// Draw a separator
|
||||
g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x+w, y+kLineHeight));
|
||||
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),
|
||||
Common::Rect(x + 1, y + 2, x + w, y + 2 + kLineHeight),
|
||||
name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled,
|
||||
Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, _leftPadding
|
||||
);
|
||||
|
@ -478,10 +478,7 @@ void PopUpWidget::drawWidget() {
|
|||
Common::String sel;
|
||||
if (_selectedItem >= 0)
|
||||
sel = _entries[_selectedItem].name;
|
||||
g_gui.theme()->drawPopUpWidgetClip(
|
||||
Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(),
|
||||
sel, _leftPadding, _state, Graphics::kTextAlignLeft
|
||||
);
|
||||
g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state);
|
||||
}
|
||||
|
||||
} // End of namespace GUI
|
||||
|
|
|
@ -203,11 +203,7 @@ void ScrollBarWidget::drawWidget() {
|
|||
state = ThemeEngine::kScrollbarStateSlider;
|
||||
}
|
||||
|
||||
Common::Rect clipRect = getBossClipRect();
|
||||
//scrollbar is not a usual child of ScrollContainerWidget, so it gets this special treatment
|
||||
if (dynamic_cast<ScrollContainerWidget *>(_boss))
|
||||
clipRect.right += _w;
|
||||
g_gui.theme()->drawScrollbarClip(Common::Rect(_x, _y, _x+_w, _y+_h), clipRect, _sliderPos, _sliderHeight, state, _state);
|
||||
g_gui.theme()->drawScrollbar(Common::Rect(_x, _y, _x + _w, _y + _h), _sliderPos, _sliderHeight, state);
|
||||
}
|
||||
|
||||
} // End of namespace GUI
|
||||
|
|
|
@ -140,7 +140,8 @@ void ScrollContainerWidget::reflowLayout() {
|
|||
}
|
||||
|
||||
void ScrollContainerWidget::drawWidget() {
|
||||
g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), getBossClipRect(), ThemeEngine::kDialogBackgroundDefault);
|
||||
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1),
|
||||
ThemeEngine::kDialogBackgroundDefault);
|
||||
}
|
||||
|
||||
bool ScrollContainerWidget::containsWidget(Widget *w) const {
|
||||
|
@ -155,4 +156,9 @@ Widget *ScrollContainerWidget::findWidget(int x, int y) {
|
|||
return Widget::findWidgetInChain(_firstWidget, x + _scrolledX, y + _scrolledY);
|
||||
}
|
||||
|
||||
Common::Rect ScrollContainerWidget::getClipRect() const {
|
||||
// Make sure the clipping rect contains the scrollbar so it is properly redrawn
|
||||
return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight());
|
||||
}
|
||||
|
||||
} // End of namespace GUI
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
|
||||
virtual bool containsWidget(Widget *) const;
|
||||
|
||||
Common::Rect getClipRect() const override;
|
||||
|
||||
protected:
|
||||
// We overload getChildY to make sure child widgets are positioned correctly.
|
||||
// Essentially this compensates for the space taken up by the tab title header.
|
||||
|
|
|
@ -320,9 +320,12 @@ void TabWidget::drawWidget() {
|
|||
tabs.push_back(_tabs[i].title);
|
||||
widths.push_back(_tabs[i]._tabWidth);
|
||||
}
|
||||
g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x + _bodyLP, _y + _bodyTP, _x+_w-_bodyRP, _y+_h-_bodyBP+_tabHeight), getBossClipRect(), _bodyBackgroundType);
|
||||
g_gui.theme()->drawDialogBackground(
|
||||
Common::Rect(_x + _bodyLP, _y + _bodyTP, _x + _w - _bodyRP, _y + _h - _bodyBP + _tabHeight),
|
||||
_bodyBackgroundType);
|
||||
|
||||
g_gui.theme()->drawTabClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _tabHeight, widths, tabs, _activeTab - _firstVisibleTab, 0, _titleVPad);
|
||||
g_gui.theme()->drawTab(Common::Rect(_x, _y, _x + _w, _y + _h), _tabHeight, widths, tabs,
|
||||
_activeTab - _firstVisibleTab);
|
||||
}
|
||||
|
||||
void TabWidget::draw() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue