public override void RegisterData(ImGuiView view) { ImageAsset asset = GetFirstAssetOfType <ImageAsset>(); asset.Tex2D = ContentManagement.ContentManager.LoadTexture2D(asset.ContentName); asset.ImGuiID = new IntPtr(view.Textures.Register(asset.Tex2D)); }
/// <summary> /// Instance list on window left side /// </summary> public void DrawInstanceList() { ImGui.Text("Instance List"); ImGuiView.TableView("InstanceListView", () => { foreach (var pair in m_Instances) { ImGui.TableNextRow(); //Instance Type ImGui.TableNextColumn(); m_TypeDrawer.DrawType(pair.Value.type); //Instance name ImGui.TableNextColumn(); DrawInstanceButton(pair.Key, pair.Value); //Instance Parent Type ImGui.TableNextColumn(); m_TypeDrawer.DrawType(pair.Value.parent); ///Remove ImGui.TableNextColumn(); if (ImGui.Button("X##RemoveInstanceList" + pair.Key)) { m_Instances.Remove(pair.Key); break; } } }, ImGuiTableFlags.Resizable, "Type", "Instance", "Parent", "Remove"); }
public override void RegisterData(ImGuiView view) { FontAsset asset = GetFirstAssetOfType <FontAsset>(); asset.ImGuiID = view.Fonts.RegisterFromAssetTTF( ContentManagement.ContentManager.GetUVContent(), "FreeTypeFonts\\" + asset.ContentName, FontSize); }
public void DrawTableWithSingleRow(string tableName, Type type, string name, bool errored = false) { ImGuiView.TableView(tableName, () => { ImGui.TableNextRow(); paramTable.DrawRow(type, name, ref m_InputText, errored); }, "Type", "Name", "Value", "Error"); }
protected UICanvas(GraphicsDevice gd, ImGuiView imGuiView, Func <Vector2> computeSize) { ComputeSize = computeSize; ImGuiView = imGuiView; GraphicsDevice = gd; Canvas = MakeCanvasFrom(8, 8); imageBind = ImGuiView.GetOrCreateImGuiBinding(Factory, Canvas.TextureView); }
public MIDIPatternIO(GraphicsDevice gd, ImGuiView view, Func <Vector2> computeSize, MIDIPatternConnect pattern) : base(gd, view, computeSize) { Buffers = new BufferList <VertexPositionColor> [257]; // first buffer for general purpose, others for keys for (int i = 0; i < 257; i++) { Buffers[i] = dispose.Add(new BufferList <VertexPositionColor>(gd, 6 * 2048 * 16, new[] { 0, 3, 2, 0, 2, 1 })); } PatternHandler = pattern; CurrentInteraction = new MIDIPatternInteractionIdle(PatternHandler); ProjMatrix = Factory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer | BufferUsage.Dynamic)); dispose.Add(ProjMatrix); VertexLayoutDescription vertexLayout = new VertexLayoutDescription( new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2), new VertexElementDescription("Color", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float4)); Layout = Factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("ProjectionMatrixBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex))); dispose.Add(Layout); ShaderDescription vertexShaderDesc = new ShaderDescription( ShaderStages.Vertex, Encoding.UTF8.GetBytes(VertexCode), "main"); ShaderDescription fragmentShaderDesc = new ShaderDescription( ShaderStages.Fragment, Encoding.UTF8.GetBytes(FragmentCode), "main"); Shaders = dispose.AddArray(Factory.CreateFromSpirv(vertexShaderDesc, fragmentShaderDesc)); var pipelineDescription = new GraphicsPipelineDescription(); pipelineDescription.BlendState = BlendStateDescription.SingleAlphaBlend; pipelineDescription.DepthStencilState = new DepthStencilStateDescription( depthTestEnabled: true, depthWriteEnabled: true, comparisonKind: ComparisonKind.LessEqual); pipelineDescription.RasterizerState = new RasterizerStateDescription( cullMode: FaceCullMode.Front, fillMode: PolygonFillMode.Solid, frontFace: FrontFace.Clockwise, depthClipEnabled: true, scissorTestEnabled: false); pipelineDescription.PrimitiveTopology = PrimitiveTopology.TriangleList; pipelineDescription.ResourceLayouts = new ResourceLayout[] { Layout }; pipelineDescription.ShaderSet = new ShaderSetDescription( vertexLayouts: new VertexLayoutDescription[] { vertexLayout }, shaders: Shaders); pipelineDescription.Outputs = Canvas.FrameBuffer.OutputDescription; Pipeline = Factory.CreateGraphicsPipeline(pipelineDescription); MainResourceSet = Factory.CreateResourceSet(new ResourceSetDescription(Layout, ProjMatrix)); }
protected override void DrawWindowContent() { m_TabBarView.OnGui(); ImGuiView.TableView("##ClassWindowTable", () => { ImGui.TableNextRow(); ImGui.TableNextColumn(); DrawInstanceList(); ImGui.TableNextColumn(); DrawSubViews(); }, 2, ImGuiTableFlags.Resizable); }
public void DrawFieldTable(List <FieldInfo> fieldList, string tableName) { if (fieldList.Count == 0) { return; } ImGuiView.TableView(tableName, () => { foreach (var field in fieldList) { ImGui.TableNextRow(); DrawTableRow(field, m_FieldDrawer); } }, TableFlags, "Type", "Name", "Value"); }
public void DrawTable(List <MethodInfo> table, string TableName) { if (table.Count == 0) { return; } ImGuiView.TableView(TableName, () => { foreach (var method in table) { ImGui.TableNextRow(); DrawTableRow(method); } }, TableFlags, "Return Type", "Method Name", "Params"); }
public void ImGuiRegisterResources(ImGuiView view) { view.Fonts.RegisterDefault(); foreach (var entity in _entities) { foreach (var type in GUIManager.UIComponentsTypes) { var func = typeof(Entity).GetMethod("GetComponent").MakeGenericMethod(type); UIComponent comp = (UIComponent)func.Invoke(entity, null); if (comp != null) { comp.RegisterData(view); _components.Add(comp); } } } }
/// <summary> /// 4. Draw Class Table /// </summary> protected virtual void DrawClassTable(ClassSubCategory classDict, string label) { PadLeft(" ", () => { ImGuiView.TableView("Tabel" + label, () => { foreach (var class2type in classDict) { if (class2type.Key.IndexOf(m_SearchText) != -1) { ImGui.TableNextRow(); DrawClassTableRow(class2type.Value, label); } } }, s_TableFlags, "Class Name", "Class Type", "Base Class"); }); }
void DrawTable() { ImGuiView.TableView("MethodInvokeTable", () => { for (int i = 0; i < inputText.Length; ++i) { ImGui.TableNextRow(); if (m_ErrorRow == i) { paramTable.DrawRow(methodParameters[i].ParameterType, methodParameters[i].Name, ref inputText[i], true); } else { paramTable.DrawRow(methodParameters[i].ParameterType, methodParameters[i].Name, ref inputText[i]); } } }, "Type", "Name", "Value", "Error"); }
public void DrawTable( List <PropertyInfo> propertyList, string table_name = "StaticPropertyTable" ) { if (propertyList.Count == 0) { return; } ImGuiView.TableView(table_name, () => { foreach (PropertyInfo property in propertyList) { ImGui.TableNextRow(); DrawTableRow(property); } }, TableFlags, "Type", "Name", "Value", "Gettable", "Settable"); }
/// <summary> /// Create and initialize a new game. /// </summary> public EditorWindow() { disposer = new DisposeGroup(); // Initialize window and imgui var projectInfo = Assembly.GetExecutingAssembly().GetName(); view = disposer.Add(new RenderView(new RenderViewSettings() { X = 100, Y = 100, Width = 1280, Height = 720, Title = $"{projectInfo.Name} {DateTime.Now.Year}.{projectInfo.Version.Major}.{projectInfo.Version.Minor}.r{projectInfo.Version.Revision}", })); gd = view.GraphicsDevice; cl = gd.ResourceFactory.CreateCommandList(); imGui = new ImGuiView(gd, view.Window, gd.MainSwapchain.Framebuffer.OutputDescription, view.Width, view.Height); ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true; }
public virtual void Render(CommandList cl) { var imgSize = ComputeSize(); int IntImageSizeX = (int)Math.Floor(imgSize.X); int IntImageSizeY = (int)Math.Floor(imgSize.Y); if (Canvas.Width != IntImageSizeX || Canvas.Height != IntImageSizeY) { Canvas = MakeCanvasFrom(IntImageSizeX, IntImageSizeY); imageBind = ImGuiView.GetOrCreateImGuiBinding(Factory, Canvas.TextureView); } ImGui.Image(imageBind, new Vector2(IntImageSizeX, IntImageSizeY)); ProcessInputs(); RenderToCanvas(cl); }
void DrawMethodMenu(MethodInfo method, object instance, string label) { if (method is null) { return; } ImGuiView.PopupView(method.Name + "##" + label, () => { if (ImGui.Button("Invoke")) { if (CanInvoke(method, instance)) { RuntimeExplorerApp.Instance.MethodInvokeWindow.Show(method, method.GetParameters(), instance); } else { ImGui.CloseCurrentPopup(); } } //ImGui.Button("Hook"); }); }
public abstract void RegisterData(ImGuiView view);
public TestCanvas(GraphicsDevice gd, ImGuiView view, Func <Vector2> computeSize) : base(gd, view, computeSize) { Buffer = dispose.Add(new BufferList <VertexPositionColor>(gd, 6)); VertexPositionColor[] quadVertices = { new VertexPositionColor(new Vector2(-150f, 150f), RgbaFloat.Red), new VertexPositionColor(new Vector2(150f, 150f), RgbaFloat.Green), new VertexPositionColor(new Vector2(-150f, -150f), RgbaFloat.Blue), new VertexPositionColor(new Vector2(150f, -150f), RgbaFloat.Yellow) }; ushort[] quadIndices = { 0, 1, 2, 3 }; VertexBuffer = Factory.CreateBuffer(new BufferDescription(4 * VertexPositionColor.SizeInBytes, BufferUsage.VertexBuffer | BufferUsage.Dynamic)); IndexBuffer = Factory.CreateBuffer(new BufferDescription(4 * sizeof(ushort), BufferUsage.IndexBuffer)); dispose.Add(VertexBuffer); dispose.Add(IndexBuffer); ProjMatrix = Factory.CreateBuffer(new BufferDescription(64, BufferUsage.UniformBuffer | BufferUsage.Dynamic)); dispose.Add(ProjMatrix); GraphicsDevice.UpdateBuffer(VertexBuffer, 0, quadVertices); GraphicsDevice.UpdateBuffer(IndexBuffer, 0, quadIndices); VertexLayoutDescription vertexLayout = new VertexLayoutDescription( new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2), new VertexElementDescription("Color", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float4)); Layout = Factory.CreateResourceLayout(new ResourceLayoutDescription( new ResourceLayoutElementDescription("ProjectionMatrixBuffer", ResourceKind.UniformBuffer, ShaderStages.Vertex))); dispose.Add(Layout); ShaderDescription vertexShaderDesc = new ShaderDescription( ShaderStages.Vertex, Encoding.UTF8.GetBytes(VertexCode), "main"); ShaderDescription fragmentShaderDesc = new ShaderDescription( ShaderStages.Fragment, Encoding.UTF8.GetBytes(FragmentCode), "main"); Shaders = dispose.AddArray(Factory.CreateFromSpirv(vertexShaderDesc, fragmentShaderDesc)); var pipelineDescription = new GraphicsPipelineDescription(); pipelineDescription.BlendState = BlendStateDescription.SingleOverrideBlend; pipelineDescription.DepthStencilState = new DepthStencilStateDescription( depthTestEnabled: true, depthWriteEnabled: true, comparisonKind: ComparisonKind.LessEqual); pipelineDescription.RasterizerState = new RasterizerStateDescription( cullMode: FaceCullMode.Front, fillMode: PolygonFillMode.Solid, frontFace: FrontFace.Clockwise, depthClipEnabled: true, scissorTestEnabled: false); pipelineDescription.PrimitiveTopology = PrimitiveTopology.TriangleList; pipelineDescription.ResourceLayouts = new ResourceLayout[] { Layout }; pipelineDescription.ShaderSet = new ShaderSetDescription( vertexLayouts: new VertexLayoutDescription[] { vertexLayout }, shaders: Shaders); pipelineDescription.Outputs = Canvas.FrameBuffer.OutputDescription; Pipeline = Factory.CreateGraphicsPipeline(pipelineDescription); MainResourceSet = Factory.CreateResourceSet(new ResourceSetDescription(Layout, ProjMatrix)); }
/// <inheritdoc/> void IImGuiPanel.ImGuiRegisterResources(ImGuiView view) { view.Fonts.RegisterDefault(); myFont = view.Fonts.RegisterFromAssetTTF(GlobalContent, "Fonts/Inconsolata-Regular", 16f); testTextureID = view.Textures.Register(GlobalContent, "Textures/Logo"); }
static void Main(string[] args) { var dispose = new DisposeGroup(); // Initialize window and imgui var view = dispose.Add(new RenderView()); var gd = view.GraphicsDevice; var cl = gd.ResourceFactory.CreateCommandList(); var imGui = new ImGuiView(gd, view.Window, gd.MainSwapchain.Framebuffer.OutputDescription, view.Width, view.Height); ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true; //Create ImGui Windows var menu = new UIMenu("Hello World!", new IUIComponent[] { new UIMenuItem("Test 1"), new UIMenuItem("Test 2", "CTRL+Z") }); var mainmenu = new UIMainMenuBar(new IUIComponent[] { menu }); var uiwindow = new UIWindow("Abstracted ImGui!", new IUIComponent[] { new UIText("Test Text"), new UICheckbox("Test Checkbox", false) }); var pattern = new MIDIPattern(); var projectConnect = new ProjectConnect(); var pianoRollWindow = UIUtils.CreatePianoRollWindow(projectConnect, pattern, gd, imGui); // Initialize imgui UI var uihost = dispose.Add(new UIHost(new IUIComponent[] { mainmenu, uiwindow, pianoRollWindow })); Stopwatch frameTimer = new Stopwatch(); frameTimer.Start(); var hotkeys = new HotkeyHandler <GlobalHotkey>(); // Main application loop while (view.Exists) { if (!view.Exists) { break; } imGui.Update((float)frameTimer.Elapsed.TotalSeconds, view.Width, view.Height); frameTimer.Reset(); frameTimer.Start(); cl.Begin(); // Compute UI elements, render canvases ImGui.DockSpaceOverViewport(); uihost.Render(cl); ImGui.ShowDemoWindow(); hotkeys.Update(true); if (hotkeys.CurrentHotkey == GlobalHotkey.Undo) { projectConnect.Undo(); } if (hotkeys.CurrentHotkey == GlobalHotkey.Redo) { projectConnect.Redo(); } Console.WriteLine(hotkeys.CurrentHotkey); ImGui.Text(ImGui.GetIO().Framerate.ToString()); imGui.UpdateViewIO(view); cl.SetFramebuffer(gd.MainSwapchain.Framebuffer); cl.ClearColorTarget(0, new RgbaFloat(clearColor.X, clearColor.Y, clearColor.Z, 1f)); imGui.Render(gd, cl); cl.End(); gd.SubmitCommands(cl); gd.SwapBuffers(gd.MainSwapchain); imGui.SwapExtraWindows(gd); } dispose.Dispose(); }
public static UIWindow CreatePianoRollWindow(ProjectConnect projectConnect, MIDIPattern pattern, GraphicsDevice gd, ImGuiView imGui) { var menu = new UIMenu("Retard Menu", new IUIComponent[] { new UIMenuItem("Snap Size") }); var menuBar = new UIMenuBar(new IUIComponent[] { menu }); pattern.GenNotes(); var pianoPattern = new MIDIPatternConnect(projectConnect, pattern); var canvas = new MIDIPatternIO(gd, imGui, ImGui.GetContentRegionAvail, pianoPattern); var window = new UIWindow("PianoRoll", new UIValueProperty <bool>(true), ImGuiWindowFlags.MenuBar, new IUIComponent[] { menuBar, canvas }); return(window); }