Exemplo n.º 1
0
        public override bool Draw()
        {
            ImGui.Text("Zoom: ");
            ImGui.SameLine();
            ImGui.SliderFloat("", ref zoom, 10, 800, "%.0f%%", 1);
            ImGui.SameLine();
            ImGui.Checkbox("Checkerboard", ref checkerboard);
            ImGui.Separator();
            var w = ImGui.GetContentRegionAvailableWidth();

            zoom = (int)zoom;
            var scale = zoom / 100;
            var sz    = new Vector2(tex.Width, tex.Height) * scale;

            ImGuiNative.igSetNextWindowContentSize(new Vector2(sz.X, 0));
            ImGui.BeginChild("##scroll", false, WindowFlags.HorizontalScrollbar);
            var pos     = ImGui.GetCursorScreenPos();
            var windowH = ImGui.GetWindowHeight();
            var windowW = ImGui.GetWindowWidth();

            if (checkerboard)
            {
                unsafe
                {
                    var lst = ImGuiNative.igGetWindowDrawList();
                    ImGuiNative.ImDrawList_AddImage(lst, (void *)ImGuiHelper.CheckerboardId,
                                                    pos, new Vector2(pos.X + windowW, pos.Y + windowH),
                                                    new Vector2(0, 0),
                                                    new Vector2(windowW / 16, windowH / 16),
                                                    uint.MaxValue);
                }
            }
            if (sz.Y < windowH) //Centre
            {
                ImGui.Dummy(5, (windowH / 2) - (sz.Y / 2));
            }
            if (sz.X < w)
            {
                ImGui.Dummy((w / 2) - (sz.X / 2), 5);
                ImGui.SameLine();
            }
            ImGui.Image((IntPtr)tid, sz, Vector2.Zero, new Vector2(1, 1),
                        new Vector4(1, 1, 1, 1), new Vector4(0, 0, 0, 0));
            ImGui.EndChild();
            return(open);
        }
Exemplo n.º 2
0
        public override void Draw()
        {
            ImGui.Text("Zoom: ");
            ImGui.SameLine();
            ImGui.PushItemWidth(120);
            ImGui.SliderFloat("", ref zoom, 10, 800, "%.0f%%", 1);
            ImGui.PopItemWidth();
            ImGui.SameLine();
            if (anim != null)
            {
                ImGui.PushItemWidth(80);
                ImGui.InputInt("Frame Number", ref frame, 1, 1);
                if (frame <= 0)
                {
                    frame = 0;
                }
                if (frame >= anim.FrameCount)
                {
                    frame = anim.FrameCount - 1;
                }
                ImGui.PopItemWidth();
                ImGui.SameLine();
            }
            ImGui.Checkbox("Checkerboard", ref checkerboard);
            ImGui.SameLine();

            bool doOpen = ImGui.Button("Info");

            if (doOpen)
            {
                ImGui.OpenPopup("Info##" + Unique);
            }
            ImGui.Separator();
            var w = ImGui.GetWindowContentRegionWidth();

            zoom = (int)zoom;
            var scale = zoom / 100;
            var sz    = new Vector2(tex.Width, tex.Height) * scale;

            ImGuiNative.igSetNextWindowContentSize(new Vector2(sz.X, 0));
            bool isOpen = true;

            if (ImGui.BeginPopupModal("Info##" + Unique, ref isOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Format: " + tex.Format);
                ImGui.Text("Width: " + tex.Width);
                ImGui.Text("Height: " + tex.Height);
                ImGui.Text("Mipmaps: " + ((tex.LevelCount > 1) ? "Yes" : "No"));
                ImGui.EndPopup();
            }
            ImGui.BeginChild("##scroll", new Vector2(-1), false, ImGuiWindowFlags.HorizontalScrollbar);
            var pos     = ImGui.GetCursorScreenPos();
            var windowH = ImGui.GetWindowHeight();
            var windowW = ImGui.GetWindowWidth();
            var cbX     = Math.Max(windowW, sz.X);
            var cbY     = Math.Max(windowH, sz.Y);

            if (checkerboard)
            {
                unsafe
                {
                    var lst = ImGuiNative.igGetWindowDrawList();
                    ImGuiNative.ImDrawList_AddImage(lst, (IntPtr)ImGuiHelper.CheckerboardId,
                                                    pos, new Vector2(pos.X + cbX, pos.Y + cbY),
                                                    new Vector2(0, 0),
                                                    new Vector2(cbX / 16, cbY / 16),
                                                    uint.MaxValue);
                }
            }
            if (sz.Y < windowH) //Centre
            {
                ImGui.Dummy(new Vector2(5, (windowH / 2) - (sz.Y / 2)));
            }
            if (sz.X < w)
            {
                ImGui.Dummy(new Vector2((w / 2) - (sz.X / 2), 5));
                ImGui.SameLine();
            }
            var tl = new Vector2(0, 1);
            var br = new Vector2(1, 0);

            if (anim != null)
            {
                var f = anim.Frames[frame];
                tl = new Vector2(f.UV1.X, 1 - f.UV1.Y);
                br = new Vector2(f.UV2.X, 1 - f.UV2.Y);
            }
            ImGui.Image((IntPtr)tid, sz, tl, br,
                        Vector4.One, Vector4.Zero);

            ImGui.EndChild();
        }
Exemplo n.º 3
0
 public static unsafe void AddDrawListImage(ImDrawList *list, Texture texture, Vector2 a, Vector2 b, Vector2 uv_a, Vector2 uv_b, uint col)
 {
     AddTexture(texture);
     ImGuiNative.ImDrawList_AddImage(list, texture.GetNativeTexturePtr(), a, b, uv_a, uv_b, col);
 }