Working on child window

This commit is contained in:
Chewico 2025-07-10 23:10:33 +02:00
parent a02469b935
commit ee2bac28f9
10 changed files with 210 additions and 195 deletions

View File

@ -10,31 +10,31 @@ Collapsed=0
[Window][Terrain Editor] [Window][Terrain Editor]
Pos=925,24 Pos=925,24
Size=355,413 Size=355,434
Collapsed=0 Collapsed=0
DockId=0x00000006,0 DockId=0x00000006,0
[Window][Viewport] [Window][Viewport]
Pos=309,24 Pos=309,24
Size=614,413 Size=614,434
Collapsed=0 Collapsed=0
DockId=0x00000005,0 DockId=0x00000005,0
[Window][ViewportPannel] [Window][ViewportPannel]
Pos=309,24 Pos=309,24
Size=614,413 Size=614,434
Collapsed=0 Collapsed=0
DockId=0x00000005,1 DockId=0x00000005,1
[Window][ShaderExplorer] [Window][ShaderExplorer]
Pos=0,439 Pos=0,460
Size=1280,281 Size=1280,260
Collapsed=0 Collapsed=0
DockId=0x00000004,0 DockId=0x00000004,0
[Window][TreePannel] [Window][TreePannel]
Pos=0,24 Pos=0,24
Size=307,413 Size=307,434
Collapsed=0 Collapsed=0
DockId=0x00000001,0 DockId=0x00000001,0
@ -46,7 +46,7 @@ DockId=0x00000004,0
[Window][PropertiesPannel] [Window][PropertiesPannel]
Pos=925,24 Pos=925,24
Size=355,413 Size=355,434
Collapsed=0 Collapsed=0
DockId=0x00000006,1 DockId=0x00000006,1
@ -73,17 +73,17 @@ Collapsed=0
DockId=0x00000005,2 DockId=0x00000005,2
[Window][AssetExplorer] [Window][AssetExplorer]
Pos=0,439 Pos=0,460
Size=1280,281 Size=1280,260
Collapsed=0 Collapsed=0
DockId=0x00000004,1 DockId=0x00000004,1
[Docking][Data] [Docking][Data]
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y Selected=0x34A4C10F DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y Selected=0x34A4C10F
DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,413 Split=X DockNode ID=0x00000003 Parent=0xA1672E74 SizeRef=1280,434 Split=X
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=307,696 Selected=0xE45B9F93 DockNode ID=0x00000001 Parent=0x00000003 SizeRef=307,696 Selected=0xE45B9F93
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=971,696 Split=X Selected=0x34A4C10F DockNode ID=0x00000002 Parent=0x00000003 SizeRef=971,696 Split=X Selected=0x34A4C10F
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=614,454 CentralNode=1 Selected=0x34A4C10F DockNode ID=0x00000005 Parent=0x00000002 SizeRef=614,454 CentralNode=1 Selected=0x34A4C10F
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=355,454 Selected=0xA35A27E3 DockNode ID=0x00000006 Parent=0x00000002 SizeRef=355,454 Selected=0xA35A27E3
DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,281 Selected=0x21191D0B DockNode ID=0x00000004 Parent=0xA1672E74 SizeRef=1280,260 Selected=0x21191D0B

View File

@ -5,26 +5,31 @@ class asIScriptFunction;
class CScriptAny; class CScriptAny;
namespace Deer { namespace Deer {
namespace EditorEngine { namespace EditorEngine {
// Set up the colums to fit the pixelSize elements // Set up the colums to fit the pixelSize elements
void setupAutomaticColumns(int pixelSize); void setupAutomaticColumns(int pixelSize);
// Set up the colums to the number // Set up the colums to the number
void setupColumns(int); void setupColumns(int);
// Iterates to the next column // Iterates to the next column
void nextColumn(); void nextColumn();
// Ends the columns made with setupColumns // Ends the columns made with setupColumns
void endColumns(); void endColumns();
// Renders a component node // Renders a component node
bool componentNode(std::string&, CScriptAny*, asIScriptFunction*); bool componentNode(std::string&, CScriptAny*, asIScriptFunction*);
// Renders a component node with option to menu // Renders a component node with option to menu
bool componentNode_contextMenu(std::string&, CScriptAny*, asIScriptFunction*, asIScriptFunction*); bool componentNode_contextMenu(std::string&, CScriptAny*,
// Renders a tree leaf asIScriptFunction*, asIScriptFunction*);
void treeNode(std::string&, bool); // Renders a tree leaf
// Renders a tree node with its sub nodes void treeNode(std::string&, bool);
bool treeNodeRecursive(std::string&, bool, CScriptAny*, asIScriptFunction&); // Renders a tree node with its sub nodes
bool treeNodeRecursive(std::string&, bool, CScriptAny*,
asIScriptFunction&);
void space(); // Call, x, y, border
void space_params(int, int); void childWindow(CScriptAny*, asIScriptFunction*, int, int, bool);
}
} void space();
void space_params(int, int);
} // namespace EditorEngine
} // namespace Deer

View File

@ -1,196 +1,193 @@
#include "DeerStudio/EditorEngine/API/Layout.h" #include "DeerStudio/EditorEngine/API/Layout.h"
#include "DeerStudio/EditorEngine/ErrorHandle.h"
#include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/ErrorHandle.h"
#include "angelscript.h" #include "angelscript.h"
#include "scriptany.h"
#include "imgui.h" #include "imgui.h"
#include "scriptany.h"
namespace Deer { namespace Deer {
namespace EditorEngine { namespace EditorEngine {
void treeNode(std::string& txt, bool active) { void treeNode(std::string& txt, bool active) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf |
ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoTreePushOnOpen |
ImGuiTreeNodeFlags_SpanFullWidth; ImGuiTreeNodeFlags_SpanFullWidth;
if (active) if (active)
flags |= ImGuiTreeNodeFlags_Selected; flags |= ImGuiTreeNodeFlags_Selected;
ImGui::TreeNodeEx(txt.c_str(), flags); ImGui::TreeNodeEx(txt.c_str(), flags);
} }
bool treeNodeRecursive(std::string& txt, bool active, CScriptAny *data, asIScriptFunction& func) { bool treeNodeRecursive(std::string& txt, bool active, CScriptAny* data,
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); asIScriptFunction& func) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnDoubleClick |
ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_OpenOnArrow |
ImGuiTreeNodeFlags_DefaultOpen; ImGuiTreeNodeFlags_SpanFullWidth |
ImGuiTreeNodeFlags_DefaultOpen;
if (active) if (active)
flags |= ImGuiTreeNodeFlags_Selected; flags |= ImGuiTreeNodeFlags_Selected;
if (ImGui::TreeNodeEx(txt.c_str(), flags)) { if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
ImGui::PushID(txt.c_str()); ImGui::PushID(txt.c_str());
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) { if (executingScriptContext &&
AS_CHECK_ADDITIONAL_INFO( executingScriptContext->PushState() == asSUCCESS) {
executingScriptContext->Prepare(&func), AS_CHECK_ADDITIONAL_INFO(
func.GetDeclaration() executingScriptContext->Prepare(&func),
); func.GetDeclaration());
AS_CHECK_ADDITIONAL_INFO( AS_CHECK_ADDITIONAL_INFO(
executingScriptContext->SetArgObject(0, data), executingScriptContext->SetArgObject(0, data),
func.GetDeclaration() func.GetDeclaration());
);
AS_CHECK_ADDITIONAL_INFO( AS_CHECK_ADDITIONAL_INFO(executingScriptContext->Execute(),
executingScriptContext->Execute(), func.GetDeclaration());
func.GetDeclaration()
);
executingScriptContext->PopState(); executingScriptContext->PopState();
} else { } else {
ImGui::Text("Something failed"); ImGui::Text("Something failed");
} }
ImGui::PopID(); ImGui::PopID();
ImGui::TreePop(); ImGui::TreePop();
ImGui::PopStyleVar();
return true;
}
ImGui::PopStyleVar(); ImGui::PopStyleVar();
return true; return false;
} }
ImGui::PopStyleVar(); bool componentNode(std::string& txt, CScriptAny* data,
return false; asIScriptFunction* func) {
}
bool componentNode(std::string& txt, CScriptAny* data, asIScriptFunction* func) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth |
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); ImGuiTreeNodeFlags_Framed |
ImGuiTreeNodeFlags_AllowItemOverlap |
ImGuiTreeNodeFlags_FramePadding |
ImGuiTreeNodeFlags_DefaultOpen;
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
ImGuiTreeNodeFlags_Framed | ImGui::Dummy(ImVec2(0, 10));
ImGuiTreeNodeFlags_AllowItemOverlap | ImGui::PushID(txt.c_str());
ImGuiTreeNodeFlags_FramePadding | if (executingScriptContext &&
ImGuiTreeNodeFlags_DefaultOpen; executingScriptContext->PushState() == asSUCCESS) {
if (ImGui::TreeNodeEx(txt.c_str(), flags)){ AS_CHECK(executingScriptContext->Prepare(func));
ImGui::Dummy(ImVec2(0, 10));
ImGui::PushID(txt.c_str());
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
AS_CHECK( executingScriptContext->Prepare(func)); AS_CHECK(executingScriptContext->SetArgObject(0, data));
AS_CHECK(executingScriptContext->SetArgObject(0, data)); AS_CHECK(executingScriptContext->Execute());
AS_CHECK(executingScriptContext->Execute()); executingScriptContext->PopState();
} else {
ImGui::Text("Something failed");
}
executingScriptContext->PopState(); ImGui::Dummy(ImVec2(0, 10));
} else { ImGui::PopID();
ImGui::Text("Something failed"); ImGui::TreePop();
}
ImGui::Dummy(ImVec2(0, 10)); ImGui::PopStyleVar(2);
ImGui::PopID(); return true;
ImGui::TreePop(); }
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
return true; return false;
} }
ImGui::PopStyleVar(2); bool componentNode_contextMenu(std::string& txt, CScriptAny* data,
return false; asIScriptFunction* func,
} asIScriptFunction* menu) {
bool componentNode_contextMenu(std::string& txt, CScriptAny* data, asIScriptFunction* func, asIScriptFunction* menu) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth |
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); ImGuiTreeNodeFlags_Framed |
ImGuiTreeNodeFlags_AllowItemOverlap |
ImGuiTreeNodeFlags_FramePadding |
ImGuiTreeNodeFlags_DefaultOpen;
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | if (ImGui::TreeNodeEx(txt.c_str(), flags)) {
ImGuiTreeNodeFlags_Framed | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,
ImGuiTreeNodeFlags_AllowItemOverlap | ImVec2(10, 10));
ImGuiTreeNodeFlags_FramePadding | if (ImGui::BeginPopupContextItem(txt.c_str())) {
ImGuiTreeNodeFlags_DefaultOpen; if (executingScriptContext &&
executingScriptContext->PushState() == asSUCCESS) {
if (ImGui::TreeNodeEx(txt.c_str(), flags)){ AS_CHECK(executingScriptContext->Prepare(menu));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));
if (ImGui::BeginPopupContextItem(txt.c_str())) {
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
AS_CHECK( executingScriptContext->Prepare(menu)); AS_CHECK(executingScriptContext->SetArgObject(0, data));
AS_CHECK(executingScriptContext->SetArgObject(0, data)); AS_CHECK(executingScriptContext->Execute());
AS_CHECK(executingScriptContext->Execute()); executingScriptContext->PopState();
} else {
ImGui::Text("Something failed");
}
ImGui::EndPopup();
}
ImGui::PopStyleVar();
executingScriptContext->PopState(); ImGui::Dummy(ImVec2(0, 10));
} else { ImGui::PushID(txt.c_str());
ImGui::Text("Something failed"); if (executingScriptContext &&
} executingScriptContext->PushState() == asSUCCESS) {
ImGui::EndPopup();
}
ImGui::PopStyleVar();
ImGui::Dummy(ImVec2(0, 10)); AS_CHECK(executingScriptContext->Prepare(func));
ImGui::PushID(txt.c_str());
if (executingScriptContext && executingScriptContext->PushState() == asSUCCESS) {
AS_CHECK( executingScriptContext->Prepare(func)); AS_CHECK(executingScriptContext->SetArgObject(0, data));
AS_CHECK(executingScriptContext->SetArgObject(0, data)); AS_CHECK(executingScriptContext->Execute());
AS_CHECK(executingScriptContext->Execute()); executingScriptContext->PopState();
} else {
ImGui::Text("Something failed");
}
executingScriptContext->PopState(); ImGui::Dummy(ImVec2(0, 10));
} else { ImGui::PopID();
ImGui::Text("Something failed"); ImGui::TreePop();
}
ImGui::Dummy(ImVec2(0, 10)); ImGui::PopStyleVar(2);
ImGui::PopID(); return true;
ImGui::TreePop(); }
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
return true; return false;
} }
ImGui::PopStyleVar(2); void setupColumns(int i) { ImGui::Columns(i, nullptr, false); }
return false;
}
void setupColumns(int i) { void setupAutomaticColumns(int pixelSize) {
ImGui::Columns(i, nullptr, false); float width = ImGui::GetWindowContentRegionWidth();
}
void setupAutomaticColumns(int pixelSize) { if (width < pixelSize) {
float width = ImGui::GetWindowContentRegionWidth(); ImGui::Columns();
return;
}
if (width < pixelSize) { int cols = (int)(width / (pixelSize));
ImGui::Columns(); float componentWidth = width / (float)cols;
return;
}
int cols = (int)(width / (pixelSize)); ImGui::Columns(cols, 0, false);
float componentWidth = width / (float)cols; }
ImGui::Columns(cols, 0, false); void childWindow(CScriptAny* data, asIScriptFunction* func, int width,
} int height, bool border) {}
void endColumns() { void endColumns() { ImGui::Columns(); }
ImGui::Columns();
}
void nextColumn() { void nextColumn() { ImGui::NextColumn(); }
ImGui::NextColumn();
}
void space() { void space() { ImGui::Dummy(ImVec2(10, 10)); }
ImGui::Dummy(ImVec2(10, 10));
}
void space_params(int x, int y) { void space_params(int x, int y) { ImGui::Dummy(ImVec2(x, y)); }
ImGui::Dummy(ImVec2(x, y)); } // namespace EditorEngine
} } // namespace Deer
}
}

