← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/fsmenu_fullscreen_3_mapselect into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/fsmenu_fullscreen_3_mapselect into lp:widelands.

Commit message:
Map Selection screen now relayouts itself on fullscreen toggle.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1398733 in widelands: "Fullscreen Menus cannot relayout themselves"
  https://bugs.launchpad.net/widelands/+bug/1398733

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/fsmenu_fullscreen_3_mapselect/+merge/310744
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fsmenu_fullscreen_3_mapselect into lp:widelands.
=== modified file 'src/editor/ui_menus/main_menu_save_map.cc'
--- src/editor/ui_menus/main_menu_save_map.cc	2016-08-04 18:09:55 +0000
+++ src/editor/ui_menus/main_menu_save_map.cc	2016-11-15 07:13:59 +0000
@@ -77,7 +77,7 @@
 	set_current_directory(curdir_);
 
 	// Make room for edit_options_ button
-	map_details_.set_max_height(map_details_.get_h() - buth_ - padding_);
+	map_details_.set_size(map_details_.get_w(), map_details_.get_h() - buth_ - padding_);
 
 	table_.selected.connect(boost::bind(&MainMenuSaveMap::clicked_item, boost::ref(*this)));
 	table_.double_clicked.connect(

=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2016-10-30 07:59:27 +0000
+++ src/ui_basic/table.cc	2016-11-15 07:13:59 +0000
@@ -72,9 +72,8 @@
 	set_thinks(false);
 	set_can_focus(true);
 	scrollbar_filler_button_->set_visible(false);
-	scrollbar_ =
-	   new Scrollbar(get_parent(), get_x() + get_w() - Scrollbar::kSize, get_y() + headerheight_,
-	                 Scrollbar::kSize, get_h() - headerheight_, button_background);
+	scrollbar_ = new Scrollbar(this, get_w() - Scrollbar::kSize, headerheight_, Scrollbar::kSize,
+	                           get_h() - headerheight_, button_background);
 	scrollbar_->moved.connect(boost::bind(&Table::set_scrollpos, this, _1));
 	scrollbar_->set_steps(1);
 	scrollbar_->set_singlestepsize(lineheight_);
@@ -497,12 +496,11 @@
 	EntryRecord& result = *new EntryRecord(entry);
 	entry_records_.push_back(&result);
 	result.data_.resize(columns_.size());
-	for (size_t i = 0; i < columns_.size(); ++i)
+	for (size_t i = 0; i < columns_.size(); ++i) {
 		if (columns_.at(i).is_checkbox_column) {
 			result.data_.at(i).d_picture = g_gr->images().get("images/ui_basic/checkbox_empty.png");
 		}
-
-	scrollbar_->set_steps(entry_records_.size() * get_lineheight() - (get_h() - headerheight_ - 2));
+	}
 
 	if (do_select) {
 		select(entry_records_.size() - 1);
@@ -528,12 +526,12 @@
 	const EntryRecordVector::iterator it = entry_records_.begin() + i;
 	delete *it;
 	entry_records_.erase(it);
-	if (selection_ == i)
+	if (selection_ == i) {
 		selection_ = no_selection_index();
-	else if (selection_ > i && selection_ != no_selection_index())
+	} else if (selection_ > i && selection_ != no_selection_index()) {
 		selection_--;
-
-	scrollbar_->set_steps(entry_records_.size() * get_lineheight() - (get_h() - headerheight_ - 2));
+	}
+	layout();
 }
 
 bool Table<void*>::sort_helper(uint32_t a, uint32_t b) {
@@ -544,14 +542,42 @@
 }
 
 void Table<void*>::layout() {
-	// If we have a flexible column, adjust the column sizes.
+	if (columns_.empty()) {
+		return;
+	}
+
+	// Position and update the scrollbar
+	scrollbar_->set_pos(Vector2i(get_w() - Scrollbar::kSize, headerheight_));
+	scrollbar_->set_size(scrollbar_->get_w(), get_h() - headerheight_);
+	scrollbar_->set_pagesize(get_h() - 2 * get_lineheight() - headerheight_);
+	scrollbar_->set_steps(entry_records_.size() * get_lineheight() - (get_h() - headerheight_ - 2));
+
+	// Find a column to resize
+	size_t resizeable_column = std::numeric_limits<size_t>::max();
 	if (flexible_column_ != std::numeric_limits<size_t>::max()) {
+		resizeable_column = flexible_column_;
+	} else {
+		// Use the widest column
+		int all_columns_width = scrollbar_ && scrollbar_->is_enabled() ? scrollbar_->get_w() : 0;
+		uint32_t widest_width = columns_[resizeable_column].width;
+		for (size_t i = 1; i < columns_.size(); ++i) {
+			const uint32_t width = columns_[i].width;
+			all_columns_width += width;
+			if (width > widest_width) {
+				widest_width = width;
+				resizeable_column = i;
+			}
+		}
+	}
+
+	// If we have a resizeable column, adjust the column sizes.
+	if (resizeable_column != std::numeric_limits<size_t>::max()) {
 		int all_columns_width = scrollbar_->is_enabled() ? scrollbar_->get_w() : 0;
 		for (const auto& column : columns_) {
 			all_columns_width += column.width;
 		}
 		if (all_columns_width != get_w()) {
-			Column& column = columns_.at(flexible_column_);
+			Column& column = columns_.at(resizeable_column);
 			column.width = column.width + get_w() - all_columns_width;
 			column.btn->set_size(column.width, column.btn->get_h());
 			int offset = 0;
@@ -559,6 +585,7 @@
 				col.btn->set_pos(Vector2i(offset, col.btn->get_y()));
 				offset = col.btn->get_x() + col.btn->get_w();
 			}
+
 			if (scrollbar_->is_enabled()) {
 				const UI::Button* last_column_btn = columns_.back().btn;
 				scrollbar_filler_button_->set_pos(

=== modified file 'src/ui_fsmenu/campaign_select.cc'
--- src/ui_fsmenu/campaign_select.cc	2016-10-29 06:41:42 +0000
+++ src/ui_fsmenu/campaign_select.cc	2016-11-15 07:13:59 +0000
@@ -114,6 +114,10 @@
 	fill_table();
 }
 
+void FullscreenMenuCampaignSelect::layout() {
+	// TODO(GunChleoc): Implement when we have box layout for the details.
+}
+
 /**
  * OK was clicked, after an entry of campaignlist got selected.
  */
@@ -351,6 +355,10 @@
 	table_.focus();
 }
 
+void FullscreenMenuCampaignMapSelect::layout() {
+	// TODO(GunChleoc): Implement when we have box layout for the details.
+}
+
 std::string FullscreenMenuCampaignMapSelect::get_map() {
 	return campmapfile;
 }

=== modified file 'src/ui_fsmenu/campaign_select.h'
--- src/ui_fsmenu/campaign_select.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/campaign_select.h	2016-11-15 07:13:59 +0000
@@ -47,6 +47,8 @@
 	void fill_table() override;
 
 private:
+	void layout() override;
+
 	/// Updates buttons and text labels and returns whether a table entry is selected.
 	bool set_has_selection();
 
@@ -101,6 +103,8 @@
 	void fill_table() override;
 
 private:
+	void layout() override;
+
 	/// Updates buttons and text labels and returns whether a table entry is selected.
 	bool set_has_selection();
 	/**

=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc	2016-11-01 12:15:30 +0000
+++ src/ui_fsmenu/internet_lobby.cc	2016-11-15 07:13:59 +0000
@@ -151,6 +151,10 @@
 		connect_to_metaserver();
 }
 
+void FullscreenMenuInternetLobby::layout() {
+	// TODO(GunChleoc): Box layout and then implement
+}
+
 /// think function of the UI (main loop)
 void FullscreenMenuInternetLobby::think() {
 	FullscreenMenuBase::think();

=== modified file 'src/ui_fsmenu/internet_lobby.h'
--- src/ui_fsmenu/internet_lobby.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/internet_lobby.h	2016-11-15 07:13:59 +0000
@@ -44,6 +44,8 @@
 	void clicked_ok() override;
 
 private:
+	void layout() override;
+
 	uint32_t butx_;
 	uint32_t butw_;
 	uint32_t buth_;

=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc	2016-10-31 08:14:21 +0000
+++ src/ui_fsmenu/launch_mpg.cc	2016-11-15 07:13:59 +0000
@@ -237,6 +237,10 @@
 	delete chat_;
 }
 
+void FullscreenMenuLaunchMPG::layout() {
+	// TODO(GunChleoc): Implement when we have redesigned this
+}
+
 void FullscreenMenuLaunchMPG::think() {
 	if (ctrl_)
 		ctrl_->think();

=== modified file 'src/ui_fsmenu/launch_mpg.h'
--- src/ui_fsmenu/launch_mpg.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/launch_mpg.h	2016-11-15 07:13:59 +0000
@@ -58,6 +58,8 @@
 	void clicked_back() override;
 
 private:
+	void layout() override;
+
 	LuaInterface* lua_;
 
 	void change_map_or_save();

=== modified file 'src/ui_fsmenu/launch_spg.cc'
--- src/ui_fsmenu/launch_spg.cc	2016-10-29 10:21:08 +0000
+++ src/ui_fsmenu/launch_spg.cc	2016-11-15 07:13:59 +0000
@@ -163,6 +163,10 @@
 	delete lua_;
 }
 
+void FullscreenMenuLaunchSPG::layout() {
+	// TODO(GunChleoc): Implement when we have redesigned this
+}
+
 /**
  * Select a map as a first step in launching a game, before
  * showing the actual setup menu.

=== modified file 'src/ui_fsmenu/launch_spg.h'
--- src/ui_fsmenu/launch_spg.h	2016-10-29 10:21:08 +0000
+++ src/ui_fsmenu/launch_spg.h	2016-11-15 07:13:59 +0000
@@ -64,6 +64,8 @@
 	void clicked_back() override;
 
 private:
+	void layout() override;
+
 	LuaInterface* lua_;
 
 	void select_map();

=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
--- src/ui_fsmenu/load_map_or_game.cc	2016-10-26 12:43:57 +0000
+++ src/ui_fsmenu/load_map_or_game.cc	2016-11-15 07:13:59 +0000
@@ -38,34 +38,31 @@
      padding_(4),
      indent_(10),
      label_height_(20),
-     tablex_(get_w() * 47 / 2500),
-     tabley_(get_h() * 17 / 50),
-     tablew_(get_w() * 711 / 1250),
-     tableh_(get_h() * 6083 / 10000),
      right_column_margin_(15),
-     right_column_x_(tablex_ + tablew_ + right_column_margin_),
-     buty_(get_h() * 9 / 10),
-     butw_((get_w() - right_column_x_ - right_column_margin_) / 2 - padding_),
-     buth_(get_h() * 9 / 200),
-     right_column_tab_(get_w() - right_column_margin_ - butw_),
 
      // Main buttons
-     back_(this,
-           "back",
-           right_column_x_,
-           buty_,
-           butw_,
-           buth_,
-           g_gr->images().get("images/ui_basic/but0.png"),
-           _("Back")),
-     ok_(this,
-         "ok",
-         get_w() - right_column_margin_ - butw_,
-         buty_,
-         butw_,
-         buth_,
-         g_gr->images().get("images/ui_basic/but2.png"),
-         _("OK")) {
+     back_(this, "back", 0, 0, 0, 0, g_gr->images().get("images/ui_basic/but0.png"), _("Back")),
+     ok_(this, "ok", 0, 0, 0, 0, g_gr->images().get("images/ui_basic/but2.png"), _("OK")) {
+	layout();
+}
+
+void FullscreenMenuLoadMapOrGame::layout() {
+	// UI coordinates and spacers
+	tablex_ = get_w() * 47 / 2500;
+	tabley_ = get_h() * 17 / 50;
+	tablew_ = get_w() * 711 / 1250;
+	tableh_ = get_h() * 6083 / 10000;
+	right_column_x_ = tablex_ + tablew_ + right_column_margin_;
+	buty_ = get_h() * 9 / 10;
+	butw_ = (get_w() - right_column_x_ - right_column_margin_) / 2 - padding_;
+	buth_ = get_h() * 9 / 200;
+	right_column_tab_ = get_w() - right_column_margin_ - butw_;
+
+	// Main buttons
+	back_.set_size(butw_, buth_);
+	back_.set_pos(Vector2i(right_column_x_, buty_));
+	ok_.set_size(butw_, buth_);
+	ok_.set_pos(Vector2i(get_w() - right_column_margin_ - butw_, buty_));
 }
 
 int32_t FullscreenMenuLoadMapOrGame::get_y_from_preceding(UI::Panel& preceding_panel) {

=== modified file 'src/ui_fsmenu/load_map_or_game.h'
--- src/ui_fsmenu/load_map_or_game.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/load_map_or_game.h	2016-11-15 07:13:59 +0000
@@ -54,6 +54,8 @@
 	FullscreenMenuLoadMapOrGame();
 
 protected:
+	void layout() override;
+
 	// Updates the information display on the right-hand side.
 	// Call this function when a different entry in the table gets selected.
 	virtual void entry_selected() {
@@ -68,14 +70,14 @@
 	int32_t get_right_column_w(int32_t x);
 
 	// UI coordinates and spacers
-	int32_t const padding_;  // Common padding between panels
-	int32_t const indent_;   // Indent for elements below labels
-	int32_t const label_height_;
-	int32_t const tablex_, tabley_, tablew_, tableh_;
-	int32_t const right_column_margin_;  // X margins of the right column
-	int32_t const right_column_x_;
-	int32_t const buty_, butw_, buth_;  // Button dimensions
-	int32_t const right_column_tab_;
+	const int32_t padding_;  // Common padding between panels
+	const int32_t indent_;   // Indent for elements below labels
+	const int32_t label_height_;
+	const int32_t right_column_margin_;  // X margins of the right column
+	int32_t tablex_, tabley_, tablew_, tableh_;
+	int32_t right_column_x_;
+	int32_t buty_, butw_, buth_;  // Button dimensions
+	int32_t right_column_tab_;
 
 	// Main buttons
 	UI::Button back_;

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2016-10-29 06:41:42 +0000
+++ src/ui_fsmenu/loadgame.cc	2016-11-15 07:13:59 +0000
@@ -238,6 +238,10 @@
 	fill_table();
 }
 
+void FullscreenMenuLoadGame::layout() {
+	// TODO(GunChleoc): Implement when we have box layout for the details.
+}
+
 void FullscreenMenuLoadGame::think() {
 	if (ctrl_) {
 		ctrl_->think();

=== modified file 'src/ui_fsmenu/loadgame.h'
--- src/ui_fsmenu/loadgame.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/loadgame.h	2016-11-15 07:13:59 +0000
@@ -91,6 +91,8 @@
 	void fill_table() override;
 
 private:
+	void layout() override;
+
 	/// Updates buttons and text labels and returns whether a table entry is selected.
 	bool set_has_selection();
 	bool compare_date_descending(uint32_t, uint32_t);

=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc	2016-10-28 18:04:11 +0000
+++ src/ui_fsmenu/mapselect.cc	2016-11-15 07:13:59 +0000
@@ -42,11 +42,12 @@
                                                  GameController* const ctrl)
    : FullscreenMenuLoadMapOrGame(),
      checkbox_space_(25),
-     checkboxes_y_(tabley_ - 120),
+     // Less padding for big fonts; space is tight.
+     checkbox_padding_(UI::g_fh1->fontset()->size_offset() > 0 ? 0 : 2 * padding_),
 
      // Main title
-     title_(this, get_w() / 2, checkboxes_y_ / 3, _("Choose a map"), UI::Align::kHCenter),
-
+     title_(this, 0, 0, _("Choose a map"), UI::Align::kHCenter),
+     checkboxes_(this, 0, 0, UI::Box::Vertical, 0, 0, 2 * padding_),
      table_(this, tablex_, tabley_, tablew_, tableh_, false),
      map_details_(this,
                   right_column_x_,
@@ -77,45 +78,40 @@
 	   1, boost::bind(&FullscreenMenuMapSelect::compare_mapnames, this, _1, _2));
 	table_.set_column_compare(2, boost::bind(&FullscreenMenuMapSelect::compare_size, this, _1, _2));
 
-	UI::Box* vbox =
-	   new UI::Box(this, tablex_, checkboxes_y_, UI::Box::Horizontal, checkbox_space_, get_w());
+	UI::Box* hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
 
 	// Must be initialized before tag checkboxes
 	cb_dont_localize_mapnames_ =
-	   new UI::Checkbox(vbox, Vector2i(0, 0), _("Show original map names"));
+	   new UI::Checkbox(hbox, Vector2i(0, 0), _("Show original map names"));
 	cb_dont_localize_mapnames_->set_state(false);
 	cb_dont_localize_mapnames_->changedto.connect(
 	   boost::bind(&FullscreenMenuMapSelect::fill_table, boost::ref(*this)));
 
-	cb_show_all_maps_ = add_tag_checkbox(vbox, "blumba", _("Show all maps"));
+	cb_show_all_maps_ = add_tag_checkbox(hbox, "blumba", _("Show all maps"));
 	tags_checkboxes_.clear();  // Remove this again, it is a special tag checkbox
 	cb_show_all_maps_->set_state(true);
 
-	vbox->add(cb_dont_localize_mapnames_, UI::Align::kLeft, true);
-	vbox->set_size(get_w() - 2 * tablex_, checkbox_space_);
-
-	vbox = new UI::Box(this, tablex_, vbox->get_y() + vbox->get_h() + padding_, UI::Box::Horizontal,
-	                   checkbox_space_, get_w());
-	add_tag_checkbox(vbox, "official", localize_tag("official"));
-	add_tag_checkbox(vbox, "unbalanced", localize_tag("unbalanced"));
-	add_tag_checkbox(vbox, "seafaring", localize_tag("seafaring"));
-	add_tag_checkbox(vbox, "artifacts", localize_tag("artifacts"));
-	add_tag_checkbox(vbox, "scenario", localize_tag("scenario"));
-	vbox->set_size(get_w() - 2 * tablex_, checkbox_space_);
-
-	vbox = new UI::Box(this, tablex_, vbox->get_y() + vbox->get_h() + padding_, UI::Box::Horizontal,
-	                   checkbox_space_, get_w());
-	add_tag_checkbox(vbox, "ffa", localize_tag("ffa"));
-	add_tag_checkbox(vbox, "1v1", localize_tag("1v1"));
-
-	vbox->set_size(get_w() - 2 * tablex_, checkbox_space_);
-
-	vbox = new UI::Box(this, tablex_, vbox->get_y() + vbox->get_h() + padding_, UI::Box::Horizontal,
-	                   checkbox_space_, get_w());
-	add_tag_checkbox(vbox, "2teams", localize_tag("2teams"));
-	add_tag_checkbox(vbox, "3teams", localize_tag("3teams"));
-	add_tag_checkbox(vbox, "4teams", localize_tag("4teams"));
-	vbox->set_size(get_w() - 2 * tablex_, checkbox_space_);
+	hbox->add(cb_dont_localize_mapnames_, UI::Align::kLeft, true);
+	checkboxes_.add(hbox, UI::Align::kLeft, true);
+
+	hbox = new UI::Box(&checkboxes_, 0, 0, UI::Box::Horizontal, checkbox_space_, get_w());
+	add_tag_checkbox(hbox, "official", localize_tag("official"));
+	add_tag_checkbox(hbox, "unbalanced", localize_tag("unbalanced"));
+	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);
+
+	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);
+
+	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);
 
 	scenario_types_ = settings_->settings().multiplayer ? Map::MP_SCENARIO : Map::SP_SCENARIO;
 
@@ -125,6 +121,20 @@
 	// We don't need the unlocalizing option if there is nothing to unlocalize.
 	// We know this after the list is filled.
 	cb_dont_localize_mapnames_->set_visible(has_translated_mapname_);
+	layout();
+}
+
+void FullscreenMenuMapSelect::layout() {
+	title_.set_size(get_w(), title_.get_h());
+	FullscreenMenuLoadMapOrGame::layout();
+	checkboxes_y_ = tabley_ - 4 * (cb_show_all_maps_->get_h() + checkbox_padding_) - 2 * padding_;
+	title_.set_pos(Vector2i(0, checkboxes_y_ / 3));
+	checkboxes_.set_pos(Vector2i(tablex_, checkboxes_y_));
+	checkboxes_.set_size(get_w() - 2 * tablex_, tabley_ - checkboxes_y_);
+	table_.set_size(tablew_, tableh_);
+	table_.set_pos(Vector2i(tablex_, tabley_));
+	map_details_.set_size(get_right_column_w(right_column_x_), tableh_ - buth_ - 4 * padding_);
+	map_details_.set_pos(Vector2i(right_column_x_, tabley_));
 }
 
 void FullscreenMenuMapSelect::think() {

=== modified file 'src/ui_fsmenu/mapselect.h'
--- src/ui_fsmenu/mapselect.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/mapselect.h	2016-11-15 07:13:59 +0000
@@ -52,6 +52,8 @@
 	void fill_table() override;
 
 private:
+	void layout() override;
+
 	bool compare_players(uint32_t, uint32_t);
 	bool compare_mapnames(uint32_t, uint32_t);
 	bool compare_size(uint32_t, uint32_t);
@@ -62,9 +64,11 @@
 	void tagbox_changed(int32_t, bool);
 
 	int32_t const checkbox_space_;
-	int32_t const checkboxes_y_;
+	const int checkbox_padding_;
+	int32_t checkboxes_y_;
 
 	UI::Textarea title_;
+	UI::Box checkboxes_;
 
 	MapTable table_;
 	MapDetails map_details_;

=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc	2016-09-25 10:13:23 +0000
+++ src/ui_fsmenu/netsetup_lan.cc	2016-11-15 07:13:59 +0000
@@ -124,6 +124,10 @@
 	joingame.set_enabled(false);
 }
 
+void FullscreenMenuNetSetupLAN::layout() {
+	// TODO(GunChleoc): Box layout and then implement
+}
+
 void FullscreenMenuNetSetupLAN::think() {
 	FullscreenMenuBase::think();
 

=== modified file 'src/ui_fsmenu/netsetup_lan.h'
--- src/ui_fsmenu/netsetup_lan.h	2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/netsetup_lan.h	2016-11-15 07:13:59 +0000
@@ -57,6 +57,8 @@
 	void clicked_ok() override;
 
 private:
+	void layout() override;
+
 	uint32_t butx_;
 	uint32_t butw_;
 	uint32_t buth_;

=== modified file 'src/wui/mapdetails.cc'
--- src/wui/mapdetails.cc	2016-10-29 06:41:42 +0000
+++ src/wui/mapdetails.cc	2016-11-15 07:13:59 +0000
@@ -27,6 +27,7 @@
 #include "base/i18n.h"
 #include "base/log.h"
 #include "base/wexception.h"
+#include "graphic/font_handler1.h"
 #include "graphic/graphic.h"
 #include "graphic/text_constants.h"
 #include "io/filesystem/layered_filesystem.h"
@@ -34,6 +35,7 @@
 #include "logic/game_settings.h"
 #include "map_io/widelands_map_loader.h"
 #include "ui_basic/box.h"
+#include "ui_basic/scrollbar.h"
 #include "wui/map_tags.h"
 
 namespace {
@@ -68,34 +70,31 @@
 }
 }  // namespace
 
-MapDetails::MapDetails(
-   Panel* parent, int32_t x, int32_t y, int32_t max_w, int32_t max_h, Style style)
-   : UI::Panel(parent, x, y, max_w, max_h),
+MapDetails::MapDetails(Panel* parent, int32_t x, int32_t y, int32_t w, int32_t h, Style style)
+   : UI::Panel(parent, x, y, w, h),
 
      style_(style),
      padding_(4),
-     main_box_(this, 0, 0, UI::Box::Vertical, max_w, max_h, 0),
+     main_box_(this, 0, 0, UI::Box::Vertical, 0, 0, 0),
      name_label_(&main_box_,
                  0,
                  0,
-                 max_w - padding_,
-                 20,
+                 UI::Scrollbar::kSize,
+                 0,
                  "",
                  UI::Align::kLeft,
                  g_gr->images().get("images/ui_basic/but3.png"),
                  UI::MultilineTextarea::ScrollMode::kNoScrolling),
-     descr_(&main_box_, 0, 0, max_w, 20, ""),
+     descr_(&main_box_, 0, 0, UI::Scrollbar::kSize, 0, ""),
      suggested_teams_box_(
-        new UI::SuggestedTeamsBox(this, 0, 0, UI::Box::Vertical, padding_, 0, max_w)) {
+        new UI::SuggestedTeamsBox(this, 0, 0, UI::Box::Vertical, padding_, 0, w)) {
 	name_label_.force_new_renderer();
 	descr_.force_new_renderer();
 
 	main_box_.add(&name_label_, UI::Align::kLeft);
 	main_box_.add_space(padding_);
 	main_box_.add(&descr_, UI::Align::kLeft);
-	main_box_.set_size(
-	   max_w, max_h);  // We need to initialize the width, set_max_height will set the height
-	set_max_height(max_h);
+	layout();
 }
 
 void MapDetails::clear() {
@@ -104,20 +103,19 @@
 	suggested_teams_box_->hide();
 }
 
-void MapDetails::set_max_height(int new_height) {
-	max_h_ = new_height;
-	update_layout();
-}
+void MapDetails::layout() {
+	name_label_.set_size(
+	   get_w() - padding_,
+	   UI::g_fh1->render(as_uifont(UI::g_fh1->fontset()->representative_character()))->height() + 2);
 
-void MapDetails::update_layout() {
 	// Adjust sizes for show / hide suggested teams
 	if (suggested_teams_box_->is_visible()) {
-		suggested_teams_box_->set_pos(Vector2i(0, max_h_ - suggested_teams_box_->get_h()));
-		main_box_.set_size(main_box_.get_w(), max_h_ - suggested_teams_box_->get_h() - padding_);
+		suggested_teams_box_->set_pos(Vector2i(0, get_h() - suggested_teams_box_->get_h()));
+		main_box_.set_size(get_w(), get_h() - suggested_teams_box_->get_h() - padding_);
 	} else {
-		main_box_.set_size(main_box_.get_w(), max_h_);
+		main_box_.set_size(get_w(), get_h());
 	}
-	descr_.set_size(descr_.get_w(), main_box_.get_h() - name_label_.get_h() - padding_);
+	descr_.set_size(main_box_.get_w(), main_box_.get_h() - name_label_.get_h() - padding_);
 	descr_.scroll_to_top();
 }
 
@@ -129,7 +127,7 @@
 		                      as_header(_("Directory:"), style_, true) %
 		                      as_content(mapdata.localized_name, style_))
 		                        .str());
-		main_box_.set_size(main_box_.get_w(), max_h_);
+		main_box_.set_size(main_box_.get_w(), get_h());
 
 	} else {  // Show map information
 		name_label_.set_text(
@@ -196,5 +194,5 @@
 			suggested_teams_box_->show(mapdata.suggested_teams);
 		}
 	}
-	update_layout();
+	layout();
 }

=== modified file 'src/wui/mapdetails.h'
--- src/wui/mapdetails.h	2016-08-04 15:49:05 +0000
+++ src/wui/mapdetails.h	2016-11-15 07:13:59 +0000
@@ -33,17 +33,15 @@
 public:
 	enum class Style { kFsMenu, kWui };
 
-	MapDetails(Panel* parent, int32_t x, int32_t y, int32_t max_w, int32_t max_h, Style style);
+	MapDetails(Panel* parent, int32_t x, int32_t y, int32_t w, int32_t h, Style style);
 
 	void clear();
-	void set_max_height(int new_height);
-	void update_layout();
 	void update(const MapData& mapdata, bool localize_mapname);
 
 private:
+	void layout() override;
 	const Style style_;
 	const int padding_;
-	int max_h_;
 
 	UI::Box main_box_;
 	UI::MultilineTextarea name_label_;


References