diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index ae6b63b48..75f4d48f9 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -49,8 +49,6 @@ namespace Ndk inline const TextAreaWidget* GetInput() const; inline const Nz::FontRef& GetTextFont() const; - void ResizeToContent() override; - void SetCharacterSize(unsigned int size); void SetFocus(); void SetTextFont(Nz::FontRef font); diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index 3a02e741f..2a7234b79 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -83,7 +83,7 @@ namespace Ndk inline std::size_t TextAreaWidget::GetGlyphIndex() const { - return GetGlyphIndex(m_cursorPosition); + return GetGlyphIndex(m_cursorPositionBegin); } inline std::size_t TextAreaWidget::GetGlyphIndex(const Nz::Vector2ui& cursorPosition) const diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index b190250ff..c26b1e7d2 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -154,7 +154,7 @@ namespace Ndk overlay->console = info.canvas->Add(overlay->lua); Console& consoleRef = *overlay->console; - consoleRef.SetSize({float(windowDimensions.x), windowDimensions.y / 4.f}); + consoleRef.Resize({float(windowDimensions.x), windowDimensions.y / 4.f}); consoleRef.Show(false); // Redirect logs toward the console @@ -227,7 +227,7 @@ namespace Ndk overlay->resizedSlot.Connect(info.renderTarget->OnRenderTargetSizeChange, [&consoleRef] (const Nz::RenderTarget* renderTarget) { Nz::Vector2ui size = renderTarget->GetSize(); - consoleRef.SetSize({float(size.x), size.y / 4.f}); + consoleRef.Resize({float(size.x), size.y / 4.f}); }); info.console = std::move(overlay); diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index f1f43ed9d..a6ad6d38a 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -47,14 +47,12 @@ namespace Ndk m_history->EnableBackground(true); m_history->SetReadOnly(true); m_history->SetBackgroundColor(Nz::Color(80, 80, 160, 128)); - m_history->SetPadding(0.f, 0.f, 0.f, 4.f); // Input m_input = Add(); m_input->EnableBackground(true); m_input->SetText(s_inputPrefix); m_input->SetTextColor(Nz::Color::Black); - m_input->SetPadding(0.f, 2.f, 0.f, 2.f); m_input->OnTextAreaKeyReturn.Connect(this, &Console::ExecuteInput); @@ -92,9 +90,6 @@ namespace Ndk m_input->SetText(s_inputPrefix + m_commandHistory[m_historyPosition]); }); - - // General - SetPadding(0.f, 0.f, 0.f, 0.f); } /*! @@ -131,10 +126,6 @@ namespace Ndk m_input->ClearFocus(); } - void Console::ResizeToContent() - { - } - /*! * \brief Sets the character size * @@ -206,8 +197,8 @@ namespace Ndk void Console::Layout() { - Nz::Vector2f origin = GetContentOrigin(); - const Nz::Vector2f& size = GetContentSize(); + Nz::Vector2f origin = Nz::Vector2f(GetPosition()); + const Nz::Vector2f& size = GetSize(); unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight; float historyHeight = size.y - lineHeight; @@ -215,10 +206,10 @@ namespace Ndk m_maxHistoryLines = static_cast(std::ceil(historyHeight / lineHeight)); float diff = historyHeight - m_maxHistoryLines * lineHeight; + m_history->Resize({ size.x, historyHeight - diff - 4.f }); m_history->SetPosition(origin.x, origin.y + diff); - m_history->SetSize({size.x, historyHeight - diff - 4.f}); - m_input->SetContentSize({size.x, size.y - historyHeight}); + m_input->Resize({size.x, size.y - historyHeight}); m_input->SetPosition(origin.x, origin.y + historyHeight); } }