aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/PopUpWidget.cpp29
-rw-r--r--gui/ThemeClassic.cpp30
-rw-r--r--gui/ThemeNew.cpp46
-rw-r--r--gui/theme.h15
-rw-r--r--gui/themes/modern.ini14
5 files changed, 107 insertions, 27 deletions
diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp
index 09b68c882f..c04d3d7767 100644
--- a/gui/PopUpWidget.cpp
+++ b/gui/PopUpWidget.cpp
@@ -408,36 +408,15 @@ void PopUpWidget::drawWidget(bool hilite) {
int x = _x + _labelWidth;
int w = _w - _labelWidth;
- // Draw a thin frame around us.
- g_gui.theme()->drawWidgetBackground(Common::Rect(x, _y, x+w, _y+_h), _hints | THEME_HINT_USE_SHADOW, Theme::kWidgetBackgroundBorderSmall);
-
// Draw the label, if any
if (_labelWidth > 0)
g_gui.theme()->drawText(Common::Rect(_x+2,_y+3,_x+2+_labelWidth, _y+3+g_gui.theme()->getFontHeight()), _label,
isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, Theme::kTextAlignRight);
- // Draw a set of arrows at the right end to signal this is a dropdown/popup
- /*Common::Point p0, p1;
-
- p0 = Common::Point(x + w + 1 - _h / 2, _y + 4);
- p1 = Common::Point(x + w + 1 - _h / 2, _y + _h - 4);
-
- Graphics::Surface &surf = g_gui.getScreen();
- OverlayColor color = !isEnabled() ? gui->_color : hilite ? gui->_textcolorhi : gui->_textcolor;
-
- // Evil HACK to draw filled triangles
- // FIXME: The "big" version is pretty ugly.
- for (; p1.y - p0.y > 1; p0.y++, p0.x--, p1.y--, p1.x++) {
- surf.drawLine(p0.x, p0.y, p1.x, p0.y, color);
- surf.drawLine(p0.x, p1.y, p1.x, p1.y, color);
- }*/
-
- // Draw the selected entry, if any
- if (_selectedItem >= 0) {
- TextAlignment align = (g_gui.getStringWidth(_entries[_selectedItem].name) > w-6) ? kTextAlignRight : kTextAlignLeft;
- g_gui.theme()->drawText(Common::Rect(x+2, _y+3, _x+2+w-6, _y+3+g_gui.theme()->getFontHeight()), _entries[_selectedItem].name,
- isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, g_gui.theme()->convertAligment(align), false, _leftPadding);
- }
+ Common::String sel = "";
+ if (_selectedItem >= 0)
+ sel = _entries[_selectedItem].name;
+ g_gui.theme()->drawPopUpWidget(Common::Rect(x, _y, x+w, _y+_h), sel, _leftPadding, isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled, g_gui.theme()->convertAligment(kTextAlignLeft));
}
} // End of namespace GUI
diff --git a/gui/ThemeClassic.cpp b/gui/ThemeClassic.cpp
index d33897774d..df2fc4751e 100644
--- a/gui/ThemeClassic.cpp
+++ b/gui/ThemeClassic.cpp
@@ -261,6 +261,36 @@ void ThemeClassic::drawSlider(const Common::Rect &r, int width, kState state) {
addDirtyRect(r);
}
+void ThemeClassic::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align) {
+ if (!_initOk)
+ return;
+
+ restoreBackground(r);
+
+ box(r.left, r.top, r.width(), r.height());
+
+ Common::Point p0, p1;
+
+ p0 = Common::Point(r.right + 1 - r.height() / 2, r.top + 4);
+ p1 = Common::Point(r.right + 1 - r.height() / 2, r.bottom - 4);
+
+ OverlayColor color = getColor(state);
+
+ // Evil HACK to draw filled triangles
+ // FIXME: The "big" version is pretty ugly.
+ for (; p1.y - p0.y > 1; p0.y++, p0.x--, p1.y--, p1.x++) {
+ _screen.drawLine(p0.x, p0.y, p1.x, p0.y, color);
+ _screen.drawLine(p0.x, p1.y, p1.x, p1.y, color);
+ }
+
+ if (sel != "") {
+ Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + _font->getFontHeight());
+ _font->drawString(&_screen, sel, text.left, text.top, text.width(), color, convertAligment(align), deltax, false);
+ }
+
+ addDirtyRect(r);
+}
+
void ThemeClassic::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state) {
if (!_initOk)
return;
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp
index 36575c0e04..51080d160f 100644
--- a/gui/ThemeNew.cpp
+++ b/gui/ThemeNew.cpp
@@ -38,7 +38,7 @@
#define kShadowTr3 64
#define kShadowTr4 128
-#define THEME_VERSION 8
+#define THEME_VERSION 9
using Graphics::Surface;
@@ -211,6 +211,11 @@ _lastUsedBitMask(0), _forceRedraw(false), _fonts(), _imageHandles(0), _images(0)
_configFile.getKey("button_bkgd", "pixmaps", imageHandlesTable[kButtonBkgd]);
_configFile.getKey("theme_logo", "pixmaps", imageHandlesTable[kThemeLogo]);
+
+ _configFile.getKey("popupwidget_corner", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdCorner]);
+ _configFile.getKey("popupwidget_top", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdTop]);
+ _configFile.getKey("popupwidget_left", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdLeft]);
+ _configFile.getKey("popupwidget_bkgd", "pixmaps", imageHandlesTable[kPopUpWidgetBkgd]);
// load the gradient factors from the config file
getFactorFromConfig(_configFile, "main_dialog", _gradientFactors[kMainDialogFactor]);
@@ -229,6 +234,8 @@ _lastUsedBitMask(0), _forceRedraw(false), _fonts(), _imageHandles(0), _images(0)
getFactorFromConfig(_configFile, "scrollbar", _gradientFactors[kScrollbarFactor]);
getFactorFromConfig(_configFile, "scrollbar_background", _gradientFactors[kScrollbarBkgdFactor]);
+
+ getFactorFromConfig(_configFile, "popupwidget", _gradientFactors[kPopUpWidgetFactor]);
// load values with default values from the config file
getExtraValueFromConfig(_configFile, "shadow_left_width", _shadowLeftWidth, 2);
@@ -616,6 +623,38 @@ void ThemeNew::drawSlider(const Common::Rect &r, int width, kState state) {
addDirtyRect(r);
}
+void ThemeNew::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align) {
+ if (!_initOk)
+ return;
+
+ OverlayColor start = _colors[kPopUpWidgetStart], end = _colors[kPopUpWidgetEnd];
+ if (state == kStateHighlight) {
+ start = _colors[kPopUpWidgetHighlightStart];
+ end = _colors[kPopUpWidgetHighlightEnd];
+ }
+
+ drawRectMasked(r, surface(kPopUpWidgetBkgdCorner), surface(kPopUpWidgetBkgdTop), surface(kPopUpWidgetBkgdLeft), surface(kPopUpWidgetBkgd),
+ (state == kStateDisabled) ? -30 : 256, start, end, _gradientFactors[kPopUpWidgetFactor]);
+
+ const Graphics::Surface *arrow = surface(kWidgetArrow);
+ Common::Rect arrowRect(r.right - 4 - arrow->w, r.top + 4, r.right - 4, r.top + 4 + arrow->h);
+ arrowRect.clip(r);
+
+ drawSurface(arrowRect, arrow, false, false, (state == kStateDisabled) ? -30 : 256);
+
+ arrowRect.top += arrow->h + 1;
+ arrowRect.bottom += arrow->h + 1;
+ arrowRect.clip(r);
+ drawSurface(arrowRect, arrow, true, false, (state == kStateDisabled) ? -30 : 256);
+
+ if (sel != "") {
+ Common::Rect text(r.left + 2, r.top + 3, r.right - 4, r.top + 3 + getFont()->getFontHeight());
+ getFont()->drawString(&_screen, sel, text.left, text.top, text.width(), getColor(state), convertAligment(align), deltax, false);
+ }
+
+ addDirtyRect(r);
+}
+
void ThemeNew::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state) {
if (!_initOk)
return;
@@ -1236,6 +1275,11 @@ void ThemeNew::setupColors() {
getColorFromConfig(_configFile, "scrollbar_slider_highlight_end", _colors[kScrollbarSliderHighlightEnd]);
getColorFromConfig(_configFile, "caret_color", _colors[kCaretColor]);
+
+ getColorFromConfig(_configFile, "popupwidget_start", _colors[kPopUpWidgetStart]);
+ getColorFromConfig(_configFile, "pupupwidget_end", _colors[kPopUpWidgetEnd]);
+ getColorFromConfig(_configFile, "popupwidget_highlight_start", _colors[kPopUpWidgetHighlightStart]);
+ getColorFromConfig(_configFile, "popupwidget_highlight_end", _colors[kPopUpWidgetHighlightEnd]);
}
#define FONT_NAME_NORMAL "newgui_normal"
diff --git a/gui/theme.h b/gui/theme.h
index 8b0e59a6de..1c2f941135 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -138,6 +138,7 @@ public:
virtual void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, kState state = kStateEnabled) = 0;
virtual void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, kState state = kStateEnabled) = 0;
virtual void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state = kStateEnabled) = 0;
+ virtual void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state = kStateEnabled, kTextAlign align = kTextAlignLeft) = 0;
virtual void drawCaret(const Common::Rect &r, bool erase, kState state = kStateEnabled) = 0;
virtual void drawLineSeparator(const Common::Rect &r, kState state = kStateEnabled) = 0;
@@ -234,6 +235,7 @@ public:
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state);
+ void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align);
void drawCaret(const Common::Rect &r, bool erase, kState state);
void drawLineSeparator(const Common::Rect &r, kState state);
private:
@@ -307,6 +309,7 @@ public:
void drawCheckbox(const Common::Rect &r, const String &str, bool checked, kState state);
void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<String> &tabs, int active, uint16 hints, kState state);
void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, kScrollbarState, kState state);
+ void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, kState state, kTextAlign align);
void drawCaret(const Common::Rect &r, bool erase, kState state);
void drawLineSeparator(const Common::Rect &r, kState state);
const Graphics::Surface *getImageSurface(int n) { return _images[n]; }
@@ -420,6 +423,11 @@ public:
kWidgetSmallBkgd = 38,
kThemeLogo = 39,
+
+ kPopUpWidgetBkgdCorner = 40,
+ kPopUpWidgetBkgdTop = 41,
+ kPopUpWidgetBkgdLeft = 42,
+ kPopUpWidgetBkgd = 43,
kImageHandlesMax
};
@@ -490,6 +498,11 @@ private:
kScrollbarButtonHighlightEnd = 37,
kScrollbarSliderHighlightStart = 38,
kScrollbarSliderHighlightEnd = 39,
+
+ kPopUpWidgetStart = 40,
+ kPopUpWidgetEnd = 41,
+ kPopUpWidgetHighlightStart = 42,
+ kPopUpWidgetHighlightEnd = 43,
kColorHandlesMax
};
@@ -513,6 +526,8 @@ private:
kScrollbarFactor = 8,
kScrollbarBkgdFactor = 9,
+
+ kPopUpWidgetFactor = 10,
kMaxGradientFactors
};
diff --git a/gui/themes/modern.ini b/gui/themes/modern.ini
index 444c5aa8b0..456eada976 100644
--- a/gui/themes/modern.ini
+++ b/gui/themes/modern.ini
@@ -1,7 +1,7 @@
# $URL$
# $Id$
[theme]
-version=8
+version=9
[pixmaps]
dialog_corner=dialog_bkgd_corner.bmp
@@ -54,6 +54,11 @@ button_top=button_bkgd_top.bmp
button_left=button_bkgd_left.bmp
button_bkgd=button_bkgd.bmp
+popupwidget_corner=widget_small_bkgd_corner.bmp
+popupwidget_top=widget_small_bkgd_top.bmp
+popupwidget_left=widget_small_bkgd_left.bmp
+popupwidget_bkgd=widget_small_bkgd.bmp
+
theme_logo=logo.bmp
[colors]
@@ -106,6 +111,11 @@ scrollbar_button_highlight_end=200 70 50
scrollbar_slider_highlight_start=255 210 200
scrollbar_slider_highlight_end=200 70 50
+popupwidget_start=246 224 139
+pupupwidget_end=251 241 206
+popupwidget_highlight_start=246 224 139
+popupwidget_highlight_end=251 241 206
+
caret_color=0 0 0
[gradients]
@@ -126,6 +136,8 @@ tab=2
scrollbar=1
scrollbar_background=1
+popupwidget=3
+
[extra]
shadow_left_width=2
shadow_right_width=4