some improvements

This commit is contained in:
Turánszki János
2024-08-02 07:19:43 +02:00
parent f854040bda
commit c8b581f8b1
8 changed files with 76 additions and 27 deletions
+36 -1
View File
@@ -8,7 +8,7 @@ void TransformWindow::Create(EditorComponent* _editor)
{
editor = _editor;
wi::gui::Window::Create(ICON_TRANSFORM " Transform" , wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE);
SetSize(XMFLOAT2(480, 260));
SetSize(XMFLOAT2(480, 280));
closeButton.SetTooltip("Delete TransformComponent\nNote that a lot of components won't work correctly without a TransformComponent!");
OnClose([=](wi::gui::EventArgs args) {
@@ -141,6 +141,23 @@ void TransformWindow::Create(EditorComponent* _editor)
});
AddWidget(&szInput);
suInput.Create("");
suInput.SetDescription("Uniform Scale: ");
suInput.SetValue(1);
suInput.SetPos(XMFLOAT2(x, y += step));
suInput.SetSize(XMFLOAT2(siz, hei));
suInput.OnInputAccepted([&](wi::gui::EventArgs args) {
TransformComponent* transform = editor->GetCurrentScene().transforms.GetComponent(entity);
if (transform != nullptr)
{
transform->scale_local.x = args.fValue;
transform->scale_local.y = args.fValue;
transform->scale_local.z = args.fValue;
transform->SetDirty();
}
});
AddWidget(&suInput);
x = xx;
y = step * 4;
@@ -341,6 +358,20 @@ void TransformWindow::Create(EditorComponent* _editor)
});
AddWidget(&resetScaleButton);
resetScaleUniformButton.Create("ResetScaleUniform");
resetScaleUniformButton.SetText("X");
resetScaleUniformButton.SetTooltip("Reset scale");
resetScaleUniformButton.SetSize(XMFLOAT2(hei, hei));
resetScaleUniformButton.OnClick([=](wi::gui::EventArgs args) {
TransformComponent* transform = editor->GetCurrentScene().transforms.GetComponent(entity);
if (transform != nullptr)
{
transform->scale_local = XMFLOAT3(1, 1, 1);
transform->SetDirty();
}
});
AddWidget(&resetScaleUniformButton);
resetRotationButton.Create("ResetRotation");
resetRotationButton.SetText("X");
resetRotationButton.SetTooltip("Reset rotation");
@@ -389,6 +420,7 @@ void TransformWindow::SetEntity(Entity entity)
sxInput.SetValue(transform->scale_local.x);
syInput.SetValue(transform->scale_local.y);
szInput.SetValue(transform->scale_local.z);
suInput.SetValue(transform->scale_local.x);
SetEnabled(true);
}
@@ -445,6 +477,7 @@ void TransformWindow::ResizeLayout()
sxInput.SetSize(XMFLOAT2(safe_width / 3.0f - padding, txInput.GetSize().y));
syInput.SetSize(XMFLOAT2(safe_width / 3.0f - padding, txInput.GetSize().y));
szInput.SetSize(XMFLOAT2(safe_width / 3.0f - padding, txInput.GetSize().y));
suInput.SetSize(XMFLOAT2(safe_width - padding, txInput.GetSize().y));
rollInput.SetSize(XMFLOAT2(safe_width / 3.0f - padding, txInput.GetSize().y));
pitchInput.SetSize(XMFLOAT2(safe_width / 3.0f - padding, txInput.GetSize().y));
@@ -464,6 +497,8 @@ void TransformWindow::ResizeLayout()
szInput.SetPos(XMFLOAT2(resetScaleButton.GetPos().x - szInput.GetSize().x - padding, resetScaleButton.GetPos().y));
syInput.SetPos(XMFLOAT2(szInput.GetPos().x - syInput.GetSize().x - padding, szInput.GetPos().y));
sxInput.SetPos(XMFLOAT2(syInput.GetPos().x - sxInput.GetSize().x - padding, syInput.GetPos().y));
add_right(resetScaleUniformButton);
suInput.SetPos(XMFLOAT2(resetScaleUniformButton.GetPos().x - suInput.GetSize().x - padding, resetScaleUniformButton.GetPos().y));
add_right(resetRotationButton);
yawInput.SetPos(XMFLOAT2(resetRotationButton.GetPos().x - yawInput.GetSize().x - padding, resetRotationButton.GetPos().y));
pitchInput.SetPos(XMFLOAT2(yawInput.GetPos().x - pitchInput.GetSize().x - padding, yawInput.GetPos().y));