Merge branch 'master' into console-widget
This commit is contained in:
parent
400e8e92aa
commit
1c0a234d04
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ namespace Ndk
|
|||
overlay->console = info.canvas->Add<Console>(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);
|
||||
|
|
|
|||
|
|
@ -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<TextAreaWidget>();
|
||||
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<unsigned int>(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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue