BaseWidget: Renamed GrabKeyboard to SetFocus, added ClearFocus and focus virtual methods
This commit is contained in:
parent
f5b639ec0f
commit
f136530a74
|
|
@ -11,6 +11,7 @@ Nazara Engine:
|
||||||
- Fix built-in unserialization of std::string which was corruption memory
|
- Fix built-in unserialization of std::string which was corruption memory
|
||||||
- Fix Buffer::Destroy() not really destroying buffer
|
- Fix Buffer::Destroy() not really destroying buffer
|
||||||
|
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
- ⚠️ Removed TextAreaWidget::GetLineCount
|
- ⚠️ Removed TextAreaWidget::GetLineCount
|
||||||
|
|
@ -18,6 +19,10 @@ Nazara Development Kit:
|
||||||
- Fix crash occuring sometimes on keyboard event
|
- Fix crash occuring sometimes on keyboard event
|
||||||
- Add support for EchoMode to TextAreaWidget (which allows to setup password text area)
|
- Add support for EchoMode to TextAreaWidget (which allows to setup password text area)
|
||||||
- Add signal OnTextChanged to TextAreaWidget
|
- Add signal OnTextChanged to TextAreaWidget
|
||||||
|
- ⚠️ Removed TextAreaWidget::GetGlyphUnderCursor
|
||||||
|
- Fixed minor issues relative to TextAreaWidget cursor handling
|
||||||
|
- ⚠️ Renamed BaseWidget::GrabKeyboard method to SetFocus
|
||||||
|
- Added BaseWidget::ClearFocus method and OnFocus[Lost|Received] virtual methods
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ namespace Ndk
|
||||||
inline void CenterHorizontal();
|
inline void CenterHorizontal();
|
||||||
inline void CenterVertical();
|
inline void CenterVertical();
|
||||||
|
|
||||||
|
void ClearFocus();
|
||||||
|
|
||||||
inline void Destroy();
|
inline void Destroy();
|
||||||
|
|
||||||
void EnableBackground(bool enable);
|
void EnableBackground(bool enable);
|
||||||
|
|
@ -56,13 +58,12 @@ namespace Ndk
|
||||||
|
|
||||||
inline bool IsVisible() const;
|
inline bool IsVisible() const;
|
||||||
|
|
||||||
void GrabKeyboard();
|
|
||||||
|
|
||||||
virtual void ResizeToContent() = 0;
|
virtual void ResizeToContent() = 0;
|
||||||
|
|
||||||
void SetBackgroundColor(const Nz::Color& color);
|
void SetBackgroundColor(const Nz::Color& color);
|
||||||
void SetCursor(Nz::SystemCursor systemCursor);
|
void SetCursor(Nz::SystemCursor systemCursor);
|
||||||
inline void SetContentSize(const Nz::Vector2f& size);
|
inline void SetContentSize(const Nz::Vector2f& size);
|
||||||
|
void SetFocus();
|
||||||
inline void SetPadding(float left, float top, float right, float bottom);
|
inline void SetPadding(float left, float top, float right, float bottom);
|
||||||
void SetSize(const Nz::Vector2f& size);
|
void SetSize(const Nz::Vector2f& size);
|
||||||
|
|
||||||
|
|
@ -85,6 +86,8 @@ namespace Ndk
|
||||||
virtual void Layout();
|
virtual void Layout();
|
||||||
void InvalidateNode() override;
|
void InvalidateNode() override;
|
||||||
|
|
||||||
|
virtual void OnFocusLost();
|
||||||
|
virtual void OnFocusReceived();
|
||||||
virtual void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key);
|
virtual void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key);
|
||||||
virtual void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key);
|
virtual void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key);
|
||||||
virtual void OnMouseEnter();
|
virtual void OnMouseEnter();
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ namespace Ndk
|
||||||
Canvas& operator=(Canvas&&) = delete;
|
Canvas& operator=(Canvas&&) = delete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
inline void ClearKeyboardOwner(std::size_t canvasIndex);
|
||||||
|
|
||||||
inline void NotifyWidgetBoxUpdate(std::size_t index);
|
inline void NotifyWidgetBoxUpdate(std::size_t index);
|
||||||
inline void NotifyWidgetCursorUpdate(std::size_t index);
|
inline void NotifyWidgetCursorUpdate(std::size_t index);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ namespace Ndk
|
||||||
return m_world;
|
return m_world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Canvas::ClearKeyboardOwner(std::size_t canvasIndex)
|
||||||
|
{
|
||||||
|
if (m_keyboardOwner == canvasIndex)
|
||||||
|
SetKeyboardOwner(InvalidCanvasIndex);
|
||||||
|
}
|
||||||
|
|
||||||
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
|
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
|
||||||
{
|
{
|
||||||
WidgetBox& entry = m_widgetBoxes[index];
|
WidgetBox& entry = m_widgetBoxes[index];
|
||||||
|
|
@ -67,6 +73,12 @@ namespace Ndk
|
||||||
|
|
||||||
inline void Canvas::SetKeyboardOwner(std::size_t canvasIndex)
|
inline void Canvas::SetKeyboardOwner(std::size_t canvasIndex)
|
||||||
{
|
{
|
||||||
|
if (m_keyboardOwner != InvalidCanvasIndex)
|
||||||
|
m_widgetBoxes[m_keyboardOwner].widget->OnFocusLost();
|
||||||
|
|
||||||
m_keyboardOwner = canvasIndex;
|
m_keyboardOwner = canvasIndex;
|
||||||
|
|
||||||
|
if (m_keyboardOwner != InvalidCanvasIndex)
|
||||||
|
m_widgetBoxes[m_keyboardOwner].widget->OnFocusReceived();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,15 @@ namespace Ndk
|
||||||
UnregisterFromCanvas();
|
UnregisterFromCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Clears keyboard focus if and only if this widget owns it.
|
||||||
|
*/
|
||||||
|
void BaseWidget::ClearFocus()
|
||||||
|
{
|
||||||
|
if (IsRegisteredToCanvas())
|
||||||
|
m_canvas->ClearKeyboardOwner(m_canvasIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Destroy the widget, deleting it in the process.
|
* \brief Destroy the widget, deleting it in the process.
|
||||||
*
|
*
|
||||||
|
|
@ -85,11 +94,6 @@ namespace Ndk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWidget::GrabKeyboard()
|
|
||||||
{
|
|
||||||
m_canvas->SetKeyboardOwner(m_canvasIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseWidget::SetBackgroundColor(const Nz::Color& color)
|
void BaseWidget::SetBackgroundColor(const Nz::Color& color)
|
||||||
{
|
{
|
||||||
m_backgroundColor = color;
|
m_backgroundColor = color;
|
||||||
|
|
@ -109,6 +113,12 @@ namespace Ndk
|
||||||
m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex);
|
m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWidget::SetFocus()
|
||||||
|
{
|
||||||
|
if (IsRegisteredToCanvas())
|
||||||
|
m_canvas->SetKeyboardOwner(m_canvasIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWidget::SetSize(const Nz::Vector2f& size)
|
void BaseWidget::SetSize(const Nz::Vector2f& size)
|
||||||
{
|
{
|
||||||
SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)});
|
SetContentSize({std::max(size.x - m_padding.left - m_padding.right, 0.f), std::max(size.y - m_padding.top - m_padding.bottom, 0.f)});
|
||||||
|
|
@ -167,6 +177,14 @@ namespace Ndk
|
||||||
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseWidget::OnFocusLost()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseWidget::OnFocusReceived()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& /*key*/)
|
void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& /*key*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue