Mercurial > malikania
changeset 143:7627d614f3e0
Client: add const overload to take const font in draw_text
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 28 Sep 2017 12:49:27 +0200 |
parents | 473e1eb96363 |
children | 67eac3fc099f |
files | libclient/malikania/client/backend/sdl/font_backend.hpp libclient/malikania/client/backend/sdl/window_backend.cpp libclient/malikania/client/backend/sdl/window_backend.hpp libclient/malikania/client/window.cpp libclient/malikania/client/window.hpp |
diffstat | 5 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libclient/malikania/client/backend/sdl/font_backend.hpp Thu Sep 28 12:36:15 2017 +0200 +++ b/libclient/malikania/client/backend/sdl/font_backend.hpp Thu Sep 28 12:49:27 2017 +0200 @@ -39,6 +39,11 @@ public: backend_impl(std::string data, unsigned size); + inline TTF_Font* font() const noexcept + { + return m_font.get(); + } + inline TTF_Font* font() noexcept { return m_font.get();
--- a/libclient/malikania/client/backend/sdl/window_backend.cpp Thu Sep 28 12:36:15 2017 +0200 +++ b/libclient/malikania/client/backend/sdl/window_backend.cpp Thu Sep 28 12:49:27 2017 +0200 @@ -544,7 +544,7 @@ throw std::runtime_error(SDL_GetError()); } -void window::backend_impl::draw_text(const std::string& text, font& font, const rectangle& rectangle) +void window::backend_impl::draw_text(const std::string& text, const font& font, const rectangle& rectangle) { SDL_Color color = {0, 0, 0, 255}; SDL_Surface* message = TTF_RenderUTF8_Blended(font.backend().font(), text.c_str(), color); @@ -555,7 +555,7 @@ SDL_DestroyTexture(texture); } -void window::backend_impl::draw_text(const std::string &text, font& font, const point& point) +void window::backend_impl::draw_text(const std::string &text, const font& font, const point& point) { SDL_Color color = {0, 0, 0, 0}; SDL_GetRenderDrawColor(renderer_.get(), &color.r, &color.g, &color.b, &color.a);
--- a/libclient/malikania/client/backend/sdl/window_backend.hpp Thu Sep 28 12:36:15 2017 +0200 +++ b/libclient/malikania/client/backend/sdl/window_backend.hpp Thu Sep 28 12:49:27 2017 +0200 @@ -78,9 +78,9 @@ void fill_rectangles(const std::vector<rectangle>& rects); - void draw_text(const std::string& text, font& font, const rectangle& rectangle); + void draw_text(const std::string& text, const font& font, const rectangle& rectangle); - void draw_text(const std::string& text, font& font, const point& point); + void draw_text(const std::string& text, const font& font, const point& point); void poll(dispatcher& dp); };
--- a/libclient/malikania/client/window.cpp Thu Sep 28 12:36:15 2017 +0200 +++ b/libclient/malikania/client/window.cpp Thu Sep 28 12:49:27 2017 +0200 @@ -141,12 +141,12 @@ backend_->fill_rectangles(rectangles); } -void window::draw_text(const std::string& text, font& font, const rectangle& rectangle) +void window::draw_text(const std::string& text, const font& font, const rectangle& rectangle) { backend_->draw_text(text, font, rectangle); } -void window::draw_text(const std::string& text, font& font, const point& point) +void window::draw_text(const std::string& text, const font& font, const point& point) { backend_->draw_text(text, font, point); }
--- a/libclient/malikania/client/window.hpp Thu Sep 28 12:36:15 2017 +0200 +++ b/libclient/malikania/client/window.hpp Thu Sep 28 12:49:27 2017 +0200 @@ -264,7 +264,7 @@ * \param font the font * \param rectangle the rectangle target */ - void draw_text(const std::string& text, font& font, const rectangle& rectangle); + void draw_text(const std::string& text, const font& font, const rectangle& rectangle); /** * Overloaded function. @@ -275,7 +275,7 @@ * \param font the font * \param point the text position */ - void draw_text(const std::string& text, font& font, const point& point); + void draw_text(const std::string& text, const font& font, const point& point); /** * Poll all pending events and call appropriate functions.