Ejemplo n.º 1
0
        private void ChangeTool(Type type, Property property)
        {
            ImGui.OpenPopup("Tool Picker");
            if (ImGui.BeginPopup("Tool Picker"))
            {
                var allTools = this.ToolSelector.GetAllTools(type);
                var bestTool = this.ToolSelector.GetBestTool(type, this.changingState);

                var index = Array.IndexOf(allTools.Tools, bestTool);
                if (ImGui.Combo("Tools", ref index, allTools.Names, allTools.Names.Length))
                {
                    this.changingState.Name = allTools.Tools[index].Name;
                }

                ImGui.Separator();
                this.changingState = bestTool.Configure(this.changingState);
                ImGui.Separator();

                if (ImGui.Button("Save"))
                {
                    this.LinkedTools.Link(property, this.changingState);
                    this.Deactivate();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    this.Deactivate();
                }

                ImGui.EndPopup();
            }
        }
Ejemplo n.º 2
0
 private void ToolRow(Property property, ToolState state, ITool tool, Type type)
 {
     if (ToolUtils.ButtonRowWithTooltip($"Tool: {tool.Name}", $"Type: {type.Name}, Path: {property.Path}", "change tool"))
     {
         this.Activate(property);
         this.changingState = state;
     }
 }
Ejemplo n.º 3
0
        public bool Details(ref object value, ToolState tool, Property propertyPath)
        {
            var specific = (T)value;
            var changed  = this.Details(ref specific, tool);

            value = specific !;

            return(changed);
        }
Ejemplo n.º 4
0
        public bool HeaderValue(ref object value, ToolState tool)
        {
            var specific = (T)value;
            var changed  = this.HeaderValue(ref specific, tool);

            value = specific !;

            return(changed);
        }
Ejemplo n.º 5
0
 public virtual ToolState Configure(ToolState tool) => tool;
Ejemplo n.º 6
0
 public virtual bool Details(ref T value, ToolState tool) => false;
Ejemplo n.º 7
0
 public abstract bool HeaderValue(ref T value, ToolState tool);
Ejemplo n.º 8
0
        public ITool GetBestTool(Type type, ToolState toolState)
        {
            var tools = this.GetAllTools(type);

            return(tools.Tools.FirstOrDefault(t => t.Name == toolState.Name) ?? tools.Tools[0]);
        }
Ejemplo n.º 9
0
        private static bool Header(ref object value, out bool open, Property property, ITool tool, ToolState toolState)
        {
            ImGui.AlignTextToFramePadding();
            open = ImGui.TreeNode(property.Name);

            ImGui.NextColumn();
            ImGui.AlignTextToFramePadding();
            var changed = false;

            if (value == null)
            {
                ImGui.Text("null");
            }
            else
            {
                changed = tool.HeaderValue(ref value, toolState);
            }

            ImGui.NextColumn();
            return(changed);
        }
Ejemplo n.º 10
0
 private void Link(string sortKey, ToolState tool)
 {
     this.KnownTools.Add(sortKey);
     this.Tools[sortKey] = tool;
 }
Ejemplo n.º 11
0
 public void Link(Property property, ToolState tool)
     => this.Link(property.SortKey, tool);
Ejemplo n.º 12
0
 private record ToolPair(string Key, ToolState Value);