Merge lp:~widelands-dev/widelands/bug-1526911-cursor-positioning into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7943
Proposed branch: lp:~widelands-dev/widelands/bug-1526911-cursor-positioning
Merge into: lp:widelands
Diff against target: 81 lines (+18/-10)
4 files modified
src/editor/ui_menus/editor_player_menu.cc (+0/-4)
src/map_io/map_player_names_and_tribes_packet.cc (+10/-1)
src/ui_basic/editbox.cc (+5/-2)
src/ui_basic/multilineeditbox.cc (+3/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1526911-cursor-positioning
Reviewer Review Type Date Requested Status
Miroslav Remák code Approve
kaputtnik (community) testing Approve
Review via email: mp+290954@code.launchpad.net

Commit message

Some cursor fixes for edit boxes:
- Fixed cursor y position for empty Editboxes.
- Moved test for empty player names from editor player tool to map saving.
- In a new MultilineEditbox, position cursor at end of text.

Description of the change

Cursor position for BiDi languages is still broken, but that's a separate issue.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 962. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/120833342.
Appveyor build 795. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1526911_cursor_positioning-795.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 967. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/120912395.
Appveyor build 800. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1526911_cursor_positioning-800.

Revision history for this message
kaputtnik (franku) wrote :

I think this is much better :-)

review: Approve (testing)
Revision history for this message
Miroslav Remák (miroslavr256) wrote :

Looks good code-wise.

review: Approve (code)
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
2--- src/editor/ui_menus/editor_player_menu.cc 2016-03-14 18:10:09 +0000
3+++ src/editor/ui_menus/editor_player_menu.cc 2016-04-05 14:43:40 +0000
4@@ -334,10 +334,6 @@
5 std::string text = plr_names_[m]->text();
6 EditorInteractive& menu = eia();
7 Widelands::Map & map = menu.egbase().map();
8- if (text == "") {
9- text = map.get_scenario_player_name(m + 1);
10- plr_names_[m]->set_text(text);
11- }
12 map.set_scenario_player_name(m + 1, text);
13 plr_names_[m]->set_text(map.get_scenario_player_name(m + 1));
14 menu.set_need_save(true);
15
16=== modified file 'src/map_io/map_player_names_and_tribes_packet.cc'
17--- src/map_io/map_player_names_and_tribes_packet.cc 2015-11-28 22:29:26 +0000
18+++ src/map_io/map_player_names_and_tribes_packet.cc 2016-04-05 14:43:40 +0000
19@@ -19,6 +19,7 @@
20
21 #include "map_io/map_player_names_and_tribes_packet.h"
22
23+#include <boost/algorithm/string/trim.hpp>
24 #include <boost/format.hpp>
25
26 #include "logic/editor_game_base.h"
27@@ -96,8 +97,16 @@
28 iterate_player_numbers(p, nr_players) {
29 const std::string section_key = (boost::format("player_%u")
30 % static_cast<unsigned int>(p)).str();
31+
32+ // Make sure that no player name is empty, and trim leading/trailing whitespaces.
33+ std::string player_name = map.get_scenario_player_name(p);
34+ boost::trim(player_name);
35+ if (player_name.empty()) {
36+ player_name = (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str();
37+ }
38+
39 Section & s = prof.create_section(section_key.c_str());
40- s.set_string("name", map.get_scenario_player_name (p));
41+ s.set_string("name", player_name);
42 s.set_string("tribe", map.get_scenario_player_tribe (p));
43 s.set_string("ai", map.get_scenario_player_ai (p));
44 s.set_bool ("closeable", map.get_scenario_player_closeable(p));
45
46=== modified file 'src/ui_basic/editbox.cc'
47--- src/ui_basic/editbox.cc 2016-04-01 09:29:17 +0000
48+++ src/ui_basic/editbox.cc 2016-04-05 14:43:40 +0000
49@@ -396,8 +396,11 @@
50
51 const Image* entry_text_im = UI::g_fh1->render(as_editorfont(m_->text, m_->fontsize));
52
53- int linewidth = entry_text_im->width();
54- int lineheight = entry_text_im->height();
55+ const int linewidth = entry_text_im->width();
56+ const int lineheight = m_->text.empty() ?
57+ UI::g_fh1->render(as_editorfont(UI::g_fh1->fontset()->representative_character(),
58+ m_->fontsize))->height() :
59+ entry_text_im->height();
60
61 Point point(kMargin, get_h() / 2);
62
63
64=== modified file 'src/ui_basic/multilineeditbox.cc'
65--- src/ui_basic/multilineeditbox.cc 2016-03-25 17:01:05 +0000
66+++ src/ui_basic/multilineeditbox.cc 2016-04-05 14:43:40 +0000
67@@ -138,11 +138,11 @@
68 return;
69
70 d_->text = text;
71- while (d_->text.size() > d_->maxbytes)
72+ while (d_->text.size() > d_->maxbytes) {
73 d_->erase_bytes(d_->prev_char(d_->text.size()), d_->text.size());
74+ }
75
76- if (d_->cursor_pos > d_->text.size())
77- d_->cursor_pos = d_->text.size();
78+ d_->set_cursor_pos(d_->text.size());
79
80 d_->update();
81 d_->scroll_cursor_into_view();

Subscribers

People subscribed via source and target branches

to status/vote changes: