Пример #1
0
        public static bool ButtonGradient(string strId, Vector2 buttonSizeVector)
        {
            String[]      strIdArray = strId.Split("###");
            Vector2       p          = ImGuiNET.ImGui.GetCursorScreenPos();
            Vector2       sizeText   = ImGui.CalcTextSize(strIdArray[0]);
            ImDrawListPtr drawList   = ImGuiNET.ImGui.GetWindowDrawList();
            //ButtonHeight += ImGuiNET.ImGui.GetFrameHeight(); //Dynamically Allocated Height
            //float ButtonWidth = sizeText.X + ButtonHeight; //Dynamically Allocated Width
            float buttonHeight = buttonSizeVector.Y; //Fixed Height
            float buttonWidth  = buttonSizeVector.X; //Dynamically Allocated Width

            if (buttonWidth < sizeText.X)
            {
                buttonWidth = sizeText.X + sizeText.X * 0.20f;
            }
            Vector2 buttonSize = new Vector2(p.X + buttonWidth, p.Y + buttonHeight);
            uint    colTop;
            uint    colBottom;

            if (strIdArray.Length > 1)
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[1], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            else
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[0], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            if (ImGuiNET.ImGui.IsItemHovered())
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonActive);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered);
            }
            else
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button);
            }
            drawList.AddRectFilledMultiColor(p, buttonSize, colTop, colTop, colBottom, colBottom);
            drawList.AddRect(p, buttonSize, ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonActive));
            drawList.AddText(new Vector2(p.X + (buttonWidth / 2) - (sizeText.X / 2), p.Y + (buttonHeight / 2) - (sizeText.Y / 2)), ImGui.GetColorU32(ImGuiCol.Text), strIdArray[0]);
            return(false);
        }
Пример #2
0
        public static bool ButtonGradient(string strId)
        {
            String[]      strIdArray   = strId.Split("##");
            Vector2       p            = ImGuiNET.ImGui.GetCursorScreenPos();
            Vector2       sizeText     = ImGui.CalcTextSize(strIdArray[0]);
            ImDrawListPtr drawList     = ImGuiNET.ImGui.GetWindowDrawList();
            float         buttonHeight = ImGuiNET.ImGui.GetFrameHeight();
            float         buttonWidth  = sizeText.X + sizeText.X * 0.20f;
            Vector2       buttonSize   = new Vector2(p.X + buttonWidth, p.Y + buttonHeight);
            uint          colTop;
            uint          colBottom;

            if (strIdArray.Length > 1)
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[1], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            else
            {
                if (ImGuiNET.ImGui.InvisibleButton(strIdArray[0], new Vector2(buttonWidth, buttonHeight)))
                {
                    return(true);
                }
            }
            if (ImGuiNET.ImGui.IsItemHovered())
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1.50f);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.50f);
            }
            else
            {
                colTop    = ImGuiNET.ImGui.GetColorU32(ImGuiCol.ButtonHovered);
                colBottom = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Button, 0.20f);
            }
            drawList.AddRectFilledMultiColor(p, buttonSize, colTop, colTop, colBottom, colBottom);
            drawList.AddRect(p, buttonSize, ImGuiNET.ImGui.GetColorU32(ImGuiCol.Separator));
            drawList.AddText(new Vector2(p.X + (buttonWidth / 2) - (sizeText.X / 2), p.Y + (buttonHeight / 2) - (sizeText.Y / 2)), ImGui.GetColorU32(ImGuiCol.Text), strIdArray[0]);
            return(false);
        }
Пример #3
0
        private static bool SequencerButton(
            ImDrawListPtr draw_list,
            Vector2 pos,
            char ch,
            bool isSelected = false,
            uint color      = ColorWhite)
        {
            var io          = ImGui.GetIO();
            var rect        = new ImRect(pos, new Vector2(pos.X + 16, pos.Y + 16));
            var isMouseOver = rect.Contains(io.MousePos);

            if (!isSelected)
            {
                color = isMouseOver ? 0xFFFFFFFFu : 0x50FFFFFFu;
            }

            draw_list.AddRect(rect.Min, rect.Max, color, 4);
            draw_list.AddText(new Vector2(pos.X + 4, pos.Y - 1), color, $"{ch}");

            return(isMouseOver);
        }