← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1326395 into lp:widelands

 

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

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1326395 in widelands: "Information tool in the editor has large tool area"
  https://bugs.launchpad.net/widelands/+bug/1326395

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1326395/+merge/265905

The editor info tool now always has size one.

The size tool buttons are greyed out if the current tool only has size 1. The last tool size is remembered for when another tool gets activated.

-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1326395 into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2015-01-31 16:03:59 +0000
+++ src/editor/editorinteractive.cc	2015-07-26 09:28:16 +0000
@@ -335,6 +335,7 @@
 
 void EditorInteractive::set_sel_radius_and_update_menu(uint32_t const val) {
 	if (tools.current().has_size_one()) {
+		set_sel_radius(0);
 		return;
 	}
 	if (UI::UniqueWindow * const w = m_toolsizemenu.window) {
@@ -497,8 +498,18 @@
 void EditorInteractive::select_tool
 (EditorTool & primary, EditorTool::ToolIndex const which) {
 	if (which == EditorTool::First && & primary != tools.current_pointer) {
-		if (primary.has_size_one())
-			set_sel_radius_and_update_menu(0);
+		if (primary.has_size_one()) {
+			set_sel_radius(0);
+			if (UI::UniqueWindow * const w = m_toolsizemenu.window) {
+				EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
+				toolsize_menu.set_buttons_enabled(false);
+			}
+		} else {
+			if (UI::UniqueWindow * const w = m_toolsizemenu.window) {
+				EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
+				toolsize_menu.update(toolsize_menu.value());
+			}
+		}
 		Widelands::Map & map = egbase().map();
 		//  A new tool has been selected. Remove all registered overlay callback
 		//  functions.

=== modified file 'src/editor/tools/editor_info_tool.h'
--- src/editor/tools/editor_info_tool.h	2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_info_tool.h	2015-07-26 09:28:16 +0000
@@ -36,6 +36,8 @@
 	char const* get_sel_impl() const override {
 		return "pics/fsel_editor_info.png";
 	}
+
+	bool has_size_one() const override {return true;}
 };
 
 #endif  // end of include guard: WL_EDITOR_TOOLS_EDITOR_INFO_TOOL_H

=== modified file 'src/editor/ui_menus/editor_toolsize_menu.cc'
--- src/editor/ui_menus/editor_toolsize_menu.cc	2014-11-30 18:49:38 +0000
+++ src/editor/ui_menus/editor_toolsize_menu.cc	2015-07-26 09:28:16 +0000
@@ -55,7 +55,8 @@
 		 g_gr->images().get("pics/but0.png"),
 		 g_gr->images().get("pics/scrollbar_down.png"),
 		 std::string(),
-		 0 < parent.get_sel_radius())
+		 0 < parent.get_sel_radius()),
+	value_(1)
 {
 	m_increase.sigclicked.connect(boost::bind(&EditorToolsizeMenu::increase_radius, boost::ref(*this)));
 	m_decrease.sigclicked.connect(boost::bind(&EditorToolsizeMenu::decrease_radius, boost::ref(*this)));
@@ -64,16 +65,25 @@
 	m_decrease.set_repeating(true);
 	update(parent.get_sel_radius());
 
+	if (eia().tools.current().has_size_one()) {
+		set_buttons_enabled(false);
+	}
+
 	if (get_usedefaultpos())
 		center_to_parent();
 }
 
 
 void EditorToolsizeMenu::update(uint32_t const val) {
-	eia().set_sel_radius(val);
-	m_decrease.set_enabled(0 < val);
-	m_increase.set_enabled    (val < MAX_TOOL_AREA);
-	m_textarea.set_text((boost::format(_("Current Size: %u")) % (val + 1)).str());
+		value_ = val;
+		eia().set_sel_radius(val);
+		set_buttons_enabled(true);
+		m_textarea.set_text((boost::format(_("Current Size: %u")) % (val + 1)).str());
+}
+
+void EditorToolsizeMenu::set_buttons_enabled(bool enable) {
+	m_decrease.set_enabled(enable && 0 < value_);
+	m_increase.set_enabled(enable && value_ < MAX_TOOL_AREA);
 }
 
 

=== modified file 'src/editor/ui_menus/editor_toolsize_menu.h'
--- src/editor/ui_menus/editor_toolsize_menu.h	2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_toolsize_menu.h	2015-07-26 09:28:16 +0000
@@ -32,6 +32,8 @@
 struct EditorToolsizeMenu : public UI::UniqueWindow {
 	EditorToolsizeMenu(EditorInteractive &, UI::UniqueWindow::Registry &);
 	void update(uint32_t);
+	void set_buttons_enabled(bool enable);
+	uint32_t value() {return value_;}
 
 private:
 	EditorInteractive & eia();
@@ -40,6 +42,7 @@
 
 	UI::Textarea                                   m_textarea;
 	UI::Button m_increase, m_decrease;
+	uint32_t value_;
 };
 
 


Follow ups