Merge lp:~widelands-dev/widelands/bug-1532279 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7773
Proposed branch: lp:~widelands-dev/widelands/bug-1532279
Merge into: lp:widelands
Diff against target: 199 lines (+30/-37)
7 files modified
src/ui_basic/multilinetextarea.cc (+13/-16)
src/ui_basic/multilinetextarea.h (+7/-6)
src/ui_basic/spinbox.cc (+5/-9)
src/wui/game_debug_ui.cc (+1/-2)
src/wui/game_message_menu.cc (+1/-1)
src/wui/game_objectives_menu.cc (+1/-1)
src/wui/gamechatpanel.cc (+2/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1532279
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+284728@code.launchpad.net

Commit message

ScrollMode in MultilineTextarea is now an enum class, and it is now set through the constructor only. Added new enum member "kNoScrolling", which will expand the MultilineTextarea rather than creating a scrollbar. Using this mode in Spinboxes now to prevent the creation of a Scrollbar there.

Description of the change

See commit message. This should fix the scrollbar button problem in the Spinboxes for good. A good test case is the Options menu in Arabic.

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

Continuous integration builds have changed state:

Travis build 366. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/104407166.
Appveyor build 273. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1532279-273.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 533. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/106464175.
Appveyor build 408. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1532279-408.

Revision history for this message
SirVer (sirver) wrote :

Code lgtm. Functionality tested in the options with arabic and works fine.

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/multilinetextarea.cc'
2--- src/ui_basic/multilinetextarea.cc 2016-01-31 14:49:09 +0000
3+++ src/ui_basic/multilinetextarea.cc 2016-02-02 12:58:58 +0000
4@@ -36,14 +36,14 @@
5 const int32_t x, const int32_t y, const uint32_t w, const uint32_t h,
6 const std::string& text,
7 const Align align,
8- const bool always_show_scrollbar)
9+ MultilineTextarea::ScrollMode scroll_mode)
10 :
11 Panel (parent, x, y, w, h),
12 m_text (text),
13 m_style(UI::TextStyle::ui_small()),
14 isrichtext(false),
15 m_scrollbar (this, get_w() - scrollbar_w(), 0, scrollbar_w(), h, false),
16- m_scrollmode(ScrollNormal)
17+ m_scrollmode(scroll_mode)
18 {
19 assert(scrollbar_w() <= w);
20 set_thinks(false);
21@@ -56,7 +56,8 @@
22 m_scrollbar.set_singlestepsize(UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_SMALL))->height());
23 m_scrollbar.set_pagesize(h - 2 * UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_BIG))->height());
24 m_scrollbar.set_steps(1);
25- m_scrollbar.set_force_draw(always_show_scrollbar);
26+ m_scrollbar.set_force_draw(m_scrollmode == ScrollMode::kScrollNormalForced ||
27+ m_scrollmode == ScrollMode::kScrollLogForced);
28
29 recompute();
30 }
31@@ -81,7 +82,7 @@
32 uint32_t height;
33
34 // We wrap the text twice. We need to do this to account for the presence/absence of the scollbar.
35- bool scroolbar_was_enabled = m_scrollbar.is_enabled();
36+ bool scrollbar_was_enabled = m_scrollbar.is_enabled();
37 for (int i = 0; i < 2; ++i) {
38 if (m_text.compare(0, 3, "<rt")) {
39 isrichtext = false;
40@@ -99,15 +100,21 @@
41
42 bool setbottom = false;
43
44- if (m_scrollmode == ScrollLog)
45+ if (m_scrollmode == ScrollMode::kScrollLog || m_scrollmode == ScrollMode::kScrollLogForced) {
46 if (m_scrollbar.get_scrollpos() >= m_scrollbar.get_steps() - 1)
47 setbottom = true;
48+ } else if (m_scrollmode == ScrollMode::kNoScrolling) {
49+ m_scrollbar.set_scrollpos(0);
50+ m_scrollbar.set_steps(1);
51+ set_desired_size(get_w(), height);
52+ set_size(get_w(), height);
53+ }
54
55 m_scrollbar.set_steps(height - get_h());
56 if (setbottom)
57 m_scrollbar.set_scrollpos(height - get_h());
58
59- if (m_scrollbar.is_enabled() == scroolbar_was_enabled) {
60+ if (m_scrollbar.is_enabled() == scrollbar_was_enabled) {
61 break; // No need to wrap twice.
62 }
63 }
64@@ -120,16 +127,6 @@
65 {
66 }
67
68-/**
69- * Change the scroll mode. This will not change the current scroll position;
70- * it only affects the behaviour of set_text().
71- */
72-void MultilineTextarea::set_scrollmode(ScrollMode mode)
73-{
74- m_scrollmode = mode;
75-}
76-
77-
78 /// Take care about scrollbar on resize
79 void MultilineTextarea::layout()
80 {
81
82=== modified file 'src/ui_basic/multilinetextarea.h'
83--- src/ui_basic/multilinetextarea.h 2016-01-29 08:50:22 +0000
84+++ src/ui_basic/multilinetextarea.h 2016-02-02 12:58:58 +0000
85@@ -37,9 +37,12 @@
86 * The textarea transparently handles explicit line-breaks and word wrapping.
87 */
88 struct MultilineTextarea : public Panel {
89- enum ScrollMode {
90- ScrollNormal = 0, ///< (default) only explicit or forced scrolling
91- ScrollLog = 1, ///< follow the bottom of the text
92+ enum class ScrollMode {
93+ kNoScrolling, // Expand the height instead of showing a scroll bar
94+ kScrollNormal, // (default) only explicit scrolling
95+ kScrollNormalForced, // forced scrolling
96+ kScrollLog, // follow the bottom of the text
97+ kScrollLogForced // follow the bottom of the text, and forced
98 };
99
100 MultilineTextarea
101@@ -47,13 +50,11 @@
102 const int32_t x, const int32_t y, const uint32_t w, const uint32_t h,
103 const std::string& text = std::string(),
104 const Align = UI::Align::kLeft,
105- const bool always_show_scrollbar = false);
106+ MultilineTextarea::ScrollMode scroll_mode = MultilineTextarea::ScrollMode::kScrollNormal);
107
108 const std::string& get_text() const {return m_text;}
109- ScrollMode get_scrollmode() const {return m_scrollmode;}
110
111 void set_text(const std::string&);
112- void set_scrollmode(ScrollMode mode);
113
114 uint32_t scrollbar_w() const {return 24;}
115 uint32_t get_eff_w() const {return m_scrollbar.is_enabled() ? get_w() - scrollbar_w() : get_w();}
116
117=== modified file 'src/ui_basic/spinbox.cc'
118--- src/ui_basic/spinbox.cc 2016-01-31 10:57:58 +0000
119+++ src/ui_basic/spinbox.cc 2016-02-02 12:58:58 +0000
120@@ -129,15 +129,11 @@
121
122 box_ = new UI::Box(this, 0, 0, UI::Box::Horizontal, actual_w, texth, padding);
123
124- // Find out how much height we need for the label. We give it 6 rows maximum.
125- const Image* rendered_text = UI::g_fh1->render(as_uifont(label_text));
126- uint32_t available_width = w - unit_w - no_padding * padding;
127- uint32_t extra_rows =
128- available_width > 0 ?
129- std::min(static_cast<int>(rendered_text->width() / available_width), 6) : 0;
130-
131- UI::MultilineTextarea* label = new UI::MultilineTextarea(box_, 0, 0, available_width,
132- texth * (extra_rows + 1), label_text);
133+ UI::MultilineTextarea* label = new UI::MultilineTextarea(box_, 0, 0,
134+ w - unit_w - no_padding * padding, texth,
135+ label_text,
136+ UI::Align::kLeft,
137+ UI::MultilineTextarea::ScrollMode::kNoScrolling);
138 box_->add(label, UI::Align::kHCenter);
139
140 sbi_->text = new UI::Textarea(box_, "", UI::Align::kCenter);
141
142=== modified file 'src/wui/game_debug_ui.cc'
143--- src/wui/game_debug_ui.cc 2016-01-28 05:24:34 +0000
144+++ src/wui/game_debug_ui.cc 2016-02-02 12:58:58 +0000
145@@ -70,9 +70,8 @@
146 UI::Panel(&parent, 0, 0, 350, 200),
147 m_egbase (egbase),
148 m_object (&obj),
149-m_log (this, 0, 0, 350, 200, "")
150+m_log (this, 0, 0, 350, 200, "", UI::Align::kLeft, UI::MultilineTextarea::ScrollMode::kScrollLog)
151 {
152- m_log.set_scrollmode(UI::MultilineTextarea::ScrollLog);
153 obj.set_logsink(this);
154 }
155
156
157=== modified file 'src/wui/game_message_menu.cc'
158--- src/wui/game_message_menu.cc 2016-01-31 21:03:15 +0000
159+++ src/wui/game_message_menu.cc 2016-02-02 12:58:58 +0000
160@@ -58,7 +58,7 @@
161 kMessageBodyY,
162 kWindowWidth - 2 * kPadding,
163 get_inner_h() - kMessageBodyY - 2 * kPadding - kButtonSize,
164- "", UI::Align::kLeft, 1),
165+ "", UI::Align::kLeft, UI::MultilineTextarea::ScrollMode::kScrollNormalForced),
166 mode(Inbox)
167 {
168
169
170=== modified file 'src/wui/game_objectives_menu.cc'
171--- src/wui/game_objectives_menu.cc 2015-12-17 09:36:59 +0000
172+++ src/wui/game_objectives_menu.cc 2016-02-02 12:58:58 +0000
173@@ -55,7 +55,7 @@
174 get_inner_w() - 10, FULL_OBJECTIVE_TEXT,
175 "",
176 UI::Align::kLeft,
177- 1)
178+ UI::MultilineTextarea::ScrollMode::kScrollNormalForced)
179 {
180 list.selected.connect(boost::bind(&GameObjectivesMenu::selected, this, _1));
181 if (get_usedefaultpos())
182
183=== modified file 'src/wui/gamechatpanel.cc'
184--- src/wui/gamechatpanel.cc 2016-01-29 08:50:22 +0000
185+++ src/wui/gamechatpanel.cc 2016-02-02 12:58:58 +0000
186@@ -34,11 +34,11 @@
187 :
188 UI::Panel(parent, x, y, w, h),
189 chat_ (chat),
190- chatbox (this, 0, 0, w, h - 25, "", UI::Align::kLeft, 1),
191+ chatbox (this, 0, 0, w, h - 25, "", UI::Align::kLeft,
192+ UI::MultilineTextarea::ScrollMode::kScrollLogForced),
193 editbox (this, 0, h - 20, w),
194 chat_message_counter(std::numeric_limits<uint32_t>::max())
195 {
196- chatbox.set_scrollmode(UI::MultilineTextarea::ScrollLog);
197 editbox.ok.connect(boost::bind(&GameChatPanel::key_enter, this));
198 editbox.cancel.connect(boost::bind(&GameChatPanel::key_escape, this));
199 editbox.activate_history(true);

Subscribers

People subscribed via source and target branches

to status/vote changes: