diff --git a/src/Text.cpp b/src/Text.cpp index 69e4f26..8d9c5b6 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -26,9 +26,9 @@ void Text::font(std::shared_ptr font) refresh(); } -void Text::size(const glm::vec2 &size) +void Text::dimensions(const glm::vec2 &dimensions) { - _size = size; + _dimensions = dimensions; refresh(); } @@ -48,21 +48,21 @@ void Text::refresh() } else { - /* Use the size of the rendered text unless size has been set. */ - glm::vec2 size; - if (_size.has_value()) + /* Use the size of the rendered text unless dimensions has been set. */ + glm::vec2 dimensions; + if (_dimensions.has_value()) { - size = _size.value(); + dimensions = _dimensions.value(); } else { - size = glm::vec2{blended->w, blended->h}; + dimensions = glm::vec2{blended->w, blended->h}; } /* Create a container surface with the same format as the rendered text that the rendered text will be composited onto. */ std::shared_ptr container { - SDL_CreateRGBSurfaceWithFormat(0, size.x, size.y, blended->format->BitsPerPixel, blended->format->format), + SDL_CreateRGBSurfaceWithFormat(0, dimensions.x, dimensions.y, blended->format->BitsPerPixel, blended->format->format), SDL_FreeSurface }; diff --git a/src/Text.hpp b/src/Text.hpp index e51deac..40a14e2 100644 --- a/src/Text.hpp +++ b/src/Text.hpp @@ -20,7 +20,7 @@ namespace sb std::string _content; sb::Color _foreground, _background; std::shared_ptr _font; - std::optional _size; + std::optional _dimensions; GLint _scaling_quality = GL_LINEAR; /*! @@ -36,7 +36,7 @@ namespace sb * * The font must be wrapped in a shared pointer. A default loaded font is available from Game::font(). * - * A size can be given in pixels, in which case the text will be rendered at the center of a texture in exactly the given dimensions, + * Dimensions can be given in pixels, in which case the text will be rendered at the center of a texture in exactly the given dimensions, * regardless of the length of the text. If the given dimensions are larger than the text, the resulting texture will have padding around * the text. This can be useful, for example, for creating identically sized text buttons. * @@ -44,11 +44,11 @@ namespace sb * @param content text content * @param foreground text color * @param background background color - * @param size force the texture to be a certain size in pixels, extra area is filled with the background color + * @param dimensions force the texture to be a certain size in pixels, extra area is filled with the background color */ Text(std::shared_ptr font, const std::string& content = "", const sb::Color& foreground = DEFAULT_FG, - const sb::Color& background = DEFAULT_BG, std::optional size = std::nullopt) : - _content(content), _foreground(foreground), _background(background), _font(font), _size(size) + const sb::Color& background = DEFAULT_BG, std::optional dimensions = std::nullopt) : + _content(content), _foreground(foreground), _background(background), _font(font), _dimensions(dimensions) { /* Add an empty Texture object */ texture(sb::Texture()); @@ -75,9 +75,9 @@ namespace sb void font(std::shared_ptr font); /*! - * @param size force the texture to be a certain size in pixels, extra area is filled with the background color + * @param dimensions force the texture to be a certain size in pixels, extra area is filled with the background color */ - void size(const glm::vec2& size); + void dimensions(const glm::vec2& dimensions); /*! * This GL parameter will be passed to `glTexParameter` for `GL_TEXTURE_MIN_FILTER` and `GL_TEXTURE_MAG_FILTER`.