diff options
author | alberth <alberth@openttd.org> | 2009-07-18 10:46:55 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-07-18 10:46:55 +0000 |
commit | 36576371c05edf9a3498196d7ebdb8824a6910d1 (patch) | |
tree | 0b847859d28abe6988089bd80682f0d9b0f40412 /src/intro_gui.cpp | |
parent | 2b374824dcd55fef5cf6afe727f1ab914b19a1d2 (diff) | |
download | openttd-36576371c05edf9a3498196d7ebdb8824a6910d1.tar.xz |
(svn r16871) -Codechange: Generalize GetWidgetContentSize to UpdateWidgetSize for better control over widget size and resize steps.
Diffstat (limited to 'src/intro_gui.cpp')
-rw-r--r-- | src/intro_gui.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index dcc55b131..9b2c8511b 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -83,16 +83,18 @@ struct SelectGameWindow : public Window { } } - virtual Dimension GetWidgetContentSize(int widget) + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize) { - Dimension d = {0, 0}; - if (widget == SGI_DIFFICULTIES) { - for (uint i = STR_DIFFICULTY_LEVEL_EASY; i <= STR_DIFFICULTY_LEVEL_CUSTOM; i++) { - SetDParam(0, i); - d = maxdim(d, GetStringBoundingBox(STR_INTRO_DIFFICULTY)); - } + if (widget != SGI_DIFFICULTIES) return; + + Dimension textdim = {0, 0}; + for (uint i = STR_DIFFICULTY_LEVEL_EASY; i <= STR_DIFFICULTY_LEVEL_CUSTOM; i++) { + SetDParam(0, i); + textdim = maxdim(textdim, GetStringBoundingBox(STR_INTRO_DIFFICULTY)); } - return d; + textdim.width += padding.width; + textdim.height += padding.height; + *size = maxdim(*size, textdim); } virtual void OnClick(Point pt, int widget) |