widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #09781
[Merge] lp:~widelands-dev/widelands/align-cleanup-box into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/align-cleanup-box into lp:widelands.
Commit message:
Refactored UI::Box::add():
- Bumped align argument to the back, because it is the least needed parameter.
- Replaced bool fullsize and bool fillspace with new enum class Resizing { kAlign, kFullSize, kFillSpace, kExpandBoth };
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/align-cleanup-box/+merge/318315
This is a follow-up branch to Hasi's align cleanup which gets rid of most mentions of UI::Align in calls to UI::Box::add().
I also replaced the two bool arguments in that function with an enum class, because I always found the function hard to understand. Better ideas for naming the enum class members are welcome :)
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/align-cleanup-box into lp:widelands.
=== modified file 'src/editor/ui_menus/categorized_item_selection_menu.h'
--- src/editor/ui_menus/categorized_item_selection_menu.h 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/categorized_item_selection_menu.h 2017-02-25 18:55:39 +0000
@@ -96,7 +96,7 @@
tool_(tool) {
current_selection_names_.set_background(
g_gr->images().get("images/wui/window_background_dark.png"));
- add(&tab_panel_, UI::Align::kCenter);
+ add(&tab_panel_);
for (uint32_t category_index = 0; category_index < categories.size(); ++category_index) {
const Widelands::EditorCategory& category = categories.get(category_index);
@@ -120,7 +120,7 @@
horizontal = new UI::Box(vertical, 0, 0, UI::Box::Horizontal);
horizontal->add_space(kSpacing);
- vertical->add(horizontal, UI::Align::kLeft);
+ vertical->add(horizontal);
vertical->add_space(kSpacing);
}
assert(horizontal != nullptr);
@@ -129,13 +129,13 @@
cb->set_state(tool_->is_enabled(i));
cb->changedto.connect(boost::bind(&CategorizedItemSelectionMenu::selected, this, i, _1));
checkboxes_[i] = cb;
- horizontal->add(cb, UI::Align::kLeft);
+ horizontal->add(cb);
horizontal->add_space(kSpacing);
++nitems_handled;
}
tab_panel_.add(category.name(), category.picture(), vertical, category.descname());
}
- add(¤t_selection_names_, UI::Align::kCenter, true);
+ add(¤t_selection_names_, UI::Box::Resizing::kFullSize);
tab_panel_.sigclicked.connect(boost::bind(&CategorizedItemSelectionMenu::update_label, this));
update_label();
}
=== modified file 'src/editor/ui_menus/main_menu.cc'
--- src/editor/ui_menus/main_menu.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/main_menu.cc 2017-02-25 18:55:39 +0000
@@ -90,12 +90,12 @@
0,
g_gr->images().get("images/ui_basic/but5.png"),
_("Exit Editor")) {
- box_.add(&button_new_map_, UI::Align::kCenter);
- box_.add(&button_new_random_map_, UI::Align::kCenter);
- box_.add(&button_load_map_, UI::Align::kCenter);
- box_.add(&button_save_map_, UI::Align::kCenter);
- box_.add(&button_map_options_, UI::Align::kCenter);
- box_.add(&button_exit_editor_, UI::Align::kCenter);
+ box_.add(&button_new_map_);
+ box_.add(&button_new_random_map_);
+ box_.add(&button_load_map_);
+ box_.add(&button_save_map_);
+ box_.add(&button_map_options_);
+ box_.add(&button_exit_editor_);
box_.set_size(width, 6 * button_new_map_.get_h() + 5 * vspacing);
set_inner_size(get_inner_w(), box_.get_h() + 2 * margin);
=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc'
--- src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-02-25 18:55:39 +0000
@@ -86,14 +86,14 @@
show_mapnames_ =
new UI::Button(vbox, "show_mapnames", 0, 0, 2 * butw_, buth_,
g_gr->images().get("images/ui_basic/but1.png"), _("Show Map Names"));
- vbox->add(show_mapnames_, UI::Align::kLeft, true);
+ vbox->add(show_mapnames_, UI::Box::Resizing::kFullSize);
/** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
cb_dont_localize_mapnames_ =
new UI::Checkbox(vbox, Vector2i(0, 0), _("Show original map names"));
cb_dont_localize_mapnames_->set_state(false);
vbox->add_space(2 * padding_);
- vbox->add(cb_dont_localize_mapnames_, UI::Align::kLeft, true);
+ vbox->add(cb_dont_localize_mapnames_, UI::Box::Resizing::kFullSize);
vbox->set_size(get_inner_w(), buth_);
table_.set_column_compare(0, boost::bind(&MainMenuLoadOrSaveMap::compare_players, this, _1, _2));
=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
--- src/editor/ui_menus/main_menu_map_options.cc 2017-02-23 17:58:25 +0000
+++ src/editor/ui_menus/main_menu_map_options.cc 2017-02-25 18:55:39 +0000
@@ -109,29 +109,29 @@
g_gr->images().get("images/ui_basic/but1.png"));
main_box_.add(
- new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Map Name:")), UI::Align::kLeft);
- main_box_.add(&name_, UI::Align::kLeft);
- main_box_.add_space(indent_);
-
- main_box_.add(
- new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Authors:")), UI::Align::kLeft);
- main_box_.add(&author_, UI::Align::kLeft);
- main_box_.add_space(indent_);
-
- main_box_.add(
- new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Description:")), UI::Align::kLeft);
- main_box_.add(descr_, UI::Align::kLeft);
- main_box_.add_space(indent_);
-
- main_box_.add(
- new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Hint (optional):")), UI::Align::kLeft);
- main_box_.add(hint_, UI::Align::kLeft);
- main_box_.add_space(indent_);
-
- main_box_.add(&size_, UI::Align::kLeft);
- main_box_.add_space(indent_);
-
- tags_box_.add(new UI::Textarea(&tags_box_, 0, 0, max_w_, labelh_, _("Tags:")), UI::Align::kLeft);
+ new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Map Name:")));
+ main_box_.add(&name_);
+ main_box_.add_space(indent_);
+
+ main_box_.add(
+ new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Authors:")));
+ main_box_.add(&author_);
+ main_box_.add_space(indent_);
+
+ main_box_.add(
+ new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Description:")));
+ main_box_.add(descr_);
+ main_box_.add_space(indent_);
+
+ main_box_.add(
+ new UI::Textarea(&main_box_, 0, 0, max_w_, labelh_, _("Hint (optional):")));
+ main_box_.add(hint_);
+ main_box_.add_space(indent_);
+
+ main_box_.add(&size_);
+ main_box_.add_space(indent_);
+
+ tags_box_.add(new UI::Textarea(&tags_box_, 0, 0, max_w_, labelh_, _("Tags:")));
add_tag_checkbox(&tags_box_, "unbalanced", localize_tag("unbalanced"));
add_tag_checkbox(&tags_box_, "ffa", localize_tag("ffa"));
add_tag_checkbox(&tags_box_, "1v1", localize_tag("1v1"));
@@ -139,9 +139,8 @@
add_tag_checkbox(&tags_box_, "3teams", localize_tag("3teams"));
add_tag_checkbox(&tags_box_, "4teams", localize_tag("4teams"));
- teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, _("Suggested Teams:")),
- UI::Align::kLeft);
- teams_box_.add(&teams_list_, UI::Align::kLeft);
+ teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, _("Suggested Teams:")));
+ teams_box_.add(&teams_list_);
// TODO(GunChleoc): We need team images in the listselect here,
// so map editors will be able to delete entries.
// This is waiting for the new RT renderer.
@@ -150,9 +149,9 @@
unsigned int nr_players = static_cast<unsigned int>(eia().egbase().map().get_nrplayers());
std::string players =
(boost::format(ngettext("%u Player", "%u Players", nr_players)) % nr_players).str();
- teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, players), UI::Align::kLeft);
+ teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, players));
- tab_box_.add(&tabs_, UI::Align::kLeft, true);
+ tab_box_.add(&tabs_, UI::Box::Resizing::kFullSize);
tabs_.add("main_map_options", g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),
&main_box_, _("Main Options"));
tabs_.add("map_tags", g_gr->images().get("images/ui_basic/checkbox_checked.png"), &tags_box_,
@@ -236,9 +235,9 @@
std::string displ_name) {
UI::Box* box = new UI::Box(parent, 0, 0, UI::Box::Horizontal, max_w_, checkbox_space_, 0);
UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);
- box->add(cb, UI::Align::kLeft, true);
+ box->add(cb, UI::Box::Resizing::kFullSize);
box->add_space(checkbox_space_);
- parent->add(box, UI::Align::kLeft);
+ parent->add(box);
parent->add_space(padding_);
tags_checkboxes_[tag] = cb;
}
=== modified file 'src/editor/ui_menus/main_menu_new_map.cc'
--- src/editor/ui_menus/main_menu_new_map.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/main_menu_new_map.cc 2017-02-25 18:55:39 +0000
@@ -109,24 +109,24 @@
height_.set_value(height_index);
}
- box_.add(&width_, UI::Align::kLeft);
- box_.add(&height_, UI::Align::kLeft);
+ box_.add(&width_);
+ box_.add(&height_);
box_.add_space(margin_);
UI::Textarea* terrain_label = new UI::Textarea(&box_, _("Terrain:"));
- box_.add(terrain_label, UI::Align::kLeft);
- box_.add(&list_, UI::Align::kLeft);
+ box_.add(terrain_label);
+ box_.add(&list_);
box_.add_space(2 * margin_);
cancel_button_.sigclicked.connect(boost::bind(&MainMenuNewMap::clicked_cancel, this));
ok_button_.sigclicked.connect(boost::bind(&MainMenuNewMap::clicked_create_map, this));
if (UI::g_fh1->fontset()->is_rtl()) {
- button_box_.add(&ok_button_, UI::Align::kLeft);
- button_box_.add(&cancel_button_, UI::Align::kLeft);
+ button_box_.add(&ok_button_);
+ button_box_.add(&cancel_button_);
} else {
- button_box_.add(&cancel_button_, UI::Align::kLeft);
- button_box_.add(&ok_button_, UI::Align::kLeft);
+ button_box_.add(&cancel_button_);
+ button_box_.add(&ok_button_);
}
- box_.add(&button_box_, UI::Align::kLeft);
+ box_.add(&button_box_);
box_.set_size(box_width_, width_.get_h() + height_.get_h() + terrain_label->get_h() +
list_.get_h() + button_box_.get_h() + 9 * margin_);
=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
--- src/editor/ui_menus/main_menu_random_map.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/main_menu_random_map.cc 2017-02-25 18:55:39 +0000
@@ -180,7 +180,7 @@
UI::SpinBox::Type::kSmall,
5),
mountains_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_),
- mountains_label_(&mountains_box_, 0, 0, _("Mountains:")),
+ mountains_label_(&mountains_box_, 0, 0, _("Mountains:")),
mountains_(&mountains_box_,
0,
0,
@@ -248,14 +248,14 @@
height_.get_buttons()[1]->sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kMapSize));
- box_.add(&width_, UI::Align::kLeft);
- box_.add(&height_, UI::Align::kLeft);
+ box_.add(&width_);
+ box_.add(&height_);
box_height += margin_ + width_.get_h();
box_height += margin_ + height_.get_h();
// ---------- Players -----------
- box_.add(&players_, UI::Align::kLeft);
+ box_.add(&players_);
box_height += margin_ + players_.get_h();
box_.add_space(margin_);
@@ -266,30 +266,30 @@
// ---------- Worlds ----------
- world_box_.add(&world_label_, UI::Align::kLeft);
+ world_box_.add(&world_label_);
if (world_label_.get_w() < resources_label_.get_w()) {
world_box_.add_space(resources_label_.get_w() - world_label_.get_w() - margin_);
}
world_.sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kWorld));
- world_box_.add(&world_, UI::Align::kLeft);
- box_.add(&world_box_, UI::Align::kLeft);
+ world_box_.add(&world_);
+ box_.add(&world_box_);
box_height += margin_ + world_box_.get_h();
box_.add_space(margin_);
box_height += margin_;
// ---------- Amount of Resources (Low/Medium/High) ----------
- resources_box_.add(&resources_label_, UI::Align::kLeft);
+ resources_box_.add(&resources_label_);
if (resources_label_.get_w() < world_label_.get_w()) {
resources_box_.add_space(world_label_.get_w() - resources_label_.get_w() - margin_);
}
resources_.sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kResources));
- resources_box_.add(&resources_, UI::Align::kLeft);
- box_.add(&resources_box_, UI::Align::kLeft);
+ resources_box_.add(&resources_);
+ box_.add(&resources_box_);
box_height += margin_ + resources_box_.get_h();
box_.add_space(margin_);
box_height += margin_;
@@ -300,7 +300,7 @@
water_.get_buttons()[1]->sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kWater));
- box_.add(&water_, UI::Align::kLeft);
+ box_.add(&water_);
box_height += margin_ + water_.get_h();
// ---------- Land -----------
@@ -310,7 +310,7 @@
land_.get_buttons()[1]->sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kLand));
- box_.add(&land_, UI::Align::kLeft);
+ box_.add(&land_);
box_height += margin_ + land_.get_h();
// ---------- Wasteland -----------
@@ -320,21 +320,21 @@
wasteland_.get_buttons()[1]->sigclicked.connect(
boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kWasteland));
- box_.add(&wasteland_, UI::Align::kLeft);
+ box_.add(&wasteland_);
box_height += margin_ + wasteland_.get_h();
// ---------- Mountains -----------
- mountains_box_.add(&mountains_label_, UI::Align::kLeft);
+ mountains_box_.add(&mountains_label_);
// Convince the value label to align with the spinbox labels above
mountains_box_.add_space(box_width_ - box_width_ / 6 - mountains_label_.get_w() -
mountains_.get_w() + margin_ + 3);
mountains_.set_fixed_width(box_width_ / 3 - margin_);
- mountains_box_.add(&mountains_, UI::Align::kLeft);
+ mountains_box_.add(&mountains_);
mountains_box_.set_size(box_width_, mountains_label_.get_h());
- box_.add(&mountains_box_, UI::Align::kLeft);
+ box_.add(&mountains_box_);
box_height += margin_ + mountains_box_.get_h();
box_.add_space(margin_);
box_height += margin_;
@@ -342,7 +342,7 @@
// ---------- Island mode ----------
island_mode_.set_state(true);
- box_.add(&island_mode_, UI::Align::kLeft);
+ box_.add(&island_mode_);
box_height += margin_ + island_mode_.get_h();
box_.add_space(margin_);
box_height += margin_;
@@ -352,7 +352,7 @@
// ---------- Random map number edit ----------
- map_number_box_.add(&map_number_label_, UI::Align::kLeft);
+ map_number_box_.add(&map_number_label_);
map_number_edit_.changed.connect(boost::bind(&MainMenuNewRandomMap::nr_edit_box_changed, this));
RNG rng;
@@ -360,8 +360,8 @@
rng.rand();
map_number_ = rng.rand();
map_number_edit_.set_text(std::to_string(static_cast<unsigned int>(map_number_)));
- map_number_box_.add(&map_number_edit_, UI::Align::kLeft);
- box_.add(&map_number_box_, UI::Align::kLeft);
+ map_number_box_.add(&map_number_edit_);
+ box_.add(&map_number_box_);
box_height += margin_ + map_number_box_.get_h();
box_.add_space(margin_);
@@ -369,12 +369,12 @@
// ---------- Map ID String edit ----------
- map_id_box_.add(&map_id_label_, UI::Align::kLeft);
+ map_id_box_.add(&map_id_label_);
map_id_edit_.set_text("abcd-efgh-ijkl-mnop");
map_id_edit_.changed.connect(boost::bind(&MainMenuNewRandomMap::id_edit_box_changed, this));
- map_id_box_.add(&map_id_edit_, UI::Align::kLeft);
- box_.add(&map_id_box_, UI::Align::kLeft);
+ map_id_box_.add(&map_id_edit_);
+ box_.add(&map_id_box_);
box_height += margin_ + map_id_edit_.get_h();
box_.add_space(margin_);
box_height += margin_;
@@ -383,13 +383,13 @@
cancel_button_.sigclicked.connect(boost::bind(&MainMenuNewRandomMap::clicked_cancel, this));
ok_button_.sigclicked.connect(boost::bind(&MainMenuNewRandomMap::clicked_create_map, this));
if (UI::g_fh1->fontset()->is_rtl()) {
- button_box_.add(&ok_button_, UI::Align::kLeft);
- button_box_.add(&cancel_button_, UI::Align::kLeft);
+ button_box_.add(&ok_button_);
+ button_box_.add(&cancel_button_);
} else {
- button_box_.add(&cancel_button_, UI::Align::kLeft);
- button_box_.add(&ok_button_, UI::Align::kLeft);
+ button_box_.add(&cancel_button_);
+ button_box_.add(&ok_button_);
}
- box_.add(&button_box_, UI::Align::kLeft);
+ box_.add(&button_box_);
box_height += margin_ + button_box_.get_h();
box_height += 6 * margin_;
=== modified file 'src/editor/ui_menus/main_menu_save_map_make_directory.cc'
--- src/editor/ui_menus/main_menu_save_map_make_directory.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/main_menu_save_map_make_directory.cc 2017-02-25 18:55:39 +0000
@@ -69,9 +69,9 @@
g_gr->images().get("images/ui_basic/but1.png"),
_("Cancel")) {
- vbox_.add(&label_, UI::Align::kLeft);
+ vbox_.add(&label_);
vbox_.add_space(padding_);
- vbox_.add(&edit_, UI::Align::kLeft);
+ vbox_.add(&edit_);
vbox_.set_size(get_inner_w() - 2 * padding_, get_inner_h() - 3 * padding_ - buth_);
edit_.set_text(dirname_);
=== modified file 'src/editor/ui_menus/tool_change_height_options_menu.cc'
--- src/editor/ui_menus/tool_change_height_options_menu.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/tool_change_height_options_menu.cc 2017-02-25 18:55:39 +0000
@@ -72,8 +72,8 @@
set_to_.changed.connect(
boost::bind(&EditorToolChangeHeightOptionsMenu::update_set_to, boost::ref(*this)));
- box_.add(&change_by_, UI::Align::kLeft);
- box_.add(&set_to_, UI::Align::kLeft);
+ box_.add(&change_by_);
+ box_.add(&set_to_);
box_.set_size(get_inner_w() - 2 * hmargin(), change_by_.get_h() + set_to_.get_h() + vspacing());
set_inner_size(box_.get_w() + 2 * hmargin(), box_.get_h() + 2 * vspacing());
}
=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-02-25 18:55:39 +0000
@@ -90,8 +90,8 @@
set_to_.changed.connect(
boost::bind(&EditorToolChangeResourcesOptionsMenu::update_set_to, boost::ref(*this)));
- box_.add(&change_by_, UI::Align::kLeft);
- box_.add(&set_to_, UI::Align::kLeft);
+ box_.add(&change_by_);
+ box_.add(&set_to_);
box_.set_size(get_inner_w() - 2 * hmargin(), change_by_.get_h() + set_to_.get_h() + vspacing());
// Add resource buttons
@@ -103,11 +103,11 @@
radiogroup_.add_button(&resources_box_, Vector2i(0, 0),
g_gr->images().get(resource.representative_image()),
resource.descname());
- resources_box_.add(radiogroup_.get_first_button(), UI::Align::kLeft, false, true);
+ resources_box_.add(radiogroup_.get_first_button(), UI::Box::Resizing::kFillSpace);
}
box_.add_space(vspacing());
- box_.add(&resources_box_, UI::Align::kLeft, true);
+ box_.add(&resources_box_, UI::Box::Resizing::kFullSize);
box_.set_size(box_.get_w(), box_.get_h() + 4 * vspacing() + resources_box_.get_h());
radiogroup_.set_state(increase_tool_.get_cur_res());
@@ -119,7 +119,7 @@
// Add label
cur_selection_.set_fixed_width(box_.get_inner_w());
- box_.add(&cur_selection_, UI::Align::kLeft);
+ box_.add(&cur_selection_);
box_.set_size(box_.get_w(), box_.get_h() + vspacing() + cur_selection_.get_h());
set_inner_size(get_inner_w(), box_.get_h() + 1 * vmargin());
=== modified file 'src/editor/ui_menus/tool_noise_height_options_menu.cc'
--- src/editor/ui_menus/tool_noise_height_options_menu.cc 2017-02-23 19:38:51 +0000
+++ src/editor/ui_menus/tool_noise_height_options_menu.cc 2017-02-25 18:55:39 +0000
@@ -95,15 +95,15 @@
UI::Textarea* label =
new UI::Textarea(&box_, 0, 0, 0, 0, _("Random Height"), UI::Align::kCenter);
label->set_fixed_width(get_inner_w() - 2 * hmargin());
- box_.add(label, UI::Align::kCenter);
- box_.add(&upper_, UI::Align::kCenter);
- box_.add(&lower_, UI::Align::kCenter);
+ box_.add(label);
+ box_.add(&upper_);
+ box_.add(&lower_);
box_.add_space(2 * vspacing());
label = new UI::Textarea(&box_, 0, 0, 0, 0, _("Fixed Height"), UI::Align::kCenter);
label->set_fixed_width(get_inner_w() - 2 * hmargin());
- box_.add(label, UI::Align::kLeft);
- box_.add(&set_to_, UI::Align::kLeft);
+ box_.add(label);
+ box_.add(&set_to_);
box_.set_size(get_inner_w() - 2 * hmargin(), upper_.get_h() + lower_.get_h() + set_to_.get_h() +
2 * label->get_h() + 7 * vspacing());
=== modified file 'src/ui_basic/box.cc'
--- src/ui_basic/box.cc 2017-02-23 19:38:51 +0000
+++ src/ui_basic/box.cc 2017-02-25 18:55:39 +0000
@@ -244,22 +244,27 @@
/**
* Add a new panel to be controlled by this box
*
- * @param fullsize when true, @p panel will be extended to cover the entire width (or height)
- * of the box for horizontal (vertical) panels. If false, then @p panel may end up smaller;
- * in that case, it will be aligned according to @p align
- *
- * @param fillspace when true, @p panel will be expanded as an infinite space would be.
+ * @param resizing:
+ *
+ * When Resizing::kAlign, then @p panel will be aligned according to @p align
+ *
+ * When Resizing::kFullSize, @p panel will be extended to cover the entire width (or height)
+ * of the box for horizontal (vertical) panels.
+ *
+ * When Resizing::kFillSpace, @p panel will be expanded as an infinite space would be.
* This can be used to make buttons fill a box completely.
*
+ * When Resizing::kExpandBoth, both width and height of @p panel will be expanded.
+ *
*/
-void Box::add(Panel* const panel, UI::Align const align, bool fullsize, bool fillspace) {
+void Box::add(Panel* const panel, Resizing resizing, UI::Align const align) {
Item it;
it.type = Item::ItemPanel;
it.u.panel.panel = panel;
it.u.panel.align = align;
- it.u.panel.fullsize = fullsize;
- it.fillspace = fillspace;
+ it.u.panel.fullsize = resizing == Resizing::kFullSize || resizing == Resizing::kExpandBoth;
+ it.fillspace = resizing == Resizing::kFillSpace || resizing == Resizing::kExpandBoth;
it.assigned_var_depth = 0;
items_.push_back(it);
=== modified file 'src/ui_basic/box.h'
--- src/ui_basic/box.h 2017-02-23 19:38:51 +0000
+++ src/ui_basic/box.h 2017-02-25 18:55:39 +0000
@@ -56,10 +56,8 @@
return items_.size();
}
- void add(Panel* panel,
- UI::Align align = UI::Align::kLeft,
- bool fullsize = false,
- bool fillspace = false);
+ enum class Resizing { kAlign, kFullSize, kFillSpace, kExpandBoth };
+ void add(Panel* panel, Resizing resizing = Resizing::kAlign, UI::Align align = UI::Align::kLeft);
void add_space(uint32_t space);
void add_inf_space();
bool is_snap_target() const override {
=== modified file 'src/ui_basic/dropdown.cc'
--- src/ui_basic/dropdown.cc 2017-02-23 17:58:25 +0000
+++ src/ui_basic/dropdown.cc 2017-02-25 18:55:39 +0000
@@ -73,8 +73,8 @@
list_.set_visible(false);
list_.set_background(background);
display_button_.set_perm_pressed(true);
- button_box_.add(&display_button_, UI::Align::kLeft);
- button_box_.add(&push_button_, UI::Align::kLeft);
+ button_box_.add(&display_button_);
+ button_box_.add(&push_button_);
button_box_.set_size(w, get_h());
display_button_.sigclicked.connect(boost::bind(&BaseDropdown::toggle_list, this));
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2017-02-24 19:22:36 +0000
+++ src/ui_basic/progressbar.cc 2017-02-25 18:55:39 +0000
@@ -86,7 +86,7 @@
// Print the state in percent without decimal points.
const std::string progress_text = (boost::format("<font color=%s>%u%%</font>") %
- UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100))
+ UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100.f))
.str();
const Image* rendered_text = UI::g_fh1->render(as_uifont(progress_text));
Vector2f pos(get_w() / 2, get_h() / 2);
=== modified file 'src/ui_basic/spinbox.cc'
--- src/ui_basic/spinbox.cc 2017-02-23 19:38:51 +0000
+++ src/ui_basic/spinbox.cc 2017-02-25 18:55:39 +0000
@@ -112,7 +112,7 @@
sbi_->label =
new UI::MultilineTextarea(box_, 0, 0, 0, 0, label_text, UI::Align::kLeft, button_background,
UI::MultilineTextarea::ScrollMode::kNoScrolling);
- box_->add(sbi_->label, UI::Align::kCenter);
+ box_->add(sbi_->label);
sbi_->text = new UI::Textarea(box_, "", UI::Align::kCenter);
@@ -148,15 +148,15 @@
buttons_.push_back(sbi_->button_ten_minus);
buttons_.push_back(sbi_->button_ten_plus);
- box_->add(sbi_->button_ten_minus, UI::Align::kLeft);
- box_->add(sbi_->button_minus, UI::Align::kLeft);
- box_->add(sbi_->text, UI::Align::kLeft);
- box_->add(sbi_->button_plus, UI::Align::kLeft);
- box_->add(sbi_->button_ten_plus, UI::Align::kLeft);
+ box_->add(sbi_->button_ten_minus);
+ box_->add(sbi_->button_minus);
+ box_->add(sbi_->text);
+ box_->add(sbi_->button_plus);
+ box_->add(sbi_->button_ten_plus);
} else {
- box_->add(sbi_->button_minus, UI::Align::kCenter);
- box_->add(sbi_->text, UI::Align::kCenter);
- box_->add(sbi_->button_plus, UI::Align::kCenter);
+ box_->add(sbi_->button_minus);
+ box_->add(sbi_->text);
+ box_->add(sbi_->button_plus);
}
sbi_->button_plus->sigclicked.connect(
=== modified file 'src/ui_fsmenu/main.cc'
--- src/ui_fsmenu/main.cc 2017-02-23 19:38:51 +0000
+++ src/ui_fsmenu/main.cc 2017-02-25 18:55:39 +0000
@@ -130,19 +130,19 @@
boost::bind(&FullscreenMenuMain::end_modal<FullscreenMenuBase::MenuTarget>, boost::ref(*this),
FullscreenMenuBase::MenuTarget::kExit));
- vbox_.add(&playtutorial, UI::Align::kCenter, true);
- vbox_.add(&singleplayer, UI::Align::kCenter, true);
- vbox_.add(&multiplayer, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&replay, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&editor, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&options, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&about, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&exit, UI::Align::kCenter, true);
+ vbox_.add(&playtutorial, UI::Box::Resizing::kFullSize);
+ vbox_.add(&singleplayer, UI::Box::Resizing::kFullSize);
+ vbox_.add(&multiplayer, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&replay, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&editor, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&options, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&about, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&exit, UI::Box::Resizing::kFullSize);
add_overlay_image("images/ui_fsmenu/main_title.png",
FullscreenWindow::Alignment(UI::Align::kCenter, UI::Align::kTop));
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2017-02-23 19:38:51 +0000
+++ src/ui_fsmenu/mapselect.cc 2017-02-25 18:55:39 +0000
@@ -92,8 +92,8 @@
tags_checkboxes_.clear(); // Remove this again, it is a special tag checkbox
cb_show_all_maps_->set_state(true);
- hbox->add(cb_dont_localize_mapnames_, UI::Align::kLeft, true);
- checkboxes_.add(hbox, UI::Align::kLeft, true);
+ hbox->add(cb_dont_localize_mapnames_, UI::Box::Resizing::kFullSize);
+ checkboxes_.add(hbox, UI::Box::Resizing::kFullSize);
hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
add_tag_checkbox(hbox, "official", localize_tag("official"));
@@ -101,18 +101,18 @@
add_tag_checkbox(hbox, "seafaring", localize_tag("seafaring"));
add_tag_checkbox(hbox, "artifacts", localize_tag("artifacts"));
add_tag_checkbox(hbox, "scenario", localize_tag("scenario"));
- checkboxes_.add(hbox, UI::Align::kLeft, true);
+ checkboxes_.add(hbox, UI::Box::Resizing::kFullSize);
hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
add_tag_checkbox(hbox, "ffa", localize_tag("ffa"));
add_tag_checkbox(hbox, "1v1", localize_tag("1v1"));
- checkboxes_.add(hbox, UI::Align::kLeft, true);
+ checkboxes_.add(hbox, UI::Box::Resizing::kFullSize);
hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
add_tag_checkbox(hbox, "2teams", localize_tag("2teams"));
add_tag_checkbox(hbox, "3teams", localize_tag("3teams"));
add_tag_checkbox(hbox, "4teams", localize_tag("4teams"));
- checkboxes_.add(hbox, UI::Align::kLeft, true);
+ checkboxes_.add(hbox, UI::Box::Resizing::kFullSize);
scenario_types_ = settings_->settings().multiplayer ? Map::MP_SCENARIO : Map::SP_SCENARIO;
@@ -305,7 +305,7 @@
UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);
cb->changedto.connect(boost::bind(&FullscreenMenuMapSelect::tagbox_changed, this, id, _1));
- box->add(cb, UI::Align::kLeft, true);
+ box->add(cb, UI::Box::Resizing::kFullSize);
box->add_space(checkbox_space_);
tags_checkboxes_.push_back(cb);
=== modified file 'src/ui_fsmenu/multiplayer.cc'
--- src/ui_fsmenu/multiplayer.cc 2017-02-23 19:38:51 +0000
+++ src/ui_fsmenu/multiplayer.cc 2017-02-25 18:55:39 +0000
@@ -64,10 +64,10 @@
title.set_fontsize(fs_big());
- vbox_.add(&metaserver, UI::Align::kCenter, true);
- vbox_.add(&lan, UI::Align::kCenter, true);
+ vbox_.add(&metaserver, UI::Box::Resizing::kFullSize);
+ vbox_.add(&lan, UI::Box::Resizing::kFullSize);
vbox_.add_inf_space();
- vbox_.add(&back, UI::Align::kCenter, true);
+ vbox_.add(&back, UI::Box::Resizing::kFullSize);
Section& s = g_options.pull_section("global");
auto_log_ = s.get_bool("auto_log", false);
=== modified file 'src/ui_fsmenu/singleplayer.cc'
--- src/ui_fsmenu/singleplayer.cc 2017-02-23 19:38:51 +0000
+++ src/ui_fsmenu/singleplayer.cc 2017-02-25 18:55:39 +0000
@@ -70,14 +70,14 @@
title.set_fontsize(fs_big());
- vbox_.add(&new_game, UI::Align::kCenter, true);
- vbox_.add(&campaign, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add(&load_game, UI::Align::kCenter, true);
- vbox_.add_inf_space();
- vbox_.add_inf_space();
- vbox_.add_inf_space();
- vbox_.add(&back, UI::Align::kCenter, true);
+ vbox_.add(&new_game, UI::Box::Resizing::kFullSize);
+ vbox_.add(&campaign, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add(&load_game, UI::Box::Resizing::kFullSize);
+ vbox_.add_inf_space();
+ vbox_.add_inf_space();
+ vbox_.add_inf_space();
+ vbox_.add(&back, UI::Box::Resizing::kFullSize);
layout();
}
=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc 2017-02-23 17:58:25 +0000
+++ src/wui/actionconfirm.cc 2017-02-25 18:55:39 +0000
@@ -149,13 +149,13 @@
cancelbtn->sigclicked.connect(boost::bind(&ActionConfirm::die, this));
button_box->add(
- UI::g_fh1->fontset()->is_rtl() ? okbtn : cancelbtn, UI::Align::kLeft, false, true);
+ UI::g_fh1->fontset()->is_rtl() ? okbtn : cancelbtn, UI::Box::Resizing::kFillSpace);
button_box->add_space(2 * padding);
button_box->add(
- UI::g_fh1->fontset()->is_rtl() ? cancelbtn : okbtn, UI::Align::kLeft, false, true);
+ UI::g_fh1->fontset()->is_rtl() ? cancelbtn : okbtn, UI::Box::Resizing::kFillSpace);
main_box->add(textarea);
main_box->add_space(1.5 * padding);
- main_box->add(button_box, UI::Align::kLeft, true);
+ main_box->add(button_box, UI::Box::Resizing::kFullSize);
button_box->set_size(textarea->get_w(), okbtn->get_h());
main_box->set_size(textarea->get_w(), textarea->get_h() + button_box->get_h() + 1.5 * padding);
set_inner_size(main_box->get_w() + 2 * padding, main_box->get_h() + 2 * padding);
=== modified file 'src/wui/attack_box.cc'
--- src/wui/attack_box.cc 2017-02-23 19:38:51 +0000
+++ src/wui/attack_box.cc 2017-02-25 18:55:39 +0000
@@ -73,7 +73,7 @@
AttackBox::add_text(UI::Box& parent, std::string str, UI::Align alignment, int fontsize) {
UI::Textarea& result = *new UI::Textarea(&parent, str.c_str());
result.set_fontsize(fontsize);
- parent.add(&result, alignment);
+ parent.add(&result, UI::Box::Resizing::kAlign, alignment);
return result;
}
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2017-02-23 17:58:25 +0000
+++ src/wui/buildingwindow.cc 2017-02-25 18:55:39 +0000
@@ -66,10 +66,10 @@
UI::Box* vbox = new UI::Box(this, 0, 0, UI::Box::Vertical);
tabs_ = new UI::TabPanel(vbox, 0, 0, nullptr);
- vbox->add(tabs_, UI::Align::kLeft, true);
+ vbox->add(tabs_, UI::Box::Resizing::kFullSize);
capsbuttons_ = new UI::Box(vbox, 0, 0, UI::Box::Horizontal);
- vbox->add(capsbuttons_, UI::Align::kLeft, true);
+ vbox->add(capsbuttons_, UI::Box::Resizing::kFullSize);
// actually create buttons on the first call to think(),
// so that overriding create_capsbuttons() works
@@ -247,7 +247,7 @@
waremap_to_richtext(owner.tribe(), wares));
dismantlebtn->sigclicked.connect(
boost::bind(&BuildingWindow::act_dismantle, boost::ref(*this)));
- capsbuttons->add(dismantlebtn, UI::Align::kCenter);
+ capsbuttons->add(dismantlebtn);
requires_destruction_separator = true;
}
}
=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc 2017-02-23 17:58:25 +0000
+++ src/wui/constructionsitewindow.cc 2017-02-25 18:55:39 +0000
@@ -52,14 +52,14 @@
progress_ = new UI::ProgressBar(&box, 0, 0, UI::ProgressBar::DefaultWidth,
UI::ProgressBar::DefaultHeight, UI::ProgressBar::Horizontal);
progress_->set_total(1 << 16);
- box.add(progress_, UI::Align::kCenter);
+ box.add(progress_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
box.add_space(8);
// Add the wares queue
for (uint32_t i = 0; i < cs.get_nrwaresqueues(); ++i)
box.add(
- new InputQueueDisplay(&box, 0, 0, igbase(), cs, cs.get_waresqueue(i)), UI::Align::kLeft);
+ new InputQueueDisplay(&box, 0, 0, igbase(), cs, cs.get_waresqueue(i)));
get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), &box, _("Building materials"));
}
=== modified file 'src/wui/dismantlesitewindow.cc'
--- src/wui/dismantlesitewindow.cc 2017-02-23 17:58:25 +0000
+++ src/wui/dismantlesitewindow.cc 2017-02-25 18:55:39 +0000
@@ -50,7 +50,7 @@
progress_ = new UI::ProgressBar(&box, 0, 0, UI::ProgressBar::DefaultWidth,
UI::ProgressBar::DefaultHeight, UI::ProgressBar::Horizontal);
progress_->set_total(1 << 16);
- box.add(progress_, UI::Align::kCenter);
+ box.add(progress_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
box.add_space(8);
=== modified file 'src/wui/economy_options_window.cc'
--- src/wui/economy_options_window.cc 2017-02-23 17:58:25 +0000
+++ src/wui/economy_options_window.cc 2017-02-25 18:55:39 +0000
@@ -132,7 +132,7 @@
owner_(owner),
can_act_(can_act),
display_(this, 0, 0, owner.tribe(), type_, can_act_, economy_number, owner) {
- add(&display_, UI::Align::kLeft, true);
+ add(&display_, UI::Box::Resizing::kFullSize);
UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
add(buttons);
@@ -142,7 +142,7 @@
g_gr->images().get("images/ui_basic/but4.png"), "-", _("Decrease target"));
b->set_enabled(can_act_);
b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, -1));
- buttons->add(b, UI::Align::kCenter);
+ buttons->add(b);
b->set_repeating(true);
buttons->add_space(8);
@@ -150,7 +150,7 @@
g_gr->images().get("images/ui_basic/but4.png"), "+", _("Increase target"));
b->set_enabled(can_act_);
b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, 1));
- buttons->add(b, UI::Align::kCenter);
+ buttons->add(b);
b->set_repeating(true);
buttons->add_space(8);
@@ -158,7 +158,7 @@
g_gr->images().get("images/ui_basic/but4.png"), "R", _("Reset to default"));
b->set_enabled(can_act_);
b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::reset_target, this));
- buttons->add(b, UI::Align::kCenter);
+ buttons->add(b);
}
void EconomyOptionsWindow::EconomyOptionsPanel::set_economy_number(size_t economy_number) {
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc 2017-02-23 19:38:51 +0000
+++ src/wui/game_summary.cc 2017-02-25 18:55:39 +0000
@@ -48,7 +48,7 @@
// Init boxes
UI::Box* vbox = new UI::Box(this, 0, 0, UI::Box::Vertical, 0, 0, PADDING);
title_area_ = new UI::Textarea(vbox, "", UI::Align::kCenter);
- vbox->add(title_area_);
+ vbox->add(title_area_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
vbox->add_space(PADDING);
UI::Box* hbox1 = new UI::Box(this, 0, 0, UI::Box::Horizontal);
@@ -64,7 +64,7 @@
info_area_ = new UI::MultilineTextarea(
info_box, 0, 0, 130,
std::max(130, players_table_->get_h() - info_area_label_->get_h() - PADDING), "");
- info_box->add(info_area_, UI::Align::kLeft, true);
+ info_box->add(info_area_, UI::Box::Resizing::kFullSize);
info_box->add_space(PADDING);
hbox1->add(info_box);
hbox1->add_space(PADDING);
@@ -75,10 +75,10 @@
bottom_box->add_space(PADDING);
gametime_label_ = new UI::Textarea(bottom_box, _("Elapsed time:"));
- bottom_box->add(gametime_label_);
+ bottom_box->add(gametime_label_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
bottom_box->add_space(PADDING);
gametime_value_ = new UI::Textarea(bottom_box, gametimestring(game_.get_gametime()));
- bottom_box->add(gametime_value_);
+ bottom_box->add(gametime_value_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
bottom_box->add_inf_space();
@@ -93,7 +93,7 @@
bottom_box->add(stop_button_);
bottom_box->add_space(PADDING);
- vbox->add(bottom_box, UI::Align::kLeft, true);
+ vbox->add(bottom_box, UI::Box::Resizing::kFullSize);
vbox->add_space(PADDING);
set_center_panel(vbox);
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2017-02-23 17:58:25 +0000
+++ src/wui/general_statistics_menu.cc 2017-02-25 18:55:39 +0000
@@ -120,12 +120,12 @@
cbs_[p - 1] = &cb;
- hbox1->add(&cb, UI::Align::kLeft, false, true);
+ hbox1->add(&cb, UI::Box::Resizing::kFillSpace);
}
else // player nr p does not exist
cbs_[p - 1] = nullptr;
- box_.add(hbox1, UI::Align::kLeft, true);
+ box_.add(hbox1, UI::Box::Resizing::kFullSize);
UI::Box* hbox2 = new UI::Box(&box_, 0, 0, UI::Box::Horizontal, 0, 0, 1);
@@ -134,72 +134,72 @@
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_landsize.png"), _("Land"),
&btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_nrworkers.png"),
_("Workers"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_nrbuildings.png"),
_("Buildings"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_nrwares.png"), _("Wares"),
&btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_productivity.png"),
_("Productivity"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_casualties.png"),
_("Casualties"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_kills.png"), _("Kills"),
&btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_msites_lost.png"),
_("Military buildings lost"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_msites_defeated.png"),
_("Military buildings defeated"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_civil_blds_lost.png"),
_("Civilian buildings lost"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
radiogroup_.add_button(hbox2, Vector2i(0, 0),
g_gr->images().get("images/wui/stats/genstats_militarystrength.png"),
_("Military"), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
if (hook) {
radiogroup_.add_button(
hbox2, Vector2i(0, 0), g_gr->images().get(cs_pic), cs_name.c_str(), &btn);
- hbox2->add(btn, UI::Align::kLeft, false, true);
+ hbox2->add(btn, UI::Box::Resizing::kFillSpace);
}
radiogroup_.set_state(selected_information_);
radiogroup_.changedto.connect(boost::bind(&GeneralStatisticsMenu::radiogroup_changed, this, _1));
- box_.add(hbox2, UI::Align::kLeft, true);
+ box_.add(hbox2, UI::Box::Resizing::kFullSize);
box_.add(new WuiPlotAreaSlider(
&box_, plot_, 0, 0, 100, 45, g_gr->images().get("images/ui_basic/but1.png")),
- UI::Align::kLeft, true);
+ UI::Box::Resizing::kFullSize);
}
GeneralStatisticsMenu::~GeneralStatisticsMenu() {
=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc 2017-02-23 19:38:51 +0000
+++ src/wui/multiplayersetupgroup.cc 2017-02-25 18:55:39 +0000
@@ -56,7 +56,7 @@
save_(-2) {
set_size(w, h);
name = new UI::Textarea(this, 0, 0, w - h - UI::Scrollbar::kSize * 11 / 5, h);
- add(name, UI::Align::kCenter);
+ add(name);
// Either Button if changeable OR text if not
if (id == settings->settings().usernum) { // Our Client
type = new UI::Button(
@@ -67,7 +67,7 @@
} else { // just a shown client
type_icon = new UI::Icon(
this, 0, 0, h, h, g_gr->images().get("images/wui/fieldaction/menu_tab_watch.png"));
- add(type_icon, UI::Align::kCenter);
+ add(type_icon);
}
}
@@ -164,27 +164,27 @@
g_gr->images().get("images/players/player_position_menu_pc.png"));
assert(player_image);
player = new UI::Icon(this, 0, 0, h, h, player_image);
- add(player, UI::Align::kCenter);
+ add(player);
type = new UI::Button(
this, "player_type", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
type->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_type, boost::ref(*this)));
- add(type, UI::Align::kCenter);
+ add(type);
tribe = new UI::Button(
this, "player_tribe", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
tribe->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_tribe, boost::ref(*this)));
- add(tribe, UI::Align::kCenter);
+ add(tribe);
init = new UI::Button(this, "player_init", 0, 0, w - 4 * h, h,
g_gr->images().get("images/ui_basic/but1.png"), "");
init->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_init, boost::ref(*this)));
- add(init, UI::Align::kCenter);
+ add(init);
team = new UI::Button(
this, "player_team", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
team->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_team, boost::ref(*this)));
- add(team, UI::Align::kCenter);
+ add(team);
}
/// Toggle through the types
@@ -413,7 +413,7 @@
for (uint8_t i = 0; i < multi_player_player_groups.size(); ++i) {
multi_player_player_groups.at(i) = new MultiPlayerPlayerGroup(
&playerbox, i, 0, 0, playerbox.get_w(), buth, s, npsb.get(), tribepics_, tribenames_);
- playerbox.add(multi_player_player_groups.at(i), UI::Align::kCenter);
+ playerbox.add(multi_player_player_groups.at(i), UI::Box::Resizing::kAlign, UI::Align::kCenter);
}
refresh();
}
@@ -435,7 +435,7 @@
if (!multi_player_client_groups.at(i)) {
multi_player_client_groups.at(i) =
new MultiPlayerClientGroup(&clientbox, i, 0, 0, clientbox.get_w(), buth_, s);
- clientbox.add(&*multi_player_client_groups.at(i), UI::Align::kCenter);
+ clientbox.add(&*multi_player_client_groups.at(i), UI::Box::Resizing::kAlign, UI::Align::kCenter);
}
multi_player_client_groups.at(i)->refresh();
}
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2017-02-23 19:38:51 +0000
+++ src/wui/productionsitewindow.cc 2017-02-25 18:55:39 +0000
@@ -87,12 +87,12 @@
_("Terminate the employment of the selected worker"));
evict_button->sigclicked.connect(
boost::bind(&ProductionSiteWindow::evict_worker, boost::ref(*this)));
- worker_caps_->add(evict_button, UI::Align::kCenter);
+ worker_caps_->add(evict_button);
}
- worker_box->add(worker_table_, UI::Align::kLeft, true);
+ worker_box->add(worker_table_, UI::Box::Resizing::kFullSize);
worker_box->add_space(4);
- worker_box->add(worker_caps_, UI::Align::kLeft, true);
+ worker_box->add(worker_caps_, UI::Box::Resizing::kFullSize);
get_tabs()->add(
"workers", g_gr->images().get(pic_tab_workers), worker_box,
(ngettext("Worker", "Workers", productionsite().descr().nr_working_positions())));
=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc 2017-02-24 08:07:50 +0000
+++ src/wui/shipwindow.cc 2017-02-25 18:55:39 +0000
@@ -81,92 +81,92 @@
display_ = new ItemWaresDisplay(vbox_.get(), *ship_.get_owner());
display_->set_capacity(ship_.descr().get_capacity());
- vbox_->add(display_, UI::Align::kCenter, false);
+ vbox_->add(display_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
// Expedition buttons
if (ship_.state_is_expedition()) {
UI::Box* exp_top = new UI::Box(vbox_.get(), 0, 0, UI::Box::Horizontal);
- vbox_->add(exp_top, UI::Align::kCenter, false);
+ vbox_->add(exp_top, UI::Box::Resizing::kAlign, UI::Align::kCenter);
UI::Box* exp_mid = new UI::Box(vbox_.get(), 0, 0, UI::Box::Horizontal);
- vbox_->add(exp_mid, UI::Align::kCenter, false);
+ vbox_->add(exp_mid, UI::Box::Resizing::kAlign, UI::Align::kCenter);
UI::Box* exp_bot = new UI::Box(vbox_.get(), 0, 0, UI::Box::Horizontal);
- vbox_->add(exp_bot, UI::Align::kCenter, false);
+ vbox_->add(exp_bot, UI::Box::Resizing::kAlign, UI::Align::kCenter);
btn_scout_[WALK_NW - 1] =
make_button(exp_top, "scnw", _("Scout towards the north west"), pic_scout_nw,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_NW));
- exp_top->add(btn_scout_[WALK_NW - 1], UI::Align::kLeft, false);
+ exp_top->add(btn_scout_[WALK_NW - 1]);
btn_explore_island_cw_ = make_button(
exp_top, "expcw", _("Explore the island’s coast clockwise"), pic_explore_cw,
boost::bind(&ShipWindow::act_explore_island, this, IslandExploreDirection::kClockwise));
- exp_top->add(btn_explore_island_cw_, UI::Align::kLeft, false);
+ exp_top->add(btn_explore_island_cw_);
btn_scout_[WALK_NE - 1] =
make_button(exp_top, "scne", _("Scout towards the north east"), pic_scout_ne,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_NE));
- exp_top->add(btn_scout_[WALK_NE - 1], UI::Align::kLeft, false);
+ exp_top->add(btn_scout_[WALK_NE - 1]);
btn_scout_[WALK_W - 1] =
make_button(exp_mid, "scw", _("Scout towards the west"), pic_scout_w,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_W));
- exp_mid->add(btn_scout_[WALK_W - 1], UI::Align::kLeft, false);
+ exp_mid->add(btn_scout_[WALK_W - 1]);
btn_construct_port_ =
make_button(exp_mid, "buildport", _("Construct a port at the current location"),
pic_construct_port, boost::bind(&ShipWindow::act_construct_port, this));
- exp_mid->add(btn_construct_port_, UI::Align::kLeft, false);
+ exp_mid->add(btn_construct_port_);
btn_scout_[WALK_E - 1] =
make_button(exp_mid, "sce", _("Scout towards the east"), pic_scout_e,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_E));
- exp_mid->add(btn_scout_[WALK_E - 1], UI::Align::kLeft, false);
+ exp_mid->add(btn_scout_[WALK_E - 1]);
btn_scout_[WALK_SW - 1] =
make_button(exp_bot, "scsw", _("Scout towards the south west"), pic_scout_sw,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_SW));
- exp_bot->add(btn_scout_[WALK_SW - 1], UI::Align::kLeft, false);
+ exp_bot->add(btn_scout_[WALK_SW - 1]);
btn_explore_island_ccw_ =
make_button(exp_bot, "expccw", _("Explore the island’s coast counter clockwise"),
pic_explore_ccw, boost::bind(&ShipWindow::act_explore_island, this,
IslandExploreDirection::kCounterClockwise));
- exp_bot->add(btn_explore_island_ccw_, UI::Align::kLeft, false);
+ exp_bot->add(btn_explore_island_ccw_);
btn_scout_[WALK_SE - 1] =
make_button(exp_bot, "scse", _("Scout towards the south east"), pic_scout_se,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_SE));
- exp_bot->add(btn_scout_[WALK_SE - 1], UI::Align::kLeft, false);
+ exp_bot->add(btn_scout_[WALK_SE - 1]);
}
// Bottom buttons
UI::Box* buttons = new UI::Box(vbox_.get(), 0, 0, UI::Box::Horizontal);
- vbox_->add(buttons, UI::Align::kLeft, false);
+ vbox_->add(buttons);
btn_goto_ = make_button(
buttons, "goto", _("Go to ship"), pic_goto, boost::bind(&ShipWindow::act_goto, this));
- buttons->add(btn_goto_, UI::Align::kLeft, false);
+ buttons->add(btn_goto_);
btn_destination_ = make_button(buttons, "destination", _("Go to destination"), pic_destination,
boost::bind(&ShipWindow::act_destination, this));
btn_destination_->set_enabled(false);
- buttons->add(btn_destination_, UI::Align::kLeft, false);
+ buttons->add(btn_destination_);
btn_sink_ = make_button(
buttons, "sink", _("Sink the ship"), pic_sink, boost::bind(&ShipWindow::act_sink, this));
- buttons->add(btn_sink_, UI::Align::kLeft, false);
+ buttons->add(btn_sink_);
if (ship_.state_is_expedition()) {
btn_cancel_expedition_ =
make_button(buttons, "cancel_expedition", _("Cancel the Expedition"),
pic_cancel_expedition, boost::bind(&ShipWindow::act_cancel_expedition, this));
- buttons->add(btn_cancel_expedition_, UI::Align::kLeft, false);
+ buttons->add(btn_cancel_expedition_);
}
if (igbase_.get_display_flag(InteractiveBase::dfDebug)) {
btn_debug_ = make_button(buttons, "debug", _("Show Debug Window"), pic_debug,
boost::bind(&ShipWindow::act_debug, this));
btn_debug_->set_enabled(true);
- buttons->add(btn_debug_, UI::Align::kLeft, false);
+ buttons->add(btn_debug_);
}
set_center_panel(vbox_.get());
set_thinks(true);
=== modified file 'src/wui/soldiercapacitycontrol.cc'
--- src/wui/soldiercapacitycontrol.cc 2017-02-23 19:38:51 +0000
+++ src/wui/soldiercapacitycontrol.cc 2017-02-25 18:55:39 +0000
@@ -85,10 +85,10 @@
increase_.sigclicked.connect(
boost::bind(&SoldierCapacityControl::click_increase, boost::ref(*this)));
- add(new UI::Textarea(this, _("Capacity")), UI::Align::kCenter);
- add(&decrease_, UI::Align::kCenter);
- add(&value_, UI::Align::kCenter);
- add(&increase_, UI::Align::kCenter);
+ add(new UI::Textarea(this, _("Capacity")), UI::Box::Resizing::kAlign, UI::Align::kCenter);
+ add(&decrease_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
+ add(&value_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
+ add(&increase_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
decrease_.set_repeating(true);
increase_.set_repeating(true);
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2017-02-23 19:38:51 +0000
+++ src/wui/soldierlist.cc 2017-02-25 18:55:39 +0000
@@ -371,11 +371,11 @@
building_(building),
soldierpanel_(*this, igb.egbase(), building),
infotext_(this, _("Click soldier to send away")) {
- add(&soldierpanel_, UI::Align::kCenter);
+ add(&soldierpanel_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
add_space(2);
- add(&infotext_, UI::Align::kCenter);
+ add(&infotext_, UI::Box::Resizing::kAlign, UI::Align::kCenter);
soldierpanel_.set_mouseover(boost::bind(&SoldierList::mouseover, this, _1));
soldierpanel_.set_click(boost::bind(&SoldierList::eject, this, _1));
@@ -422,9 +422,8 @@
}
}
buttons->add_inf_space();
- buttons->add(create_soldier_capacity_control(*buttons, igb, building), UI::Align::kRight);
-
- add(buttons, UI::Align::kCenter, true);
+ buttons->add(create_soldier_capacity_control(*buttons, igb, building));
+ add(buttons, UI::Box::Resizing::kFullSize);
}
SoldierControl& SoldierList::soldiers() const {
=== modified file 'src/wui/ware_statistics_menu.cc'
--- src/wui/ware_statistics_menu.cc 2017-02-23 19:38:51 +0000
+++ src/wui/ware_statistics_menu.cc 2017-02-25 18:55:39 +0000
@@ -150,7 +150,7 @@
tabs->activate(0);
// Add tabbed environment to box
- box->add(tabs, UI::Align::kLeft, true);
+ box->add(tabs, UI::Box::Resizing::kFullSize);
// Register statistics data
for (Widelands::DescriptionIndex cur_ware = 0; cur_ware < nr_wares; ++cur_ware) {
@@ -182,10 +182,10 @@
new StatisticWaresDisplay(
box, 0, 0, parent.get_player()->tribe(),
boost::bind(&WareStatisticsMenu::cb_changed_to, boost::ref(*this), _1, _2), color_map_),
- UI::Align::kLeft, true);
+ UI::Box::Resizing::kFullSize);
box->add(new WuiPlotGenericAreaSlider(this, *plot_production_, this, 0, 0, kPlotWidth, 45,
g_gr->images().get("images/ui_basic/but1.png")),
- UI::Align::kLeft, true);
+ UI::Box::Resizing::kFullSize);
}
/**
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2017-02-23 19:38:51 +0000
+++ src/wui/warehousewindow.cc 2017-02-25 18:55:39 +0000
@@ -127,7 +127,7 @@
can_act_(gb_.can_act(wh_.owner().player_number())),
type_(type),
display_(this, width, wh_, type_, can_act_) {
- add(&display_, UI::Align::kLeft, true);
+ add(&display_, Resizing::kFullSize);
if (can_act_) {
UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
@@ -140,7 +140,7 @@
g_gr->images().get("images/wui/buildings/stock_policy_button_" #policy ".png"), tooltip), \
b->sigclicked.connect( \
boost::bind(&WarehouseWaresPanel::set_policy, this, Warehouse::StockPolicy::k##policyname)), \
- buttons->add(b, UI::Align::kCenter);
+ buttons->add(b);
ADD_POLICY_BUTTON(normal, Normal, _("Normal policy"))
ADD_POLICY_BUTTON(prefer, Prefer, _("Preferably store selected wares here"))
Follow ups