feat: add canvas rework
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#ifndef EDITOR_CANVASVIEW_H
|
||||
#define EDITOR_CANVASVIEW_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <destrum/Components/UI/CanvasFrame.h>
|
||||
|
||||
class GameObject;
|
||||
class RectGizmo;
|
||||
class Scene;
|
||||
struct ImDrawList;
|
||||
|
||||
class CanvasView final {
|
||||
public:
|
||||
[[nodiscard]] bool IsEnabled() const { return m_Enabled; }
|
||||
void SetEnabled(bool enabled);
|
||||
void Toggle() { SetEnabled(!m_Enabled); }
|
||||
|
||||
[[nodiscard]] bool ShowsScene() const { return m_ShowScene; }
|
||||
[[nodiscard]] bool IsPanning() const { return m_Panning; }
|
||||
[[nodiscard]] CanvasFrame GetFrame() const;
|
||||
|
||||
void SetDrawImageSize(const glm::vec2& size);
|
||||
void Fit();
|
||||
|
||||
bool HandleInput(const glm::vec2& mousePixel, const glm::vec2& pixelsPerPoint, bool hovered);
|
||||
void SubmitBackdrop() const;
|
||||
void DrawOverlay(ImDrawList& drawList, const glm::vec2& viewMin, const glm::vec2& viewScale) const;
|
||||
void DrawToolbar(RectGizmo& gizmo);
|
||||
|
||||
[[nodiscard]] static GameObject* Pick(Scene& scene, const glm::vec2& pixel);
|
||||
|
||||
private:
|
||||
bool m_Enabled{false};
|
||||
bool m_ShowScene{false};
|
||||
bool m_Fitted{true};
|
||||
bool m_Panning{false};
|
||||
int m_Preset{0};
|
||||
glm::ivec2 m_Resolution{1920, 1080};
|
||||
glm::vec2 m_DrawImageSize{1.0f};
|
||||
glm::vec2 m_FrameMin{0.0f};
|
||||
float m_Zoom{1.0f};
|
||||
};
|
||||
|
||||
#endif // EDITOR_CANVASVIEW_H
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <destrum/AppLayer.h>
|
||||
|
||||
#include <editor/AssetBrowser.h>
|
||||
#include <editor/CanvasView.h>
|
||||
#include <editor/EditorCamera.h>
|
||||
#include <editor/PlayMode.h>
|
||||
#include <editor/RectGizmo.h>
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
[[nodiscard]] Camera* viewCamera() override;
|
||||
[[nodiscard]] bool hostsViewport() const override { return true; }
|
||||
[[nodiscard]] InputFocus gameInputFocus() const override;
|
||||
[[nodiscard]] std::optional<CanvasFrame> canvasFrame() const override;
|
||||
|
||||
bool OpenScene(std::string_view path);
|
||||
bool SaveScene();
|
||||
@@ -81,7 +83,8 @@ private:
|
||||
|
||||
// Editor.cpp
|
||||
[[nodiscard]] Scene* CurrentScene() const;
|
||||
[[nodiscard]] bool UsesEditorCamera();
|
||||
[[nodiscard]] bool UsesEditorCamera() const;
|
||||
[[nodiscard]] bool CanvasViewActive() const;
|
||||
void HandleShortcuts();
|
||||
void Undo();
|
||||
void Redo();
|
||||
@@ -126,6 +129,7 @@ private:
|
||||
ResourcesInspector m_ResourcesInspector;
|
||||
TransformGizmo m_TransformGizmo;
|
||||
RectGizmo m_RectGizmo;
|
||||
CanvasView m_CanvasView;
|
||||
ShaderHotReload m_ShaderHotReload;
|
||||
|
||||
Panels m_Panels;
|
||||
|
||||
Reference in New Issue
Block a user