diff --git a/libs/gfx/include/psemek/gfx/texture_view.hpp b/libs/gfx/include/psemek/gfx/texture_view.hpp index a42e1e10..e8378485 100644 --- a/libs/gfx/include/psemek/gfx/texture_view.hpp +++ b/libs/gfx/include/psemek/gfx/texture_view.hpp @@ -3,6 +3,8 @@ #include #include +#include + namespace psemek::gfx { @@ -10,19 +12,19 @@ namespace psemek::gfx struct basic_texture_view { basic_texture const * texture = nullptr; - geom::box part; + geom::box part; basic_texture_view(basic_texture const * texture = nullptr); - basic_texture_view(basic_texture const * texture, geom::box const & part); + basic_texture_view(basic_texture const * texture, geom::box const & part); - geom::vector size() const { return part.dimensions(); } + geom::vector size() const { return part.dimensions(); } - std::size_t width() const + float width() const { return part[0].length(); } - std::size_t height() const + float height() const { if constexpr (D >= 2) return part[1].length(); @@ -30,7 +32,7 @@ namespace psemek::gfx return 1; } - std::size_t depth() const + float depth() const { if constexpr (D >= 3) return part[2].length(); @@ -47,13 +49,13 @@ namespace psemek::gfx { if (texture) { - static const auto zero = geom::point::zero(); - part = geom::span(zero, zero + texture->size()); + static const auto zero = geom::point::zero(); + part = geom::span(zero, zero + geom::cast(texture->size())); } } template - basic_texture_view::basic_texture_view(basic_texture const * texture, geom::box const & part) + basic_texture_view::basic_texture_view(basic_texture const * texture, geom::box const & part) : texture(texture) , part(part) {} diff --git a/libs/ui/include/psemek/ui/label.hpp b/libs/ui/include/psemek/ui/label.hpp index 1ea6c44c..ebac04bd 100644 --- a/libs/ui/include/psemek/ui/label.hpp +++ b/libs/ui/include/psemek/ui/label.hpp @@ -97,7 +97,7 @@ namespace psemek::ui { struct image { - geom::box texcoords; + geom::box texcoords; geom::box position; }; diff --git a/libs/ui/source/label.cpp b/libs/ui/source/label.cpp index 67400fc4..98502a45 100644 --- a/libs/ui/source/label.cpp +++ b/libs/ui/source/label.cpp @@ -317,7 +317,7 @@ namespace psemek::ui image.position = g.position; image.position[0] += (std::round(image.position[0].min) - image.position[0].min); image.position[1] += (std::round(image.position[1].min) - image.position[1].min); - image.texcoords = geom::cast(*tc); + image.texcoords = *tc; } } diff --git a/libs/ui/source/painter_impl.cpp b/libs/ui/source/painter_impl.cpp index fc28e3fc..b28c36b4 100644 --- a/libs/ui/source/painter_impl.cpp +++ b/libs/ui/source/painter_impl.cpp @@ -364,12 +364,10 @@ void main() p11 = c + geom::rotate(p11 - c, rotation); } - auto part = geom::cast(tex.part); - - batch.vertices.push_back({p00, depth, color, part.corner(0.f, 0.f)}); - batch.vertices.push_back({p10, depth, color, part.corner(1.f, 0.f)}); - batch.vertices.push_back({p01, depth, color, part.corner(0.f, 1.f)}); - batch.vertices.push_back({p11, depth, color, part.corner(1.f, 1.f)}); + batch.vertices.push_back({p00, depth, color, tex.part.corner(0.f, 0.f)}); + batch.vertices.push_back({p10, depth, color, tex.part.corner(1.f, 0.f)}); + batch.vertices.push_back({p01, depth, color, tex.part.corner(0.f, 1.f)}); + batch.vertices.push_back({p11, depth, color, tex.part.corner(1.f, 1.f)}); batch.indices.insert(batch.indices.end(), {base + 0, base + 1, base + 2, base + 2, base + 1, base + 3}); diff --git a/libs/ui/source/rich_image_view.cpp b/libs/ui/source/rich_image_view.cpp index 07040b3d..ba7548af 100644 --- a/libs/ui/source/rich_image_view.cpp +++ b/libs/ui/source/rich_image_view.cpp @@ -177,7 +177,7 @@ namespace psemek::ui if (*st->shadow_offset != geom::vector{0, 0}) p.draw_rect(box + geom::cast(*st->shadow_offset), *st->shadow_color); - p.draw_image(box, {image_.get(), geom::cast(reg)}, color_); + p.draw_image(box, {image_.get(), reg}, color_); } }