Exemplo n.º 1
0
        private static bool DrawPressEnterWarning(string old, float?width = null)
        {
            const uint red = 0xFF202080;

            using var color = ImGuiRaii.PushColor(ImGuiCol.Button, red);
            var w = Vector2.UnitX * (width ?? ImGui.CalcItemWidth());

            return(ImGui.Button($"Press Enter or Click Here to Save (Current Directory: {old})", w));
        }
Exemplo n.º 2
0
        private static bool BeginFramedGroupInternal(ref string label, Vector2 minSize, bool edit)
        {
            var itemSpacing     = ImGui.GetStyle().ItemSpacing;
            var frameHeight     = ImGui.GetFrameHeight();
            var halfFrameHeight = new Vector2(ImGui.GetFrameHeight() / 2, 0);

            ImGui.BeginGroup(); // First group

            ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);

            ImGui.BeginGroup(); // Second group

            var effectiveSize = minSize;

            if (effectiveSize.X < 0)
            {
                effectiveSize.X = ImGui.GetContentRegionAvail().X;
            }

            // Ensure width.
            ImGui.Dummy(Vector2.UnitX * effectiveSize.X);
            // Ensure left half boundary width/distance.
            ImGui.Dummy(halfFrameHeight);

            ImGui.SameLine();
            ImGui.BeginGroup(); // Third group.
            // Ensure right half of boundary width/distance
            ImGui.Dummy(halfFrameHeight);

            // Label block
            ImGui.SameLine();
            var ret = false;

            if (edit)
            {
                ret = ResizingTextInput(ref label, 1024);
            }
            else
            {
                ImGui.TextUnformatted(label);
            }

            var labelMin = ImGui.GetItemRectMin();
            var labelMax = ImGui.GetItemRectMax();

            ImGui.SameLine();
            // Ensure height and distance to label.
            ImGui.Dummy(Vector2.UnitY * (frameHeight + itemSpacing.Y));

            ImGui.BeginGroup(); // Fourth Group.

            ImGui.PopStyleVar(2);

            // This seems wrong?
            //ImGui.SetWindowSize( new Vector2( ImGui.GetWindowSize().X - frameHeight, ImGui.GetWindowSize().Y ) );

            var itemWidth = ImGui.CalcItemWidth();

            ImGui.PushItemWidth(Math.Max(0f, itemWidth - frameHeight));

            LabelStack.Add((labelMin, labelMax));
            return(ret);
        }
Exemplo n.º 3
0
 public override void ReTree()
 {
     ImGui.PushID(this.UUID);
     if (ImGui.TreeNode(this.UUID, this.Title))
     {
         ImGui.InputText($"Title###{this.UUID}#Title", ref this.Title, 0xF);
         ImGui.Text($"Macro Commands");
         var combinds = String.Join('\n', this.Commands);
         ImGui.InputTextMultiline($"###{this.UUID}#Commands", ref combinds, 0x41 * 30, new Vector2(ImGui.CalcItemWidth(), 200));
         this.Commands = combinds.Split('\n').Where(x => !String.IsNullOrEmpty(x)).Take(30).ToArray();
         ImGui.TreePop();
     }
     ImGui.PopID();
 }
Exemplo n.º 4
0
        public override void OnGuiRender()
        {
            bool open = true;

            ImGui.Begin("Asset Manager", ref open, ImGuiWindowFlags.NoNav);
            if (ImGui.Button("Create"))
            {
                ImGui.OpenPopup("Create");
            }

            #region Search bar
            var width = ImGui.CalcItemWidth();
            ImGui.SameLine();

            ImGui.SetNextItemWidth(ImGui.CalcItemWidth());
            ImGui.SetCursorPosX((width * .35f) + 8);
            string tmp = searchPattern;
            bool   updateSearchPattern = ImGui.InputTextWithHint("##Search", FontAwesome5.Search + " Search", ref tmp, 512, ImGuiInputTextFlags.AutoSelectAll);

            if (ImGui.IsItemClicked(0))
            {
                isSearching = true;
            }

            ImGui.SameLine();

            ImGui.SetCursorPosX(ImGui.GetCursorPosX() - 8);
            if (ImGui.Button(FontAwesome5.Times))
            {
                searchPattern = "";
            }

            if (updateSearchPattern)
            {
                searchPattern = tmp;
            }
            #endregion

            if (ImGui.BeginPopup("Create"))
            {
                DrawCreateMenu();
                ImGui.EndPopup();
            }

            ImGui.Separator();

            ImGui.Columns(2, "##AssetColumns", true);
            if (setColumnWidth)
            {
                ImGui.SetColumnWidth(0, width * .35f);
                setColumnWidth = false;
            }

            ImGui.BeginChild("FileBrowser##1", new Vector2(0, ImGui.GetWindowHeight() * .71f));

            if (ImGui.TreeNodeEx("Assets", ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.SpanFullWidth | ImGuiTreeNodeFlags.Selected | ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick))
            {
                if (ImGui.IsItemClicked())
                {
                    activeFolder     = "";
                    activeFolderInfo = _assetDirectoryInfo;
                    isSearching      = false;
                }
                DrawAssetsDir(_assetDirectoryInfo);
                ImGui.TreePop();
            }
            ImGui.EndChild();

            ImGui.NextColumn();

            if (ImGui.IsItemClicked(0))
            {
                selectedFile = -1;
                isSearching  = false;
            }

            ImGui.BeginChild("ContentBrowser##1", new Vector2(0, ImGui.GetWindowHeight() * .71f), false, ImGuiWindowFlags.NoNav);

            #region Breadcrumb Trail
            string[] splitPath = activeFolder.Split('\\');
            if (splitPath[0].Length > 0)
            {
                if (ImGui.Selectable("Assets", false, ImGuiSelectableFlags.AllowItemOverlap, ImGui.CalcTextSize("Assets")))
                {
                    activeFolder     = "";
                    activeFolderInfo = _assetDirectoryInfo;
                }

                DragAndDropTargetFolder(_assetDirectoryInfo);

                ImGui.SameLine();
                ImGui.Text(" > ");
                ImGui.SameLine();

                if (ImGui.Selectable(splitPath[0], false, ImGuiSelectableFlags.AllowItemOverlap, ImGui.CalcTextSize(splitPath[0])))
                {
                    activeFolder     = splitPath[0];
                    activeFolderInfo = new DirectoryInfo(string.Join('\\', _assetDirectoryInfo.FullName, activeFolder));
                }

                DragAndDropTargetFolder(new DirectoryInfo(string.Join('\\', _assetDirectoryInfo.FullName, splitPath[0])));
            }
            else
            {
                ImGui.Text("Assets");
            }

            for (int i = 0; i < splitPath[1..].Length; i++)
            {
                string path = splitPath[1..][i];