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
=== modified file 'src/base/vector.h'
--- src/base/vector.h 2017-01-25 18:55:59 +0000
+++ src/base/vector.h 2017-05-13 13:15:21 +0000
@@ -28,7 +28,10 @@
28template <typename T> struct Vector2 {28template <typename T> struct Vector2 {
29 Vector2(const T& px, const T& py) : x(px), y(py) {29 Vector2(const T& px, const T& py) : x(px), y(py) {
30 }30 }
31 Vector2() : Vector2(T(0), T(0)) {31 Vector2() = delete;
32
33 static Vector2 zero() {
34 return Vector2(T(0), T(0));
32 }35 }
3336
34 // Returns an invalid point.37 // Returns an invalid point.
3538
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2017-01-25 18:55:59 +0000
+++ src/editor/editorinteractive.cc 2017-05-13 13:15:21 +0000
@@ -636,7 +636,7 @@
636 }636 }
637637
638 // Make sure that we will start at coordinates (0,0).638 // Make sure that we will start at coordinates (0,0).
639 set_view(MapView::View{Vector2f(0, 0), 1.f}, Transition::Jump);639 set_view(MapView::View{Vector2f::zero(), 1.f}, Transition::Jump);
640 set_sel_pos(Widelands::NodeAndTriangle<>(640 set_sel_pos(Widelands::NodeAndTriangle<>(
641 Widelands::Coords(0, 0),641 Widelands::Coords(0, 0),
642 Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TCoords<>::D)));642 Widelands::TCoords<>(Widelands::Coords(0, 0), Widelands::TCoords<>::D)));
643643
=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc'
--- src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-03-01 11:23:54 +0000
+++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2017-05-13 13:15:21 +0000
@@ -89,7 +89,7 @@
8989
90 /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */90 /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
91 cb_dont_localize_mapnames_ =91 cb_dont_localize_mapnames_ =
92 new UI::Checkbox(vbox, Vector2i(0, 0), _("Show original map names"));92 new UI::Checkbox(vbox, Vector2i::zero(), _("Show original map names"));
93 cb_dont_localize_mapnames_->set_state(false);93 cb_dont_localize_mapnames_->set_state(false);
94 vbox->add_space(2 * padding_);94 vbox->add_space(2 * padding_);
95 vbox->add(cb_dont_localize_mapnames_, UI::Box::Resizing::kFullSize);95 vbox->add(cb_dont_localize_mapnames_, UI::Box::Resizing::kFullSize);
9696
=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
--- src/editor/ui_menus/main_menu_map_options.cc 2017-02-26 11:00:07 +0000
+++ src/editor/ui_menus/main_menu_map_options.cc 2017-05-13 13:15:21 +0000
@@ -230,7 +230,7 @@
230 std::string tag,230 std::string tag,
231 std::string displ_name) {231 std::string displ_name) {
232 UI::Box* box = new UI::Box(parent, 0, 0, UI::Box::Horizontal, max_w_, checkbox_space_, 0);232 UI::Box* box = new UI::Box(parent, 0, 0, UI::Box::Horizontal, max_w_, checkbox_space_, 0);
233 UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);233 UI::Checkbox* cb = new UI::Checkbox(box, Vector2i::zero(), displ_name);
234 box->add(cb, UI::Box::Resizing::kFullSize);234 box->add(cb, UI::Box::Resizing::kFullSize);
235 box->add_space(checkbox_space_);235 box->add_space(checkbox_space_);
236 parent->add(box);236 parent->add(box);
237237
=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
--- src/editor/ui_menus/main_menu_random_map.cc 2017-02-26 11:00:07 +0000
+++ src/editor/ui_menus/main_menu_random_map.cc 2017-05-13 13:15:21 +0000
@@ -188,7 +188,7 @@
188 resources_label_.get_h(),188 resources_label_.get_h(),
189 (boost::format(_("%i %%")) % mountainsval_).str(),189 (boost::format(_("%i %%")) % mountainsval_).str(),
190 UI::Align::kCenter),190 UI::Align::kCenter),
191 island_mode_(&box_, Vector2i(0, 0), _("Island mode")),191 island_mode_(&box_, Vector2i::zero(), _("Island mode")),
192 // Geeky stuff192 // Geeky stuff
193 map_number_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_),193 map_number_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, margin_),
194 map_number_label_(&map_number_box_, 0, 0, _("Random Number:")),194 map_number_label_(&map_number_box_, 0, 0, _("Random Number:")),
195195
=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-02-25 13:27:40 +0000
+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-05-13 13:15:21 +0000
@@ -100,7 +100,7 @@
100100
101 for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) {101 for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) {
102 const Widelands::ResourceDescription& resource = *world.get_resource(i);102 const Widelands::ResourceDescription& resource = *world.get_resource(i);
103 radiogroup_.add_button(&resources_box_, Vector2i(0, 0),103 radiogroup_.add_button(&resources_box_, Vector2i::zero(),
104 g_gr->images().get(resource.representative_image()),104 g_gr->images().get(resource.representative_image()),
105 resource.descname());105 resource.descname());
106 resources_box_.add(radiogroup_.get_first_button(), UI::Box::Resizing::kFillSpace);106 resources_box_.add(radiogroup_.get_first_button(), UI::Box::Resizing::kFillSpace);
107107
=== modified file 'src/editor/ui_menus/tool_place_critter_options_menu.cc'
--- src/editor/ui_menus/tool_place_critter_options_menu.cc 2017-01-25 18:55:59 +0000
+++ src/editor/ui_menus/tool_place_critter_options_menu.cc 2017-05-13 13:15:21 +0000
@@ -38,7 +38,7 @@
38UI::Checkbox* create_critter_checkbox(UI::Panel* parent,38UI::Checkbox* create_critter_checkbox(UI::Panel* parent,
39 const Widelands::CritterDescr& critter_descr) {39 const Widelands::CritterDescr& critter_descr) {
40 const Image* pic = critter_descr.representative_image();40 const Image* pic = critter_descr.representative_image();
41 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), pic, critter_descr.descname());41 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), pic, critter_descr.descname());
42 const int kMinClickableArea = 24;42 const int kMinClickableArea = 24;
43 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),43 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),
44 std::max<int>(pic->height(), kMinClickableArea));44 std::max<int>(pic->height(), kMinClickableArea));
4545
=== modified file 'src/editor/ui_menus/tool_place_immovable_options_menu.cc'
--- src/editor/ui_menus/tool_place_immovable_options_menu.cc 2017-01-25 18:55:59 +0000
+++ src/editor/ui_menus/tool_place_immovable_options_menu.cc 2017-05-13 13:15:21 +0000
@@ -39,7 +39,7 @@
3939
40UI::Checkbox* create_immovable_checkbox(UI::Panel* parent, const ImmovableDescr& immovable_descr) {40UI::Checkbox* create_immovable_checkbox(UI::Panel* parent, const ImmovableDescr& immovable_descr) {
41 const Image* pic = immovable_descr.representative_image();41 const Image* pic = immovable_descr.representative_image();
42 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), pic, immovable_descr.descname());42 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), pic, immovable_descr.descname());
43 const int kMinClickableArea = 24;43 const int kMinClickableArea = 24;
44 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),44 cb->set_desired_size(std::max<int>(pic->width(), kMinClickableArea),
45 std::max<int>(pic->height(), kMinClickableArea));45 std::max<int>(pic->height(), kMinClickableArea));
4646
=== modified file 'src/editor/ui_menus/tool_set_terrain_options_menu.cc'
--- src/editor/ui_menus/tool_set_terrain_options_menu.cc 2017-01-25 18:55:59 +0000
+++ src/editor/ui_menus/tool_set_terrain_options_menu.cc 2017-05-13 13:15:21 +0000
@@ -79,7 +79,7 @@
79 .str();79 .str();
8080
81 std::unique_ptr<const Image>& image = offscreen_images->back();81 std::unique_ptr<const Image>& image = offscreen_images->back();
82 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i(0, 0), image.get(), tooltip);82 UI::Checkbox* cb = new UI::Checkbox(parent, Vector2i::zero(), image.get(), tooltip);
83 cb->set_desired_size(image->width() + 1, image->height() + 1);83 cb->set_desired_size(image->width() + 1, image->height() + 1);
84 return cb;84 return cb;
85}85}
8686
=== modified file 'src/game_io/game_interactive_player_packet.cc'
--- src/game_io/game_interactive_player_packet.cc 2017-01-25 18:55:59 +0000
+++ src/game_io/game_interactive_player_packet.cc 2017-05-13 13:15:21 +0000
@@ -70,7 +70,7 @@
70 if (player_number > max)70 if (player_number > max)
71 throw GameDataError("The game has no players!");71 throw GameDataError("The game has no players!");
72 }72 }
73 Vector2f center_map_pixel;73 Vector2f center_map_pixel = Vector2f::zero();
74 if (packet_version <= 3) {74 if (packet_version <= 3) {
75 center_map_pixel.x = fr.unsigned_16();75 center_map_pixel.x = fr.unsigned_16();
76 center_map_pixel.y = fr.unsigned_16();76 center_map_pixel.y = fr.unsigned_16();
7777
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2017-05-03 07:24:06 +0000
+++ src/graphic/animation.cc 2017-05-13 13:15:21 +0000
@@ -91,7 +91,7 @@
91 uint32_t current_frame(uint32_t time) const;91 uint32_t current_frame(uint32_t time) const;
9292
93 uint32_t frametime_;93 uint32_t frametime_;
94 Vector2i hotspot_;94 Vector2i hotspot_ = Vector2i::zero();
95 bool hasplrclrs_;95 bool hasplrclrs_;
96 std::vector<std::string> image_files_;96 std::vector<std::string> image_files_;
97 std::vector<std::string> pc_mask_image_files_;97 std::vector<std::string> pc_mask_image_files_;
9898
=== modified file 'src/graphic/font_handler.cc'
--- src/graphic/font_handler.cc 2017-02-28 20:07:07 +0000
+++ src/graphic/font_handler.cc 2017-05-13 13:15:21 +0000
@@ -54,9 +54,9 @@
54 int caret_x = style.calc_bare_width(text.substr(0, caret_offset));54 int caret_x = style.calc_bare_width(text.substr(0, caret_offset));
5555
56 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");56 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
57 Vector2f caretpt;57 Vector2i caretpt = Vector2i::zero();
58 caretpt.x = dstpoint.x + caret_x + LINE_MARGIN - caret_image->width();58 caretpt.x = dstpoint.x + caret_x + LINE_MARGIN - caret_image->width();
59 caretpt.y = dstpoint.y + (style.font->height() - caret_image->height()) / 2.f;59 caretpt.y = dstpoint.y + (style.font->height() - caret_image->height()) / 2;
60 dst.blit(caretpt, caret_image);60 dst.blit(caretpt, caret_image);
61}61}
6262
@@ -203,7 +203,7 @@
203 */203 */
204void FontHandler::draw_text(RenderTarget& dst,204void FontHandler::draw_text(RenderTarget& dst,
205 const TextStyle& style,205 const TextStyle& style,
206 Vector2i dstpoint_i,206 Vector2i dstpoint,
207 const std::string& text,207 const std::string& text,
208 Align align,208 Align align,
209 uint32_t caret) {209 uint32_t caret) {
@@ -213,14 +213,13 @@
213 copytext = i18n::make_ligatures(copytext.c_str());213 copytext = i18n::make_ligatures(copytext.c_str());
214 const LineCacheEntry& lce = d->get_line(style, copytext);214 const LineCacheEntry& lce = d->get_line(style, copytext);
215215
216 Vector2f dstpoint = dstpoint_i.cast<float>();
217 UI::correct_for_align(align, lce.width + 2 * LINE_MARGIN, &dstpoint);216 UI::correct_for_align(align, lce.width + 2 * LINE_MARGIN, &dstpoint);
218217
219 if (lce.image)218 if (lce.image)
220 dst.blit(Vector2f(dstpoint.x + LINE_MARGIN, dstpoint.y), lce.image.get());219 dst.blit(Vector2i(dstpoint.x + LINE_MARGIN, dstpoint.y), lce.image.get());
221220
222 if (caret <= copytext.size())221 if (caret <= copytext.size())
223 draw_caret(dst, style, dstpoint, copytext, caret);222 draw_caret(dst, style, dstpoint.cast<float>(), copytext, caret);
224}223}
225224
226/**225/**
@@ -233,7 +232,7 @@
233 const LineCacheEntry& lce = d->get_line(style, text);232 const LineCacheEntry& lce = d->get_line(style, text);
234233
235 if (lce.image) {234 if (lce.image) {
236 dst.blit(dstpoint.cast<float>(), lce.image.get());235 dst.blit(dstpoint, lce.image.get());
237 }236 }
238237
239 return lce.width;238 return lce.width;
240239
=== modified file 'src/graphic/gl/fields_to_draw.h'
--- src/graphic/gl/fields_to_draw.h 2017-01-25 18:55:59 +0000
+++ src/graphic/gl/fields_to_draw.h 2017-05-13 13:15:21 +0000
@@ -43,15 +43,15 @@
43 Widelands::Coords geometric_coords; // geometric coordinates (i.e. map coordinates that can43 Widelands::Coords geometric_coords; // geometric coordinates (i.e. map coordinates that can
44 // be out of bounds).44 // be out of bounds).
45 Widelands::FCoords fcoords; // The normalized coords and the field this is refering to.45 Widelands::FCoords fcoords; // The normalized coords and the field this is refering to.
46 Vector2f gl_position; // GL Position of this field.46 Vector2f gl_position = Vector2f::zero(); // GL Position of this field.
4747
48 // Surface pixel this will be plotted on.48 // Surface pixel this will be plotted on.
49 Vector2f surface_pixel;49 Vector2f surface_pixel = Vector2f::zero();
5050
51 // Rendertarget pixel this will be plotted on. This is only different by51 // Rendertarget pixel this will be plotted on. This is only different by
52 // the Rendertarget::get_rect().origin() of the view window.52 // the Rendertarget::get_rect().origin() of the view window.
53 Vector2f rendertarget_pixel;53 Vector2f rendertarget_pixel = Vector2f::zero();
54 Vector2f texture_coords; // Texture coordinates.54 Vector2f texture_coords = Vector2f::zero(); // Texture coordinates.
55 float brightness; // brightness of the pixel55 float brightness; // brightness of the pixel
5656
57 // The next values are not necessarily the true data of this field, but57 // The next values are not necessarily the true data of this field, but
5858
=== modified file 'src/graphic/minimap_renderer.cc'
--- src/graphic/minimap_renderer.cc 2017-01-25 18:55:59 +0000
+++ src/graphic/minimap_renderer.cc 2017-05-13 13:15:21 +0000
@@ -97,7 +97,7 @@
97 const int half_height =97 const int half_height =
98 round_up_to_nearest_even(std::ceil(view_area.h / kTriangleHeight / divider));98 round_up_to_nearest_even(std::ceil(view_area.h / kTriangleHeight / divider));
9999
100 Vector2i center_pixel;100 Vector2i center_pixel = Vector2i::zero();
101 switch (minimap_type) {101 switch (minimap_type) {
102 case MiniMapType::kStaticViewWindow:102 case MiniMapType::kStaticViewWindow:
103 center_pixel = Vector2i(texture->width() / 2, texture->height() / 2);103 center_pixel = Vector2i(texture->width() / 2, texture->height() / 2);
@@ -203,7 +203,7 @@
203 const Rectf& view_area,203 const Rectf& view_area,
204 MiniMapType minimap_type,204 MiniMapType minimap_type,
205 const bool zoom) {205 const bool zoom) {
206 Vector2f top_left;206 Vector2f top_left = Vector2f::zero();
207 switch (minimap_type) {207 switch (minimap_type) {
208 case MiniMapType::kStaticViewWindow:208 case MiniMapType::kStaticViewWindow:
209 top_left =209 top_left =
@@ -212,7 +212,7 @@
212 break;212 break;
213213
214 case MiniMapType::kStaticMap:214 case MiniMapType::kStaticMap:
215 top_left = Vector2f(0., 0.);215 top_left = Vector2f::zero();
216 break;216 break;
217 }217 }
218218
@@ -242,7 +242,7 @@
242 // Center the view on the middle of the 'view_area'.242 // Center the view on the middle of the 'view_area'.
243 const bool zoom = layers & MiniMapLayer::Zoom2;243 const bool zoom = layers & MiniMapLayer::Zoom2;
244 Vector2f top_left =244 Vector2f top_left =
245 minimap_pixel_to_mappixel(map, Vector2i(0, 0), view_area, minimap_type, zoom);245 minimap_pixel_to_mappixel(map, Vector2i::zero(), view_area, minimap_type, zoom);
246 const Coords node =246 const Coords node =
247 MapviewPixelFunctions::calc_node_and_triangle(map, top_left.x, top_left.y).node;247 MapviewPixelFunctions::calc_node_and_triangle(map, top_left.x, top_left.y).node;
248248
249249
=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc 2017-02-28 20:07:07 +0000
+++ src/graphic/rendertarget.cc 2017-05-13 13:15:21 +0000
@@ -23,7 +23,6 @@
23#include "graphic/animation.h"23#include "graphic/animation.h"
24#include "graphic/graphic.h"24#include "graphic/graphic.h"
25#include "graphic/surface.h"25#include "graphic/surface.h"
26#include "graphic/text_layout.h"
2726
28/**27/**
29 * Build a render target for the given surface.28 * Build a render target for the given surface.
@@ -119,21 +118,21 @@
119/**118/**
120 * Clip against window and pass those primitives along to the bitmap.119 * Clip against window and pass those primitives along to the bitmap.
121 */120 */
122void RenderTarget::draw_rect(const Rectf& rect, const RGBColor& clr) {121void RenderTarget::draw_rect(const Recti& rect, const RGBColor& clr) {
123 Rectf r(rect);122 Rectf r(rect.cast<float>());
124 if (clip(r)) {123 if (clip(r)) {
125 ::draw_rect(r, clr, surface_);124 ::draw_rect(r, clr, surface_);
126 }125 }
127}126}
128127
129void RenderTarget::fill_rect(const Rectf& rect, const RGBAColor& clr, BlendMode blend_mode) {128void RenderTarget::fill_rect(const Recti& rect, const RGBAColor& clr, BlendMode blend_mode) {
130 Rectf r(rect);129 Rectf r(rect.cast<float>());
131 if (clip(r))130 if (clip(r))
132 surface_->fill_rect(r, clr, blend_mode);131 surface_->fill_rect(r, clr, blend_mode);
133}132}
134133
135void RenderTarget::brighten_rect(const Rectf& rect, int32_t factor) {134void RenderTarget::brighten_rect(const Recti& rect, int32_t factor) {
136 Rectf r(rect);135 Rectf r(rect.cast<float>());
137 if (clip(r))136 if (clip(r))
138 surface_->brighten_rect(r, factor);137 surface_->brighten_rect(r, factor);
139}138}
@@ -143,15 +142,11 @@
143 *142 *
144 * This blit function copies the pixels to the destination surface.143 * This blit function copies the pixels to the destination surface.
145 */144 */
146void RenderTarget::blit(const Vector2f& dst,145void RenderTarget::blit(const Vector2i& dst,
147 const Image* image,146 const Image* image,
148 BlendMode blend_mode,147 BlendMode blend_mode) {
149 UI::Align align) {148 Rectf source_rect(Vector2i::zero(), image->width(), image->height());
150 Vector2f destination_point(dst);149 Rectf destination_rect(dst.x, dst.y, source_rect.w, source_rect.h);
151 UI::correct_for_align(align, image->width(), &destination_point);
152
153 Rectf source_rect(Vector2i(0, 0), image->width(), image->height());
154 Rectf destination_rect(destination_point.x, destination_point.y, source_rect.w, source_rect.h);
155150
156 if (to_surface_geometry(&destination_rect, &source_rect)) {151 if (to_surface_geometry(&destination_rect, &source_rect)) {
157 // I seem to remember seeing 1. a lot in blitting calls.152 // I seem to remember seeing 1. a lot in blitting calls.
@@ -160,15 +155,11 @@
160 }155 }
161}156}
162157
163void RenderTarget::blit_monochrome(const Vector2f& dst,158void RenderTarget::blit_monochrome(const Vector2i& dst,
164 const Image* image,159 const Image* image,
165 const RGBAColor& blend_mode,160 const RGBAColor& blend_mode) {
166 UI::Align align) {161 Rectf source_rect(Vector2i::zero(), image->width(), image->height());
167 Vector2f destination_point(dst);162 Rectf destination_rect(dst.x, dst.y, source_rect.w, source_rect.h);
168 UI::correct_for_align(align, image->width(), &destination_point);
169
170 Rectf source_rect(Vector2i(0, 0), image->width(), image->height());
171 Rectf destination_rect(destination_point.x, destination_point.y, source_rect.w, source_rect.h);
172163
173 if (to_surface_geometry(&destination_rect, &source_rect)) {164 if (to_surface_geometry(&destination_rect, &source_rect)) {
174 surface_->blit_monochrome(destination_rect, *image, source_rect, blend_mode);165 surface_->blit_monochrome(destination_rect, *image, source_rect, blend_mode);
@@ -178,7 +169,7 @@
178/**169/**
179 * Like \ref blit, but use only a sub-rectangle of the source image.170 * Like \ref blit, but use only a sub-rectangle of the source image.
180 */171 */
181void RenderTarget::blitrect(const Vector2f& dst,172void RenderTarget::blitrect(const Vector2i& dst,
182 const Image* image,173 const Image* image,
183 const Recti& gsrcrc,174 const Recti& gsrcrc,
184 BlendMode blend_mode) {175 BlendMode blend_mode) {
185176
=== modified file 'src/graphic/rendertarget.h'
--- src/graphic/rendertarget.h 2017-02-23 19:38:51 +0000
+++ src/graphic/rendertarget.h 2017-05-13 13:15:21 +0000
@@ -58,22 +58,20 @@
58 int32_t height() const;58 int32_t height() const;
5959
60 void draw_line_strip(const std::vector<Vector2f>& points, const RGBColor& color, float width);60 void draw_line_strip(const std::vector<Vector2f>& points, const RGBColor& color, float width);
61 void draw_rect(const Rectf&, const RGBColor&);61 void draw_rect(const Recti&, const RGBColor&);
62 void fill_rect(const Rectf&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);62 void fill_rect(const Recti&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
63 void brighten_rect(const Rectf&, int32_t factor);63 void brighten_rect(const Recti&, int32_t factor);
6464
65 void blit(const Vector2f& dst,65 void blit(const Vector2i& dst,
66 const Image* image,66 const Image* image,
67 BlendMode blend_mode = BlendMode::UseAlpha,67 BlendMode blend_mode = BlendMode::UseAlpha);
68 UI::Align = UI::Align::kLeft);
6968
70 // Like blit. See MonochromeBlitProgram for details.69 // Like blit. See MonochromeBlitProgram for details.
71 void blit_monochrome(const Vector2f& dst,70 void blit_monochrome(const Vector2i& dst,
72 const Image* image,71 const Image* image,
73 const RGBAColor& blend_mode,72 const RGBAColor& blend_mode);
74 UI::Align = UI::Align::kLeft);
7573
76 void blitrect(const Vector2f& dst,74 void blitrect(const Vector2i& dst,
77 const Image* image,75 const Image* image,
78 const Recti& src,76 const Recti& src,
79 BlendMode blend_mode = BlendMode::UseAlpha);77 BlendMode blend_mode = BlendMode::UseAlpha);
@@ -147,7 +145,7 @@
147 /// The current clip rectangle145 /// The current clip rectangle
148 Recti rect_;146 Recti rect_;
149 /// Drawing offset147 /// Drawing offset
150 Vector2i offset_;148 Vector2i offset_ = Vector2i::zero();
151};149};
152150
153#endif // end of include guard: WL_GRAPHIC_RENDERTARGET_H151#endif // end of include guard: WL_GRAPHIC_RENDERTARGET_H
154152
=== modified file 'src/graphic/richtext.cc'
--- src/graphic/richtext.cc 2017-02-23 19:38:51 +0000
+++ src/graphic/richtext.cc 2017-05-13 13:15:21 +0000
@@ -61,7 +61,7 @@
61 }61 }
6262
63 void draw(RenderTarget& dst) override {63 void draw(RenderTarget& dst) override {
64 dst.blit(Vector2f(0, 0), image);64 dst.blit(Vector2i::zero(), image);
65 }65 }
6666
67 const Image* image;67 const Image* image;
@@ -107,7 +107,7 @@
107 }107 }
108 }108 }
109 // Now render109 // Now render
110 uint32_t x = g_fh->draw_text_raw(dst, style, Vector2i(0, 0), result_words[0]);110 uint32_t x = g_fh->draw_text_raw(dst, style, Vector2i::zero(), result_words[0]);
111111
112 it = result_words.begin() + 1;112 it = result_words.begin() + 1;
113 if (it != result_words.end()) {113 if (it != result_words.end()) {
@@ -493,12 +493,12 @@
493 for (std::vector<Element*>::const_iterator elt = m->elements.begin(); elt != m->elements.end();493 for (std::vector<Element*>::const_iterator elt = m->elements.begin(); elt != m->elements.end();
494 ++elt) {494 ++elt) {
495 Recti oldbox;495 Recti oldbox;
496 Vector2i oldofs;496 Vector2i oldofs = Vector2i::zero();
497 Recti bbox((*elt)->bbox.origin() + offset, (*elt)->bbox.w, (*elt)->bbox.h);497 Recti bbox((*elt)->bbox.origin() + offset, (*elt)->bbox.w, (*elt)->bbox.h);
498498
499 if (dst.enter_window(bbox, &oldbox, &oldofs)) {499 if (dst.enter_window(bbox, &oldbox, &oldofs)) {
500 if (background)500 if (background)
501 dst.fill_rect(Rectf(0.f, 0.f, bbox.w, bbox.h), m->background_color);501 dst.fill_rect(Recti(0, 0, bbox.w, bbox.h), m->background_color);
502 (*elt)->draw(dst);502 (*elt)->draw(dst);
503 dst.set_window(oldbox, oldofs);503 dst.set_window(oldbox, oldofs);
504 }504 }
505505
=== modified file 'src/graphic/text_layout.cc'
--- src/graphic/text_layout.cc 2017-05-03 07:24:06 +0000
+++ src/graphic/text_layout.cc 2017-05-13 13:15:21 +0000
@@ -204,7 +204,7 @@
204 * subsampled rendering - this can lead to blurry texts. That is why we204 * subsampled rendering - this can lead to blurry texts. That is why we
205 * never do float divisions in this function.205 * never do float divisions in this function.
206 */206 */
207void correct_for_align(Align align, uint32_t w, Vector2f* pt) {207void correct_for_align(Align align, uint32_t w, Vector2i* pt) {
208208
209 if (align == Align::kCenter)209 if (align == Align::kCenter)
210 pt->x -= w / 2;210 pt->x -= w / 2;
@@ -215,7 +215,7 @@
215/**215/**
216 * Adjust the y coordinate in 'point 'pt' to vertically center an element with height 'h'.216 * Adjust the y coordinate in 'point 'pt' to vertically center an element with height 'h'.
217 */217 */
218void center_vertically(uint32_t h, Vector2f* pt) {218void center_vertically(uint32_t h, Vector2i* pt) {
219 pt->y -= h / 2;219 pt->y -= h / 2;
220}220}
221} // namespace UI221} // namespace UI
222222
=== modified file 'src/graphic/text_layout.h'
--- src/graphic/text_layout.h 2017-03-29 12:36:20 +0000
+++ src/graphic/text_layout.h 2017-05-13 13:15:21 +0000
@@ -104,8 +104,8 @@
104104
105Align mirror_alignment(Align alignment);105Align mirror_alignment(Align alignment);
106106
107void center_vertically(uint32_t h, Vector2f* pt);107void center_vertically(uint32_t h, Vector2i* pt);
108void correct_for_align(Align, uint32_t w, Vector2f* pt);108void correct_for_align(Align, uint32_t w, Vector2i* pt);
109109
110} // namespace UI110} // namespace UI
111111
112112
=== modified file 'src/graphic/wordwrap.cc'
--- src/graphic/wordwrap.cc 2017-04-30 07:44:27 +0000
+++ src/graphic/wordwrap.cc 2017-05-13 13:15:21 +0000
@@ -310,7 +310,7 @@
310 if (where.y >= dst.height() || int32_t(where.y + fontheight) <= 0)310 if (where.y >= dst.height() || int32_t(where.y + fontheight) <= 0)
311 continue;311 continue;
312312
313 Vector2f point(where.x, where.y);313 Vector2i point(where.x, where.y);
314314
315 if (alignment == UI::Align::kRight) {315 if (alignment == UI::Align::kRight) {
316 point.x += wrapwidth_ - kLineMargin;316 point.x += wrapwidth_ - kLineMargin;
@@ -327,9 +327,9 @@
327 int caret_x = text_width(line_to_caret, fontsize_);327 int caret_x = text_width(line_to_caret, fontsize_);
328328
329 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");329 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
330 Vector2f caretpt;330 Vector2i caretpt = Vector2i::zero();
331 caretpt.x = point.x + caret_x - caret_image->width() + kLineMargin;331 caretpt.x = point.x + caret_x - caret_image->width() + kLineMargin;
332 caretpt.y = point.y + (fontheight - caret_image->height()) / 2.f;332 caretpt.y = point.y + (fontheight - caret_image->height()) / 2;
333 dst.blit(caretpt, caret_image);333 dst.blit(caretpt, caret_image);
334 }334 }
335 }335 }
336336
=== modified file 'src/logic/map_objects/map_object.cc'
--- src/logic/map_objects/map_object.cc 2017-04-30 08:27:40 +0000
+++ src/logic/map_objects/map_object.cc 2017-05-13 13:15:21 +0000
@@ -473,19 +473,19 @@
473 const Image* rendered_census_info =473 const Image* rendered_census_info =
474 UI::g_fh1->render(as_condensed(census, UI::Align::kCenter, font_size), 120);474 UI::g_fh1->render(as_condensed(census, UI::Align::kCenter, font_size), 120);
475475
476 // Rounding guarantees that text aligns with pixels to avoid subsampling.476 const Vector2i base_pos = field_on_dst.cast<int>() - Vector2i(0, 48) * scale;
477 const Vector2f census_pos = round(field_on_dst - Vector2f(0, 48) * scale).cast<float>();477 Vector2i census_pos(base_pos);
478 UI::correct_for_align(UI::Align::kCenter, rendered_census_info->width(), &census_pos);
478 if (draw_text & TextToDraw::kCensus) {479 if (draw_text & TextToDraw::kCensus) {
479 dst->blit(census_pos, rendered_census_info, BlendMode::UseAlpha, UI::Align::kCenter);480 dst->blit(census_pos, rendered_census_info, BlendMode::UseAlpha);
480 }481 }
481482
482 if (draw_text & TextToDraw::kStatistics && !statictics.empty()) {483 if (draw_text & TextToDraw::kStatistics && !statictics.empty()) {
483 const Vector2f statistics_pos =484 Vector2i statistics_pos =
484 round(census_pos + Vector2f(0, rendered_census_info->height() / 2.f + 10 * scale))485 base_pos + Vector2i(0, rendered_census_info->height() / 2 + 10 * scale);
485 .cast<float>();486 const Image* rendered_statictics = UI::g_fh1->render(as_condensed(statictics, UI::Align::kCenter, font_size));
486 dst->blit(statistics_pos,487 UI::correct_for_align(UI::Align::kCenter, rendered_statictics->width(), &statistics_pos);
487 UI::g_fh1->render(as_condensed(statictics, UI::Align::kCenter, font_size)),488 dst->blit(statistics_pos, rendered_statictics, BlendMode::UseAlpha);
488 BlendMode::UseAlpha, UI::Align::kCenter);
489 }489 }
490}490}
491491
492492
=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc 2017-05-03 07:24:06 +0000
+++ src/logic/map_objects/tribes/soldier.cc 2017-05-13 13:15:21 +0000
@@ -451,8 +451,8 @@
451451
452 const Vector2f point_on_dst = calc_drawpos(game, field_on_dst, scale);452 const Vector2f point_on_dst = calc_drawpos(game, field_on_dst, scale);
453 draw_info_icon(453 draw_info_icon(
454 point_on_dst -454 point_on_dst.cast<int>() -
455 Vector2f(0.f, (g_gr->animations().get_animation(get_current_anim()).height() - 7) * scale),455 Vector2i(0, (g_gr->animations().get_animation(get_current_anim()).height() - 7) * scale),
456 scale, true, dst);456 scale, true, dst);
457 draw_inner(game, point_on_dst, scale, dst);457 draw_inner(game, point_on_dst, scale, dst);
458}458}
@@ -460,7 +460,7 @@
460/**460/**
461 * Draw the info icon (level indicators + health bar) for this soldier.461 * Draw the info icon (level indicators + health bar) for this soldier.
462 */462 */
463void Soldier::draw_info_icon(Vector2f draw_position,463void Soldier::draw_info_icon(Vector2i draw_position,
464 float scale,464 float scale,
465 const bool anchor_below,465 const bool anchor_below,
466 RenderTarget* dst) const {466 RenderTarget* dst) const {
@@ -492,29 +492,26 @@
492 assert(kSoldierHealthBarWidth > dimension);492 assert(kSoldierHealthBarWidth > dimension);
493#endif493#endif
494494
495 const float icon_size = healthpic->width();495 const int icon_size = healthpic->width();
496 const float half_width = kSoldierHealthBarWidth;
497496
498 if (!anchor_below) {497 if (!anchor_below) {
499 float totalwidth = 2 * half_width;498 draw_position.x += kSoldierHealthBarWidth * scale;
500 float totalheight = 5.f + 2 * icon_size;499 draw_position.y += 2 * icon_size * scale;
501 draw_position.x += (totalwidth / 2.f) * scale;
502 draw_position.y += (totalheight - 5.f) * scale;
503 } else {500 } else {
504 draw_position.y -= 5.f * scale;501 draw_position.y -= 5 * scale;
505 }502 }
506503
507 // Draw energy bar504 // Draw energy bar
508 assert(get_max_health());505 assert(get_max_health());
509 const Rectf energy_outer(506 const Recti energy_outer(
510 draw_position - Vector2f(half_width, 0.f) * scale, half_width * 2.f * scale, 5.f * scale);507 draw_position - Vector2i(kSoldierHealthBarWidth, 0) * scale, kSoldierHealthBarWidth * 2 * scale, 5 * scale);
511 dst->fill_rect(energy_outer, RGBColor(255, 255, 255));508 dst->fill_rect(energy_outer, RGBColor(255, 255, 255));
512509
513 float health_width = 2.f * (half_width - 1.f) * current_health_ / get_max_health();510 int health_width = 2 * (kSoldierHealthBarWidth - 1) * current_health_ / get_max_health();
514 Rectf energy_inner(511 Recti energy_inner(
515 draw_position + Vector2f(-half_width + 1.f, 1.f) * scale, health_width * scale, 3 * scale);512 draw_position + Vector2i(-kSoldierHealthBarWidth + 1, 1) * scale, health_width * scale, 3 * scale);
516 Rectf energy_complement(energy_inner.origin() + Vector2f(health_width, 0.f) * scale,513 Recti energy_complement(energy_inner.origin() + Vector2i(health_width, 0) * scale,
517 (2 * (half_width - 1) - health_width) * scale, 3 * scale);514 (2 * (kSoldierHealthBarWidth - 1) - health_width) * scale, 3 * scale);
518515
519 const RGBColor& color = owner().get_playercolor();516 const RGBColor& color = owner().get_playercolor();
520 RGBColor complement_color;517 RGBColor complement_color;
@@ -528,15 +525,15 @@
528 dst->fill_rect(energy_complement, complement_color);525 dst->fill_rect(energy_complement, complement_color);
529526
530 const auto draw_level_image = [icon_size, scale, &draw_position, dst](527 const auto draw_level_image = [icon_size, scale, &draw_position, dst](
531 const Vector2f& offset, const Image* image) {528 const Vector2i& offset, const Image* image) {
532 dst->blitrect_scale(529 dst->blitrect_scale(
533 Rectf(draw_position + offset * icon_size * scale, icon_size * scale, icon_size * scale),530 Rectf(draw_position + offset * icon_size * scale, icon_size * scale, icon_size * scale),
534 image, Recti(0, 0, icon_size, icon_size), 1.f, BlendMode::UseAlpha);531 image, Recti(0, 0, icon_size, icon_size), 1.f, BlendMode::UseAlpha);
535 };532 };
536 draw_level_image(Vector2f(-1.f, -2.f), attackpic);533 draw_level_image(Vector2i(-1, -2), attackpic);
537 draw_level_image(Vector2f(0.f, -2.f), defensepic);534 draw_level_image(Vector2i(0, -2), defensepic);
538 draw_level_image(Vector2f(-1.f, -1.f), healthpic);535 draw_level_image(Vector2i(-1, -1), healthpic);
539 draw_level_image(Vector2f(0.f, -1.f), evadepic);536 draw_level_image(Vector2i(0, -1), evadepic);
540}537}
541538
542/**539/**
543540
=== modified file 'src/logic/map_objects/tribes/soldier.h'
--- src/logic/map_objects/tribes/soldier.h 2017-04-23 12:11:19 +0000
+++ src/logic/map_objects/tribes/soldier.h 2017-05-13 13:15:21 +0000
@@ -219,7 +219,7 @@
219 // Draw the info icon containing health bar and levels. If 'anchor_below' is219 // Draw the info icon containing health bar and levels. If 'anchor_below' is
220 // true, the icon is drawn horizontally centered above Otherwise, the icon220 // true, the icon is drawn horizontally centered above Otherwise, the icon
221 // is drawn below and right of 'draw_position'.221 // is drawn below and right of 'draw_position'.
222 void draw_info_icon(Vector2f draw_position,222 void draw_info_icon(Vector2i draw_position,
223 const float scale,223 const float scale,
224 const bool anchor_below,224 const bool anchor_below,
225 RenderTarget*) const;225 RenderTarget*) const;
226226
=== modified file 'src/profile/profile.h'
--- src/profile/profile.h 2017-01-25 18:55:59 +0000
+++ src/profile/profile.h 2017-05-13 13:15:21 +0000
@@ -126,7 +126,7 @@
126 uint32_t get_positive(char const* name, uint32_t def = 1);126 uint32_t get_positive(char const* name, uint32_t def = 1);
127 bool get_bool(char const* name, bool def = false);127 bool get_bool(char const* name, bool def = false);
128 const char* get_string(char const* name, char const* def = nullptr);128 const char* get_string(char const* name, char const* def = nullptr);
129 Vector2i get_point(char const* name, Vector2i def = Vector2i(0, 0));129 Vector2i get_point(char const* name, Vector2i def = Vector2i::zero());
130130
131 int32_t get_safe_int(const char* name);131 int32_t get_safe_int(const char* name);
132 uint32_t get_safe_natural(char const* name);132 uint32_t get_safe_natural(char const* name);
133133
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2017-01-25 18:55:59 +0000
+++ src/scripting/lua_ui.cc 2017-05-13 13:15:21 +0000
@@ -212,7 +212,7 @@
212*/212*/
213int LuaPanel::get_position_x(lua_State* L) {213int LuaPanel::get_position_x(lua_State* L) {
214 assert(panel_);214 assert(panel_);
215 Vector2i p = panel_->to_parent(Vector2i(0, 0));215 Vector2i p = panel_->to_parent(Vector2i::zero());
216216
217 lua_pushint32(L, p.x);217 lua_pushint32(L, p.x);
218 return 1;218 return 1;
@@ -225,7 +225,7 @@
225}225}
226int LuaPanel::get_position_y(lua_State* L) {226int LuaPanel::get_position_y(lua_State* L) {
227 assert(panel_);227 assert(panel_);
228 Vector2i p = panel_->to_parent(Vector2i(0, 0));228 Vector2i p = panel_->to_parent(Vector2i::zero());
229229
230 lua_pushint32(L, p.y);230 lua_pushint32(L, p.y);
231 return 1;231 return 1;
@@ -257,9 +257,9 @@
257257
258 UI::Panel* cur = (*get_base_user_class<LuaPanel>(L, 2))->panel_;258 UI::Panel* cur = (*get_base_user_class<LuaPanel>(L, 2))->panel_;
259259
260 Vector2i cp = Vector2i(0, 0);260 Vector2i cp = Vector2i::zero();
261 while (cur && cur != panel_) {261 while (cur && cur != panel_) {
262 cp += cur->to_parent(Vector2i(0, 0));262 cp += cur->to_parent(Vector2i::zero());
263 cur = cur->get_parent();263 cur = cur->get_parent();
264 }264 }
265265
266266
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2017-02-27 22:09:57 +0000
+++ src/ui_basic/button.cc 2017-05-13 13:15:21 +0000
@@ -161,25 +161,25 @@
161161
162 // Draw the background162 // Draw the background
163 if (pic_background_) {163 if (pic_background_) {
164 dst.fill_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBAColor(0, 0, 0, 255));164 dst.fill_rect(Recti(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 255));
165 dst.tile(165 dst.tile(
166 Recti(Vector2i(0, 0), get_w(), get_h()), pic_background_, Vector2i(get_x(), get_y()));166 Recti(Vector2i::zero(), get_w(), get_h()), pic_background_, Vector2i(get_x(), get_y()));
167 }167 }
168168
169 if (is_flat && highlighted_)169 if (is_flat && highlighted_)
170 dst.brighten_rect(Rectf(0.f, 0.f, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);170 dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
171171
172 // If we've got a picture, draw it centered172 // If we've got a picture, draw it centered
173 if (pic_custom_) {173 if (pic_custom_) {
174 if (image_mode_ == UI::Button::ImageMode::kUnscaled) {174 if (image_mode_ == UI::Button::ImageMode::kUnscaled) {
175 if (!is_monochrome) {175 if (!is_monochrome) {
176 dst.blit(Vector2f((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2.f,176 dst.blit(Vector2i((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2,
177 (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2.f),177 (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2),
178 pic_custom_);178 pic_custom_);
179 } else {179 } else {
180 dst.blit_monochrome(180 dst.blit_monochrome(
181 Vector2f((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2.f,181 Vector2i((get_w() - static_cast<int32_t>(pic_custom_->width())) / 2,
182 (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2.f),182 (get_h() - static_cast<int32_t>(pic_custom_->height())) / 2),
183 pic_custom_, RGBAColor(255, 255, 255, 127));183 pic_custom_, RGBAColor(255, 255, 255, 127));
184 }184 }
185 } else {185 } else {
@@ -213,7 +213,7 @@
213 is_monochrome ? UI_FONT_CLR_DISABLED : UI_FONT_CLR_FG);213 is_monochrome ? UI_FONT_CLR_DISABLED : UI_FONT_CLR_FG);
214 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.214 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.
215 dst.blit(215 dst.blit(
216 Vector2f((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),216 Vector2i((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),
217 entry_text_im);217 entry_text_im);
218 }218 }
219219
@@ -229,36 +229,36 @@
229 // Button is a normal one, not flat. We invert the behaviour for kPermpressed.229 // Button is a normal one, not flat. We invert the behaviour for kPermpressed.
230 if (is_permpressed == (pressed_ && highlighted_)) {230 if (is_permpressed == (pressed_ && highlighted_)) {
231 // top edge231 // top edge
232 dst.brighten_rect(Rectf(0.f, 0.f, get_w(), 2.f), BUTTON_EDGE_BRIGHT_FACTOR);232 dst.brighten_rect(Recti(0, 0, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
233 // left edge233 // left edge
234 dst.brighten_rect(Rectf(0, 2, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);234 dst.brighten_rect(Recti(0, 2, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
235 // bottom edge235 // bottom edge
236 dst.fill_rect(Rectf(2, get_h() - 2, get_w() - 2, 1), black);236 dst.fill_rect(Recti(2, get_h() - 2, get_w() - 2, 1), black);
237 dst.fill_rect(Rectf(1, get_h() - 1, get_w() - 1, 1), black);237 dst.fill_rect(Recti(1, get_h() - 1, get_w() - 1, 1), black);
238 // right edge238 // right edge
239 dst.fill_rect(Rectf(get_w() - 2, 2, 1, get_h() - 2), black);239 dst.fill_rect(Recti(get_w() - 2, 2, 1, get_h() - 2), black);
240 dst.fill_rect(Rectf(get_w() - 1, 1, 1, get_h() - 1), black);240 dst.fill_rect(Recti(get_w() - 1, 1, 1, get_h() - 1), black);
241 } else {241 } else {
242 // bottom edge242 // bottom edge
243 dst.brighten_rect(Rectf(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);243 dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
244 // right edge244 // right edge
245 dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);245 dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
246 // top edge246 // top edge
247 dst.fill_rect(Rectf(0, 0, get_w() - 1, 1), black);247 dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
248 dst.fill_rect(Rectf(0, 1, get_w() - 2, 1), black);248 dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
249 // left edge249 // left edge
250 dst.fill_rect(Rectf(0, 0, 1, get_h() - 1), black);250 dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
251 dst.fill_rect(Rectf(1, 0, 1, get_h() - 2), black);251 dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
252 }252 }
253 } else {253 } else {
254 // Button is flat, do not draw borders, instead, if it is pressed, draw254 // Button is flat, do not draw borders, instead, if it is pressed, draw
255 // a box around it.255 // a box around it.
256 if (enabled_ && highlighted_) {256 if (enabled_ && highlighted_) {
257 RGBAColor shade(100, 100, 100, 80);257 RGBAColor shade(100, 100, 100, 80);
258 dst.fill_rect(Rectf(0, 0, get_w(), 2), shade);258 dst.fill_rect(Recti(0, 0, get_w(), 2), shade);
259 dst.fill_rect(Rectf(0, 2, 2, get_h() - 2), shade);259 dst.fill_rect(Recti(0, 2, 2, get_h() - 2), shade);
260 dst.fill_rect(Rectf(0, get_h() - 2, get_w(), get_h()), shade);260 dst.fill_rect(Recti(0, get_h() - 2, get_w(), get_h()), shade);
261 dst.fill_rect(Rectf(get_w() - 2, 0, get_w(), get_h()), shade);261 dst.fill_rect(Recti(get_w() - 2, 0, get_w(), get_h()), shade);
262 }262 }
263 }263 }
264}264}
265265
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2017-02-23 17:58:25 +0000
+++ src/ui_basic/checkbox.cc 2017-05-13 13:15:21 +0000
@@ -134,18 +134,18 @@
134 const uint16_t w = pic_graphics_->width();134 const uint16_t w = pic_graphics_->width();
135 const uint16_t h = pic_graphics_->height();135 const uint16_t h = pic_graphics_->height();
136136
137 dst.blit(Vector2f((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), pic_graphics_);137 dst.blit(Vector2i((get_inner_w() - w) / 2, (get_inner_h() - h) / 2), pic_graphics_);
138138
139 if (flags_ & Is_Checked) {139 if (flags_ & Is_Checked) {
140 dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBColor(229, 116, 2));140 dst.draw_rect(Recti(0, 0, get_w(), get_h()), RGBColor(229, 116, 2));
141 } else if (flags_ & Is_Highlighted) {141 } else if (flags_ & Is_Highlighted) {
142 dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), RGBColor(100, 100, 80));142 dst.draw_rect(Recti(0, 0, get_w(), get_h()), RGBColor(100, 100, 80));
143 }143 }
144 } else {144 } else {
145 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_WIDTH) failed.");145 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_WIDTH) failed.");
146 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_HEIGHT) failed.");146 static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_HEIGHT) failed.");
147 Vector2f image_anchor(0.f, 0.f);147 Vector2i image_anchor(0, 0);
148 Vector2f text_anchor(kStateboxSize + kPadding, 0);148 Vector2i text_anchor(kStateboxSize + kPadding, 0);
149149
150 if (rendered_text_) {150 if (rendered_text_) {
151 if (UI::g_fh1->fontset()->is_rtl()) {151 if (UI::g_fh1->fontset()->is_rtl()) {
@@ -153,7 +153,7 @@
153 image_anchor.x = rendered_text_->width() + kPadding;153 image_anchor.x = rendered_text_->width() + kPadding;
154 image_anchor.y = (get_h() - kStateboxSize) / 2;154 image_anchor.y = (get_h() - kStateboxSize) / 2;
155 }155 }
156 dst.blit(text_anchor, rendered_text_, BlendMode::UseAlpha, UI::Align::kLeft);156 dst.blit(text_anchor, rendered_text_, BlendMode::UseAlpha);
157 }157 }
158158
159 dst.blitrect(159 dst.blitrect(
@@ -162,7 +162,7 @@
162162
163 if (flags_ & Is_Highlighted)163 if (flags_ & Is_Highlighted)
164 dst.draw_rect(164 dst.draw_rect(
165 Rectf(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));165 Recti(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));
166 }166 }
167}167}
168168
169169
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2017-02-28 20:07:07 +0000
+++ src/ui_basic/editbox.cc 2017-05-13 13:15:21 +0000
@@ -363,19 +363,19 @@
363 static const RGBColor black(0, 0, 0);363 static const RGBColor black(0, 0, 0);
364364
365 // bottom edge365 // bottom edge
366 dst.brighten_rect(Rectf(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);366 dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
367 // right edge367 // right edge
368 dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);368 dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
369 // top edge369 // top edge
370 dst.fill_rect(Rectf(0.f, 0.f, get_w() - 1, 1), black);370 dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
371 dst.fill_rect(Rectf(0.f, 1.f, get_w() - 2, 1), black);371 dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
372 // left edge372 // left edge
373 dst.fill_rect(Rectf(0.f, 0.f, 1, get_h() - 1), black);373 dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
374 dst.fill_rect(Rectf(1.f, 0.f, 1, get_h() - 2), black);374 dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
375 }375 }
376376
377 if (has_focus()) {377 if (has_focus()) {
378 dst.brighten_rect(Rectf(0.f, 0.f, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);378 dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
379 }379 }
380380
381 const int max_width = get_w() - 2 * kMarginX;381 const int max_width = get_w() - 2 * kMarginX;
@@ -390,7 +390,7 @@
390 ->height() :390 ->height() :
391 entry_text_im->height();391 entry_text_im->height();
392392
393 Vector2f point(kMarginX, get_h() / 2);393 Vector2i point(kMarginX, get_h() / 2);
394 if (m_->align == UI::Align::kRight) {394 if (m_->align == UI::Align::kRight) {
395 point.x += max_width - linewidth;395 point.x += max_width - linewidth;
396 }396 }
@@ -428,9 +428,9 @@
428 const uint16_t fontheight = text_height(m_->text, m_->fontsize);428 const uint16_t fontheight = text_height(m_->text, m_->fontsize);
429429
430 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");430 const Image* caret_image = g_gr->images().get("images/ui_basic/caret.png");
431 Vector2f caretpt;431 Vector2i caretpt = Vector2i::zero();
432 caretpt.x = point.x + m_->scrolloffset + caret_x - caret_image->width() + kLineMargin;432 caretpt.x = point.x + m_->scrolloffset + caret_x - caret_image->width() + kLineMargin;
433 caretpt.y = point.y + (fontheight - caret_image->height()) / 2.f;433 caretpt.y = point.y + (fontheight - caret_image->height()) / 2;
434 dst.blit(caretpt, caret_image);434 dst.blit(caretpt, caret_image);
435 }435 }
436}436}
437437
=== modified file 'src/ui_basic/fullscreen_window.cc'
--- src/ui_basic/fullscreen_window.cc 2017-02-23 19:38:51 +0000
+++ src/ui_basic/fullscreen_window.cc 2017-05-13 13:15:21 +0000
@@ -86,7 +86,7 @@
86*/86*/
87void FullscreenWindow::draw(RenderTarget& dst) {87void FullscreenWindow::draw(RenderTarget& dst) {
88 // Overall background88 // Overall background
89 dst.tile(Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i(0, 0));89 dst.tile(Recti(0, 0, get_w(), get_h()), g_gr->images().get(background_image_), Vector2i::zero());
9090
91 // Optional overlays91 // Optional overlays
92 for (const auto& overlay : overlays_) {92 for (const auto& overlay : overlays_) {
@@ -148,9 +148,9 @@
148 if (tiling != kNone) {148 if (tiling != kNone) {
149 const int w = (tiling == kVertical) ? image->width() : get_w();149 const int w = (tiling == kVertical) ? image->width() : get_w();
150 const int h = (tiling == kHorizontal) ? image->height() : get_h();150 const int h = (tiling == kHorizontal) ? image->height() : get_h();
151 dst.tile(Recti(x, y, w, h), image, Vector2i(0, 0));151 dst.tile(Recti(x, y, w, h), image, Vector2i::zero());
152 } else {152 } else {
153 dst.blit(Vector2f(x, y), image);153 dst.blit(Vector2i(x, y), image);
154 }154 }
155 }155 }
156}156}
157157
=== modified file 'src/ui_basic/icon.cc'
--- src/ui_basic/icon.cc 2017-01-25 18:55:59 +0000
+++ src/ui_basic/icon.cc 2017-05-13 13:15:21 +0000
@@ -63,7 +63,7 @@
63 Recti(0, 0, pic_->width(), pic_->height()), 1., BlendMode::UseAlpha);63 Recti(0, 0, pic_->width(), pic_->height()), 1., BlendMode::UseAlpha);
64 }64 }
65 if (draw_frame_) {65 if (draw_frame_) {
66 dst.draw_rect(Rectf(0.f, 0.f, get_w(), get_h()), framecolor_);66 dst.draw_rect(Recti(0, 0, get_w(), get_h()), framecolor_);
67 }67 }
68}68}
69}69}
7070
=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc 2017-03-06 06:57:47 +0000
+++ src/ui_basic/listselect.cc 2017-05-13 13:15:21 +0000
@@ -356,23 +356,23 @@
356 int y = 1 + idx * get_lineheight() - scrollpos_;356 int y = 1 + idx * get_lineheight() - scrollpos_;
357357
358 if (background_ != nullptr) {358 if (background_ != nullptr) {
359 dst.tile(Recti(Vector2i(0, 0), get_w(), get_h()), background_, Vector2i(0, 0));359 dst.tile(Recti(Vector2i::zero(), get_w(), get_h()), background_, Vector2i::zero());
360 }360 }
361361
362 if (selection_mode_ == ListselectLayout::kDropdown) {362 if (selection_mode_ == ListselectLayout::kDropdown) {
363 RGBAColor black(0, 0, 0, 255);363 RGBAColor black(0, 0, 0, 255);
364 // top edge364 // top edge
365 dst.brighten_rect(Rectf(0.f, 0.f, get_w(), 2.f), BUTTON_EDGE_BRIGHT_FACTOR / 4);365 dst.brighten_rect(Recti(0, 0, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR / 4);
366 // left edge366 // left edge
367 dst.brighten_rect(Rectf(0.f, 0.f, 2.f, get_h()), BUTTON_EDGE_BRIGHT_FACTOR);367 dst.brighten_rect(Recti(0, 0, 2, get_h()), BUTTON_EDGE_BRIGHT_FACTOR);
368 // bottom edge368 // bottom edge
369 dst.fill_rect(Rectf(2.f, get_h() - 2.f, get_eff_w() - 2.f, 1.f), black);369 dst.fill_rect(Recti(2, get_h() - 2, get_eff_w() - 2, 1), black);
370 dst.fill_rect(Rectf(1.f, get_h() - 1.f, get_eff_w() - 1.f, 1.f), black);370 dst.fill_rect(Recti(1, get_h() - 1, get_eff_w() - 1, 1), black);
371 // right edge371 // right edge
372 dst.fill_rect(Rectf(get_w() - 2.f, 1.f, 1.f, get_h() - 1.f), black);372 dst.fill_rect(Recti(get_w() - 2, 1, 1, get_h() - 1), black);
373 dst.fill_rect(Rectf(get_w() - 1.f, 0.f, 1.f, get_h()), black);373 dst.fill_rect(Recti(get_w() - 1, 0, 1, get_h()), black);
374 } else {374 } else {
375 dst.brighten_rect(Rectf(0.f, 0.f, get_eff_w(), get_h()), ms_darken_value);375 dst.brighten_rect(Recti(0, 0, get_eff_w(), get_h()), ms_darken_value);
376 }376 }
377377
378 while (idx < entry_records_.size()) {378 while (idx < entry_records_.size()) {
@@ -390,14 +390,14 @@
390 break;390 break;
391 }391 }
392392
393 Vector2f point(selection_mode_ == ListselectLayout::kDropdown ? 3.f : 1.f, y);393 Vector2i point(selection_mode_ == ListselectLayout::kDropdown ? 3 : 1, y);
394 uint32_t maxw =394 uint32_t maxw =
395 get_eff_w() -395 get_eff_w() -
396 (selection_mode_ == ListselectLayout::kDropdown ? scrollbar_.is_enabled() ? 4 : 5 : 2);396 (selection_mode_ == ListselectLayout::kDropdown ? scrollbar_.is_enabled() ? 4 : 5 : 2);
397397
398 // Highlight the current selected entry398 // Highlight the current selected entry
399 if (idx == selection_) {399 if (idx == selection_) {
400 Rectf r(point, maxw, lineheight_);400 Recti r(point, maxw, lineheight_);
401 if (r.x < 0) {401 if (r.x < 0) {
402 r.w += r.x;402 r.w += r.x;
403 r.x = 0;403 r.x = 0;
@@ -417,7 +417,7 @@
417417
418 // Now draw pictures418 // Now draw pictures
419 if (er.pic) {419 if (er.pic) {
420 dst.blit(Vector2f(UI::g_fh1->fontset()->is_rtl() ? get_eff_w() - er.pic->width() - 1 : 1,420 dst.blit(Vector2i(UI::g_fh1->fontset()->is_rtl() ? get_eff_w() - er.pic->width() - 1 : 1,
421 y + (get_lineheight() - er.pic->height()) / 2),421 y + (get_lineheight() - er.pic->height()) / 2),
422 er.pic);422 er.pic);
423 }423 }
424424
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2017-03-04 18:02:23 +0000
+++ src/ui_basic/multilineeditbox.cc 2017-05-13 13:15:21 +0000
@@ -426,26 +426,26 @@
426 */426 */
427void MultilineEditbox::draw(RenderTarget& dst) {427void MultilineEditbox::draw(RenderTarget& dst) {
428 // Draw the background428 // Draw the background
429 dst.tile(Recti(Vector2i(0, 0), get_w(), get_h()), d_->background, Vector2i(get_x(), get_y()));429 dst.tile(Recti(Vector2i::zero(), get_w(), get_h()), d_->background, Vector2i(get_x(), get_y()));
430430
431 // Draw border.431 // Draw border.
432 if (get_w() >= 4 && get_h() >= 4) {432 if (get_w() >= 4 && get_h() >= 4) {
433 static const RGBColor black(0, 0, 0);433 static const RGBColor black(0, 0, 0);
434434
435 // bottom edge435 // bottom edge
436 dst.brighten_rect(Rectf(0.f, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);436 dst.brighten_rect(Recti(0, get_h() - 2, get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
437 // right edge437 // right edge
438 dst.brighten_rect(Rectf(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);438 dst.brighten_rect(Recti(get_w() - 2, 0, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
439 // top edge439 // top edge
440 dst.fill_rect(Rectf(0, 0, get_w() - 1, 1), black);440 dst.fill_rect(Recti(0, 0, get_w() - 1, 1), black);
441 dst.fill_rect(Rectf(0, 1, get_w() - 2, 1), black);441 dst.fill_rect(Recti(0, 1, get_w() - 2, 1), black);
442 // left edge442 // left edge
443 dst.fill_rect(Rectf(0, 0, 1, get_h() - 1), black);443 dst.fill_rect(Recti(0, 0, 1, get_h() - 1), black);
444 dst.fill_rect(Rectf(1, 0, 1, get_h() - 2), black);444 dst.fill_rect(Recti(1, 0, 1, get_h() - 2), black);
445 }445 }
446446
447 if (has_focus())447 if (has_focus())
448 dst.brighten_rect(Rectf(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);448 dst.brighten_rect(Recti(0, 0, get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
449449
450 d_->refresh_ww();450 d_->refresh_ww();
451451
452452
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2017-03-04 18:02:23 +0000
+++ src/ui_basic/multilinetextarea.cc 2017-05-13 13:15:21 +0000
@@ -145,7 +145,7 @@
145 */145 */
146void MultilineTextarea::draw(RenderTarget& dst) {146void MultilineTextarea::draw(RenderTarget& dst) {
147 if (pic_background_) {147 if (pic_background_) {
148 dst.tile(Recti(0, 0, get_inner_w(), get_inner_h()), pic_background_, Vector2i(0, 0));148 dst.tile(Recti(0, 0, get_inner_w(), get_inner_h()), pic_background_, Vector2i::zero());
149 }149 }
150 if (use_old_renderer_) {150 if (use_old_renderer_) {
151 rt.draw(dst, Vector2i(RICHTEXT_MARGIN, RICHTEXT_MARGIN - scrollbar_.get_scrollpos()));151 rt.draw(dst, Vector2i(RICHTEXT_MARGIN, RICHTEXT_MARGIN - scrollbar_.get_scrollpos()));
@@ -174,7 +174,7 @@
174 anchor = RICHTEXT_MARGIN;174 anchor = RICHTEXT_MARGIN;
175 }175 }
176176
177 dst.blitrect(Vector2f(anchor, 0), text_im,177 dst.blitrect(Vector2i(anchor, 0), text_im,
178 Recti(0, scrollbar_.get_scrollpos(), blit_width, blit_height),178 Recti(0, scrollbar_.get_scrollpos(), blit_width, blit_height),
179 BlendMode::UseAlpha);179 BlendMode::UseAlpha);
180 }180 }
181181
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2017-02-27 13:53:04 +0000
+++ src/ui_basic/panel.cc 2017-05-13 13:15:21 +0000
@@ -191,7 +191,7 @@
191 RenderTarget& rt = *g_gr->get_render_target();191 RenderTarget& rt = *g_gr->get_render_target();
192 forefather->do_draw(rt);192 forefather->do_draw(rt);
193 rt.blit(193 rt.blit(
194 (app->get_mouse_position() - Vector2i(3, 7)).cast<float>(),194 (app->get_mouse_position() - Vector2i(3, 7)),
195 WLApplication::get()->is_mouse_pressed() ? default_cursor_click_ : default_cursor_);195 WLApplication::get()->is_mouse_pressed() ? default_cursor_click_ : default_cursor_);
196 forefather->do_tooltip();196 forefather->do_tooltip();
197 g_gr->refresh();197 g_gr->refresh();
@@ -746,7 +746,7 @@
746 return;746 return;
747747
748 Recti outerrc;748 Recti outerrc;
749 Vector2i outerofs;749 Vector2i outerofs = Vector2i::zero();
750750
751 if (!dst.enter_window(Recti(Vector2i(x_, y_), w_, h_), &outerrc, &outerofs))751 if (!dst.enter_window(Recti(Vector2i(x_, y_), w_, h_), &outerrc, &outerofs))
752 return;752 return;
@@ -1068,9 +1068,9 @@
1068 uint16_t tip_width = rendered_text->width() + 4;1068 uint16_t tip_width = rendered_text->width() + 4;
1069 uint16_t tip_height = rendered_text->height() + 4;1069 uint16_t tip_height = rendered_text->height() + 4;
10701070
1071 Rectf r(WLApplication::get()->get_mouse_position() + Vector2i(2, 32), tip_width, tip_height);1071 Recti r(WLApplication::get()->get_mouse_position() + Vector2i(2, 32), tip_width, tip_height);
1072 const Vector2f tooltip_bottom_right = r.opposite_of_origin();1072 const Vector2i tooltip_bottom_right = r.opposite_of_origin();
1073 const Vector2f screen_bottom_right(g_gr->get_xres(), g_gr->get_yres());1073 const Vector2i screen_bottom_right(g_gr->get_xres(), g_gr->get_yres());
1074 if (screen_bottom_right.x < tooltip_bottom_right.x)1074 if (screen_bottom_right.x < tooltip_bottom_right.x)
1075 r.x -= 4 + r.w;1075 r.x -= 4 + r.w;
1076 if (screen_bottom_right.y < tooltip_bottom_right.y)1076 if (screen_bottom_right.y < tooltip_bottom_right.y)
@@ -1078,7 +1078,7 @@
10781078
1079 dst.fill_rect(r, RGBColor(63, 52, 34));1079 dst.fill_rect(r, RGBColor(63, 52, 34));
1080 dst.draw_rect(r, RGBColor(0, 0, 0));1080 dst.draw_rect(r, RGBColor(0, 0, 0));
1081 dst.blit(r.origin() + Vector2f(2.f, 2.f), rendered_text);1081 dst.blit(r.origin() + Vector2i(2, 2), rendered_text);
1082 return true;1082 return true;
1083}1083}
1084}1084}
10851085
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2017-02-26 11:00:07 +0000
+++ src/ui_basic/progressbar.cc 2017-05-13 13:15:21 +0000
@@ -75,13 +75,13 @@
75 const float w = get_w() * fraction;75 const float w = get_w() * fraction;
76 assert(w <= get_w());76 assert(w <= get_w());
7777
78 dst.fill_rect(Rectf(0.f, 0.f, w, get_h()), color);78 dst.fill_rect(Recti(0, 0, w, get_h()), color);
79 dst.fill_rect(Rectf(w, 0.f, get_w() - w, get_h()), RGBColor(0, 0, 0));79 dst.fill_rect(Recti(w, 0, get_w() - w, get_h()), RGBColor(0, 0, 0));
80 } else {80 } else {
81 const uint32_t h = static_cast<uint32_t>(get_h() * (1.0f - fraction));81 const uint32_t h = static_cast<uint32_t>(get_h() * (1.0f - fraction));
8282
83 dst.fill_rect(Rectf(0.f, 0.f, get_w(), h), RGBColor(0, 0, 0));83 dst.fill_rect(Recti(0, 0, get_w(), h), RGBColor(0, 0, 0));
84 dst.fill_rect(Rectf(0.f, h, get_w(), get_h() - h), color);84 dst.fill_rect(Recti(0, h, get_w(), get_h() - h), color);
85 }85 }
8686
87 // Print the state in percent without decimal points.87 // Print the state in percent without decimal points.
@@ -89,8 +89,9 @@
89 UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100.f))89 UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100.f))
90 .str();90 .str();
91 const Image* rendered_text = UI::g_fh1->render(as_uifont(progress_text));91 const Image* rendered_text = UI::g_fh1->render(as_uifont(progress_text));
92 Vector2f pos(get_w() / 2, get_h() / 2);92 Vector2i pos(get_w() / 2, get_h() / 2);
93 UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &pos);
93 UI::center_vertically(rendered_text->height(), &pos);94 UI::center_vertically(rendered_text->height(), &pos);
94 dst.blit(pos, rendered_text, BlendMode::UseAlpha, UI::Align::kCenter);95 dst.blit(pos, rendered_text, BlendMode::UseAlpha);
95}96}
96}97}
9798
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2017-02-24 10:21:37 +0000
+++ src/ui_basic/progresswindow.cc 2017-05-13 13:15:21 +0000
@@ -45,7 +45,9 @@
4545
46namespace UI {46namespace UI {
4747
48ProgressWindow::ProgressWindow(const std::string& background) : UI::FullscreenWindow() {48ProgressWindow::ProgressWindow(const std::string& background) :
49 UI::FullscreenWindow(),
50 label_center_(Vector2i::zero()) {
49 set_background(background);51 set_background(background);
50 step(_("Loading…"));52 step(_("Loading…"));
51}53}
@@ -70,7 +72,7 @@
70 label_rectangle_.y = label_center_.y - h / 2 - PROGRESS_STATUS_RECT_PADDING;72 label_rectangle_.y = label_center_.y - h / 2 - PROGRESS_STATUS_RECT_PADDING;
71 label_rectangle_.h = h + 2 * PROGRESS_STATUS_RECT_PADDING;73 label_rectangle_.h = h + 2 * PROGRESS_STATUS_RECT_PADDING;
7274
73 Rectf border_rect = label_rectangle_;75 Recti border_rect = label_rectangle_;
74 border_rect.x -= PROGRESS_STATUS_BORDER_X;76 border_rect.x -= PROGRESS_STATUS_BORDER_X;
75 border_rect.y -= PROGRESS_STATUS_BORDER_Y;77 border_rect.y -= PROGRESS_STATUS_BORDER_Y;
76 border_rect.w += 2 * PROGRESS_STATUS_BORDER_X;78 border_rect.w += 2 * PROGRESS_STATUS_BORDER_X;
@@ -100,8 +102,9 @@
100 rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG);102 rt.fill_rect(label_rectangle_, PROGRESS_FONT_COLOR_BG);
101 const Image* rendered_text =103 const Image* rendered_text =
102 UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG));104 UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG));
105 UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &label_center_);
103 UI::center_vertically(rendered_text->height(), &label_center_);106 UI::center_vertically(rendered_text->height(), &label_center_);
104 rt.blit(label_center_, rendered_text, BlendMode::UseAlpha, UI::Align::kCenter);107 rt.blit(label_center_, rendered_text, BlendMode::UseAlpha);
105108
106#ifdef _WIN32109#ifdef _WIN32
107 // Pump events to prevent "not responding" on windows110 // Pump events to prevent "not responding" on windows
108111
=== modified file 'src/ui_basic/progresswindow.h'
--- src/ui_basic/progresswindow.h 2017-02-24 10:21:37 +0000
+++ src/ui_basic/progresswindow.h 2017-05-13 13:15:21 +0000
@@ -63,8 +63,8 @@
63private:63private:
64 using VisualizationArray = std::vector<IProgressVisualization*>;64 using VisualizationArray = std::vector<IProgressVisualization*>;
6565
66 Vector2f label_center_;66 Vector2i label_center_;
67 Rectf label_rectangle_;67 Recti label_rectangle_;
68 VisualizationArray visualizations_;68 VisualizationArray visualizations_;
69 std::string background_;69 std::string background_;
7070
7171
=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc 2017-02-27 13:48:29 +0000
+++ src/ui_basic/scrollbar.cc 2017-05-13 13:15:21 +0000
@@ -233,7 +233,7 @@
233 set_scrollpos(pos);233 set_scrollpos(pos);
234}234}
235235
236void Scrollbar::draw_button(RenderTarget& dst, Area area, const Rectf& r) {236void Scrollbar::draw_button(RenderTarget& dst, Area area, const Recti& r) {
237 dst.tile(r.cast<int>(), pic_buttons_, Vector2i(get_x(), get_y()));237 dst.tile(r.cast<int>(), pic_buttons_, Vector2i(get_x(), get_y()));
238238
239 // Draw the picture239 // Draw the picture
@@ -250,7 +250,7 @@
250 int blit_height = image_scale * pic->height();250 int blit_height = image_scale * pic->height();
251251
252 dst.blitrect_scale(252 dst.blitrect_scale(
253 Rectf(r.origin() + Vector2f((r.w - blit_width) / 2.f, (r.h - blit_height) / 2.f),253 Rectf(r.origin() + Vector2i((r.w - blit_width) / 2, (r.h - blit_height) / 2),
254 blit_width, blit_height),254 blit_width, blit_height),
255 pic, Recti(0, 0, pic->width(), pic->height()), 1., BlendMode::UseAlpha);255 pic, Recti(0, 0, pic->width(), pic->height()), 1., BlendMode::UseAlpha);
256 }256 }
@@ -260,46 +260,46 @@
260260
261 if (area != pressed_) {261 if (area != pressed_) {
262 // top edge262 // top edge
263 dst.brighten_rect(Rectf(r.origin(), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);263 dst.brighten_rect(Recti(r.origin(), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
264 // left edge264 // left edge
265 dst.brighten_rect(Rectf(r.origin() + Vector2f(0, 2), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);265 dst.brighten_rect(Recti(r.origin() + Vector2i(0, 2), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
266 // bottom edge266 // bottom edge
267 dst.fill_rect(Rectf(r.origin() + Vector2f(2, r.h - 2), r.w - 2, 1), black);267 dst.fill_rect(Recti(r.origin() + Vector2i(2, r.h - 2), r.w - 2, 1), black);
268 dst.fill_rect(Rectf(r.origin() + Vector2f(1, r.h - 1), r.w - 1, 1), black);268 dst.fill_rect(Recti(r.origin() + Vector2i(1, r.h - 1), r.w - 1, 1), black);
269 // right edge269 // right edge
270 dst.fill_rect(Rectf(r.origin() + Vector2f(r.w - 2, 2), 1, r.h - 2), black);270 dst.fill_rect(Recti(r.origin() + Vector2i(r.w - 2, 2), 1, r.h - 2), black);
271 dst.fill_rect(Rectf(r.origin() + Vector2f(r.w - 1, 1), 1, r.h - 1), black);271 dst.fill_rect(Recti(r.origin() + Vector2i(r.w - 1, 1), 1, r.h - 1), black);
272 } else {272 } else {
273 // bottom edge273 // bottom edge
274 dst.brighten_rect(274 dst.brighten_rect(
275 Rectf(r.origin() + Vector2f(0, r.h - 2), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);275 Recti(r.origin() + Vector2i(0, r.h - 2), r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
276 // right edge276 // right edge
277 dst.brighten_rect(277 dst.brighten_rect(
278 Rectf(r.origin() + Vector2f(r.w - 2, 0), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);278 Recti(r.origin() + Vector2i(r.w - 2, 0), 2, r.h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
279 // top edge279 // top edge
280 dst.fill_rect(Rectf(r.origin(), r.w - 1, 1), black);280 dst.fill_rect(Recti(r.origin(), r.w - 1, 1), black);
281 dst.fill_rect(Rectf(r.origin() + Vector2f(0, 1), r.w - 2, 1), black);281 dst.fill_rect(Recti(r.origin() + Vector2i(0, 1), r.w - 2, 1), black);
282 // left edge282 // left edge
283 dst.fill_rect(Rectf(r.origin(), 1, r.h - 1), black);283 dst.fill_rect(Recti(r.origin(), 1, r.h - 1), black);
284 dst.fill_rect(Rectf(r.origin() + Vector2f(1, 0), 1, r.h - 2), black);284 dst.fill_rect(Recti(r.origin() + Vector2i(1, 0), 1, r.h - 2), black);
285 }285 }
286}286}
287287
288void Scrollbar::draw_area(RenderTarget& dst, Area area, const Rectf& r) {288void Scrollbar::draw_area(RenderTarget& dst, Area area, const Recti& r) {
289 // background289 // background
290 dst.brighten_rect(r, area == pressed_ ? 2 * MOUSE_OVER_BRIGHT_FACTOR : MOUSE_OVER_BRIGHT_FACTOR);290 dst.brighten_rect(r, area == pressed_ ? 2 * MOUSE_OVER_BRIGHT_FACTOR : MOUSE_OVER_BRIGHT_FACTOR);
291 if (horizontal_) {291 if (horizontal_) {
292 // top edge292 // top edge
293 dst.brighten_rect(Rectf(r.x, r.y, r.w - 1.f, 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);293 dst.brighten_rect(Recti(r.x, r.y, r.w - 1, 1), -BUTTON_EDGE_BRIGHT_FACTOR);
294 dst.brighten_rect(Rectf(r.x, r.y + 1.f, r.w - 2.f, 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);294 dst.brighten_rect(Recti(r.x, r.y + 1, r.w - 2, 1), -BUTTON_EDGE_BRIGHT_FACTOR);
295 // bottom edge295 // bottom edge
296 dst.brighten_rect(Rectf(r.x, r.h - 2.f, r.w, 2.f), BUTTON_EDGE_BRIGHT_FACTOR);296 dst.brighten_rect(Recti(r.x, r.h - 2, r.w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
297 } else {297 } else {
298 // right edge298 // right edge
299 dst.brighten_rect(Rectf(r.w - 2.f, r.y, 2.f, r.h), BUTTON_EDGE_BRIGHT_FACTOR);299 dst.brighten_rect(Recti(r.w - 2, r.y, 2, r.h), BUTTON_EDGE_BRIGHT_FACTOR);
300 // left edge300 // left edge
301 dst.brighten_rect(Rectf(r.x, r.y, 1.f, r.h - 1.f), -BUTTON_EDGE_BRIGHT_FACTOR);301 dst.brighten_rect(Recti(r.x, r.y, 1, r.h - 1), -BUTTON_EDGE_BRIGHT_FACTOR);
302 dst.brighten_rect(Rectf(r.x + 1.f, r.y, 1.f, r.h - 2.f), -BUTTON_EDGE_BRIGHT_FACTOR);302 dst.brighten_rect(Recti(r.x + 1, r.y, 1, r.h - 2), -BUTTON_EDGE_BRIGHT_FACTOR);
303 }303 }
304}304}
305305
@@ -317,46 +317,46 @@
317 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_w())) {317 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_w())) {
318 // Our owner allocated too little space318 // Our owner allocated too little space
319 if (static_cast<uint32_t>(get_w()) >= 2 * buttonsize_) {319 if (static_cast<uint32_t>(get_w()) >= 2 * buttonsize_) {
320 draw_button(dst, Minus, Rectf(0, 0, get_w() / 2, get_h()));320 draw_button(dst, Minus, Recti(0, 0, get_w() / 2, get_h()));
321 draw_button(dst, Plus, Rectf(get_w() - buttonsize_, 0, get_w() / 2, get_h()));321 draw_button(dst, Plus, Recti(get_w() - buttonsize_, 0, get_w() / 2, get_h()));
322 } else {322 } else {
323 draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h()));323 draw_button(dst, Minus, Recti(0, 0, get_w(), get_h()));
324 }324 }
325 return;325 return;
326 }326 }
327327
328 draw_button(dst, Minus, Rectf(0, 0, buttonsize_, get_h()));328 draw_button(dst, Minus, Recti(0, 0, buttonsize_, get_h()));
329 draw_button(dst, Plus, Rectf(get_w() - buttonsize_, 0, buttonsize_, get_h()));329 draw_button(dst, Plus, Recti(get_w() - buttonsize_, 0, buttonsize_, get_h()));
330 draw_button(dst, Knob, Rectf(knobpos - knobsize / 2.f, 0, knobsize, get_h()));330 draw_button(dst, Knob, Recti(knobpos - knobsize / 2, 0, knobsize, get_h()));
331331
332 assert(buttonsize_ + knobsize / 2 <= knobpos);332 assert(buttonsize_ + knobsize / 2 <= knobpos);
333 draw_area(333 draw_area(
334 dst, MinusPage, Rectf(buttonsize_, 0, knobpos - buttonsize_ - knobsize / 2, get_h()));334 dst, MinusPage, Recti(buttonsize_, 0, knobpos - buttonsize_ - knobsize / 2, get_h()));
335 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_w()));335 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_w()));
336 draw_area(dst, PlusPage, Rectf(knobpos + knobsize / 2.f, 0.f,336 draw_area(dst, PlusPage, Recti(knobpos + knobsize / 2, 0,
337 get_w() - knobpos - knobsize / 2 - buttonsize_, get_h()));337 get_w() - knobpos - knobsize / 2 - buttonsize_, get_h()));
338 } else {338 } else {
339 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_h())) {339 if ((2 * buttonsize_ + knobsize) > static_cast<uint32_t>(get_h())) {
340 // Our owner allocated too little space340 // Our owner allocated too little space
341 if (static_cast<uint32_t>(get_h()) >= 2 * buttonsize_) {341 if (static_cast<uint32_t>(get_h()) >= 2 * buttonsize_) {
342 draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h() / 2.f));342 draw_button(dst, Minus, Recti(0, 0, get_w(), get_h() / 2));
343 draw_button(dst, Plus, Rectf(0.f, get_h() - buttonsize_, get_w(), get_h() / 2));343 draw_button(dst, Plus, Recti(0, get_h() - buttonsize_, get_w(), get_h() / 2));
344 } else {344 } else {
345 draw_button(dst, Minus, Rectf(0.f, 0.f, get_w(), get_h()));345 draw_button(dst, Minus, Recti(0, 0, get_w(), get_h()));
346 }346 }
347 return;347 return;
348 }348 }
349349
350 draw_button(dst, Minus, Rectf(0, 0, get_w(), buttonsize_));350 draw_button(dst, Minus, Recti(0, 0, get_w(), buttonsize_));
351 draw_button(dst, Plus, Rectf(0, get_h() - buttonsize_, get_w(), buttonsize_));351 draw_button(dst, Plus, Recti(0, get_h() - buttonsize_, get_w(), buttonsize_));
352 draw_button(dst, Knob, Rectf(0, knobpos - knobsize / 2.f, get_w(), knobsize));352 draw_button(dst, Knob, Recti(0, knobpos - knobsize / 2, get_w(), knobsize));
353353
354 assert(buttonsize_ + knobsize / 2 <= knobpos);354 assert(buttonsize_ + knobsize / 2 <= knobpos);
355 draw_area(355 draw_area(
356 dst, MinusPage, Rectf(0.f, buttonsize_, get_w(), knobpos - buttonsize_ - knobsize / 2));356 dst, MinusPage, Recti(0, buttonsize_, get_w(), knobpos - buttonsize_ - knobsize / 2));
357 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_h()));357 assert(knobpos + knobsize / 2 + buttonsize_ <= static_cast<uint32_t>(get_h()));
358 draw_area(dst, PlusPage, Rectf(0.f, knobpos + knobsize / 2.f, get_w(),358 draw_area(dst, PlusPage, Recti(0, knobpos + knobsize / 2, get_w(),
359 get_h() - knobpos - knobsize / 2.f - buttonsize_));359 get_h() - knobpos - knobsize / 2 - buttonsize_));
360 }360 }
361}361}
362362
363363
=== modified file 'src/ui_basic/scrollbar.h'
--- src/ui_basic/scrollbar.h 2017-01-25 18:55:59 +0000
+++ src/ui_basic/scrollbar.h 2017-05-13 13:15:21 +0000
@@ -82,8 +82,8 @@
8282
83 void action(Area area);83 void action(Area area);
8484
85 void draw_button(RenderTarget&, Area, const Rectf&);85 void draw_button(RenderTarget&, Area, const Recti&);
86 void draw_area(RenderTarget& dst, Area area, const Rectf& r);86 void draw_area(RenderTarget& dst, Area area, const Recti& r);
87 void draw(RenderTarget&) override;87 void draw(RenderTarget&) override;
88 void think() override;88 void think() override;
8989
9090
=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc 2017-02-24 19:22:36 +0000
+++ src/ui_basic/slider.cc 2017-05-13 13:15:21 +0000
@@ -152,34 +152,34 @@
152 (Recti(Vector2i(x, y), w, h), pic_background_, Vector2i(get_x(), get_y()));152 (Recti(Vector2i(x, y), w, h), pic_background_, Vector2i(get_x(), get_y()));
153153
154 if (highlighted_)154 if (highlighted_)
155 dst.brighten_rect(Rectf(x, y, w, h), MOUSE_OVER_BRIGHT_FACTOR);155 dst.brighten_rect(Recti(x, y, w, h), MOUSE_OVER_BRIGHT_FACTOR);
156156
157 if (pressed_) { // draw border157 if (pressed_) { // draw border
158 dst.brighten_rect // bottom edge158 dst.brighten_rect // bottom edge
159 (Rectf(x, y + h - 2, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);159 (Recti(x, y + h - 2, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
160 dst.brighten_rect // right edge160 dst.brighten_rect // right edge
161 (Rectf(x + w - 2, y, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);161 (Recti(x + w - 2, y, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
162162
163 // top edge163 // top edge
164 dst.fill_rect(Rectf(x, y, w - 1, 1), black);164 dst.fill_rect(Recti(x, y, w - 1, 1), black);
165 dst.fill_rect(Rectf(x, y + 1, w - 2, 1), black);165 dst.fill_rect(Recti(x, y + 1, w - 2, 1), black);
166166
167 // left edge167 // left edge
168 dst.fill_rect(Rectf(x, y, 1, h - 1), black);168 dst.fill_rect(Recti(x, y, 1, h - 1), black);
169 dst.fill_rect(Rectf(x + 1, y, 1, h - 2), black);169 dst.fill_rect(Recti(x + 1, y, 1, h - 2), black);
170 } else {170 } else {
171 dst.brighten_rect // top edge171 dst.brighten_rect // top edge
172 (Rectf(x, y, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);172 (Recti(x, y, w, 2), BUTTON_EDGE_BRIGHT_FACTOR);
173 dst.brighten_rect // left edge173 dst.brighten_rect // left edge
174 (Rectf(x, y + 2, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);174 (Recti(x, y + 2, 2, h - 2), BUTTON_EDGE_BRIGHT_FACTOR);
175175
176 // bottom edge176 // bottom edge
177 dst.fill_rect(Rectf(x + 2, y + h - 2, w - 2, 1), black);177 dst.fill_rect(Recti(x + 2, y + h - 2, w - 2, 1), black);
178 dst.fill_rect(Rectf(x + 1, y + h - 1, w - 1, 1), black);178 dst.fill_rect(Recti(x + 1, y + h - 1, w - 1, 1), black);
179179
180 // right edge180 // right edge
181 dst.fill_rect(Rectf(x + w - 2, y + 2, 1, h - 2), black);181 dst.fill_rect(Recti(x + w - 2, y + 2, 1, h - 2), black);
182 dst.fill_rect(Rectf(x + w - 1, y + 1, 1, h - 1), black);182 dst.fill_rect(Recti(x + w - 1, y + 1, 1, h - 1), black);
183 }183 }
184}184}
185185
@@ -362,18 +362,18 @@
362362
363 if (get_bar_size() > 0) {363 if (get_bar_size() > 0) {
364 dst.brighten_rect // bottom edge364 dst.brighten_rect // bottom edge
365 (Rectf(get_x_gap(), get_h() / 2.f, get_bar_size(), 2), BUTTON_EDGE_BRIGHT_FACTOR);365 (Recti(get_x_gap(), get_h() / 2, get_bar_size(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
366 dst.brighten_rect // right edge366 dst.brighten_rect // right edge
367 (Rectf(get_x_gap() + get_bar_size() - 2, get_y_gap(), 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);367 (Recti(get_x_gap() + get_bar_size() - 2, get_y_gap(), 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
368368
369 // top edge369 // top edge
370 dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), get_bar_size() - 1, 1), black);370 dst.fill_rect(Recti(get_x_gap(), get_y_gap(), get_bar_size() - 1, 1), black);
371 dst.fill_rect(Rectf(get_x_gap(), get_y_gap() + 1, get_bar_size() - 2, 1), black);371 dst.fill_rect(Recti(get_x_gap(), get_y_gap() + 1, get_bar_size() - 2, 1), black);
372 }372 }
373373
374 // left edge374 // left edge
375 dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 1, 4), black);375 dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 1, 4), black);
376 dst.fill_rect(Rectf(get_x_gap() + 1, get_y_gap(), 1, 3), black);376 dst.fill_rect(Recti(get_x_gap() + 1, get_y_gap(), 1, 3), black);
377377
378 draw_cursor(dst, cursor_pos_, 0, cursor_size_, get_h());378 draw_cursor(dst, cursor_pos_, 0, cursor_size_, get_h());
379}379}
@@ -435,17 +435,17 @@
435 RGBAColor black(0, 0, 0, 255);435 RGBAColor black(0, 0, 0, 255);
436436
437 dst.brighten_rect // right edge437 dst.brighten_rect // right edge
438 (Rectf(get_w() / 2.f, get_y_gap(), 2, get_bar_size()), BUTTON_EDGE_BRIGHT_FACTOR);438 (Recti(get_w() / 2, get_y_gap(), 2, get_bar_size()), BUTTON_EDGE_BRIGHT_FACTOR);
439 dst.brighten_rect // bottom edge439 dst.brighten_rect // bottom edge
440 (Rectf(get_x_gap(), get_y_gap() + get_bar_size() - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);440 (Recti(get_x_gap(), get_y_gap() + get_bar_size() - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
441441
442 // left edge442 // left edge
443 dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 1, get_bar_size() - 1), black);443 dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 1, get_bar_size() - 1), black);
444 dst.fill_rect(Rectf(get_x_gap() + 1, get_y_gap(), 1, get_bar_size() - 2), black);444 dst.fill_rect(Recti(get_x_gap() + 1, get_y_gap(), 1, get_bar_size() - 2), black);
445445
446 // top edge446 // top edge
447 dst.fill_rect(Rectf(get_x_gap(), get_y_gap(), 4, 1), black);447 dst.fill_rect(Recti(get_x_gap(), get_y_gap(), 4, 1), black);
448 dst.fill_rect(Rectf(get_x_gap(), get_y_gap() + 1, 3, 1), black);448 dst.fill_rect(Recti(get_x_gap(), get_y_gap() + 1, 3, 1), black);
449449
450 draw_cursor(dst, 0, cursor_pos_, get_w(), cursor_size_);450 draw_cursor(dst, 0, cursor_pos_, get_w(), cursor_size_);
451}451}
@@ -540,8 +540,9 @@
540 for (uint32_t i = 0; i < labels.size(); i++) {540 for (uint32_t i = 0; i < labels.size(); i++) {
541 const Image* rendered_text =541 const Image* rendered_text =
542 UI::g_fh1->render(as_condensed(labels[i], UI::Align::kCenter, UI_FONT_SIZE_SMALL - 2));542 UI::g_fh1->render(as_condensed(labels[i], UI::Align::kCenter, UI_FONT_SIZE_SMALL - 2));
543 dst.blit(Vector2f(gap_1 + i * gap_n, get_h() - rendered_text->height()), rendered_text,543 Vector2i point(gap_1 + i * gap_n, get_h() - rendered_text->height());
544 BlendMode::UseAlpha, UI::Align::kCenter);544 UI::correct_for_align(UI::Align::kCenter, rendered_text->width(), &point);
545 dst.blit(point, rendered_text, BlendMode::UseAlpha);
545 }546 }
546}547}
547548
548549
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2017-04-25 08:10:11 +0000
+++ src/ui_basic/table.cc 2017-05-13 13:15:21 +0000
@@ -220,7 +220,7 @@
220 uint32_t idx = scrollpos_ / lineheight;220 uint32_t idx = scrollpos_ / lineheight;
221 int32_t y = 1 + idx * lineheight - scrollpos_ + headerheight_;221 int32_t y = 1 + idx * lineheight - scrollpos_ + headerheight_;
222222
223 dst.brighten_rect(Rectf(0.f, 0.f, get_eff_w(), get_h()), ms_darken_value);223 dst.brighten_rect(Recti(0, 0, get_eff_w(), get_h()), ms_darken_value);
224224
225 while (idx < entry_records_.size()) {225 while (idx < entry_records_.size()) {
226 if (y >= static_cast<int32_t>(get_h()))226 if (y >= static_cast<int32_t>(get_h()))
@@ -230,7 +230,7 @@
230230
231 if (idx == selection_ || multiselect_.count(idx)) {231 if (idx == selection_ || multiselect_.count(idx)) {
232 assert(2 <= get_eff_w());232 assert(2 <= get_eff_w());
233 dst.brighten_rect(Rectf(1.f, y, get_eff_w() - 2, lineheight_), -ms_darken_value);233 dst.brighten_rect(Recti(1, y, get_eff_w() - 2, lineheight_), -ms_darken_value);
234 }234 }
235235
236 Columns::size_type const nr_columns = columns_.size();236 Columns::size_type const nr_columns = columns_.size();
@@ -242,14 +242,14 @@
242 const Image* entry_picture = er.get_picture(i);242 const Image* entry_picture = er.get_picture(i);
243 const std::string& entry_string = er.get_string(i);243 const std::string& entry_string = er.get_string(i);
244244
245 Vector2f point(curx, y);245 Vector2i point(curx, y);
246 int picw = 0;246 int picw = 0;
247247
248 if (entry_picture != nullptr) {248 if (entry_picture != nullptr) {
249 picw = entry_picture->width();249 picw = entry_picture->width();
250 const int pich = entry_picture->height();250 const int pich = entry_picture->height();
251251
252 float draw_x = point.x;252 int draw_x = point.x;
253253
254 // We want a bit of margin254 // We want a bit of margin
255 int max_pic_height = lineheight - 3;255 int max_pic_height = lineheight - 3;
@@ -263,7 +263,7 @@
263 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {263 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
264 draw_x = point.x + (curw - blit_width - scrollbar_->get_w()) / 2.f;264 draw_x = point.x + (curw - blit_width - scrollbar_->get_w()) / 2.f;
265 } else {265 } else {
266 draw_x = point.x + (curw - blit_width) / 2.f;266 draw_x = point.x + (curw - blit_width) / 2;
267 }267 }
268 }268 }
269269
@@ -272,7 +272,7 @@
272 }272 }
273273
274 // Create the scaled image274 // Create the scaled image
275 dst.blitrect_scale(Rectf(draw_x, point.y + 1.f, blit_width, max_pic_height),275 dst.blitrect_scale(Rectf(draw_x, point.y + 1, blit_width, max_pic_height),
276 entry_picture, Recti(0, 0, picw, pich), 1., BlendMode::UseAlpha);276 entry_picture, Recti(0, 0, picw, pich), 1., BlendMode::UseAlpha);
277277
278 // For text alignment below278 // For text alignment below
@@ -282,12 +282,12 @@
282 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {282 if (i == nr_columns - 1 && scrollbar_->is_enabled()) {
283 draw_x = point.x + (curw - picw - scrollbar_->get_w()) / 2.f;283 draw_x = point.x + (curw - picw - scrollbar_->get_w()) / 2.f;
284 } else {284 } else {
285 draw_x = point.x + (curw - picw) / 2.f;285 draw_x = point.x + (curw - picw) / 2;
286 }286 }
287 } else if (alignment == UI::Align::kRight) {287 } else if (alignment == UI::Align::kRight) {
288 draw_x += curw - picw;288 draw_x += curw - picw;
289 }289 }
290 dst.blit(Vector2f(draw_x, point.y + (lineheight - pich) / 2.f), entry_picture);290 dst.blit(Vector2i(draw_x, point.y + (lineheight - pich) / 2), entry_picture);
291 }291 }
292 point.x += picw;292 point.x += picw;
293 }293 }
294294
=== modified file 'src/ui_basic/tabpanel.cc'
--- src/ui_basic/tabpanel.cc 2017-03-04 09:14:37 +0000
+++ src/ui_basic/tabpanel.cc 2017-05-13 13:15:21 +0000
@@ -259,7 +259,7 @@
259259
260 if (pic_background_) {260 if (pic_background_) {
261 if (!tabs_.empty()) {261 if (!tabs_.empty()) {
262 dst.tile(Recti(Vector2i(0, 0), tabs_.back()->get_x() + tabs_.back()->get_w(),262 dst.tile(Recti(Vector2i::zero(), tabs_.back()->get_x() + tabs_.back()->get_w(),
263 kTabPanelButtonHeight - 2),263 kTabPanelButtonHeight - 2),
264 pic_background_, Vector2i(get_x(), get_y()));264 pic_background_, Vector2i(get_x(), get_y()));
265 }265 }
@@ -279,7 +279,7 @@
279 tab_width = tabs_[idx]->get_w();279 tab_width = tabs_[idx]->get_w();
280280
281 if (highlight_ == idx) {281 if (highlight_ == idx) {
282 dst.brighten_rect(Rectf(x, 0, tab_width, kTabPanelButtonHeight), MOUSE_OVER_BRIGHT_FACTOR);282 dst.brighten_rect(Recti(x, 0, tab_width, kTabPanelButtonHeight), MOUSE_OVER_BRIGHT_FACTOR);
283 }283 }
284284
285 assert(tabs_[idx]->pic);285 assert(tabs_[idx]->pic);
@@ -300,46 +300,46 @@
300 tabs_[idx]->pic, Recti(0, 0, tabs_[idx]->pic->width(), tabs_[idx]->pic->height()), 1,300 tabs_[idx]->pic, Recti(0, 0, tabs_[idx]->pic->width(), tabs_[idx]->pic->height()), 1,
301 BlendMode::UseAlpha);301 BlendMode::UseAlpha);
302 } else {302 } else {
303 dst.blit(Vector2f(x + kTabPanelTextMargin,303 dst.blit(Vector2i(x + kTabPanelTextMargin,
304 (kTabPanelButtonHeight - tabs_[idx]->pic->height()) / 2),304 (kTabPanelButtonHeight - tabs_[idx]->pic->height()) / 2),
305 tabs_[idx]->pic, BlendMode::UseAlpha, UI::Align::kLeft);305 tabs_[idx]->pic, BlendMode::UseAlpha);
306 }306 }
307307
308 // Draw top part of border308 // Draw top part of border
309 dst.brighten_rect(Rectf(x, 0, tab_width, 2), BUTTON_EDGE_BRIGHT_FACTOR);309 dst.brighten_rect(Recti(x, 0, tab_width, 2), BUTTON_EDGE_BRIGHT_FACTOR);
310 dst.brighten_rect(Rectf(x, 2, 2, kTabPanelButtonHeight - 4), BUTTON_EDGE_BRIGHT_FACTOR);310 dst.brighten_rect(Recti(x, 2, 2, kTabPanelButtonHeight - 4), BUTTON_EDGE_BRIGHT_FACTOR);
311 dst.fill_rect(Rectf(x + tab_width - 2, 2, 1, kTabPanelButtonHeight - 4), black);311 dst.fill_rect(Recti(x + tab_width - 2, 2, 1, kTabPanelButtonHeight - 4), black);
312 dst.fill_rect(Rectf(x + tab_width - 1, 1, 1, kTabPanelButtonHeight - 3), black);312 dst.fill_rect(Recti(x + tab_width - 1, 1, 1, kTabPanelButtonHeight - 3), black);
313313
314 // Draw bottom part314 // Draw bottom part
315 if (active_ != idx)315 if (active_ != idx)
316 dst.brighten_rect(316 dst.brighten_rect(
317 Rectf(x, kTabPanelButtonHeight - 2, tab_width, 2), 2 * BUTTON_EDGE_BRIGHT_FACTOR);317 Recti(x, kTabPanelButtonHeight - 2, tab_width, 2), 2 * BUTTON_EDGE_BRIGHT_FACTOR);
318 else {318 else {
319 dst.brighten_rect(Rectf(x, kTabPanelButtonHeight - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);319 dst.brighten_rect(Recti(x, kTabPanelButtonHeight - 2, 2, 2), BUTTON_EDGE_BRIGHT_FACTOR);
320320
321 dst.brighten_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 2),321 dst.brighten_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 2),
322 2 * BUTTON_EDGE_BRIGHT_FACTOR);322 2 * BUTTON_EDGE_BRIGHT_FACTOR);
323 dst.fill_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 1, 1, 1), black);323 dst.fill_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 1, 1, 1), black);
324 dst.fill_rect(Rectf(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 1), black);324 dst.fill_rect(Recti(x + tab_width - 2, kTabPanelButtonHeight - 2, 2, 1), black);
325 }325 }
326 }326 }
327327
328 // draw the remaining separator328 // draw the remaining separator
329 assert(x <= get_w());329 assert(x <= get_w());
330 dst.brighten_rect(Rectf(x + tab_width, kTabPanelButtonHeight - 2, get_w() - x, 2),330 dst.brighten_rect(Recti(x + tab_width, kTabPanelButtonHeight - 2, get_w() - x, 2),
331 2 * BUTTON_EDGE_BRIGHT_FACTOR);331 2 * BUTTON_EDGE_BRIGHT_FACTOR);
332332
333 // Draw border around the main panel333 // Draw border around the main panel
334 if (border_type_ == TabPanel::Type::kBorder) {334 if (border_type_ == TabPanel::Type::kBorder) {
335 // left edge335 // left edge
336 dst.brighten_rect(Rectf(0, kTabPanelButtonHeight, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);336 dst.brighten_rect(Recti(0, kTabPanelButtonHeight, 2, get_h() - 2), BUTTON_EDGE_BRIGHT_FACTOR);
337 // bottom edge337 // bottom edge
338 dst.fill_rect(Rectf(2, get_h() - 2, get_w() - 2, 1), black);338 dst.fill_rect(Recti(2, get_h() - 2, get_w() - 2, 1), black);
339 dst.fill_rect(Rectf(1, get_h() - 1, get_w() - 1, 1), black);339 dst.fill_rect(Recti(1, get_h() - 1, get_w() - 1, 1), black);
340 // right edge340 // right edge
341 dst.fill_rect(Rectf(get_w() - 2, kTabPanelButtonHeight - 1, 1, get_h() - 2), black);341 dst.fill_rect(Recti(get_w() - 2, kTabPanelButtonHeight - 1, 1, get_h() - 2), black);
342 dst.fill_rect(Rectf(get_w() - 1, kTabPanelButtonHeight - 2, 1, get_h() - 1), black);342 dst.fill_rect(Recti(get_w() - 1, kTabPanelButtonHeight - 2, 1, get_h() - 1), black);
343 }343 }
344}344}
345345
346346
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc 2017-02-27 13:48:29 +0000
+++ src/ui_basic/textarea.cc 2017-05-13 13:15:21 +0000
@@ -125,10 +125,10 @@
125 */125 */
126void Textarea::draw(RenderTarget& dst) {126void Textarea::draw(RenderTarget& dst) {
127 if (!text_.empty()) {127 if (!text_.empty()) {
128 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.128 Vector2i anchor(
129 Vector2f anchor(
130 (align_ == Align::kCenter) ? get_w() / 2 : (align_ == UI::Align::kRight) ? get_w() : 0, 0);129 (align_ == Align::kCenter) ? get_w() / 2 : (align_ == UI::Align::kRight) ? get_w() : 0, 0);
131 dst.blit(anchor, rendered_text_, BlendMode::UseAlpha, align_);130 UI::correct_for_align(align_, rendered_text_->width(), &anchor);
131 dst.blit(anchor, rendered_text_, BlendMode::UseAlpha);
132 }132 }
133}133}
134134
135135
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2017-02-27 13:48:29 +0000
+++ src/ui_basic/window.cc 2017-05-13 13:15:21 +0000
@@ -141,7 +141,7 @@
141 */141 */
142void Window::layout() {142void Window::layout() {
143 if (center_panel_ && !is_minimal_) {143 if (center_panel_ && !is_minimal_) {
144 center_panel_->set_pos(Vector2i(0, 0));144 center_panel_->set_pos(Vector2i::zero());
145 center_panel_->set_size(get_inner_w(), get_inner_h());145 center_panel_->set_size(get_inner_w(), get_inner_h());
146 }146 }
147}147}
@@ -235,7 +235,7 @@
235void Window::draw(RenderTarget& dst) {235void Window::draw(RenderTarget& dst) {
236 if (!is_minimal()) {236 if (!is_minimal()) {
237 dst.tile(237 dst.tile(
238 Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), pic_background_, Vector2i(0, 0));238 Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), pic_background_, Vector2i::zero());
239 }239 }
240}240}
241241
@@ -253,19 +253,19 @@
253 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;253 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;
254254
255 dst.blitrect // top left corner255 dst.blitrect // top left corner
256 (Vector2f(0.f, 0.f), pic_top_, Recti(Vector2i(0, 0), pos, TP_B_PIXMAP_THICKNESS));256 (Vector2i::zero(), pic_top_, Recti(Vector2i::zero(), pos, TP_B_PIXMAP_THICKNESS));
257257
258 // top bar258 // top bar
259 static_assert(0 <= HZ_B_CORNER_PIXMAP_LEN, "assert(0 <= HZ_B_CORNER_PIXMAP_LEN) failed.");259 static_assert(0 <= HZ_B_CORNER_PIXMAP_LEN, "assert(0 <= HZ_B_CORNER_PIXMAP_LEN) failed.");
260 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)260 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
261 dst.blitrect(261 dst.blitrect(
262 Vector2f(pos, 0), pic_top_, Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0),262 Vector2i(pos, 0), pic_top_, Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0),
263 HZ_B_MIDDLE_PIXMAP_LEN, TP_B_PIXMAP_THICKNESS));263 HZ_B_MIDDLE_PIXMAP_LEN, TP_B_PIXMAP_THICKNESS));
264264
265 // odd pixels of top bar and top right corner265 // odd pixels of top bar and top right corner
266 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;266 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;
267 assert(0 <= HZ_B_TOTAL_PIXMAP_LEN - width);267 assert(0 <= HZ_B_TOTAL_PIXMAP_LEN - width);
268 dst.blitrect(Vector2f(pos, 0), pic_top_,268 dst.blitrect(Vector2i(pos, 0), pic_top_,
269 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, TP_B_PIXMAP_THICKNESS));269 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, TP_B_PIXMAP_THICKNESS));
270 }270 }
271271
@@ -276,9 +276,10 @@
276 autofit_ui_text(richtext_escape(title_), get_inner_w(), UI_FONT_CLR_FG, 13);276 autofit_ui_text(richtext_escape(title_), get_inner_w(), UI_FONT_CLR_FG, 13);
277277
278 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.278 // Blit on pixel boundary (not float), so that the text is blitted pixel perfect.
279 Vector2f pos(get_lborder() + get_inner_w() / 2, TP_B_PIXMAP_THICKNESS / 2);279 Vector2i pos(get_lborder() + get_inner_w() / 2, TP_B_PIXMAP_THICKNESS / 2);
280 UI::correct_for_align(UI::Align::kCenter, text->width(), &pos);
280 UI::center_vertically(text->height(), &pos);281 UI::center_vertically(text->height(), &pos);
281 dst.blit(pos, text, BlendMode::UseAlpha, UI::Align::kCenter);282 dst.blit(pos, text, BlendMode::UseAlpha);
282 }283 }
283284
284 if (!is_minimal_) {285 if (!is_minimal_) {
@@ -290,15 +291,15 @@
290291
291 static_assert(0 <= VT_B_PIXMAP_THICKNESS, "assert(0 <= VT_B_PIXMAP_THICKNESS) failed.");292 static_assert(0 <= VT_B_PIXMAP_THICKNESS, "assert(0 <= VT_B_PIXMAP_THICKNESS) failed.");
292 dst.blitrect // left top thingy293 dst.blitrect // left top thingy
293 (Vector2f(0, TP_B_PIXMAP_THICKNESS), pic_lborder_,294 (Vector2i(0, TP_B_PIXMAP_THICKNESS), pic_lborder_,
294 Recti(Vector2i(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));295 Recti(Vector2i::zero(), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
295296
296 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;297 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
297298
298 // left bar299 // left bar
299 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");300 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
300 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)301 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
301 dst.blitrect(Vector2f(0, pos), pic_lborder_,302 dst.blitrect(Vector2i(0, pos), pic_lborder_,
302 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,303 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,
303 VT_B_MIDDLE_PIXMAP_LEN));304 VT_B_MIDDLE_PIXMAP_LEN));
304305
@@ -306,7 +307,7 @@
306 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;307 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;
307 assert(0 <= VT_B_TOTAL_PIXMAP_LEN - height);308 assert(0 <= VT_B_TOTAL_PIXMAP_LEN - height);
308 dst.blitrect(309 dst.blitrect(
309 Vector2f(0, pos), pic_lborder_,310 Vector2i(0, pos), pic_lborder_,
310 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));311 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));
311 }312 }
312313
@@ -314,22 +315,22 @@
314 const int32_t right_border_x = get_w() - VT_B_PIXMAP_THICKNESS;315 const int32_t right_border_x = get_w() - VT_B_PIXMAP_THICKNESS;
315316
316 dst.blitrect // right top thingy317 dst.blitrect // right top thingy
317 (Vector2f(right_border_x, TP_B_PIXMAP_THICKNESS), pic_rborder_,318 (Vector2i(right_border_x, TP_B_PIXMAP_THICKNESS), pic_rborder_,
318 Recti(Vector2i(0, 0), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));319 Recti(Vector2i::zero(), VT_B_PIXMAP_THICKNESS, VT_B_THINGY_PIXMAP_LEN));
319320
320 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;321 int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
321322
322 // right bar323 // right bar
323 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");324 static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
324 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)325 for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
325 dst.blitrect(Vector2f(right_border_x, pos), pic_rborder_,326 dst.blitrect(Vector2i(right_border_x, pos), pic_rborder_,
326 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,327 Recti(Vector2i(0, VT_B_THINGY_PIXMAP_LEN), VT_B_PIXMAP_THICKNESS,
327 VT_B_MIDDLE_PIXMAP_LEN));328 VT_B_MIDDLE_PIXMAP_LEN));
328329
329 // odd pixels of right bar and right bottom thingy330 // odd pixels of right bar and right bottom thingy
330 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;331 const int32_t height = vt_bar_end - pos + VT_B_THINGY_PIXMAP_LEN;
331 dst.blitrect(332 dst.blitrect(
332 Vector2f(right_border_x, pos), pic_rborder_,333 Vector2i(right_border_x, pos), pic_rborder_,
333 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));334 Recti(Vector2i(0, VT_B_TOTAL_PIXMAP_LEN - height), VT_B_PIXMAP_THICKNESS, height));
334 }335 }
335336
@@ -337,19 +338,19 @@
337 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;338 int32_t pos = HZ_B_CORNER_PIXMAP_LEN;
338339
339 dst.blitrect // bottom left corner340 dst.blitrect // bottom left corner
340 (Vector2f(0, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,341 (Vector2i(0, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
341 Recti(Vector2i(0, 0), pos, BT_B_PIXMAP_THICKNESS));342 Recti(Vector2i::zero(), pos, BT_B_PIXMAP_THICKNESS));
342343
343 // bottom bar344 // bottom bar
344 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)345 for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
345 dst.blitrect(Vector2f(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,346 dst.blitrect(Vector2i(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
346 Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0), HZ_B_MIDDLE_PIXMAP_LEN,347 Recti(Vector2i(HZ_B_CORNER_PIXMAP_LEN, 0), HZ_B_MIDDLE_PIXMAP_LEN,
347 BT_B_PIXMAP_THICKNESS));348 BT_B_PIXMAP_THICKNESS));
348349
349 // odd pixels of bottom bar and bottom right corner350 // odd pixels of bottom bar and bottom right corner
350 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;351 const int32_t width = hz_bar_end - pos + HZ_B_CORNER_PIXMAP_LEN;
351 dst.blitrect(352 dst.blitrect(
352 Vector2f(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,353 Vector2i(pos, get_h() - BT_B_PIXMAP_THICKNESS), pic_bottom_,
353 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, BT_B_PIXMAP_THICKNESS));354 Recti(Vector2i(HZ_B_TOTAL_PIXMAP_LEN - width, 0), width, BT_B_PIXMAP_THICKNESS));
354 }355 }
355 }356 }
356357
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2017-02-28 20:07:07 +0000
+++ src/ui_fsmenu/mapselect.cc 2017-05-13 13:15:21 +0000
@@ -84,7 +84,7 @@
8484
85 // Must be initialized before tag checkboxes85 // Must be initialized before tag checkboxes
86 cb_dont_localize_mapnames_ =86 cb_dont_localize_mapnames_ =
87 new UI::Checkbox(hbox, Vector2i(0, 0), _("Show original map names"));87 new UI::Checkbox(hbox, Vector2i::zero(), _("Show original map names"));
88 cb_dont_localize_mapnames_->set_state(false);88 cb_dont_localize_mapnames_->set_state(false);
89 cb_dont_localize_mapnames_->changedto.connect(89 cb_dont_localize_mapnames_->changedto.connect(
90 boost::bind(&FullscreenMenuMapSelect::fill_table, boost::ref(*this)));90 boost::bind(&FullscreenMenuMapSelect::fill_table, boost::ref(*this)));
@@ -303,7 +303,7 @@
303 int32_t id = tags_ordered_.size();303 int32_t id = tags_ordered_.size();
304 tags_ordered_.push_back(tag);304 tags_ordered_.push_back(tag);
305305
306 UI::Checkbox* cb = new UI::Checkbox(box, Vector2i(0, 0), displ_name);306 UI::Checkbox* cb = new UI::Checkbox(box, Vector2i::zero(), displ_name);
307 cb->changedto.connect(boost::bind(&FullscreenMenuMapSelect::tagbox_changed, this, id, _1));307 cb->changedto.connect(boost::bind(&FullscreenMenuMapSelect::tagbox_changed, this, id, _1));
308308
309 box->add(cb, UI::Box::Resizing::kFullSize);309 box->add(cb, UI::Box::Resizing::kFullSize);
310310
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2017-03-29 12:37:47 +0000
+++ src/ui_fsmenu/options.cc 2017-05-13 13:15:21 +0000
@@ -148,15 +148,15 @@
148 24,148 24,
149 _("In-game resolution")),149 _("In-game resolution")),
150150
151 fullscreen_(&box_interface_, Vector2i(0, 0), _("Fullscreen"), "", 0),151 fullscreen_(&box_interface_, Vector2i::zero(), _("Fullscreen"), "", 0),
152 inputgrab_(&box_interface_, Vector2i(0, 0), _("Grab Input"), "", 0),152 inputgrab_(&box_interface_, Vector2i::zero(), _("Grab Input"), "", 0),
153153
154 sb_maxfps_(&box_interface_, 0, 0, 0, 0, opt.maxfps, 0, 99, _("Maximum FPS:")),154 sb_maxfps_(&box_interface_, 0, 0, 0, 0, opt.maxfps, 0, 99, _("Maximum FPS:")),
155155
156 // Windows options156 // Windows options
157 snap_win_overlap_only_(157 snap_win_overlap_only_(
158 &box_windows_, Vector2i(0, 0), _("Snap windows only when overlapping"), "", 0),158 &box_windows_, Vector2i::zero(), _("Snap windows only when overlapping"), "", 0),
159 dock_windows_to_edges_(&box_windows_, Vector2i(0, 0), _("Dock windows to edges"), "", 0),159 dock_windows_to_edges_(&box_windows_, Vector2i::zero(), _("Dock windows to edges"), "", 0),
160160
161 sb_dis_panel_(&box_windows_,161 sb_dis_panel_(&box_windows_,
162 0,162 0,
@@ -181,9 +181,9 @@
181 UI::SpinBox::Units::kPixels),181 UI::SpinBox::Units::kPixels),
182182
183 // Sound options183 // Sound options
184 music_(&box_sound_, Vector2i(0, 0), _("Enable Music"), "", 0),184 music_(&box_sound_, Vector2i::zero(), _("Enable Music"), "", 0),
185 fx_(&box_sound_, Vector2i(0, 0), _("Enable Sound Effects"), "", 0),185 fx_(&box_sound_, Vector2i::zero(), _("Enable Sound Effects"), "", 0),
186 message_sound_(&box_sound_, Vector2i(0, 0), _("Play a sound at message arrival"), "", 0),186 message_sound_(&box_sound_, Vector2i::zero(), _("Play a sound at message arrival"), "", 0),
187187
188 // Saving options188 // Saving options
189 sb_autosave_(&box_saving_,189 sb_autosave_(&box_saving_,
@@ -213,26 +213,26 @@
213 UI::SpinBox::Type::kBig),213 UI::SpinBox::Type::kBig),
214214
215 zip_(&box_saving_,215 zip_(&box_saving_,
216 Vector2i(0, 0),216 Vector2i::zero(),
217 _("Compress widelands data files (maps, replays and savegames)"),217 _("Compress widelands data files (maps, replays and savegames)"),
218 "",218 "",
219 0),219 0),
220 write_syncstreams_(&box_saving_,220 write_syncstreams_(&box_saving_,
221 Vector2i(0, 0),221 Vector2i::zero(),
222 _("Write syncstreams in network games to debug desyncs"),222 _("Write syncstreams in network games to debug desyncs"),
223 "",223 "",
224 0),224 0),
225225
226 // Game options226 // Game options
227 auto_roadbuild_mode_(227 auto_roadbuild_mode_(
228 &box_game_, Vector2i(0, 0), _("Start building road after placing a flag")),228 &box_game_, Vector2i::zero(), _("Start building road after placing a flag")),
229 show_workarea_preview_(&box_game_, Vector2i(0, 0), _("Show buildings area preview")),229 show_workarea_preview_(&box_game_, Vector2i::zero(), _("Show buildings area preview")),
230 transparent_chat_(230 transparent_chat_(
231 &box_game_, Vector2i(0, 0), _("Show in-game chat with transparent background"), "", 0),231 &box_game_, Vector2i::zero(), _("Show in-game chat with transparent background"), "", 0),
232232
233 /** TRANSLATORS: A watchwindow is a window where you keep watching an object or a map region,*/233 /** TRANSLATORS: A watchwindow is a window where you keep watching an object or a map region,*/
234 /** TRANSLATORS: and it also lets you jump to it on the map. */234 /** TRANSLATORS: and it also lets you jump to it on the map. */
235 single_watchwin_(&box_game_, Vector2i(0, 0), _("Use single watchwindow mode")),235 single_watchwin_(&box_game_, Vector2i::zero(), _("Use single watchwindow mode")),
236 os_(opt) {236 os_(opt) {
237 // Set up UI Elements237 // Set up UI Elements
238 title_.set_fontsize(UI_FONT_SIZE_BIG);238 title_.set_fontsize(UI_FONT_SIZE_BIG);
239239
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2017-05-11 10:45:44 +0000
+++ src/wlapplication.cc 2017-05-13 13:15:21 +0000
@@ -283,9 +283,9 @@
283 game_type_(NONE),283 game_type_(NONE),
284 mouse_swapped_(false),284 mouse_swapped_(false),
285 faking_middle_mouse_button_(false),285 faking_middle_mouse_button_(false),
286 mouse_position_(0, 0),286 mouse_position_(Vector2i::zero()),
287 mouse_locked_(0),287 mouse_locked_(0),
288 mouse_compensate_warp_(0, 0),288 mouse_compensate_warp_(Vector2i::zero()),
289 should_die_(false),289 should_die_(false),
290#ifdef _WIN32290#ifdef _WIN32
291 homedir_(FileSystem::get_homedir() + "\\.widelands"),291 homedir_(FileSystem::get_homedir() + "\\.widelands"),
@@ -469,7 +469,7 @@
469 case SDL_MOUSEMOTION:469 case SDL_MOUSEMOTION:
470 ev.motion.xrel += mouse_compensate_warp_.x;470 ev.motion.xrel += mouse_compensate_warp_.x;
471 ev.motion.yrel += mouse_compensate_warp_.y;471 ev.motion.yrel += mouse_compensate_warp_.y;
472 mouse_compensate_warp_ = Vector2i(0, 0);472 mouse_compensate_warp_ = Vector2i::zero();
473473
474 if (mouse_locked_) {474 if (mouse_locked_) {
475 warp_mouse(mouse_position_);475 warp_mouse(mouse_position_);
@@ -665,7 +665,7 @@
665void WLApplication::warp_mouse(const Vector2i position) {665void WLApplication::warp_mouse(const Vector2i position) {
666 mouse_position_ = position;666 mouse_position_ = position;
667667
668 Vector2i cur_position;668 Vector2i cur_position = Vector2i::zero();
669 SDL_GetMouseState(&cur_position.x, &cur_position.y);669 SDL_GetMouseState(&cur_position.x, &cur_position.y);
670 if (cur_position != position) {670 if (cur_position != position) {
671 mouse_compensate_warp_ += cur_position - position;671 mouse_compensate_warp_ += cur_position - position;
672672
=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc 2017-01-25 18:55:59 +0000
+++ src/wui/chatoverlay.cc 2017-05-13 13:15:21 +0000
@@ -183,10 +183,10 @@
183 const int width = std::min<int>(get_w(), im->width());183 const int width = std::min<int>(get_w(), im->width());
184184
185 if (!m->transparent_) {185 if (!m->transparent_) {
186 dst.fill_rect(Rectf(0, top, width, height), RGBAColor(50, 50, 50, 128), BlendMode::Default);186 dst.fill_rect(Recti(0, top, width, height), RGBAColor(50, 50, 50, 128), BlendMode::Default);
187 }187 }
188 int32_t topcrop = im->height() - height;188 int32_t topcrop = im->height() - height;
189 Recti cropRect(0, topcrop, width, height);189 Recti cropRect(0, topcrop, width, height);
190190
191 dst.blitrect(Vector2f(0, top), im, cropRect);191 dst.blitrect(Vector2i(0, top), im, cropRect);
192}192}
193193
=== modified file 'src/wui/field_overlay_manager.h'
--- src/wui/field_overlay_manager.h 2017-01-25 18:55:59 +0000
+++ src/wui/field_overlay_manager.h 2017-05-13 13:15:21 +0000
@@ -60,7 +60,7 @@
60 }60 }
6161
62 const Image* pic;62 const Image* pic;
63 Vector2i hotspot;63 Vector2i hotspot = Vector2i::zero();
64 };64 };
6565
66 /// A function returning Field::nodecaps() for the build overlay. This can be66 /// A function returning Field::nodecaps() for the build overlay. This can be
@@ -118,7 +118,7 @@
118 }118 }
119 std::set<OverlayId> overlay_ids;119 std::set<OverlayId> overlay_ids;
120 const Image* pic;120 const Image* pic;
121 Vector2i hotspot;121 Vector2i hotspot = Vector2i::zero();
122 int level;122 int level;
123 };123 };
124124
125125
=== modified file 'src/wui/game_tips.cc'
--- src/wui/game_tips.cc 2017-01-25 18:55:59 +0000
+++ src/wui/game_tips.cc 2017-05-13 13:15:21 +0000
@@ -107,11 +107,11 @@
107107
108 uint16_t w = pic_background->width();108 uint16_t w = pic_background->width();
109 uint16_t h = pic_background->height();109 uint16_t h = pic_background->height();
110 Vector2f pt((g_gr->get_xres() - w) / 2, (g_gr->get_yres() - h) / 2);110 Vector2i pt((g_gr->get_xres() - w) / 2, (g_gr->get_yres() - h) / 2);
111 Rectf tips_area(pt, w, h);111 Recti tips_area(pt, w, h);
112 rt.blit(pt, pic_background);112 rt.blit(pt, pic_background);
113113
114 const Image* rendered_text = UI::g_fh1->render(as_game_tip(tips_[index].text), tips_area.w);114 const Image* rendered_text = UI::g_fh1->render(as_game_tip(tips_[index].text), tips_area.w);
115 rt.blit(tips_area.center() - Vector2f(rendered_text->width() / 2, rendered_text->height() / 2),115 rt.blit(tips_area.center().cast<int>() - Vector2i(rendered_text->width() / 2, rendered_text->height() / 2),
116 rendered_text);116 rendered_text);
117}117}
118118
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2017-05-03 07:24:06 +0000
+++ src/wui/general_statistics_menu.cc 2017-05-13 13:15:21 +0000
@@ -129,64 +129,66 @@
129129
130 UI::Radiobutton* btn;130 UI::Radiobutton* btn;
131131
132 radiogroup_.add_button(hbox2, Vector2i(0, 0),132 const Vector2i zero = Vector2i::zero();
133
134 radiogroup_.add_button(hbox2, zero,
133 g_gr->images().get("images/wui/stats/genstats_landsize.png"), _("Land"),135 g_gr->images().get("images/wui/stats/genstats_landsize.png"), _("Land"),
134 &btn);136 &btn);
135 hbox2->add(btn, UI::Box::Resizing::kFillSpace);137 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
136138
137 radiogroup_.add_button(hbox2, Vector2i(0, 0),139 radiogroup_.add_button(hbox2, zero,
138 g_gr->images().get("images/wui/stats/genstats_nrworkers.png"),140 g_gr->images().get("images/wui/stats/genstats_nrworkers.png"),
139 _("Workers"), &btn);141 _("Workers"), &btn);
140 hbox2->add(btn, UI::Box::Resizing::kFillSpace);142 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
141143
142 radiogroup_.add_button(hbox2, Vector2i(0, 0),144 radiogroup_.add_button(hbox2, zero,
143 g_gr->images().get("images/wui/stats/genstats_nrbuildings.png"),145 g_gr->images().get("images/wui/stats/genstats_nrbuildings.png"),
144 _("Buildings"), &btn);146 _("Buildings"), &btn);
145 hbox2->add(btn, UI::Box::Resizing::kFillSpace);147 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
146148
147 radiogroup_.add_button(hbox2, Vector2i(0, 0),149 radiogroup_.add_button(hbox2, zero,
148 g_gr->images().get("images/wui/stats/genstats_nrwares.png"), _("Wares"),150 g_gr->images().get("images/wui/stats/genstats_nrwares.png"), _("Wares"),
149 &btn);151 &btn);
150 hbox2->add(btn, UI::Box::Resizing::kFillSpace);152 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
151153
152 radiogroup_.add_button(hbox2, Vector2i(0, 0),154 radiogroup_.add_button(hbox2, zero,
153 g_gr->images().get("images/wui/stats/genstats_productivity.png"),155 g_gr->images().get("images/wui/stats/genstats_productivity.png"),
154 _("Productivity"), &btn);156 _("Productivity"), &btn);
155 hbox2->add(btn, UI::Box::Resizing::kFillSpace);157 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
156158
157 radiogroup_.add_button(hbox2, Vector2i(0, 0),159 radiogroup_.add_button(hbox2, zero,
158 g_gr->images().get("images/wui/stats/genstats_casualties.png"),160 g_gr->images().get("images/wui/stats/genstats_casualties.png"),
159 _("Casualties"), &btn);161 _("Casualties"), &btn);
160 hbox2->add(btn, UI::Box::Resizing::kFillSpace);162 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
161163
162 radiogroup_.add_button(hbox2, Vector2i(0, 0),164 radiogroup_.add_button(hbox2, zero,
163 g_gr->images().get("images/wui/stats/genstats_kills.png"), _("Kills"),165 g_gr->images().get("images/wui/stats/genstats_kills.png"), _("Kills"),
164 &btn);166 &btn);
165 hbox2->add(btn, UI::Box::Resizing::kFillSpace);167 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
166168
167 radiogroup_.add_button(hbox2, Vector2i(0, 0),169 radiogroup_.add_button(hbox2, zero,
168 g_gr->images().get("images/wui/stats/genstats_msites_lost.png"),170 g_gr->images().get("images/wui/stats/genstats_msites_lost.png"),
169 _("Military buildings lost"), &btn);171 _("Military buildings lost"), &btn);
170 hbox2->add(btn, UI::Box::Resizing::kFillSpace);172 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
171173
172 radiogroup_.add_button(hbox2, Vector2i(0, 0),174 radiogroup_.add_button(hbox2, zero,
173 g_gr->images().get("images/wui/stats/genstats_msites_defeated.png"),175 g_gr->images().get("images/wui/stats/genstats_msites_defeated.png"),
174 _("Military buildings defeated"), &btn);176 _("Military buildings defeated"), &btn);
175 hbox2->add(btn, UI::Box::Resizing::kFillSpace);177 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
176178
177 radiogroup_.add_button(hbox2, Vector2i(0, 0),179 radiogroup_.add_button(hbox2, zero,
178 g_gr->images().get("images/wui/stats/genstats_civil_blds_lost.png"),180 g_gr->images().get("images/wui/stats/genstats_civil_blds_lost.png"),
179 _("Civilian buildings lost"), &btn);181 _("Civilian buildings lost"), &btn);
180 hbox2->add(btn, UI::Box::Resizing::kFillSpace);182 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
181183
182 radiogroup_.add_button(hbox2, Vector2i(0, 0),184 radiogroup_.add_button(hbox2, zero,
183 g_gr->images().get("images/wui/stats/genstats_militarystrength.png"),185 g_gr->images().get("images/wui/stats/genstats_militarystrength.png"),
184 _("Military"), &btn);186 _("Military"), &btn);
185 hbox2->add(btn, UI::Box::Resizing::kFillSpace);187 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
186188
187 if (hook) {189 if (hook) {
188 radiogroup_.add_button(190 radiogroup_.add_button(
189 hbox2, Vector2i(0, 0), g_gr->images().get(cs_pic), cs_name.c_str(), &btn);191 hbox2, zero, g_gr->images().get(cs_pic), cs_name.c_str(), &btn);
190 hbox2->add(btn, UI::Box::Resizing::kFillSpace);192 hbox2->add(btn, UI::Box::Resizing::kFillSpace);
191 }193 }
192194
193195
=== modified file 'src/wui/inputqueuedisplay.cc'
--- src/wui/inputqueuedisplay.cc 2017-01-25 18:55:59 +0000
+++ src/wui/inputqueuedisplay.cc 2017-05-13 13:15:21 +0000
@@ -131,12 +131,12 @@
131 uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_);131 uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_);
132 uint32_t nr_empty_to_draw = cache_size_ - nr_inputs_to_draw;132 uint32_t nr_empty_to_draw = cache_size_ - nr_inputs_to_draw;
133133
134 Vector2f point;134 Vector2i point = Vector2i::zero();
135 point.x = Border + (show_only_ ? 0 : CellWidth + CellSpacing);135 point.x = Border + (show_only_ ? 0 : CellWidth + CellSpacing);
136 point.y = Border + (total_height_ - 2 * Border - WARE_MENU_PIC_HEIGHT) / 2;136 point.y = Border + (total_height_ - 2 * Border - WARE_MENU_PIC_HEIGHT) / 2;
137137
138 for (; nr_inputs_to_draw; --nr_inputs_to_draw, point.x += CellWidth + CellSpacing) {138 for (; nr_inputs_to_draw; --nr_inputs_to_draw, point.x += CellWidth + CellSpacing) {
139 dst.blitrect(Vector2f(point.x, point.y), icon_, Recti(0, 0, icon_->width(), icon_->height()),139 dst.blitrect(Vector2i(point.x, point.y), icon_, Recti(0, 0, icon_->width(), icon_->height()),
140 BlendMode::UseAlpha);140 BlendMode::UseAlpha);
141 }141 }
142 for (; nr_empty_to_draw; --nr_empty_to_draw, point.x += CellWidth + CellSpacing) {142 for (; nr_empty_to_draw; --nr_empty_to_draw, point.x += CellWidth + CellSpacing) {
143143
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2017-03-03 18:13:55 +0000
+++ src/wui/interactive_base.cc 2017-05-13 13:15:21 +0000
@@ -358,8 +358,7 @@
358 if (is_game) {358 if (is_game) {
359 const std::string gametime(gametimestring(egbase().get_gametime(), true));359 const std::string gametime(gametimestring(egbase().get_gametime(), true));
360 const std::string gametime_text = as_condensed(gametime);360 const std::string gametime_text = as_condensed(gametime);
361 dst.blit(Vector2f(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha,361 dst.blit(Vector2i(5, 5), UI::g_fh1->render(gametime_text), BlendMode::UseAlpha);
362 UI::Align::kLeft);
363362
364 static boost::format node_format("(%i, %i)");363 static boost::format node_format("(%i, %i)");
365 node_text = as_condensed((node_format % sel_.pos.node.x % sel_.pos.node.y).str());364 node_text = as_condensed((node_format % sel_.pos.node.x % sel_.pos.node.y).str());
@@ -370,9 +369,9 @@
370 }369 }
371370
372 const Image* rendered_text = UI::g_fh1->render(node_text);371 const Image* rendered_text = UI::g_fh1->render(node_text);
373372 Vector2i point(get_w() - 5, get_h() - rendered_text->height() - 5);
374 dst.blit(Vector2f(get_w() - 5, get_h() - rendered_text->height() - 5), rendered_text,373 UI::correct_for_align(UI::Align::kRight, rendered_text->width(), &point);
375 BlendMode::UseAlpha, UI::Align::kRight);374 dst.blit(point, rendered_text, BlendMode::UseAlpha);
376 }375 }
377376
378 // Blit FPS when playing a game in debug mode.377 // Blit FPS when playing a game in debug mode.
@@ -380,8 +379,8 @@
380 static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");379 static boost::format fps_format("%5.1f fps (avg: %5.1f fps)");
381 const Image* rendered_text = UI::g_fh1->render(as_condensed(380 const Image* rendered_text = UI::g_fh1->render(as_condensed(
382 (fps_format % (1000.0 / frametime_) % (1000.0 / (avg_usframetime_ / 1000))).str()));381 (fps_format % (1000.0 / frametime_) % (1000.0 / (avg_usframetime_ / 1000))).str()));
383 dst.blit(Vector2f((get_w() - rendered_text->width()) / 2, 5), rendered_text,382 dst.blit(Vector2i((get_w() - rendered_text->width()) / 2, 5), rendered_text,
384 BlendMode::UseAlpha, UI::Align::kLeft);383 BlendMode::UseAlpha);
385 }384 }
386}385}
387386
388387
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2017-02-28 16:00:20 +0000
+++ src/wui/interactive_gamebase.cc 2017-05-13 13:15:21 +0000
@@ -126,8 +126,10 @@
126 }126 }
127127
128 if (!game_speed.empty()) {128 if (!game_speed.empty()) {
129 dst.blit(Vector2f(get_w() - 5, 5), UI::g_fh1->render(game_speed), BlendMode::UseAlpha,129 Vector2i point(get_w() - 5, 5);
130 UI::Align::kRight);130 const Image* rendered_speed = UI::g_fh1->render(game_speed);
131 UI::correct_for_align(UI::Align::kRight, rendered_speed->width(), &point);
132 dst.blit(point, rendered_speed, BlendMode::UseAlpha);
131 }133 }
132 }134 }
133}135}
134136
=== modified file 'src/wui/itemwaresdisplay.cc'
--- src/wui/itemwaresdisplay.cc 2017-01-25 18:55:59 +0000
+++ src/wui/itemwaresdisplay.cc 2017-05-13 13:15:21 +0000
@@ -98,7 +98,7 @@
98void ItemWaresDisplay::draw(RenderTarget& dst) {98void ItemWaresDisplay::draw(RenderTarget& dst) {
99 const Widelands::TribeDescr& tribe(player().tribe());99 const Widelands::TribeDescr& tribe(player().tribe());
100100
101 dst.fill_rect(Rectf(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 0));101 dst.fill_rect(Recti(0, 0, get_w(), get_h()), RGBAColor(0, 0, 0, 0));
102102
103 for (uint32_t idx = 0; idx < items_.size(); ++idx) {103 for (uint32_t idx = 0; idx < items_.size(); ++idx) {
104 const Item& it = items_[idx];104 const Item& it = items_[idx];
@@ -117,7 +117,7 @@
117 } else {117 } else {
118 y += IWD_WareBaseLine;118 y += IWD_WareBaseLine;
119 if (tribe.get_ware_descr(it.index)->icon())119 if (tribe.get_ware_descr(it.index)->icon())
120 dst.blit(Vector2f(x, y), tribe.get_ware_descr(it.index)->icon());120 dst.blit(Vector2i(x, y), tribe.get_ware_descr(it.index)->icon());
121 }121 }
122 }122 }
123}123}
124124
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2017-02-12 09:10:57 +0000
+++ src/wui/mapview.cc 2017-05-13 13:15:21 +0000
@@ -133,7 +133,7 @@
133 const Vector2f center_point = center_point_t.value(dt);133 const Vector2f center_point = center_point_t.value(dt);
134 const Vector2f viewpoint = center_point - Vector2f(width * zoom / 2.f, height * zoom / 2.f);134 const Vector2f viewpoint = center_point - Vector2f(width * zoom / 2.f, height * zoom / 2.f);
135 plan->push_back(MapView::TimestampedView{135 plan->push_back(MapView::TimestampedView{
136 static_cast<uint32_t>(std::lround(start_time + dt)), MapView::View{viewpoint, zoom}});136 static_cast<uint32_t>(std::lround(start_time + dt)), MapView::View(viewpoint, zoom)});
137 }137 }
138}138}
139139
@@ -194,7 +194,7 @@
194 Vector2f(width * end.zoom / 2.f, height * end.zoom / 2.f);194 Vector2f(width * end.zoom / 2.f, height * end.zoom / 2.f);
195 plan.push_back(195 plan.push_back(
196 MapView::TimestampedView{static_cast<uint32_t>(std::lround(start_time + duration_ms)),196 MapView::TimestampedView{static_cast<uint32_t>(std::lround(start_time + duration_ms)),
197 MapView::View{end_viewpoint, end.zoom}});197 MapView::View(end_viewpoint, end.zoom)});
198 return plan;198 return plan;
199}199}
200200
@@ -233,11 +233,11 @@
233 plan.push_back(start);233 plan.push_back(start);
234 for (int i = 1; i < kNumKeyFrames - 2; i++) {234 for (int i = 1; i < kNumKeyFrames - 2; i++) {
235 float dt = (kShortAnimationMs / kNumKeyFrames) * i;235 float dt = (kShortAnimationMs / kNumKeyFrames) * i;
236 plan.push_back(MapView::TimestampedMouse{236 plan.push_back(MapView::TimestampedMouse(
237 static_cast<uint32_t>(std::lround(start.t + dt)), mouse_t.value(dt)});237 static_cast<uint32_t>(std::lround(start.t + dt)), mouse_t.value(dt)));
238 }238 }
239 plan.push_back(MapView::TimestampedMouse{239 plan.push_back(MapView::TimestampedMouse(
240 static_cast<uint32_t>(std::lround(start.t + kShortAnimationMs)), target.cast<float>()});240 static_cast<uint32_t>(std::lround(start.t + kShortAnimationMs)), target.cast<float>()));
241 return plan;241 return plan;
242}242}
243243
@@ -299,7 +299,8 @@
299 : UI::Panel(parent, x, y, w, h),299 : UI::Panel(parent, x, y, w, h),
300 renderer_(new GameRenderer()),300 renderer_(new GameRenderer()),
301 intbase_(player),301 intbase_(player),
302 view_{Vector2f(0.f, 0.f), 1.f},302 view_(),
303 last_mouse_pos_(Vector2i::zero()),
303 dragging_(false) {304 dragging_(false) {
304}305}
305306
@@ -446,7 +447,7 @@
446 const TimestampedView current = animation_target_view();447 const TimestampedView current = animation_target_view();
447 const Rectf area = get_view_area(current.view, get_w(), get_h());448 const Rectf area = get_view_area(current.view, get_w(), get_h());
448 const Vector2f target_view = pos - Vector2f(area.w / 2.f, area.h / 2.f);449 const Vector2f target_view = pos - Vector2f(area.w / 2.f, area.h / 2.f);
449 set_view(View{target_view, current.view.zoom}, transition);450 set_view(View(target_view, current.view.zoom), transition);
450}451}
451452
452MapView::ViewArea MapView::view_area() const {453MapView::ViewArea MapView::view_area() const {
@@ -605,7 +606,7 @@
605606
606MapView::TimestampedMouse MapView::animation_target_mouse() const {607MapView::TimestampedMouse MapView::animation_target_mouse() const {
607 if (mouse_plans_.empty()) {608 if (mouse_plans_.empty()) {
608 return TimestampedMouse{SDL_GetTicks(), get_mouse_position().cast<float>()};609 return TimestampedMouse(SDL_GetTicks(), get_mouse_position().cast<float>());
609 }610 }
610 return mouse_plans_.back().back();611 return mouse_plans_.back().back();
611}612}
612613
=== modified file 'src/wui/mapview.h'
--- src/wui/mapview.h 2017-01-25 18:55:59 +0000
+++ src/wui/mapview.h 2017-05-13 13:15:21 +0000
@@ -71,6 +71,11 @@
71 };71 };
7272
73 struct View {73 struct View {
74 View(Vector2f init_viewpoint, float init_zoom) : viewpoint(init_viewpoint), zoom(init_zoom) {
75 }
76 View() : View(Vector2f::zero(), 1.0f) {
77 }
78
74 // Mappixel of top-left pixel of this MapView.79 // Mappixel of top-left pixel of this MapView.
75 Vector2f viewpoint;80 Vector2f viewpoint;
7681
@@ -87,8 +92,12 @@
87 };92 };
8893
89 struct TimestampedMouse {94 struct TimestampedMouse {
95 TimestampedMouse(uint32_t init_t, Vector2f init_pixel) : t(init_t), pixel(init_pixel) {
96 }
97 TimestampedMouse() : t(0), pixel(Vector2f::zero()) {
98 }
90 uint32_t t;99 uint32_t t;
91 Vector2f pixel;100 Vector2f pixel = Vector2f::zero();
92 };101 };
93102
94 MapView(UI::Panel* const parent,103 MapView(UI::Panel* const parent,
95104
=== modified file 'src/wui/minimap.cc'
--- src/wui/minimap.cc 2017-02-12 09:10:57 +0000
+++ src/wui/minimap.cc 2017-05-13 13:15:21 +0000
@@ -52,7 +52,7 @@
52void MiniMap::View::draw(RenderTarget& dst) {52void MiniMap::View::draw(RenderTarget& dst) {
53 minimap_image_ = draw_minimap(ibase_.egbase(), ibase_.get_player(), view_area_, *minimap_type_,53 minimap_image_ = draw_minimap(ibase_.egbase(), ibase_.get_player(), view_area_, *minimap_type_,
54 *minimap_layers_ | MiniMapLayer::ViewWindow);54 *minimap_layers_ | MiniMapLayer::ViewWindow);
55 dst.blit(Vector2f(), minimap_image_.get());55 dst.blit(Vector2i::zero(), minimap_image_.get());
56}56}
5757
58/*58/*
5959
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2017-05-02 12:09:44 +0000
+++ src/wui/plot_area.cc 2017-05-13 13:15:21 +0000
@@ -176,12 +176,13 @@
176 */176 */
177void draw_value(const string& value,177void draw_value(const string& value,
178 const RGBColor& color,178 const RGBColor& color,
179 const Vector2f& pos,179 const Vector2i& pos,
180 RenderTarget& dst) {180 RenderTarget& dst) {
181 const Image* pic = UI::g_fh1->render(ytick_text_style(value, color));181 const Image* pic = UI::g_fh1->render(ytick_text_style(value, color));
182 Vector2f point(pos); // Un-const this182 Vector2i point(pos); // Un-const this
183 UI::correct_for_align(UI::Align::kRight, pic->width(), &point);
183 UI::center_vertically(pic->height(), &point);184 UI::center_vertically(pic->height(), &point);
184 dst.blit(point, pic, BlendMode::UseAlpha, UI::Align::kRight);185 dst.blit(point, pic, BlendMode::UseAlpha);
185}186}
186187
187uint32_t calc_plot_x_max_ticks(int32_t plot_width) {188uint32_t calc_plot_x_max_ticks(int32_t plot_width) {
@@ -229,6 +230,7 @@
229 }230 }
230 // Make sure that we always have a tick231 // Make sure that we always have a tick
231 how_many_ticks = std::max(how_many_ticks, 1u);232 how_many_ticks = std::max(how_many_ticks, 1u);
233
232 // Make sure we haven't more ticks than we have space for -> avoid overlap234 // Make sure we haven't more ticks than we have space for -> avoid overlap
233 how_many_ticks = std::min(how_many_ticks, calc_plot_x_max_ticks(inner_w));235 how_many_ticks = std::min(how_many_ticks, calc_plot_x_max_ticks(inner_w));
234236
@@ -264,9 +266,10 @@
264 // over the number, not to the left266 // over the number, not to the left
265 const Image* xtick = UI::g_fh1->render(267 const Image* xtick = UI::g_fh1->render(
266 xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));268 xtick_text_style((boost::format("-%u ") % (max_x / how_many_ticks * i)).str()));
267 Vector2f pos(posx, inner_h - kSpaceBottom + 10);269 Vector2i pos(posx, inner_h - kSpaceBottom + 10);
270 UI::correct_for_align(UI::Align::kCenter, xtick->width(), &pos);
268 UI::center_vertically(xtick->height(), &pos);271 UI::center_vertically(xtick->height(), &pos);
269 dst.blit(pos, xtick, BlendMode::UseAlpha, UI::Align::kCenter);272 dst.blit(pos, xtick, BlendMode::UseAlpha);
270273
271 posx -= sub;274 posx -= sub;
272 }275 }
@@ -282,9 +285,9 @@
282285
283 // print the used unit286 // print the used unit
284 const Image* xtick = UI::g_fh1->render(xtick_text_style(get_generic_unit_name(unit)));287 const Image* xtick = UI::g_fh1->render(xtick_text_style(get_generic_unit_name(unit)));
285 Vector2f pos(2, kSpacing + 2);288 Vector2i pos(2, kSpacing + 2);
286 UI::center_vertically(xtick->height(), &pos);289 UI::center_vertically(xtick->height(), &pos);
287 dst.blit(pos, xtick, BlendMode::UseAlpha, UI::Align::kLeft);290 dst.blit(pos, xtick, BlendMode::UseAlpha);
288}291}
289292
290} // namespace293} // namespace
@@ -459,8 +462,8 @@
459 * Draw this. This is the main function462 * Draw this. This is the main function
460 */463 */
461void WuiPlotArea::draw(RenderTarget& dst) {464void WuiPlotArea::draw(RenderTarget& dst) {
462 dst.tile(Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),465 dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
463 Vector2i(0, 0));466 Vector2i::zero());
464 draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);467 draw_plot(dst, get_inner_h() - kSpaceBottom, std::to_string(highest_scale_), highest_scale_);
465}468}
466469
@@ -482,7 +485,7 @@
482485
483 // print the maximal value into the top right corner486 // print the maximal value into the top right corner
484 draw_value(yscale_label, RGBColor(60, 125, 0),487 draw_value(yscale_label, RGBColor(60, 125, 0),
485 Vector2f(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);488 Vector2i(get_inner_w() - kSpaceRight - 3, kSpacing + 2), dst);
486}489}
487490
488/**491/**
@@ -671,8 +674,8 @@
671void DifferentialPlotArea::draw(RenderTarget& dst) {674void DifferentialPlotArea::draw(RenderTarget& dst) {
672675
673 // first, tile the background676 // first, tile the background
674 dst.tile(Recti(Vector2i(0, 0), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),677 dst.tile(Recti(Vector2i::zero(), get_inner_w(), get_inner_h()), g_gr->images().get(BG_PIC),
675 Vector2i(0, 0));678 Vector2i::zero());
676679
677 // yoffset of the zero line680 // yoffset of the zero line
678 float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;681 float const yoffset = kSpacing + ((get_inner_h() - kSpaceBottom) - kSpacing) / 2;
@@ -687,7 +690,7 @@
687690
688 // Print the min value691 // Print the min value
689 draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),692 draw_value((boost::format("-%u") % (highest_scale_)).str(), RGBColor(125, 0, 0),
690 Vector2f(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);693 Vector2i(get_inner_w() - kSpaceRight - 3, get_inner_h() - kSpacing - 23), dst);
691}694}
692695
693/**696/**
694697
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2017-02-25 13:27:40 +0000
+++ src/wui/soldierlist.cc 2017-05-13 13:15:21 +0000
@@ -82,7 +82,7 @@
82 Widelands::OPtr<Soldier> soldier;82 Widelands::OPtr<Soldier> soldier;
83 uint32_t row;83 uint32_t row;
84 uint32_t col;84 uint32_t col;
85 Vector2i pos;85 Vector2i pos = Vector2i::zero();
8686
87 /**87 /**
88 * Keep track of how we last rendered this soldier,88 * Keep track of how we last rendered this soldier,
@@ -281,11 +281,11 @@
281 uint32_t fullrows = capacity / kMaxColumns;281 uint32_t fullrows = capacity / kMaxColumns;
282282
283 if (fullrows) {283 if (fullrows) {
284 dst.fill_rect(Rectf(0.f, 0.f, get_w(), icon_height_ * fullrows), RGBAColor(0, 0, 0, 0));284 dst.fill_rect(Recti(0, 0, get_w(), icon_height_ * fullrows), RGBAColor(0, 0, 0, 0));
285 }285 }
286 if (capacity % kMaxColumns) {286 if (capacity % kMaxColumns) {
287 dst.fill_rect(287 dst.fill_rect(
288 Rectf(0.f, icon_height_ * fullrows, icon_width_ * (capacity % kMaxColumns), icon_height_),288 Recti(0, icon_height_ * fullrows, icon_width_ * (capacity % kMaxColumns), icon_height_),
289 RGBAColor(0, 0, 0, 0));289 RGBAColor(0, 0, 0, 0));
290 }290 }
291291
@@ -297,7 +297,7 @@
297297
298 constexpr float kNoZoom = 1.f;298 constexpr float kNoZoom = 1.f;
299 soldier->draw_info_icon(299 soldier->draw_info_icon(
300 icon.pos.cast<float>() + Vector2f(kIconBorder, kIconBorder), kNoZoom, false, &dst);300 icon.pos + Vector2i(kIconBorder, kIconBorder), kNoZoom, false, &dst);
301 }301 }
302}302}
303303
@@ -398,7 +398,7 @@
398398
399 bool can_act = igbase_.can_act(building_.owner().player_number());399 bool can_act = igbase_.can_act(building_.owner().player_number());
400 if (upcast(Widelands::MilitarySite, ms, &building)) {400 if (upcast(Widelands::MilitarySite, ms, &building)) {
401 soldier_preference_.add_button(buttons, Vector2i(0, 0),401 soldier_preference_.add_button(buttons, Vector2i::zero(),
402 g_gr->images().get("images/wui/buildings/prefer_rookies.png"),402 g_gr->images().get("images/wui/buildings/prefer_rookies.png"),
403 _("Prefer Rookies"));403 _("Prefer Rookies"));
404 soldier_preference_.add_button(buttons, Vector2i(32, 0),404 soldier_preference_.add_button(buttons, Vector2i(32, 0),
405405
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2017-02-27 18:28:39 +0000
+++ src/wui/warehousewindow.cc 2017-05-13 13:15:21 +0000
@@ -94,7 +94,7 @@
94 }94 }
95 assert(pic != nullptr);95 assert(pic != nullptr);
9696
97 dst.blit(ware_position(ware).cast<float>(), pic);97 dst.blit(ware_position(ware), pic);
98}98}
9999
100/**100/**
101101
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2017-04-30 08:40:08 +0000
+++ src/wui/waresdisplay.cc 2017-05-13 13:15:21 +0000
@@ -320,20 +320,20 @@
320 "images/wui/ware_list_bg.png");320 "images/wui/ware_list_bg.png");
321 uint16_t w = bgpic->width();321 uint16_t w = bgpic->width();
322322
323 const Vector2f p = ware_position(id).cast<float>();323 const Vector2i p = ware_position(id);
324 dst.blit(p, bgpic);324 dst.blit(p, bgpic);
325325
326 const Image* icon = type_ == Widelands::wwWORKER ? tribe_.get_worker_descr(id)->icon() :326 const Image* icon = type_ == Widelands::wwWORKER ? tribe_.get_worker_descr(id)->icon() :
327 tribe_.get_ware_descr(id)->icon();327 tribe_.get_ware_descr(id)->icon();
328328
329 dst.blit(p + Vector2f((w - WARE_MENU_PIC_WIDTH) / 2.f, 1.f), icon);329 dst.blit(p + Vector2i((w - WARE_MENU_PIC_WIDTH) / 2, 1), icon);
330330
331 dst.fill_rect(Rectf(p + Vector2f(0.f, WARE_MENU_PIC_HEIGHT), w, WARE_MENU_INFO_SIZE),331 dst.fill_rect(Recti(p + Vector2i(0, WARE_MENU_PIC_HEIGHT), w, WARE_MENU_INFO_SIZE),
332 info_color_for_ware(id));332 info_color_for_ware(id));
333333
334 const Image* text = UI::g_fh1->render(as_waresinfo(info_for_ware(id)));334 const Image* text = UI::g_fh1->render(as_waresinfo(info_for_ware(id)));
335 if (text) // might be zero when there is no info text.335 if (text) // might be zero when there is no info text.
336 dst.blit(p + Vector2f(w - text->width() - 1,336 dst.blit(p + Vector2i(w - text->width() - 1,
337 WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + 1 - text->height()),337 WARE_MENU_PIC_HEIGHT + WARE_MENU_INFO_SIZE + 1 - text->height()),
338 text);338 text);
339}339}

Subscribers

People subscribed via source and target branches

to status/vote changes: