← Back to team overview

widelands-dev team mailing list archive

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

 

SirVer has proposed merging lp:~widelands-dev/widelands/ui_fixes into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

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

- Uses SDLK_ (logical keycodes) instead of SDL_SCANCODE (physical keycodes) for
  hotkeys.
- A panel that handles textinput should also handle all key inputs so that they
  do not propagate.
- Removes a bunch of unneeded ifs and other save code changes.
- Renames set_think() to set_thinks().

-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/ui_fixes into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2014-11-13 18:48:57 +0000
+++ src/editor/editorinteractive.cc	2014-11-22 12:01:09 +0000
@@ -394,16 +394,16 @@
 			handled = true;
 			break;
 
-		case SDL_SCANCODE_LSHIFT:
-		case SDL_SCANCODE_RSHIFT:
+		case SDLK_LSHIFT:
+		case SDLK_RSHIFT:
 			if (tools.use_tool == EditorTool::First)
 				select_tool(tools.current(), EditorTool::Second);
 			handled = true;
 			break;
 
-		case SDL_SCANCODE_LALT:
-		case SDL_SCANCODE_RALT:
-		case SDL_SCANCODE_MODE:
+		case SDLK_LALT:
+		case SDLK_RALT:
+		case SDLK_MODE:
 			if (tools.use_tool == EditorTool::First)
 				select_tool(tools.current(), EditorTool::Third);
 			handled = true;
@@ -470,6 +470,7 @@
 				m_history.undo_action(egbase().world());
 			handled = true;
 			break;
+
 		case SDLK_y:
 			if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
 				m_history.redo_action(egbase().world());
@@ -477,16 +478,15 @@
 			break;
 		default:
 			break;
