mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Editor window
This commit is contained in:
@@ -8,32 +8,16 @@ using ImGuizmo;
|
||||
|
||||
namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
class SceneViewportWindow
|
||||
class SceneViewportWindow : EditorWindow
|
||||
{
|
||||
private Editor _editor;
|
||||
public Camera _camera;
|
||||
|
||||
public const String s_WindowTitle = "Scene";
|
||||
|
||||
private bool _open = true;
|
||||
|
||||
private RenderTarget2D _renderTarget ~ _?.ReleaseRef();
|
||||
|
||||
private bool _hasFocus;
|
||||
|
||||
public Event<EventHandler<Vector2>> ViewportSizeChangedEvent ~ _.Dispose();
|
||||
|
||||
public bool Open
|
||||
{
|
||||
get => _open;
|
||||
set => _open = value;
|
||||
}
|
||||
|
||||
public bool HasFocus
|
||||
{
|
||||
get => _hasFocus;
|
||||
}
|
||||
|
||||
public RenderTarget2D RenderTarget
|
||||
{
|
||||
get => _renderTarget;
|
||||
@@ -54,11 +38,8 @@ namespace GlitchyEditor.EditWindows
|
||||
private ImGui.Vec2 oldViewportSize;
|
||||
private bool viewPortChanged;
|
||||
|
||||
public void Show()
|
||||
protected override void InternalShow()
|
||||
{
|
||||
if(!_open)
|
||||
return;
|
||||
|
||||
ImGui.PushStyleVar(.WindowPadding, ImGui.Vec2(1, 1));
|
||||
defer ImGui.PopStyleVar();
|
||||
|
||||
@@ -83,8 +64,22 @@ namespace GlitchyEditor.EditWindows
|
||||
ImGui.Image(_renderTarget, viewportSize);
|
||||
}
|
||||
|
||||
ImGuizmo.SetDrawlist();
|
||||
DrawImGuizmo(viewportSize);
|
||||
|
||||
ImGui.End();
|
||||
|
||||
if(oldViewportSize != viewportSize)
|
||||
{
|
||||
ViewportSizeChangedEvent.Invoke(this, (Vector2)viewportSize);
|
||||
viewPortChanged = true;
|
||||
oldViewportSize = viewportSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawImGuizmo(ImGui.Vec2 viewportSize)
|
||||
{
|
||||
ImGuizmo.SetDrawlist();
|
||||
|
||||
var topLeft = ImGui.GetWindowPos();
|
||||
var cntMin = ImGui.GetWindowContentRegionMin();
|
||||
|
||||
@@ -112,15 +107,6 @@ namespace GlitchyEditor.EditWindows
|
||||
|
||||
transformCmp.LocalTransform = transform;
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
||||
if(oldViewportSize != viewportSize)
|
||||
{
|
||||
ViewportSizeChangedEvent.Invoke(this, (Vector2)viewportSize);
|
||||
viewPortChanged = true;
|
||||
oldViewportSize = viewportSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user