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

Proposed by GunChleoc
Status: Merged
Merged at revision: 8356
Proposed branch: lp:~widelands-dev/widelands/rendertarget_ints
Merge into: lp:widelands
Diff against target: 2403 lines (+403/-393)
62 files modified
src/base/vector.h (+4/-1)
src/editor/editorinteractive.cc (+1/-1)
src/editor/ui_menus/main_menu_load_or_save_map.cc (+1/-1)
src/editor/ui_menus/main_menu_map_options.cc (+1/-1)
src/editor/ui_menus/main_menu_random_map.cc (+1/-1)
src/editor/ui_menus/tool_change_resources_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_place_critter_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_place_immovable_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_set_terrain_options_menu.cc (+1/-1)
src/game_io/game_interactive_player_packet.cc (+1/-1)
src/graphic/animation.cc (+1/-1)
src/graphic/font_handler.cc (+6/-7)
src/graphic/gl/fields_to_draw.h (+4/-4)
src/graphic/minimap_renderer.cc (+4/-4)
src/graphic/rendertarget.cc (+15/-24)
src/graphic/rendertarget.h (+9/-11)
src/graphic/richtext.cc (+4/-4)
src/graphic/text_layout.cc (+2/-2)
src/graphic/text_layout.h (+2/-2)
src/graphic/wordwrap.cc (+3/-3)
src/logic/map_objects/map_object.cc (+9/-9)
src/logic/map_objects/tribes/soldier.cc (+19/-22)
src/logic/map_objects/tribes/soldier.h (+1/-1)
src/profile/profile.h (+1/-1)
src/scripting/lua_ui.cc (+4/-4)
src/ui_basic/button.cc (+24/-24)
src/ui_basic/checkbox.cc (+7/-7)
src/ui_basic/editbox.cc (+10/-10)
src/ui_basic/fullscreen_window.cc (+3/-3)
src/ui_basic/icon.cc (+1/-1)
src/ui_basic/listselect.cc (+11/-11)
src/ui_basic/multilineeditbox.cc (+8/-8)
src/ui_basic/multilinetextarea.cc (+2/-2)
src/ui_basic/panel.cc (+6/-6)
src/ui_basic/progressbar.cc (+7/-6)
src/ui_basic/progresswindow.cc (+6/-3)
src/ui_basic/progresswindow.h (+2/-2)
src/ui_basic/scrollbar.cc (+38/-38)
src/ui_basic/scrollbar.h (+2/-2)
src/ui_basic/slider.cc (+28/-27)
src/ui_basic/table.cc (+8/-8)
src/ui_basic/tabpanel.cc (+19/-19)
src/ui_basic/textarea.cc (+3/-3)
src/ui_basic/window.cc (+20/-19)
src/ui_fsmenu/mapselect.cc (+2/-2)
src/ui_fsmenu/options.cc (+13/-13)
src/wlapplication.cc (+4/-4)
src/wui/chatoverlay.cc (+2/-2)
src/wui/field_overlay_manager.h (+2/-2)
src/wui/game_tips.cc (+3/-3)
src/wui/general_statistics_menu.cc (+14/-12)
src/wui/inputqueuedisplay.cc (+2/-2)
src/wui/interactive_base.cc (+6/-7)
src/wui/interactive_gamebase.cc (+4/-2)
src/wui/itemwaresdisplay.cc (+2/-2)
src/wui/mapview.cc (+10/-9)
src/wui/mapview.h (+10/-1)
src/wui/minimap.cc (+1/-1)
src/wui/plot_area.cc (+16/-13)
src/wui/soldierlist.cc (+5/-5)
src/wui/warehousewindow.cc (+1/-1)
src/wui/waresdisplay.cc (+4/-4)
To merge this branch: bzr merge lp:~widelands-dev/widelands/rendertarget_ints
Reviewer Review Type Date Requested Status
SirVer code Approve
Review via email: mp+322996@code.launchpad.net

Commit message

Use int values in RenderTarget and alignment functions where float precision is not needed.

- RenderTarget::draw_rect, RenderTarget::fill_rect, RenderTarget::brighten_rect, RenderTarget::blit, RenderTarget::blit_monochrome and RenderTarget::blitrect
- UI::correct_for_align and UI::center_vertically
- Consistently use UI::correct_for_align outside of RenderTarget.
- Replaced Vector2<T> default constructor with static function Vector2<T>::zero()

Description of the change

Use ints in RenderTarget everywhere except for scaled map elements and plot lines. This means no more hunting for fuzzy-looking GUI elements and text.

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

Continuous integration builds have changed state:

Travis build 2111. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/224722001.
Appveyor build 1946. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_rendertarget_ints-1946.

Revision history for this message
Notabilis (notabilis27) wrote :
Download full text (6.9 KiB)

The diff looks okay to me and a short test game hasn't shown any optical glitches. But... ;-)

Three minor remarks code-wise:
- Is there a reason that Bob::calc_drawpos() (and derived methods) are still returning floats? Since it returns the pixel position on the screen I guess it is always an integer anyway.
- UI::correct_for_align() and UI::center_vertically() are somehow related from what they are doing but are offering quite different interfaces. Since I found an older TODO concerning the Align-enum I guess this might be already scheduled to change at some time.
- correct_for_align(kCenter) is called but correct_for_align(kLeft) is omitted. This might be a problem with right-to-left languages (or strange corner cases I could not come up with right now). Could also already be scheduled for change.

Another problem is a crash I encountered in my test game. It happened randomly and I couldn't reproduce it, so it might be also in trunk. But since it is graphic/blitting related I post the backtrace here for now.

Cmd_EnemyFlagAction::execute player(1): flag->owner(2) number=1
Cmd_EnemyFlagAction::execute player(1): flag->owner(2) number=1
Cmd_EnemyFlagAction::execute player(1): flag->owner(2) number=1
Forcing flag at (45, 31)

Thread 1 "widelands" received signal SIGSEGV, Segmentation fault.
0x0000555555de1828 in std::equal_to<unsigned int>::operator() (this=0x555556ad91b8 <Gl::State::instance()::binder+56>, __x=@0x7fffffff9100: 27123, __y=<error reading variable>)
    at /usr/include/c++/6/bits/stl_function.h:356
356 { return __x == __y; }
(gdb) bt
#0 0x0000555555de1828 in std::equal_to<unsigned int>::operator() (this=0x555556ad91b8 <Gl::State::instance()::binder+56>, __x=@0x7fffffff9100: 27123, __y=<error reading variable>)
    at /usr/include/c++/6/bits/stl_function.h:356
#1 0x00005555563b0eab in std::__detail::_Equal_helper<unsigned int, std::pair<unsigned int const, unsigned int>, std::__detail::_Select1st, std::equal_to<unsigned int>, unsigned long, false>::_S_equals (__eq=..., __extract=..., __k=@0x7fffffff9100: 27123, __n=0x608f5b40) at /usr/include/c++/6/bits/hashtable_policy.h:1331
#2 0x00005555563b0b0a in std::__detail::_Hashtable_base<unsigned int, std::pair<unsigned int const, unsigned int>, std::__detail::_Select1st, std::equal_to<unsigned int>, std::hash<unsigned int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<false, false, true> >::_M_equals (
    this=0x555556ad91b8 <Gl::State::instance()::binder+56>, __k=@0x7fffffff9100: 27123, __c=27123, __n=0x608f5b40) at /usr/include/c++/6/bits/hashtable_policy.h:1702
#3 0x00005555563b0687 in std::_Hashtable<unsigned int, std::pair<unsigned int const, unsigned int>, std::allocator<std::pair<unsigned int const, unsigned int> >, std::__detail::_Select1st, std::equal_to<unsigned int>, std::hash<unsigned int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_find_before_node (this=0x555556ad91b8 <Gl::State::instance()::binder+56>, __n=27123, __k=@0x7fffffff9100: 27123, __code=27123)
    at /usr/include/...

Read more...

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review :)

The crash looks unfamiliar, I'll have to look into this.

> Is there a reason that Bob::calc_drawpos() (and derived methods) are still returning floats?

Yes, these are there for the zoom function, map elements can now end up not being positioned pixel perfect.

> UI::correct_for_align() and UI::center_vertically() are somehow related from what they are doing but are offering quite different interfaces.

Not really. center_vertically() is omitting the align parameter, because align is always centered here.

> correct_for_align(kCenter) is called but correct_for_align(kLeft) is omitted.

I'll go over these again when we do the final RTL GUI switching code.

Revision history for this message
SirVer (sirver) wrote :

Good change!

One suggestion to improve the code: how about we disallow Vector2i() (by making the default constructor deleted) and instead have a static function Vector2i::Zero() that returns Vector2i(0, 0). It would make the call sites slightly easier to read.

otherwise code lgtm. I did not test.

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