-
 		}
 	} else {
 		// key up events
 		switch (code.sym) {
-		case SDL_SCANCODE_LSHIFT:
-		case SDL_SCANCODE_RSHIFT:
-		case SDL_SCANCODE_LALT:
-		case SDL_SCANCODE_RALT:
-		case SDL_SCANCODE_MODE:
+		case SDLK_LSHIFT:
+		case SDLK_RSHIFT:
+		case SDLK_LALT:
+		case SDLK_RALT:
+		case SDLK_MODE:
 			if (tools.use_tool != EditorTool::First)
 				select_tool(tools.current(), EditorTool::First);
 			handled = true;

=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc	2014-10-27 10:14:10 +0000
+++ src/editor/ui_menus/editor_player_menu.cc	2014-11-22 12:01:09 +0000
@@ -90,8 +90,7 @@
 	}
 	update();
 
-	set_think(true);
-
+	set_thinks(true);
 }
 
 /**

=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2014-11-13 06:45:36 +0000
+++ src/graphic/graphic.cc	2014-11-22 12:01:09 +0000
@@ -295,7 +295,6 @@
 */
 void Graphic::toggle_fullscreen()
 {
-	log("Try SDL_WM_ToggleFullScreen...\n");
 	// TODO(unknown): implement proper fullscreening here. The way it can work is to
 	// recreate SurfaceCache but keeping ImageCache around. Then exiting and
 	// reinitalizing the SDL Video Mode should just work: all surface are

=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc	2014-11-22 10:35:14 +0000
+++ src/ui_basic/button.cc	2014-11-22 12:01:09 +0000
@@ -58,10 +58,9 @@
 	m_clr_down      (229, 161, 2),
 	m_draw_caret    (false)
 {
-	set_think(false);
+	set_thinks(false);
 }
 
-
 Button::Button //  for pictorial buttons
 	(Panel * const parent,
 	 const std::string & name,
@@ -87,7 +86,7 @@
 	m_clr_down      (229, 161, 2),
 	m_draw_caret    (false)
 {
-	set_think(false);
+	set_thinks(false);
 }
 
 
@@ -142,7 +141,7 @@
 	else {
 		if (m_pressed) {
 			m_pressed = false;
-			set_think(false);
+			set_thinks(false);
 			grab_mouse(false);
 		}
 		m_enabled = false;
@@ -307,7 +306,7 @@
 		if (m_repeating) {
 			m_time_nextact =
 				WLApplication::get()->get_time() + MOUSE_BUTTON_AUTOREPEAT_DELAY;
-			set_think(true);
+			set_thinks(true);
 		}
 	}
 	update();
@@ -320,7 +319,7 @@
 
 	if (m_pressed) {
 		m_pressed = false;
-		set_think(false);
+		set_thinks(false);
 		grab_mouse(false);
 		update();
 		if (m_highlighted && m_enabled) {

=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc	2014-11-22 10:23:33 +0000
+++ src/ui_basic/editbox.cc	2014-11-22 12:01:09 +0000
@@ -23,6 +23,7 @@
 
 #include <SDL_keycode.h>
 
+#include "base/log.h"
 #include "graphic/font.h"
 #include "graphic/font_handler.h"
 #include "graphic/rendertarget.h"
@@ -71,7 +72,7 @@
 	m_history_active(false),
 	m_history_position(-1)
 {
-	set_think(false);
+	set_thinks(false);
 
 	m->background = background;
 	m->fontname = UI_FONT_NAME;
@@ -86,7 +87,7 @@
 
 	set_handle_mouse(true);
 	set_can_focus(true);
-	set_handle_textinput(true);
+	set_handle_textinput();
 
 	// Initialize history as empty string
 	for (uint8_t i = 0; i < CHAT_HISTORY_SIZE; ++i)
@@ -232,7 +233,7 @@
 			//let the panel handle the tab key
 			return false;
 
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			// Save history if active and text is not empty
 			if (m_history_active) {
@@ -246,7 +247,7 @@
 			ok();
 			return true;
 
-		case SDL_SCANCODE_KP_PERIOD:
+		case SDLK_KP_PERIOD:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
@@ -269,12 +270,12 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_4:
+		case SDLK_KP_4:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_LEFT:
+		case SDLK_LEFT:
 			if (m->caret > 0) {
 				while ((m->text[--m->caret] & 0xc0) == 0x80) {};
 				if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
@@ -288,12 +289,12 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_6:
+		case SDLK_KP_6:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_RIGHT:
+		case SDLK_RIGHT:
 			if (m->caret < m->text.size()) {
 				while ((m->text[++m->caret] & 0xc0) == 0x80) {};
 				if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
@@ -312,7 +313,7 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_7:
+		case SDLK_KP_7:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
@@ -326,7 +327,7 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_1:
+		case SDLK_KP_1:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
@@ -339,12 +340,12 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_8:
+		case SDLK_KP_8:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_UP:
+		case SDLK_UP:
 			// Load entry from history if active and text is not empty
 			if (m_history_active) {
 				if (m_history_position > CHAT_HISTORY_SIZE - 2)
@@ -358,12 +359,12 @@
 			}
 			return true;
 
-		case SDL_SCANCODE_KP_2:
+		case SDLK_KP_2:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_DOWN:
+		case SDLK_DOWN:
 			// Load entry from history if active and text is not equivalent to the current one
 			if (m_history_active) {
 				if (m_history_position < 1)
@@ -385,11 +386,10 @@
 	return false;
 }
 
-bool EditBox::handle_textinput(const char * ntext) {
-	const std::string help(ntext);
-	if ((m->text.size() +  help.length()) < m->maxLength) {
-		m->text.insert(m->caret, help);
-		m->caret += help.length();
+bool EditBox::handle_textinput(const std::string& input_text) {
+	if ((m->text.size() +  input_text.length()) < m->maxLength) {
+		m->text.insert(m->caret, input_text);
+		m->caret += input_text.length();
 		check_caret();
 		changed();
 		update();

=== modified file 'src/ui_basic/editbox.h'
--- src/ui_basic/editbox.h	2014-10-27 08:37:54 +0000
+++ src/ui_basic/editbox.h	2014-11-22 12:01:09 +0000
@@ -62,7 +62,7 @@
 	bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
 	bool handle_key(bool down, SDL_Keysym) override;
-	bool handle_textinput(const char* text);
+	bool handle_textinput(const std::string& text);
 
 	void draw(RenderTarget &) override;
 

=== modified file 'src/ui_basic/icon.cc'
--- src/ui_basic/icon.cc	2014-09-19 09:07:14 +0000
+++ src/ui_basic/icon.cc	2014-11-22 12:01:09 +0000
@@ -33,7 +33,7 @@
 	m_pic(picture_id)
 {
 	set_handle_mouse(false);
-	set_think(false);
+	set_thinks(false);
 }
 
 void Icon::set_icon(const Image* picture_id) {

=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc	2014-10-28 12:53:29 +0000
+++ src/ui_basic/listselect.cc	2014-11-22 12:01:09 +0000
@@ -59,7 +59,7 @@
 	m_fontname(UI_FONT_NAME),
 	m_fontsize(UI_FONT_SIZE_SMALL)
 {
-	set_think(false);
+	set_thinks(false);
 
 	//  do not allow vertical alignment as it does not make sense
 	m_align = static_cast<Align>(align & Align_Horizontal);
@@ -480,11 +480,11 @@
 	if (down) {
 		uint32_t selected_idx;
 		switch (code.sym) {
-		case SDL_SCANCODE_KP_2:
+		case SDLK_KP_2:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
-		case SDL_SCANCODE_DOWN:
+		case SDLK_DOWN:
 			selected_idx = selection_index() + 1;
 			if (selected_idx < size())
 				select(selected_idx);
@@ -494,11 +494,11 @@
 				m_scrollbar.set_scrollpos(m_scrollpos);
 			}
 			return true;
-		case SDL_SCANCODE_KP_8:
+		case SDLK_KP_8:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
-		case SDL_SCANCODE_UP:
+		case SDLK_UP:
 			selected_idx = selection_index();
 			if (selected_idx > 0)
 				select(selected_idx - 1);

=== modified file 'src/ui_basic/messagebox.cc'
--- src/ui_basic/messagebox.cc	2014-10-14 07:55:05 +0000
+++ src/ui_basic/messagebox.cc	2014-11-22 12:01:09 +0000
@@ -140,7 +140,7 @@
 	}
 
 	switch (code.sym) {
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			pressed_yes();
 			pressed_ok();

=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc	2014-11-22 10:23:33 +0000
+++ src/ui_basic/multilineeditbox.cc	2014-11-22 12:01:09 +0000
@@ -87,8 +87,8 @@
 {
 	set_handle_mouse(true);
 	set_can_focus(true);
-	set_think(false);
-	set_handle_textinput(true);
+	set_thinks(false);
+	set_handle_textinput();
 
 	set_text(text);
 }
@@ -253,7 +253,7 @@
 {
 	if (down) {
 		switch (code.sym) {
-		case SDL_SCANCODE_KP_PERIOD:
+		case SDLK_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
@@ -271,12 +271,12 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_4:
+		case SDLK_KP_4:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_LEFT: {
+		case SDLK_LEFT: {
 			if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
 				uint32_t newpos = d->prev_char(d->cursor_pos);
 				while (newpos > 0 && isspace(d->text[newpos]))
@@ -294,12 +294,12 @@
 			break;
 		}
 
-		case SDL_SCANCODE_KP_6:
+		case SDLK_KP_6:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_RIGHT:
+		case SDLK_RIGHT:
 			if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
 				uint32_t newpos = d->next_char(d->cursor_pos);
 				while (newpos < d->text.size() && isspace(d->text[newpos]))
@@ -312,12 +312,12 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_2:
+		case SDLK_KP_2:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_DOWN:
+		case SDLK_DOWN:
 			if (d->cursor_pos < d->text.size()) {
 				d->refresh_ww();
 
@@ -341,12 +341,12 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_8:
+		case SDLK_KP_8:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
 			/* no break */
-		case SDL_SCANCODE_UP:
+		case SDLK_UP:
 			if (d->cursor_pos > 0) {
 				d->refresh_ww();
 
@@ -368,7 +368,7 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_7:
+		case SDLK_KP_7:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
@@ -386,7 +386,7 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_1:
+		case SDLK_KP_1:
 			if (code.mod & KMOD_NUM) {
 				break;
 			}
@@ -407,7 +407,7 @@
 			}
 			break;
 
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			d->insert(d->cursor_pos, "\n");
 			changed();
@@ -422,11 +422,9 @@
 	return Panel::handle_key(down, code);
 }
 
-
-bool MultilineEditbox::handle_textinput(const char * ntext) {
-	const std::string help(ntext);
-	if (d->text.size() + help.size() <= d->maxbytes) {
-		d->insert(d->cursor_pos, help);
+bool MultilineEditbox::handle_textinput(const std::string& input_text) {
+	if (d->text.size() + input_text.size() <= d->maxbytes) {
+		d->insert(d->cursor_pos, input_text);
 		changed();
 	}
 	return true;

=== modified file 'src/ui_basic/multilineeditbox.h'
--- src/ui_basic/multilineeditbox.h	2014-10-14 06:30:20 +0000
+++ src/ui_basic/multilineeditbox.h	2014-11-22 12:01:09 +0000
@@ -53,7 +53,7 @@
 	void draw(RenderTarget &) override;
 
 	bool handle_key(bool down, SDL_Keysym) override;
-	bool handle_textinput(const char* text);
+	bool handle_textinput(const std::string& text);
 
 private:
 	void scrollpos_changed(int32_t);

=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc	2014-10-28 12:53:29 +0000
+++ src/ui_basic/multilinetextarea.cc	2014-11-22 12:01:09 +0000
@@ -52,7 +52,7 @@
 	m_scrollmode(ScrollNormal)
 {
 	assert(scrollbar_w() <= w);
-	set_think(false);
+	set_thinks(false);
 
 	//  do not allow vertical alignment as it does not make sense
 	m_align = static_cast<Align>(align & Align_Horizontal);

=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc	2014-11-22 11:51:38 +0000
+++ src/ui_basic/panel.cc	2014-11-22 12:01:09 +0000
@@ -57,7 +57,7 @@
 	 const std::string & tooltip_text)
 	:
 	_parent(nparent), _fchild(nullptr), _lchild(nullptr), _mousein(nullptr), _focus(nullptr),
-	_flags(pf_handle_mouse|pf_think|pf_visible),
+	_flags(pf_handle_mouse|pf_thinks|pf_visible),
 	_x(nx), _y(ny), _w(nw), _h(nh),
 	_lborder(0), _rborder(0), _tborder(0), _bborder(0),
 	_border_snap_distance(0), _panel_snap_distance(0),
@@ -528,11 +528,11 @@
 
 /**
  * Descend the panel hierarchy and call the \ref think() function of all
- * (grand-)children for which set_think(false) has not been called.
+ * (grand-)children for which set_thinks(false) has not been called.
  */
 void Panel::do_think()
 {
-	if (get_think())
+	if (thinks())
 		think();
 
 	for (Panel * child = _fchild; child; child = child->_next)
@@ -661,7 +661,7 @@
 }
 
 
-bool Panel::handle_textinput(const char *) {
+bool Panel::handle_textinput(const std::string& /* text */) {
 	return false;
 }
 
@@ -730,18 +730,17 @@
  * Grabs the keyboard focus, if it can,
  * topcaller identifies widget at the beginning of the recursion
  */
-void Panel::focus(bool topcaller)
+void Panel::focus(const bool topcaller)
 {
-	// this assert was deleted, because
-	// it happens, that a child can focus, but a parent
-	// can't. but focus is called recursivly
-	// assert(get_can_focus());
-
 	if (topcaller) {
-		if (get_handle_textinput()) {
-			if (!SDL_IsTextInputActive()) SDL_StartTextInput();
+		if (handles_textinput()) {
+			if (!SDL_IsTextInputActive()) {
+				SDL_StartTextInput();
+			}
 		} else {
-			if (SDL_IsTextInputActive()) SDL_StopTextInput();
+			if (SDL_IsTextInputActive()) {
+				SDL_StopTextInput();
+			}
 		}
 	}
 
@@ -761,12 +760,12 @@
  *
  * \param yes true if the panel's think function should be called
  */
-void Panel::set_think(bool const yes)
+void Panel::set_thinks(bool const yes)
 {
 	if (yes)
-		_flags |= pf_think;
+		_flags |= pf_thinks;
 	else
-		_flags &= ~pf_think;
+		_flags &= ~pf_thinks;
 }
 
 /**
@@ -885,7 +884,7 @@
 {
 
 	for (; child; child = child->_next) {
-		if (!child->get_handle_mouse() || !child->is_visible())
+		if (!child->handles_mouse() || !child->is_visible())
 			continue;
 		if
 			(x < child->_x + static_cast<int32_t>(child->_w) && x >= child->_x
@@ -909,9 +908,6 @@
  */
 void Panel::do_mousein(bool const inside)
 {
-	if (!_g_allow_user_input)
-		return;
-
 	if (!inside && _mousein) {
 		_mousein->do_mousein(false);
 		_mousein = nullptr;
@@ -925,9 +921,6 @@
  * Returns whether the event was processed.
  */
 bool Panel::do_mousepress(const uint8_t btn, int32_t x, int32_t y) {
-	if (!_g_allow_user_input) {
-		return true;
-	}
 	if (get_can_focus()) {
 		focus();
 	}
@@ -950,10 +943,6 @@
 
 
 bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y) {
-	if (!_g_allow_user_input) {
-		return true;
-	}
-
 	// TODO(GunChleoc): This is just a hack for focussed panels
 	// We need to find the actualy scrollable panel beneaththe mouse cursor,
 	// so we can have multiple scrollable elements on the same screen
@@ -968,9 +957,6 @@
 
 
 bool Panel::do_mouserelease(const uint8_t btn, int32_t x, int32_t y) {
-	if (!_g_allow_user_input)
-		return true;
-
 	x -= _lborder;
 	y -= _tborder;
 	if (_g_mousegrab != this)
@@ -987,9 +973,6 @@
 	(uint8_t const state,
 	 int32_t x, int32_t y, int32_t const xdiff, int32_t const ydiff)
 {
-	if (!_g_allow_user_input)
-		return true;
-
 	x -= _lborder;
 	y -= _tborder;
 	if (_g_mousegrab != this) {
@@ -1015,31 +998,30 @@
  */
 bool Panel::do_key(bool const down, SDL_Keysym const code)
 {
-	if (!_g_allow_user_input)
-		return true;
-
-	if (_focus) {
-		if (_focus->do_key(down, code))
-			return true;
-	}
-
-	return handle_key(down, code);
+	if (_focus && _focus->do_key(down, code)) {
+		return true;
+	}
+
+	// If we handle text, it does not matter if we handled this key
+	// or not, it should not propagate.
+	if (handle_key(down, code) || handles_textinput()) {
+		return true;
+	}
+	return false;
 }
 
-
-bool Panel::do_textinput(const char * text) {
-	if (!_g_allow_user_input) {
+bool Panel::do_textinput(const std::string& text) {
+	if (_focus && _focus->do_textinput(text)) {
 		return true;
 	}
-	if (_focus) {
-		if (_focus->do_textinput(text)) {
-			return true;
-		}
+
+	if (!handles_textinput()) {
+		return false;
 	}
+
 	return handle_textinput(text);
 }
 
-
 bool Panel::do_tooltip()
 {
 	if (_mousein && _mousein->do_tooltip()) {
@@ -1056,7 +1038,6 @@
 	return WLApplication::get()->get_key_state(key);
 }
 
-
 /**
  * Determine which panel is to receive a mouse event.
  *
@@ -1180,7 +1161,7 @@
 /**
  * Input callback function. Pass the textinput event to the currently modal panel
  */
-void Panel::ui_textinput(const char * text) {
+void Panel::ui_textinput(const std::string& text) {
 	if (!_g_allow_user_input) {
 		return;
 	}

=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h	2014-11-22 11:51:38 +0000
+++ src/ui_basic/panel.h	2014-11-22 12:01:09 +0000
@@ -56,10 +56,11 @@
  * its desired size changes, this automatically changes the actual size (which then invokes
  * \ref layout and \ref move_inside_parent).
  */
-struct Panel : boost::signals2::trackable {
+class Panel : public boost::signals2::trackable {
+public:
 	enum {
 		pf_handle_mouse = 1, ///< receive mouse events
-		pf_think = 2, ///< call think() function during run
+		pf_thinks = 2, ///< call think() function during run
 		pf_top_on_click = 4, ///< bring panel on top when clicked inside it
 		pf_die = 8, ///< this panel needs to die
 		pf_child_die = 16, ///< a child needs to die
@@ -72,8 +73,8 @@
 		/// whether any change in the desired size should propagate to the actual size
 		pf_layout_toplevel = 512,
 		/// whether widget wants to receive unicode textinput messages
-		pf_textinput = 2048,
-	}; // TODO(unknown): Turn this into separate bool flags
+		pf_handle_textinput = 2048,
+	};
 
 	Panel
 		(Panel * const nparent,
@@ -186,7 +187,12 @@
 		(uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
 	virtual bool handle_mousewheel(uint32_t which, int32_t x, int32_t y);
 	virtual bool handle_key(bool down, SDL_Keysym);
+<<<<<<< TREE
 	virtual bool handle_textinput(const char* text);
+=======
+	virtual bool handle_textinput(const std::string& text);
+	virtual bool handle_alt_drag(int32_t x, int32_t y);
+>>>>>>> MERGE-SOURCE
 	virtual bool handle_tooltip();
 
 	/// \returns whether a certain given is currently down.
@@ -202,7 +208,6 @@
 	bool get_key_state(SDL_Scancode) const;
 
 	void set_handle_mouse(bool yes);
-	bool get_handle_mouse() const {return _flags & pf_handle_mouse;}
 	void grab_mouse(bool grab);
 
 	void set_can_focus(bool yes);
@@ -213,9 +218,6 @@
 	}
 	virtual void focus(bool topcaller = true);
 
-	void set_think(bool yes);
-	bool get_think() const {return _flags & pf_think;}
-
 	void set_top_on_click(bool const on) {
 		if (on)
 			_flags |= pf_top_on_click;
@@ -230,15 +232,20 @@
 	void set_tooltip(const std::string& text) {_tooltip = text;}
 	const std::string& tooltip() const {return _tooltip;}
 
-	void set_handle_textinput(bool on) {
-		on ? _flags |= pf_textinput : _flags &= ~pf_textinput;
-	}
-	bool get_handle_textinput() const {return _flags & pf_textinput;}
-
 	///\return the current set UI font
 	std::string ui_fn();
 
 protected:
+	// This panel will never receive keypresses (do_key), instead
+	// textinput will be passed on (do_textinput).
+	void set_handle_textinput() {
+		_flags |= pf_handle_textinput;
+	}
+
+	// Defines if think() should be called repeatedly. This is true on construction.
+	void set_thinks(bool yes);
+
+
 	virtual void die();
 	bool keyboard_free() {return !(_focus);}
 
@@ -251,6 +258,16 @@
 	static bool draw_tooltip(RenderTarget &, const std::string & text);
 
 private:
+	bool handles_mouse() const {
+		return (_flags & pf_handle_mouse) != 0;
+	}
+	bool handles_textinput() const {
+		return (_flags & pf_handle_textinput) != 0;
+	}
+	bool thinks() const {
+		return (_flags & pf_thinks) != 0;
+	}
+
 	void check_child_death();
 
 	void do_draw(RenderTarget &);
@@ -266,7 +283,7 @@
 		(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
 	bool do_mousewheel(uint32_t which, int32_t x, int32_t y);
 	bool do_key(bool down, SDL_Keysym code);
-	bool do_textinput(const char* text);
+	bool do_textinput(const std::string& text);
 	bool do_tooltip();
 
 	static Panel * ui_trackmouse(int32_t & x, int32_t & y);
@@ -276,7 +293,7 @@
 		(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
 	static void ui_mousewheel(uint32_t which, int32_t x, int32_t y);
 	static void ui_key(bool down, SDL_Keysym code);
-	static void ui_textinput(const char* text);
+	static void ui_textinput(const std::string& text);
 
 	Panel * _parent;
 	Panel * _next, * _prev;

=== modified file 'src/ui_basic/radiobutton.h'
--- src/ui_basic/radiobutton.h	2014-07-05 16:41:51 +0000
+++ src/ui_basic/radiobutton.h	2014-11-22 12:01:09 +0000
@@ -27,7 +27,7 @@
 
 namespace UI {
 
-struct Panel;
+class Panel;
 
 struct Radiogroup;
 

=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc	2014-10-27 08:37:54 +0000
+++ src/ui_basic/scrollbar.cc	2014-11-22 12:01:09 +0000
@@ -63,7 +63,7 @@
 		(g_gr->images().get("pics/scrollbar_background.png")),
 	m_pic_buttons   (g_gr->images().get("pics/but3.png"))
 {
-	set_think(true);
+	set_thinks(true);
 }
 
 

=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc	2014-07-25 22:17:48 +0000
+++ src/ui_basic/slider.cc	2014-11-22 12:01:09 +0000
@@ -70,7 +70,7 @@
 	m_bar_size       (bar_size),
 	m_cursor_size (cursor_size)
 {
-	set_think(false);
+	set_thinks(false);
 	calc_cursor_pos();
 }
 

=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc	2014-10-28 12:53:29 +0000
+++ src/ui_basic/table.cc	2014-11-22 12:01:09 +0000
@@ -62,7 +62,7 @@
 	m_sort_column     (0),
 	m_sort_descending (descending)
 {
-	set_think(false);
+	set_thinks(false);
 	set_can_focus(true);
 }
 
@@ -328,13 +328,13 @@
 {
 	if (down) {
 		switch (code.sym) {
-		case SDL_SCANCODE_UP:
-		case SDL_SCANCODE_KP_8:
+		case SDLK_UP:
+		case SDLK_KP_8:
 			move_selection(-1);
 			return true;
 
-		case SDL_SCANCODE_DOWN:
-		case SDL_SCANCODE_KP_2:
+		case SDLK_DOWN:
+		case SDLK_KP_2:
 			move_selection(1);
 			return true;
 

=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc	2013-07-26 20:19:36 +0000
+++ src/ui_basic/textarea.cc	2014-11-22 12:01:09 +0000
@@ -80,7 +80,7 @@
 void Textarea::init()
 {
 	set_handle_mouse(false);
-	set_think(false);
+	set_thinks(false);
 	set_textstyle(TextStyle::ui_small());
 }
 

=== modified file 'src/ui_basic/unique_window.h'
--- src/ui_basic/unique_window.h	2014-07-13 21:38:10 +0000
+++ src/ui_basic/unique_window.h	2014-11-22 12:01:09 +0000
@@ -26,7 +26,7 @@
 #include "ui_basic/window.h"
 
 namespace UI {
-struct Panel;
+class Panel;
 
 
 /**

=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
--- src/ui_fsmenu/load_map_or_game.cc	2014-10-28 12:53:29 +0000
+++ src/ui_fsmenu/load_map_or_game.cc	2014-11-22 12:01:09 +0000
@@ -74,7 +74,7 @@
 
 	switch (code.sym)
 	{
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			clicked_ok();
 			return true;

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2014-11-11 11:28:05 +0000
+++ src/ui_fsmenu/loadgame.cc	2014-11-22 12:01:09 +0000
@@ -593,7 +593,7 @@
 
 	switch (code.sym)
 	{
-		case SDL_SCANCODE_KP_PERIOD:
+		case SDLK_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */

=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc	2014-11-12 21:01:23 +0000
+++ src/ui_fsmenu/options.cc	2014-11-22 12:01:09 +0000
@@ -408,7 +408,7 @@
 {
 	if (down) {
 		switch (code.sym) {
-			case SDL_SCANCODE_KP_ENTER:
+			case SDLK_KP_ENTER:
 			case SDLK_RETURN:
 				end_modal(static_cast<int32_t>(om_ok));
 				return true;
@@ -648,7 +648,7 @@
 {
 	if (down) {
 		switch (code.sym) {
-			case SDL_SCANCODE_KP_ENTER:
+			case SDLK_KP_ENTER:
 			case SDLK_RETURN:
 				end_modal(static_cast<int32_t>(om_ok));
 				return true;

=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc	2014-11-12 21:01:23 +0000
+++ src/wlapplication.cc	2014-11-22 12:01:09 +0000
@@ -500,14 +500,14 @@
 		switch (ev.type) {
 		case SDL_KEYDOWN:
 		case SDL_KEYUP:
-			if (ev.key.keysym.scancode == SDL_SCANCODE_F10 &&
+			if (ev.key.keysym.sym == SDLK_F10 &&
 			    (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL))) {
 				//  get out of here quick
 				if (ev.type == SDL_KEYDOWN)
 					m_should_die = true;
 				break;
 			}
-			if (ev.key.keysym.scancode == SDL_SCANCODE_F11) { //  take screenshot
+			if (ev.key.keysym.sym == SDLK_F11) { //  take screenshot
 				if (ev.type == SDL_KEYDOWN)
 				{
 					if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {

=== modified file 'src/wlapplication.h'
--- src/wlapplication.h	2014-11-12 21:01:23 +0000
+++ src/wlapplication.h	2014-11-22 12:01:09 +0000
@@ -59,7 +59,7 @@
 	void (*mouse_move)
 	(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
 	void (*key)        (bool down, SDL_Keysym code);
-	void (*textinput) (const char * text);
+	void (*textinput) (const std::string& text);
 	void (*mouse_wheel) (uint32_t which, int32_t x, int32_t y);
 };
 

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2014-11-02 20:31:40 +0000
+++ src/wui/buildingwindow.cc	2014-11-22 12:01:09 +0000
@@ -81,7 +81,7 @@
 	// so that overriding create_capsbuttons() works
 
 	set_center_panel(vbox);
-	set_think(true);
+	set_thinks(true);
 	set_fastclick_panel(this);
 
 	show_workarea();

=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc	2014-09-20 09:37:47 +0000
+++ src/wui/chatoverlay.cc	2014-11-22 12:01:09 +0000
@@ -77,7 +77,7 @@
 	Section & s = g_options.pull_section("global");
 	m->transparent_ = s.get_bool("transparent_chat", true);
 
-	set_think(true);
+	set_thinks(true);
 }
 
 ChatOverlay::~ChatOverlay()

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2014-10-28 14:57:52 +0000
+++ src/wui/game_message_menu.cc	2014-11-22 12:01:09 +0000
@@ -253,7 +253,7 @@
 				center_view();
 			return true;
 
-		case SDL_SCANCODE_KP_PERIOD:
+		case SDLK_KP_PERIOD:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */

=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2014-11-13 08:25:45 +0000
+++ src/wui/interactive_base.cc	2014-11-22 12:01:09 +0000
@@ -261,7 +261,6 @@
 		case 3: wa_index = 0; break;
 		default:
 			throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs);
-			break;
 	}
 	Widelands::Map & map = m_egbase.map();
 	OverlayManager & overlay_manager = map.overlay_manager();

=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc	2014-10-28 12:53:29 +0000
+++ src/wui/interactive_player.cc	2014-11-22 12:01:09 +0000
@@ -405,7 +405,7 @@
 			g_gr->toggle_fullscreen();
 			return true;
 
-		case SDL_SCANCODE_KP_7:
+		case SDLK_KP_7:
 			if (code.mod & KMOD_NUM)
 				break;
 			/* no break */
@@ -413,7 +413,7 @@
 			move_view_to(game().map().get_starting_pos(m_player_number));
 			return true;
 
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			if (!m_chatProvider | !m_chatenabled || !is_multiplayer())
 				break;

=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc	2014-10-14 07:55:05 +0000
+++ src/wui/interactive_spectator.cc	2014-11-22 12:01:09 +0000
@@ -268,7 +268,7 @@
 			return true;
 
 		case SDLK_RETURN:
-		case SDL_SCANCODE_KP_ENTER:
+		case SDLK_KP_ENTER:
 			if (!m_chatProvider | !m_chatenabled)
 				break;
 

=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc	2014-10-14 06:30:20 +0000
+++ src/wui/shipwindow.cc	2014-11-22 12:01:09 +0000
@@ -195,7 +195,7 @@
 		buttons->add(m_btn_cancel_expedition, 0, false);
 	}
 	set_center_panel(vbox);
-	set_think(true);
+	set_thinks(true);
 
 	center_to_parent();
 	move_out_of_the_way();

=== modified file 'src/wui/soldiercapacitycontrol.cc'
--- src/wui/soldiercapacitycontrol.cc	2014-09-19 12:54:54 +0000
+++ src/wui/soldiercapacitycontrol.cc	2014-11-22 12:01:09 +0000
@@ -81,7 +81,7 @@
 	m_decrease.set_repeating(true);
 	m_increase.set_repeating(true);
 
-	set_think(true);
+	set_thinks(true);
 }
 
 void SoldierCapacityControl::think()

=== modified file 'src/wui/soldiercapacitycontrol.h'
--- src/wui/soldiercapacitycontrol.h	2014-09-10 08:55:04 +0000
+++ src/wui/soldiercapacitycontrol.h	2014-11-22 12:01:09 +0000
@@ -23,7 +23,7 @@
 class InteractiveGameBase;
 
 namespace UI {
-struct Panel;
+class Panel;
 }
 
 namespace Widelands {

=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc	2014-09-19 12:54:54 +0000
+++ src/wui/soldierlist.cc	2014-11-22 12:01:09 +0000
@@ -129,7 +129,7 @@
 
 	set_size(m_cols * m_icon_width, m_rows * m_icon_height);
 	set_desired_size(m_cols * m_icon_width, m_rows * m_icon_height);
-	set_think(true);
+	set_thinks(true);
 
 	// Initialize the icons
 	uint32_t row = 0;

=== modified file 'src/wui/soldierlist.h'
--- src/wui/soldierlist.h	2014-09-10 08:55:04 +0000
+++ src/wui/soldierlist.h	2014-11-22 12:01:09 +0000
@@ -23,7 +23,7 @@
 class InteractiveGameBase;
 
 namespace UI {
-struct Panel;
+class Panel;
 }
 
 namespace Widelands {

=== modified file 'src/wui/waresqueuedisplay.cc'
--- src/wui/waresqueuedisplay.cc	2014-09-10 08:55:04 +0000
+++ src/wui/waresqueuedisplay.cc	2014-11-22 12:01:09 +0000
@@ -74,7 +74,7 @@
 
 	max_size_changed();
 
-	set_think(true);
+	set_thinks(true);
 }
 
 WaresQueueDisplay::~WaresQueueDisplay()

=== modified file 'src/wui/waresqueuedisplay.h'
--- src/wui/waresqueuedisplay.h	2014-09-10 10:18:46 +0000
+++ src/wui/waresqueuedisplay.h	2014-11-22 12:01:09 +0000
@@ -33,7 +33,7 @@
 class InteractiveGameBase;
 
 namespace UI {
-struct Panel;
+class Panel;
 struct Radiogroup;
 }
 


Follow ups