Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions Hazelnut/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ namespace Hazel {

style.WindowMinSize.x = minWinSizeX;

UI_Viewport();
UI_MenuBar();
UI_Toolbar();
UI_Settings();
UI_ChildPanels();
UI_Stats();

ImGui::End();
}

void EditorLayer::UI_MenuBar()
{
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("File"))
Expand All @@ -202,10 +214,16 @@ namespace Hazel {

ImGui::EndMenuBar();
}
}

void EditorLayer::UI_ChildPanels()
{
m_SceneHierarchyPanel.OnImGuiRender();
m_ContentBrowserPanel.OnImGuiRender();
}

void EditorLayer::UI_Stats()
{
ImGui::Begin("Stats");

std::string name = "None";
Expand All @@ -221,11 +239,17 @@ namespace Hazel {
ImGui::Text("Indices: %d", stats.GetTotalIndexCount());

ImGui::End();
}

void EditorLayer::UI_Settings()
{
ImGui::Begin("Settings");
ImGui::Checkbox("Show physics colliders", &m_ShowPhysicsColliders);
ImGui::End();
}

void EditorLayer::UI_Viewport()
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0, 0 });
ImGui::Begin("Viewport");
auto viewportMinRegion = ImGui::GetWindowContentRegionMin();
Expand Down Expand Up @@ -254,7 +278,14 @@ namespace Hazel {
ImGui::EndDragDropTarget();
}

// Gizmos
UI_Gizmos();

ImGui::End();
ImGui::PopStyleVar();
}

void EditorLayer::UI_Gizmos()
{
Entity selectedEntity = m_SceneHierarchyPanel.GetSelectedEntity();
if (selectedEntity && m_GizmoType != -1)
{
Expand All @@ -264,7 +295,7 @@ namespace Hazel {
ImGuizmo::SetRect(m_ViewportBounds[0].x, m_ViewportBounds[0].y, m_ViewportBounds[1].x - m_ViewportBounds[0].x, m_ViewportBounds[1].y - m_ViewportBounds[0].y);

// Camera

// Runtime camera from entity
// auto cameraEntity = m_ActiveScene->GetPrimaryCameraEntity();
// const auto& camera = cameraEntity.GetComponent<CameraComponent>().Camera;
Expand Down Expand Up @@ -303,14 +334,6 @@ namespace Hazel {
tc.Scale = scale;
}
}


ImGui::End();
ImGui::PopStyleVar();

UI_Toolbar();

ImGui::End();
}

void EditorLayer::UI_Toolbar()
Expand Down Expand Up @@ -465,7 +488,7 @@ namespace Hazel {
Entity camera = m_ActiveScene->GetPrimaryCameraEntity();
if (!camera)
return;

Renderer2D::BeginScene(camera.GetComponent<CameraComponent>().Camera, camera.GetComponent<TransformComponent>().GetTransform());
}
else
Expand Down Expand Up @@ -511,7 +534,7 @@ namespace Hazel {
}
}

// Draw selected entity outline
// Draw selected entity outline
if (Entity selectedEntity = m_SceneHierarchyPanel.GetSelectedEntity())
{
const TransformComponent& transform = selectedEntity.GetComponent<TransformComponent>();
Expand All @@ -526,7 +549,7 @@ namespace Hazel {
m_ActiveScene = CreateRef<Scene>();
m_ActiveScene->OnViewportResize((uint32_t)m_ViewportSize.x, (uint32_t)m_ViewportSize.y);
m_SceneHierarchyPanel.SetContext(m_ActiveScene);

m_EditorScenePath = std::filesystem::path();
}

Expand Down
6 changes: 6 additions & 0 deletions Hazelnut/src/EditorLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ namespace Hazel {
void OnDuplicateEntity();

// UI Panels
void UI_ChildPanels();
void UI_MenuBar();
void UI_Stats();
void UI_Toolbar();
void UI_Settings();
void UI_Viewport();
void UI_Gizmos();
private:
Hazel::OrthographicCameraController m_CameraController;

Expand Down