From 917c41f90e250c28a1c3fc17fefe19c083e30df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 12 Apr 2018 13:40:39 +0200 Subject: [PATCH] Sdk/TextAreaWidget: Fix GetGlyphIndex not being const + add overload returning current glyph index --- SDK/include/NDK/Widgets/TextAreaWidget.hpp | 3 ++- SDK/include/NDK/Widgets/TextAreaWidget.inl | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index e0f08053e..873ca274a 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -34,7 +34,8 @@ namespace Ndk inline const Nz::Vector2ui& GetCursorPosition() const; inline const Nz::String& GetDisplayText() const; inline EchoMode GetEchoMode() const; - inline std::size_t GetGlyphIndex(const Nz::Vector2ui& cursorPosition); + inline std::size_t GetGlyphIndex() const; + inline std::size_t GetGlyphIndex(const Nz::Vector2ui& cursorPosition) const; inline const Nz::String& GetText() const; inline const Nz::Color& GetTextColor() const; diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index 07daf7896..1e13a96e5 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -37,7 +37,17 @@ namespace Ndk return m_drawer.GetText(); } - inline std::size_t TextAreaWidget::GetGlyphIndex(const Nz::Vector2ui& cursorPosition) + inline EchoMode TextAreaWidget::GetEchoMode() const + { + return m_echoMode; + } + + inline std::size_t TextAreaWidget::GetGlyphIndex() const + { + return GetGlyphIndex(m_cursorPosition); + } + + inline std::size_t TextAreaWidget::GetGlyphIndex(const Nz::Vector2ui& cursorPosition) const { std::size_t glyphIndex = m_drawer.GetLine(cursorPosition.y).glyphIndex + cursorPosition.x; if (m_drawer.GetLineCount() > cursorPosition.y + 1) @@ -48,11 +58,6 @@ namespace Ndk return glyphIndex; } - inline EchoMode TextAreaWidget::GetEchoMode() const - { - return m_echoMode; - } - inline const Nz::String& TextAreaWidget::GetText() const { return m_text;