Merge lp:~widelands-dev/widelands/fsmenu_fullscreen_2_about into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8176
Proposed branch: lp:~widelands-dev/widelands/fsmenu_fullscreen_2_about
Merge into: lp:widelands
Diff against target: 162 lines (+58/-41)
4 files modified
src/ui_basic/fileview_panel.cc (+24/-10)
src/ui_basic/fileview_panel.h (+4/-0)
src/ui_fsmenu/about.cc (+23/-26)
src/ui_fsmenu/about.h (+7/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fsmenu_fullscreen_2_about
Reviewer Review Type Date Requested Status
Tino Approve
Review via email: mp+309754@code.launchpad.net

Commit message

The About menu now relayouts itself when fullscreen mode is toggled.

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

Continuous integration builds have changed state:

Travis build 1554. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/172288018.
Appveyor build 1394. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_fsmenu_fullscreen_2_about-1394.

Revision history for this message
Tino (tino79) wrote :

@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/fileview_panel.cc'
2--- src/ui_basic/fileview_panel.cc 2016-08-04 15:49:05 +0000
3+++ src/ui_basic/fileview_panel.cc 2016-11-03 07:35:42 +0000
4@@ -36,6 +36,7 @@
5 const Image* background,
6 TabPanel::Type border_type)
7 : TabPanel(parent, x, y, w, h, background, border_type), padding_(5) {
8+ layout();
9 }
10
11 void FileViewPanel::add_tab(const std::string& lua_script) {
12@@ -53,21 +54,34 @@
13 std::unique_ptr<UI::Box>(new UI::Box(this, 0, 0, UI::Box::Vertical, 0, 0, padding_)));
14 size_t index = boxes_.size() - 1;
15
16- // If there is a border, we have less space
17- const int width =
18+ textviews_.push_back(std::unique_ptr<UI::MultilineTextarea>(
19+ new UI::MultilineTextarea(boxes_.at(index).get(), 0, 0, Scrollbar::kSize, 0, content)));
20+ add((boost::format("about_%lu") % index).str(), title, boxes_.at(index).get(), "");
21+
22+ assert(boxes_.size() == textviews_.size());
23+ assert(tabs().size() == textviews_.size());
24+ update_tab_size(index);
25+}
26+
27+void FileViewPanel::update_tab_size(size_t index) {
28+ boxes_.at(index)->set_size(get_inner_w(), get_inner_h());
29+ textviews_.at(index)->set_size(contents_width_, contents_height_);
30+}
31+
32+void FileViewPanel::layout() {
33+ assert(boxes_.size() == textviews_.size());
34+
35+ // If there is a border, we have less space for the contents
36+ contents_width_ =
37 border_type_ == TabPanel::Type::kNoBorder ? get_w() - padding_ : get_w() - 2 * padding_;
38
39- const int height = border_type_ == TabPanel::Type::kNoBorder ?
40+ contents_height_ = border_type_ == TabPanel::Type::kNoBorder ?
41 get_inner_h() - 2 * padding_ - UI::kTabPanelButtonHeight :
42 get_inner_h() - 3 * padding_ - UI::kTabPanelButtonHeight;
43
44- textviews_.push_back(std::unique_ptr<UI::MultilineTextarea>(
45- new UI::MultilineTextarea(boxes_.at(index).get(), 0, 0, width, height, content)));
46- add((boost::format("about_%lu") % index).str(), title, boxes_.at(index).get(), "");
47- boxes_.at(index)->set_size(get_inner_w(), get_inner_h());
48-
49- assert(boxes_.size() == textviews_.size());
50- assert(tabs().size() == textviews_.size());
51+ for (size_t i = 0; i < boxes_.size(); ++i) {
52+ update_tab_size(i);
53+ }
54 }
55
56 } // namespace UI
57
58=== modified file 'src/ui_basic/fileview_panel.h'
59--- src/ui_basic/fileview_panel.h 2016-08-04 15:49:05 +0000
60+++ src/ui_basic/fileview_panel.h 2016-11-03 07:35:42 +0000
61@@ -48,7 +48,11 @@
62 void add_tab(const std::string& lua_script);
63
64 private:
65+ void update_tab_size(size_t index);
66+ void layout() override;
67 const uint32_t padding_;
68+ int contents_width_;
69+ int contents_height_;
70
71 // Tab contents
72 std::vector<std::unique_ptr<Box>> boxes_;
73
74=== modified file 'src/ui_fsmenu/about.cc'
75--- src/ui_fsmenu/about.cc 2016-10-24 14:04:00 +0000
76+++ src/ui_fsmenu/about.cc 2016-11-03 07:35:42 +0000
77@@ -26,39 +26,36 @@
78
79 FullscreenMenuAbout::FullscreenMenuAbout()
80 : FullscreenMenuBase(),
81-
82- // Values for alignment and size
83- butw_(get_w() / 5),
84- buth_(get_h() * 9 / 200),
85- hmargin_(get_w() * 19 / 200),
86- tab_panel_width_(get_inner_w() - 2 * hmargin_),
87- tab_panel_y_(get_h() * 14 / 100),
88-
89- title_(this, get_w() / 2, buth_, _("About Widelands"), UI::Align::kCenter),
90-
91- close_(this,
92- "close",
93- get_w() * 2 / 4 - butw_ / 2,
94- get_inner_h() - hmargin_,
95- butw_,
96- buth_,
97- g_gr->images().get("images/ui_basic/but2.png"),
98- _("Close")),
99-
100+ title_(this, 0, 0, _("About Widelands"), UI::Align::kCenter),
101+ close_(this, "close", 0, 0, 0, 0, g_gr->images().get("images/ui_basic/but2.png"), _("Close")),
102 tabs_(this,
103- hmargin_,
104- 0,
105- tab_panel_width_,
106- get_inner_h() - tab_panel_y_ - buth_ - hmargin_,
107+ 0,
108+ 0,
109+ 0,
110+ 0,
111 g_gr->images().get("images/ui_basic/but1.png"),
112 UI::TabPanel::Type::kBorder) {
113 title_.set_fontsize(UI_FONT_SIZE_BIG);
114- tabs_.set_pos(Vector2i(hmargin_, tab_panel_y_));
115-
116 tabs_.add_tab("txts/README.lua");
117 tabs_.add_tab("txts/LICENSE.lua");
118 tabs_.add_tab("txts/AUTHORS.lua");
119 tabs_.add_tab("txts/TRANSLATORS.lua");
120-
121 close_.sigclicked.connect(boost::bind(&FullscreenMenuAbout::clicked_back, this));
122+ layout();
123+}
124+
125+void FullscreenMenuAbout::layout() {
126+ // Values for alignment and size
127+ butw_ = get_w() / 5;
128+ buth_ = get_h() * 9 / 200;
129+ hmargin_ = get_w() * 19 / 200;
130+ tab_panel_width_ = get_inner_w() - 2 * hmargin_;
131+ tab_panel_y_ = get_h() * 14 / 100;
132+
133+ title_.set_size(get_w(), title_.get_h());
134+ title_.set_pos(Vector2i(0, buth_));
135+ close_.set_size(butw_, buth_);
136+ close_.set_pos(Vector2i(get_w() * 2 / 4 - butw_ / 2, get_inner_h() - hmargin_));
137+ tabs_.set_pos(Vector2i(hmargin_, tab_panel_y_));
138+ tabs_.set_size(tab_panel_width_, get_inner_h() - tab_panel_y_ - buth_ - hmargin_);
139 }
140
141=== modified file 'src/ui_fsmenu/about.h'
142--- src/ui_fsmenu/about.h 2016-08-04 15:49:05 +0000
143+++ src/ui_fsmenu/about.h 2016-11-03 07:35:42 +0000
144@@ -33,11 +33,13 @@
145 FullscreenMenuAbout();
146
147 private:
148- uint32_t const butw_;
149- uint32_t const buth_;
150- uint32_t const hmargin_;
151- uint32_t const tab_panel_width_;
152- uint32_t const tab_panel_y_;
153+ void layout() override;
154+
155+ uint32_t butw_;
156+ uint32_t buth_;
157+ uint32_t hmargin_;
158+ uint32_t tab_panel_width_;
159+ uint32_t tab_panel_y_;
160
161 UI::Textarea title_;
162 UI::Button close_;

Subscribers

People subscribed via source and target branches

to status/vote changes: