Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/DevTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DevTools {
void setupPlatform();

void drawTree();
void drawTreeBranch(CCNode* node, size_t index, bool drag);
void drawTreeBranch(CCNode* node, size_t index, bool drag, bool visible);
void drawSettings();
void drawAdvancedSettings();
void drawNodeAttributes(CCNode* node);
Expand Down
22 changes: 18 additions & 4 deletions src/pages/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ bool isNodeParentOf(CCNode* parent, CCNode* child) {
return false;
}

void DevTools::drawTreeBranch(CCNode* node, size_t index, bool drag) {
void DevTools::drawTreeBranch(CCNode* node, size_t index, bool drag, bool visible) {
if (!this->searchBranch(node)) {
return;
}

visible = node->isVisible() && visible;

auto selected = DevTools::get()->getSelectedNode() == node;

ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None;
Expand Down Expand Up @@ -103,11 +105,22 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index, bool drag) {
ImGui::SetNextItemOpen(true);
}

auto alpha = ImGui::GetStyle().DisabledAlpha;
ImGui::GetStyle().DisabledAlpha = node->isVisible() ? alpha + 0.15f : alpha;

ImGui::BeginDisabled(!visible);
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, false); // Bypass iteract blocking in imgui

const auto name = formatNodeName(node, index);
// The order here is unusual due to imgui weirdness; see the second-to-last paragraph in https://kahwei.dev/2022/06/20/imgui-tree-node/
bool expanded = ImGui::TreeNodeEx(node, flags, "%s", name.c_str());
float height = ImGui::GetItemRectSize().y;


ImGui::GetStyle().DisabledAlpha = alpha;
ImGui::PopItemFlag(); //ImGuiItemFlags_Disabled
ImGui::EndDisabled();

if (ImGui::IsItemClicked()) {
DevTools::get()->selectNode(node);
selected = true;
Expand Down Expand Up @@ -152,7 +165,7 @@ void DevTools::drawTreeBranch(CCNode* node, size_t index, bool drag) {
}
size_t i = 0;
for (auto& child : CCArrayExt<CCNode*>(node->getChildren())) {
this->drawTreeBranch(child, i++, drag || isDrag);
this->drawTreeBranch(child, i++, drag || isDrag, visible);
}
ImGui::TreePop();
}
Expand All @@ -177,7 +190,7 @@ void DevTools::drawTree() {
m_searchQuery.clear();
}

this->drawTreeBranch(CCDirector::get()->getRunningScene(), 0, false);
this->drawTreeBranch(CCDirector::get()->getRunningScene(), 0, false, true);

if (auto* dragged = this->getDraggedNode()) {
const auto name = formatNodeName(dragged, 0);
Expand Down Expand Up @@ -217,4 +230,5 @@ bool DevTools::searchBranch(CCNode* node) {
}
}
return false;
}

}