diff options
author | bjarni <bjarni@openttd.org> | 2007-01-24 02:36:55 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2007-01-24 02:36:55 +0000 |
commit | 4dd0d007b1cf1f595fba5d690a096e69c7bbca20 (patch) | |
tree | 6db06687d695ee0417f9694efa9466b841ab1481 /src/widget.cpp | |
parent | 802d1065b2d181ad71b4a1506e5af44b60907859 (diff) | |
download | openttd-4dd0d007b1cf1f595fba5d690a096e69c7bbca20.tar.xz |
(svn r8384) -Codechange: [GUI] instead of writing a resize button function for each window, a global ResizeButtons() is added
Diffstat (limited to 'src/widget.cpp')
-rw-r--r-- | src/widget.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp index 2c6dba2fa..2c21cd74c 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -698,3 +698,50 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt WP(w2,dropdown_d).click_delay = 0; WP(w2,dropdown_d).drag_mode = true; } + +/* Make the buttons in the bottom equal in size */ +void ResizeButtons(Window *w, byte a, byte b, byte c, byte d, byte right) +{ + w->widget[d].right = w->widget[right].left - 1; // now we set the right of the widgets + + /* Now we will find the middle, then the middle of each of the two blocks on each side of the middle. + * This way, if we got leftover pixels from the division, they will be somewhat evenly distributed */ + w->widget[b].right = w->widget[d].right / 2; + w->widget[a].right = w->widget[b].right / 2; + w->widget[c].right = (w->widget[b].right + w->widget[d].right)/2; + /* Now the right side of the buttons are set. We will now set the left sides next to them */ + w->widget[b].left = w->widget[a].right + 1; + w->widget[c].left = w->widget[b].right + 1; + w->widget[d].left = w->widget[c].right + 1; +} + +void ResizeButtons(Window *w, byte a, byte b, byte c, byte right) +{ + w->widget[c].right = w->widget[right].left - 1; // now we set the right of the widgets + + w->widget[a].right = w->widget[c].right / 3; + w->widget[b].right = w->widget[a].right * 2; + + /* Now the right side of the buttons are set. We will now set the left sides next to them */ + w->widget[b].left = w->widget[a].right + 1; + w->widget[c].left = w->widget[b].right + 1; +} + +void ResizeButtons(Window *w, byte a, byte b, byte right) +{ + w->widget[b].right = w->widget[right].left - 1; // now we set the right of the widgets + + w->widget[a].right = w->widget[b].right / 2; + + w->widget[b].left = w->widget[a].right + 1; +} + +void ResizeButtons(Window *w, byte left, byte right) +{ + switch (right - left) { + case 2: ResizeButtons(w, left, left + 1, left + 2); break; + case 3: ResizeButtons(w, left, left + 1, left + 2, left + 3); break; + case 4: ResizeButtons(w, left, left + 1, left + 2, left + 3, left + 4); break; + default: NOT_REACHED(); + } +} |