aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/ListWidget.cpp25
-rw-r--r--gui/ListWidget.h3
-rw-r--r--gui/ScrollBarWidget.cpp72
-rw-r--r--gui/ScrollBarWidget.h3
-rw-r--r--gui/console.cpp15
5 files changed, 66 insertions, 52 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 929a8a8319..f600676c07 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -27,16 +27,21 @@
namespace GUI {
-ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h)
- : EditableWidget(boss, x, y, w - kDefaultScrollBarWidth, h), CommandSender(boss) {
+ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws)
+ : EditableWidget(boss, x, y, w, h), CommandSender(boss) {
+
+ // TODO: When in kBigWidgetSize mode, use another font
+ _w = w - (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth);
+ _lineHeight = kLineHeight;
+
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE;
_type = kListWidget;
_editMode = false;
_numberingMode = kListNumberingOne;
- _entriesPerPage = (_h - 2) / kLineHeight;
+ _entriesPerPage = (_h - 2) / _lineHeight;
_currentPos = 0;
_selectedItem = -1;
- _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kDefaultScrollBarWidth, _h);
+ _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h);
_scrollBar->setTarget(this);
_currentKeyDown = 0;
@@ -144,7 +149,7 @@ void ListWidget::handleMouseWheel(int x, int y, int direction) {
int ListWidget::findItem(int x, int y) const {
- return (y - 1) / kLineHeight + _currentPos;
+ return (y - 1) / _lineHeight + _currentPos;
}
static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) {
@@ -301,14 +306,14 @@ void ListWidget::drawWidget(bool hilite) {
// Draw the list items
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
const OverlayColor textColor = (_selectedItem == pos && _hasFocus) ? gui->_bgcolor : gui->_textcolor;
- const int y = _y + 2 + kLineHeight * i;
+ const int y = _y + 2 + _lineHeight * i;
// Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos) {
if (_hasFocus)
- gui->fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi);
+ gui->fillRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi);
else
- gui->frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi);
+ gui->frameRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi);
}
// If in numbering mode, we first print a number prefix
@@ -339,8 +344,8 @@ void ListWidget::drawWidget(bool hilite) {
}
Common::Rect ListWidget::getEditRect() const {
- Common::Rect r(2, 1, _w - 2 , kLineHeight);
- const int offset = (_selectedItem - _currentPos) * kLineHeight;
+ Common::Rect r(2, 1, _w - 2 , _lineHeight);
+ const int offset = (_selectedItem - _currentPos) * _lineHeight;
r.top += offset;
r.bottom += offset;
diff --git a/gui/ListWidget.h b/gui/ListWidget.h
index e31b58d813..652489cfa3 100644
--- a/gui/ListWidget.h
+++ b/gui/ListWidget.h
@@ -56,12 +56,13 @@ protected:
int _selectedItem;
ScrollBarWidget *_scrollBar;
int _currentKeyDown;
+ int _lineHeight;
String _quickSelectStr;
uint32 _quickSelectTime;
public:
- ListWidget(GuiObject *boss, int x, int y, int w, int h);
+ ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws = kDefaultWidgetSize);
virtual ~ListWidget();
void setList(const StringList& list);
diff --git a/gui/ScrollBarWidget.cpp b/gui/ScrollBarWidget.cpp
index 50c66cb63d..f49a08f9f7 100644
--- a/gui/ScrollBarWidget.cpp
+++ b/gui/ScrollBarWidget.cpp
@@ -28,30 +28,6 @@ namespace GUI {
#define UP_DOWN_BOX_HEIGHT (_w+1)
-// Up arrow
-static uint32 up_arrow[8] = {
- 0x00000000,
- 0x00000000,
- 0x00001000,
- 0x00001000,
- 0x00011100,
- 0x00011100,
- 0x00110110,
- 0x00100010,
-};
-
-// Down arrow
-static uint32 down_arrow[8] = {
- 0x00000000,
- 0x00000000,
- 0x00100010,
- 0x00110110,
- 0x00011100,
- 0x00011100,
- 0x00001000,
- 0x00001000,
-};
-
ScrollBarWidget::ScrollBarWidget(GuiObject *boss, int x, int y, int w, int h)
: Widget (boss, x, y, w, h), CommandSender(boss) {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG | WIDGET_WANT_TICKLE;
@@ -205,33 +181,59 @@ void ScrollBarWidget::recalc() {
void ScrollBarWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
- int bottomY = _y + _h;
+ int bottomY = _y + _h - UP_DOWN_BOX_HEIGHT;
bool isSinglePage = (_numEntries <= _entriesPerPage);
+ OverlayColor color;
+ Graphics::Surface &surf = g_gui.getScreen();
+ const int B = (_w + 1) / 4;
+ Common::Point p0, p1, p2;
gui->frameRect(_x, _y, _w, _h, gui->_shadowcolor);
if (_draggingPart != kNoPart)
_part = _draggingPart;
+ //
// Up arrow
+ //
+ color = isSinglePage ? gui->_color :
+ (hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor;
gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
- gui->drawBitmap(up_arrow, _x + 1 + (_w - 8) / 2, _y + (_w - 8) / 2,
- isSinglePage ? gui->_color :
- (hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor);
-
+ p0 = Common::Point(_x + _w / 2, _y + B);
+ p1 = Common::Point(_x + B, _y + _w - B);
+ p2 = Common::Point(_x + _w - B - 1, _y + _w - B);
+ // Evil HACK to draw filled triangle
+// for (; p1.x <= p2.x; ++p1.x)
+// surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+ surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+ surf.drawLine(p0.x, p0.y, p2.x, p2.y, color);
+// surf.drawLine(p1.x, p1.y, p2.x, p2.y, color);
+
+ //
// Down arrow
- gui->frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
- gui->drawBitmap(down_arrow, _x + 1 + (_w - 8) / 2, bottomY - UP_DOWN_BOX_HEIGHT + (_w - 8) / 2,
- isSinglePage ? gui->_color :
- (hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor);
-
+ //
+ color = isSinglePage ? gui->_color :
+ (hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor;
+ gui->frameRect(_x, bottomY, _w, UP_DOWN_BOX_HEIGHT, gui->_color);
+ p0 = Common::Point(_x + _w / 2, bottomY + _w - B);
+ p1 = Common::Point(_x + B, bottomY + B);
+ p2 = Common::Point(_x + _w - B - 1, bottomY + B);
+ // Evil HACK to draw filled triangle
+// for (; p1.x <= p2.x; ++p1.x)
+// surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+ surf.drawLine(p0.x, p0.y, p1.x, p1.y, color);
+ surf.drawLine(p0.x, p0.y, p2.x, p2.y, color);
+// surf.drawLine(p1.x, p1.y, p2.x, p2.y, color);
+
+ //
// Slider
+ //
if (!isSinglePage) {
gui->fillRect(_x, _y + _sliderPos, _w, _sliderHeight,
(hilite && _part == kSliderPart) ? gui->_textcolorhi : gui->_textcolor);
gui->frameRect(_x, _y + _sliderPos, _w, _sliderHeight, gui->_color);
int y = _y + _sliderPos + _sliderHeight / 2;
- OverlayColor color = (hilite && _part == kSliderPart) ? gui->_color : gui->_shadowcolor;
+ color = (hilite && _part == kSliderPart) ? gui->_color : gui->_shadowcolor;
gui->hLine(_x + 2, y - 2, _x + _w - 3, color);
gui->hLine(_x + 2, y, _x + _w - 3, color);
gui->hLine(_x + 2, y + 2, _x + _w-3, color);
diff --git a/gui/ScrollBarWidget.h b/gui/ScrollBarWidget.h
index dd132096c5..7eaaa1540e 100644
--- a/gui/ScrollBarWidget.h
+++ b/gui/ScrollBarWidget.h
@@ -26,7 +26,8 @@
namespace GUI {
enum {
- kDefaultScrollBarWidth = 9
+ kNormalScrollBarWidth = 9,
+ kBigScrollBarWidth = 15
};
diff --git a/gui/console.cpp b/gui/console.cpp
index a079a976d3..03163fb7ca 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -57,15 +57,20 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent)
: Dialog(0, 0, 1, 1),
_widthPercent(widthPercent), _heightPercent(heightPercent) {
+ const int screenW = g_system->getOverlayWidth();
+ const int screenH = g_system->getOverlayHeight();
+
// Calculate the real width/height (rounded to char/line multiples)
- _w = (uint16)(_widthPercent * g_system->getOverlayWidth());
- _h = (uint16)((_heightPercent * g_system->getOverlayHeight() - 2) / kConsoleLineHeight);
+ _w = (uint16)(_widthPercent * screenW);
+ _h = (uint16)((_heightPercent * screenH - 2) / kConsoleLineHeight);
_h = _h * kConsoleLineHeight + 2;
// Add scrollbar
- int scrollBarWidth = kDefaultScrollBarWidth;
- if (g_system->getOverlayWidth() >= 640)
- scrollBarWidth = 14;
+ int scrollBarWidth;
+ if (screenW >= 400 && screenH >= 300)
+ scrollBarWidth = kBigScrollBarWidth;
+ else
+ scrollBarWidth = kNormalScrollBarWidth;
_scrollBar = new ScrollBarWidget(this, _w - scrollBarWidth - 1, 0, scrollBarWidth, _h);
_scrollBar->setTarget(this);