Merge branch 'master' into vulkan

This commit is contained in:
Lynix
2020-05-27 19:48:22 +02:00
179 changed files with 41359 additions and 5418 deletions

View File

@@ -167,7 +167,7 @@ namespace Ndk
overlay->keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event)
{
if (event.code == Nz::Keyboard::F9)
if (event.virtualKey == Nz::Keyboard::VKey::F9)
{
// Toggle console visibility and focus
if (consoleRef.IsVisible())

View File

@@ -39,16 +39,16 @@ namespace Ndk
}
/*!
* \brief Frees the widget, unregistering it from its canvas
*/
* \brief Frees the widget, unregistering it from its canvas
*/
BaseWidget::~BaseWidget()
{
UnregisterFromCanvas();
}
/*!
* \brief Clears keyboard focus if and only if this widget owns it.
*/
* \brief Clears keyboard focus if and only if this widget owns it.
*/
void BaseWidget::ClearFocus()
{
if (IsRegisteredToCanvas())
@@ -56,10 +56,10 @@ namespace Ndk
}
/*!
* \brief Destroy the widget, deleting it in the process.
*
* Calling this function immediately destroys the widget, freeing its memory.
*/
* \brief Destroy the widget, deleting it in the process.
*
* Calling this function immediately destroys the widget, freeing its memory.
*/
void BaseWidget::Destroy()
{
NazaraAssert(this != m_canvas, "Canvas cannot be destroyed by calling Destroy()");
@@ -68,8 +68,8 @@ namespace Ndk
}
/*!
* \brief Enable or disables the widget background.
*/
* \brief Enable or disables the widget background.
*/
void BaseWidget::EnableBackground(bool enable)
{
if (m_backgroundEntity.IsValid() == enable)
@@ -96,9 +96,9 @@ namespace Ndk
}
/*!
* \brief Checks if this widget has keyboard focus
* \return true if widget has keyboard focus, false otherwise
*/
* \brief Checks if this widget has keyboard focus
* \return true if widget has keyboard focus, false otherwise
*/
bool BaseWidget::HasFocus() const
{
if (!IsRegisteredToCanvas())
@@ -188,8 +188,7 @@ namespace Ndk
}
}
for (const auto& widgetPtr : m_children)
widgetPtr->Show(show);
ShowChildren(show);
}
}
@@ -313,6 +312,16 @@ namespace Ndk
{
}
void BaseWidget::OnTextEdited(const std::array<char, 32>& /*characters*/, int /*length*/)
{
}
void BaseWidget::ShowChildren(bool show)
{
for (const auto& widgetPtr : m_children)
widgetPtr->Show(show);
}
void BaseWidget::DestroyChild(BaseWidget* widget)
{
auto it = std::find_if(m_children.begin(), m_children.end(), [widget] (const std::unique_ptr<BaseWidget>& widgetPtr) -> bool

View File

@@ -157,7 +157,7 @@ namespace Ndk
if (m_widgetEntries[m_keyboardOwner].widget->OnKeyPressed(event))
return;
if (event.code == Nz::Keyboard::Tab)
if (event.virtualKey == Nz::Keyboard::VKey::Tab)
{
if (!event.shift)
{
@@ -221,4 +221,10 @@ namespace Ndk
if (m_keyboardOwner != InvalidCanvasIndex)
m_widgetEntries[m_keyboardOwner].widget->OnTextEntered(event.character, event.repeated);
}
void Canvas::OnEventTextEdited(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::EditEvent& event)
{
if (m_keyboardOwner != InvalidCanvasIndex)
m_widgetEntries[m_keyboardOwner].widget->OnTextEdited(event.text, event.length);
}
}

View File

@@ -145,7 +145,7 @@ namespace Ndk
void Console::ClearFocus()
{
m_input->ClearFocus();
}
}
/*!
* \brief Sets the character size

View File

@@ -151,9 +151,9 @@ namespace Ndk
{
const Nz::AbstractTextDrawer& textDrawer = GetTextDrawer();
switch (key.code)
switch (key.virtualKey)
{
case Nz::Keyboard::Backspace:
case Nz::Keyboard::VKey::Backspace:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyBackspace(this, &ignoreDefaultAction);
@@ -175,7 +175,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Delete:
case Nz::Keyboard::VKey::Delete:
{
if (HasSelection())
EraseSelection();
@@ -185,7 +185,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Down:
case Nz::Keyboard::VKey::Down:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyDown(this, &ignoreDefaultAction);
@@ -200,7 +200,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::End:
case Nz::Keyboard::VKey::End:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyEnd(this, &ignoreDefaultAction);
@@ -217,7 +217,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Home:
case Nz::Keyboard::VKey::Home:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyHome(this, &ignoreDefaultAction);
@@ -229,7 +229,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Left:
case Nz::Keyboard::VKey::Left:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyLeft(this, &ignoreDefaultAction);
@@ -247,7 +247,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Return:
case Nz::Keyboard::VKey::Return:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyReturn(this, &ignoreDefaultAction);
@@ -265,7 +265,7 @@ namespace Ndk
return true;;
}
case Nz::Keyboard::Right:
case Nz::Keyboard::VKey::Right:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyRight(this, &ignoreDefaultAction);
@@ -283,7 +283,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Up:
case Nz::Keyboard::VKey::Up:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyUp(this, &ignoreDefaultAction);
@@ -298,7 +298,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Tab:
case Nz::Keyboard::VKey::Tab:
{
if (!m_tabEnabled)
return false;
@@ -331,7 +331,7 @@ namespace Ndk
Nz::Vector2ui hoveredGlyph = GetHoveredGlyph(float(x), float(y));
// Shift extends selection
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift))
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift))
SetSelection(hoveredGlyph, m_selectionCursor);
else
{