public void Draw(float width) { icard.Recalculate(width); if (icard.Height < 1 || width < 1) { ImGui.Dummy(new Vector2(1, 1)); return; } if (icard.Height != renderHeight || (int)width != renderWidth) { renderWidth = (int)width; renderHeight = (int)icard.Height; if (renderTarget != null) { ImGuiHelper.DeregisterTexture(renderTarget.Texture); renderTarget.Dispose(); } renderTarget = new RenderTarget2D(renderWidth, renderHeight); rid = ImGuiHelper.RegisterTexture(renderTarget.Texture); } window.RenderContext.RenderTarget = renderTarget; window.RenderContext.PushViewport(0, 0, renderWidth, renderHeight); var cc = window.RenderContext.ClearColor; window.RenderContext.ClearColor = Color4.Transparent; window.RenderContext.ClearAll(); window.RenderContext.ClearColor = cc; window.RichText.RenderText(icard, 0, 0); window.RenderContext.RenderTarget = null; window.RenderContext.PopViewport(); //ImGui. Base off ImageButton so we can get input for selection later var style = ImGui.GetStyle(); var btn = style.Colors[(int)ImGuiCol.Button]; ImGui.PushStyleColor(ImGuiCol.ButtonHovered, btn); ImGui.PushStyleColor(ImGuiCol.ButtonActive, btn); ImGui.ImageButton((IntPtr)rid, new Vector2(renderWidth, icard.Height), new Vector2(0, 1), new Vector2(1, 0), 0, Vector4.Zero, Vector4.One); ImGui.PopStyleColor(); ImGui.PopStyleColor(); //Somehow keep track of selection? (idk if InfocardDisplay should do this) }
public void Draw(float width) { icard.Recalculate(width); if (icard.Height < 1 || width < 1) { ImGui.Dummy(new Vector2(1, 1)); return; } if (icard.Height != renderHeight || (int)width != renderWidth) { renderWidth = (int)width; renderHeight = (int)icard.Height; if (renderTarget != null) { ImGuiHelper.DeregisterTexture(renderTarget.Texture); renderTarget.Dispose(); } renderTarget = new RenderTarget2D(renderWidth, renderHeight); rid = ImGuiHelper.RegisterTexture(renderTarget.Texture); } window.RenderContext.RenderTarget = renderTarget; window.RenderContext.PushViewport(0, 0, renderWidth, renderHeight); var cc = window.RenderContext.ClearColor; window.RenderContext.ClearColor = Color4.Transparent; window.RenderContext.ClearAll(); window.RenderContext.ClearColor = cc; window.RichText.RenderText(icard, 0, 0); window.RenderContext.RenderTarget = null; window.RenderContext.PopViewport(); var cPos = (Vector2)ImGui.GetCursorPos(); var wPos = (Vector2)ImGui.GetWindowPos(); var scrPos = -ImGui.GetScrollY(); var mOffset = cPos + wPos + new Vector2(0, scrPos); var drawList = ImGui.GetWindowDrawList(); drawList.AddImage((IntPtr)rid, new Vector2((int)mOffset.X, (int)mOffset.Y), new Vector2((int)(mOffset.X + renderWidth), (int)(mOffset.Y + icard.Height)), new Vector2(0, 1), new Vector2(1, 0)); ImGui.InvisibleButton("##infocardbutton", new System.Numerics.Vector2(renderWidth, icard.Height)); }