Miroslav Remák has proposed merging 
lp:~widelands-dev/widelands/infotool_stuck_painting into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/infotool_stuck_painting/+merge/290076

After using the info tool, if your mouse pointer is located where the field 
info window is to be created, the editor remains in painting mode (because the 
newly created window eats the mouse release event that is required to stop 
painting). This can get pretty nasty, as moving your mouse to different fields 
will keep creating new windows (until you click and release somewhere in the 
map view).

As a consequence of the fix, it will no longer be possible to 'paint' with the 
info tool, though, frankly, I can't imagine anyone getting upset over that. :)
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/infotool_stuck_painting into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2016-03-19 11:47:00 +0000
+++ src/editor/editorinteractive.cc	2016-03-24 18:26:09 +0000
@@ -104,7 +104,7 @@
 	InteractiveBase(e, g_options.pull_section("global")),
 	need_save_(false),
 	realtime_(SDL_GetTicks()),
-	left_mouse_button_is_down_(false),
+	is_painting_(false),
 	tools_(new Tools()),
 	history_(new EditorHistory(undo_, redo_)),
 
@@ -307,14 +307,14 @@
 
 bool EditorInteractive::handle_mouserelease(uint8_t btn, int32_t x, int32_t y) {
 	if (btn == SDL_BUTTON_LEFT) {
-		left_mouse_button_is_down_ = false;
+		stop_painting();
 	}
 	return InteractiveBase::handle_mouserelease(btn, x, y);
 }
 
 bool EditorInteractive::handle_mousepress(uint8_t btn, int32_t x, int32_t y) {
 	if (btn == SDL_BUTTON_LEFT) {
-		left_mouse_button_is_down_ = true;
+		start_painting();
 	}
 	return InteractiveBase::handle_mousepress(btn, x, y);
 }
@@ -325,7 +325,7 @@
 	    tools_->current().operates_on_triangles() ?
 	    sel.triangle != get_sel_pos().triangle : sel.node != get_sel_pos().node;
 	InteractiveBase::set_sel_pos(sel);
-	if (target_changed && left_mouse_button_is_down_)
+	if (target_changed && is_painting_)
 		map_clicked(true);
 }
 
@@ -366,6 +366,16 @@
 	}
 }
 
+void EditorInteractive::start_painting()
+{
+	is_painting_ = true;
+}
+
+void EditorInteractive::stop_painting()
+{
+	is_painting_ = false;
+}
+
 void EditorInteractive::toggle_help() {
 	if (helpmenu_.window)
 		delete helpmenu_.window;

=== modified file 'src/editor/editorinteractive.h'
--- src/editor/editorinteractive.h	2016-02-18 18:27:52 +0000
+++ src/editor/editorinteractive.h	2016-03-24 18:26:09 +0000
@@ -100,6 +100,8 @@
 	void map_clicked(bool draw = false);
 	void set_sel_pos(Widelands::NodeAndTriangle<>) override;
 	void set_sel_radius_and_update_menu(uint32_t);
+	void start_painting();
+	void stop_painting();
 
 	//  Handle UI elements.
 	bool handle_key(bool down, SDL_Keysym) override;
@@ -155,7 +157,7 @@
 	bool need_save_;
 	std::vector<PlayerReferences> player_tribe_references_;
 	uint32_t realtime_;
-	bool left_mouse_button_is_down_;
+	bool is_painting_;
 
 	std::unique_ptr<Tools> tools_;
 	std::unique_ptr<EditorHistory> history_;

=== modified file 'src/editor/tools/editor_info_tool.cc'
--- src/editor/tools/editor_info_tool.cc	2016-02-10 19:50:13 +0000
+++ src/editor/tools/editor_info_tool.cc	2016-03-24 18:26:09 +0000
@@ -39,6 +39,8 @@
 										 EditorInteractive& parent,
 										 EditorActionArgs* /* args */,
 										 Widelands::Map* map) {
+	parent.stop_painting();
+
 	UI::Window * const w =
 	    new UI::Window
 	(&parent, "field_information", 30, 30, 400, 200,

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to