mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 00:42:24 +00:00
GUI: Fix the caret drawing over the scroll bar in the list widget
Also remove the unused linesWidth variable and fix the hlLeftPadding and hlRightPadding widget attributes to actually work. There are still issues remaining with the caret in the list widget due to the ellipsis being used to shorten long text. Ellipsis is accounted for when drawing the text but not when computing the caret position.
This commit is contained in:
parent
5878c618c9
commit
7dc602f352
@ -37,7 +37,6 @@ ListWidget::ListWidget(Dialog *boss, const String &name, const char *tooltip, ui
|
|||||||
: EditableWidget(boss, name, tooltip), _cmd(cmd) {
|
: EditableWidget(boss, name, tooltip), _cmd(cmd) {
|
||||||
|
|
||||||
_scrollBar = NULL;
|
_scrollBar = NULL;
|
||||||
_textWidth = NULL;
|
|
||||||
|
|
||||||
// This ensures that _entriesPerPage is properly initialized.
|
// This ensures that _entriesPerPage is properly initialized.
|
||||||
reflowLayout();
|
reflowLayout();
|
||||||
@ -69,7 +68,6 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *too
|
|||||||
: EditableWidget(boss, x, y, w, h, tooltip), _cmd(cmd) {
|
: EditableWidget(boss, x, y, w, h, tooltip), _cmd(cmd) {
|
||||||
|
|
||||||
_scrollBar = NULL;
|
_scrollBar = NULL;
|
||||||
_textWidth = NULL;
|
|
||||||
|
|
||||||
// This ensures that _entriesPerPage is properly initialized.
|
// This ensures that _entriesPerPage is properly initialized.
|
||||||
reflowLayout();
|
reflowLayout();
|
||||||
@ -97,10 +95,6 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *too
|
|||||||
_editColor = ThemeEngine::kFontColorNormal;
|
_editColor = ThemeEngine::kFontColorNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListWidget::~ListWidget() {
|
|
||||||
delete[] _textWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ListWidget::containsWidget(Widget *w) const {
|
bool ListWidget::containsWidget(Widget *w) const {
|
||||||
if (w == _scrollBar || _scrollBar->containsWidget(w))
|
if (w == _scrollBar || _scrollBar->containsWidget(w))
|
||||||
return true;
|
return true;
|
||||||
@ -502,7 +496,6 @@ void ListWidget::drawWidget() {
|
|||||||
|
|
||||||
// Draw a thin frame around the list.
|
// 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()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);
|
||||||
const int scrollbarW = (_scrollBar && _scrollBar->isVisible()) ? _scrollBarWidth : 0;
|
|
||||||
|
|
||||||
// Draw the list items
|
// Draw the list items
|
||||||
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
|
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
|
||||||
@ -520,13 +513,11 @@ void ListWidget::drawWidget() {
|
|||||||
// If in numbering mode, we first print a number prefix
|
// If in numbering mode, we first print a number prefix
|
||||||
if (_numberingMode != kListNumberingOff) {
|
if (_numberingMode != kListNumberingOff) {
|
||||||
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
|
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
|
||||||
g_gui.theme()->drawTextClip(Common::Rect(_x, y, _x + r.left + _leftPadding, y + fontHeight - 2), getBossClipRect(),
|
g_gui.theme()->drawTextClip(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
|
||||||
buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
|
getBossClipRect(), buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
|
||||||
pad = 0;
|
pad = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width;
|
|
||||||
|
|
||||||
ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
|
ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
|
||||||
|
|
||||||
if (!_listColors.empty()) {
|
if (!_listColors.empty()) {
|
||||||
@ -540,22 +531,21 @@ void ListWidget::drawWidget() {
|
|||||||
buffer = _editString;
|
buffer = _editString;
|
||||||
color = _editColor;
|
color = _editColor;
|
||||||
adjustOffset();
|
adjustOffset();
|
||||||
width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW;
|
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
|
||||||
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), getBossClipRect(), buffer, _state,
|
getBossClipRect(), buffer, _state,
|
||||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||||
} else {
|
} else {
|
||||||
buffer = _list[pos];
|
buffer = _list[pos];
|
||||||
width = _w - r.left - scrollbarW;
|
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
|
||||||
g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), getBossClipRect(), buffer, _state,
|
getBossClipRect(), buffer, _state,
|
||||||
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
_textWidth[i] = width;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Rect ListWidget::getEditRect() const {
|
Common::Rect ListWidget::getEditRect() const {
|
||||||
Common::Rect r(_hlLeftPadding, 0, _w - _hlLeftPadding - _hlRightPadding, kLineHeight - 2);
|
const int scrollbarW = (_scrollBar && _scrollBar->isVisible()) ? _scrollBarWidth : 0;
|
||||||
|
Common::Rect r(_hlLeftPadding, 0, _w - _hlRightPadding - scrollbarW, kLineHeight - 2);
|
||||||
const int offset = (_selectedItem - _currentPos) * kLineHeight + _topPadding;
|
const int offset = (_selectedItem - _currentPos) * kLineHeight + _topPadding;
|
||||||
r.top += offset;
|
r.top += offset;
|
||||||
r.bottom += offset;
|
r.bottom += offset;
|
||||||
@ -668,12 +658,6 @@ void ListWidget::reflowLayout() {
|
|||||||
_entriesPerPage = fracToInt(entriesPerPage);
|
_entriesPerPage = fracToInt(entriesPerPage);
|
||||||
assert(_entriesPerPage > 0);
|
assert(_entriesPerPage > 0);
|
||||||
|
|
||||||
delete[] _textWidth;
|
|
||||||
_textWidth = new int[_entriesPerPage];
|
|
||||||
|
|
||||||
for (int i = 0; i < _entriesPerPage; i++)
|
|
||||||
_textWidth[i] = 0;
|
|
||||||
|
|
||||||
if (_scrollBar) {
|
if (_scrollBar) {
|
||||||
_scrollBar->resize(_w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h);
|
_scrollBar->resize(_w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h);
|
||||||
scrollBarRecalc();
|
scrollBarRecalc();
|
||||||
|
@ -87,7 +87,6 @@ protected:
|
|||||||
public:
|
public:
|
||||||
ListWidget(Dialog *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);
|
ListWidget(Dialog *boss, const String &name, const char *tooltip = 0, uint32 cmd = 0);
|
||||||
ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
|
ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0);
|
||||||
virtual ~ListWidget();
|
|
||||||
|
|
||||||
virtual bool containsWidget(Widget *) const;
|
virtual bool containsWidget(Widget *) const;
|
||||||
virtual Widget *findWidget(int x, int y);
|
virtual Widget *findWidget(int x, int y);
|
||||||
@ -149,8 +148,6 @@ protected:
|
|||||||
void lostFocusWidget();
|
void lostFocusWidget();
|
||||||
void checkBounds();
|
void checkBounds();
|
||||||
void scrollToCurrent();
|
void scrollToCurrent();
|
||||||
|
|
||||||
int *_textWidth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace GUI
|
} // End of namespace GUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user