Since everything points to the crash already being in trunk, let's get this in.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/base/vector.h'
2--- src/base/vector.h 2017-01-25 18:55:59 +0000
3+++ src/base/vector.h 2017-05-13 13:15:21 +0000
4@@ -28,7 +28,10 @@
5 template <typename T> struct Vector2 {
6 Vector2(const T& px, const T& py) : x(px), y(py) {
7 }
8- Vector2() : Vector2(T(0), T(0)) {
9+ Vector2() = delete;
10+
11+ static Vector2 zero() {
12+ return Vector2(T(0), T(0));
13 }
14
15 // Returns an invalid point.
16
17=== modified file 'src/editor/editorinteractive.cc'
18--- src/editor/editorinteractive.cc 2017-01-25 18:55:59 +0000
19+++ src/editor/editorinteractive.cc 2017-05-13 13:15:21 +0000
20@@ -636,7 +636,7 @@
21 }
22
23 // Make sure that we will start at coordinates (0,0).
24- set_view(MapView::View{Vector2f(0, 0), 1.f}, Transition::Jump);
25+ set_view(MapView::View{Vector2f::zero(), 1.f}, Transition::Jump);
26 set_sel_pos(Widelands::NodeAndTriangle<>(
27 Widelands::Coords(0, 0),
28 Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TCoords<>::D)));
29
30=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc'
31--- src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-03-01 11:23:54 +0000
32+++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-05-13 13:15:21 +0000
33@@ -89,7 +89,7 @@
34
35 /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
36 cb_dont_localize_mapnames_ =
37- new UI::Checkbox(vbox, Vector2i(0, 0), _("Show original map names"));
38+ new UI::Checkbox(vbox, Vector2i::zero(), _("Show original map names"));
39 cb_dont_localize_mapnames_->set_state(false);
40 vbox->add_space(2 * padding_);
41 vbox->add(cb_dont_localize_mapnames_, UI::Box::Resizing::kFullSize);
42
43=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
44--- src/editor/ui_menus/main_menu_map_options.cc 2017-02-26 11:00:07 +0000
45+++ src/editor/ui_menus/main_menu_map_options.cc 2017-05-13 13:15:21 +0000
46@@ -230,7 +230,7 @@
47 std::string tag,
48 std::string displ_name) {
49 UI::Box* box = new UI::Box(parent, 0, 0, UI::Box::Horizontal, max_w_, checkbox_space_, 0);
50- UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);
51+ UI::Checkbox* cb = new UI::Checkbox(box, Vector2i::zero(), displ_name);
52 box->add(cb, UI::Box::Resizing::kFullSize);
53 box->add_space(checkbox_space_);
54 parent->add(box);
55
56=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
57--- src/editor/ui_menus/main_menu_random_map.cc 2017-02-26 11:00:07 +0000
58+++ src/editor/ui_menus/main_menu_random_map.cc 2017-05-13 13:15:21 +0000
59@@ -188,7 +188,7 @@
60 resources_label_.get_h(),
61 (boost::format(_("%i %%")) % mountainsval_).str(),
62 UI::Align::kCenter),
63- island_mode_(&box_, Vector2i(0, 0), _("Island mode")),
64+ island_mode_(&box_, Vector2i::zero(), _("Island mode")),
65 // Geeky stuff
66 map_number_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_),
67 map_number_label_(&map_number_box_, 0, 0, _("Random Number:")),
68
69=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
70--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-02-25 13:27:40 +0000
71+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-05-13 13:15:21 +0000
72@@ -100,7 +100,7 @@
73
74 for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) {
75 const Widelands::ResourceDescription& resource = *world.get_resource(i);
76- radiogroup_.add_button(&resources_box_, Vector2i(0, 0),
77+ radiogroup_.add_button(&resources_box_, Vector2i::zero(),
78 g_gr->images().get(resource.representative_image()),
79 resource.descname());
80 resources_box_.add(radiogroup_.get_first_button(), UI::Box::Resizing::kFillSpace);
81
82=== modified file 'src/editor/ui_menus/tool_place_critter_options_menu.cc'
83--- src/editor/ui_menus/tool_place_critter_options_menu.cc 2017-01-25 18:55:59 +0000
84+++ src/editor/ui_menus/tool_place_critter_options_menu.cc 2017-05-13 13:15:21 +0000
85@@ -38,7 +38,7 @@
86 UI::Checkbox* create_critter_checkbox(UI::Panel* parent,
87 const Widelands::CritterDescr& critter_descr) {
88 const Image* pic = critter_descr.representative_image();
89- UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), pic, critter_descr.descname());
90+ UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), pic, critter_descr.descname());
91 const int kMinClickableArea = 24;
92 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),
93 std::max<int>(pic->height(), kMinClickableArea));
94
95=== modified file 'src/editor/ui_menus/tool_place_immovable_options_menu.cc'
96--- src/editor/ui_menus/tool_place_immovable_options_menu.cc 2017-01-25 18:55:59 +0000
97+++ src/editor/ui_menus/tool_place_immovable_options_menu.cc 2017-05-13 13:15:21 +0000
98@@ -39,7 +39,7 @@
99
100 UI::Checkbox* create_immovable_checkbox(UI::Panel* parent, const ImmovableDescr& immovable_descr) {
101 const Image* pic = immovable_descr.representative_image();
102- UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), pic, immovable_descr.descname());
103+ UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), pic, immovable_descr.descname());
104 const int kMinClickableArea = 24;
105 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),
106 std::max<int>(pic->height(), kMinClickableArea));
107
108=== modified file 'src/editor/ui_menus/tool_set_terrain_options_menu.cc'
109--- src/editor/ui_menus/tool_set_terrain_options_menu.cc 2017-01-25 18:55:59 +0000
110+++ src/editor/ui_menus/tool_set_terrain_options_menu.cc 2017-05-13 13:15:21 +0000
111@@ -79,7 +79,7 @@
112 .str();
113
114 std::unique_ptr<const Image>& image = offscreen_images->back();
115- UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), image.get(), tooltip);
116+ UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), image.get(), tooltip);
117 cb->set_desired_size(image->width() + 1, image->height() + 1);
118 return cb;
119 }
120
121=== modified file 'src/game_io/game_interactive_player_packet.cc'
122--- src/game_io/game_interactive_player_packet.cc 2017-01-25 18:55:59 +0000
123+++ src/game_io/game_interactive_player_packet.cc 2017-05-13 13:15:21 +0000
124@@ -70,7 +70,7 @@
125 if (player_number > max)
126 throw GameDataError("The game has no players!");
127 }
128- Vector2f center_map_pixel;
129+ Vector2f center_map_pixel = Vector2f::zero();
130 if (packet_version <= 3) {
131 center_map_pixel.x = fr.unsigned_16();
132 center_map_pixel.y = fr.unsigned_16();
133
134=== modified file 'src/graphic/animation.cc'
135--- src/graphic/animation.cc 2017-05-03 07:24:06 +0000
136+++ src/graphic/animation.cc 2017-05-13 13:15:21 +0000
137@@ -91,7 +91,7 @@
138 uint32_t current_frame(uint32_t time) const;
139
140 uint32_t frametime_;
141- Vector2i hotspot_;
142+ Vector2i hotspot_ = Vector2i::zero();
143 bool hasplrclrs_;
144 std::vector<std::string> image_files_;
145 std::vector<std::string> pc_mask_image_files_;
146
147=== modified file 'src/graphic/font_handler.cc'
148--- src/graphic/font_handler.cc 2017-02-28 20:07:07 +0000
149+++ src/graphic/font_handler.cc 2017-05-13 13:15:21 +0000
150@@ -54,9 +54,9 @@
151 int caret_x = style.calc_bare_width(text.substr(0, caret_offset));
152
153 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
154- Vector2f caretpt;
155+ Vector2i caretpt = Vector2i::zero();
156 caretpt.x = dstpoint.x + caret_x + LINE_MARGIN - caret_image->width();
157- caretpt.y = dstpoint.y + (style.font->height() - caret_image->height()) / 2.f;
158+ caretpt.y = dstpoint.y + (style.font->height() - caret_image->height()) / 2;
159 dst.blit(caretpt, caret_image);
160 }
161
162@@ -203,7 +203,7 @@
163 */
164 void FontHandler::draw_text(RenderTarget& dst,
165 const TextStyle& style,
166- Vector2i dstpoint_i,
167+ Vector2i dstpoint,
168 const std::string& text,
169 Align align,
170 uint32_t caret) {
171@@ -213,14 +213,13 @@
172 copytext = i18n::make_ligatures(copytext.c_str());
173 const LineCacheEntry& lce = d->get_line(style, copytext);
174
175- Vector2f dstpoint = dstpoint_i.cast<float>();
176 UI::correct_for_align(align, lce.width + 2 * LINE_MARGIN, &dstpoint);
177
178 if (lce.image)
179- dst.blit(Vector2f(dstpoint.x + LINE_MARGIN, dstpoint.y), lce.image.get());
180+ dst.blit(Vector2i(dstpoint.x + LINE_MARGIN, dstpoint.y), lce.image.get());
181
182 if (caret <= copytext.size())
183- draw_caret(dst, style, dstpoint, copytext, caret);
184+ draw_caret(dst, style, dstpoint.cast<float>(), copytext, caret);
185 }
186
187 /**
188@@ -233,7 +232,7 @@
189 const LineCacheEntry& lce = d->get_line(style, text);
190
191 if (lce.image) {
192- dst.blit(dstpoint.cast<float>(), lce.image.get());
193+ dst.blit(dstpoint, lce.image.get());
194 }
195
196 return lce.width;
197
198=== modified file 'src/graphic/gl/fields_to_draw.h'
199--- src/graphic/gl/fields_to_draw.h 2017-01-25 18:55:59 +0000
200+++ src/graphic/gl/fields_to_draw.h 2017-05-13 13:15:21 +0000
201@@ -43,15 +43,15 @@
202 Widelands::Coords geometric_coords; // geometric coordinates (i.e. map coordinates that can
203 // be out of bounds).
204 Widelands::FCoords fcoords; // The normalized coords and the field this is refering to.
205- Vector2f gl_position; // GL Position of this field.
206+ Vector2f gl_position = Vector2f::zero(); // GL Position of this field.
207
208 // Surface pixel this will be plotted on.
209- Vector2f surface_pixel;
210+ Vector2f surface_pixel = Vector2f::zero();
211
212 // Rendertarget pixel this will be plotted on. This is only different by
213 // the Rendertarget::get_rect().origin() of the view window.
214- Vector2f rendertarget_pixel;
215- Vector2f texture_coords; // Texture coordinates.
216+ Vector2f rendertarget_pixel = Vector2f::zero();
217+ Vector2f texture_coords = Vector2f::zero(); // Texture coordinates.
218 float brightness; // brightness of the pixel
219
220 // The next values are not necessarily the true data of this field, but
221
222=== modified file 'src/graphic/minimap_renderer.cc'
223--- src/graphic/minimap_renderer.cc 2017-01-25 18:55:59 +0000
224+++ src/graphic/minimap_renderer.cc 2017-05-13 13:15:21 +0000
225@@ -97,7 +97,7 @@
226 const int half_height =
227 round_up_to_nearest_even(std::ceil(view_area.h / kTriangleHeight / divider));
228
229- Vector2i center_pixel;
230+ Vector2i center_pixel = Vector2i::zero();
231 switch (minimap_type) {
232 case MiniMapType::kStaticViewWindow:
233 center_pixel = Vector2i(texture->width() / 2, texture->height() / 2);
234@@ -203,7 +203,7 @@
235 const Rectf& view_area,
236 MiniMapType minimap_type,
237 const bool zoom) {
238- Vector2f top_left;
239+ Vector2f top_left = Vector2f::zero();
240 switch (minimap_type) {
241 case MiniMapType::kStaticViewWindow:
242 top_left =
243@@ -212,7 +212,7 @@
244 break;
245
246 case MiniMapType::kStaticMap:
247- top_left = Vector2f(0., 0.);
248+ top_left = Vector2f::zero();
249 break;
250 }
251
252@@ -242,7 +242,7 @@
253 // Center the view on the middle of the 'view_area'.
254 const bool zoom = layers & MiniMapLayer::Zoom2;
255 Vector2f top_left =
256- minimap_pixel_to_mappixel(map, Vector2i(0, 0), view_area, minimap_type, zoom);
257+ minimap_pixel_to_mappixel(map, Vector2i::zero(), view_area, minimap_type, zoom);
258 const Coords node =
259 MapviewPixelFunctions::calc_node_and_triangle(map, top_left.x, top_left.y).node;
260
261
262=== modified file 'src/graphic/rendertarget.cc'
263--- src/graphic/rendertarget.cc 2017-02-28 20:07:07 +0000
264+++ src/graphic/rendertarget.cc 2017-05-13 13:15:21 +0000
265@@ -23,7 +23,6 @@
266 #include "graphic/animation.h"
267 #include "graphic/graphic.h"
268 #include "graphic/surface.h"
269-#include "graphic/text_layout.h"
270
271 /**
272 * Build a render target for the given surface.
273@@ -119,21 +118,21 @@
274 /**
275 * Clip against window and pass those primitives along to the bitmap.
276 */
277-void RenderTarget::draw_rect(const Rectf& rect, const RGBColor& clr) {
278- Rectf r(rect);
279+void RenderTarget::draw_rect(const Recti& rect, const RGBColor& clr) {
280+ Rectf r(rect.cast<float>());
281 if (clip(r)) {
282 ::draw_rect(r, clr, surface_);
283 }
284 }
285
286-void RenderTarget::fill_rect(const Rectf& rect, const RGBAColor& clr, BlendMode blend_mode) {
287- Rectf r(rect);
288+void RenderTarget::fill_rect(const Recti& rect, const RGBAColor& clr, BlendMode blend_mode) {
289+ Rectf r(rect.cast<float>());
290 if (clip(r))
291 surface_->fill_rect(r, clr, blend_mode);
292 }
293
294-void RenderTarget::brighten_rect(const Rectf& rect, int32_t factor) {
295- Rectf r(rect);
296+void RenderTarget::brighten_rect(const Recti& rect, int32_t factor) {
297+ Rectf r(rect.cast<float>());
298 if (clip(r))
299 surface_->brighten_rect(r, factor);
300 }
301@@ -143,15 +142,11 @@
302 *
303 * This blit function copies the pixels to the destination surface.
304 */
305-void RenderTarget::blit(const Vector2f& dst,
306+void RenderTarget::blit(const Vector2i& dst,
307 const Image* image,
308- BlendMode blend_mode,
309- UI::Align align) {
310- Vector2f destination_point(dst);
311- UI::correct_for_align(align, image->width(), &destination_point);
312-
313- Rectf source_rect(Vector2i(0, 0), image->width(), image->height());
314- Rectf destination_rect(destination_point.x, destination_point.y, source_rect.w, source_rect.h);
315+ BlendMode blend_mode) {
316+ Rectf source_rect(Vector2i::zero(), image->width(), image->height());
317+ Rectf destination_rect(dst.x, dst.y, source_rect.w, source_rect.h);
318
319 if (to_surface_geometry(&destination_rect, &source_rect)) {
320 // I seem to remember seeing 1. a lot in blitting calls.
321@@ -160,15 +155,11 @@
322 }
323 }
324
325-void RenderTarget::blit_monochrome(const Vector2f& dst,
326+void RenderTarget::blit_monochrome(const Vector2i& dst,
327 const Image* image,
328- const RGBAColor& blend_mode,
329- UI::Align align) {
330- Vector2f destination_point(dst);
331- UI::correct_for_align(align, image->width(), &destination_point);
332-
333- Rectf source_rect(Vector2i(0, 0), image->width(), image->height());
334- Rectf destination_rect(destination_point.x, destination_point.y, source_rect.w, source_rect.h);
335+ const RGBAColor& blend_mode) {
336+ Rectf source_rect(Vector2i::zero(), image->width(), image->height());
337+ Rectf destination_rect(dst.x, dst.y, source_rect.w, source_rect.h);
338
339 if (to_surface_geometry(&destination_rect, &source_rect)) {
340 surface_->blit_monochrome(destination_rect, *image, source_rect, blend_mode);
341@@ -178,7 +169,7 @@
342 /**
343 * Like \ref blit, but use only a sub-rectangle of the source image.
344 */
345-void RenderTarget::blitrect(const Vector2f& dst,
346+void RenderTarget::blitrect(const Vector2i& dst,
347 const Image* image,
348 const Recti& gsrcrc,
349 BlendMode blend_mode) {
350
351=== modified file 'src/graphic/rendertarget.h'
352--- src/graphic/rendertarget.h 2017-02-23 19:38:51 +0000
353+++ src/graphic/rendertarget.h 2017-05-13 13:15:21 +0000
354@@ -58,22 +58,20 @@
355 int32_t height() const;
356
357 void draw_line_strip(const std::vector<Vector2f>& points, const RGBColor& color, float width);
358- void draw_rect(const Rectf&, const RGBColor&);
359- void fill_rect(const Rectf&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
360- void brighten_rect(const Rectf&, int32_t factor);
361+ void draw_rect(const Recti&, const RGBColor&);
362+ void fill_rect(const Recti&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
363+ void brighten_rect(const Recti&, int32_t factor);
364
365- void blit(const Vector2f& dst,
366+ void blit(const Vector2i& dst,
367 const Image* image,
368- BlendMode blend_mode = BlendMode::UseAlpha,
369- UI::Align = UI::Align::kLeft);
370+ BlendMode blend_mode = BlendMode::UseAlpha);
371
372 // Like blit. See MonochromeBlitProgram for details.
373- void blit_monochrome(const Vector2f& dst,
374+ void blit_monochrome(const Vector2i& dst,
375 const Image* image,
376- const RGBAColor& blend_mode,
377- UI::Align = UI::Align::kLeft);
378+ const RGBAColor& blend_mode);
379
380- void blitrect(const Vector2f& dst,
381+ void blitrect(const Vector2i& dst,
382 const Image* image,
383 const Recti& src,
384 BlendMode blend_mode = BlendMode::UseAlpha);
385@@ -147,7 +145,7 @@
386 /// The current clip rectangle
387 Recti rect_;
388 /// Drawing offset
389- Vector2i offset_;
390+ Vector2i offset_ = Vector2i::zero();
391 };
392
393 #endif // end of include guard: WL_GRAPHIC_RENDERTARGET_H
394
395=== modified file 'src/graphic/richtext.cc'
396--- src/graphic/richtext.cc 2017-02-23 19:38:51 +0000
397+++ src/graphic/richtext.cc 2017-05-13 13:15:21 +0000
398@@ -61,7 +61,7 @@
399 }
400
401 void draw(RenderTarget& dst) override {
402- dst.blit(Vector2f(0, 0), image);
403+ dst.blit(Vector2i::zero(), image);
404 }
405
406 const Image* image;
407@@ -107,7 +107,7 @@
408 }
409 }
410 // Now render
411- uint32_t x = g_fh->draw_text_raw(dst, style, Vector2i(0, 0), result_words[0]);
412+ uint32_t x = g_fh->draw_text_raw(dst, style, Vector2i::zero(), result_words[0]);
413
414 it = result_words.begin() + 1;
415 if (it != result_words.end()) {
416@@ -493,12 +493,12 @@
417 for (std::vector<Element*>::const_iterator elt = m->elements.begin(); elt != m->elements.end();
418 ++elt) {
419 Recti oldbox;
420- Vector2i oldofs;
421+ Vector2i oldofs = Vector2i::zero();
422 Recti bbox((*elt)->bbox.origin() + offset, (*elt)->bbox.w, (*elt)->bbox.h);
423
424 if (dst.enter_window(bbox, &oldbox, &oldofs)) {
425 if (background)
426- dst.fill_rect(Rectf(0.f, 0.f, bbox.w, bbox.h), m->background_color);
427+ dst.fill_rect(Recti(0, 0, bbox.w, bbox.h), m->background_color);
428 (*elt)->draw(dst);
429 dst.set_window(oldbox, oldofs);
430 }
431
432=== modified file 'src/graphic/text_layout.cc'
433--- src/graphic/text_layout.cc 2017-05-03 07:24:06 +0000
434+++ src/graphic/text_layout.cc 2017-05-13 13:15:21 +0000
435@@ -204,7 +204,7 @@
436 * subsampled rendering - this can lead to blurry texts. That is why we
437 * never do float divisions in this function.
438 */
439-void correct_for_align(Align align, uint32_t w, Vector2f* pt) {
440+void correct_for_align(Align align, uint32_t w, Vector2i* pt) {
441
442 if (align == Align::kCenter)
443 pt->x -= w / 2;
444@@ -215,7 +215,7 @@
445 /**
446 * Adjust the y coordinate in 'point 'pt' to vertically center an element with height 'h'.
447 */
448-void center_vertically(uint32_t h, Vector2f* pt) {
449+void center_vertically(uint32_t h, Vector2i* pt) {
450 pt->y -= h / 2;
451 }
452 } // namespace UI
453
454=== modified file 'src/graphic/text_layout.h'
455--- src/graphic/text_layout.h 2017-03-29 12:36:20 +0000
456+++ src/graphic/text_layout.h 2017-05-13 13:15:21 +0000
457@@ -104,8 +104,8 @@
458
459 Align mirror_alignment(Align alignment);
460
461-void center_vertically(uint32_t h, Vector2f* pt);
462-void correct_for_align(Align, uint32_t w, Vector2f* pt);
463+void center_vertically(uint32_t h, Vector2i* pt);
464+void correct_for_align(Align, uint32_t w, Vector2i* pt);
465
466 } // namespace UI
467
468
469=== modified file 'src/graphic/wordwrap.cc'
470--- src/graphic/wordwrap.cc 2017-04-30 07:44:27 +0000
471+++ src/graphic/wordwrap.cc 2017-05-13 13:15:21 +0000
472@@ -310,7 +310,7 @@
473 if (where.y >= dst.height() || int32_t(where.y + fontheight) <= 0)
474 continue;
475
476- Vector2f point(where.x, where.y);
477+ Vector2i point(where.x, where.y);
478
479 if (alignment == UI::Align::kRight) {
480 point.x += wrapwidth_ - kLineMargin;
481@@ -327,9 +327,9 @@
482 int caret_x = text_width(line_to_caret, fontsize_);
483
484 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
485- Vector2f caretpt;
486+ Vector2i caretpt = Vector2i::zero();
487 caretpt.x = point.x + caret_x - caret_image->width() + kLineMargin;
488- caretpt.y = point.y + (fontheight - caret_image->height()) / 2.f;
489+ caretpt.y = point.y + (fontheight - caret_image->height()) / 2;
490 dst.blit(caretpt, caret_image);
491 }
492 }
493
494=== modified file 'src/logic/map_objects/map_object.cc'
495--- src/logic/map_objects/map_object.cc 2017-04-30 08:27:40 +0000
496+++ src/logic/map_objects/map_object.cc 2017-05-13 13:15:21 +0000
497@@ -473,19 +473,19 @@
498 const Image* rendered_census_info =
499 UI::g_fh1->render(as_condensed(census, UI::Align::kCenter, font_size), 120);
500
501- // Rounding guarantees that text aligns with pixels to avoid subsampling.
502- const Vector2f census_pos = round(field_on_dst - Vector2f(0, 48) * scale).cast<float>();
503+ const Vector2i base_pos = field_on_dst.cast<int>() - Vector2i(0, 48) * scale;
504+ Vector2i census_pos(base_pos);
505+ UI::correct_for_align(UI::Align::kCenter, rendered_census_info->width(), &census_pos);
506 if (draw_text & TextToDraw::kCensus) {
507- dst->blit(census_pos, rendered_census_info, BlendMode::UseAlpha, UI::Align::kCenter);
508+ dst->blit(census_pos, rendered_census_info, BlendMode::UseAlpha);
509 }
510
511 if (draw_text & TextToDraw::kStatistics && !statictics.empty()) {
512- const Vector2f statistics_pos =
513- round(census_pos + Vector2f(0, rendered_census_info->height() / 2.f + 10 * scale))
514- .cast<float>();
515- dst->blit(statistics_pos,
516- UI::g_fh1->render(as_condensed(statictics, UI::Align::kCenter, font_size)),
517- BlendMode::UseAlpha, UI::Align::kCenter);
518+ Vector2i statistics_pos =
519+ base_pos + Vector2i(0, rendered_census_info->height() / 2 + 10 * scale);
520+ const Image* rendered_statictics = UI::g_fh1->render(as_condensed(statictics, UI::Align::kCenter, font_size));
521+ UI::correct_for_align(UI::Align::kCenter, rendered_statictics->width(), &statistics_pos);
522+ dst->blit(statistics_pos, rendered_statictics, BlendMode::UseAlpha);
523 }
524 }
525
526
527=== modified file 'src/logic/map_objects/tribes/soldier.cc'
528--- src/logic/map_objects/tribes/soldier.cc 2017-05-03 07:24:06 +0000
529+++ src/logic/map_objects/tribes/soldier.cc 2017-05-13 13:15:21 +0000
530@@ -451,8 +451,8 @@
531
532 const Vector2f point_on_dst = calc_drawpos(game, field_on_dst, scale);
533 draw_info_icon(
534- point_on_dst -
535- Vector2f(0.f, (g_gr->animations().get_animation(get_current_anim()).height() - 7) * scale),
536+ point_on_dst.cast<int>() -
537+ Vector2i(0, (g_gr->animations().get_animation(get_current_anim()).height() - 7) * scale),
538 scale, true, dst);
539 draw_inner(game, point_on_dst, scale, dst);
540 }
541@@ -460,7 +460,7 @@
542 /**
543 * Draw the info icon (level indicators + health bar) for this soldier.
544 */
545-void Soldier::draw_info_icon(Vector2f draw_position,
546+void Soldier::draw_info_icon(Vector2i draw_position,
547 float scale,
548 const bool anchor_below,
549 RenderTarget* dst) const {
550@@ -492,29 +492,26 @@
551 assert(kSoldierHealthBarWidth > dimension);
552 #endif
553
554- const float icon_size = healthpic->width();
555- const float half_width = kSoldierHealthBarWidth;
556+ const int icon_size = healthpic->width();
557
558 if (!anchor_below) {
559- float totalwidth = 2 * half_width;
560- float totalheight = 5.f + 2 * icon_size;
561- draw_position.x += (totalwidth / 2.f) * scale;
562- draw_position.y += (totalheight - 5.f) * scale;
563+ draw_position.x += kSoldierHealthBarWidth * scale;
564+ draw_position.y += 2 * icon_size * scale;
565 } else {
566- draw_position.y -= 5.f * scale;
567+ draw_position.y -= 5 * scale;
568 }
569
570 // Draw energy bar
571 assert(get_max_health());
572- const Rectf energy_outer(
573- draw_position - Vector2f(half_width, 0.f) * scale, half_width * 2.f * scale, 5.f * scale);
574+ const Recti energy_outer(
575+ draw_position - Vector2i(kSoldierHealthBarWidth, 0) * scale, kSoldierHealthBarWidth * 2 * scale, 5 * scale);
576 dst->fill_rect(energy_outer, RGBColor(255, 255, 255));
577
578- float health_width = 2.f * (half_width - 1.f) * current_health_ / get_max_health();
579- Rectf energy_inner(
580- draw_position + Vector2f(-half_width + 1.f, 1.f) * scale, health_width * scale, 3 * scale);
581- Rectf energy_complement(energy_inner.origin() + Vector2f(health_width, 0.f) * scale,
582- (2 * (half_width - 1) - health_width) * scale, 3 * scale);
583+ int health_width = 2 * (kSoldierHealthBarWidth - 1) * current_health_ / get_max_health();
584+ Recti energy_inner(
585+ draw_position + Vector2i(-kSoldierHealthBarWidth + 1, 1) * scale, health_width * scale, 3 * scale);
586+ Recti energy_complement(energy_inner.origin() + Vector2i(health_width, 0) * scale,
587+ (2 * (kSoldierHealthBarWidth - 1) - health_width) * scale, 3 * scale);
588
589 const RGBColor& color = owner().get_playercolor();
590 RGBColor complement_color;
591@@ -528,15 +525,15 @@
592 dst->fill_rect(energy_complement, complement_color);
593
594 const auto draw_level_image = [icon_size, scale, &draw_position, dst](
595- const Vector2f& offset, const Image* image) {
596+ const Vector2i& offset, const Image* image) {
597 dst->blitrect_scale(
598 Rectf(draw_position + offset * icon_size * scale, icon_size * scale, icon_size * scale),
599 image, Recti(0, 0, icon_size, icon_size), 1.f, BlendMode::UseAlpha);
600 };
601- draw_level_image(Vector2f(-1.f, -2.f), attackpic);
602- draw_level_image(Vector2f(0.f, -2.f), defensepic);
603- draw_level_image(Vector2f(-1.f, -1.f), healthpic);
604- draw_level_image(Vector2f(0.f, -1.f), evadepic);
605+ draw_level_image(Vector2i(-1, -2), attackpic);
606+ draw_level_image(Vector2i(0, -2), defensepic);
607+ draw_level_image(Vector2i(-1, -1), healthpic);
608+ draw_level_image(Vector2i(0, -1), evadepic);
609 }
610
611 /**
612
613=== modified file 'src/logic/map_objects/tribes/soldier.h'
614--- src/logic/map_objects/tribes/soldier.h 2017-04-23 12:11:19 +0000
615+++ src/logic/map_objects/tribes/soldier.h 2017-05-13 13:15:21 +0000
616@@ -219,7 +219,7 @@
617 // Draw the info icon containing health bar and levels. If 'anchor_below' is
618 // true, the icon is drawn horizontally centered above Otherwise, the icon
619 // is drawn below and right of 'draw_position'.
620- void draw_info_icon(Vector2f draw_position,
621+ void draw_info_icon(Vector2i draw_position,
622 const float scale,
623 const bool anchor_below,
624 RenderTarget*) const;
625
626=== modified file 'src/profile/profile.h'
627--- src/profile/profile.h 2017-01-25 18:55:59 +0000
628+++ src/profile/profile.h 2017-05-13 13:15:21 +0000
629@@ -126,7 +126,7 @@
630 uint32_t get_positive(char const* name, uint32_t def = 1);
631 bool get_bool(char const* name, bool def = false);
632 const char* get_string(char const* name, char const* def = nullptr);
633- Vector2i get_point(char const* name, Vector2i def = Vector2i(0, 0));
634+ Vector2i get_point(char const* name, Vector2i def = Vector2i::zero());
635
636 int32_t get_safe_int(const char* name);
637 uint32_t get_safe_natural(char const* name);
638
639=== modified file 'src/scripting/lua_ui.cc'
640--- src/scripting/lua_ui.cc 2017-01-25 18:55:59 +0000
641+++ src/scripting/lua_ui.cc 2017-05-13 13:15:21 +0000
642@@ -212,7 +212,7 @@
643 */
644 int LuaPanel::get_position_x(lua_State* L) {
645 assert(panel_);
646- Vector2i p = panel_->to_parent(Vector2i(0, 0));
647+ Vector2i p = panel_->to_parent(Vector2i::zero());
648
649 lua_pushint32(L, p.x);
650 return 1;
651@@ -225,7 +225,7 @@
652 }
653 int LuaPanel::get_position_y(lua_State* L) {
654 assert(panel_);
655- Vector2i p = panel_->to_parent(Vector2i(0, 0));
656+ Vector2i p = panel_->to_parent(Vector2i::zero());
657
658 lua_pushint32(L, p.y);
659 return 1;
660@@ -257,9 +257,9 @@
661
662 UI::Panel* cur = (*get_base_user_class<LuaPanel>(L, 2))->panel_;
663
664- Vector2i cp = Vector2i(0, 0);
665+ Vector2i cp = Vector2i::zero();
666 while (cur && cur != panel_) {
667- cp += cur->to_parent(Vector2i(0, 0));
668+ cp += cur->to_parent(Vector2i::zero());
669 cur = cur->get_parent();
670 }
671
672
673=== modified file 'src/ui_basic/button.cc'
674--- src/ui_basic/button.cc 2017-02-27 22:09:57 +0000
675+++ src/ui_basic/button.cc 2017-05-13 13:15:21 +0000
676@@ -161,25 +161,25 @@
677
678 // Draw the background
679 if (pic_background_) {
680- dst.fill_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBAColor(0, 0, 0, 255));
681+ dst.fill_rect(Recti(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 255));
682 dst.tile(
683- Recti(Vector2i(0, 0), get_w(), get_h()), pic_background_, Vector2i(get_x(), get_y()));
684+ Recti(Vector2i::zero(), get_w(), get_h()), pic_background_, Vector2i(get_x(), get_y()));
685 }
686
687 if (is_flat && highlighted_)
688- dst.brighten_rect(Rectf(0.f, 0.f, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
689+ dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
690
691 // If we've got a picture, draw it centered
692 if (pic_custom_) {
693 if (image_mode_ == UI::Button::ImageMode::kUnscaled) {
694 if (!is_monochrome) {
695- dst.blit(Vector2f((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2.f,
696- (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2.f),
697+ dst.blit(Vector2i((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2,
698+ (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2),
699 pic_custom_);
700 } else {
701 dst.blit_monochrome(
702- Vector2f((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2.f,
703- (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2.f),
704+ Vector2i((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2,
705+ (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2),
706 pic_custom_, RGBAColor(255, 255, 255, 127));
707 }
708 } else {
709@@ -213,7 +213,7 @@
710 is_monochrome ? UI_FONT_CLR_DISABLED : UI_FONT_CLR_FG);
711 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.
712 dst.blit(
713- Vector2f((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),
714+ Vector2i((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),
715 entry_text_im);
716 }
717
718@@ -229,36 +229,36 @@
719 // Button is a normal one, not flat. We invert the behaviour for kPermpressed.
720 if (is_permpressed == (pressed_ && highlighted_)) {
721 // top edge
722- dst.brighten_rect(Rectf(0.f, 0.f, get_w(), 2.f), BUTTON_EDGE_BRIGHT_FACTOR);
723+ dst.brighten_rect(Recti(0, 0, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
724 // left edge
725- dst.brighten_rect(Rectf(0, 2, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
726+ dst.brighten_rect(Recti(0, 2, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
727 // bottom edge
728- dst.fill_rect(Rectf(2, get_h() - 2, get_w() - 2, 1), black);
729- dst.fill_rect(Rectf(1, get_h() - 1, get_w() - 1, 1), black);
730+ dst.fill_rect(Recti(2, get_h() - 2, get_w() - 2, 1), black);
731+ dst.fill_rect(Recti(1, get_h() - 1, get_w() - 1, 1), black);
732 // right edge
733- dst.fill_rect(Rectf(get_w() - 2, 2, 1, get_h() - 2), black);
734- dst.fill_rect(Rectf(get_w() - 1, 1, 1, get_h() - 1), black);
735+ dst.fill_rect(Recti(get_w() - 2, 2, 1, get_h() - 2), black);
736+ dst.fill_rect(Recti(get_w() - 1, 1, 1, get_h() - 1), black);
737 } else {
738 // bottom edge
739- dst.brighten_rect(Rectf(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
740+ dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
741 // right edge
742- dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
743+ dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
744 // top edge
745- dst.fill_rect(Rectf(0, 0, get_w() - 1, 1), black);
746- dst.fill_rect(Rectf(0, 1, get_w() - 2, 1), black);
747+ dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
748+ dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
749 // left edge
750- dst.fill_rect(Rectf(0, 0, 1, get_h() - 1), black);
751- dst.fill_rect(Rectf(1, 0, 1, get_h() - 2), black);
752+ dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
753+ dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
754 }
755 } else {
756 // Button is flat, do not draw borders, instead, if it is pressed, draw
757 // a box around it.
758 if (enabled_ && highlighted_) {
759 RGBAColor shade(100, 100, 100, 80);
760- dst.fill_rect(Rectf(0, 0, get_w(), 2), shade);
761- dst.fill_rect(Rectf(0, 2, 2, get_h() - 2), shade);
762- dst.fill_rect(Rectf(0, get_h() - 2, get_w(), get_h()), shade);
763- dst.fill_rect(Rectf(get_w() - 2, 0, get_w(), get_h()), shade);
764+ dst.fill_rect(Recti(0, 0, get_w(), 2), shade);
765+ dst.fill_rect(Recti(0, 2, 2, get_h() - 2), shade);
766+ dst.fill_rect(Recti(0, get_h() - 2, get_w(), get_h()), shade);
767+ dst.fill_rect(Recti(get_w() - 2, 0, get_w(), get_h()), shade);
768 }
769 }
770 }
771
772=== modified file 'src/ui_basic/checkbox.cc'
773--- src/ui_basic/checkbox.cc 2017-02-23 17:58:25 +0000
774+++ src/ui_basic/checkbox.cc 2017-05-13 13:15:21 +0000
775@@ -134,18 +134,18 @@
776 const uint16_t w = pic_graphics_->width();
777 const uint16_t h = pic_graphics_->height();
778
779- dst.blit(Vector2f((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), pic_graphics_);
780+ dst.blit(Vector2i((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), pic_graphics_);
781
782 if (flags_ & Is_Checked) {
783- dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBColor(229, 116, 2));
784+ dst.draw_rect(Recti(0, 0, get_w(), get_h()), RGBColor(229, 116, 2));
785 } else if (flags_ & Is_Highlighted) {
786- dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBColor(100, 100, 80));
787+ dst.draw_rect(Recti(0, 0, get_w(), get_h()), RGBColor(100, 100, 80));
788 }
789 } else {
790 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_WIDTH) failed.");
791 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_HEIGHT) failed.");
792- Vector2f image_anchor(0.f, 0.f);
793- Vector2f text_anchor(kStateboxSize + kPadding, 0);
794+ Vector2i image_anchor(0, 0);
795+ Vector2i text_anchor(kStateboxSize + kPadding, 0);
796
797 if (rendered_text_) {
798 if (UI::g_fh1->fontset()->is_rtl()) {
799@@ -153,7 +153,7 @@
800 image_anchor.x = rendered_text_->width() + kPadding;
801 image_anchor.y = (get_h() - kStateboxSize) / 2;
802 }
803- dst.blit(text_anchor, rendered_text_, BlendMode::UseAlpha, UI::Align::kLeft);
804+ dst.blit(text_anchor, rendered_text_, BlendMode::UseAlpha);
805 }
806
807 dst.blitrect(
808@@ -162,7 +162,7 @@
809
810 if (flags_ & Is_Highlighted)
811 dst.draw_rect(
812- Rectf(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));
813+ Recti(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));
814 }
815 }
816
817
818=== modified file 'src/ui_basic/editbox.cc'
819--- src/ui_basic/editbox.cc 2017-02-28 20:07:07 +0000
820+++ src/ui_basic/editbox.cc 2017-05-13 13:15:21 +0000
821@@ -363,19 +363,19 @@
822 static const RGBColor black(0, 0, 0);
823
824 // bottom edge
825- dst.brighten_rect(Rectf(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
826+ dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
827 // right edge
828- dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
829+ dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
830 // top edge
831- dst.fill_rect(Rectf(0.f, 0.f, get_w() - 1, 1), black);
832- dst.fill_rect(Rectf(0.f, 1.f, get_w() - 2, 1), black);
833+ dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
834+ dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
835 // left edge
836- dst.fill_rect(Rectf(0.f, 0.f, 1, get_h() - 1), black);
837- dst.fill_rect(Rectf(1.f, 0.f, 1, get_h() - 2), black);
838+ dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
839+ dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
840 }
841
842 if (has_focus()) {
843- dst.brighten_rect(Rectf(0.f, 0.f, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
844+ dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
845 }
846
847 const int max_width = get_w() - 2 * kMarginX;
848@@ -390,7 +390,7 @@
849 ->height() :
850 entry_text_im->height();
851
852- Vector2f point(kMarginX, get_h() / 2);
853+ Vector2i point(kMarginX, get_h() / 2);
854 if (m_->align == UI::Align::kRight) {
855 point.x += max_width - linewidth;
856 }
857@@ -428,9 +428,9 @@
858 const uint16_t fontheight = text_height(m_->text, m_->fontsize);
859
860 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
861- Vector2f caretpt;
862+ Vector2i caretpt = Vector2i::zero();
863 caretpt.x = point.x + m_->scrolloffset + caret_x - caret_image->width() + kLineMargin;
864- caretpt.y = point.y + (fontheight - caret_image->height()) / 2.f;
865+ caretpt.y = point.y + (fontheight - caret_image->height()) / 2;
866 dst.blit(caretpt, caret_image);
867 }
868 }
869
870=== modified file 'src/ui_basic/fullscreen_window.cc'
871--- src/ui_basic/fullscreen_window.cc 2017-02-23 19:38:51 +0000
872+++ src/ui_basic/fullscreen_window.cc 2017-05-13 13:15:21 +0000
873@@ -86,7 +86,7 @@
874 */
875 void FullscreenWindow::draw(RenderTarget& dst) {
876 // Overall background
877- dst.tile(Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i(0, 0));
878+ dst.tile(Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i::zero());
879
880 // Optional overlays
881 for (const auto& overlay : overlays_) {
882@@ -148,9 +148,9 @@
883 if (tiling != kNone) {
884 const int w = (tiling == kVertical) ? image->width() : get_w();
885 const int h = (tiling == kHorizontal) ? image->height() : get_h();
886- dst.tile(Recti(x, y, w, h), image, Vector2i(0, 0));
887+ dst.tile(Recti(x, y, w, h), image, Vector2i::zero());
888 } else {
889- dst.blit(Vector2f(x, y), image);
890+ dst.blit(Vector2i(x, y), image);
891 }
892 }
893 }
894
895=== modified file 'src/ui_basic/icon.cc'
896--- src/ui_basic/icon.cc 2017-01-25 18:55:59 +0000
897+++ src/ui_basic/icon.cc 2017-05-13 13:15:21 +0000
898@@ -63,7 +63,7 @@
899 Recti(0, 0, pic_->width(), pic_->height()), 1., BlendMode::UseAlpha);
900 }
901 if (draw_frame_) {
902- dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), framecolor_);
903+ dst.draw_rect(Recti(0, 0, get_w(), get_h()), framecolor_);
904 }
905 }
906 }
907
908=== modified file 'src/ui_basic/listselect.cc'
909--- src/ui_basic/listselect.cc 2017-03-06 06:57:47 +0000
910+++ src/ui_basic/listselect.cc 2017-05-13 13:15:21 +0000
911@@ -356,23 +356,23 @@
912 int y = 1 + idx * get_lineheight() - scrollpos_;
913
914 if (background_ != nullptr) {
915- dst.tile(Recti(Vector2i(0, 0), get_w(), get_h()), background_, Vector2i(0, 0));
916+ dst.tile(Recti(Vector2i::zero(), get_w(), get_h()), background_, Vector2i::zero());
917 }
918
919 if (selection_mode_ == ListselectLayout::kDropdown) {
920 RGBAColor black(0, 0, 0, 255);
921 // top edge
922- dst.brighten_rect(Rectf(0.f, 0.f, get_w(), 2.f), BUTTON_EDGE_BRIGHT_FACTOR / 4);
923+ dst.brighten_rect(Recti(0, 0, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR / 4);
924 // left edge
925- dst.brighten_rect(Rectf(0.f, 0.f, 2.f, get_h()), BUTTON_EDGE_BRIGHT_FACTOR);
926+ dst.brighten_rect(Recti(0, 0, 2, get_h()), BUTTON_EDGE_BRIGHT_FACTOR);
927 // bottom edge
928- dst.fill_rect(Rectf(2.f, get_h() - 2.f, get_eff_w() - 2.f, 1.f), black);
929- dst.fill_rect(Rectf(1.f, get_h() - 1.f, get_eff_w() - 1.f, 1.f), black);
930+ dst.fill_rect(Recti(2, get_h() - 2, get_eff_w() - 2, 1), black);
931+ dst.fill_rect(Recti(1, get_h() - 1, get_eff_w() - 1, 1), black);
932 // right edge
933- dst.fill_rect(Rectf(get_w() - 2.f, 1.f, 1.f, get_h() - 1.f), black);
934- dst.fill_rect(Rectf(get_w() - 1.f, 0.f, 1.f, get_h()), black);
935+ dst.fill_rect(Recti(get_w() - 2, 1, 1, get_h() - 1), black);
936+ dst.fill_rect(Recti(get_w() - 1, 0, 1, get_h()), black);
937 } else {
938- dst.brighten_rect(Rectf(0.f, 0.f, get_eff_w(), get_h()), ms_darken_value);
939+ dst.brighten_rect(Recti(0, 0, get_eff_w(), get_h()), ms_darken_value);
940 }
941
942 while (idx < entry_records_.size()) {
943@@ -390,14 +390,14 @@
944 break;
945 }
946
947- Vector2f point(selection_mode_ == ListselectLayout::kDropdown ? 3.f : 1.f, y);
948+ Vector2i point(selection_mode_ == ListselectLayout::kDropdown ? 3 : 1, y);
949 uint32_t maxw =
950 get_eff_w() -
951 (selection_mode_ == ListselectLayout::kDropdown ? scrollbar_.is_enabled() ? 4 : 5 : 2);
952
953 // Highlight the current selected entry
954 if (idx == selection_) {
955- Rectf r(point, maxw, lineheight_);
956+ Recti r(point, maxw, lineheight_);
957 if (r.x < 0) {
958 r.w += r.x;
959 r.x = 0;
960@@ -417,7 +417,7 @@
961
962 // Now draw pictures
963 if (er.pic) {
964- dst.blit(Vector2f(UI::g_fh1->fontset()->is_rtl() ? get_eff_w() - er.pic->width() - 1 : 1,
965+ dst.blit(Vector2i(UI::g_fh1->fontset()->is_rtl() ? get_eff_w() - er.pic->width() - 1 : 1,
966 y + (get_lineheight() - er.pic->height()) / 2),
967 er.pic);
968 }
969
970=== modified file 'src/ui_basic/multilineeditbox.cc'
971--- src/ui_basic/multilineeditbox.cc 2017-03-04 18:02:23 +0000
972+++ src/ui_basic/multilineeditbox.cc 2017-05-13 13:15:21 +0000
973@@ -426,26 +426,26 @@
974 */
975 void MultilineEditbox::draw(RenderTarget& dst) {
976 // Draw the background
977- dst.tile(Recti(Vector2i(0, 0), get_w(), get_h()), d_->background, Vector2i(get_x(), get_y()));
978+ dst.tile(Recti(Vector2i::zero(), get_w(), get_h()), d_->background, Vector2i(get_x(), get_y()));
979
980 // Draw border.
981 if (get_w() >= 4 && get_h() >= 4) {
982 static const RGBColor black(0, 0, 0);
983
984 // bottom edge
985- dst.brighten_rect(Rectf(0.f, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
986+ dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
987 // right edge
988- dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
989+ dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
990 // top edge
991- dst.fill_rect(Rectf(0, 0, get_w() - 1, 1), black);
992- dst.fill_rect(Rectf(0, 1, get_w() - 2, 1), black);
993+ dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
994+ dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
995 // left edge
996- dst.fill_rect(Rectf(0, 0, 1, get_h() - 1), black);
997- dst.fill_rect(Rectf(1, 0, 1, get_h() - 2), black);
998+ dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
999+ dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
1000 }
1001
1002 if (has_focus())
1003- dst.brighten_rect(Rectf(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
1004+ dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
1005
1006 d_->refresh_ww();
1007
1008
1009=== modified file 'src/ui_basic/multilinetextarea.cc'
1010--- src/ui_basic/multilinetextarea.cc 2017-03-04 18:02:23 +0000
1011+++ src/ui_basic/multilinetextarea.cc 2017-05-13 13:15:21 +0000
1012@@ -145,7 +145,7 @@
1013 */
1014 void MultilineTextarea::draw(RenderTarget& dst) {
1015 if (pic_background_) {
1016- dst.tile(Recti(0, 0, get_inner_w(), get_inner_h()), pic_background_, Vector2i(0, 0));
1017+ dst.tile(Recti(0, 0, get_inner_w(), get_inner_h()), pic_background_, Vector2i::zero());
1018 }
1019 if (use_old_renderer_) {
1020 rt.draw(dst, Vector2i(RICHTEXT_MARGIN, RICHTEXT_MARGIN - scrollbar_.get_scrollpos()));
1021@@ -174,7 +174,7 @@
1022 anchor = RICHTEXT_MARGIN;
1023 }
1024
1025- dst.blitrect(Vector2f(anchor, 0), text_im,
1026+ dst.blitrect(Vector2i(anchor, 0), text_im,
1027 Recti(0, scrollbar_.get_scrollpos(), blit_width, blit_height),
1028 BlendMode::UseAlpha);
1029 }
1030
1031=== modified file 'src/ui_basic/panel.cc'
1032--- src/ui_basic/panel.cc 2017-02-27 13:53:04 +0000
1033+++ src/ui_basic/panel.cc 2017-05-13 13:15:21 +0000
1034@@ -191,7 +191,7 @@
1035 RenderTarget& rt = *g_gr->get_render_target();
1036 forefather->do_draw(rt);
1037 rt.blit(
1038- (app->get_mouse_position() - Vector2i(3, 7)).cast<float>(),
1039+ (app->get_mouse_position() - Vector2i(3, 7)),
1040 WLApplication::get()->is_mouse_pressed() ? default_cursor_click_ : default_cursor_);
1041 forefather->do_tooltip();
1042 g_gr->refresh();
1043@@ -746,7 +746,7 @@
1044 return;
1045
1046 Recti outerrc;
1047- Vector2i outerofs;
1048+ Vector2i outerofs = Vector2i::zero();
1049
1050 if (!dst.enter_window(Recti(Vector2i(x_, y_), w_, h_), &outerrc, &outerofs))
1051 return;
1052@@ -1068,9 +1068,9 @@
1053 uint16_t tip_width = rendered_text->width() + 4;
1054 uint16_t tip_height = rendered_text->height() + 4;
1055
1056- Rectf r(WLApplication::get()->get_mouse_position() + Vector2i(2, 32), tip_width, tip_height);
1057- const Vector2f tooltip_bottom_right = r.opposite_of_origin();
1058- const Vector2f screen_bottom_right(g_gr->get_xres(), g_gr->get_yres());
1059+ Recti r(WLApplication::get()->get_mouse_position() + Vector2i(2, 32), tip_width, tip_height);
1060+ const Vector2i tooltip_bottom_right = r.opposite_of_origin();
1061+ const Vector2i screen_bottom_right(g_gr->get_xres(), g_gr->get_yres());
1062 if (screen_bottom_right.x < tooltip_bottom_right.x)
1063 r.x -= 4 + r.w;
1064 if (screen_bottom_right.y < tooltip_bottom_right.y)
1065@@ -1078,7 +1078,7 @@
1066
1067 dst.fill_rect(r, RGBColor(63, 52, 34));
1068 dst.draw_rect(r, RGBColor(0, 0, 0));
1069- dst.blit(r.origin() + Vector2f(2.f, 2.f), rendered_text);
1070+ dst.blit(r.origin() + Vector2i(2, 2), rendered_text);
1071 return true;
1072 }
1073 }
1074
1075=== modified file 'src/ui_basic/progressbar.cc'
1076--- src/ui_basic/progressbar.cc 2017-02-26 11:00:07 +0000
1077+++ src/ui_basic/progressbar.cc 2017-05-13 13:15:21 +0000
1078@@ -75,13 +75,13 @@
1079 const float w = get_w() * fraction;
1080 assert(w <= get_w());
1081
1082- dst.fill_rect(Rectf(0.f, 0.f, w, get_h()), color);
1083- dst.fill_rect(Rectf(w, 0.f, get_w() - w, get_h()), RGBColor(0, 0, 0));
1084+ dst.fill_rect(Recti(0, 0, w, get_h()), color);
1085+ dst.fill_rect(Recti(w, 0, get_w() - w, get_h()), RGBColor(0, 0, 0));
1086 } else {
1087 const uint32_t h = static_cast<uint32_t>(get_h() * (1.0f - fraction));
1088
1089- dst.fill_rect(Rectf(0.f, 0.f, get_w(), h), RGBColor(0, 0, 0));
1090- dst.fill_rect(Rectf(0.f, h, get_w(), get_h() - h), color);
1091+ dst.fill_rect(Recti(0, 0, get_w(), h), RGBColor(0, 0, 0));
1092+ dst.fill_rect(Recti(0, h, get_w(), get_h() - h), color);
1093 }
1094
1095 // Print the state in percent without decimal points.
1096@@ -89,8 +89,9 @@
1097 UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100.f))
1098 .str();
1099 const Image* rendered_text = UI::g_fh1->render(as_uifont(progress_text));
1100- Vector2f pos(get_w() / 2, get_h() / 2);
1101+ Vector2i pos(get_w() / 2, get_h() / 2);
1102+ UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &pos);
1103 UI::center_vertically(rendered_text->height(), &pos);
1104- dst.blit(pos, rendered_text, BlendMode::UseAlpha, UI::Align::kCenter);
1105+ dst.blit(pos, rendered_text, BlendMode::UseAlpha);
1106 }
1107 }
1108
1109=== modified file 'src/ui_basic/progresswindow.cc'
1110--- src/ui_basic/progresswindow.cc 2017-02-24 10:21:37 +0000
1111+++ src/ui_basic/progresswindow.cc 2017-05-13 13:15:21 +0000
1112@@ -45,7 +45,9 @@
1113
1114 namespace UI {
1115
1116-ProgressWindow::ProgressWindow(const std::string& background) : UI::FullscreenWindow() {
1117+ProgressWindow::ProgressWindow(const std::string& background) :
1118+ UI::FullscreenWindow(),
1119+ label_center_(Vector2i::zero()) {
1120 set_background(background);
1121 step(_("Loading…"));
1122 }
1123@@ -70,7 +72,7 @@
1124 label_rectangle_.y = label_center_.y - h / 2 - PROGRESS_STATUS_RECT_PADDING;
1125 label_rectangle_.h = h + 2 * PROGRESS_STATUS_RECT_PADDING;
1126
1127- Rectf border_rect = label_rectangle_;
1128+ Recti border_rect = label_rectangle_;
1129 border_rect.x -= PROGRESS_STATUS_BORDER_X;
1130 border_rect.y -= PROGRESS_STATUS_BORDER_Y;
1131 border_rect.w += 2 * PROGRESS_STATUS_BORDER_X;
1132@@ -100,8 +102,9 @@
1133 rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG);
1134 const Image* rendered_text =
1135 UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG));
1136+ UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &label_center_);
1137 UI::center_vertically(rendered_text->height(), &label_center_);
1138- rt.blit(label_center_, rendered_text, BlendMode::UseAlpha, UI::Align::kCenter);
1139+ rt.blit(label_center_, rendered_text, BlendMode::UseAlpha);
1140
1141 #ifdef _WIN32
1142 // Pump events to prevent "not responding" on windows
1143
1144=== modified file 'src/ui_basic/progresswindow.h'
1145--- src/ui_basic/progresswindow.h 2017-02-24 10:21:37 +0000
1146+++ src/ui_basic/progresswindow.h 2017-05-13 13:15:21 +0000
1147@@ -63,8 +63,8 @@
1148 private:
1149 using VisualizationArray = std::vector<IProgressVisualization*>;
1150
1151- Vector2f label_center_;
1152- Rectf label_rectangle_;
1153+ Vector2i label_center_;
1154+ Recti label_rectangle_;
1155 VisualizationArray visualizations_;
1156 std::string background_;
1157
1158
1159=== modified file 'src/ui_basic/scrollbar.cc'
1160--- src/ui_basic/scrollbar.cc 2017-02-27 13:48:29 +0000
1161+++ src/ui_basic/scrollbar.cc 2017-05-13 13:15:21 +0000
1162@@ -233,7 +233,7 @@
1163 set_scrollpos(pos);
1164 }
1165
1166-void Scrollbar::draw_button(RenderTarget& dst, Area area, const Rectf& r) {
1167+void Scrollbar::draw_button(RenderTarget& dst, Area area, const Recti& r) {
1168 dst.tile(r.cast<int>(), pic_buttons_, Vector2i(get_x(), get_y()));
1169
1170 // Draw the picture
1171@@ -250,7 +250,7 @@
1172 int blit_height = image_scale * pic->height();
1173
1174 dst.blitrect_scale(
1175- Rectf(r.origin() + Vector2f((r.w - blit_width) / 2.f, (r.h - blit_height) / 2.f),
1176+ Rectf(r.origin() + Vector2i((r.w - blit_width) / 2, (r.h - blit_height) / 2),
1177 blit_width, blit_height),
1178 pic, Recti(0, 0, pic->width(), pic->height()), 1., BlendMode::UseAlpha);
1179 }
1180@@ -260,46 +260,46 @@
1181
1182 if (area != pressed_) {
1183 // top edge
1184- dst.brighten_rect(Rectf(r.origin(), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1185+ dst.brighten_rect(Recti(r.origin(), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1186 // left edge
1187- dst.brighten_rect(Rectf(r.origin() + Vector2f(0, 2), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1188+ dst.brighten_rect(Recti(r.origin() + Vector2i(0, 2), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1189 // bottom edge
1190- dst.fill_rect(Rectf(r.origin() + Vector2f(2, r.h - 2), r.w - 2, 1), black);
1191- dst.fill_rect(Rectf(r.origin() + Vector2f(1, r.h - 1), r.w - 1, 1), black);
1192+ dst.fill_rect(Recti(r.origin() + Vector2i(2, r.h - 2), r.w - 2, 1), black);
1193+ dst.fill_rect(Recti(r.origin() + Vector2i(1, r.h - 1), r.w - 1, 1), black);
1194 // right edge
1195- dst.fill_rect(Rectf(r.origin() + Vector2f(r.w - 2, 2), 1, r.h - 2), black);
1196- dst.fill_rect(Rectf(r.origin() + Vector2f(r.w - 1, 1), 1, r.h - 1), black);
1197+ dst.fill_rect(Recti(r.origin() + Vector2i(r.w - 2, 2), 1, r.h - 2), black);
1198+ dst.fill_rect(Recti(r.origin() + Vector2i(r.w - 1, 1), 1, r.h - 1), black);
1199 } else {
1200 // bottom edge
1201 dst.brighten_rect(
1202- Rectf(r.origin() + Vector2f(0, r.h - 2), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1203+ Recti(r.origin() + Vector2i(0, r.h - 2), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1204 // right edge
1205 dst.brighten_rect(
1206- Rectf(r.origin() + Vector2f(r.w - 2, 0), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1207+ Recti(r.origin() + Vector2i(r.w - 2, 0), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1208 // top edge
1209- dst.fill_rect(Rectf(r.origin(), r.w - 1, 1), black);
1210- dst.fill_rect(Rectf(r.origin() + Vector2f(0, 1), r.w - 2, 1), black);
1211+ dst.fill_rect(Recti(r.origin(), r.w - 1, 1), black);
1212+ dst.fill_rect(Recti(r.origin() + Vector2i(0, 1), r.w - 2, 1), black);
1213 // left edge
1214- dst.fill_rect(Rectf(r.origin(), 1, r.h - 1), black);
1215- dst.fill_rect(Rectf(r.origin() + Vector2f(1, 0), 1, r.h - 2), black);
1216+ dst.fill_rect(Recti(r.origin(), 1, r.h - 1), black);
1217+ dst.fill_rect(Recti(r.origin() + Vector2i(1, 0), 1, r.h - 2), black);
1218 }
1219 }
1220
1221-void Scrollbar::draw_area(RenderTarget& dst, Area area, const Rectf& r) {
1222+void Scrollbar::draw_area(RenderTarget& dst, Area area, const Recti& r) {
1223 // background
1224 dst.brighten_rect(r, area == pressed_ ? 2 * MOUSE_OVER_BRIGHT_FACTOR : MOUSE_OVER_BRIGHT_FACTOR);
1225 if (horizontal_) {
1226 // top edge
1227- dst.brighten_rect(Rectf(r.x, r.y, r.w - 1.f, 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);
1228- dst.brighten_rect(Rectf(r.x, r.y + 1.f, r.w - 2.f, 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);
1229+ dst.brighten_rect(Recti(r.x, r.y, r.w - 1, 1), -BUTTON_EDGE_BRIGHT_FACTOR);
1230+ dst.brighten_rect(Recti(r.x, r.y + 1, r.w - 2, 1), -BUTTON_EDGE_BRIGHT_FACTOR);
1231 // bottom edge
1232- dst.brighten_rect(Rectf(r.x, r.h - 2.f, r.w, 2.f), BUTTON_EDGE_BRIGHT_FACTOR);
1233+ dst.brighten_rect(Recti(r.x, r.h - 2, r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1234 } else {
1235 // right edge
1236- dst.brighten_rect(Rectf(r.w - 2.f, r.y, 2.f, r.h), BUTTON_EDGE_BRIGHT_FACTOR);
1237+ dst.brighten_rect(Recti(r.w - 2, r.y, 2, r.h), BUTTON_EDGE_BRIGHT_FACTOR);
1238 // left edge
1239- dst.brighten_rect(Rectf(r.x, r.y, 1.f, r.h - 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);
1240- dst.brighten_rect(Rectf(r.x + 1.f, r.y, 1.f, r.h - 2.f), -BUTTON_EDGE_BRIGHT_FACTOR);
1241+ dst.brighten_rect(Recti(r.x, r.y, 1, r.h - 1), -BUTTON_EDGE_BRIGHT_FACTOR);
1242+ dst.brighten_rect(Recti(r.x + 1, r.y, 1, r.h - 2), -BUTTON_EDGE_BRIGHT_FACTOR);
1243 }
1244 }
1245
1246@@ -317,46 +317,46 @@
1247 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_w())) {
1248 // Our owner allocated too little space
1249 if (static_cast<uint32_t>(get_w()) >= 2 * buttonsize_) {
1250- draw_button(dst, Minus, Rectf(0, 0, get_w() / 2, get_h()));
1251- draw_button(dst, Plus, Rectf(get_w() - buttonsize_, 0, get_w() / 2, get_h()));
1252+ draw_button(dst, Minus, Recti(0, 0, get_w() / 2, get_h()));
1253+ draw_button(dst, Plus, Recti(get_w() - buttonsize_, 0, get_w() / 2, get_h()));
1254 } else {
1255- draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h()));
1256+ draw_button(dst, Minus, Recti(0, 0, get_w(), get_h()));
1257 }
1258 return;
1259 }
1260
1261- draw_button(dst, Minus, Rectf(0, 0, buttonsize_, get_h()));
1262- draw_button(dst, Plus, Rectf(get_w() - buttonsize_, 0, buttonsize_, get_h()));
1263- draw_button(dst, Knob, Rectf(knobpos - knobsize / 2.f, 0, knobsize, get_h()));
1264+ draw_button(dst, Minus, Recti(0, 0, buttonsize_, get_h()));
1265+ draw_button(dst, Plus, Recti(get_w() - buttonsize_, 0, buttonsize_, get_h()));
1266+ draw_button(dst, Knob, Recti(knobpos - knobsize / 2, 0, knobsize, get_h()));
1267
1268 assert(buttonsize_ + knobsize / 2 <= knobpos);
1269 draw_area(
1270- dst, MinusPage, Rectf(buttonsize_, 0, knobpos - buttonsize_ - knobsize / 2, get_h()));
1271+ dst, MinusPage, Recti(buttonsize_, 0, knobpos - buttonsize_ - knobsize / 2, get_h()));
1272 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_w()));
1273- draw_area(dst, PlusPage, Rectf(knobpos + knobsize / 2.f, 0.f,
1274+ draw_area(dst, PlusPage, Recti(knobpos + knobsize / 2, 0,
1275 get_w() - knobpos - knobsize / 2 - buttonsize_, get_h()));
1276 } else {
1277 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_h())) {
1278 // Our owner allocated too little space
1279 if (static_cast<uint32_t>(get_h()) >= 2 * buttonsize_) {
1280- draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h() / 2.f));
1281- draw_button(dst, Plus, Rectf(0.f, get_h() - buttonsize_, get_w(), get_h() / 2));
1282+ draw_button(dst, Minus, Recti(0, 0, get_w(), get_h() / 2));
1283+ draw_button(dst, Plus, Recti(0, get_h() - buttonsize_, get_w(), get_h() / 2));
1284 } else {
1285- draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h()));
1286+ draw_button(dst, Minus, Recti(0, 0, get_w(), get_h()));
1287 }
1288 return;
1289 }
1290
1291- draw_button(dst, Minus, Rectf(0, 0, get_w(), buttonsize_));
1292- draw_button(dst, Plus, Rectf(0, get_h() - buttonsize_, get_w(), buttonsize_));
1293- draw_button(dst, Knob, Rectf(0, knobpos - knobsize / 2.f, get_w(), knobsize));
1294+ draw_button(dst, Minus, Recti(0, 0, get_w(), buttonsize_));
1295+ draw_button(dst, Plus, Recti(0, get_h() - buttonsize_, get_w(), buttonsize_));
1296+ draw_button(dst, Knob, Recti(0, knobpos - knobsize / 2, get_w(), knobsize));
1297
1298 assert(buttonsize_ + knobsize / 2 <= knobpos);
1299 draw_area(
1300- dst, MinusPage, Rectf(0.f, buttonsize_, get_w(), knobpos - buttonsize_ - knobsize / 2));
1301+ dst, MinusPage, Recti(0, buttonsize_, get_w(), knobpos - buttonsize_ - knobsize / 2));
1302 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_h()));
1303- draw_area(dst, PlusPage, Rectf(0.f, knobpos + knobsize / 2.f, get_w(),
1304- get_h() - knobpos - knobsize / 2.f - buttonsize_));
1305+ draw_area(dst, PlusPage, Recti(0, knobpos + knobsize / 2, get_w(),
1306+ get_h() - knobpos - knobsize / 2 - buttonsize_));
1307 }
1308 }
1309
1310
1311=== modified file 'src/ui_basic/scrollbar.h'
1312--- src/ui_basic/scrollbar.h 2017-01-25 18:55:59 +0000
1313+++ src/ui_basic/scrollbar.h 2017-05-13 13:15:21 +0000
1314@@ -82,8 +82,8 @@
1315
1316 void action(Area area);
1317
1318- void draw_button(RenderTarget&, Area, const Rectf&);
1319- void draw_area(RenderTarget& dst, Area area, const Rectf& r);
1320+ void draw_button(RenderTarget&, Area, const Recti&);
1321+ void draw_area(RenderTarget& dst, Area area, const Recti& r);
1322 void draw(RenderTarget&) override;
1323 void think() override;
1324
1325
1326=== modified file 'src/ui_basic/slider.cc'
1327--- src/ui_basic/slider.cc 2017-02-24 19:22:36 +0000
1328+++ src/ui_basic/slider.cc 2017-05-13 13:15:21 +0000
1329@@ -152,34 +152,34 @@
1330 (Recti(Vector2i(x, y), w, h), pic_background_, Vector2i(get_x(), get_y()));
1331
1332 if (highlighted_)
1333- dst.brighten_rect(Rectf(x, y, w, h), MOUSE_OVER_BRIGHT_FACTOR);
1334+ dst.brighten_rect(Recti(x, y, w, h), MOUSE_OVER_BRIGHT_FACTOR);
1335
1336 if (pressed_) { // draw border
1337 dst.brighten_rect // bottom edge
1338- (Rectf(x, y + h - 2, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1339+ (Recti(x, y + h - 2, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1340 dst.brighten_rect // right edge
1341- (Rectf(x + w - 2, y, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1342+ (Recti(x + w - 2, y, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1343
1344 // top edge
1345- dst.fill_rect(Rectf(x, y, w - 1, 1), black);
1346- dst.fill_rect(Rectf(x, y + 1, w - 2, 1), black);
1347+ dst.fill_rect(Recti(x, y, w - 1, 1), black);
1348+ dst.fill_rect(Recti(x, y + 1, w - 2, 1), black);
1349
1350 // left edge
1351- dst.fill_rect(Rectf(x, y, 1, h - 1), black);
1352- dst.fill_rect(Rectf(x + 1, y, 1, h - 2), black);
1353+ dst.fill_rect(Recti(x, y, 1, h - 1), black);
1354+ dst.fill_rect(Recti(x + 1, y, 1, h - 2), black);
1355 } else {
1356 dst.brighten_rect // top edge
1357- (Rectf(x, y, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1358+ (Recti(x, y, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1359 dst.brighten_rect // left edge
1360- (Rectf(x, y + 2, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1361+ (Recti(x, y + 2, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1362
1363 // bottom edge
1364- dst.fill_rect(Rectf(x + 2, y + h - 2, w - 2, 1), black);
1365- dst.fill_rect(Rectf(x + 1, y + h - 1, w - 1, 1), black);
1366+ dst.fill_rect(Recti(x + 2, y + h - 2, w - 2, 1), black);
1367+ dst.fill_rect(Recti(x + 1, y + h - 1, w - 1, 1), black);
1368
1369 // right edge
1370- dst.fill_rect(Rectf(x + w - 2, y + 2, 1, h - 2), black);
1371- dst.fill_rect(Rectf(x + w - 1, y + 1, 1, h - 1), black);
1372+ dst.fill_rect(Recti(x + w - 2, y + 2, 1, h - 2), black);
1373+ dst.fill_rect(Recti(x + w - 1, y + 1, 1, h - 1), black);
1374 }
1375 }
1376
1377@@ -362,18 +362,18 @@
1378
1379 if (get_bar_size() > 0) {
1380 dst.brighten_rect // bottom edge
1381- (Rectf(get_x_gap(), get_h() / 2.f, get_bar_size(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
1382+ (Recti(get_x_gap(), get_h() / 2, get_bar_size(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
1383 dst.brighten_rect // right edge
1384- (Rectf(get_x_gap() + get_bar_size() - 2, get_y_gap(), 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1385+ (Recti(get_x_gap() + get_bar_size() - 2, get_y_gap(), 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1386
1387 // top edge
1388- dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), get_bar_size() - 1, 1), black);
1389- dst.fill_rect(Rectf(get_x_gap(), get_y_gap() + 1, get_bar_size() - 2, 1), black);
1390+ dst.fill_rect(Recti(get_x_gap(), get_y_gap(), get_bar_size() - 1, 1), black);
1391+ dst.fill_rect(Recti(get_x_gap(), get_y_gap() + 1, get_bar_size() - 2, 1), black);
1392 }
1393
1394 // left edge
1395- dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 1, 4), black);
1396- dst.fill_rect(Rectf(get_x_gap() + 1, get_y_gap(), 1, 3), black);
1397+ dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 1, 4), black);
1398+ dst.fill_rect(Recti(get_x_gap() + 1, get_y_gap(), 1, 3), black);
1399
1400 draw_cursor(dst, cursor_pos_, 0, cursor_size_, get_h());
1401 }
1402@@ -435,17 +435,17 @@
1403 RGBAColor black(0, 0, 0, 255);
1404
1405 dst.brighten_rect // right edge
1406- (Rectf(get_w() / 2.f, get_y_gap(), 2, get_bar_size()), BUTTON_EDGE_BRIGHT_FACTOR);
1407+ (Recti(get_w() / 2, get_y_gap(), 2, get_bar_size()), BUTTON_EDGE_BRIGHT_FACTOR);
1408 dst.brighten_rect // bottom edge
1409- (Rectf(get_x_gap(), get_y_gap() + get_bar_size() - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1410+ (Recti(get_x_gap(), get_y_gap() + get_bar_size() - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1411
1412 // left edge
1413- dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 1, get_bar_size() - 1), black);
1414- dst.fill_rect(Rectf(get_x_gap() + 1, get_y_gap(), 1, get_bar_size() - 2), black);
1415+ dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 1, get_bar_size() - 1), black);
1416+ dst.fill_rect(Recti(get_x_gap() + 1, get_y_gap(), 1, get_bar_size() - 2), black);
1417
1418 // top edge
1419- dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 4, 1), black);
1420- dst.fill_rect(Rectf(get_x_gap(), get_y_gap() + 1, 3, 1), black);
1421+ dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 4, 1), black);
1422+ dst.fill_rect(Recti(get_x_gap(), get_y_gap() + 1, 3, 1), black);
1423
1424 draw_cursor(dst, 0, cursor_pos_, get_w(), cursor_size_);
1425 }
1426@@ -540,8 +540,9 @@
1427 for (uint32_t i = 0; i < labels.size(); i++) {
1428 const Image* rendered_text =
1429 UI::g_fh1->render(as_condensed(labels[i], UI::Align::kCenter, UI_FONT_SIZE_SMALL - 2));
1430- dst.blit(Vector2f(gap_1 + i * gap_n, get_h() - rendered_text->height()), rendered_text,
1431- BlendMode::UseAlpha, UI::Align::kCenter);
1432+ Vector2i point(gap_1 + i * gap_n, get_h() - rendered_text->height());
1433+ UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &point);
1434+ dst.blit(point, rendered_text, BlendMode::UseAlpha);
1435 }
1436 }
1437
1438
1439=== modified file 'src/ui_basic/table.cc'
1440--- src/ui_basic/table.cc 2017-04-25 08:10:11 +0000
1441+++ src/ui_basic/table.cc 2017-05-13 13:15:21 +0000
1442@@ -220,7 +220,7 @@
1443 uint32_t idx = scrollpos_ / lineheight;
1444 int32_t y = 1 + idx * lineheight - scrollpos_ + headerheight_;
1445
1446- dst.brighten_rect(Rectf(0.f, 0.f, get_eff_w(), get_h()), ms_darken_value);
1447+ dst.brighten_rect(Recti(0, 0, get_eff_w(), get_h()), ms_darken_value);
1448
1449 while (idx < entry_records_.size()) {
1450 if (y >= static_cast<int32_t>(get_h()))
1451@@ -230,7 +230,7 @@
1452
1453 if (idx == selection_ || multiselect_.count(idx)) {
1454 assert(2 <= get_eff_w());
1455- dst.brighten_rect(Rectf(1.f, y, get_eff_w() - 2, lineheight_), -ms_darken_value);
1456+ dst.brighten_rect(Recti(1, y, get_eff_w() - 2, lineheight_), -ms_darken_value);
1457 }
1458
1459 Columns::size_type const nr_columns = columns_.size();
1460@@ -242,14 +242,14 @@
1461 const Image* entry_picture = er.get_picture(i);
1462 const std::string& entry_string = er.get_string(i);
1463
1464- Vector2f point(curx, y);
1465+ Vector2i point(curx, y);
1466 int picw = 0;
1467
1468 if (entry_picture != nullptr) {
1469 picw = entry_picture->width();
1470 const int pich = entry_picture->height();
1471
1472- float draw_x = point.x;
1473+ int draw_x = point.x;
1474
1475 // We want a bit of margin
1476 int max_pic_height = lineheight - 3;
1477@@ -263,7 +263,7 @@
1478 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
1479 draw_x = point.x + (curw - blit_width - scrollbar_->get_w()) / 2.f;
1480 } else {
1481- draw_x = point.x + (curw - blit_width) / 2.f;
1482+ draw_x = point.x + (curw - blit_width) / 2;
1483 }
1484 }
1485
1486@@ -272,7 +272,7 @@
1487 }
1488
1489 // Create the scaled image
1490- dst.blitrect_scale(Rectf(draw_x, point.y + 1.f, blit_width, max_pic_height),
1491+ dst.blitrect_scale(Rectf(draw_x, point.y + 1, blit_width, max_pic_height),
1492 entry_picture, Recti(0, 0, picw, pich), 1., BlendMode::UseAlpha);
1493
1494 // For text alignment below
1495@@ -282,12 +282,12 @@
1496 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
1497 draw_x = point.x + (curw - picw - scrollbar_->get_w()) / 2.f;
1498 } else {
1499- draw_x = point.x + (curw - picw) / 2.f;
1500+ draw_x = point.x + (curw - picw) / 2;
1501 }
1502 } else if (alignment == UI::Align::kRight) {
1503 draw_x += curw - picw;
1504 }
1505- dst.blit(Vector2f(draw_x, point.y + (lineheight - pich) / 2.f), entry_picture);
1506+ dst.blit(Vector2i(draw_x, point.y + (lineheight - pich) / 2), entry_picture);
1507 }
1508 point.x += picw;
1509 }
1510
1511=== modified file 'src/ui_basic/tabpanel.cc'
1512--- src/ui_basic/tabpanel.cc 2017-03-04 09:14:37 +0000
1513+++ src/ui_basic/tabpanel.cc 2017-05-13 13:15:21 +0000
1514@@ -259,7 +259,7 @@
1515
1516 if (pic_background_) {
1517 if (!tabs_.empty()) {
1518- dst.tile(Recti(Vector2i(0, 0), tabs_.back()->get_x() + tabs_.back()->get_w(),
1519+ dst.tile(Recti(Vector2i::zero(), tabs_.back()->get_x() + tabs_.back()->get_w(),
1520 kTabPanelButtonHeight - 2),
1521 pic_background_, Vector2i(get_x(), get_y()));
1522 }
1523@@ -279,7 +279,7 @@
1524 tab_width = tabs_[idx]->get_w();
1525
1526 if (highlight_ == idx) {
1527- dst.brighten_rect(Rectf(x, 0, tab_width, kTabPanelButtonHeight), MOUSE_OVER_BRIGHT_FACTOR);
1528+ dst.brighten_rect(Recti(x, 0, tab_width, kTabPanelButtonHeight), MOUSE_OVER_BRIGHT_FACTOR);
1529 }
1530
1531 assert(tabs_[idx]->pic);
1532@@ -300,46 +300,46 @@
1533 tabs_[idx]->pic, Recti(0, 0, tabs_[idx]->pic->width(), tabs_[idx]->pic->height()), 1,
1534 BlendMode::UseAlpha);
1535 } else {
1536- dst.blit(Vector2f(x + kTabPanelTextMargin,
1537+ dst.blit(Vector2i(x + kTabPanelTextMargin,
1538 (kTabPanelButtonHeight - tabs_[idx]->pic->height()) / 2),
1539- tabs_[idx]->pic, BlendMode::UseAlpha, UI::Align::kLeft);
1540+ tabs_[idx]->pic, BlendMode::UseAlpha);
1541 }
1542
1543 // Draw top part of border
1544- dst.brighten_rect(Rectf(x, 0, tab_width, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1545- dst.brighten_rect(Rectf(x, 2, 2, kTabPanelButtonHeight - 4), BUTTON_EDGE_BRIGHT_FACTOR);
1546- dst.fill_rect(Rectf(x + tab_width - 2, 2, 1, kTabPanelButtonHeight - 4), black);
1547- dst.fill_rect(Rectf(x + tab_width - 1, 1, 1, kTabPanelButtonHeight - 3), black);
1548+ dst.brighten_rect(Recti(x, 0, tab_width, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1549+ dst.brighten_rect(Recti(x, 2, 2, kTabPanelButtonHeight - 4), BUTTON_EDGE_BRIGHT_FACTOR);
1550+ dst.fill_rect(Recti(x + tab_width - 2, 2, 1, kTabPanelButtonHeight - 4), black);
1551+ dst.fill_rect(Recti(x + tab_width - 1, 1, 1, kTabPanelButtonHeight - 3), black);
1552
1553 // Draw bottom part
1554 if (active_ != idx)
1555 dst.brighten_rect(
1556- Rectf(x, kTabPanelButtonHeight - 2, tab_width, 2), 2 * BUTTON_EDGE_BRIGHT_FACTOR);
1557+ Recti(x, kTabPanelButtonHeight - 2, tab_width, 2), 2 * BUTTON_EDGE_BRIGHT_FACTOR);
1558 else {
1559- dst.brighten_rect(Rectf(x, kTabPanelButtonHeight - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1560+ dst.brighten_rect(Recti(x, kTabPanelButtonHeight - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
1561
1562- dst.brighten_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 2),
1563+ dst.brighten_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 2),
1564 2 * BUTTON_EDGE_BRIGHT_FACTOR);
1565- dst.fill_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 1, 1, 1), black);
1566- dst.fill_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 1), black);
1567+ dst.fill_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 1, 1, 1), black);
1568+ dst.fill_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 1), black);
1569 }
1570 }
1571
1572 // draw the remaining separator
1573 assert(x <= get_w());
1574- dst.brighten_rect(Rectf(x + tab_width, kTabPanelButtonHeight - 2, get_w() - x, 2),
1575+ dst.brighten_rect(Recti(x + tab_width, kTabPanelButtonHeight - 2, get_w() - x, 2),
1576 2 * BUTTON_EDGE_BRIGHT_FACTOR);
1577
1578 // Draw border around the main panel
1579 if (border_type_ == TabPanel::Type::kBorder) {
1580 // left edge
1581- dst.brighten_rect(Rectf(0, kTabPanelButtonHeight, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1582+ dst.brighten_rect(Recti(0, kTabPanelButtonHeight, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
1583 // bottom edge
1584- dst.fill_rect(Rectf(2, get_h() - 2, get_w() - 2, 1), black);
1585- dst.fill_rect(Rectf(1, get_h() - 1, get_w() - 1, 1), black);
1586+ dst.fill_rect(Recti(2, get_h() - 2, get_w() - 2, 1), black);
1587+ dst.fill_rect(Recti(1, get_h() - 1, get_w() - 1, 1), black);
1588 // right edge
1589- dst.fill_rect(Rectf(get_w() - 2, kTabPanelButtonHeight - 1, 1, get_h() - 2), black);
1590- dst.fill_rect(Rectf(get_w() - 1, kTabPanelButtonHeight - 2, 1, get_h() - 1), black);
1591+ dst.fill_rect(Recti(get_w() - 2, kTabPanelButtonHeight - 1, 1, get_h() - 2), black);
1592+ dst.fill_rect(Recti(get_w() - 1, kTabPanelButtonHeight - 2, 1, get_h() - 1), black);
1593 }
1594 }
1595
1596
1597=== modified file 'src/ui_basic/textarea.cc'
1598--- src/ui_basic/textarea.cc 2017-02-27 13:48:29 +0000
1599+++ src/ui_basic/textarea.cc 2017-05-13 13:15:21 +0000
1600@@ -125,10 +125,10 @@
1601 */
1602 void Textarea::draw(RenderTarget& dst) {
1603 if (!text_.empty()) {
1604- // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.
1605- Vector2f anchor(
1606+ Vector2i anchor(
1607 (align_ == Align::kCenter) ? get_w() / 2 : (align_ == UI::Align::kRight) ? get_w() : 0, 0);
1608- dst.blit(anchor, rendered_text_, BlendMode::UseAlpha, align_);
1609+ UI::correct_for_align(align_, rendered_text_->width(), &anchor);
1610+ dst.blit(anchor, rendered_text_, BlendMode::UseAlpha);
1611 }
1612 }
1613
1614
1615=== modified file 'src/ui_basic/window.cc'
1616--- src/ui_basic/window.cc 2017-02-27 13:48:29 +0000
1617+++ src/ui_basic/window.cc 2017-05-13 13:15:21 +0000
1618@@ -141,7 +141,7 @@
1619 */
1620 void Window::layout() {
1621 if (center_panel_ && !is_minimal_) {
1622- center_panel_->set_pos(Vector2i(0, 0));
1623+ center_panel_->set_pos(Vector2i::zero());
1624 center_panel_->set_size(get_inner_w(), get_inner_h());
1625 }
1626 }
1627@@ -235,7 +235,7 @@
1628 void Window::draw(RenderTarget& dst) {
1629 if (!is_minimal()) {
1630 dst.tile(
1631- Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), pic_background_, Vector2i(0, 0));
1632+ Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), pic_background_, Vector2i::zero());
1633 }
1634 }
1635
1636@@ -253,19 +253,19 @@
1637 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;
1638
1639 dst.blitrect // top left corner
1640- (Vector2f(0.f, 0.f), pic_top_, Recti(Vector2i(0, 0), pos, TP_B_PIXMAP_THICKNESS));
1641+ (Vector2i::zero(), pic_top_, Recti(Vector2i::zero(), pos, TP_B_PIXMAP_THICKNESS));
1642
1643 // top bar
1644 static_assert(0 <= HZ_B_CORNER_PIXMAP_LEN, "assert(0 <= HZ_B_CORNER_PIXMAP_LEN) failed.");
1645 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
1646 dst.blitrect(
1647- Vector2f(pos, 0), pic_top_, Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0),
1648+ Vector2i(pos, 0), pic_top_, Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0),
1649 HZ_B_MIDDLE_PIXMAP_LEN, TP_B_PIXMAP_THICKNESS));
1650
1651 // odd pixels of top bar and top right corner
1652 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;
1653 assert(0 <= HZ_B_TOTAL_PIXMAP_LEN - width);
1654- dst.blitrect(Vector2f(pos, 0), pic_top_,
1655+ dst.blitrect(Vector2i(pos, 0), pic_top_,
1656 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, TP_B_PIXMAP_THICKNESS));
1657 }
1658
1659@@ -276,9 +276,10 @@
1660 autofit_ui_text(richtext_escape(title_), get_inner_w(), UI_FONT_CLR_FG, 13);
1661
1662 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.
1663- Vector2f pos(get_lborder() + get_inner_w() / 2, TP_B_PIXMAP_THICKNESS / 2);
1664+ Vector2i pos(get_lborder() + get_inner_w() / 2, TP_B_PIXMAP_THICKNESS / 2);
1665+ UI::correct_for_align(UI::Align::kCenter, text->width(), &pos);
1666 UI::center_vertically(text->height(), &pos);
1667- dst.blit(pos, text, BlendMode::UseAlpha, UI::Align::kCenter);
1668+ dst.blit(pos, text, BlendMode::UseAlpha);
1669 }
1670
1671 if (!is_minimal_) {
1672@@ -290,15 +291,15 @@
1673
1674 static_assert(0 <= VT_B_PIXMAP_THICKNESS, "assert(0 <= VT_B_PIXMAP_THICKNESS) failed.");
1675 dst.blitrect // left top thingy
1676- (Vector2f(0, TP_B_PIXMAP_THICKNESS), pic_lborder_,
1677- Recti(Vector2i(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
1678+ (Vector2i(0, TP_B_PIXMAP_THICKNESS), pic_lborder_,
1679+ Recti(Vector2i::zero(), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
1680
1681 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
1682
1683 // left bar
1684 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
1685 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
1686- dst.blitrect(Vector2f(0, pos), pic_lborder_,
1687+ dst.blitrect(Vector2i(0, pos), pic_lborder_,
1688 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,
1689 VT_B_MIDDLE_PIXMAP_LEN));
1690
1691@@ -306,7 +307,7 @@
1692 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;
1693 assert(0 <= VT_B_TOTAL_PIXMAP_LEN - height);
1694 dst.blitrect(
1695- Vector2f(0, pos), pic_lborder_,
1696+ Vector2i(0, pos), pic_lborder_,
1697 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));
1698 }
1699
1700@@ -314,22 +315,22 @@
1701 const int32_t right_border_x = get_w() - VT_B_PIXMAP_THICKNESS;
1702
1703 dst.blitrect // right top thingy
1704- (Vector2f(right_border_x, TP_B_PIXMAP_THICKNESS), pic_rborder_,
1705- Recti(Vector2i(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
1706+ (Vector2i(right_border_x, TP_B_PIXMAP_THICKNESS), pic_rborder_,
1707+ Recti(Vector2i::zero(), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
1708
1709 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
1710
1711 // right bar
1712 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
1713 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
1714- dst.blitrect(Vector2f(right_border_x, pos), pic_rborder_,
1715+ dst.blitrect(Vector2i(right_border_x, pos), pic_rborder_,
1716 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,
1717 VT_B_MIDDLE_PIXMAP_LEN));
1718
1719 // odd pixels of right bar and right bottom thingy
1720 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;
1721 dst.blitrect(
1722- Vector2f(right_border_x, pos), pic_rborder_,
1723+ Vector2i(right_border_x, pos), pic_rborder_,
1724 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));
1725 }
1726
1727@@ -337,19 +338,19 @@
1728 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;
1729
1730 dst.blitrect // bottom left corner
1731- (Vector2f(0, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1732- Recti(Vector2i(0, 0), pos, BT_B_PIXMAP_THICKNESS));
1733+ (Vector2i(0, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1734+ Recti(Vector2i::zero(), pos, BT_B_PIXMAP_THICKNESS));
1735
1736 // bottom bar
1737 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
1738- dst.blitrect(Vector2f(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1739+ dst.blitrect(Vector2i(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1740 Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0), HZ_B_MIDDLE_PIXMAP_LEN,
1741 BT_B_PIXMAP_THICKNESS));
1742
1743 // odd pixels of bottom bar and bottom right corner
1744 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;
1745 dst.blitrect(
1746- Vector2f(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1747+ Vector2i(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
1748 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, BT_B_PIXMAP_THICKNESS));
1749 }
1750 }
1751
1752=== modified file 'src/ui_fsmenu/mapselect.cc'
1753--- src/ui_fsmenu/mapselect.cc 2017-02-28 20:07:07 +0000
1754+++ src/ui_fsmenu/mapselect.cc 2017-05-13 13:15:21 +0000
1755@@ -84,7 +84,7 @@
1756
1757 // Must be initialized before tag checkboxes
1758 cb_dont_localize_mapnames_ =
1759- new UI::Checkbox(hbox, Vector2i(0, 0), _("Show original map names"));
1760+ new UI::Checkbox(hbox, Vector2i::zero(), _("Show original map names"));
1761 cb_dont_localize_mapnames_->set_state(false);
1762 cb_dont_localize_mapnames_->changedto.connect(
1763 boost::bind(&FullscreenMenuMapSelect::fill_table, boost::ref(*this)));
1764@@ -303,7 +303,7 @@
1765 int32_t id = tags_ordered_.size();
1766 tags_ordered_.push_back(tag);
1767
1768- UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);
1769+ UI::Checkbox* cb = new UI::Checkbox(box, Vector2i::zero(), displ_name);
1770 cb->changedto.connect(boost::bind(&FullscreenMenuMapSelect::tagbox_changed, this, id, _1));
1771
1772 box->add(cb, UI::Box::Resizing::kFullSize);
1773
1774=== modified file 'src/ui_fsmenu/options.cc'
1775--- src/ui_fsmenu/options.cc 2017-03-29 12:37:47 +0000
1776+++ src/ui_fsmenu/options.cc 2017-05-13 13:15:21 +0000
1777@@ -148,15 +148,15 @@
1778 24,
1779 _("In-game resolution")),
1780
1781- fullscreen_(&box_interface_, Vector2i(0, 0), _("Fullscreen"), "", 0),
1782- inputgrab_(&box_interface_, Vector2i(0, 0), _("Grab Input"), "", 0),
1783+ fullscreen_(&box_interface_, Vector2i::zero(), _("Fullscreen"), "", 0),
1784+ inputgrab_(&box_interface_, Vector2i::zero(), _("Grab Input"), "", 0),
1785
1786 sb_maxfps_(&box_interface_, 0, 0, 0, 0, opt.maxfps, 0, 99, _("Maximum FPS:")),
1787
1788 // Windows options
1789 snap_win_overlap_only_(
1790- &box_windows_, Vector2i(0, 0), _("Snap windows only when overlapping"), "", 0),
1791- dock_windows_to_edges_(&box_windows_, Vector2i(0, 0), _("Dock windows to edges"), "", 0),
1792+ &box_windows_, Vector2i::zero(), _("Snap windows only when overlapping"), "", 0),
1793+ dock_windows_to_edges_(&box_windows_, Vector2i::zero(), _("Dock windows to edges"), "", 0),
1794
1795 sb_dis_panel_(&box_windows_,
1796 0,
1797@@ -181,9 +181,9 @@
1798 UI::SpinBox::Units::kPixels),
1799
1800 // Sound options
1801- music_(&box_sound_, Vector2i(0, 0), _("Enable Music"), "", 0),
1802- fx_(&box_sound_, Vector2i(0, 0), _("Enable Sound Effects"), "", 0),
1803- message_sound_(&box_sound_, Vector2i(0, 0), _("Play a sound at message arrival"), "", 0),
1804+ music_(&box_sound_, Vector2i::zero(), _("Enable Music"), "", 0),
1805+ fx_(&box_sound_, Vector2i::zero(), _("Enable Sound Effects"), "", 0),
1806+ message_sound_(&box_sound_, Vector2i::zero(), _("Play a sound at message arrival"), "", 0),
1807
1808 // Saving options
1809 sb_autosave_(&box_saving_,
1810@@ -213,26 +213,26 @@
1811 UI::SpinBox::Type::kBig),
1812
1813 zip_(&box_saving_,
1814- Vector2i(0, 0),
1815+ Vector2i::zero(),
1816 _("Compress widelands data files (maps, replays and savegames)"),
1817 "",
1818 0),
1819 write_syncstreams_(&box_saving_,
1820- Vector2i(0, 0),
1821+ Vector2i::zero(),
1822 _("Write syncstreams in network games to debug desyncs"),
1823 "",
1824 0),
1825
1826 // Game options
1827 auto_roadbuild_mode_(
1828- &box_game_, Vector2i(0, 0), _("Start building road after placing a flag")),
1829- show_workarea_preview_(&box_game_, Vector2i(0, 0), _("Show buildings area preview")),
1830+ &box_game_, Vector2i::zero(), _("Start building road after placing a flag")),
1831+ show_workarea_preview_(&box_game_, Vector2i::zero(), _("Show buildings area preview")),
1832 transparent_chat_(
1833- &box_game_, Vector2i(0, 0), _("Show in-game chat with transparent background"), "", 0),
1834+ &box_game_, Vector2i::zero(), _("Show in-game chat with transparent background"), "", 0),
1835
1836 /** TRANSLATORS: A watchwindow is a window where you keep watching an object or a map region,*/
1837 /** TRANSLATORS: and it also lets you jump to it on the map. */
1838- single_watchwin_(&box_game_, Vector2i(0, 0), _("Use single watchwindow mode")),
1839+ single_watchwin_(&box_game_, Vector2i::zero(), _("Use single watchwindow mode")),
1840 os_(opt) {
1841 // Set up UI Elements
1842 title_.set_fontsize(UI_FONT_SIZE_BIG);
1843
1844=== modified file 'src/wlapplication.cc'
1845--- src/wlapplication.cc 2017-05-11 10:45:44 +0000
1846+++ src/wlapplication.cc 2017-05-13 13:15:21 +0000
1847@@ -283,9 +283,9 @@
1848 game_type_(NONE),
1849 mouse_swapped_(false),
1850 faking_middle_mouse_button_(false),
1851- mouse_position_(0, 0),
1852+ mouse_position_(Vector2i::zero()),
1853 mouse_locked_(0),
1854- mouse_compensate_warp_(0, 0),
1855+ mouse_compensate_warp_(Vector2i::zero()),
1856 should_die_(false),
1857 #ifdef _WIN32
1858 homedir_(FileSystem::get_homedir() + "\\.widelands"),
1859@@ -469,7 +469,7 @@
1860 case SDL_MOUSEMOTION:
1861 ev.motion.xrel += mouse_compensate_warp_.x;
1862 ev.motion.yrel += mouse_compensate_warp_.y;
1863- mouse_compensate_warp_ = Vector2i(0, 0);
1864+ mouse_compensate_warp_ = Vector2i::zero();
1865
1866 if (mouse_locked_) {
1867 warp_mouse(mouse_position_);
1868@@ -665,7 +665,7 @@
1869 void WLApplication::warp_mouse(const Vector2i position) {
1870 mouse_position_ = position;
1871
1872- Vector2i cur_position;
1873+ Vector2i cur_position = Vector2i::zero();
1874 SDL_GetMouseState(&cur_position.x, &cur_position.y);
1875 if (cur_position != position) {
1876 mouse_compensate_warp_ += cur_position - position;
1877
1878=== modified file 'src/wui/chatoverlay.cc'
1879--- src/wui/chatoverlay.cc 2017-01-25 18:55:59 +0000
1880+++ src/wui/chatoverlay.cc 2017-05-13 13:15:21 +0000
1881@@ -183,10 +183,10 @@
1882 const int width = std::min<int>(get_w(), im->width());
1883
1884 if (!m->transparent_) {
1885- dst.fill_rect(Rectf(0, top, width, height), RGBAColor(50, 50, 50, 128), BlendMode::Default);
1886+ dst.fill_rect(Recti(0, top, width, height), RGBAColor(50, 50, 50, 128), BlendMode::Default);
1887 }
1888 int32_t topcrop = im->height() - height;
1889 Recti cropRect(0, topcrop, width, height);
1890
1891- dst.blitrect(Vector2f(0, top), im, cropRect);
1892+ dst.blitrect(Vector2i(0, top), im, cropRect);
1893 }
1894
1895=== modified file 'src/wui/field_overlay_manager.h'
1896--- src/wui/field_overlay_manager.h 2017-01-25 18:55:59 +0000
1897+++ src/wui/field_overlay_manager.h 2017-05-13 13:15:21 +0000
1898@@ -60,7 +60,7 @@
1899 }
1900
1901 const Image* pic;
1902- Vector2i hotspot;
1903+ Vector2i hotspot = Vector2i::zero();
1904 };
1905
1906 /// A function returning Field::nodecaps() for the build overlay. This can be
1907@@ -118,7 +118,7 @@
1908 }
1909 std::set<OverlayId> overlay_ids;
1910 const Image* pic;
1911- Vector2i hotspot;
1912+ Vector2i hotspot = Vector2i::zero();
1913 int level;
1914 };
1915
1916
1917=== modified file 'src/wui/game_tips.cc'
1918--- src/wui/game_tips.cc 2017-01-25 18:55:59 +0000
1919+++ src/wui/game_tips.cc 2017-05-13 13:15:21 +0000
1920@@ -107,11 +107,11 @@
1921
1922 uint16_t w = pic_background->width();
1923 uint16_t h = pic_background->height();
1924- Vector2f pt((g_gr->get_xres() - w) / 2, (g_gr->get_yres() - h) / 2);
1925- Rectf tips_area(pt, w, h);
1926+ Vector2i pt((g_gr->get_xres() - w) / 2, (g_gr->get_yres() - h) / 2);
1927+ Recti tips_area(pt, w, h);
1928 rt.blit(pt, pic_background);
1929
1930 const Image* rendered_text = UI::g_fh1->render(as_game_tip(tips_[index].text), tips_area.w);
1931- rt.blit(tips_area.center() - Vector2f(rendered_text->width() / 2, rendered_text->height() / 2),
1932+ rt.blit(tips_area.center().cast<int>() - Vector2i(rendered_text->width() / 2, rendered_text->height() / 2),
1933 rendered_text);
1934 }
1935
1936=== modified file 'src/wui/general_statistics_menu.cc'
1937--- src/wui/general_statistics_menu.cc 2017-05-03 07:24:06 +0000
1938+++ src/wui/general_statistics_menu.cc 2017-05-13 13:15:21 +0000
1939@@ -129,64 +129,66 @@
1940
1941 UI::Radiobutton* btn;
1942
1943- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1944+ const Vector2i zero = Vector2i::zero();
1945+
1946+ radiogroup_.add_button(hbox2, zero,
1947 g_gr->images().get("images/wui/stats/genstats_landsize.png"), _("Land"),
1948 &btn);
1949 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1950
1951- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1952+ radiogroup_.add_button(hbox2, zero,
1953 g_gr->images().get("images/wui/stats/genstats_nrworkers.png"),
1954 _("Workers"), &btn);
1955 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1956
1957- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1958+ radiogroup_.add_button(hbox2, zero,
1959 g_gr->images().get("images/wui/stats/genstats_nrbuildings.png"),
1960 _("Buildings"), &btn);
1961 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1962
1963- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1964+ radiogroup_.add_button(hbox2, zero,
1965 g_gr->images().get("images/wui/stats/genstats_nrwares.png"), _("Wares"),
1966 &btn);
1967 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1968
1969- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1970+ radiogroup_.add_button(hbox2, zero,
1971 g_gr->images().get("images/wui/stats/genstats_productivity.png"),
1972 _("Productivity"), &btn);
1973 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1974
1975- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1976+ radiogroup_.add_button(hbox2, zero,
1977 g_gr->images().get("images/wui/stats/genstats_casualties.png"),
1978 _("Casualties"), &btn);
1979 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1980
1981- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1982+ radiogroup_.add_button(hbox2, zero,
1983 g_gr->images().get("images/wui/stats/genstats_kills.png"), _("Kills"),
1984 &btn);
1985 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1986
1987- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1988+ radiogroup_.add_button(hbox2, zero,
1989 g_gr->images().get("images/wui/stats/genstats_msites_lost.png"),
1990 _("Military buildings lost"), &btn);
1991 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1992
1993- radiogroup_.add_button(hbox2, Vector2i(0, 0),
1994+ radiogroup_.add_button(hbox2, zero,
1995 g_gr->images().get("images/wui/stats/genstats_msites_defeated.png"),
1996 _("Military buildings defeated"), &btn);
1997 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
1998
1999- radiogroup_.add_button(hbox2, Vector2i(0, 0),
2000+ radiogroup_.add_button(hbox2, zero,
2001 g_gr->images().get("images/wui/stats/genstats_civil_blds_lost.png"),
2002 _("Civilian buildings lost"), &btn);
2003 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
2004
2005- radiogroup_.add_button(hbox2, Vector2i(0, 0),
2006+ radiogroup_.add_button(hbox2, zero,
2007 g_gr->images().get("images/wui/stats/genstats_militarystrength.png"),
2008 _("Military"), &btn);
2009 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
2010
2011 if (hook) {
2012 radiogroup_.add_button(
2013- hbox2, Vector2i(0, 0), g_gr->images().get(cs_pic), cs_name.c_str(), &btn);
2014+ hbox2, zero, g_gr->images().get(cs_pic), cs_name.c_str(), &btn);
2015 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
2016 }
2017
2018
2019=== modified file 'src/wui/inputqueuedisplay.cc'
2020--- src/wui/inputqueuedisplay.cc 2017-01-25 18:55:59 +0000
2021+++ src/wui/inputqueuedisplay.cc 2017-05-13 13:15:21 +0000
2022@@ -131,12 +131,12 @@
2023 uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_);
2024 uint32_t nr_empty_to_draw = cache_size_ - nr_inputs_to_draw;
2025
2026- Vector2f point;
2027+ Vector2i point = Vector2i::zero();
2028 point.x = Border + (show_only_ ? 0 : CellWidth + CellSpacing);
2029 point.y = Border + (total_height_ - 2 * Border - WARE_MENU_PIC_HEIGHT) / 2;
2030
2031 for (; nr_inputs_to_draw; --nr_inputs_to_draw, point.x += CellWidth + CellSpacing) {
2032- dst.blitrect(Vector2f(point.x, point.y), icon_, Recti(0, 0, icon_->width(), icon_->height()),
2033+ dst.blitrect(Vector2i(point.x, point.y), icon_, Recti(0, 0, icon_->width(), icon_->height()),
2034 BlendMode::UseAlpha);
2035 }
2036 for (; nr_empty_to_draw; --nr_empty_to_draw, point.x += CellWidth + CellSpacing) {
2037
2038=== modified file 'src/wui/interactive_base.cc'
2039--- src/wui/interactive_base.cc 2017-03-03 18:13:55 +0000
2040+++ src/wui/interactive_base.cc 2017-05-13 13:15:21 +0000
2041@@ -358,8 +358,7 @@
2042 if (is_game) {
2043 const std::string gametime(gametimestring(egbase().get_gametime(), true));
2044 const std::string gametime_text = as_condensed(gametime);
2045- dst.blit(Vector2f(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha,
2046- UI::Align::kLeft);
2047+ dst.blit(Vector2i(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha);
2048
2049 static boost::format node_format("(%i, %i)");
2050 node_text = as_condensed((node_format % sel_.pos.node.x % sel_.pos.node.y).str());
2051@@ -370,9 +369,9 @@
2052 }
2053
2054 const Image* rendered_text = UI::g_fh1->render(node_text);
2055-
2056- dst.blit(Vector2f(get_w() - 5, get_h() - rendered_text->height() - 5), rendered_text,
2057- BlendMode::UseAlpha, UI::Align::kRight);
2058+ Vector2i point(get_w() - 5, get_h() - rendered_text->height() - 5);
2059+ UI::correct_for_align(UI::Align::kRight, rendered_text->width(), &point);
2060+ dst.blit(point, rendered_text, BlendMode::UseAlpha);
2061 }
2062
2063 // Blit FPS when playing a game in debug mode.
2064@@ -380,8 +379,8 @@
2065 static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");
2066 const Image* rendered_text = UI::g_fh1->render(as_condensed(
2067 (fps_format % (1000.0 / frametime_) % (1000.0 / (avg_usframetime_ / 1000))).str()));
2068- dst.blit(Vector2f((get_w() - rendered_text->width()) / 2, 5), rendered_text,
2069- BlendMode::UseAlpha, UI::Align::kLeft);
2070+ dst.blit(Vector2i((get_w() - rendered_text->width()) / 2, 5), rendered_text,
2071+ BlendMode::UseAlpha);
2072 }
2073 }
2074
2075
2076=== modified file 'src/wui/interactive_gamebase.cc'
2077--- src/wui/interactive_gamebase.cc 2017-02-28 16:00:20 +0000
2078+++ src/wui/interactive_gamebase.cc 2017-05-13 13:15:21 +0000
2079@@ -126,8 +126,10 @@
2080 }
2081
2082 if (!game_speed.empty()) {
2083- dst.blit(Vector2f(get_w() - 5, 5), UI::g_fh1->render(game_speed), BlendMode::UseAlpha,
2084- UI::Align::kRight);
2085+ Vector2i point(get_w() - 5, 5);
2086+ const Image* rendered_speed = UI::g_fh1->render(game_speed);
2087+ UI::correct_for_align(UI::Align::kRight, rendered_speed->width(), &point);
2088+ dst.blit(point, rendered_speed, BlendMode::UseAlpha);
2089 }
2090 }
2091 }
2092
2093=== modified file 'src/wui/itemwaresdisplay.cc'
2094--- src/wui/itemwaresdisplay.cc 2017-01-25 18:55:59 +0000
2095+++ src/wui/itemwaresdisplay.cc 2017-05-13 13:15:21 +0000
2096@@ -98,7 +98,7 @@
2097 void ItemWaresDisplay::draw(RenderTarget& dst) {
2098 const Widelands::TribeDescr& tribe(player().tribe());
2099
2100- dst.fill_rect(Rectf(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 0));
2101+ dst.fill_rect(Recti(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 0));
2102
2103 for (uint32_t idx = 0; idx < items_.size(); ++idx) {
2104 const Item& it = items_[idx];
2105@@ -117,7 +117,7 @@
2106 } else {
2107 y += IWD_WareBaseLine;
2108 if (tribe.get_ware_descr(it.index)->icon())
2109- dst.blit(Vector2f(x, y), tribe.get_ware_descr(it.index)->icon());
2110+ dst.blit(Vector2i(x, y), tribe.get_ware_descr(it.index)->icon());
2111 }
2112 }
2113 }
2114
2115=== modified file 'src/wui/mapview.cc'
2116--- src/wui/mapview.cc 2017-02-12 09:10:57 +0000
2117+++ src/wui/mapview.cc 2017-05-13 13:15:21 +0000
2118@@ -133,7 +133,7 @@
2119 const Vector2f center_point = center_point_t.value(dt);
2120 const Vector2f viewpoint = center_point - Vector2f(width * zoom / 2.f, height * zoom / 2.f);
2121 plan->push_back(MapView::TimestampedView{
2122- static_cast<uint32_t>(std::lround(start_time + dt)), MapView::View{viewpoint, zoom}});
2123+ static_cast<uint32_t>(std::lround(start_time + dt)), MapView::View(viewpoint, zoom)});
2124 }
2125 }
2126
2127@@ -194,7 +194,7 @@
2128 Vector2f(width * end.zoom / 2.f, height * end.zoom / 2.f);
2129 plan.push_back(
2130 MapView::TimestampedView{static_cast<uint32_t>(std::lround(start_time + duration_ms)),
2131- MapView::View{end_viewpoint, end.zoom}});
2132+ MapView::View(end_viewpoint, end.zoom)});
2133 return plan;
2134 }
2135
2136@@ -233,11 +233,11 @@
2137 plan.push_back(start);
2138 for (int i = 1; i < kNumKeyFrames - 2; i++) {
2139 float dt = (kShortAnimationMs / kNumKeyFrames) * i;
2140- plan.push_back(MapView::TimestampedMouse{
2141- static_cast<uint32_t>(std::lround(start.t + dt)), mouse_t.value(dt)});
2142+ plan.push_back(MapView::TimestampedMouse(
2143+ static_cast<uint32_t>(std::lround(start.t + dt)), mouse_t.value(dt)));
2144 }
2145- plan.push_back(MapView::TimestampedMouse{
2146- static_cast<uint32_t>(std::lround(start.t + kShortAnimationMs)), target.cast<float>()});
2147+ plan.push_back(MapView::TimestampedMouse(
2148+ static_cast<uint32_t>(std::lround(start.t + kShortAnimationMs)), target.cast<float>()));
2149 return plan;
2150 }
2151
2152@@ -299,7 +299,8 @@
2153 : UI::Panel(parent, x, y, w, h),
2154 renderer_(new GameRenderer()),
2155 intbase_(player),
2156- view_{Vector2f(0.f, 0.f), 1.f},
2157+ view_(),
2158+ last_mouse_pos_(Vector2i::zero()),
2159 dragging_(false) {
2160 }
2161
2162@@ -446,7 +447,7 @@
2163 const TimestampedView current = animation_target_view();
2164 const Rectf area = get_view_area(current.view, get_w(), get_h());
2165 const Vector2f target_view = pos - Vector2f(area.w / 2.f, area.h / 2.f);
2166- set_view(View{target_view, current.view.zoom}, transition);
2167+ set_view(View(target_view, current.view.zoom), transition);
2168 }
2169
2170 MapView::ViewArea MapView::view_area() const {
2171@@ -605,7 +606,7 @@
2172
2173 MapView::TimestampedMouse MapView::animation_target_mouse() const {
2174 if (mouse_plans_.empty()) {
2175- return TimestampedMouse{SDL_GetTicks(), get_mouse_position().cast<float>()};
2176+ return TimestampedMouse(SDL_GetTicks(), get_mouse_position().cast<float>());
2177 }
2178 return mouse_plans_.back().back();
2179 }
2180
2181=== modified file 'src/wui/mapview.h'
2182--- src/wui/mapview.h 2017-01-25 18:55:59 +0000
2183+++ src/wui/mapview.h 2017-05-13 13:15:21 +0000
2184@@ -71,6 +71,11 @@
2185 };
2186
2187 struct View {
2188+ View(Vector2f init_viewpoint, float init_zoom) : viewpoint(init_viewpoint), zoom(init_zoom) {
2189+ }
2190+ View() : View(Vector2f::zero(), 1.0f) {
2191+ }
2192+
2193 // Mappixel of top-left pixel of this MapView.
2194 Vector2f viewpoint;
2195
2196@@ -87,8 +92,12 @@
2197 };
2198
2199 struct TimestampedMouse {
2200+ TimestampedMouse(uint32_t init_t, Vector2f init_pixel) : t(init_t), pixel(init_pixel) {
2201+ }
2202+ TimestampedMouse() : t(0), pixel(Vector2f::zero()) {
2203+ }
2204 uint32_t t;
2205- Vector2f pixel;
2206+ Vector2f pixel = Vector2f::zero();
2207 };
2208
2209 MapView(UI::Panel* const parent,
2210
2211=== modified file 'src/wui/minimap.cc'
2212--- src/wui/minimap.cc 2017-02-12 09:10:57 +0000
2213+++ src/wui/minimap.cc 2017-05-13 13:15:21 +0000
2214@@ -52,7 +52,7 @@
2215 void MiniMap::View::draw(RenderTarget& dst) {
2216 minimap_image_ = draw_minimap(ibase_.egbase(), ibase_.get_player(), view_area_, *minimap_type_,
2217 *minimap_layers_ | MiniMapLayer::ViewWindow);
2218- dst.blit(Vector2f(), minimap_image_.get());
2219+ dst.blit(Vector2i::zero(), minimap_image_.get());
2220 }
2221
2222 /*
2223
2224=== modified file 'src/wui/plot_area.cc'
2225--- src/wui/plot_area.cc 2017-05-02 12:09:44 +0000
2226+++ src/wui/plot_area.cc 2017-05-13 13:15:21 +0000
2227@@ -176,12 +176,13 @@
2228 */
2229 void draw_value(const string& value,
2230 const RGBColor& color,
2231- const Vector2f& pos,
2232+ const Vector2i& pos,
2233 RenderTarget& dst) {
2234 const Image* pic = UI::g_fh1->render(ytick_text_style(value, color));
2235- Vector2f point(pos); // Un-const this
2236+ Vector2i point(pos); // Un-const this
2237+ UI::correct_for_align(UI::Align::kRight, pic->width(), &point);
2238 UI::center_vertically(pic->height(), &point);
2239- dst.blit(point, pic, BlendMode::UseAlpha, UI::Align::kRight);
2240+ dst.blit(point, pic, BlendMode::UseAlpha);
2241 }
2242
2243 uint32_t calc_plot_x_max_ticks(int32_t plot_width) {
2244@@ -229,6 +230,7 @@
2245 }
2246 // Make sure that we always have a tick
2247 how_many_ticks = std::max(how_many_ticks, 1u);
2248+
2249 // Make sure we haven't more ticks than we have space for -> avoid overlap
2250 how_many_ticks = std::min(how_many_ticks, calc_plot_x_max_ticks(inner_w));
2251
2252@@ -264,9 +266,10 @@
2253 // over the number, not to the left
2254 const Image* xtick = UI::g_fh1->render(
2255 xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
2256- Vector2f pos(posx, inner_h - kSpaceBottom + 10);
2257+ Vector2i pos(posx, inner_h - kSpaceBottom + 10);
2258+ UI::correct_for_align(UI::Align::kCenter, xtick->width(), &pos);
2259 UI::center_vertically(xtick->height(), &pos);
2260- dst.blit(pos, xtick, BlendMode::UseAlpha, UI::Align::kCenter);
2261+ dst.blit(pos, xtick, BlendMode::UseAlpha);
2262
2263 posx -= sub;
2264 }
2265@@ -282,9 +285,9 @@
2266
2267 // print the used unit
2268 const Image* xtick = UI::g_fh1->render(xtick_text_style(get_generic_unit_name(unit)));
2269- Vector2f pos(2, kSpacing + 2);
2270+ Vector2i pos(2, kSpacing + 2);
2271 UI::center_vertically(xtick->height(), &pos);
2272- dst.blit(pos, xtick, BlendMode::UseAlpha, UI::Align::kLeft);
2273+ dst.blit(pos, xtick, BlendMode::UseAlpha);
2274 }
2275
2276 } // namespace
2277@@ -459,8 +462,8 @@
2278 * Draw this. This is the main function
2279 */
2280 void WuiPlotArea::draw(RenderTarget& dst) {
2281- dst.tile(Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
2282- Vector2i(0, 0));
2283+ dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
2284+ Vector2i::zero());
2285 draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
2286 }
2287
2288@@ -482,7 +485,7 @@
2289
2290 // print the maximal value into the top right corner
2291 draw_value(yscale_label, RGBColor(60, 125, 0),
2292- Vector2f(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);
2293+ Vector2i(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);
2294 }
2295
2296 /**
2297@@ -671,8 +674,8 @@
2298 void DifferentialPlotArea::draw(RenderTarget& dst) {
2299
2300 // first, tile the background
2301- dst.tile(Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
2302- Vector2i(0, 0));
2303+ dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
2304+ Vector2i::zero());
2305
2306 // yoffset of the zero line
2307 float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;
2308@@ -687,7 +690,7 @@
2309
2310 // Print the min value
2311 draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),
2312- Vector2f(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);
2313+ Vector2i(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);
2314 }
2315
2316 /**
2317
2318=== modified file 'src/wui/soldierlist.cc'
2319--- src/wui/soldierlist.cc 2017-02-25 13:27:40 +0000
2320+++ src/wui/soldierlist.cc 2017-05-13 13:15:21 +0000
2321@@ -82,7 +82,7 @@
2322 Widelands::OPtr<Soldier> soldier;
2323 uint32_t row;
2324 uint32_t col;
2325- Vector2i pos;
2326+ Vector2i pos = Vector2i::zero();
2327
2328 /**
2329 * Keep track of how we last rendered this soldier,
2330@@ -281,11 +281,11 @@
2331 uint32_t fullrows = capacity / kMaxColumns;
2332
2333 if (fullrows) {
2334- dst.fill_rect(Rectf(0.f, 0.f, get_w(), icon_height_ * fullrows), RGBAColor(0, 0, 0, 0));
2335+ dst.fill_rect(Recti(0, 0, get_w(), icon_height_ * fullrows), RGBAColor(0, 0, 0, 0));
2336 }
2337 if (capacity % kMaxColumns) {
2338 dst.fill_rect(
2339- Rectf(0.f, icon_height_ * fullrows, icon_width_ * (capacity % kMaxColumns), icon_height_),
2340+ Recti(0, icon_height_ * fullrows, icon_width_ * (capacity % kMaxColumns), icon_height_),
2341 RGBAColor(0, 0, 0, 0));
2342 }
2343
2344@@ -297,7 +297,7 @@
2345
2346 constexpr float kNoZoom = 1.f;
2347 soldier->draw_info_icon(
2348- icon.pos.cast<float>() + Vector2f(kIconBorder, kIconBorder), kNoZoom, false, &dst);
2349+ icon.pos + Vector2i(kIconBorder, kIconBorder), kNoZoom, false, &dst);
2350 }
2351 }
2352
2353@@ -398,7 +398,7 @@
2354
2355 bool can_act = igbase_.can_act(building_.owner().player_number());
2356 if (upcast(Widelands::MilitarySite, ms, &building)) {
2357- soldier_preference_.add_button(buttons, Vector2i(0, 0),
2358+ soldier_preference_.add_button(buttons, Vector2i::zero(),
2359 g_gr->images().get("images/wui/buildings/prefer_rookies.png"),
2360 _("Prefer Rookies"));
2361 soldier_preference_.add_button(buttons, Vector2i(32, 0),
2362
2363=== modified file 'src/wui/warehousewindow.cc'
2364--- src/wui/warehousewindow.cc 2017-02-27 18:28:39 +0000
2365+++ src/wui/warehousewindow.cc 2017-05-13 13:15:21 +0000
2366@@ -94,7 +94,7 @@
2367 }
2368 assert(pic != nullptr);
2369
2370- dst.blit(ware_position(ware).cast<float>(), pic);
2371+ dst.blit(ware_position(ware), pic);
2372 }
2373
2374 /**
2375
2376=== modified file 'src/wui/waresdisplay.cc'
2377--- src/wui/waresdisplay.cc 2017-04-30 08:40:08 +0000
2378+++ src/wui/waresdisplay.cc 2017-05-13 13:15:21 +0000
2379@@ -320,20 +320,20 @@
2380 "images/wui/ware_list_bg.png");
2381 uint16_t w = bgpic->width();
2382
2383- const Vector2f p = ware_position(id).cast<float>();
2384+ const Vector2i p = ware_position(id);
2385 dst.blit(p, bgpic);
2386
2387 const Image* icon = type_ == Widelands::wwWORKER ? tribe_.get_worker_descr(id)->icon() :
2388 tribe_.get_ware_descr(id)->icon();
2389
2390- dst.blit(p + Vector2f((w - WARE_MENU_PIC_WIDTH) / 2.f, 1.f), icon);
2391+ dst.blit(p + Vector2i((w - WARE_MENU_PIC_WIDTH) / 2, 1), icon);
2392
2393- dst.fill_rect(Rectf(p + Vector2f(0.f, WARE_MENU_PIC_HEIGHT), w, WARE_MENU_INFO_SIZE),
2394+ dst.fill_rect(Recti(p + Vector2i(0, WARE_MENU_PIC_HEIGHT), w, WARE_MENU_INFO_SIZE),
2395 info_color_for_ware(id));
2396
2397 const Image* text = UI::g_fh1->render(as_waresinfo(info_for_ware(id)));
2398 if (text) // might be zero when there is no info text.
2399- dst.blit(p + Vector2f(w - text->width() - 1,
2400+ dst.blit(p + Vector2i(w - text->width() - 1,
2401 WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + 1 - text->height()),
2402 text);
2403 }

Subscribers

People subscribed via source and target branches

to status/vote changes: