Merge lp:~nomeata/widelands/bug887737 into lp:widelands

Proposed by Joachim Breitner
Status: Merged
Merged at revision: 6201
Proposed branch: lp:~nomeata/widelands/bug887737
Merge into: lp:widelands
Diff against target: 288 lines (+40/-43)
3 files modified
src/ui_basic/box.cc (+18/-25)
src/ui_basic/box.h (+7/-3)
src/wui/general_statistics_menu.cc (+15/-15)
To merge this branch: bzr merge lp:~nomeata/widelands/bug887737
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+90035@code.launchpad.net
To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Joachim, thanks! I much appreciate the democratical sense you've shown by implementing this against your own opinion.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ui_basic/box.cc'
--- src/ui_basic/box.cc 2011-11-30 21:38:37 +0000
+++ src/ui_basic/box.cc 2012-01-25 03:00:32 +0000
@@ -195,7 +195,7 @@
195 // Second pass: Count number of infinite spaces195 // Second pass: Count number of infinite spaces
196 uint32_t infspace_count = 0;196 uint32_t infspace_count = 0;
197 for (uint32_t idx = 0; idx < m_items.size(); ++idx)197 for (uint32_t idx = 0; idx < m_items.size(); ++idx)
198 if (m_items[idx].type == Item::ItemInfSpace)198 if (m_items[idx].fillspace)
199 infspace_count++;199 infspace_count++;
200200
201 // Third pass: Distribute left over space to all infinite spaces. To201 // Third pass: Distribute left over space to all infinite spaces. To
@@ -205,10 +205,10 @@
205 uint32_t max_depths =205 uint32_t max_depths =
206 m_orientation == Horizontal ? get_inner_w() : get_inner_h();206 m_orientation == Horizontal ? get_inner_w() : get_inner_h();
207 for (uint32_t idx = 0; idx < m_items.size(); ++idx)207 for (uint32_t idx = 0; idx < m_items.size(); ++idx)
208 if (m_items[idx].type == Item::ItemInfSpace) {208 if (m_items[idx].fillspace) {
209 m_items[idx].u.assigned_space =209 m_items[idx].assigned_var_depth =
210 (max_depths - totaldepth) / infspace_count;210 (max_depths - totaldepth) / infspace_count;
211 totaldepth += m_items[idx].u.assigned_space;211 totaldepth += m_items[idx].assigned_var_depth;
212 infspace_count--;212 infspace_count--;
213 }213 }
214214
@@ -256,8 +256,11 @@
256 * @param fullsize when true, @p panel will be extended to cover the entire width (or height)256 * @param fullsize when true, @p panel will be extended to cover the entire width (or height)
257 * of the box for horizontal (vertical) panels. If false, then @p panel may end up smaller;257 * of the box for horizontal (vertical) panels. If false, then @p panel may end up smaller;
258 * in that case, it will be aligned according to @p align258 * in that case, it will be aligned according to @p align
259 *
260 * @param fillspace when true, @p panel will be expanded as an infinite space would be. This can be used to make buttons fill a box completely.
261 *
259 */262 */
260void Box::add(Panel * const panel, uint32_t const align, bool fullsize)263void Box::add(Panel * const panel, uint32_t const align, bool fullsize, bool fillspace)
261{264{
262 Item it;265 Item it;
263266
@@ -265,6 +268,8 @@
265 it.u.panel.panel = panel;268 it.u.panel.panel = panel;
266 it.u.panel.align = align;269 it.u.panel.align = align;
267 it.u.panel.fullsize = fullsize;270 it.u.panel.fullsize = fullsize;
271 it.fillspace = fillspace;
272 it.assigned_var_depth = 0;
268273
269 m_items.push_back(it);274 m_items.push_back(it);
270275
@@ -281,6 +286,7 @@
281286
282 it.type = Item::ItemSpace;287 it.type = Item::ItemSpace;
283 it.u.space = space;288 it.u.space = space;
289 it.fillspace = false;
284290
285 m_items.push_back(it);291 m_items.push_back(it);
286292
@@ -295,8 +301,10 @@
295{301{
296 Item it;302 Item it;
297303
298 it.type = Item::ItemInfSpace;304 it.type = Item::ItemSpace;
299 it.u.assigned_space = 0;305 it.u.space = 0;
306 it.assigned_var_depth = 0;
307 it.fillspace = true;
300308
301 m_items.push_back(it);309 m_items.push_back(it);
302310
@@ -330,11 +338,6 @@
330 breadth = 0;338 breadth = 0;
331 break;339 break;
332340
333 case Item::ItemInfSpace:
334 depth = 0;
335 breadth = 0;
336 break;
337
338 default:341 default:
339 throw wexception("Box::get_item_size: bad type %u", it.type);342 throw wexception("Box::get_item_size: bad type %u", it.type);
340 }343 }
@@ -342,7 +345,7 @@
342345
343/**346/**
344 * Retrieve the given item's size. This differs from get_item_desired_size only347 * Retrieve the given item's size. This differs from get_item_desired_size only
345 * for InfSpace items, at least for now.348 * for expanding items, at least for now.
346 */349 */
347void Box::get_item_size350void Box::get_item_size
348 (uint32_t const idx, uint32_t & depth, uint32_t & breadth)351 (uint32_t const idx, uint32_t & depth, uint32_t & breadth)
@@ -351,16 +354,8 @@
351354
352 Item const & it = m_items[idx];355 Item const & it = m_items[idx];
353356
354 switch (it.type) {357 get_item_desired_size(idx, depth, breadth);
355 case Item::ItemInfSpace:358 depth += it.assigned_var_depth;
356 depth = it.u.assigned_space;
357 breadth = 0;
358 break;
359
360 default:
361 get_item_desired_size(idx, depth, breadth);
362 }
363
364}359}
365360
366/**361/**
@@ -424,8 +419,6 @@
424 }419 }
425420
426 case Item::ItemSpace:; // no need to do anything421 case Item::ItemSpace:; // no need to do anything
427
428 case Item::ItemInfSpace:; // no need to do anything
429 };422 };
430}423}
431424
432425
=== modified file 'src/ui_basic/box.h'
--- src/ui_basic/box.h 2011-11-30 21:38:37 +0000
+++ src/ui_basic/box.h 2012-01-25 03:00:32 +0000
@@ -55,7 +55,10 @@
5555
56 int32_t get_nritems() const {return m_items.size();}56 int32_t get_nritems() const {return m_items.size();}
5757
58 void add(Panel * panel, uint32_t align, bool fullsize = false);58 void add(Panel * panel,
59 uint32_t align,
60 bool fullsize = false,
61 bool fillspace = false);
59 void add_space(uint32_t space);62 void add_space(uint32_t space);
60 void add_inf_space();63 void add_inf_space();
61 bool is_snap_target() const {return true;}64 bool is_snap_target() const {return true;}
@@ -82,7 +85,6 @@
82 enum Type {85 enum Type {
83 ItemPanel,86 ItemPanel,
84 ItemSpace,87 ItemSpace,
85 ItemInfSpace
86 };88 };
8789
88 Type type;90 Type type;
@@ -94,8 +96,10 @@
94 bool fullsize;96 bool fullsize;
95 } panel;97 } panel;
96 uint32_t space;98 uint32_t space;
97 uint32_t assigned_space;
98 } u;99 } u;
100
101 bool fillspace;
102 uint32_t assigned_var_depth;
99 };103 };
100104
101 bool m_scrolling;105 bool m_scrolling;
102106
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2011-11-30 21:38:37 +0000
+++ src/wui/general_statistics_menu.cc 2012-01-25 03:00:32 +0000
@@ -157,11 +157,11 @@
157157
158 m_cbs[p - 1] = &cb;158 m_cbs[p - 1] = &cb;
159159
160 hbox1->add(&cb, UI::Box::AlignLeft);160 hbox1->add(&cb, UI::Box::AlignLeft, false, true);
161 } else // player nr p does not exist161 } else // player nr p does not exist
162 m_cbs[p - 1] = 0;162 m_cbs[p - 1] = 0;
163163
164 m_box.add(hbox1, UI::Box::AlignTop);164 m_box.add(hbox1, UI::Box::AlignTop, true);
165165
166 UI::Box * hbox2 = new UI::Box(&m_box, 0, 0, UI::Box::Horizontal, 0, 0, 1);166 UI::Box * hbox2 = new UI::Box(&m_box, 0, 0, UI::Box::Horizontal, 0, 0, 1);
167167
@@ -173,7 +173,7 @@
173 g_gr->get_picture(PicMod_Game, "pics/genstats_landsize.png"),173 g_gr->get_picture(PicMod_Game, "pics/genstats_landsize.png"),
174 _("Land"),174 _("Land"),
175 &btn);175 &btn);
176 hbox2->add(btn, UI::Box::AlignLeft);176 hbox2->add(btn, UI::Box::AlignLeft, false, true);
177177
178 m_radiogroup.add_button178 m_radiogroup.add_button
179 (hbox2,179 (hbox2,
@@ -181,7 +181,7 @@
181 g_gr->get_picture(PicMod_Game, "pics/genstats_nrworkers.png"),181 g_gr->get_picture(PicMod_Game, "pics/genstats_nrworkers.png"),
182 _("Workers"),182 _("Workers"),
183 &btn);183 &btn);
184 hbox2->add(btn, UI::Box::AlignLeft);184 hbox2->add(btn, UI::Box::AlignLeft, false, true);
185185
186 m_radiogroup.add_button186 m_radiogroup.add_button
187 (hbox2,187 (hbox2,
@@ -189,7 +189,7 @@
189 g_gr->get_picture(PicMod_Game, "pics/genstats_nrbuildings.png"),189 g_gr->get_picture(PicMod_Game, "pics/genstats_nrbuildings.png"),
190 _("Buildings"),190 _("Buildings"),
191 &btn);191 &btn);
192 hbox2->add(btn, UI::Box::AlignLeft);192 hbox2->add(btn, UI::Box::AlignLeft, false, true);
193193
194 m_radiogroup.add_button194 m_radiogroup.add_button
195 (hbox2,195 (hbox2,
@@ -197,7 +197,7 @@
197 g_gr->get_picture(PicMod_Game, "pics/genstats_nrwares.png"),197 g_gr->get_picture(PicMod_Game, "pics/genstats_nrwares.png"),
198 _("Wares"),198 _("Wares"),
199 &btn);199 &btn);
200 hbox2->add(btn, UI::Box::AlignLeft);200 hbox2->add(btn, UI::Box::AlignLeft, false, true);
201201
202 m_radiogroup.add_button202 m_radiogroup.add_button
203 (hbox2,203 (hbox2,
@@ -205,7 +205,7 @@
205 g_gr->get_picture(PicMod_Game, "pics/genstats_productivity.png"),205 g_gr->get_picture(PicMod_Game, "pics/genstats_productivity.png"),
206 _("Productivity"),206 _("Productivity"),
207 &btn);207 &btn);
208 hbox2->add(btn, UI::Box::AlignLeft);208 hbox2->add(btn, UI::Box::AlignLeft, false, true);
209209
210 m_radiogroup.add_button210 m_radiogroup.add_button
211 (hbox2,211 (hbox2,
@@ -213,7 +213,7 @@
213 g_gr->get_picture(PicMod_Game, "pics/genstats_casualties.png"),213 g_gr->get_picture(PicMod_Game, "pics/genstats_casualties.png"),
214 _("Casualties"),214 _("Casualties"),
215 &btn);215 &btn);
216 hbox2->add(btn, UI::Box::AlignLeft);216 hbox2->add(btn, UI::Box::AlignLeft, false, true);
217217
218 m_radiogroup.add_button218 m_radiogroup.add_button
219 (hbox2,219 (hbox2,
@@ -221,7 +221,7 @@
221 g_gr->get_picture(PicMod_Game, "pics/genstats_kills.png"),221 g_gr->get_picture(PicMod_Game, "pics/genstats_kills.png"),
222 _("Kills"),222 _("Kills"),
223 &btn);223 &btn);
224 hbox2->add(btn, UI::Box::AlignLeft);224 hbox2->add(btn, UI::Box::AlignLeft, false, true);
225225
226 m_radiogroup.add_button226 m_radiogroup.add_button
227 (hbox2,227 (hbox2,
@@ -229,7 +229,7 @@
229 g_gr->get_picture(PicMod_Game, "pics/genstats_msites_lost.png"),229 g_gr->get_picture(PicMod_Game, "pics/genstats_msites_lost.png"),
230 _("Military buildings lost"),230 _("Military buildings lost"),
231 &btn);231 &btn);
232 hbox2->add(btn, UI::Box::AlignLeft);232 hbox2->add(btn, UI::Box::AlignLeft, false, true);
233233
234 m_radiogroup.add_button234 m_radiogroup.add_button
235 (hbox2,235 (hbox2,
@@ -237,7 +237,7 @@
237 g_gr->get_picture(PicMod_Game, "pics/genstats_msites_defeated.png"),237 g_gr->get_picture(PicMod_Game, "pics/genstats_msites_defeated.png"),
238 _("Military buildings defeated"),238 _("Military buildings defeated"),
239 &btn);239 &btn);
240 hbox2->add(btn, UI::Box::AlignLeft);240 hbox2->add(btn, UI::Box::AlignLeft, false, true);
241241
242 m_radiogroup.add_button242 m_radiogroup.add_button
243 (hbox2,243 (hbox2,
@@ -245,7 +245,7 @@
245 g_gr->get_picture(PicMod_Game, "pics/genstats_civil_blds_lost.png"),245 g_gr->get_picture(PicMod_Game, "pics/genstats_civil_blds_lost.png"),
246 _("Civilian buildings lost"),246 _("Civilian buildings lost"),
247 &btn);247 &btn);
248 hbox2->add(btn, UI::Box::AlignLeft);248 hbox2->add(btn, UI::Box::AlignLeft, false, true);
249249
250 m_radiogroup.add_button250 m_radiogroup.add_button
251 (hbox2,251 (hbox2,
@@ -253,7 +253,7 @@
253 g_gr->get_picture(PicMod_Game, "pics/genstats_militarystrength.png"),253 g_gr->get_picture(PicMod_Game, "pics/genstats_militarystrength.png"),
254 _("Military"),254 _("Military"),
255 &btn);255 &btn);
256 hbox2->add(btn, UI::Box::AlignLeft);256 hbox2->add(btn, UI::Box::AlignLeft, false, true);
257257
258 if (hook) {258 if (hook) {
259 m_radiogroup.add_button259 m_radiogroup.add_button
@@ -262,14 +262,14 @@
262 g_gr->get_picture(PicMod_Game, cs_pic),262 g_gr->get_picture(PicMod_Game, cs_pic),
263 cs_name.c_str(),263 cs_name.c_str(),
264 &btn);264 &btn);
265 hbox2->add(btn, UI::Box::AlignLeft);265 hbox2->add(btn, UI::Box::AlignLeft, false, true);
266 }266 }
267267
268 m_radiogroup.set_state(m_selected_information);268 m_radiogroup.set_state(m_selected_information);
269 m_radiogroup.changedto.connect269 m_radiogroup.changedto.connect
270 (boost::bind(&General_Statistics_Menu::radiogroup_changed, this, _1));270 (boost::bind(&General_Statistics_Menu::radiogroup_changed, this, _1));
271271
272 m_box.add(hbox2, UI::Box::AlignTop);272 m_box.add(hbox2, UI::Box::AlignTop, true);
273273
274 m_box.add274 m_box.add
275 (new WUIPlot_Area_Slider275 (new WUIPlot_Area_Slider

Subscribers

People subscribed via source and target branches

to status/vote changes: