void CreateScreenObject(IScreenObject obj)
        {
            const ImGuiTreeNodeFlags baseTreeFlags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick | ImGuiTreeNodeFlags.SpanAvailWidth;

            ImGuiTreeNodeFlags treeFlags = baseTreeFlags;

            ScreenObjectState state;

            if (GuiState.ScreenObjectUniques.ContainsKey(obj))
            {
                state       = GuiState.ScreenObjectUniques[obj];
                state.Found = true;
            }
            else
            {
                state = ScreenObjectState.Create(obj);
                GuiState.ScreenObjectUniques[obj] = state;
            }

            if (GuiState._selectedScreenObject == obj)
            {
                treeFlags |= ImGuiTreeNodeFlags.Selected;
            }

            if (obj.Children.Count == 0)
            {
                treeFlags |= ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen;
                ImGui.TreeNodeEx(state.Identifier.ToString(), treeFlags, obj.ToString());

                if (ImGui.IsItemClicked())
                {
                    SetScreenObject(obj, state);
                }
            }
            else
            {
                bool opened = ImGui.TreeNodeEx(state.Identifier.ToString(), treeFlags, obj.ToString());

                if (ImGui.IsItemClicked())
                {
                    SetScreenObject(obj, state);
                }

                if (opened)
                {
                    foreach (IScreenObject item in obj.Children)
                    {
                        CreateScreenObject(item);
                    }

                    ImGui.TreePop();
                }
            }
        }
Exemple #2
0
        public static ScreenObjectState Create(IScreenObject obj)
        {
            var state = new ScreenObjectState()
            {
                Object     = obj,
                Identifier = _identifier++,
                Found      = true
            };

            state.Refresh();

            return(state);
        }
 private void SetScreenObject(IScreenObject obj, ScreenObjectState state)
 {
     GuiState._selectedScreenObject      = obj;
     GuiState._selectedScreenObjectState = state;
     _toggle_screenObj_doDraw            = obj.IsVisible;
 }