[Scummvm-cvs-logs] SF.net SVN: scummvm:[33702] scummvm/branches/gsoc2008-gui/gui
Tanoku at users.sourceforge.net
Tanoku at users.sourceforge.net
Fri Aug 8 17:06:29 CEST 2008
Revision: 33702
http://scummvm.svn.sourceforge.net/scummvm/?rev=33702&view=rev
Author: Tanoku
Date: 2008-08-08 15:06:28 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
Browser dialog.
Improved layout expansion in the layout parser.
Fixed serious coordinates initialization bug.
Modified Paths:
--------------
scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
scummvm/branches/gsoc2008-gui/gui/browser.cpp
scummvm/branches/gsoc2008-gui/gui/themes/default.inc
scummvm/branches/gsoc2008-gui/gui/themes/modern.stx
Modified: scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/ListWidget.cpp 2008-08-08 15:06:28 UTC (rev 33702)
@@ -499,8 +499,18 @@
_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];
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp 2008-08-08 15:06:28 UTC (rev 33702)
@@ -65,6 +65,9 @@
_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 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 @@
}
_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 @@
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::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(
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.h 2008-08-08 15:06:28 UTC (rev 33702)
@@ -52,7 +52,7 @@
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 @@
}
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);
}
Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp 2008-08-08 15:06:28 UTC (rev 33702)
@@ -651,15 +651,18 @@
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 @@
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 @@
renderDirtyScreen();
- // _vectorRenderer->fillSurface();
- // themeEval()->debugDraw(_screen, _font);
- // _vectorRenderer->copyWholeFrame(_system);
+// _vectorRenderer->fillSurface();
+// themeEval()->debugDraw(_screen, _font);
+// _vectorRenderer->copyWholeFrame(_system);
}
void ThemeRenderer::renderDirtyScreen() {
Modified: scummvm/branches/gsoc2008-gui/gui/browser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/browser.cpp 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/browser.cpp 2008-08-08 15:06:28 UTC (rev 33702)
@@ -133,29 +133,29 @@
*/
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() {
Modified: scummvm/branches/gsoc2008-gui/gui/themes/default.inc
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/default.inc 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/themes/default.inc 2008-08-08 15:06:28 UTC (rev 33702)
@@ -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'> "
Modified: scummvm/branches/gsoc2008-gui/gui/themes/modern.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/modern.stx 2008-08-08 14:56:34 UTC (rev 33701)
+++ scummvm/branches/gsoc2008-gui/gui/themes/modern.stx 2008-08-08 15:06:28 UTC (rev 33702)
@@ -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'>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list