Exemplo n.º 1
0
        public static void DrawIcon(ImGuiController controller, string name, int countCaption = 1, Vector2?offset = null)
        {
            Texture btnIcon = controller.GetImage(name);
            IntPtr  CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, btnIcon, $"Icon" + name);

            Vector2 size   = new Vector2(btnIcon.Width, btnIcon.Height);
            Vector2 corner = ImGui.GetCursorScreenPos() + (offset ?? Vector2.Zero);

            ImGui.GetWindowDrawList().AddImage(CPUframeBufferTextureId, corner, corner + size, Vector2.Zero, Vector2.One);
            if (countCaption > 1)
            {
                ImGui.SetCursorScreenPos(corner + new Vector2(size.X * 0.8f, 5));
                ImGui.Text($"{countCaption}");
            }
        }
Exemplo n.º 2
0
        //No longer used
        public static void DrawClickableIcon(ImGuiController controller, string name, int countCaption = 1, Vector2?offset = null)
        {
            Texture btnIcon = controller.GetImage(name);
            IntPtr  CPUframeBufferTextureId = controller.GetOrCreateImGuiBinding(controller.GraphicsDevice.ResourceFactory, btnIcon, $"ClickIcon" + name);

            Vector2 size    = new Vector2(btnIcon.Width, btnIcon.Height);
            Vector2 thispos = ImGui.GetCursorScreenPos();

            ImGui.InvisibleButton($"#{name + ImGui.GetCursorPosY()}", size + new Vector2(-2, -4));

            uint iconcol = ImGui.IsItemHovered() ? 0xaaafafaf : 0xffffffff;

            ImGui.SetCursorScreenPos(thispos);
            Vector2 corner = ImGui.GetCursorScreenPos() + offset ?? Vector2.Zero;

            ImGui.GetWindowDrawList().AddImage(CPUframeBufferTextureId, corner, corner + size, Vector2.Zero, Vector2.One, iconcol);
            if (countCaption > 1)
            {
                ImGui.SetCursorScreenPos(corner + new Vector2(size.X * 0.8f, 5));
                ImGui.Text($"{countCaption}");
            }
        }