View File

@ -11,6 +11,19 @@ bool drawFolder(string&in name) {
return click; return click;
} }
bool drawIcon(string&in name, string&in iconName) {
bool click = false;
UI::drawIconCentered(iconName, 64);
if (UI::isItemClicked(0) and UI::isMouseDoubleClicked(0)) {
click = true;
}
UI::textCenter(name);
UI::nextColumn();
return click;
}
bool drawFile(string&in name) { bool drawFile(string&in name) {
bool click = false; bool click = false;
UI::drawIconCentered("file", 64); UI::drawIconCentered("file", 64);

View File

@ -2,10 +2,10 @@
AssetType renderRootAssets() { AssetType renderRootAssets() {
AssetType selectedAssetType = AssetType::None; AssetType selectedAssetType = AssetType::None;
if (drawFolder("Scripts")) selectedAssetType = AssetType::None; if (drawIcon("Scripts", "script")) selectedAssetType = AssetType::None;
if (drawFolder("Meshes")) selectedAssetType = AssetType::Mesh; if (drawIcon("Meshes", "mesh")) selectedAssetType = AssetType::Mesh;
if (drawFolder("Textures")) selectedAssetType = AssetType::None; if (drawIcon("Textures", "texture")) selectedAssetType = AssetType::None;
if (drawFolder("Shaders")) selectedAssetType = AssetType::Shader; if (drawIcon("Shaders", "shader")) selectedAssetType = AssetType::Shader;
return selectedAssetType; return selectedAssetType;
} }

BIN
roe/Editor/icons/mesh.ase Normal file

Binary file not shown.

BIN
roe/Editor/icons/mesh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

BIN
roe/Editor/icons/script.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B