Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj">Object the node is for</param>
        /// <param name="text">Desired text, not required to use</param>
        /// <param name="isSelected">Selection status of the node</param>
        protected virtual void DrawNodeObject(object obj, string text, bool isSelected)
        {
            // Insert an image here, preceded by an ImGuiCli.Sameline
            ImGuiCli.SameLine();
            ImGuiCli.Selectable(text, isSelected);
            if (Selection != null && ImGuiCli.IsItemClicked(0))
            {
                if (ImGuiIO.KeyCtrl)
                {
                    if (isSelected)
                    {
                        Selection.Deselect(obj);
                    }
                    else
                    {
                        Selection.Select(obj, true);
                    }
                }
                else
                {
                    Selection.Select(obj, false);
                }
            }
            else if (ImGuiCli.IsItemClicked(1) && ContextMenu != null)
            {
                ImGuiCli.OpenPopup("###tree_ctx");
            }

            if (ImGuiCli.BeginPopup("###tree_ctx", ImGuiWindowFlags_.None))
            {
                ContextMenu(obj);
                ImGuiCli.EndPopup();
            }

            if (DragConverter != null)
            {
                if (!ImGuiCli.IsPopupOpen() && ImGuiCli.BeginDragDropSource())
                {
                    ImGuiCli.SetDragDropPayload("U_TREE", DragConverter(obj));
                    ImGuiCli.Text(text);
                    ImGuiCli.EndDragDropSource();
                }
                else if (ImGuiCli.BeginDragDropTarget())
                {
                    string data = null;
                    if (ImGuiCli.AcceptDragDropPayload("U_TREE", ref data))
                    {
                        Selection.Drop(obj, data);
                    }
                }
            }
        }