diff --git a/Content/textures/Move.png b/Content/textures/Move.png new file mode 100644 index 0000000..e5ac882 Binary files /dev/null and b/Content/textures/Move.png differ diff --git a/Content/textures/Move.png.wetx b/Content/textures/Move.png.wetx new file mode 100644 index 0000000..e1f0eeb --- /dev/null +++ b/Content/textures/Move.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: cdd1630a-b087-40c1-98d6-fc22bb42dae1 +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: dbab8d73-7029-4538-8f54-18dc54469fd2 + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: f7abb165-2f4f-4602-8cb4-82718d814054 + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/Content/textures/Rotate.png b/Content/textures/Rotate.png new file mode 100644 index 0000000..fedd781 Binary files /dev/null and b/Content/textures/Rotate.png differ diff --git a/Content/textures/Rotate.png.wetx b/Content/textures/Rotate.png.wetx new file mode 100644 index 0000000..733c198 --- /dev/null +++ b/Content/textures/Rotate.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: e66fa5d6-91ac-4e88-956b-e6eea325d2ba +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: 29406d95-727f-4799-aa8e-2fdc85fd093b + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: 54d3a3fa-bc47-4b6e-8cb4-cf80fccc32df + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/Content/textures/Universal.png b/Content/textures/Universal.png new file mode 100644 index 0000000..f7430f9 Binary files /dev/null and b/Content/textures/Universal.png differ diff --git a/Content/textures/Universal.png.wetx b/Content/textures/Universal.png.wetx new file mode 100644 index 0000000..3c9a267 --- /dev/null +++ b/Content/textures/Universal.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: 770c594e-a265-4d7d-bf00-179f99d7db69 +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: f97a12b2-79e1-48c0-ba3d-ea4699701f15 + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: f458cf4c-20f0-41b4-ab7f-628678eaded0 + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/Content/textures/scale.png b/Content/textures/scale.png new file mode 100644 index 0000000..b5810f8 Binary files /dev/null and b/Content/textures/scale.png differ diff --git a/Content/textures/scale.png.wetx b/Content/textures/scale.png.wetx new file mode 100644 index 0000000..7fec58a --- /dev/null +++ b/Content/textures/scale.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: bdf96e06-a60b-4835-8920-b1a095a0658b +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: 8ec2d289-8fa4-4ecd-a25a-2cd5d58c1168 + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: a3c977ee-93a3-46fa-a7ec-16d210cf3d5f + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/Content/textures/solid.png b/Content/textures/solid.png new file mode 100644 index 0000000..21f6169 Binary files /dev/null and b/Content/textures/solid.png differ diff --git a/Content/textures/solid.png.wetx b/Content/textures/solid.png.wetx new file mode 100644 index 0000000..913b607 --- /dev/null +++ b/Content/textures/solid.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: ee2f0013-99d6-47c8-b997-2ce926608055 +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: c10685b3-050d-438b-a680-5df80b53d275 + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: b313975f-949a-4884-8c83-26370ecbb912 + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/Content/textures/wireframe.png b/Content/textures/wireframe.png new file mode 100644 index 0000000..0593a5d Binary files /dev/null and b/Content/textures/wireframe.png differ diff --git a/Content/textures/wireframe.png.wetx b/Content/textures/wireframe.png.wetx new file mode 100644 index 0000000..88314e7 --- /dev/null +++ b/Content/textures/wireframe.png.wetx @@ -0,0 +1,40 @@ +!Evergine.Assets.Exporters.TextureMetaFile,Evergine.Assets +Id: 389ce1ad-1d90-43e6-a82a-fe73838a9fc4 +DefaultProfile: + ExcludeAsset: false + ExportedItem: null + Name: default + PixelFormat: R8G8B8A8_UNorm + Platform: Undefined + ScaledHeight: 64 + ScaledPercentage: 1.0 + ScaledWidth: 64 + ScalingType: Original +ExportAsRaw: false +GenerateMipMaps: true +NinePatchType: None +PremultipliedAlpha: true +Profiles: {} +SamplerID: 00000000-0000-0000-0000-000000000000 +Source: + Header: + Id: 9ecc3db1-42dd-4657-a619-c18b510baefc + IsCompressed: true + LastModified: 0001-01-01T00:00:00.0000000 + TextureInfo: + Id: 0f7be850-5872-4112-8f1e-9644ffd1f6c6 + Description: + ArraySize: 1 + CpuAccess: None + Depth: 1 + Faces: 1 + Flags: ShaderResource + Format: R8G8B8A8_UNorm + Height: 64 + MipLevels: 1 + SampleCount: None + Type: Texture2D + Usage: Default + Width: 64 + HasData: true + SamplerID: 9018edf8-ea96-4721-bf83-5561942432e0 diff --git a/DonatelloAI/MyScene.cs b/DonatelloAI/MyScene.cs index fd27abc..1e5fca2 100644 --- a/DonatelloAI/MyScene.cs +++ b/DonatelloAI/MyScene.cs @@ -18,8 +18,7 @@ public override void RegisterManagers() this.Managers.AddManager(new CustomImGuiManager() { ImGuizmoEnabled = true, - }); - + }); } protected override void CreateScene() diff --git a/DonatelloAI/UI/ToolbarPanel.cs b/DonatelloAI/UI/ToolbarPanel.cs index 435af31..0f2fd72 100644 --- a/DonatelloAI/UI/ToolbarPanel.cs +++ b/DonatelloAI/UI/ToolbarPanel.cs @@ -1,8 +1,13 @@ using DonatelloAI.Components; +using DonatelloAI.ImGui; using DonatelloAI.SceneManagers; using Evergine.Bindings.Imgui; +using Evergine.Common.Graphics; +using Evergine.Framework; +using Evergine.Framework.Services; using Evergine.Mathematics; using Evergine.UI; +using System; namespace DonatelloAI.UI { @@ -10,15 +15,53 @@ public class ToolbarPanel { public bool OpenWindow = true; + private readonly uint SelectedColor = (uint)new Color("#4296fa").ToInt(); + + private CustomImGuiManager imguiManager; private Manipulation manipulation; private ModelCollectionManager modelCollectionManager; - public ToolbarPanel(Manipulation manipulation, ModelCollectionManager modelCollectionManager) + private IntPtr moveIcon; + private IntPtr rotateIcon; + private IntPtr scaleIcon; + private IntPtr universalIcon; + private IntPtr wireframeIcon; + private IntPtr solidIcon; + + private bool initialized = false; + + public ToolbarPanel(CustomImGuiManager imGuiManager, Manipulation manipulation, ModelCollectionManager modelCollectionManager) { + this.imguiManager = imGuiManager; this.manipulation = manipulation; this.modelCollectionManager = modelCollectionManager; } + public void Initialized() + { + var assetsService = Application.Current.Container.Resolve(); + + var moveTexture = assetsService.Load(EvergineContent.Textures.Move_png); + this.moveIcon = this.imguiManager.CreateImGuiBinding(moveTexture); + + var rotateTexture = assetsService.Load(EvergineContent.Textures.Rotate_png); + this.rotateIcon = this.imguiManager.CreateImGuiBinding(rotateTexture); + + var scaleTexture = assetsService.Load(EvergineContent.Textures.scale_png); + this.scaleIcon = this.imguiManager.CreateImGuiBinding(scaleTexture); + + var universalTexture = assetsService.Load(EvergineContent.Textures.Universal_png); + this.universalIcon = this.imguiManager.CreateImGuiBinding(universalTexture); + + var wireframeTexture = assetsService.Load(EvergineContent.Textures.wireframe_png); + this.wireframeIcon = this.imguiManager.CreateImGuiBinding(wireframeTexture); + + var solidTexture = assetsService.Load(EvergineContent.Textures.solid_png); + this.solidIcon = this.imguiManager.CreateImGuiBinding(solidTexture); + + this.initialized = true; + } + public unsafe void Show(ref ImGuiIO* io) { if (!this.OpenWindow) @@ -26,48 +69,140 @@ public unsafe void Show(ref ImGuiIO* io) return; } - int windowsWidth = 247; - int windowsHeight = 52; - ImguiNative.igSetNextWindowPos(new Vector2(io->DisplaySize.X - 128, 40), ImGuiCond.Appearing, new Vector2(1, 0)); - ImguiNative.igSetNextWindowSize(new Vector2(windowsWidth, windowsHeight), ImGuiCond.Appearing); - ImguiNative.igBegin("Toolbar", this.OpenWindow.Pointer(), ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove); + if (!this.initialized) + { + this.Initialized(); + } + + int windowsWidth = 300; + int windowsHeight = 60; + ImguiNative.igSetNextWindowPos(new Vector2(io->DisplaySize.X - 128, 50), ImGuiCond.None, new Vector2(1, 0)); + ImguiNative.igSetNextWindowSize(new Vector2(windowsWidth, windowsHeight), ImGuiCond.None); + ImguiNative.igBegin("Toolbar", this.OpenWindow.Pointer(), ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBackground); + + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, (uint)Color.Black.ToInt()); + + int buttonSize = 40; + int spaceBetweenButtons = 8; + int verticalSeparator = 12; + + int additionalStylePushed = 0; + + // Move + if (this.manipulation.Operation == Evergine.Bindings.Imguizmo.OPERATION.TRANSLATE) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } - int buttonSize = 35; - if (ImguiNative.igButton("M", Vector2.One * buttonSize)) + if (ImguiNative.igImageButton(this.moveIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.manipulation.Operation = Evergine.Bindings.Imguizmo.OPERATION.TRANSLATE; } - ImguiNative.igSameLine(0,4); - if (ImguiNative.igButton("R", Vector2.One * buttonSize)) + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + // Rotate + ImguiNative.igSameLine(0, spaceBetweenButtons); + if (this.manipulation.Operation == Evergine.Bindings.Imguizmo.OPERATION.ROTATE) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } + + if (ImguiNative.igImageButton(this.rotateIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.manipulation.Operation = Evergine.Bindings.Imguizmo.OPERATION.ROTATE; } - ImguiNative.igSameLine(0, 4); - if (ImguiNative.igButton("S", Vector2.One * buttonSize)) + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + // Scale + ImguiNative.igSameLine(0, spaceBetweenButtons); + if (this.manipulation.Operation == Evergine.Bindings.Imguizmo.OPERATION.SCALE) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } + + if (ImguiNative.igImageButton(this.scaleIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.manipulation.Operation = Evergine.Bindings.Imguizmo.OPERATION.SCALE; } - ImguiNative.igSameLine(0, 4); - if (ImguiNative.igButton("U", Vector2.One * buttonSize)) + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + // Universal + ImguiNative.igSameLine(0, spaceBetweenButtons); + if (this.manipulation.Operation == Evergine.Bindings.Imguizmo.OPERATION.UNIVERSAL) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } + + if (ImguiNative.igImageButton(this.universalIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.manipulation.Operation = Evergine.Bindings.Imguizmo.OPERATION.UNIVERSAL; } - ImguiNative.igSameLine(0, 8); - if (ImguiNative.igButton("W", Vector2.One * buttonSize)) + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + // Wireframe + ImguiNative.igSameLine(0, verticalSeparator); + if (this.modelCollectionManager.RenderType == ModelCollectionManager.RenderMode.Wireframe) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } + + if (ImguiNative.igImageButton(this.wireframeIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.modelCollectionManager.RenderType = ModelCollectionManager.RenderMode.Wireframe; } - ImguiNative.igSameLine(0, 4); - if (ImguiNative.igButton("O", Vector2.One * buttonSize)) + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + // Solid + ImguiNative.igSameLine(0, spaceBetweenButtons); + if (this.modelCollectionManager.RenderType == ModelCollectionManager.RenderMode.Solid) + { + ImguiNative.igPushStyleColor_U32(ImGuiCol.Button, SelectedColor); + additionalStylePushed++; + } + + if (ImguiNative.igImageButton(this.solidIcon, Vector2.One * buttonSize, Vector2.Zero, Vector2.One, 0, Vector4.Zero, Vector4.One)) { this.modelCollectionManager.RenderType = ModelCollectionManager.RenderMode.Solid; } + if (additionalStylePushed > 0) + { + ImguiNative.igPopStyleColor(additionalStylePushed); + additionalStylePushed = 0; + } + + ImguiNative.igPopStyleColor(1); + ImguiNative.igEnd(); } } diff --git a/DonatelloAI/UI/UIBehavior.cs b/DonatelloAI/UI/UIBehavior.cs index b2392ec..a3da395 100644 --- a/DonatelloAI/UI/UIBehavior.cs +++ b/DonatelloAI/UI/UIBehavior.cs @@ -6,7 +6,6 @@ using Evergine.Common.Graphics; using Evergine.Framework; using Evergine.Mathematics; -using Evergine.UI; using System; namespace DonatelloAI.UI @@ -49,7 +48,7 @@ protected override void OnActivated() this.galleryPanel = new GalleryPanel(modelCollectionManager); this.menuBar = new MenuBar(this); this.conversionPanel = new ConversionPanel(this.loadingPanel); - this.toolbar = new ToolbarPanel(this.manipulation, modelCollectionManager); + this.toolbar = new ToolbarPanel(imguiManager, this.manipulation, modelCollectionManager); } public bool ShowTextToModelPanel