MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / DrawTreeScenegraphElement

Function DrawTreeScenegraphElement

Source/GUI/dimgui/dimgui.cpp:1623–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1621static void DrawTreeScenegraphFor(SceneGraph* scenegraph, GUI* gui, Object* root);
1622
1623static void DrawTreeScenegraphElement(SceneGraph* scenegraph, GUI* gui, Object* parent, Object* obj, int index, bool force) {
1624 static bool select_elements;
1625
1626 const int kBufSize = 512;
1627 char buf[kBufSize];
1628 if (!force) {
1629 if (!TreeScenegraphElementVisible(obj, parent, buf))
1630 return;
1631 } else {
1632 obj->GetDisplayName(buf, kBufSize);
1633 }
1634
1635 ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
1636 if (obj->Selected()) {
1637 node_flags |= ImGuiTreeNodeFlags_Selected;
1638 }
1639 if (obj->GetType() != _group && obj->GetType() != _prefab) {
1640 node_flags |= ImGuiTreeNodeFlags_Leaf;
1641 }
1642 ImGui::PushID(obj->GetID());
1643 vec4 color = GetObjColor(obj);
1644 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(color[0], color[1], color[2], color[3]));
1645 bool node_open = ImGui::TreeNodeEx("", node_flags, "%s", buf);
1646 ImGui::PopStyleColor();
1647 ImGui::PopID();
1648 if (ImGui::IsItemClicked()) {
1649 obj->Select(!obj->Selected());
1650
1651 const Keyboard& keyboard = Input::Instance()->getKeyboard();
1652
1653 if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LShift)) || ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_RShift))) {
1654 if (select_start_index == -1) {
1655 select_start_index = index;
1656 select_elements = obj->Selected();
1657 } else {
1658 char temp_buf[kBufSize];
1659
1660 int low_index = std::min(select_start_index, index);
1661 int high_index = std::max(select_start_index, index);
1662
1663 for (int j = 0, len = (int)scenegraph->objects_.size(); j < len; ++j) {
1664 Object* temp_obj = scenegraph->objects_[j];
1665 if (TreeScenegraphElementVisible(temp_obj, parent, temp_buf)) {
1666 if (j >= low_index && j <= high_index) {
1667 if (temp_obj->Selected() != select_elements)
1668 temp_obj->Select(select_elements);
1669 }
1670 }
1671 }
1672 }
1673 } else {
1674 select_start_index = index;
1675 select_elements = obj->Selected();
1676 }
1677 }
1678 if (node_open) {
1679 if ((node_flags & ImGuiTreeNodeFlags_Leaf) == 0) {
1680 DrawTreeScenegraphFor(scenegraph, gui, obj);

Callers 1

DrawTreeScenegraphForFunction · 0.85

Calls 14

GetObjColorFunction · 0.85
PushStyleColorFunction · 0.85
PopStyleColorFunction · 0.85
maxFunction · 0.85
DrawTreeScenegraphForFunction · 0.85
SelectedMethod · 0.80
ImVec4Class · 0.50
minFunction · 0.50
GetDisplayNameMethod · 0.45
GetTypeMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected