aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorVicent Marti2008-08-08 15:06:28 +0000
committerVicent Marti2008-08-08 15:06:28 +0000
commit3ca6f76f7be2ef8c982c83ed0c1a1da633033c35 (patch)
tree87775e687ae845e2a5ff42f75de5c2ac0f05b3ff /gui
parent1ea3301a8a358e9da9be644b8de54a9fec952dce (diff)
downloadscummvm-rg350-3ca6f76f7be2ef8c982c83ed0c1a1da633033c35.tar.gz
scummvm-rg350-3ca6f76f7be2ef8c982c83ed0c1a1da633033c35.tar.bz2
scummvm-rg350-3ca6f76f7be2ef8c982c83ed0c1a1da633033c35.zip
Browser dialog.
Improved layout expansion in the layout parser. Fixed serious coordinates initialization bug. svn-id: r33702
Diffstat (limited to 'gui')
-rw-r--r--gui/ListWidget.cpp12
-rw-r--r--gui/ThemeEval.cpp64
-rw-r--r--gui/ThemeEval.h4
-rw-r--r--gui/ThemeRenderer.cpp19
-rw-r--r--gui/browser.cpp14
-rw-r--r--gui/themes/default.inc27
-rw-r--r--gui/themes/modern.stx29
7 files changed, 127 insertions, 42 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index dda110aa07..4f829fd323 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -499,7 +499,17 @@ void ListWidget::reflowLayout() {
_scrollBarWidth = kNormalScrollBarWidth;
}
- _entriesPerPage = (_h - _topPadding - _bottomPadding) / kLineHeight;
+ // HACK: Once we take padding into account, there are times where
+ // integer rounding leaves a big chunk of white space in the bottom
+ // of the list.
+ // We do a rough rounding on the decimal places of Entries Per Page,
+ // to add another entry even if it goes a tad over the padding.
+ _entriesPerPage = ((_h - _topPadding - _bottomPadding) << 16) / kLineHeight;
+
+ if ((uint)(_entriesPerPage & 0xFFFF) >= 0xF000)
+ _entriesPerPage += (1 << 16);
+
+ _entriesPerPage >>= 16;
delete[] _textWidth;
_textWidth = new int[_entriesPerPage];
diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp
index b452e1c2f5..96ac8098ad 100644
--- a/gui/ThemeEval.cpp
+++ b/gui/ThemeEval.cpp
@@ -65,6 +65,9 @@ void ThemeLayoutMain::reflowLayout() {
_children[0]->setHeight(_h);
_children[0]->reflowLayout();
+// _children[0]->setX(_x);
+// _children[0]->setY(_y);
+
if (_w == -1)
_w = _children[0]->getWidth();
@@ -81,25 +84,27 @@ void ThemeLayoutMain::reflowLayout() {
void ThemeLayoutVertical::reflowLayout() {
int curX, curY;
+ int autoWidget = -1;
curX = _paddingLeft;
curY = _paddingTop;
_h = _paddingTop + _paddingBottom;
for (uint i = 0; i < _children.size(); ++i) {
- assert(_children[i]->getLayoutType() != kLayoutVertical);
_children[i]->resetLayout();
_children[i]->reflowLayout();
-
- if (i != _children.size() - 1)
- assert(_children[i]->getHeight() != -1);
if (_children[i]->getWidth() == -1)
_children[i]->setWidth((_w == -1 ? getParentW() : _w) - _paddingLeft - _paddingRight);
- if (_children[i]->getHeight() == -1)
+ if (_children[i]->getHeight() == -1) {
+ if (autoWidget != -1)
+ error("Cannot expand automatically two different widgets.");
+
+ autoWidget = i;
_children[i]->setHeight(getParentH() - _h - _spacing);
+ }
_children[i]->setY(curY);
@@ -116,31 +121,40 @@ void ThemeLayoutVertical::reflowLayout() {
}
_w = MAX(_w, (int16)(_children[i]->getWidth() + _paddingLeft + _paddingRight));
- _h += _children[i]->getHeight() + _spacing;
+
+ if (autoWidget != -1 && autoWidget != (int)i) {
+ _children[autoWidget]->setHeight(_children[autoWidget]->getHeight() - (_children[i]->getHeight() + _spacing));
+ for (int j = autoWidget - 1; j >= 0; --j)
+ _children[j]->setY(-(_children[i]->getHeight() + _spacing));
+ } else {
+ _h += _children[i]->getHeight() + _spacing;
+ }
}
}
void ThemeLayoutHorizontal::reflowLayout() {
int curX, curY;
+ int autoWidget = -1;
curX = _paddingLeft;
curY = _paddingTop;
_w = _paddingLeft + _paddingRight;
for (uint i = 0; i < _children.size(); ++i) {
- assert(_children[i]->getLayoutType() != kLayoutHorizontal);
_children[i]->resetLayout();
_children[i]->reflowLayout();
- if (i != _children.size() - 1)
- assert(_children[i]->getWidth() != -1);
-
if (_children[i]->getHeight() == -1)
_children[i]->setHeight((_h == -1 ? getParentH() : _h) - _paddingTop - _paddingBottom);
- if (_children[i]->getWidth() == -1)
+ if (_children[i]->getWidth() == -1) {
+ if (autoWidget != -1)
+ error("Cannot expand automatically two different widgets.");
+
+ autoWidget = i;
_children[i]->setWidth(getParentW() - _w - _spacing);
+ }
_children[i]->setX(curX);
@@ -156,7 +170,15 @@ void ThemeLayoutHorizontal::reflowLayout() {
curX += (_children[i]->getWidth() + _spacing);
}
- _w += _children[i]->getWidth() + _spacing;
+ if (autoWidget != -1 && autoWidget != (int)i) {
+ _children[autoWidget]->setWidth(_children[autoWidget]->getWidth() - (_children[i]->getWidth() + _spacing));
+ for (int j = autoWidget - 1; j >= 0; --j)
+ _children[j]->setX(-(_children[i]->getWidth() + _spacing));
+ } else {
+ _w += _children[i]->getWidth() + _spacing;
+ }
+
+
_h = MAX(_h, (int16)(_children[i]->getHeight() + _paddingTop + _paddingBottom));
}
}
@@ -197,19 +219,21 @@ void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common
void ThemeEval::addDialog(const Common::String &name, const Common::String &overlays, bool enabled) {
int16 x, y;
- int16 w, h;
+ uint16 w, h;
+
+ ThemeLayout *layout = 0;
if (overlays == "screen") {
- x = y = 0;
- w = g_system->getOverlayWidth();
- h = g_system->getOverlayHeight();
+ layout = new ThemeLayoutMain(0, 0, g_system->getOverlayWidth(), g_system->getOverlayHeight());
} else if (overlays == "screen_center") {
- x = y = w = h = -1;
- } else if (!getWidgetData(overlays, x, y, (uint16&)w, (uint16&)h)) {
- error("Error when loading dialog position for '%s'", overlays.c_str());
+ layout = new ThemeLayoutMain(-1, -1, -1, -1);
+ } else if (getWidgetData(overlays, x, y, w, h)) {
+ layout = new ThemeLayoutMain(x, y, w, h);
}
- ThemeLayout *layout = new ThemeLayoutMain(x, y, w, h);
+ if (!layout)
+ error("Error when loading dialog position for '%s'", overlays.c_str());
+
_layouts[name] = layout;
layout->setPadding(
diff --git a/gui/ThemeEval.h b/gui/ThemeEval.h
index 7df4d60aa4..4d5a3db5f6 100644
--- a/gui/ThemeEval.h
+++ b/gui/ThemeEval.h
@@ -52,7 +52,7 @@ public:
ThemeLayout(ThemeLayout *p, const Common::String &name) :
_parent(p), _name(name), _x(0), _y(0), _w(-1), _h(-1), _reverse(false),
_paddingLeft(0), _paddingRight(0), _paddingTop(0), _paddingBottom(0),
- _centered(false) { }
+ _centered(false), _defaultW(-1), _defaultH(-1) { }
virtual ~ThemeLayout() {
_children.clear();
@@ -375,7 +375,7 @@ public:
}
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
- _layouts["Dialog.ScummSaveLoad"]->debugDraw(screen, font);
+ _layouts["Dialog.Browser"]->debugDraw(screen, font);
// _layouts["Dialog.GameOptions_Graphics"]->debugDraw(screen, font);
}
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 6244895719..f2dfb4fd1f 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -651,15 +651,18 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W
if (!ready())
return;
+ Common::Rect dr = r;
+ dr.left += deltax;
+
if (inverted) {
queueDD(kDDTextSelectionBackground, r);
- queueDDText(kTextDataInverted, r, str, false, useEllipsis, align);
+ queueDDText(kTextDataInverted, dr, str, false, useEllipsis, align);
return;
}
switch (font) {
case kFontStyleNormal:
- queueDDText(kTextDataNormalFont, r, str, true, useEllipsis, align);
+ queueDDText(kTextDataNormalFont, dr, str, true, useEllipsis, align);
return;
default:
@@ -668,15 +671,15 @@ void ThemeRenderer::drawText(const Common::Rect &r, const Common::String &str, W
switch (state) {
case kStateDisabled:
- queueDDText(kTextDataDisabled, r, str, true, useEllipsis, align);
+ queueDDText(kTextDataDisabled, dr, str, true, useEllipsis, align);
return;
case kStateHighlight:
- queueDDText(kTextDataHover, r, str, true, useEllipsis, align);
+ queueDDText(kTextDataHover, dr, str, true, useEllipsis, align);
return;
case kStateEnabled:
- queueDDText(kTextDataDefault, r, str, true, useEllipsis, align);
+ queueDDText(kTextDataDefault, dr, str, true, useEllipsis, align);
return;
}
}
@@ -719,9 +722,9 @@ void ThemeRenderer::updateScreen() {
renderDirtyScreen();
- // _vectorRenderer->fillSurface();
- // themeEval()->debugDraw(_screen, _font);
- // _vectorRenderer->copyWholeFrame(_system);
+// _vectorRenderer->fillSurface();
+// themeEval()->debugDraw(_screen, _font);
+// _vectorRenderer->copyWholeFrame(_system);
}
void ThemeRenderer::renderDirtyScreen() {
diff --git a/gui/browser.cpp b/gui/browser.cpp
index 41d3d15bb6..21d492f942 100644
--- a/gui/browser.cpp
+++ b/gui/browser.cpp
@@ -133,29 +133,29 @@ int BrowserDialog::runModal() {
*/
BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)
- : Dialog("browser") {
+ : Dialog("Browser") {
_isDirBrowser = dirBrowser;
_fileList = NULL;
_currentPath = NULL;
// Headline - TODO: should be customizable during creation time
- new StaticTextWidget(this, "browser_headline", title);
+ new StaticTextWidget(this, "Browser.Headline", title);
// Current path - TODO: handle long paths ?
- _currentPath = new StaticTextWidget(this, "browser_path", "DUMMY");
+ _currentPath = new StaticTextWidget(this, "Browser.Path", "DUMMY");
// Add file list
- _fileList = new ListWidget(this, "browser_list");
+ _fileList = new ListWidget(this, "Browser.List");
_fileList->setNumberingMode(kListNumberingOff);
_fileList->setEditable(false);
_fileList->setHints(THEME_HINT_PLAIN_COLOR);
// Buttons
- new ButtonWidget(this, "browser_up", "Go up", kGoUpCmd, 0);
- new ButtonWidget(this, "browser_cancel", "Cancel", kCloseCmd, 0);
- new ButtonWidget(this, "browser_choose", "Choose", kChooseCmd, 0);
+ new ButtonWidget(this, "Browser.Up", "Go up", kGoUpCmd, 0);
+ new ButtonWidget(this, "Browser.Cancel", "Cancel", kCloseCmd, 0);
+ new ButtonWidget(this, "Browser.Choose", "Choose", kChooseCmd, 0);
}
void BrowserDialog::open() {
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 4c1e57a52c..41de1be85f 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -401,7 +401,7 @@
"<def var = 'Padding.Left' value = '16' /> "
"<def var = 'Padding.Right' value = '16' /> "
"<def var = 'Padding.Top' value = '16' /> "
-"<def var = 'ListWidget.hlLeftPadding' value = '8'/> "
+"<def var = 'ListWidget.hlLeftPadding' value = '0'/> "
"<def var = 'ListWidget.hlRightPadding' value = '16'/> "
"<def var = 'PopUpWidget.labelSpacing' value = '10' /> "
"<widget name = 'OptionsLabel' "
@@ -423,7 +423,7 @@
"size = '-1, Globals.Line.Height' "
"/> "
"<widget name = 'ListWidget' "
-"padding = '7, 5, 3, 3' "
+"padding = '5, 0, 8, 0' "
"/> "
"<widget name = 'PopUpWidget' "
"padding = '7, 5, 0, 0' "
@@ -487,6 +487,29 @@
"</layout> "
"</layout> "
"</dialog> "
+"<dialog name = 'Browser' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> "
+"<layout type = 'vertical' padding = '8, 8, 8, 8' direction = 'bottom2top'> "
+"<layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'> "
+"<widget name = 'Choose' "
+"type = 'Button' "
+"/> "
+"<widget name = 'Cancel' "
+"type = 'Button' "
+"/> "
+"<space/> "
+"<widget name = 'Up' "
+"type = 'Button' "
+"/> "
+"</layout> "
+"<widget name = 'List'/> "
+"<widget name = 'Path' "
+"height = 'Globals.Line.Height' "
+"/> "
+"<widget name = 'Headline' "
+"height = 'Globals.Line.Height' "
+"/> "
+"</layout> "
+"</dialog> "
"<dialog name = 'GlobalOptions' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> "
"<layout type = 'vertical' padding = '0, 0, 0, 0' direction = 'bottom2top'> "
"<layout type = 'horizontal' direction = 'right2left' padding = '16, 16, 16, 16'> "
diff --git a/gui/themes/modern.stx b/gui/themes/modern.stx
index a0a4bfad0a..3551b637df 100644
--- a/gui/themes/modern.stx
+++ b/gui/themes/modern.stx
@@ -462,7 +462,7 @@
<def var = 'Padding.Right' value = '16' />
<def var = 'Padding.Top' value = '16' />
- <def var = 'ListWidget.hlLeftPadding' value = '8'/>
+ <def var = 'ListWidget.hlLeftPadding' value = '0'/>
<def var = 'ListWidget.hlRightPadding' value = '16'/>
<def var = 'PopUpWidget.labelSpacing' value = '10' />
@@ -485,7 +485,7 @@
size = '-1, Globals.Line.Height'
/>
<widget name = 'ListWidget'
- padding = '7, 5, 3, 3'
+ padding = '5, 0, 8, 0'
/>
<widget name = 'PopUpWidget'
padding = '7, 5, 0, 0'
@@ -552,6 +552,31 @@
</layout>
</dialog>
+ <dialog name = 'Browser' overlays = 'Dialog.Launcher.GameList' shading = 'dim'>
+ <layout type = 'vertical' padding = '8, 8, 8, 8' direction = 'bottom2top'>
+ <layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'>
+ <widget name = 'Choose'
+ type = 'Button'
+ />
+ <widget name = 'Cancel'
+ type = 'Button'
+ />
+ <space/>
+ <widget name = 'Up'
+ type = 'Button'
+ />
+ </layout>
+ <widget name = 'List'/>
+ <widget name = 'Path'
+ height = 'Globals.Line.Height'
+ />
+ <widget name = 'Headline'
+ height = 'Globals.Line.Height'
+ />
+ </layout>
+ </dialog>
+
+
<dialog name = 'GlobalOptions' overlays = 'Dialog.Launcher.GameList' shading = 'dim'>
<layout type = 'vertical' padding = '0, 0, 0, 0' direction = 'bottom2top'>
<layout type = 'horizontal' direction = 'right2left' padding = '16, 16, 16, 16'>