aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets
diff options
context:
space:
mode:
authorBastien Bouclet2018-01-27 08:59:53 +0100
committerBastien Bouclet2018-04-19 19:18:39 +0200
commit4d29ce21d01176f523d6f3b05aefa1b011fc756c (patch)
treeb5133d25662475c460df806f633f4427c0188fea /gui/widgets
parentdcfac42bb3ebec723a8762d3b2b72ff4113bf900 (diff)
downloadscummvm-rg350-4d29ce21d01176f523d6f3b05aefa1b011fc756c.tar.gz
scummvm-rg350-4d29ce21d01176f523d6f3b05aefa1b011fc756c.tar.bz2
scummvm-rg350-4d29ce21d01176f523d6f3b05aefa1b011fc756c.zip
GUI: Unify clip and non-clip draw calls
Diffstat (limited to 'gui/widgets')
-rw-r--r--gui/widgets/editable.cpp6
-rw-r--r--gui/widgets/edittext.cpp8
-rw-r--r--gui/widgets/list.cpp17
-rw-r--r--gui/widgets/popup.cpp11
-rw-r--r--gui/widgets/scrollbar.cpp6
-rw-r--r--gui/widgets/scrollcontainer.cpp8
-rw-r--r--gui/widgets/scrollcontainer.h2
-rw-r--r--gui/widgets/tab.cpp7
8 files changed, 37 insertions, 28 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 5e7c94b64a..339870fe34 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -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);
}
}
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 97366741d0..b0e68985d1 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -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 {
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index df12d6fd5f..6dd4ab4dd5 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -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);
}
}
}
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 65c9dea605..a36a652e5b 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -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
diff --git a/gui/widgets/scrollbar.cpp b/gui/widgets/scrollbar.cpp
index b0e2576ec1..38cdc6fda6 100644
--- a/gui/widgets/scrollbar.cpp
+++ b/gui/widgets/scrollbar.cpp
@@ -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
diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp
index d6b1b740fd..7994c0078d 100644
--- a/gui/widgets/scrollcontainer.cpp
+++ b/gui/widgets/scrollcontainer.cpp
@@ -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
diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h
index 9366a0b658..c4b2f716e6 100644
--- a/gui/widgets/scrollcontainer.h
+++ b/gui/widgets/scrollcontainer.h
@@ -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.
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index dfcb919264..696289ef68 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -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() {