Files
sophia/editor/panels/scene_hierarchy_panel.hpp

39 lines
1.2 KiB
C++

#pragma once
#include <array>
#include <sophia/frame_info.hpp>
#include <sophia/handles.hpp>
#include <sophia/ui/panel.hpp>
#include "../editor_context.hpp"
class SceneHierarchyPanel : public sophia::Panel {
public:
// `cubeMesh` is what "+ Cube" gives new entities.
SceneHierarchyPanel(EditorContext& context, sophia::MeshHandle cubeMesh)
: Panel{{.name = "Scene Hierarchy", .locked = true}},
context{context},
cubeMesh{cubeMesh} {}
void onUpdate(const sophia::FrameInfo& frameInfo) override;
private:
// Switches between open scenes, renames the active one, and creates new
// ones.
void drawSceneSelector();
// Replaces the selector with a text field editing the active scene's name.
void drawSceneRename();
EditorContext& context;
sophia::MeshHandle cubeMesh;
// For naming new scenes "Untitled 1", "Untitled 2", ...
int untitledSceneCount = 0;
// Set while the scene selector is a text field for renaming.
bool renamingScene = false;
// Frames the text field has left to become active after renaming starts;
// focus can take a frame to land. If it never does, renaming ends.
int renameFocusFrames = 0;
std::array<char, 128> renameBuffer{};
};