From 739629354bcfcb45a594d144dc60bb152a8508e0 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 19 Jan 2015 00:44:15 +0300 Subject: [PATCH] Make setters return reference to self: Font --- SDL2pp/Font.cc | 12 ++++++++---- SDL2pp/Font.hh | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/SDL2pp/Font.cc b/SDL2pp/Font.cc index 4926716..86b7ec8 100644 --- a/SDL2pp/Font.cc +++ b/SDL2pp/Font.cc @@ -68,32 +68,36 @@ int Font::GetStyle() const { return TTF_GetFontStyle(font_); } -void Font::SetStyle(int style) { +Font& Font::SetStyle(int style) { TTF_SetFontStyle(font_, style); + return *this; } int Font::GetOutline() const { return TTF_GetFontOutline(font_); } -void Font::SetOutline(int outline) { +Font& Font::SetOutline(int outline) { TTF_SetFontOutline(font_, outline); + return *this; } int Font::GetHinting() const { return TTF_GetFontHinting(font_); } -void Font::SetHinting(int hinting) { +Font& Font::SetHinting(int hinting) { TTF_SetFontHinting(font_, hinting); + return *this; } bool Font::GetKerning() const { return TTF_GetFontKerning(font_); } -void Font::SetKerning(bool allowed) { +Font& Font::SetKerning(bool allowed) { TTF_SetFontKerning(font_, allowed); + return *this; } int Font::GetHeight() const { diff --git a/SDL2pp/Font.hh b/SDL2pp/Font.hh index 52ec454..e932c84 100644 --- a/SDL2pp/Font.hh +++ b/SDL2pp/Font.hh @@ -177,10 +177,12 @@ public: /// In this case, you should probably turn off these styles and draw your /// own strikethroughs and underlines. /// + /// \returns Reference to self + /// /// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC22 /// //////////////////////////////////////////////////////////// - void SetStyle(int style = TTF_STYLE_NORMAL); + Font& SetStyle(int style = TTF_STYLE_NORMAL); //////////////////////////////////////////////////////////// /// \brief Get the current outline size of the loaded font @@ -202,10 +204,12 @@ public: /// glyphs, even if there is no change in outline size, so it may be best /// to check the current outline size by using GetOutline() first /// + /// \returns Reference to self + /// /// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC24 /// //////////////////////////////////////////////////////////// - void SetOutline(int outline = 0); + Font& SetOutline(int outline = 0); //////////////////////////////////////////////////////////// /// \brief Get the current hinting setting of the loaded font @@ -235,10 +239,12 @@ public: /// glyphs, even if there is no change in hinting, so it may be best /// to check the current hinting by using GetHinting() first /// + /// \returns Reference to self + /// /// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC26 /// //////////////////////////////////////////////////////////// - void SetHinting(int hinting = TTF_HINTING_NORMAL); + Font& SetHinting(int hinting = TTF_HINTING_NORMAL); //////////////////////////////////////////////////////////// /// \brief Get the current kerning setting of the loaded font @@ -264,10 +270,12 @@ public: /// is not working for a specific font, resulting in overlapping /// glyphs or abnormal spacing within words. /// + /// \returns Reference to self + /// /// \see https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC28 /// //////////////////////////////////////////////////////////// - void SetKerning(bool allowed = true); + Font& SetKerning(bool allowed = true); //////////////////////////////////////////////////////////// /// \brief Get the maximum pixel height of all glyphs of the loaded font