diff --git a/inc/basic_widgets/core/draw.hpp b/inc/basic_widgets/core/draw.hpp index 6c1c5b5..6ca69e8 100644 --- a/inc/basic_widgets/core/draw.hpp +++ b/inc/basic_widgets/core/draw.hpp @@ -19,7 +19,7 @@ namespace bwidgets std::shared_ptr, int aa_pixels = 3) -> std::shared_ptr; void set_pixels_color( - std::shared_ptr, + Texture*, const std::function&); } diff --git a/inc/basic_widgets/core/renderer.hpp b/inc/basic_widgets/core/renderer.hpp index 1764478..afab015 100644 --- a/inc/basic_widgets/core/renderer.hpp +++ b/inc/basic_widgets/core/renderer.hpp @@ -44,7 +44,7 @@ namespace bwidgets [[nodiscard]] auto blend_mode() -> SDL_BlendMode; auto blend_mode(SDL_BlendMode) -> Renderer*; auto clear() -> Renderer*; - auto copy(const std::shared_ptr&, const SDL_Rect*, const SDL_Rect*) + auto copy(const Texture*, const SDL_Rect*, const SDL_Rect*) -> Renderer*; [[nodiscard]] auto draw_color() -> Color; auto draw_color(const Color&) -> Renderer*; @@ -61,19 +61,19 @@ namespace bwidgets [[nodiscard]] auto viewport() noexcept -> SDL_Rect; auto viewport(const SDL_Rect*) -> Renderer*; - inline auto copy(const std::shared_ptr& t, const SDL_Rect* src, + inline auto copy(const Texture* t, const SDL_Rect* src, const SDL_Rect& dst) { const auto d = dst; return copy(t, src, &d); } - inline auto copy(const std::shared_ptr& t, const SDL_Rect& src, + inline auto copy(const Texture* t, const SDL_Rect& src, const SDL_Rect* dst) { const auto s = src; return copy(t, &s, dst); } - inline auto copy(const std::shared_ptr& t, const SDL_Rect& src, + inline auto copy(const Texture* t, const SDL_Rect& src, const SDL_Rect& dst) { const auto s = src; diff --git a/inc/basic_widgets/core/texture.hpp b/inc/basic_widgets/core/texture.hpp index 9eb8af2..158a99a 100644 --- a/inc/basic_widgets/core/texture.hpp +++ b/inc/basic_widgets/core/texture.hpp @@ -29,9 +29,9 @@ namespace bwidgets public: Texture(SDL_Texture*); - Texture(const std::shared_ptr&, SDL_PixelFormatEnum, SDL_TextureAccess, + Texture(Renderer*, SDL_PixelFormatEnum, SDL_TextureAccess, int, int); - Texture(const std::shared_ptr&, SDL_Surface*); + Texture(Renderer*, SDL_Surface*); Texture(const Texture&) = delete; Texture(Texture&&) = delete; ~Texture() noexcept; diff --git a/inc/basic_widgets/w/base/layout.hpp b/inc/basic_widgets/w/base/layout.hpp index ddd1cb8..d51c103 100644 --- a/inc/basic_widgets/w/base/layout.hpp +++ b/inc/basic_widgets/w/base/layout.hpp @@ -35,7 +35,7 @@ namespace bwidgets virtual auto add_widget(const std::shared_ptr&) -> Layout*; virtual void - for_widgets(const std::function&)>&); + for_widgets(const std::function&); }; } diff --git a/src/core/draw.cpp b/src/core/draw.cpp index 644dc84..24b73f6 100644 --- a/src/core/draw.cpp +++ b/src/core/draw.cpp @@ -25,7 +25,7 @@ namespace bwidgets return c; } - auto filled_circle(const Color& c, const int resolution, std::shared_ptr r, + auto filled_circle(const Color& c, const int resolution, Renderer* r, const int aa_pixels) -> std::shared_ptr { // clang-format off @@ -40,7 +40,7 @@ namespace bwidgets const SDL_Point center {radius, radius}; set_pixels_color( - texture, + texture.get(), [aa_pixels, c, center, radius](const SDL_Point& p, const SDL_PixelFormat* format) -> uint32_t { const auto d_delta = distance(center, p) - (float)radius; @@ -56,7 +56,7 @@ namespace bwidgets } void set_pixels_color( - const std::shared_ptr& t, + Texture* t, const std::function& pixel_color) { diff --git a/src/core/renderer.cpp b/src/core/renderer.cpp index e4ae562..dc40cdd 100644 --- a/src/core/renderer.cpp +++ b/src/core/renderer.cpp @@ -39,7 +39,7 @@ auto Renderer::clear() -> Renderer* return this; } -auto Renderer::copy(const std::shared_ptr& t, const SDL_Rect* src, +auto Renderer::copy(const Texture* t, const SDL_Rect* src, const SDL_Rect* dst) -> Renderer* { SDLError::success_or_throw(SDL_RenderCopy(_data(), t->_data(), src, dst), __FILE__, diff --git a/src/core/texture.cpp b/src/core/texture.cpp index a6ceec0..6498000 100644 --- a/src/core/texture.cpp +++ b/src/core/texture.cpp @@ -10,12 +10,12 @@ Texture::Texture(SDL_Texture* t) _attributes = attributes(t); } -Texture::Texture(const std::shared_ptr& r, const SDL_PixelFormatEnum f, +Texture::Texture(Renderer* r, const SDL_PixelFormatEnum f, const SDL_TextureAccess a, int w, int h) : Texture(SDL_CreateTexture(r->_data(), f, a, w, h)) {} -Texture::Texture(const std::shared_ptr& r, SDL_Surface* s) +Texture::Texture(Renderer* r, SDL_Surface* s) : Texture(SDL_CreateTextureFromSurface(r->_data(), s)) { _attributes = attributes(_data()); diff --git a/src/w/base/layout.cpp b/src/w/base/layout.cpp index 4856254..d73b7c1 100644 --- a/src/w/base/layout.cpp +++ b/src/w/base/layout.cpp @@ -10,9 +10,9 @@ auto Layout::add_widget(const std::shared_ptr& widget_ptr) -> Layout* return this; } -void Layout::for_widgets(const std::function&)>& f) +void Layout::for_widgets(const std::function& f) { - for (const auto& w : _widgets) f(w); + for (const auto& w : _widgets) f(w.get()); } auto Layout::handle_event(const SDL_Event& ev) -> Layout* diff --git a/src/w/caption.cpp b/src/w/caption.cpp index 1340349..c6843e2 100644 --- a/src/w/caption.cpp +++ b/src/w/caption.cpp @@ -96,7 +96,7 @@ void Caption::_handle_rendering() texture_dst.x = _widget_area.w - texture_dst.w - margins.w + _widget_area.x; break; } - _renderer->copy(_text_texture, nullptr, texture_dst); + _renderer->copy(_text_texture.get(), nullptr, texture_dst); } void Caption::_handle_texture_update() @@ -111,6 +111,6 @@ void Caption::_handle_texture_update() s = _font->render(_render_mode, _text, _font_color_fg); break; } - _text_texture = std::make_shared(_renderer, s); + _text_texture = std::make_shared(_renderer.get(), s); SDL_FreeSurface(s); }