Merge branch 'master' into console-widget
This commit is contained in:
@@ -76,6 +76,14 @@ namespace Ndk
|
||||
}
|
||||
}
|
||||
|
||||
void BaseWidget::SetCursor(Nz::SystemCursor systemCursor)
|
||||
{
|
||||
m_cursor = systemCursor;
|
||||
|
||||
if (IsRegisteredToCanvas())
|
||||
m_canvas->NotifyWidgetCursorUpdate(m_canvasIndex);
|
||||
}
|
||||
|
||||
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)});
|
||||
@@ -120,7 +128,7 @@ namespace Ndk
|
||||
void BaseWidget::Layout()
|
||||
{
|
||||
if (IsRegisteredToCanvas())
|
||||
m_canvas->NotifyWidgetUpdate(m_canvasIndex);
|
||||
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
||||
|
||||
if (m_backgroundEntity)
|
||||
m_backgroundSprite->SetSize(m_contentSize.x + m_padding.left + m_padding.right, m_contentSize.y + m_padding.top + m_padding.bottom);
|
||||
@@ -131,7 +139,7 @@ namespace Ndk
|
||||
Node::InvalidateNode();
|
||||
|
||||
if (IsRegisteredToCanvas())
|
||||
m_canvas->NotifyWidgetUpdate(m_canvasIndex);
|
||||
m_canvas->NotifyWidgetBoxUpdate(m_canvasIndex);
|
||||
}
|
||||
|
||||
void BaseWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key)
|
||||
|
||||
@@ -14,25 +14,16 @@ namespace Ndk
|
||||
{
|
||||
}
|
||||
|
||||
void Canvas::NotifyWidgetUpdate(std::size_t index)
|
||||
{
|
||||
WidgetBox& entry = m_widgetBoxes[index];
|
||||
|
||||
Nz::Vector3f pos = entry.widget->GetPosition();
|
||||
Nz::Vector2f size = entry.widget->GetContentSize();
|
||||
|
||||
entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f);
|
||||
}
|
||||
|
||||
std::size_t Canvas::RegisterWidget(BaseWidget* widget)
|
||||
{
|
||||
WidgetBox box;
|
||||
box.cursor = widget->GetCursor();
|
||||
box.widget = widget;
|
||||
|
||||
std::size_t index = m_widgetBoxes.size();
|
||||
m_widgetBoxes.emplace_back(box);
|
||||
|
||||
NotifyWidgetUpdate(index);
|
||||
NotifyWidgetBoxUpdate(index);
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -109,6 +100,9 @@ namespace Ndk
|
||||
|
||||
m_hoveredWidget = bestEntry;
|
||||
m_hoveredWidget->widget->OnMouseEnter();
|
||||
|
||||
if (m_cursorController)
|
||||
m_cursorController->UpdateCursor(Nz::Cursor::Get(m_hoveredWidget->cursor));
|
||||
}
|
||||
|
||||
int x = static_cast<int>(std::round(event.x - m_hoveredWidget->box.x));
|
||||
@@ -120,6 +114,9 @@ namespace Ndk
|
||||
{
|
||||
m_hoveredWidget->widget->OnMouseExit();
|
||||
m_hoveredWidget = nullptr;
|
||||
|
||||
if (m_cursorController)
|
||||
m_cursorController->UpdateCursor(Nz::Cursor::Get(Nz::SystemCursor_Default));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Ndk
|
||||
m_readOnly(false)
|
||||
{
|
||||
m_cursorSprite = Nz::Sprite::New();
|
||||
m_cursorSprite->SetColor(Nz::Color(192, 192, 192));
|
||||
m_cursorSprite->SetColor(Nz::Color::Black);
|
||||
m_cursorSprite->SetSize(1.f, float(m_drawer.GetFont()->GetSizeInfo(m_drawer.GetCharacterSize()).lineHeight));
|
||||
|
||||
m_cursorEntity = CreateEntity();
|
||||
@@ -32,6 +32,8 @@ namespace Ndk
|
||||
m_textEntity->AddComponent<GraphicsComponent>().Attach(m_textSprite);
|
||||
m_textEntity->AddComponent<NodeComponent>().SetParent(this);
|
||||
|
||||
SetCursor(Nz::SystemCursor_Text);
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user