├── .gitignore ├── Ghurund.sln ├── LICENSE ├── README.md ├── apps ├── Demo.UI │ ├── .gitignore │ ├── Demo.UI.vcxproj │ ├── premake5.lua │ ├── res │ │ ├── TabIconLayout.xml │ │ ├── TestRecycler.xml │ │ ├── TestRow.xml │ │ ├── buttonsTab.xml │ │ └── layout.xml │ └── src │ │ ├── DemoApplication.h │ │ ├── DemoLayout.h │ │ ├── DemoWindow.h │ │ ├── TestRecycler.h │ │ └── main.cpp ├── Editor │ ├── .gitignore │ ├── Editor.vcxproj │ ├── cpp.hint │ ├── premake5.lua │ ├── res │ │ ├── EditorWindow.xml │ │ ├── LayoutEditor.xml │ │ ├── LogPanel.xml │ │ ├── LogRow.xml │ │ ├── PropertyPanel.xml │ │ ├── SearchField.xml │ │ ├── TitleBar.xml │ │ └── ToolWindow.xml │ └── src │ │ ├── EditorApplication.h │ │ ├── EditorLayout.h │ │ ├── EditorWindow.h │ │ ├── MainMenu.h │ │ ├── control │ │ ├── FpsText.h │ │ ├── SearchField.h │ │ ├── SearchFieldLayout.h │ │ ├── TitleBar.h │ │ └── ToolWindow.h │ │ ├── main.cpp │ │ └── tool │ │ ├── LogPanel.h │ │ ├── PropertyPanel.h │ │ └── WidgetHierarchyPanel.h ├── Messenger │ ├── Messenger.vcxproj │ ├── premake5.lua │ └── src │ │ ├── MessengerApplication.h │ │ ├── MessengerWindow.cpp │ │ ├── MessengerWindow.h │ │ ├── TextMessage.h │ │ └── main.cpp ├── Preview │ ├── .gitignore │ ├── Preview.vcxproj │ ├── premake5.lua │ ├── res │ │ └── layout.xml │ └── src │ │ ├── PreviewApplication.h │ │ ├── PreviewLayout.h │ │ ├── PreviewWindow.h │ │ └── main.cpp ├── engine.props └── premake5.lua ├── engine ├── Engine.Core.DirectX │ ├── Engine.Core.DirectX.vcxproj │ ├── premake5.lua │ └── src │ │ ├── Ghurund.Core.DirectX.h │ │ ├── core │ │ └── directx │ │ │ ├── CommandList.cpp │ │ │ ├── CommandList.h │ │ │ ├── DirectXTypes.cpp │ │ │ ├── DirectXTypes.h │ │ │ ├── Exceptions.h │ │ │ ├── Fence.cpp │ │ │ ├── Fence.h │ │ │ ├── Frame.cpp │ │ │ ├── Frame.h │ │ │ ├── Graphics.cpp │ │ │ ├── Graphics.h │ │ │ ├── MathTypes.cpp │ │ │ ├── MathTypes.h │ │ │ ├── SwapChain.cpp │ │ │ ├── SwapChain.h │ │ │ ├── adapter │ │ │ ├── AdapterOutput.cpp │ │ │ ├── AdapterOutput.h │ │ │ ├── DisplayMode.cpp │ │ │ ├── DisplayMode.h │ │ │ ├── GraphicsAdapter.cpp │ │ │ └── GraphicsAdapter.h │ │ │ ├── buffer │ │ │ ├── DepthBuffer.cpp │ │ │ ├── DepthBuffer.h │ │ │ ├── DescriptorHeap.cpp │ │ │ ├── DescriptorHeap.h │ │ │ ├── DynamicBuffer.h │ │ │ ├── GPUBuffer.cpp │ │ │ ├── GPUBuffer.h │ │ │ ├── RenderTarget.cpp │ │ │ └── RenderTarget.h │ │ │ ├── memory │ │ │ ├── GPUResourceFactory.cpp │ │ │ ├── GPUResourceFactory.h │ │ │ ├── GPUResourcePointer.cpp │ │ │ ├── GPUResourcePointer.h │ │ │ ├── HeapAllocator.cpp │ │ │ └── HeapAllocator.h │ │ │ ├── shader │ │ │ ├── CompilationTarget.cpp │ │ │ ├── CompilationTarget.h │ │ │ ├── CompilerInclude.cpp │ │ │ ├── CompilerInclude.h │ │ │ ├── ConstantBuffer.cpp │ │ │ ├── ConstantBuffer.h │ │ │ ├── ConstantBufferField.h │ │ │ ├── Sampler.h │ │ │ ├── Shader.cpp │ │ │ ├── Shader.h │ │ │ ├── ShaderConstant.h │ │ │ ├── ShaderProgram.cpp │ │ │ ├── ShaderProgram.h │ │ │ ├── ShaderType.cpp │ │ │ ├── ShaderType.h │ │ │ ├── TextureBufferConstant.h │ │ │ └── TextureConstant.h │ │ │ └── texture │ │ │ ├── Texture.cpp │ │ │ └── Texture.h │ │ ├── ghcdxpch.cpp │ │ └── ghcdxpch.h ├── Engine.Core │ ├── Engine.Core.natvis │ ├── Engine.Core.vcxproj │ ├── packages.config │ ├── premake5.lua │ └── src │ │ ├── Common.h │ │ ├── Ghurund.Core.h │ │ ├── Status.h │ │ ├── core │ │ ├── Buffer.h │ │ ├── Concepts.h │ │ ├── DataParsing.h │ │ ├── Enum.h │ │ ├── Event.h │ │ ├── EventHandler.h │ │ ├── Exceptions.h │ │ ├── Hashing.h │ │ ├── IUnknownImpl.h │ │ ├── Id.h │ │ ├── NamedObject.h │ │ ├── Noncopyable.h │ │ ├── Object.cpp │ │ ├── Object.h │ │ ├── Observable.h │ │ ├── ObservableHandler.h │ │ ├── Pointer.cpp │ │ ├── Pointer.h │ │ ├── SharedPointer.h │ │ ├── StackTrace.h │ │ ├── StateMachine.h │ │ ├── SystemInfo.h │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── Translations.h │ │ ├── TypeSequence.h │ │ ├── TypeWrapper.h │ │ ├── allocation │ │ │ ├── AllocationStrategy.h │ │ │ ├── Allocator.h │ │ │ ├── AllocatorMap.h │ │ │ ├── CircularBufferStrategy.h │ │ │ ├── PoolAllocator.h │ │ │ ├── SimpleAllocator.h │ │ │ └── SimpleBufferStrategy.h │ │ ├── application │ │ │ ├── Application.cpp │ │ │ ├── Application.h │ │ │ ├── Feature.cpp │ │ │ ├── Feature.h │ │ │ ├── FeatureCollection.h │ │ │ ├── Settings.cpp │ │ │ ├── Settings.h │ │ │ ├── WindowCloseAction.h │ │ │ └── WindowList.h │ │ ├── collection │ │ │ ├── Array.h │ │ │ ├── ArrayCollection.h │ │ │ ├── AverageValue.h │ │ │ ├── Bag.h │ │ │ ├── BufferedValue.h │ │ │ ├── Collection.h │ │ │ ├── CollectionWithCapacity.h │ │ │ ├── HashMap.h │ │ │ ├── LinkedList.h │ │ │ ├── List.h │ │ │ ├── Map.h │ │ │ ├── ObservableList.h │ │ │ ├── ObservablePointerList.h │ │ │ ├── PointerArray.h │ │ │ ├── PointerList.h │ │ │ ├── PointerSet.h │ │ │ ├── Queue.h │ │ │ ├── Range.h │ │ │ ├── Set.h │ │ │ ├── Stack.h │ │ │ ├── Tree.h │ │ │ ├── TreeMap.h │ │ │ ├── TypeMap.h │ │ │ └── iterator │ │ │ │ ├── ArrayIterator.h │ │ │ │ ├── ListNodeIterator.h │ │ │ │ ├── ReverseArrayIterator.h │ │ │ │ ├── ReverseListNodeIterator.h │ │ │ │ ├── ReverseTreeNodeIterator.h │ │ │ │ └── TreeNodeIterator.h │ │ ├── image │ │ │ ├── Image.cpp │ │ │ ├── Image.h │ │ │ ├── ImageLoader.cpp │ │ │ └── ImageLoader.h │ │ ├── input │ │ │ ├── EventConsumer.h │ │ │ ├── Input.cpp │ │ │ ├── Input.h │ │ │ ├── InputEventArgs.h │ │ │ ├── Keyboard.h │ │ │ └── Mouse.h │ │ ├── io │ │ │ ├── DirectoryLibrary.h │ │ │ ├── DirectoryPath.cpp │ │ │ ├── DirectoryPath.h │ │ │ ├── File.cpp │ │ │ ├── File.h │ │ │ ├── FileLibrary.h │ │ │ ├── FilePath.cpp │ │ │ ├── FilePath.h │ │ │ ├── FileUtils.cpp │ │ │ ├── FileUtils.h │ │ │ ├── Library.h │ │ │ ├── LibraryList.h │ │ │ ├── MemoryStream.h │ │ │ ├── Path.h │ │ │ └── watcher │ │ │ │ ├── DirectoryWatch.cpp │ │ │ │ ├── DirectoryWatch.h │ │ │ │ ├── FileChange.cpp │ │ │ │ ├── FileChange.h │ │ │ │ ├── FileWatcher.cpp │ │ │ │ └── FileWatcher.h │ │ ├── logging │ │ │ ├── Formatter.h │ │ │ ├── Log.h │ │ │ ├── LogOutput.h │ │ │ ├── LogType.cpp │ │ │ ├── LogType.h │ │ │ ├── Logger.cpp │ │ │ └── Logger.h │ │ ├── math │ │ │ ├── MathUtils.h │ │ │ ├── Matrix3x2.h │ │ │ ├── Point.h │ │ │ ├── Rect.h │ │ │ └── Size.h │ │ ├── reflection │ │ │ ├── BaseProperty.h │ │ │ ├── BaseTypedProperty.h │ │ │ ├── Constructor.h │ │ │ ├── Method.h │ │ │ ├── OperationNotSupportedException.h │ │ │ ├── Parameter.h │ │ │ ├── Property.h │ │ │ ├── ReadOnlyProperty.h │ │ │ ├── StandardTypes.cpp │ │ │ ├── StandardTypes.h │ │ │ ├── Type.h │ │ │ ├── TypeBuilder.h │ │ │ ├── TypeModifier.cpp │ │ │ ├── TypeModifier.h │ │ │ └── WriteOnlyProperty.h │ │ ├── resource │ │ │ ├── Loader.h │ │ │ ├── LoaderCollection.h │ │ │ ├── ReloadTask.h │ │ │ ├── Resource.cpp │ │ │ ├── Resource.h │ │ │ ├── ResourceFormat.h │ │ │ ├── ResourceManager.cpp │ │ │ ├── ResourceManager.h │ │ │ ├── TextLoader.h │ │ │ └── TextResource.h │ │ ├── string │ │ │ ├── FixedString.h │ │ │ ├── GenericString.cpp │ │ │ ├── GenericString.h │ │ │ ├── GenericStringView.h │ │ │ ├── String.h │ │ │ ├── StringView.h │ │ │ ├── TextConversionUtils.h │ │ │ └── TextUtils.h │ │ ├── threading │ │ │ ├── APCThread.h │ │ │ ├── ConcurrentTaskQueue.h │ │ │ ├── ConditionVariable.h │ │ │ ├── CriticalSection.h │ │ │ ├── FunctionQueue.cpp │ │ │ ├── FunctionQueue.h │ │ │ ├── Task.cpp │ │ │ ├── Task.h │ │ │ ├── Thread.h │ │ │ ├── ThreadPoolExecutor.cpp │ │ │ ├── ThreadPoolExecutor.h │ │ │ ├── Waitable.h │ │ │ ├── WorkerThread.cpp │ │ │ └── WorkerThread.h │ │ └── window │ │ │ ├── Clipboard.h │ │ │ ├── DragDropManager.cpp │ │ │ ├── DragDropManager.h │ │ │ ├── SystemWindow.cpp │ │ │ ├── SystemWindow.h │ │ │ ├── Window.cpp │ │ │ ├── Window.h │ │ │ ├── WindowClass.cpp │ │ │ ├── WindowClass.h │ │ │ ├── WindowManager.h │ │ │ ├── WindowMessage.h │ │ │ ├── WindowProc.cpp │ │ │ ├── WindowProc.h │ │ │ └── WindowStyle.h │ │ ├── ghcpch.cpp │ │ └── ghcpch.h ├── Engine.UI.Direct2D │ ├── Engine.UI.Direct2D.vcxproj │ ├── premake5.lua │ └── src │ │ ├── Ghurund.UI.Direct2D.h │ │ ├── ghuidxpch.cpp │ │ ├── ghuidxpch.h │ │ └── ui │ │ └── direct2d │ │ ├── Canvas.cpp │ │ ├── Canvas.h │ │ ├── Graphics2D.cpp │ │ ├── Graphics2D.h │ │ ├── RenderTarget2D.cpp │ │ ├── RenderTarget2D.h │ │ ├── Shape.cpp │ │ ├── Shape.h │ │ ├── StrokeStyle.h │ │ ├── UIContext.cpp │ │ ├── UIContext.h │ │ ├── drawable │ │ ├── BitmapDrawable.cpp │ │ ├── BitmapDrawable.h │ │ ├── SvgDrawable.cpp │ │ └── SvgDrawable.h │ │ ├── effects │ │ ├── ShadowEffect.h │ │ └── TintEffect.h │ │ ├── font │ │ ├── Font.cpp │ │ ├── Font.h │ │ ├── FontCollectionLoader.cpp │ │ ├── FontCollectionLoader.h │ │ ├── FontFileEnumerator.cpp │ │ ├── FontFileEnumerator.h │ │ ├── FontLoader.cpp │ │ └── FontLoader.h │ │ ├── image │ │ ├── Bitmap.cpp │ │ ├── Bitmap.h │ │ ├── BitmapLoader.h │ │ ├── SvgDocument.cpp │ │ └── SvgDocument.h │ │ ├── loading │ │ ├── ImageDrawableFactory.h │ │ ├── LayoutLoader.h │ │ ├── ShapeFactory.h │ │ └── TextFormatFactory.h │ │ └── text │ │ ├── TextFormat.cpp │ │ ├── TextFormat.h │ │ ├── TextLayout.cpp │ │ └── TextLayout.h ├── Engine.UI.GDI │ ├── Engine.UI.GDI.vcxproj │ ├── premake5.lua │ └── src │ │ ├── Ghurund.UI.GDI.h │ │ ├── ghuigdipch.cpp │ │ ├── ghuigdipch.h │ │ └── ui │ │ └── gdi │ │ ├── Canvas.cpp │ │ ├── Canvas.h │ │ ├── Gdi.h │ │ ├── Shape.cpp │ │ ├── Shape.h │ │ ├── StrokeStyle.h │ │ ├── UIContext.cpp │ │ ├── UIContext.h │ │ ├── drawable │ │ ├── BitmapDrawable.cpp │ │ ├── BitmapDrawable.h │ │ ├── SvgDrawable.cpp │ │ └── SvgDrawable.h │ │ ├── effects │ │ ├── ShadowEffect.h │ │ └── TintEffect.h │ │ ├── font │ │ ├── Font.cpp │ │ ├── Font.h │ │ ├── FontLoader.cpp │ │ └── FontLoader.h │ │ ├── image │ │ ├── Bitmap.cpp │ │ ├── Bitmap.h │ │ ├── BitmapLoader.h │ │ ├── SvgDocument.cpp │ │ └── SvgDocument.h │ │ ├── loading │ │ ├── ImageDrawableFactory.h │ │ ├── ShapeFactory.h │ │ └── TextFormatFactory.h │ │ └── text │ │ ├── TextFormat.cpp │ │ ├── TextFormat.h │ │ ├── TextLayout.cpp │ │ └── TextLayout.h ├── Engine.UI │ ├── .gitignore │ ├── Engine.UI.natvis │ ├── Engine.UI.vcxproj │ ├── UISchema.xsd │ ├── packages.config │ ├── premake5.lua │ ├── res │ │ ├── Button.xml │ │ ├── CheckBox.xml │ │ ├── ExpandableContainer.xml │ │ ├── ScrollBar.xml │ │ ├── Tab.xml │ │ ├── TabContainer.xml │ │ ├── Toolbar.xml │ │ └── TreeRow.xml │ └── src │ │ ├── Ghurund.UI.h │ │ ├── ghuipch.cpp │ │ ├── ghuipch.h │ │ └── ui │ │ ├── Alignment.cpp │ │ ├── Alignment.h │ │ ├── Animation.h │ │ ├── Binding.h │ │ ├── Canvas.h │ │ ├── Color.cpp │ │ ├── Color.h │ │ ├── Cursor.cpp │ │ ├── Cursor.h │ │ ├── Orientation.h │ │ ├── Padding.h │ │ ├── PreferredSize.cpp │ │ ├── PreferredSize.h │ │ ├── README.md │ │ ├── RootView.cpp │ │ ├── RootView.h │ │ ├── Shape.cpp │ │ ├── Shape.h │ │ ├── StrokeStyle.h │ │ ├── UIContext.cpp │ │ ├── UIContext.h │ │ ├── adapter │ │ ├── AdapterChildrenProvider.h │ │ ├── ControlPool.h │ │ ├── ItemAdapter.h │ │ ├── ItemSource.h │ │ ├── RecyclerView.cpp │ │ └── RecyclerView.h │ │ ├── control │ │ ├── Border.cpp │ │ ├── Border.h │ │ ├── ChildrenProvider.h │ │ ├── ClickableControl.cpp │ │ ├── ClickableControl.h │ │ ├── Clip.cpp │ │ ├── Clip.h │ │ ├── ColorView.cpp │ │ ├── ColorView.h │ │ ├── Control.cpp │ │ ├── Control.h │ │ ├── ControlContainer.cpp │ │ ├── ControlContainer.h │ │ ├── ControlGroup.cpp │ │ ├── ControlGroup.h │ │ ├── ControlList.h │ │ ├── ControlParent.cpp │ │ ├── ControlParent.h │ │ ├── ImageView.cpp │ │ ├── ImageView.h │ │ ├── InvalidControl.cpp │ │ ├── InvalidControl.h │ │ ├── MouseEvents.h │ │ ├── PaddingContainer.cpp │ │ ├── PaddingContainer.h │ │ ├── ScrollView.cpp │ │ ├── ScrollView.h │ │ ├── SelectableView.cpp │ │ ├── SelectableView.h │ │ ├── Shadow.cpp │ │ ├── Shadow.h │ │ ├── Space.cpp │ │ └── Space.h │ │ ├── drawable │ │ ├── CursorDrawable.cpp │ │ ├── CursorDrawable.h │ │ ├── Drawable.cpp │ │ ├── Drawable.h │ │ ├── ImageDrawable.h │ │ ├── InvalidImageDrawable.cpp │ │ └── InvalidImageDrawable.h │ │ ├── effects │ │ ├── DrawingEffect.h │ │ ├── ShadowEffect.h │ │ └── TintEffect.h │ │ ├── font │ │ ├── Font.cpp │ │ └── Font.h │ │ ├── image │ │ ├── Bitmap.cpp │ │ ├── Bitmap.h │ │ ├── VectorImage.cpp │ │ └── VectorImage.h │ │ ├── layout │ │ ├── DesktopLayout.cpp │ │ ├── DesktopLayout.h │ │ ├── FlowLayout.cpp │ │ ├── FlowLayout.h │ │ ├── FlowLayoutManager.cpp │ │ ├── FlowLayoutManager.h │ │ ├── HorizontalLayoutManager.h │ │ ├── LayoutManager.cpp │ │ ├── LayoutManager.h │ │ ├── LinearLayout.cpp │ │ ├── LinearLayout.h │ │ ├── LinearLayoutManager.cpp │ │ ├── LinearLayoutManager.h │ │ ├── ManualLayout.cpp │ │ ├── ManualLayout.h │ │ ├── ManualLayoutManager.cpp │ │ ├── ManualLayoutManager.h │ │ ├── StackLayout.cpp │ │ ├── StackLayout.h │ │ ├── StackLayoutManager.cpp │ │ ├── StackLayoutManager.h │ │ ├── VerticalLayoutManager.cpp │ │ └── VerticalLayoutManager.h │ │ ├── loading │ │ ├── ImageDrawableFactory.h │ │ ├── LayoutLoader.cpp │ │ ├── LayoutLoader.h │ │ ├── ShapeFactory.h │ │ └── TextFormatFactory.h │ │ ├── style │ │ ├── BaseTheme.h │ │ ├── ColorAttr.cpp │ │ ├── ColorAttr.h │ │ ├── DarkTheme.h │ │ ├── LightTheme.h │ │ ├── Style.cpp │ │ ├── Style.h │ │ ├── Theme.cpp │ │ ├── Theme.h │ │ └── WindowsTheme.h │ │ ├── text │ │ ├── ITextLayout.h │ │ ├── Selection.h │ │ ├── SetSelectionMode.h │ │ ├── TextBlock.cpp │ │ ├── TextBlock.h │ │ ├── TextBlockStyle.cpp │ │ ├── TextBlockStyle.h │ │ ├── TextField.cpp │ │ ├── TextField.h │ │ ├── TextFormat.cpp │ │ ├── TextFormat.h │ │ ├── TextMetrics.h │ │ ├── TextView.cpp │ │ ├── TextView.h │ │ └── license.txt │ │ ├── widget │ │ ├── ClickResponseView.cpp │ │ ├── ClickResponseView.h │ │ ├── ContentWidget.h │ │ ├── DragHelper.cpp │ │ ├── DragHelper.h │ │ ├── ExpandableContainer.cpp │ │ ├── ExpandableContainer.h │ │ ├── LayoutBinding.h │ │ ├── ProgressBar.cpp │ │ ├── ProgressBar.h │ │ ├── Separator.cpp │ │ ├── Separator.h │ │ ├── SeparatorStyle.h │ │ ├── SplitLayout.cpp │ │ ├── SplitLayout.h │ │ ├── StateIndicator.cpp │ │ ├── StateIndicator.h │ │ ├── VerticalScrollBar.cpp │ │ ├── VerticalScrollBar.h │ │ ├── Widget.h │ │ ├── button │ │ │ ├── Button.cpp │ │ │ ├── Button.h │ │ │ ├── CheckBox.cpp │ │ │ ├── CheckBox.h │ │ │ ├── CheckBoxRadio.cpp │ │ │ ├── CheckBoxRadio.h │ │ │ ├── RadioButton.cpp │ │ │ ├── RadioButton.h │ │ │ └── RadioGroup.h │ │ ├── menu │ │ │ ├── DropDown.h │ │ │ ├── DropDownLayout.h │ │ │ ├── MenuItem.h │ │ │ ├── PopupMenu.h │ │ │ ├── PopupMenuAdapter.h │ │ │ ├── Toolbar.h │ │ │ ├── ToolbarAdapter.cpp │ │ │ └── ToolbarAdapter.h │ │ ├── property │ │ │ ├── BoolPropertyRow.h │ │ │ ├── ObjectProperty.h │ │ │ ├── PropertyList.h │ │ │ ├── PropertyRow.h │ │ │ └── StringPropertyRow.h │ │ ├── tab │ │ │ ├── Tab.h │ │ │ ├── TabContainer.cpp │ │ │ ├── TabContainer.h │ │ │ ├── TabItemAdapter.cpp │ │ │ └── TabItemAdapter.h │ │ └── tree │ │ │ ├── TreeItem.h │ │ │ ├── TreeRow.h │ │ │ ├── TreeRowAdapter.h │ │ │ ├── TreeView.cpp │ │ │ └── TreeView.h │ │ └── window │ │ ├── VirtualWindow.h │ │ ├── VirtualWindowManager.h │ │ ├── WindowFrame.cpp │ │ └── WindowFrame.h ├── Engine │ ├── Engine.vcxproj │ ├── packages.config │ ├── premake5.lua │ └── src │ │ ├── Ghurund.Engine.h │ │ ├── application │ │ ├── ApplicationWindow.cpp │ │ ├── ApplicationWindow.h │ │ ├── Layer.h │ │ ├── LayerList.cpp │ │ └── LayerList.h │ │ ├── audio │ │ ├── Audio.cpp │ │ ├── Audio.h │ │ ├── Sound.cpp │ │ ├── Sound.h │ │ └── Sound3d.h │ │ ├── editor │ │ ├── CameraUtils.h │ │ ├── EditorComponent.h │ │ ├── ObservableObject.h │ │ ├── ThumbnailRenderer.cpp │ │ └── ThumbnailRenderer.h │ │ ├── game │ │ ├── GameAction.cpp │ │ ├── GameAction.h │ │ ├── KeyMap.h │ │ ├── entity │ │ │ ├── Entity.h │ │ │ ├── Scene.cpp │ │ │ ├── Scene.h │ │ │ ├── Scenes.h │ │ │ ├── TransformComponent.h │ │ │ ├── camera │ │ │ │ ├── Camera.cpp │ │ │ │ ├── Camera.h │ │ │ │ ├── CameraComponent.h │ │ │ │ ├── CameraController.cpp │ │ │ │ ├── CameraController.h │ │ │ │ └── CameraEntity.h │ │ │ └── light │ │ │ │ ├── Light.cpp │ │ │ │ ├── Light.h │ │ │ │ ├── LightComponent.h │ │ │ │ └── LightEntity.h │ │ ├── parameter │ │ │ ├── Parameter.cpp │ │ │ ├── Parameter.h │ │ │ ├── ParameterId.cpp │ │ │ ├── ParameterId.h │ │ │ ├── ParameterManager.cpp │ │ │ ├── ParameterManager.h │ │ │ ├── ParameterProvider.cpp │ │ │ ├── ParameterProvider.h │ │ │ ├── ParameterType.cpp │ │ │ ├── ParameterType.h │ │ │ ├── TextureParameter.h │ │ │ └── ValueParameter.h │ │ └── sky │ │ │ ├── AdvancedSky.h │ │ │ ├── BasicSky.h │ │ │ └── Sky.h │ │ ├── ghpch.cpp │ │ ├── ghpch.h │ │ ├── graphics │ │ ├── DrawableComponent.h │ │ ├── DrawableComponents.cpp │ │ ├── DrawableComponents.h │ │ ├── DrawingSystem.h │ │ ├── LightSystem.h │ │ ├── Material.cpp │ │ ├── Material.h │ │ ├── Materials.cpp │ │ ├── Materials.h │ │ ├── Postprocess.h │ │ ├── Renderer.cpp │ │ ├── Renderer.h │ │ ├── RenderingStatistics.cpp │ │ ├── RenderingStatistics.h │ │ ├── Shaders.h │ │ ├── Textures.h │ │ └── mesh │ │ │ ├── ConeMesh.cpp │ │ │ ├── ConeMesh.h │ │ │ ├── CubeMesh.cpp │ │ │ ├── CubeMesh.h │ │ │ ├── Mesh.cpp │ │ │ ├── Mesh.h │ │ │ ├── PlaneMesh.h │ │ │ ├── QuadMesh.h │ │ │ ├── SphereMesh.cpp │ │ │ ├── SphereMesh.h │ │ │ └── Vertex.h │ │ ├── net │ │ ├── Client.cpp │ │ ├── Client.h │ │ ├── ClientMessage.h │ │ ├── Connection.h │ │ ├── Message.cpp │ │ ├── Message.h │ │ ├── MessageType.cpp │ │ ├── MessageType.h │ │ ├── Networking.cpp │ │ ├── Networking.h │ │ ├── ReliableUDP.cpp │ │ ├── ReliableUDP.h │ │ ├── Server.cpp │ │ ├── Server.h │ │ ├── ServerMessage.h │ │ ├── Socket.cpp │ │ └── Socket.h │ │ ├── physics │ │ ├── Physics.cpp │ │ ├── Physics.h │ │ ├── PhysicsComponent.h │ │ ├── PhysicsSystem.h │ │ └── RigidBodyComponent.h │ │ ├── script │ │ ├── Script.cpp │ │ ├── Script.h │ │ ├── ScriptComponent.h │ │ ├── ScriptEngine.cpp │ │ ├── ScriptEngine.h │ │ ├── Scripts.h │ │ ├── StringFactory.h │ │ ├── angelscript │ │ │ ├── scriptmath.cpp │ │ │ └── scriptmath.h │ │ └── bindings │ │ │ ├── CameraScriptBindings.h │ │ │ ├── CollectionScriptBindings.h │ │ │ ├── EntityScriptBindings.h │ │ │ ├── Float3ScriptBindings.h │ │ │ ├── LightScriptBindings.h │ │ │ ├── ModelScriptBindings.h │ │ │ ├── SceneScriptBindings.h │ │ │ ├── ScriptBindings.h │ │ │ └── TimerScriptBindings.h │ │ └── ui │ │ ├── UIFeature.cpp │ │ ├── UIFeature.h │ │ └── UILayer.h ├── UnitTest.Core │ ├── UnitTest.Core.vcxproj │ ├── premake5.lua │ └── src │ │ ├── MemoryGuard.h │ │ ├── TestClass.h │ │ ├── TestUtils.h │ │ ├── core │ │ ├── ObservableTest.cpp │ │ ├── TypeWrapperTest.cpp │ │ ├── collection │ │ │ ├── ArrayIteratorTest.cpp │ │ │ ├── BagTest.cpp │ │ │ ├── LinkedListTest.cpp │ │ │ ├── ListTest.cpp │ │ │ ├── MapTest.cpp │ │ │ ├── QueueTest.cpp │ │ │ ├── RangeTest.cpp │ │ │ ├── ReverseIteratorTest.cpp │ │ │ ├── SetTest.cpp │ │ │ ├── StackTest.cpp │ │ │ ├── TestAllocator.h │ │ │ └── TreeTest.cpp │ │ ├── io │ │ │ └── PathTest.cpp │ │ ├── reflection │ │ │ ├── ReflectionTest.cpp │ │ │ ├── TestClass.h │ │ │ └── TypeTest.cpp │ │ ├── resource │ │ │ └── ResourceManagerTest.cpp │ │ ├── string │ │ │ └── StringTest.cpp │ │ └── threading │ │ │ ├── ThreadPoolExecutorTest.cpp │ │ │ └── WorkerThreadTest.cpp │ │ ├── pch.cpp │ │ └── pch.h ├── UnitTest.UI │ ├── UnitTest.UI.vcxproj │ ├── premake5.lua │ └── src │ │ ├── FloatSize.h │ │ ├── TestImage.h │ │ ├── pch.cpp │ │ ├── pch.h │ │ └── ui │ │ ├── AlignmentTest.cpp │ │ ├── ColorTest.cpp │ │ ├── PreferredSizeTest.cpp │ │ └── control │ │ ├── ImageViewTest.cpp │ │ └── TextBlockTest.cpp ├── UnitTest │ ├── UnitTest.vcxproj │ ├── premake5.lua │ └── src │ │ ├── TestUtils.h │ │ ├── main.cpp │ │ ├── net │ │ └── MessageTest.cpp │ │ ├── pch.cpp │ │ └── pch.h └── premake5.lua ├── images └── buttons.png ├── libs.props ├── premake5.lua ├── resources ├── fonts │ ├── lato_bold.ttf │ ├── lato_bolditalic.ttf │ ├── lato_italic.ttf │ ├── lato_light.ttf │ ├── lato_lightitalic.ttf │ ├── lato_medium.ttf │ ├── lato_mediumitalic.ttf │ └── lato_regular.ttf ├── icons │ ├── arrow down 18.png │ ├── arrow right 18.png │ ├── arrow up 18.png │ ├── category 18.png │ ├── checkBox checked 32.png │ ├── checkBox unchecked 32.png │ ├── checkbox checked 18.png │ ├── checkbox unchecked 18.png │ ├── copy 18.png │ ├── cut 18.png │ ├── face 24.svg │ ├── file 18.png │ ├── folder 18.png │ ├── icon save 32.png │ ├── lock 24.svg │ ├── material │ │ ├── close 18.png │ │ ├── help 18.png │ │ ├── maximize 18.png │ │ └── minimize 18.png │ ├── more 18.png │ ├── paste 18.png │ ├── play 18.png │ ├── radiobutton checked 18.png │ ├── radiobutton unchecked 18.png │ ├── search 18.png │ ├── sort 18.png │ ├── stop 18.png │ └── windows │ │ ├── close 18.png │ │ ├── help 18.png │ │ ├── maximize 18.png │ │ └── minimize 18.png ├── layouts │ ├── ButtonAccentLayout.xml │ ├── ButtonDefaultLayout.xml │ ├── ButtonFlatLayout.xml │ ├── ButtonIconLayout.xml │ ├── ButtonIconOnAccentLayout.xml │ ├── ButtonImageLayout.xml │ ├── ButtonLayout.xml │ ├── ButtonOutlinedLayout.xml │ ├── CheckBoxLayout.xml │ ├── ExpandableContainer.xml │ ├── HorizontalScrollBar.xml │ ├── LogRow.xml │ ├── RadioButtonLayout.xml │ ├── ToolbarLarge.xml │ ├── ToolbarSmall.xml │ ├── TreeItem.xml │ ├── VerticalScrollBar.xml │ ├── WindowFrame.xml │ ├── scrollBar test.xml │ └── test.xml ├── shaders │ ├── advancedSky.hlsl │ ├── basic.hlsl │ ├── basicLight.hlsl │ ├── basicSky.hlsl │ ├── common.hlsli │ ├── invalid.hlsl │ ├── lightPass.hlsl │ ├── normals.hlsl │ ├── outline.hlsl │ ├── toon.hlsl │ └── wireframe.hlsl └── textures │ ├── checker.png │ ├── diffuse.png │ ├── normal.png │ └── specular.png ├── samples ├── UI.Direct2D │ ├── UI.Direct2D.vcxproj │ ├── premake5.lua │ └── src │ │ ├── Direct2DWindow.cpp │ │ ├── Direct2DWindow.h │ │ └── main.cpp ├── UI.GDI │ ├── UI.GDI.vcxproj │ ├── premake5.lua │ └── src │ │ ├── GdiWindow.cpp │ │ ├── GdiWindow.h │ │ └── main.cpp ├── UI.Text │ ├── UI.Text.vcxproj │ └── premake5.lua └── premake5.lua └── tools ├── SystemInfo ├── SystemInfo.cpp ├── SystemInfo.vcxproj └── premake5.lua └── premake5.lua /apps/Demo.UI/.gitignore: -------------------------------------------------------------------------------- 1 | generated -------------------------------------------------------------------------------- /apps/Demo.UI/res/TabIconLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /apps/Demo.UI/res/TestRecycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /apps/Demo.UI/res/buttonsTab.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /apps/Demo.UI/res/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /apps/Demo.UI/src/DemoApplication.h: -------------------------------------------------------------------------------- 1 | #include "core/math/MathUtils.h" 2 | #include "DemoWindow.h" 3 | 4 | namespace Demo { 5 | using namespace Ghurund; 6 | using namespace Ghurund::UI; 7 | 8 | class DemoApplication:public Application { 9 | public: 10 | DemoApplication() { 11 | Features.add(ghnew UIFeature(*this)); 12 | } 13 | 14 | virtual Status onInit() override { 15 | auto window = ghnew DemoWindow(*this); 16 | window->Size = Settings.windowSize; 17 | Windows.add(window); 18 | window->Visible = true; 19 | window->bringToFront(); 20 | return Status::OK; 21 | } 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /apps/Demo.UI/src/DemoLayout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutBinding.h" 4 | #include "ui/widget/Widget.h" 5 | #include 6 | #include 7 | #include "ui/layout/StackLayout.h" 8 | #include 9 | 10 | namespace Demo { 11 | using namespace Ghurund::UI; 12 | 13 | class DemoLayout:public Widget { 14 | private: 15 | TestRecycler* testRecycler; 16 | 17 | protected: 18 | virtual void onLayoutChanged() override { 19 | if (!Layout) 20 | return; 21 | 22 | testRecycler = ghnew TestRecycler(); 23 | Layout->Container->Children.add(testRecycler); 24 | } 25 | 26 | public: 27 | inline StackLayout* getContainer() { 28 | return Layout->Container; 29 | } 30 | 31 | __declspec(property(get = getContainer)) StackLayout* Container; 32 | }; 33 | } -------------------------------------------------------------------------------- /apps/Demo.UI/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Ghurund.h" 2 | 3 | #include "DemoApplication.h" 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) { 6 | Ghurund::Settings settings; 7 | settings.parse(GetCommandLine()); 8 | Ghurund::main(settings); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /apps/Editor/.gitignore: -------------------------------------------------------------------------------- 1 | generated -------------------------------------------------------------------------------- /apps/Editor/cpp.hint: -------------------------------------------------------------------------------- 1 | // Hint files help the Visual Studio IDE interpret Visual C++ identifiers 2 | // such as names of functions and macros. 3 | // For more information see https://go.microsoft.com/fwlink/?linkid=865984 4 | #define ghnew new(_NORMAL_BLOCK, __FILE__, __LINE__) 5 | -------------------------------------------------------------------------------- /apps/Editor/res/EditorWindow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /apps/Editor/res/LayoutEditor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /apps/Editor/res/LogPanel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /apps/Editor/res/LogRow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /apps/Editor/res/PropertyPanel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /apps/Editor/res/SearchField.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 13 | 15 | 16 | 22 | 23 | -------------------------------------------------------------------------------- /apps/Editor/res/TitleBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /apps/Editor/res/ToolWindow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /apps/Editor/src/EditorApplication.h: -------------------------------------------------------------------------------- 1 | #include "EditorWindow.h" 2 | #include "ui/UIFeature.h" 3 | 4 | namespace Ghurund::Editor { 5 | class EditorApplication:public Ghurund::Application { 6 | public: 7 | EditorApplication() { 8 | Features.add(ghnew UIFeature(*this)); 9 | } 10 | 11 | virtual Status onInit() override { 12 | auto window = ghnew EditorWindow(*this); 13 | window->Size = Settings.windowSize; 14 | Windows.add(window); 15 | window->Visible = true; 16 | window->bringToFront(); 17 | return Status::OK; 18 | } 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /apps/Editor/src/MainMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/widget/MenuBar.h" 4 | 5 | class MainMenu:public Ghurund::UI::MenuBar { 6 | public: 7 | MainMenu():MenuBar(makeTheme()){} 8 | 9 | Theme makeTheme() 10 | }; -------------------------------------------------------------------------------- /apps/Editor/src/control/FpsText.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/collection/AverageValue.h" 4 | #include "ui/text/TextBlock.h" 5 | 6 | namespace Ghurund::Editor { 7 | using namespace Ghurund::UI; 8 | 9 | class FpsText:public TextBlock { 10 | private: 11 | AverageValue avgValue = AverageValue(30, 20); 12 | const Timer& timer; 13 | 14 | public: 15 | FpsText(Ghurund::UI::TextFormat* textFormat, uint32_t color, const Timer& timer):TextBlock(L"", color, textFormat), timer(timer) {} 16 | 17 | virtual void onUpdate(const uint64_t time) override { 18 | avgValue.set(1.0f / timer.FrameTime); 19 | Text = fmt::format(L"fps: {:.2f}", avgValue.get()).c_str(); 20 | invalidate(); 21 | } 22 | }; 23 | } -------------------------------------------------------------------------------- /apps/Editor/src/control/SearchFieldLayout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SearchFieldBinding.h" 4 | 5 | #include "ui/widget/button/Button.h" 6 | #include "ui/widget/text/TextField.h" 7 | 8 | namespace Ghurund::Editor { 9 | using namespace Ghurund::UI; 10 | 11 | class SearchFieldLayout:public SearchFieldBinding { 12 | private: 13 | EventHandler stateHandler = [this](Control& control) { 14 | Hint->Visible = QueryField->Focused; 15 | return true; 16 | }; 17 | 18 | public: 19 | SearchFieldLayout(Control* layout):SearchFieldBinding(layout) { 20 | QueryField->StateChanged.add(stateHandler); 21 | } 22 | 23 | ~SearchFieldLayout() { 24 | QueryField->StateChanged.remove(stateHandler); 25 | } 26 | }; 27 | } -------------------------------------------------------------------------------- /apps/Editor/src/control/TitleBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TitleBarBinding.h" 4 | #include "ui/text/TextBlock.h" 5 | 6 | namespace Ghurund::Editor { 7 | using namespace Ghurund::UI; 8 | 9 | class TitleBar:public Widget { 10 | public: 11 | inline const WString& getText() { 12 | return Layout->Title->Text; 13 | } 14 | 15 | inline void setText(const WString& text) { 16 | Layout->Title->Text = text; 17 | } 18 | 19 | __declspec(property(get = getText, put = setText)) const WString& Text; 20 | }; 21 | } -------------------------------------------------------------------------------- /apps/Editor/src/control/ToolWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TitleBar.h" 4 | #include "ToolWindowBinding.h" 5 | 6 | #include "ui/layout/StackLayout.h" 7 | #include "ui/widget/ContainerWidget.h" 8 | 9 | namespace Ghurund::Editor { 10 | using namespace Ghurund::UI; 11 | 12 | class ToolWindow:public ContainerWidget { 13 | public: 14 | inline const WString& getTitle() { 15 | return Layout->TitleBar->Text; 16 | } 17 | 18 | inline void setTitle(const WString& text) { 19 | Layout->TitleBar->Text = text; 20 | } 21 | 22 | __declspec(property(get = getTitle, put = setTitle)) const WString& Title; 23 | }; 24 | } -------------------------------------------------------------------------------- /apps/Editor/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Ghurund.h" 2 | 3 | #include "EditorApplication.h" 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) { 6 | Ghurund::Settings settings; 7 | settings.parse(GetCommandLine()); 8 | Ghurund::main(_T("Ghurund::Editor"), settings); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /apps/Messenger/src/TextMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "net/ClientMessage.h" 4 | 5 | namespace Messenger { 6 | struct TextMessage:public Ghurund::Net::ClientMessage { 7 | TextMessage() { 8 | type = Ghurund::Net::MessageType::RELIABLE.Value; 9 | messageType = (uint8_t)Ghurund::Net::ClientMessageType::USER; 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /apps/Messenger/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Ghurund.h" 2 | 3 | #include "MessengerApplication.h" 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) { 6 | Ghurund::Settings settings; 7 | settings.windowSize = { 200,300 }; 8 | settings.parse(GetCommandLine()); 9 | std::unique_ptr logOutput = std::make_unique(_T("logs")); 10 | Ghurund::main(settings, std::move(logOutput)); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /apps/Preview/.gitignore: -------------------------------------------------------------------------------- 1 | generated -------------------------------------------------------------------------------- /apps/Preview/res/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /apps/Preview/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Ghurund.Engine.h" 2 | 3 | #include "PreviewApplication.h" 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) { 6 | Ghurund::Settings settings; 7 | settings.parse(GetCommandLine()); 8 | Ghurund::main(&settings); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /apps/engine.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)engine\Engine\generated\reflection;$(SolutionDir)engine\Engine\src;$(SolutionDir)engine\Engine.UI\generated\reflection;$(SolutionDir)engine\Engine.UI\generated\bindings;$(SolutionDir)engine\Engine.UI\src;$(SolutionDir)engine\Engine.Core\src;$(IncludePath) 7 | $(SolutionDir)Debug;$(LibraryPath) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /apps/premake5.lua: -------------------------------------------------------------------------------- 1 | group "apps" 2 | 3 | include "Demo.UI" 4 | include "Editor" 5 | include "Messenger" 6 | include "Preview" 7 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Engine.Core.DirectX" 2 | kind "StaticLib" 3 | pchheader "ghcdxpch.h" 4 | pchsource "src/ghcdxpch.cpp" 5 | staticruntime "on" 6 | 7 | dependson { 8 | "Engine.Core" 9 | } 10 | 11 | files { 12 | "src/**.h", 13 | "src/**.cpp", 14 | } 15 | 16 | defines { "_CRT_SECURE_NO_WARNINGS" } 17 | 18 | includedirs { 19 | "src", 20 | includeDir["Engine.Core"], 21 | includeDir["DirectX"] 22 | } 23 | 24 | links { 25 | "Engine.Core" 26 | } 27 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/Ghurund.Core.DirectX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ghurund.Core.h" -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/DirectXTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/reflection/Type.h" 4 | #include "core/directx/buffer/DescriptorHeap.h" 5 | #include "core/directx/memory/GPUResourceFactory.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace Ghurund::Core { 11 | template<> 12 | const Type& getType(); 13 | 14 | template<> 15 | const Type& getType(); 16 | 17 | template<> 18 | const Type& getType(); 19 | 20 | template<> 21 | const Type& getType(); 22 | 23 | template<> 24 | const Type& getType(); 25 | } 26 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/Exceptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund { 6 | class DirectX12NotSupportedException:public std::exception {}; 7 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/MathTypes.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "MathTypes.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType<::DirectX::XMFLOAT2>() { 7 | static Type TYPE = Type("DirectX", "XMFLOAT2", sizeof(::DirectX::XMFLOAT2)); 8 | return TYPE; 9 | } 10 | 11 | template<> 12 | const Type& getType<::DirectX::XMFLOAT3>() { 13 | static Type TYPE = Type("DirectX", "XMFLOAT3", sizeof(::DirectX::XMFLOAT3)); 14 | return TYPE; 15 | } 16 | 17 | template<> 18 | const Type& getType<::DirectX::XMFLOAT4>() { 19 | static Type TYPE = Type("DirectX", "XMFLOAT4", sizeof(::DirectX::XMFLOAT4)); 20 | return TYPE; 21 | } 22 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/MathTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/reflection/Type.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | template<> 9 | const Type& getType<::DirectX::XMFLOAT2>(); 10 | 11 | template<> 12 | const Type& getType<::DirectX::XMFLOAT3>(); 13 | 14 | template<> 15 | const Type& getType<::DirectX::XMFLOAT4>(); 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/adapter/AdapterOutput.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "AdapterOutput.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::Core::DirectX { 7 | const Ghurund::Core::Type& AdapterOutput::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::DirectX::NAMESPACE_NAME, GH_STRINGIFY(AdapterOutput)) 9 | .withSupertype(Object::TYPE); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/adapter/DisplayMode.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "DisplayMode.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::Core::DirectX { 7 | const Ghurund::Core::Type& DisplayMode::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::DirectX::NAMESPACE_NAME, GH_STRINGIFY(DisplayMode)) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/adapter/GraphicsAdapter.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "GraphicsAdapter.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::Core::DirectX { 7 | const Ghurund::Core::Type& GraphicsAdapter::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::DirectX::NAMESPACE_NAME, GH_STRINGIFY(GraphicsAdapter)) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/buffer/DepthBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/directx/CommandList.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Ghurund::Core::DirectX { 10 | class DepthBuffer { 11 | private: 12 | ComPtr dsvHeap; 13 | ComPtr depthStencil; 14 | D3D12_CPU_DESCRIPTOR_HANDLE handle; 15 | 16 | public: 17 | Status init(Graphics& graphics, unsigned int width, unsigned int height); 18 | 19 | void clear(CommandList &commandList) { 20 | commandList.get()->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr); 21 | } 22 | 23 | inline D3D12_CPU_DESCRIPTOR_HANDLE &getHandle() { 24 | return handle; 25 | } 26 | 27 | __declspec(property(get = getHandle)) D3D12_CPU_DESCRIPTOR_HANDLE& Handle; 28 | }; 29 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/memory/GPUResourcePointer.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "GPUResourcePointer.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::Core::DirectX { 7 | const Ghurund::Core::Type& GPUResourcePointer::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::DirectX::NAMESPACE_NAME, GH_STRINGIFY(GPUResourcePointer)) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/memory/HeapAllocator.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "HeapAllocator.h" 3 | 4 | #include "core/directx/Graphics.h" 5 | #include "core/allocation/CircularBufferStrategy.h" 6 | #include "core/math/MathUtils.h" 7 | 8 | namespace Ghurund::Core::DirectX { 9 | HeapAllocator::HeapAllocator(Graphics& graphics, uint64_t size, AllocationStrategy* strategy, D3D12_HEAP_TYPE type, D3D12_HEAP_FLAGS flags) { 10 | this->strategy = strategy == nullptr ? ghnew CircularBufferStrategy() : strategy; 11 | this->strategy->init(size, 64_KB, 64_KB); 12 | CD3DX12_HEAP_DESC desc(this->strategy->Size, type, 0, flags); 13 | if (FAILED(graphics.Device->CreateHeap(&desc, IID_PPV_ARGS(&heap)))) 14 | Logger::log(LogType::ERR0R, _T("failed to create heap\n")); 15 | } 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/shader/CompilationTarget.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "CompilationTarget.h" 3 | 4 | namespace Ghurund::Core::DirectX { 5 | const CompilationTarget &CompilationTarget::SHADER_5_0 = CompilationTarget(0, "5_0"); 6 | const CompilationTarget &CompilationTarget::SHADER_4_1 = CompilationTarget(1, "4_1"); 7 | const CompilationTarget &CompilationTarget::SHADER_4_0 = CompilationTarget(2, "4_0"); 8 | const CompilationTarget &CompilationTarget::SHADER_4_0_LEVEL_9_3 = CompilationTarget(3, "4_0_level_9_3"); 9 | const CompilationTarget &CompilationTarget::SHADER_4_0_LEVEL_9_1 = CompilationTarget(4, "4_0_level_9_1"); 10 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/shader/ConstantBufferField.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | 5 | namespace Ghurund::Core::DirectX { 6 | struct ConstantBufferField { 7 | AString name; 8 | size_t size, offset; 9 | 10 | ConstantBufferField(const AString& name, size_t size, size_t offset) { 11 | this->name = name; 12 | this->size = size; 13 | this->offset = offset; 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/shader/ShaderType.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" 2 | #include "ShaderType.h" 3 | 4 | namespace Ghurund::Core::DirectX { 5 | const ShaderType &ShaderType::VS = ShaderType(1, "vs", "vertexMain", D3D12_SHADER_VISIBILITY_VERTEX); 6 | const ShaderType &ShaderType::PS = ShaderType(2, "ps", "pixelMain", D3D12_SHADER_VISIBILITY_PIXEL); 7 | const ShaderType &ShaderType::GS = ShaderType(4, "gs", "geometryMain", D3D12_SHADER_VISIBILITY_GEOMETRY); 8 | const ShaderType &ShaderType::HS = ShaderType(8, "hs", "hullMain", D3D12_SHADER_VISIBILITY_HULL); 9 | const ShaderType &ShaderType::DS = ShaderType(16, "ds", "domainMain", D3D12_SHADER_VISIBILITY_DOMAIN); 10 | const ShaderType &ShaderType::CS = ShaderType(32, "cs", "computeMain", D3D12_SHADER_VISIBILITY_ALL); 11 | 12 | const ShaderType ShaderType::values[] = {ShaderType::VS, ShaderType::PS, ShaderType::GS, ShaderType::HS, ShaderType::DS, ShaderType::CS}; 13 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/shader/TextureBufferConstant.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShaderConstant.h" 4 | 5 | namespace Ghurund::Core::DirectX { 6 | class TextureBufferConstant:public ShaderConstant { 7 | public: 8 | TextureBufferConstant(ID3D12ShaderReflectionConstantBuffer *constantBuffer, D3D12_SHADER_BUFFER_DESC &bufferDesc, unsigned int bindPoint, D3D12_SHADER_VISIBILITY visibility) 9 | :ShaderConstant(bufferDesc.Name, bindPoint, visibility) {} 10 | }; 11 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/core/directx/shader/TextureConstant.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ShaderConstant.h" 4 | 5 | namespace Ghurund::Core::DirectX { 6 | class TextureConstant:public ShaderConstant { 7 | public: 8 | TextureConstant(const char *name, unsigned int bindPoint, D3D12_SHADER_VISIBILITY visibility):ShaderConstant(name, bindPoint, visibility) {} 9 | }; 10 | } -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/ghcdxpch.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcdxpch.h" -------------------------------------------------------------------------------- /engine/Engine.Core.DirectX/src/ghcdxpch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace Ghurund::Core::DirectX { 8 | inline static const char* NAMESPACE_NAME = GH_STRINGIFY(Ghurund::Core::DirectX); 9 | } -------------------------------------------------------------------------------- /engine/Engine.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /engine/Engine.Core/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Engine.Core" 2 | kind "StaticLib" 3 | pchheader "ghcpch.h" 4 | pchsource "src/ghcpch.cpp" 5 | staticruntime "on" 6 | 7 | files { 8 | "src/**.h", 9 | "src/**.cpp", 10 | } 11 | 12 | defines { "_CRT_SECURE_NO_WARNINGS" } 13 | 14 | includedirs { 15 | "src", 16 | includeDir["tinyxml2"] 17 | } 18 | 19 | filter "configurations:Debug" 20 | links { 21 | library["tinyxml2_Debug"] 22 | } 23 | 24 | filter "configurations:Release" 25 | links { 26 | library["tinyxml2_Release"] 27 | } 28 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/Status.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | enum class Status { 5 | OK, INV_PARAM, INV_STATE, INV_DATA, CALL_FAIL, IO, NOT_IMPLEMENTED, ALREADY_LOADED, UNKNOWN, 6 | 7 | UNKNOWN_TYPE, MISSING_ALLOCATOR, MISSING_CONSTRUCTOR, 8 | 9 | WRONG_RESOURCE_VERSION, 10 | WRONG_RESOURCE_TYPE, 11 | LOADER_MISSING, 12 | FILE_DOESNT_EXIST, 13 | FILE_EXISTS, 14 | UNKNOWN_FORMAT, 15 | INV_FORMAT, 16 | UNEXPECTED_EOF, 17 | NOT_SUPPORTED, 18 | 19 | ENTRY_POINT_NOT_FOUND, 20 | COMPILATION_ERROR, 21 | SCRIPT_EXCEPTION, 22 | 23 | DIRECTX12_NOT_SUPPORTED, 24 | DEVICE_LOST, 25 | 26 | SOCKET, 27 | INV_PACKET, 28 | CONNECTION_REJECTED, 29 | DISCONNECTED 30 | }; 31 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Concepts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ghurund::Core { 7 | template 8 | concept Derived = std::is_base_of::value; 9 | 10 | template 11 | concept Qualified = std::is_const_v || std::is_pointer_v || std::is_reference_v || std::is_volatile_v; 12 | 13 | template 14 | concept Iterable = requires(CollectionType collection) { 15 | { collection.begin() } -> std::forward_iterator; 16 | { collection.end() } -> std::forward_iterator; 17 | }; 18 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/DataParsing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | 5 | namespace Ghurund::Core { 6 | template 7 | inline Result parse(const AString& text) { 8 | return Result::parse(text); 9 | } 10 | 11 | template<> 12 | inline uint32_t parse(const AString& text) { 13 | return atoi(text.Data); 14 | } 15 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Exceptions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | class CallFailedException:public std::exception { 7 | public: 8 | CallFailedException(const char* message = nullptr):std::exception(message) {} 9 | }; 10 | 11 | class NotImplementedException:public std::exception {}; 12 | 13 | class InvalidDataException:public std::exception { 14 | public: 15 | InvalidDataException(const char* message = nullptr):std::exception(message) {} 16 | }; 17 | 18 | class InvalidStateException:public std::exception { 19 | public: 20 | InvalidStateException(const char* message = nullptr):std::exception(message) {} 21 | }; 22 | 23 | class InvalidParamException:public std::exception { 24 | public: 25 | InvalidParamException(const char* message = nullptr):std::exception(message) {} 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Hashing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | 7 | inline uint32_t hashCode(const void* data, size_t size) { 8 | uint32_t h = 0xAAAAAAAA; 9 | const uint8_t* str = (const uint8_t*)data; 10 | for (size_t i = 0; i < size; i++) { 11 | h ^= ((i & 1) == 0) ? ((h << 7) ^ str[i] * (h >> 3)) : 12 | (~((h << 11) + str[i] ^ (h >> 5))); 13 | } 14 | return h; 15 | } 16 | 17 | template 18 | inline uint32_t hashCode(const Type& data) { 19 | size_t size = sizeof(Type); 20 | return hashCode(&data, size); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Id.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | typedef uint32_t id_t; 7 | 8 | template class IdObject { 9 | private: 10 | inline static std::atomic CURRENT_ID = 0; 11 | 12 | id_t id = CURRENT_ID++; 13 | 14 | public: 15 | virtual ~IdObject() = default; 16 | 17 | id_t getId() const { 18 | return id; 19 | } 20 | 21 | __declspec(property(get = getId)) id_t Id; 22 | }; 23 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/NamedObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | 5 | namespace Ghurund::Core { 6 | template 7 | class NamedObject { 8 | private: 9 | GenericString name; 10 | 11 | public: 12 | NamedObject() {} 13 | 14 | NamedObject(const GenericString& name):name(name) {} 15 | 16 | virtual ~NamedObject() = 0 {}; 17 | 18 | virtual void setName(const GenericString& name) { 19 | this->name = name; 20 | } 21 | 22 | virtual const GenericString& getName() const { 23 | return name; 24 | } 25 | 26 | __declspec(property(get = getName, put = setName)) const GenericString& Name; 27 | 28 | bool operator==(const NamedObject& other) const { 29 | return Name == other.Name; 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Noncopyable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | class Noncopyable { 5 | public: 6 | Noncopyable() = default; 7 | Noncopyable(const Noncopyable&) = delete; 8 | 9 | virtual ~Noncopyable() = default; 10 | 11 | Noncopyable& operator=(const Noncopyable&) = delete; 12 | }; 13 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Object.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "Object.h" 3 | 4 | #include "core/logging/Formatter.h" 5 | #include "core/reflection/TypeBuilder.h" 6 | 7 | #include 8 | 9 | namespace Ghurund::Core { 10 | const Ghurund::Core::Type& Object::GET_TYPE() { 11 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::NAMESPACE_NAME, GH_STRINGIFY(Object)) 12 | .withModifiers(TypeModifier::ABSTRACT); 13 | 14 | return TYPE; 15 | } 16 | 17 | String Object::toString() const { 18 | return String(std::format(_T("{}::{}"), Type.Namespace, _T("::"), Type.Name).c_str()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/Translations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ghurund::Core { 7 | class Translations { 8 | private: 9 | Map> translations; 10 | 11 | public: 12 | 13 | }; 14 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/TypeWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | template 5 | class TypeWrapper { 6 | private: 7 | T value; 8 | 9 | public: 10 | TypeWrapper(T&& value): value(std::move(value)) {} 11 | 12 | explicit TypeWrapper(const T& value): value(value) {} 13 | 14 | inline T& getValue() { 15 | return value; 16 | } 17 | 18 | inline const T& getValue() const { 19 | return value; 20 | } 21 | 22 | inline void setValue(const T& value) { 23 | this->value = value; 24 | } 25 | 26 | __declspec(property(get = getValue, put = setValue)) T& Value; 27 | 28 | inline operator const T& () const { 29 | return value; 30 | } 31 | 32 | inline operator T& () { 33 | return value; 34 | } 35 | 36 | inline TypeWrapper& operator=(const T& value) { 37 | this->value = value; 38 | return *this; 39 | } 40 | 41 | inline bool operator==(const TypeWrapper& other) const { 42 | return other.value == value; 43 | } 44 | }; 45 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/allocation/Allocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | template 7 | __interface Allocator { 8 | void* allocate(T size); 9 | void deallocate(void*); 10 | bool canAllocate(T size) const; 11 | }; 12 | 13 | template 14 | struct Allocation { 15 | T size; 16 | T address; 17 | }; 18 | 19 | class IncompatibleAllocatorsException:public std::exception { 20 | public: 21 | IncompatibleAllocatorsException(const char* message = nullptr):std::exception(message) {} 22 | }; 23 | } 24 | 25 | template 26 | inline void* operator new(size_t size, Ghurund::Core::Allocator& allocator) { 27 | return allocator.allocate(size); 28 | } 29 | 30 | template 31 | inline void operator delete(void* ptr, Ghurund::Core::Allocator& allocator) { 32 | allocator.deallocate(ptr); 33 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/application/Feature.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "Feature.h" 3 | 4 | namespace Ghurund::Core { 5 | inline const Ghurund::Core::Type& Feature::GET_TYPE() { 6 | 7 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::Core::NAMESPACE_NAME, "Feature") 8 | .withModifier(TypeModifier::ABSTRACT) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/application/Settings.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "Settings.h" 3 | 4 | #include "core/string/TextConversionUtils.h" 5 | 6 | namespace Ghurund::Core { 7 | void Settings::parse(const String& settings) { 8 | AString aSettings = convertText(settings); 9 | Array commands = aSettings.split(" "); 10 | for (size_t i = 0; i < commands.Size; i++) { 11 | Array keyVal = commands[i].split("="); 12 | if (keyVal.Size != 2) 13 | continue; 14 | if (allowed.containsKey(keyVal[0])) 15 | values.set(keyVal[0], keyVal[1]); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/application/WindowCloseAction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | enum class WindowCloseAction { 5 | HIDE, DESTROY, NOTHING 6 | }; 7 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/input/Input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Mouse.h" 4 | #include "core/collection/List.h" 5 | #include "Keyboard.h" 6 | #include "EventConsumer.h" 7 | #include "core/window/WindowMessage.h" 8 | 9 | namespace Ghurund::Core { 10 | 11 | class Input { 12 | private: 13 | POINT prevMousePos; 14 | IntPoint mousePos; 15 | bool keys[256]; 16 | List events; 17 | 18 | public: 19 | Input() { 20 | memset(keys, 0, sizeof(bool) * 256); 21 | } 22 | 23 | inline void addEvent(const WindowMessage& msg) { 24 | events.add(msg); 25 | } 26 | 27 | void dispatchEvents(uint64_t time, EventConsumer& consumer); 28 | 29 | inline bool isShiftDown() { 30 | return keys[VK_SHIFT]; 31 | } 32 | 33 | inline bool isControlDown() { 34 | return keys[VK_CONTROL]; 35 | } 36 | }; 37 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/input/InputEventArgs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | 7 | class InputEventArgs { 8 | protected: 9 | uint64_t time; 10 | 11 | public: 12 | InputEventArgs(uint64_t time) { 13 | this->time = time; 14 | } 15 | 16 | inline uint64_t getTimeMs() const { 17 | return time; 18 | } 19 | 20 | __declspec(property(get = getTimeMs)) uint64_t TimeMs; 21 | 22 | virtual ~InputEventArgs() = 0 {} 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/input/Keyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputEventArgs.h" 4 | 5 | namespace Ghurund::Core { 6 | enum class KeyAction { 7 | DOWN, UP, CHAR 8 | }; 9 | 10 | class KeyEventArgs:public InputEventArgs { 11 | private: 12 | KeyAction action; 13 | int key; 14 | 15 | public: 16 | KeyEventArgs(KeyAction action, int key, uint64_t time):InputEventArgs(time) { 17 | this->action = action; 18 | this->key = key; 19 | } 20 | 21 | KeyAction getAction() const { 22 | return action; 23 | } 24 | 25 | __declspec(property(get = getAction)) KeyAction Action; 26 | 27 | int getKey() const { 28 | return key; 29 | } 30 | 31 | __declspec(property(get = getKey)) int Key; 32 | }; 33 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/DirectoryLibrary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DirectoryPath.h" 4 | #include "Library.h" 5 | 6 | namespace Ghurund::Core { 7 | /* 8 | * a file folder with resources 9 | */ 10 | class DirectoryLibrary:public Library { 11 | private: 12 | DirectoryPath path; 13 | 14 | public: 15 | DirectoryLibrary(const WString& name, const DirectoryPath& path):Library(name), path(path) {} 16 | 17 | const DirectoryPath& getPath() const { 18 | return path; 19 | } 20 | 21 | __declspec(property(get = getPath)) DirectoryPath& Path; 22 | 23 | virtual bool contains(const FilePath& path) { 24 | return File(this->path / path).Exists; 25 | } 26 | 27 | virtual File* getFile(const FilePath& path) { 28 | return ghnew File(this->path / path); 29 | } 30 | 31 | virtual File* getFile(const size_t index) { 32 | return nullptr; 33 | } 34 | 35 | virtual size_t getFileCount() const { 36 | return 0; 37 | } 38 | }; 39 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/File.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "File.h" 3 | 4 | namespace Ghurund::Core { 5 | bool File::exists() const { 6 | DWORD attributes = GetFileAttributesW(path.toString().Data); 7 | 8 | return (attributes != INVALID_FILE_ATTRIBUTES && 9 | !(attributes & FILE_ATTRIBUTE_DIRECTORY)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/FileLibrary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Library.h" 4 | 5 | namespace Ghurund::Core { 6 | /* 7 | * stored in a file 8 | */ 9 | class FileLibrary:public Library { 10 | private: 11 | FilePath path; 12 | 13 | public: 14 | FileLibrary(const WString& name, const FilePath& path):Library(name), path(path) {} 15 | 16 | const FilePath& getPath() const { 17 | return path; 18 | } 19 | 20 | __declspec(property(get = getPath)) FilePath& Path; 21 | 22 | virtual bool contains(const FilePath& path) { 23 | return false; 24 | } 25 | 26 | virtual File* getFile(const FilePath& name) override { 27 | return nullptr; 28 | } 29 | 30 | virtual File* getFile(const size_t index) override { 31 | return nullptr; 32 | } 33 | 34 | virtual size_t getFileCount() const override { 35 | return 0; 36 | } 37 | }; 38 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/FileUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Status.h" 4 | 5 | namespace Ghurund::Core { 6 | Status readFile(const wchar_t * name, void *& data, size_t & size); 7 | 8 | Status writeFile(const wchar_t * name, void * data, size_t size); 9 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/Library.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | #include "core/io/FilePath.h" 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | class Library { 9 | private: 10 | WString name; 11 | 12 | public: 13 | Library(const WString& name):name(name) {} 14 | 15 | virtual ~Library() = 0 {} 16 | 17 | const WString& getName() const { 18 | return name; 19 | } 20 | 21 | __declspec(property(get = getName)) WString& Name; 22 | 23 | virtual bool contains(const FilePath& path) = 0; 24 | 25 | virtual File* getFile(const FilePath& path) = 0; 26 | 27 | virtual File* getFile(const size_t index) = 0; 28 | 29 | virtual size_t getFileCount() const = 0; 30 | 31 | __declspec(property(get = getFileCount)) size_t FileCount; 32 | }; 33 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/watcher/FileChange.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "FileChange.h" 3 | 4 | namespace Ghurund::Core { 5 | 6 | const FileChange& FileChange::ADDED = FileChange(FileChangeEnum::ADDED, "added"); 7 | const FileChange& FileChange::REMOVED = FileChange(FileChangeEnum::REMOVED, "removed"); 8 | const FileChange& FileChange::MODIFIED = FileChange(FileChangeEnum::MODIFIED, "modified"); 9 | const FileChange& FileChange::RENAMED_FROM = FileChange(FileChangeEnum::RENAMED_FROM, "renamed from"); 10 | const FileChange& FileChange::RENAMED_TO = FileChange(FileChangeEnum::RENAMED_TO, "renamed to"); 11 | 12 | const EnumValues FileChange::VALUES = { 13 | &FileChange::ADDED, 14 | &FileChange::REMOVED, 15 | &FileChange::MODIFIED, 16 | &FileChange::RENAMED_FROM, 17 | &FileChange::RENAMED_TO 18 | }; 19 | 20 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/io/watcher/FileChange.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/Enum.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | enum class FileChangeEnum { 9 | ADDED = FILE_ACTION_ADDED, 10 | REMOVED = FILE_ACTION_REMOVED, 11 | MODIFIED = FILE_ACTION_MODIFIED, 12 | RENAMED_FROM = FILE_ACTION_RENAMED_OLD_NAME, 13 | RENAMED_TO = FILE_ACTION_RENAMED_NEW_NAME, 14 | }; 15 | 16 | class FileChange:public Enum { 17 | public: 18 | static const FileChange& ADDED, & REMOVED, & MODIFIED, & RENAMED_FROM, & RENAMED_TO; 19 | 20 | static const EnumValues VALUES; 21 | 22 | FileChange(FileChangeEnum value, const char* name):Enum(value, name) {} 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/logging/Log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ghurund::Core { 7 | struct Log { 8 | const LogType& type = LogType::INFO; 9 | String fileLine, message; 10 | }; 11 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/logging/LogType.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "LogType.h" 3 | 4 | namespace Ghurund::Core { 5 | const LogType LogType::INFO = LogType(LogTypeEnum::INFO, "INFO", 0xffffffff, 7); 6 | const LogType LogType::WARNING = LogType(LogTypeEnum::WARNING, "WARNING", 0xffffff7f, 6); 7 | const LogType LogType::ERR0R = LogType(LogTypeEnum::ERR0R, "ERROR", 0xffff0000, 4); 8 | 9 | const EnumValues LogType::VALUES = { 10 | &LogType::INFO, 11 | &LogType::WARNING, 12 | &LogType::ERR0R 13 | }; 14 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/logging/LogType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/Enum.h" 4 | 5 | namespace Ghurund::Core { 6 | enum class LogTypeEnum { 7 | INFO, WARNING, ERR0R 8 | }; 9 | 10 | class LogType: public Enum { 11 | private: 12 | uint32_t color, styleCode; 13 | 14 | LogType(LogTypeEnum value, const char* name, uint32_t color, uint32_t styleCode):Enum(value, name), color(color), styleCode(styleCode) {} 15 | 16 | public: 17 | static const LogType INFO, WARNING, ERR0R; 18 | 19 | static const EnumValues VALUES; 20 | 21 | inline uint32_t getColor() const { 22 | return color; 23 | } 24 | 25 | __declspec(property(get = getColor)) uint32_t Color; 26 | 27 | inline uint32_t getStyleCode() const { 28 | return styleCode; 29 | } 30 | 31 | __declspec(property(get = getStyleCode)) uint32_t StyleCode; 32 | }; 33 | 34 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/math/Matrix3x2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | struct Matrix3x2 { 5 | union { 6 | struct { 7 | float m11, m12, m21, m22, dx, dy; 8 | }; 9 | 10 | float m[3][2]; 11 | }; 12 | 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/math/Point.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | #include "core/reflection/Type.h" 5 | 6 | #include 7 | 8 | namespace Ghurund::Core { 9 | struct IntPoint { 10 | int32_t x, y; 11 | 12 | auto operator<=>(const IntPoint& other) const = default; 13 | }; 14 | 15 | struct FloatPoint { 16 | float x, y; 17 | 18 | auto operator<=>(const FloatPoint& other) const = default; 19 | }; 20 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/math/Rect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | struct FloatRect { 5 | float left, top, right, bottom; 6 | 7 | inline float getWidth() const { 8 | return right - left; 9 | } 10 | 11 | __declspec(property(get = getWidth)) float Width; 12 | 13 | inline float getHeight() const { 14 | return bottom - top; 15 | } 16 | 17 | __declspec(property(get = getHeight)) float Height; 18 | }; 19 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/BaseTypedProperty.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BaseProperty.h" 4 | #include "Type.h" 5 | 6 | namespace Ghurund::Core { 7 | template 8 | class BaseTypedProperty:public BaseProperty { 9 | public: 10 | BaseTypedProperty( 11 | const AString& name, 12 | const AString& group = DEFAULT_GROUP 13 | ):BaseProperty( 14 | Ghurund::Core::getType::type>::type>(), 15 | std::is_pointer_v, 16 | name, 17 | group 18 | ) {} 19 | 20 | virtual const Ghurund::Core::Type& getOwnerType() const override { 21 | return Ghurund::Core::getType(); 22 | } 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/Constructor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | #include "core/allocation/Allocator.h" 6 | 7 | namespace Ghurund::Core { 8 | __interface BaseConstructor {}; 9 | 10 | template 11 | class BaseTypeConstructor:public BaseConstructor {}; 12 | 13 | template 14 | class Constructor:public BaseTypeConstructor { 15 | public: 16 | T* invoke(ArgsT... args) const { 17 | return ghnew T(args...); 18 | } 19 | 20 | T* invoke(Allocator& allocator, ArgsT... args) const { 21 | return new (allocator)T(args...); 22 | } 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/OperationNotSupportedException.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | class OperationNotSupportedException:public std::exception { 7 | public: 8 | OperationNotSupportedException(const char* message = nullptr):std::exception(message) {} 9 | }; 10 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/Parameter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | class Type; 5 | 6 | class Parameter2 { 7 | private: 8 | Type& type; 9 | 10 | public: 11 | }; 12 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/StandardTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Type.h" 4 | #include "core/Buffer.h" 5 | #include "core/math/Point.h" 6 | #include "core/math/Size.h" 7 | #include "core/math/Matrix3x2.h" 8 | #include "core/string/String.h" 9 | 10 | namespace Ghurund::Core { 11 | template<> 12 | const Type& getType(); 13 | 14 | template<> 15 | const Type& getType(); 16 | 17 | template<> 18 | const Type& getType(); 19 | 20 | template<> 21 | const Type& getType(); 22 | 23 | template<> 24 | const Type& getType(); 25 | 26 | template<> 27 | const Type& getType(); 28 | 29 | template<> 30 | const Type& getType(); 31 | 32 | template<> 33 | const Type& getType(); 34 | 35 | template<> 36 | const Type& getType(); 37 | 38 | template<> 39 | const Type& getType(); 40 | 41 | template<> 42 | const Type& getType(); 43 | 44 | template<> 45 | const Type& getType(); 46 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/TypeModifier.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "TypeModifier.h" 3 | 4 | namespace Ghurund::Core { 5 | TypeModifier operator |(TypeModifier lhs, TypeModifier rhs) { 6 | return (TypeModifier)((std::underlying_type_t)lhs | (std::underlying_type_t)rhs); 7 | } 8 | 9 | TypeModifier& operator |=(TypeModifier& lhs, TypeModifier rhs) { 10 | return lhs = (TypeModifier)((std::underlying_type_t)lhs | (std::underlying_type_t)rhs); 11 | } 12 | 13 | bool operator &(TypeModifier lhs, TypeModifier rhs) { 14 | return (std::underlying_type_t)lhs & (std::underlying_type_t)rhs; 15 | } 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/reflection/TypeModifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | enum class TypeModifier { 5 | ABSTRACT = 1, TEMPLATE = 2 6 | }; 7 | 8 | TypeModifier operator |(TypeModifier lhs, TypeModifier rhs); 9 | 10 | TypeModifier& operator |=(TypeModifier& lhs, TypeModifier rhs); 11 | 12 | bool operator &(TypeModifier lhs, TypeModifier rhs); 13 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/resource/ReloadTask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Resource.h" 4 | 5 | namespace Ghurund::Core { 6 | class ReloadTask { 7 | private: 8 | ResourceManager& resourceManager; 9 | Loader& loader; 10 | Resource& resource; 11 | LoadOption loadOption; 12 | 13 | public: 14 | ReloadTask(ResourceManager& resourceManager, Loader& loader, Resource& resource, LoadOption loadOption) 15 | :resourceManager(resourceManager), loader(loader), resource(resource), loadOption(loadOption) {} 16 | 17 | Resource& getResource() { 18 | return resource; 19 | } 20 | 21 | __declspec(property(get = getResource)) Resource& Resource; 22 | 23 | void execute() { 24 | //loader.load(resourceManager, stream, resource, loadOption); 25 | } 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/resource/TextLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Loader.h" 4 | #include "TextResource.h" 5 | #include "core/Exceptions.h" 6 | 7 | namespace Ghurund::Core { 8 | class TextLoader:public Loader { 9 | public: 10 | virtual Resource* load( 11 | Ghurund::Core::ResourceManager& manager, 12 | MemoryInputStream& stream, 13 | const ResourceFormat* format = nullptr, 14 | LoadOption options = LoadOption::DEFAULT 15 | ) override { 16 | TextResource* textResource = ghnew TextResource(); 17 | textResource->Text = stream.readASCII(); 18 | return textResource; 19 | } 20 | 21 | virtual void save( 22 | Ghurund::Core::ResourceManager& manager, 23 | MemoryOutputStream& stream, 24 | Resource& resource, 25 | const ResourceFormat* format = nullptr, 26 | SaveOption options = SaveOption::DEFAULT 27 | ) const override { 28 | throw NotImplementedException(); 29 | } 30 | }; 31 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/resource/TextResource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Resource.h" 4 | 5 | namespace Ghurund::Core { 6 | class TextResource:public Resource { 7 | private: 8 | AString text; 9 | 10 | public: 11 | inline AString& getText() { 12 | return text; 13 | } 14 | 15 | inline void setText(const AString& text) { 16 | this->text = text; 17 | } 18 | 19 | __declspec(property(get = getText, put = setText)) AString& Text; 20 | }; 21 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/string/FixedString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | template 7 | struct FixedString { 8 | char elems[N]; 9 | 10 | constexpr FixedString(char const (&s)[N]) { 11 | std::copy_n(s, N, elems); 12 | } 13 | 14 | constexpr std::strong_ordering operator<=>(FixedString const&) const = default; 15 | }; 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/string/GenericString.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "GenericString.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | uint32_t hashCode(const GenericString& data) { 7 | return hashCode(data.Data, sizeof(char) * data.Length); 8 | } 9 | 10 | template<> 11 | uint32_t hashCode(const GenericString& data) { 12 | return hashCode(data.Data, sizeof(wchar_t) * data.Length); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/string/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GenericString.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | 9 | #ifdef UNICODE 10 | typedef GenericString String; 11 | #else 12 | typedef GenericString String; 13 | #endif 14 | 15 | typedef GenericString WString; 16 | typedef GenericString AString; 17 | typedef GenericString TString; 18 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/string/StringView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GenericStringView.h" 4 | 5 | namespace Ghurund::Core { 6 | 7 | #ifdef UNICODE 8 | typedef GenericStringView StringView; 9 | #else 10 | typedef GenericStringView StringView; 11 | #endif 12 | 13 | typedef GenericStringView WStringView; 14 | typedef GenericStringView AStringView; 15 | typedef GenericStringView TStringView; 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/APCThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Thread.h" 4 | 5 | namespace Ghurund::Core { 6 | class APCThread:public Thread { 7 | private: 8 | static void CALLBACK wake(__in ULONG_PTR arg) {} 9 | 10 | bool running = false; 11 | 12 | public: 13 | virtual ~APCThread() { 14 | if (running) 15 | finish(); 16 | } 17 | 18 | void post(PAPCFUNC apc, ULONG_PTR data) { 19 | QueueUserAPC(apc, Handle, data); 20 | } 21 | 22 | void run() { 23 | running = true; 24 | while (running) 25 | ::SleepEx(INFINITE, true); 26 | } 27 | 28 | virtual void finish() override { 29 | running = false; 30 | post(&wake, 0); 31 | __super::finish(); 32 | } 33 | }; 34 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/ConditionVariable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CriticalSection.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | class ConditionVariable { 9 | private: 10 | CONDITION_VARIABLE variable; 11 | 12 | public: 13 | ConditionVariable() { 14 | InitializeConditionVariable(&variable); 15 | } 16 | 17 | ConditionVariable(ConditionVariable& other) = delete; 18 | 19 | inline void wait(CriticalSection& section) { 20 | SleepConditionVariableCS(&variable, §ion, INFINITE); 21 | } 22 | 23 | inline void notify() { 24 | WakeConditionVariable(&variable); 25 | } 26 | 27 | inline void notifyAll() { 28 | WakeAllConditionVariable(&variable); 29 | } 30 | }; 31 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/FunctionQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "FunctionQueue.h" 3 | 4 | #include "core/logging/Formatter.h" 5 | #include "core/logging/Logger.h" 6 | 7 | namespace Ghurund::Core { 8 | void FunctionQueue::post(std::function function) { 9 | if (function == nullptr) { 10 | Logger::log(LogType::WARNING, _T("Empty function posted to function queue\n")); 11 | return; 12 | } 13 | section.enter(); 14 | queue.push(function); 15 | section.leave(); 16 | } 17 | 18 | void FunctionQueue::invoke() { 19 | section.enter(); 20 | std::queue> copy = queue; 21 | while (!queue.empty()) 22 | queue.pop(); 23 | section.leave(); 24 | 25 | while (!copy.empty()) { 26 | std::function function = copy.front(); 27 | function(); 28 | copy.pop(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/FunctionQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/threading/CriticalSection.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::Core { 8 | class FunctionQueue { 9 | private: 10 | std::queue> queue; 11 | CriticalSection section; 12 | 13 | public: 14 | void post(std::function function); 15 | 16 | void invoke(); 17 | }; 18 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/Task.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "Task.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::Core { 7 | const Ghurund::Core::Type& Task::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(Task)) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/Waitable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | class Waitable { 7 | private: 8 | HANDLE event; 9 | 10 | public: 11 | Waitable() { 12 | event = CreateEventW(nullptr, false, false, nullptr); 13 | } 14 | 15 | ~Waitable() { 16 | CloseHandle(event); 17 | } 18 | 19 | inline void wait(DWORD ms = INFINITE) { 20 | WaitForSingleObjectEx(event, ms, true); 21 | } 22 | 23 | inline void notify() { 24 | SetEvent(event); 25 | } 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/threading/WorkerThread.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "WorkerThread.h" 3 | 4 | #include "core/logging/Logger.h" 5 | 6 | namespace Ghurund::Core { 7 | void WorkerThread::run() { 8 | running.test_and_set(); 9 | while (true) { 10 | waitable.wait(); 11 | busy.test_and_set(); 12 | while (true) { 13 | if (!running.test()) 14 | return; 15 | section.enter(); 16 | if (queue.Empty) 17 | break; 18 | SharedPointer task = queue.front(); 19 | queue.remove(); 20 | section.leave(); 21 | Logger::print(LogType::INFO, _T("executing task '{}' on thread '{}'\n"), task->Name, Name); 22 | task->run(); 23 | Logger::print(LogType::INFO, _T("finished task '{}' on thread '{}'\n"), task->Name, Name); 24 | } 25 | busy.clear(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/DragDropManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/IUnknownImpl.h" 4 | #include "core/collection/List.h" 5 | #include "core/io/FilePath.h" 6 | 7 | namespace Ghurund::Core { 8 | class SystemWindow; 9 | 10 | class DECLSPEC_UUID("796c4f9e-698f-42d4-ae90-3a9c4cb79b99") DragDropManager: public ComBase> { 11 | private: 12 | SystemWindow& window; 13 | 14 | Array* getFiles(IDataObject * pDataObj); 15 | 16 | public: 17 | DragDropManager(SystemWindow& window):window(window) { 18 | AddRef(); 19 | } 20 | 21 | virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) override; 22 | 23 | virtual HRESULT STDMETHODCALLTYPE DragLeave() override; 24 | 25 | virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) override; 26 | 27 | virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) override; 28 | }; 29 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/Window.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" 2 | #include "Window.h" 3 | #include "core/reflection/TypeBuilder.h" 4 | 5 | namespace Ghurund::Core { 6 | /*using namespace DirectX; 7 | 8 | void Window::updateParameters() { 9 | XMFLOAT2 sizeParam = { (float)size.width, (float)size.height }; 10 | parameterViewportSize->setValue(&sizeParam); 11 | }*/ 12 | 13 | const Ghurund::Core::Type& Window::GET_TYPE() { 14 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(Window)) 15 | .withModifiers(TypeModifier::ABSTRACT) 16 | .withSupertype(__super::GET_TYPE()); 17 | 18 | return TYPE; 19 | } 20 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/WindowClass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/Object.h" 4 | #include "core/string/String.h" 5 | #include "core/window/WindowStyle.h" 6 | #include "core/window/WindowProc.h" 7 | 8 | namespace Ghurund::Core { 9 | class WindowClass { 10 | private: 11 | String className; 12 | WNDCLASSEX windowClass; 13 | DWORD exStyle, dwStyle; 14 | 15 | WindowClass(const WindowClass& other) = delete; 16 | 17 | public: 18 | WindowClass(WindowStyle style, WNDPROC windowProc = &windowProc, const tchar* className = nullptr); 19 | 20 | ~WindowClass(){ 21 | UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); 22 | } 23 | 24 | HWND create() const; 25 | 26 | inline DWORD getStyle() const { 27 | return dwStyle; 28 | } 29 | 30 | __declspec(property(get = getStyle)) DWORD Style; 31 | }; 32 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/WindowManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/window/WindowClass.h" 4 | #include "core/window/WindowStyle.h" 5 | #include "core/collection/Map.h" 6 | 7 | namespace Ghurund::Core { 8 | class WindowManager { 9 | public: 10 | virtual HWND makeWindow(WindowStyle style) = 0; 11 | }; 12 | 13 | class SystemWindowManager:public WindowManager { 14 | private: 15 | Map classes; 16 | 17 | public: 18 | ~SystemWindowManager() { 19 | for (auto& [windowStyle, windowClass] : classes) 20 | delete windowClass; 21 | } 22 | 23 | virtual HWND makeWindow(WindowStyle style) override { 24 | WindowClass* windowClass; 25 | if (classes.containsKey(style)) { 26 | windowClass = classes.get(style); 27 | } else { 28 | windowClass = ghnew WindowClass(style); 29 | classes.set(style, windowClass); 30 | } 31 | return windowClass->create(); 32 | } 33 | }; 34 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/WindowMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::Core { 6 | struct WindowMessage { 7 | unsigned int code; 8 | WPARAM wParam; 9 | uint64_t time; 10 | POINT mousePos; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/WindowProc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Window.h" 4 | 5 | namespace Ghurund::Core { 6 | class SystemWindow; 7 | 8 | struct WindowData { 9 | SystemWindow* window; 10 | bool mouseTracked = false; 11 | 12 | WindowData(SystemWindow* w):window(w) {} 13 | }; 14 | 15 | LRESULT CALLBACK windowProc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam); 16 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/core/window/WindowStyle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::Core { 4 | enum class WindowBorderStyle { 5 | RESIZE, THIN, NONE 6 | }; 7 | 8 | struct WindowStyle { 9 | bool hasMinimizeButton = false; 10 | bool hasMaximizeButton = false; 11 | bool hasTitle = false; 12 | WindowBorderStyle borderStyle = WindowBorderStyle::NONE; 13 | bool showOnTaskbar = false; 14 | bool hasShadow = false; 15 | 16 | auto operator<=>(const WindowStyle& other) const = default; 17 | }; 18 | } -------------------------------------------------------------------------------- /engine/Engine.Core/src/ghcpch.cpp: -------------------------------------------------------------------------------- 1 | #include "ghcpch.h" -------------------------------------------------------------------------------- /engine/Engine.Core/src/ghcpch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #undef min 12 | #undef max 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Engine.UI.Direct2D" 2 | kind "StaticLib" 3 | pchheader "ghuidxpch.h" 4 | pchsource "src/ghuidxpch.cpp" 5 | staticruntime "on" 6 | 7 | dependson { 8 | "Engine.Core", 9 | "Engine.UI" 10 | } 11 | 12 | files { 13 | "src/**.h", 14 | "src/**.cpp" 15 | } 16 | 17 | includedirs { 18 | "src", 19 | includeDir["Engine.Core"], 20 | includeDir["Engine.UI"], 21 | includeDir["tinyxml2"] 22 | } 23 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/Ghurund.UI.Direct2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ghurund.UI.h" 4 | 5 | #pragma comment(lib, "Kernel32.lib") 6 | #pragma comment(lib, "dxgi.lib") 7 | #pragma comment(lib, "dxguid.lib") 8 | #pragma comment(lib, "d2d1.lib") 9 | #pragma comment(lib, "dwrite.lib") 10 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ghuidxpch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "ghuidxpch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ghuidxpch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::UI::Direct2D { 6 | inline static const char* NAMESPACE_NAME = GH_STRINGIFY(Ghurund::UI::Direct2D); 7 | } -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/UIContext.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuidxpch.h" 2 | #include "UIContext.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType() { 7 | static Type TYPE = Type(Ghurund::UI::Direct2D::NAMESPACE_NAME, "UIContext", sizeof(Ghurund::UI::Direct2D::UIContext)); 8 | return TYPE; 9 | } 10 | } -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/drawable/BitmapDrawable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/Canvas.h" 4 | #include "ui/drawable/ImageDrawable.h" 5 | #include "ui/direct2d/image/Bitmap.h" 6 | 7 | namespace Ghurund::UI::Direct2D { 8 | class BitmapDrawable:public ImageDrawable { 9 | protected: 10 | static const Ghurund::Core::Type& GET_TYPE(); 11 | 12 | public: 13 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 14 | 15 | virtual const Ghurund::Core::Type& getType() const override { 16 | return TYPE; 17 | } 18 | 19 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 20 | 21 | private: 22 | Bitmap* image; 23 | 24 | public: 25 | BitmapDrawable(Bitmap* image); 26 | 27 | ~BitmapDrawable(); 28 | 29 | virtual void onDraw(ICanvas& canvas) override; 30 | 31 | virtual BitmapDrawable* clone() const override { 32 | return ghnew BitmapDrawable(image); 33 | } 34 | }; 35 | } -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/drawable/SvgDrawable.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuidxpch.h" 2 | #include "SvgDrawable.h" 3 | 4 | namespace Ghurund::UI::Direct2D { 5 | const Ghurund::Core::Type& SvgDrawable::GET_TYPE() { 6 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "SvgDrawable") 7 | .withSupertype(__super::GET_TYPE()); 8 | 9 | return TYPE; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/effects/TintEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/effects/TintEffect.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::UI::Direct2D { 8 | class DirectXTintEffect:public TintEffect { 9 | private: 10 | ComPtr tintEffect; 11 | 12 | public: 13 | DirectXTintEffect(ID2D1DeviceContext5& deviceContext) { 14 | deviceContext.CreateEffect(CLSID_D2D1Tint, &tintEffect); 15 | } 16 | 17 | virtual void setColor(const Ghurund::UI::Color& color) { 18 | __super::setColor(color); 19 | tintEffect->SetValue(D2D1_TINT_PROP_COLOR, D2D_VECTOR_4F(color.R, color.G, color.B, color.A)); 20 | } 21 | }; 22 | } -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/loading/LayoutLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/loading/LayoutLoader.h" 4 | 5 | namespace Ghurund::UI::Direct2D { 6 | class LayoutLoader:public Ghurund::UI::LayoutLoader{ 7 | public: 8 | LayoutLoader():Ghurund::UI::LayoutLoader() { 9 | 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/loading/ShapeFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/loading/ShapeFactory.h" 4 | #include "ui/direct2d/Shape.h" 5 | 6 | namespace Ghurund::UI::Direct2D { 7 | class ShapeFactory:public Ghurund::UI::ShapeFactory { 8 | private: 9 | ID2D1Factory6& d2dFactory; 10 | 11 | public: 12 | ShapeFactory(ID2D1Factory6& d2dFactory):d2dFactory(d2dFactory) {} 13 | 14 | virtual Shape* makeShape(const AString& desc) override { 15 | if (desc == "rect") { 16 | return ghnew Rect(d2dFactory); 17 | } else if (desc.startsWith("roundRect")) { 18 | float radius = (float)atof(desc.substring(desc.find(",") + 1).trim().Data); 19 | return ghnew RoundRect(d2dFactory, radius); 20 | } 21 | return nullptr; 22 | } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /engine/Engine.UI.Direct2D/src/ui/direct2d/loading/TextFormatFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/loading/TextFormatFactory.h" 4 | 5 | namespace Ghurund::UI::Direct2D { 6 | class TextFormatFactory:public Ghurund::UI::TextFormatFactory { 7 | public: 8 | virtual TextFormat* makeTextFormat() override { 9 | throw NotImplementedException(); 10 | } 11 | }; 12 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Engine.UI.GDI" 2 | kind "StaticLib" 3 | pchheader "ghuigdipch.h" 4 | pchsource "src/ghuigdipch.cpp" 5 | staticruntime "on" 6 | 7 | dependson { 8 | "Engine.Core", 9 | "Engine.UI" 10 | } 11 | 12 | files { 13 | "src/**.h", 14 | "src/**.cpp" 15 | } 16 | 17 | includedirs { 18 | "src", 19 | includeDir["Engine.Core"], 20 | includeDir["Engine.UI"], 21 | includeDir["tinyxml2"] 22 | } 23 | -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/Ghurund.UI.GDI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ghurund.UI.h" 4 | #include "ui/gdi/Gdi.h" 5 | 6 | #pragma comment(lib, "Kernel32.lib") 7 | #pragma comment(lib, "dxgi.lib") 8 | #pragma comment(lib, "dxguid.lib") 9 | 10 | #ifdef _WIN64 11 | #pragma comment(lib, "Ghurund.UI.GDI_64.lib") 12 | #else 13 | #pragma comment(lib, "Ghurund.UI.GDI_32.lib") 14 | #endif -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ghuigdipch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "ghuigdipch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ghuigdipch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::UI::GDI { 6 | inline static const char* NAMESPACE_NAME = GH_STRINGIFY(Ghurund::UI::GDI); 7 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/Gdi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #undef GDIPVER 4 | #define GDIPVER 0x0110 5 | 6 | #include 7 | #include 8 | 9 | #pragma comment (lib, "Gdiplus.lib") 10 | 11 | namespace Ghurund::UI::GDI { 12 | class Gdi { 13 | private: 14 | Gdiplus::GdiplusStartupInput gdiplusStartupInput; 15 | ULONG_PTR gdiplusToken; 16 | 17 | public: 18 | Gdi() { 19 | Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr); 20 | } 21 | 22 | ~Gdi() { 23 | Gdiplus::GdiplusShutdown(gdiplusToken); 24 | } 25 | }; 26 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/StrokeStyle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/collection/Array.h" 4 | #include "ui/StrokeStyle.h" 5 | 6 | #undef GDIPVER 7 | #define GDIPVER 0x0110 8 | 9 | #include 10 | 11 | namespace Ghurund::UI::GDI { 12 | using namespace Ghurund::Core; 13 | 14 | class StrokeStyle:public IStrokeStyle { 15 | private: 16 | Gdiplus::DashStyle dashStyle; 17 | 18 | public: 19 | void init(Gdiplus::DashStyle dashStyle) { 20 | this->dashStyle = dashStyle; 21 | } 22 | 23 | inline Gdiplus::DashStyle get() { 24 | return dashStyle; 25 | } 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/UIContext.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuigdipch.h" 2 | #include "UIContext.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType() { 7 | static Type TYPE = Type(Ghurund::UI::GDI::NAMESPACE_NAME, "UIContext", sizeof(Ghurund::UI::GDI::UIContext)); 8 | return TYPE; 9 | } 10 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/drawable/BitmapDrawable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/Canvas.h" 4 | #include "ui/drawable/ImageDrawable.h" 5 | #include "ui/gdi/image/Bitmap.h" 6 | 7 | namespace Ghurund::UI::GDI { 8 | class BitmapDrawable:public ImageDrawable { 9 | protected: 10 | static const Ghurund::Core::Type& GET_TYPE(); 11 | 12 | public: 13 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 14 | 15 | virtual const Ghurund::Core::Type& getType() const override { 16 | return TYPE; 17 | } 18 | 19 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 20 | 21 | private: 22 | Bitmap* image; 23 | 24 | public: 25 | BitmapDrawable(Bitmap* image); 26 | 27 | ~BitmapDrawable(); 28 | 29 | virtual void onDraw(ICanvas& canvas) override; 30 | 31 | virtual BitmapDrawable* clone() const override { 32 | return ghnew BitmapDrawable(image); 33 | } 34 | }; 35 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/drawable/SvgDrawable.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuigdipch.h" 2 | #include "SvgDrawable.h" 3 | 4 | namespace Ghurund::UI::GDI { 5 | const Ghurund::Core::Type& SvgDrawable::GET_TYPE() { 6 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "SvgDrawable") 7 | .withSupertype(__super::GET_TYPE()); 8 | 9 | return TYPE; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/effects/ShadowEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/effects/ShadowEffect.h" 4 | 5 | namespace Ghurund::UI::GDI { 6 | using namespace Ghurund::Core; 7 | using namespace Ghurund::UI; 8 | 9 | class GDIShadowEffect:public ShadowEffect { 10 | public: 11 | virtual void setColor(const Ghurund::UI::Color& color) { 12 | __super::setColor(color); 13 | } 14 | 15 | virtual void setShape(Ghurund::UI::Shape* shape) { 16 | __super::setShape(shape); 17 | } 18 | 19 | virtual void setRadius(float radius) { 20 | __super::setRadius(radius); 21 | } 22 | }; 23 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/effects/TintEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/effects/TintEffect.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::UI::GDI { 8 | class GDITintEffect:public TintEffect { 9 | public: 10 | virtual void setColor(const Ghurund::UI::Color& color) { 11 | __super::setColor(color); 12 | } 13 | }; 14 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/font/Font.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuigdipch.h" 2 | #include "Font.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | #include "core/reflection/Property.h" 6 | #include "core/reflection/StandardTypes.h" 7 | 8 | namespace Ghurund::UI::GDI 9 | { 10 | const Ghurund::Core::Type& Font::GET_TYPE() { 11 | static const auto CONSTRUCTOR = Constructor(); 12 | 13 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::GDI::NAMESPACE_NAME, "Font") 14 | .withConstructor(CONSTRUCTOR) 15 | .withSupertype(__super::GET_TYPE()); 16 | 17 | return TYPE; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/font/FontLoader.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuigdipch.h" 2 | #include "FontLoader.h" 3 | 4 | #include "core/Exceptions.h" 5 | #include "core/logging/Logger.h" 6 | 7 | namespace Ghurund::UI::GDI { 8 | Font* FontLoader::load( 9 | Ghurund::Core::ResourceManager& manager, 10 | MemoryInputStream& stream, 11 | const ResourceFormat* format, 12 | LoadOption options 13 | ) { 14 | Font* font = makeResource(); 15 | return font; 16 | } 17 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/font/FontLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/resource/Loader.h" 4 | #include "Font.h" 5 | #include "core/Exceptions.h" 6 | 7 | namespace Ghurund::UI::GDI { 8 | using namespace Ghurund::Core; 9 | 10 | class FontLoader:public Loader { 11 | public: 12 | virtual Font* load( 13 | Ghurund::Core::ResourceManager& manager, 14 | MemoryInputStream& stream, 15 | const ResourceFormat* format = nullptr, 16 | LoadOption options = LoadOption::DEFAULT 17 | ) override; 18 | 19 | virtual void save( 20 | Ghurund::Core::ResourceManager& manager, 21 | MemoryOutputStream& stream, 22 | Resource& resource, 23 | const ResourceFormat* format = nullptr, 24 | SaveOption options = SaveOption::DEFAULT 25 | ) const override { 26 | throw NotImplementedException(); 27 | } 28 | }; 29 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/loading/ShapeFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/loading/ShapeFactory.h" 4 | #include "ui/gdi/Shape.h" 5 | 6 | namespace Ghurund::UI::GDI { 7 | class ShapeFactory:public Ghurund::UI::ShapeFactory { 8 | public: 9 | virtual Shape* makeShape(const AString& desc) override { 10 | if (desc == "rect") { 11 | return ghnew Rect(); 12 | } else if (desc.startsWith("roundRect")) { 13 | float radius = (float)atof(desc.substring(desc.find(",") + 1).trim().Data); 14 | return ghnew RoundRect(radius); 15 | } 16 | return nullptr; 17 | } 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/loading/TextFormatFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/Exceptions.h" 4 | #include "ui/loading/TextFormatFactory.h" 5 | 6 | namespace Ghurund::UI::GDI { 7 | class TextFormatFactory:public Ghurund::UI::TextFormatFactory { 8 | public: 9 | virtual TextFormat* makeTextFormat() override { 10 | throw NotImplementedException(); 11 | } 12 | }; 13 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/text/TextFormat.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuigdipch.h" 2 | #include "TextFormat.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace Ghurund::UI::GDI { 10 | const Ghurund::Core::Type& TextFormat::GET_TYPE() { 11 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(TextFormat)) 12 | .withSupertype(__super::GET_TYPE()); 13 | 14 | return TYPE; 15 | } 16 | } -------------------------------------------------------------------------------- /engine/Engine.UI.GDI/src/ui/gdi/text/TextFormat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/gdi/font/Font.h" 4 | #include "ui/text/TextFormat.h" 5 | 6 | namespace Ghurund::UI::GDI { 7 | using namespace Ghurund::Core; 8 | 9 | class Canvas; 10 | class Control; 11 | 12 | class TextFormat:public Ghurund::UI::TextFormat { 13 | 14 | protected: 15 | const Ghurund::Core::Type& GET_TYPE(); 16 | 17 | public: 18 | TextFormat(Ghurund::UI::GDI::Font* font, float size, unsigned int weight = 400, bool italic = false, const Ghurund::Core::WString& locale = L"en-us") 19 | :Ghurund::UI::TextFormat(font, size, weight, italic, locale) { 20 | } 21 | 22 | ~TextFormat(); 23 | 24 | virtual const Ghurund::Core::Type& getType() const override { 25 | return TYPE; 26 | } 27 | 28 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 29 | }; 30 | } -------------------------------------------------------------------------------- /engine/Engine.UI/.gitignore: -------------------------------------------------------------------------------- 1 | generated -------------------------------------------------------------------------------- /engine/Engine.UI/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /engine/Engine.UI/premake5.lua: -------------------------------------------------------------------------------- 1 | project "Engine.UI" 2 | kind "StaticLib" 3 | pchheader "ghuipch.h" 4 | pchsource "src/ghuipch.cpp" 5 | staticruntime "on" 6 | 7 | dependson { "Engine.Core" } 8 | 9 | files { 10 | "src/**.h", 11 | "src/**.cpp", 12 | "generated/bindings/**.h" 13 | } 14 | 15 | includedirs { 16 | includeDir["Engine.UI"], 17 | includeDir["Engine.UI_bindings"], 18 | includeDir["Engine.Core"], 19 | includeDir["tinyxml2"] 20 | } 21 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/Button.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/CheckBox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 12 | 13 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/ExpandableContainer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/ScrollBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 21 | 22 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/Tab.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/TabContainer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/Toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /engine/Engine.UI/res/TreeRow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 11 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/Ghurund.UI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Ghurund.Core.h" 4 | 5 | #pragma comment(lib, "Kernel32.lib") 6 | #pragma comment(lib, "dxgi.lib") 7 | #pragma comment(lib, "dxguid.lib") 8 | #pragma comment(lib, "d2d1.lib") 9 | #pragma comment(lib, "dwrite.lib") 10 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ghuipch.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" -------------------------------------------------------------------------------- /engine/Engine.UI/src/ghuipch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "core/logging/Formatter.h" 5 | #include "core/logging/Logger.h" 6 | #include "core/reflection/TypeBuilder.h" 7 | 8 | #include 9 | 10 | namespace Ghurund::UI { 11 | inline static const char* NAMESPACE_NAME = GH_STRINGIFY(Ghurund::UI); 12 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/Alignment.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | 5 | namespace Ghurund::UI { 6 | class Alignment { 7 | public: 8 | enum class Horizontal { 9 | LEFT, RIGHT, CENTER 10 | }; 11 | 12 | enum class Vertical { 13 | TOP, BOTTOM, CENTER 14 | }; 15 | 16 | Horizontal horizontal = Horizontal::LEFT; 17 | Vertical vertical = Vertical::TOP; 18 | 19 | bool operator==(const Alignment& alignment) const { 20 | return horizontal == alignment.horizontal && vertical == alignment.vertical; 21 | } 22 | 23 | static Alignment parse(const Ghurund::Core::AString& alignment); 24 | }; 25 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/Orientation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | enum class Orientation { 5 | VERTICAL, HORIZONTAL 6 | }; 7 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/Padding.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | class Padding { 5 | public: 6 | float left = 0.0f, top = 0.0f, right = 0.0f, bottom = 0.0f; 7 | 8 | inline void setAll(float value) { 9 | left = top = right = bottom = value; 10 | } 11 | 12 | __declspec(property(put = setAll)) float All; 13 | 14 | inline void setVertical(float value) { 15 | top = bottom = value; 16 | } 17 | 18 | __declspec(property(put = setVertical)) float Vertical; 19 | 20 | inline void setHorizontal(float value) { 21 | left = right = value; 22 | } 23 | 24 | __declspec(property(put = setHorizontal)) float Horizontal; 25 | }; 26 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/Shape.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Shape.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType() { 7 | static Type TYPE = Type(Ghurund::UI::NAMESPACE_NAME, "Shape", sizeof(Ghurund::UI::Shape)); 8 | return TYPE; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/Shape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/math/Rect.h" 4 | 5 | namespace Ghurund::UI { 6 | using namespace Ghurund::Core; 7 | 8 | class Shape { 9 | protected: 10 | FloatRect bounds; 11 | 12 | public: 13 | virtual ~Shape() = 0 {}; 14 | 15 | inline const FloatRect& getBounds() const { 16 | return bounds; 17 | } 18 | 19 | virtual void setBounds(const FloatRect& bounds) { 20 | this->bounds = bounds; 21 | } 22 | 23 | __declspec(property(get = getBounds, put = setBounds)) const FloatRect& Bounds; 24 | }; 25 | } 26 | 27 | namespace Ghurund::Core { 28 | template<> 29 | const Type& getType(); 30 | } 31 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/StrokeStyle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | __interface IStrokeStyle {}; 5 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/UIContext.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "UIContext.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType() { 7 | static Type TYPE = Type(Ghurund::UI::NAMESPACE_NAME, "IUIContext", sizeof(Ghurund::UI::IUIContext)); 8 | return TYPE; 9 | } 10 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/adapter/ControlPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ItemAdapter.h" 4 | #include "core/collection/PointerList.h" 5 | #include "ui/control/Control.h" 6 | 7 | namespace Ghurund::UI { 8 | template 9 | class ControlPool { 10 | private: 11 | PointerList pool; 12 | 13 | public: 14 | ~ControlPool() { 15 | for(ControlType* c:pool) 16 | c->release(); 17 | } 18 | 19 | inline bool isEmpty() const { 20 | return pool.Empty; 21 | } 22 | 23 | __declspec(property(get = isEmpty)) bool Empty; 24 | 25 | ControlType* getControl() { 26 | ControlType* control = pool[pool.Size - 1]; 27 | control->addReference(); 28 | pool.removeAt(pool.Size - 1); 29 | return control; 30 | } 31 | 32 | void recycle(ControlType* c) { 33 | pool.add(c); 34 | } 35 | }; 36 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/adapter/ItemAdapter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ControlPool.h" 4 | 5 | #include "core/Concepts.h" 6 | #include "ui/control/Control.h" 7 | #include "ui/widget/Widget.h" 8 | 9 | namespace Ghurund::UI { 10 | template 11 | class ItemAdapter { 12 | private: 13 | ControlPool pool; 14 | 15 | public: 16 | virtual ~ItemAdapter() {} 17 | 18 | virtual ControlType* makeControl() const = 0; 19 | 20 | virtual void bind(ControlType& control, T& item, size_t position) const {} 21 | 22 | inline ControlType* getControl() { 23 | if (pool.Empty) 24 | return makeControl(); 25 | return pool.getControl(); 26 | } 27 | 28 | inline void recycleControl(ControlType* control) { 29 | pool.recycle(control); 30 | } 31 | }; 32 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/adapter/ItemSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/collection/List.h" 4 | 5 | namespace Ghurund::UI { 6 | template 7 | class ItemSource { 8 | public: 9 | virtual ~ItemSource() {} 10 | 11 | virtual size_t getSize() const = 0; 12 | 13 | __declspec(property(get = getSize)) size_t Size; 14 | 15 | virtual T& get(size_t position) const = 0; 16 | }; 17 | 18 | template> 19 | class ListItemSource:public ItemSource { 20 | private: 21 | ListType items; 22 | 23 | public: 24 | virtual size_t getSize() const override { 25 | return items.Size; 26 | } 27 | 28 | virtual T& get(size_t position) const override { 29 | return items.get(position); 30 | } 31 | 32 | inline ListType& getItems() { 33 | return items; 34 | } 35 | 36 | __declspec(property(get = getItems)) ListType& Items; 37 | }; 38 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/ChildrenProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ControlGroup.h" 4 | 5 | namespace Ghurund::UI { 6 | __interface ChildrenProvider { 7 | virtual size_t getChildCount() const = 0; 8 | virtual Control* getChild(size_t index) = 0; 9 | virtual void releaseChild(Control* control, size_t index) = 0; 10 | }; 11 | 12 | class ListChildrenProvider:public ChildrenProvider { 13 | private: 14 | ControlGroup& owner; 15 | 16 | public: 17 | ListChildrenProvider(ControlGroup& owner):owner(owner) {} 18 | 19 | virtual size_t getChildCount() const override { 20 | return owner.Children.Size; 21 | } 22 | 23 | virtual Control* getChild(size_t index) { 24 | return owner.Children[index]; 25 | } 26 | 27 | virtual void releaseChild(Control* control, size_t index) {} 28 | }; 29 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/ControlParent.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "ControlParent.h" 3 | 4 | #include "core/reflection/Property.h" 5 | 6 | namespace Ghurund::UI { 7 | const Ghurund::Core::Type& ControlParent::GET_TYPE() { 8 | using namespace Ghurund::Core; 9 | 10 | static auto PROPERTY_FOCUS = Property("Focus", &getFocus, &setFocus); 11 | 12 | static const auto CONSTRUCTOR = Constructor(); 13 | 14 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "ControlParent") 15 | .withProperty(PROPERTY_FOCUS) 16 | .withConstructor(CONSTRUCTOR) 17 | .withSupertype(__super::GET_TYPE()); 18 | 19 | return TYPE; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/InvalidControl.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "InvalidControl.h" 3 | 4 | #include "ui/Canvas.h" 5 | #include "ui/style/Theme.h" 6 | 7 | namespace Ghurund::UI { 8 | const Ghurund::Core::Type& InvalidControl::GET_TYPE() { 9 | static const auto CONSTRUCTOR = Constructor(); 10 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(InvalidControl)) 11 | .withConstructor(CONSTRUCTOR) 12 | .withSupertype(__super::GET_TYPE()); 13 | 14 | return TYPE; 15 | } 16 | 17 | void InvalidControl::onDraw(ICanvas& canvas) { 18 | canvas.fillRect(0, 0, Size.width, Size.height, backgroundColor); 19 | canvas.drawRect(1, 1, Size.width - 2, Size.height - 2, borderColor, 2, strokeStyle.get()); 20 | } 21 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/SelectableView.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "SelectableView.h" 3 | #include "core/reflection/TypeBuilder.h" 4 | 5 | namespace Ghurund::UI { 6 | const Ghurund::Core::Type& SelectableView::GET_TYPE() { 7 | static const auto CONSTRUCTOR = Constructor(); 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, GH_STRINGIFY(SelectableView)) 9 | .withConstructor(CONSTRUCTOR) 10 | .withSupertype(__super::GET_TYPE()); 11 | 12 | return TYPE; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/Space.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Space.h" 3 | #include "core/reflection/TypeBuilder.h" 4 | 5 | namespace Ghurund::UI { 6 | const Ghurund::Core::Type& Space::GET_TYPE() { 7 | static const auto CONSTRUCTOR = Constructor(); 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(Space)) 9 | .withConstructor(CONSTRUCTOR) 10 | .withSupertype(__super::GET_TYPE()); 11 | 12 | return TYPE; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/control/Space.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Control.h" 4 | 5 | namespace Ghurund::UI { 6 | class Space:public Control { 7 | protected: 8 | static const Ghurund::Core::Type& GET_TYPE(); 9 | 10 | public: 11 | Space(float space = 8.0f) { 12 | preferredSize.width = PreferredSize::Width(space); 13 | preferredSize.height = PreferredSize::Height(space); 14 | } 15 | 16 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 17 | 18 | virtual const Ghurund::Core::Type& getType() const override { 19 | return TYPE; 20 | } 21 | 22 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/drawable/CursorDrawable.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "CursorDrawable.h" 3 | 4 | #include "ui/control/Control.h" 5 | 6 | namespace Ghurund::UI { 7 | void CursorDrawable::onDraw(ICanvas& canvas) { 8 | if (visible) 9 | canvas.fillRect(0, 0, size.width, size.height, color); 10 | owner->repaint(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/drawable/ImageDrawable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Drawable.h" 4 | 5 | namespace Ghurund::UI { 6 | class ImageDrawable:public Drawable { 7 | private: 8 | uint32_t tint = 0; 9 | float alpha = 1.0f; 10 | 11 | public: 12 | virtual ~ImageDrawable() = 0 {} 13 | 14 | inline void setTint(const uint32_t color) { 15 | this->tint = color; 16 | } 17 | 18 | inline uint32_t getTint() const { 19 | return tint; 20 | } 21 | 22 | __declspec(property(get = getTint, put = setTint)) uint32_t Tint; 23 | 24 | inline void setAlpha(const float alpha) { 25 | this->alpha = alpha; 26 | } 27 | 28 | inline float getAlpha() const { 29 | return alpha; 30 | } 31 | 32 | __declspec(property(get = getAlpha, put = setAlpha)) float Alpha; 33 | }; 34 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/drawable/InvalidImageDrawable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ImageDrawable.h" 4 | #include "ui/Color.h" 5 | 6 | namespace Ghurund::UI { 7 | class InvalidImageDrawable:public ImageDrawable { 8 | protected: 9 | static const Ghurund::Core::Type& GET_TYPE(); 10 | 11 | public: 12 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 13 | 14 | virtual const Ghurund::Core::Type& getType() const override { 15 | return TYPE; 16 | } 17 | 18 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 19 | 20 | private: 21 | Color backgroundColor = Color(1, 0, 0, 0.2f); 22 | Color borderColor = Color(1, 0, 0, 1.0f); 23 | 24 | public: 25 | InvalidImageDrawable(); 26 | 27 | virtual void onDraw(ICanvas& canvas) override; 28 | 29 | virtual InvalidImageDrawable* clone() const override { 30 | return ghnew InvalidImageDrawable(); 31 | } 32 | }; 33 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/effects/DrawingEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | __interface DrawingEffect {}; 5 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/effects/TintEffect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DrawingEffect.h" 4 | #include "ui/Color.h" 5 | 6 | namespace Ghurund::UI { 7 | class TintEffect:public DrawingEffect { 8 | private: 9 | Color color; 10 | 11 | public: 12 | TintEffect(const Color& color = Ghurund::UI::Color(0.0f, 0.0f, 0.0f, 0.0f)):color(color) {} 13 | 14 | inline const Color& getColor() const { 15 | return color; 16 | } 17 | 18 | virtual void setColor(const Color& color) { 19 | this->color = color; 20 | } 21 | 22 | __declspec(property(get = getColor, put = setColor)) const Color& Color; 23 | }; 24 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/font/Font.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Font.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | #include "core/reflection/Property.h" 6 | #include "core/reflection/ReadOnlyProperty.h" 7 | #include "core/reflection/StandardTypes.h" 8 | 9 | namespace Ghurund::UI { 10 | const Ghurund::Core::Type& Font::GET_TYPE() { 11 | static auto PROPERTY_FAMILYNAME = ReadOnlyProperty("FamilyName", &getFamilyName); 12 | 13 | static const auto CONSTRUCTOR = Constructor(); 14 | 15 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "Font") 16 | .withProperty(PROPERTY_FAMILYNAME) 17 | .withConstructor(CONSTRUCTOR) 18 | .withSupertype(__super::GET_TYPE()); 19 | 20 | return TYPE; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/image/Bitmap.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Bitmap.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | #include "core/reflection/StandardTypes.h" 6 | #include "core/reflection/ReadOnlyProperty.h" 7 | #include "core/reflection/Property.h" 8 | 9 | namespace Ghurund::UI { 10 | const Ghurund::Core::Type& Bitmap::GET_TYPE() { 11 | static auto PROPERTY_SIZE = ReadOnlyProperty("Size", &getSize); 12 | 13 | static const auto CONSTRUCTOR = Constructor(); 14 | 15 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "Bitmap") 16 | .withProperty(PROPERTY_SIZE) 17 | .withConstructor(CONSTRUCTOR) 18 | .withSupertype(__super::GET_TYPE()); 19 | 20 | return TYPE; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/image/Bitmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/math/Size.h" 4 | #include "core/resource/Resource.h" 5 | 6 | namespace Ghurund::UI { 7 | using namespace Ghurund::Core; 8 | 9 | class Bitmap:public Ghurund::Core::Resource { 10 | protected: 11 | static const Ghurund::Core::Type& GET_TYPE(); 12 | 13 | public: 14 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 15 | 16 | virtual const Ghurund::Core::Type& getType() const override { 17 | return TYPE; 18 | } 19 | 20 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 21 | 22 | public: 23 | virtual Ghurund::Core::IntSize getSize() const = 0; 24 | 25 | __declspec(property(get = getSize)) Ghurund::Core::IntSize Size; 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/image/VectorImage.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "VectorImage.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | #include "core/reflection/StandardTypes.h" 6 | #include "core/reflection/Property.h" 7 | #include "core/reflection/ReadOnlyProperty.h" 8 | 9 | namespace Ghurund::UI { 10 | const Ghurund::Core::Type& VectorImage::GET_TYPE() { 11 | static auto PROPERTY_SIZE = ReadOnlyProperty("Size", &getSize); 12 | 13 | static const auto CONSTRUCTOR = Constructor(); 14 | 15 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, "VectorImage") 16 | .withProperty(PROPERTY_SIZE) 17 | .withConstructor(CONSTRUCTOR) 18 | .withSupertype(__super::GET_TYPE()); 19 | 20 | return TYPE; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/image/VectorImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/math/Size.h" 4 | #include "core/resource/Resource.h" 5 | 6 | namespace Ghurund::UI { 7 | using namespace Ghurund::Core; 8 | 9 | class VectorImage:public Ghurund::Core::Resource { 10 | protected: 11 | static const Ghurund::Core::Type& GET_TYPE(); 12 | 13 | public: 14 | inline static const Ghurund::Core::Type& TYPE = GET_TYPE(); 15 | 16 | virtual const Ghurund::Core::Type& getType() const override { 17 | return TYPE; 18 | } 19 | 20 | __declspec(property(get = getType)) const Ghurund::Core::Type& Type; 21 | 22 | public: 23 | virtual Ghurund::Core::FloatSize getSize() const = 0; 24 | 25 | __declspec(property(get = getSize)) Ghurund::Core::FloatSize Size; 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/DesktopLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "DesktopLayout.h" 3 | 4 | namespace Ghurund::UI { 5 | const Ghurund::Core::Type& DesktopLayout::GET_TYPE() { 6 | static const auto CONSTRUCTOR = Constructor(); 7 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, GH_STRINGIFY(DesktopLayout)) 8 | .withConstructor(CONSTRUCTOR) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/FlowLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "FlowLayout.h" 3 | 4 | namespace Ghurund::UI { 5 | const Ghurund::Core::Type& FlowLayout::GET_TYPE() { 6 | static const auto CONSTRUCTOR = Constructor(); 7 | static const Ghurund::Core::Type TYPE = TypeBuilder(Ghurund::UI::NAMESPACE_NAME, GH_STRINGIFY(FlowLayout)) 8 | .withConstructor(CONSTRUCTOR) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/FlowLayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutManager.h" 4 | 5 | namespace Ghurund::UI { 6 | using namespace Ghurund::Core; 7 | 8 | struct Spacing { 9 | float horizontal = 0.0f, vertical = 0.0f; 10 | }; 11 | 12 | class FlowLayoutManager:public LayoutManager { 13 | private: 14 | void layoutFlowingControlsRight(float width); 15 | 16 | void layoutFlowingControlsLeft(float width); 17 | 18 | float measureWidth(); 19 | 20 | float measureHeight(float width); 21 | 22 | public: 23 | bool reverseLayout = false; 24 | Spacing spacing; 25 | 26 | virtual const FloatSize measure(float parentWidth, float parentHeight) override; 27 | 28 | virtual void layout(float x, float y, float width, float height) override; 29 | }; 30 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/LinearLayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutManager.h" 4 | #include "ui/Alignment.h" 5 | #include "ui/Orientation.h" 6 | 7 | #include 8 | 9 | namespace Ghurund::UI { 10 | class LinearLayoutManager:public LayoutManager { 11 | private: 12 | float contentSize = 0.0f; 13 | unsigned int spreadCount; 14 | 15 | Ghurund::Core::FloatSize measureHorizontal(float parentWidth, float parentHeight); 16 | 17 | Ghurund::Core::FloatSize measureVertical(float parentWidth, float parentHeight); 18 | 19 | void layoutHorizontal(float x, float y, float width, float height); 20 | 21 | void layoutVertical(float x, float y, float width, float height); 22 | 23 | public: 24 | Alignment alignment; 25 | Orientation orientation = Orientation::HORIZONTAL; 26 | 27 | virtual const Ghurund::Core::FloatSize measure(float parentWidth, float parentHeight) override; 28 | 29 | virtual void layout(float x, float y, float width, float height) override; 30 | }; 31 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/ManualLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "ManualLayout.h" 3 | #include "core/reflection/TypeBuilder.h" 4 | 5 | namespace Ghurund::UI { 6 | const Ghurund::Core::Type& ManualLayout::GET_TYPE() { 7 | static const auto CONSTRUCTOR = Constructor(); 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(ManualLayout)) 9 | .withConstructor(CONSTRUCTOR) 10 | .withSupertype(__super::GET_TYPE()); 11 | 12 | return TYPE; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/ManualLayoutManager.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "ManualLayoutManager.h" 3 | 4 | namespace Ghurund::UI { 5 | const Ghurund::Core::FloatSize ManualLayoutManager::measure(float parentWidth, float parentHeight) { 6 | __super::measure(parentWidth, parentHeight); 7 | return { measureMaxWidth(), measureMaxHeight() }; 8 | } 9 | 10 | void ManualLayoutManager::layout(float x, float y, float width, float height) { 11 | for (Control* c : group->Children) { 12 | if (!c->Visible) 13 | continue; 14 | 15 | c->layout(c->Position.x, c->Position.y, 16 | c->PreferredSize.width == PreferredSize::Width::FILL ? width : c->MeasuredSize.width, 17 | c->PreferredSize.height == PreferredSize::Height::FILL ? height : c->MeasuredSize.height 18 | ); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/ManualLayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutManager.h" 4 | 5 | #include 6 | 7 | namespace Ghurund::UI { 8 | class ManualLayoutManager:public LayoutManager { 9 | public: 10 | virtual const Ghurund::Core::FloatSize measure(float parentWidth, float parentHeight) override; 11 | 12 | virtual void layout(float x, float y, float width, float height) override; 13 | }; 14 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/StackLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "StackLayout.h" 3 | 4 | #include "ui/loading/LayoutLoader.h" 5 | 6 | namespace Ghurund::UI { 7 | const Ghurund::Core::Type& StackLayout::GET_TYPE() { 8 | static const auto CONSTRUCTOR = Constructor(); 9 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(StackLayout)) 10 | .withConstructor(CONSTRUCTOR) 11 | .withSupertype(__super::GET_TYPE()); 12 | 13 | return TYPE; 14 | } 15 | void Ghurund::UI::StackLayout::load(LayoutLoader& loader, const tinyxml2::XMLElement& xml) { 16 | __super::load(loader, xml); 17 | Ghurund::UI::Alignment a; 18 | if (loader.loadAlignment(xml, &a) == Status::OK) 19 | Alignment = a; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/StackLayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutManager.h" 4 | #include "ui/Alignment.h" 5 | 6 | #include 7 | 8 | namespace Ghurund::UI { 9 | class StackLayoutManager:public LayoutManager { 10 | public: 11 | Alignment alignment; 12 | 13 | virtual const Ghurund::Core::FloatSize measure(float parentWidth, float parentHeight) override; 14 | 15 | virtual void layout(float x, float y, float width, float height) override; 16 | }; 17 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/layout/VerticalLayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LayoutManager.h" 4 | 5 | namespace Ghurund::UI { 6 | class VerticalLayoutManager:public LayoutManager { 7 | private: 8 | unsigned int indexTop = 0, indexBottom = 0; 9 | float firstTop = 0, firstBottom = 0; 10 | float lastTop = 0, lastBottom = 0; 11 | 12 | void addTop(); 13 | void addBottom(); 14 | void removeTop(); 15 | void removeBottom(); 16 | 17 | public: 18 | virtual void scrollBy(float dx, float dy) override; 19 | 20 | virtual const FloatSize measure(float parentWidth, float parentHeight) override; 21 | 22 | virtual void layout(float x, float y, float width, float height) override; 23 | }; 24 | 25 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/loading/ImageDrawableFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/drawable/ImageDrawable.h" 4 | 5 | namespace Ghurund::UI { 6 | __interface ImageDrawableFactory { 7 | ImageDrawable* makeDrawable(const FilePath& path); 8 | }; 9 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/loading/ShapeFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "core/string/String.h" 4 | #include "ui/Shape.h" 5 | 6 | namespace Ghurund::UI { 7 | __interface ShapeFactory { 8 | Shape* makeShape(const AString& desc); 9 | }; 10 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/loading/TextFormatFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/text/TextFormat.h" 4 | 5 | namespace Ghurund::UI { 6 | __interface TextFormatFactory { 7 | TextFormat* makeTextFormat(); 8 | }; 9 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/style/Style.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Style.h" 3 | 4 | namespace Ghurund::Core { 5 | template<> 6 | const Type& getType() { 7 | static Type TYPE = Type(Ghurund::UI::NAMESPACE_NAME, "Style", sizeof(Ghurund::UI::Style)); 8 | return TYPE; 9 | } 10 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/style/Style.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | class Control; 5 | 6 | class Style { 7 | public: 8 | virtual ~Style() = 0 {} 9 | 10 | virtual void onThemeChanged(Control& control) const {} 11 | 12 | virtual void onStateChanged(Control& control) const {} 13 | }; 14 | 15 | template 16 | class TypedStyle:public Style { 17 | public: 18 | virtual void onThemeChanged(Control& control) const override { 19 | onThemeChanged((T&)control); 20 | } 21 | 22 | virtual void onStateChanged(Control& control) const override { 23 | onStateChanged((T&)control); 24 | } 25 | 26 | virtual void onThemeChanged(T& control) const {} 27 | 28 | virtual void onStateChanged(T& control) const {} 29 | }; 30 | } 31 | 32 | namespace Ghurund::Core { 33 | template<> 34 | const Type& getType(); 35 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/text/Selection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | struct Selection { 5 | uint32_t start, length; 6 | }; 7 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/text/SetSelectionMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Ghurund::UI { 4 | enum class SetSelectionMode { 5 | Left, // cluster left 6 | Right, // cluster right 7 | Up, // line up 8 | Down, // line down 9 | LeftChar, // single character left (backspace uses it) 10 | RightChar, // single character right 11 | LeftWord, // single word left 12 | RightWord, // single word right 13 | Home, // front of line 14 | End, // back of line 15 | First, // very first position 16 | Last, // very last position 17 | AbsoluteLeading, // explicit position (for mouse click) 18 | AbsoluteTrailing, // explicit position, trailing edge 19 | All // select all text 20 | }; 21 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/text/TextFormat.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "TextFormat.h" 3 | 4 | #include "core/reflection/TypeBuilder.h" 5 | 6 | namespace Ghurund::UI { 7 | const Ghurund::Core::Type& TextFormat::GET_TYPE() { 8 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(TextFormat)) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | 14 | TextFormat::~TextFormat() { 15 | if (font) 16 | font->release(); 17 | } 18 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/text/TextMetrics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Ghurund::UI { 6 | struct TextMetrics { 7 | float left, top, width, height; 8 | 9 | float widthIncludingTrailingWhitespace; 10 | 11 | float layoutWidth, layoutHeight; 12 | 13 | uint32_t maxBidiReorderingDepth; 14 | 15 | uint32_t lineCount; 16 | }; 17 | 18 | struct LineMetrics { 19 | uint32_t length; 20 | uint32_t trailingWhitespaceLength; 21 | uint32_t newlineLength; 22 | 23 | float height; 24 | float baseline; 25 | 26 | bool isTrimmed; 27 | }; 28 | 29 | struct HitTestMetrics { 30 | uint32_t textPosition, length; 31 | float left, top, width, height; 32 | }; 33 | 34 | struct ClusterMetrics { 35 | uint32_t length; 36 | bool canWrapLineAfter; 37 | }; 38 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/widget/DragHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/control/ControlParent.h" 4 | 5 | namespace Ghurund::UI { 6 | using namespace Ghurund::Core; 7 | 8 | class DragHelper { 9 | private: 10 | FloatPoint pressControlPos = {}; 11 | IntPoint pressMousePos = {}; 12 | bool pressed = false; 13 | 14 | public: 15 | DragHelper(Control& control):DragHelper(control, control) {} 16 | 17 | DragHelper(Control& handle, Control& content); 18 | 19 | Event dragged; 20 | }; 21 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/widget/ExpandableContainer.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "ExpandableContainer.h" 3 | 4 | namespace Ghurund::UI { 5 | const Ghurund::Core::Type& ExpandableContainer::GET_TYPE() { 6 | static const auto CONSTRUCTOR = Constructor(); 7 | static const Ghurund::Core::Type TYPE = TypeBuilder(NAMESPACE_NAME, GH_STRINGIFY(ExpandableContainer)) 8 | .withConstructor(CONSTRUCTOR) 9 | .withSupertype(__super::GET_TYPE()); 10 | 11 | return TYPE; 12 | } 13 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/widget/SeparatorStyle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ui/style/Style.h" 4 | #include "Separator.h" 5 | 6 | namespace Ghurund::UI { 7 | class Theme; 8 | 9 | class SeparatorStyle:public Ghurund::UI::Style { 10 | public: 11 | ~SeparatorStyle() = 0 {} 12 | 13 | virtual void onThemeChanged(Control& separator) const override; 14 | 15 | virtual void onStateChanged(Control& separator) const override; 16 | }; 17 | 18 | class SeparatorHorizontalStyle:public SeparatorStyle { 19 | public: 20 | virtual void onThemeChanged(Control& separator) const override; 21 | }; 22 | 23 | class SeparatorVerticalStyle:public SeparatorStyle { 24 | public: 25 | virtual void onThemeChanged(Control& separator) const override; 26 | }; 27 | } -------------------------------------------------------------------------------- /engine/Engine.UI/src/ui/widget/button/Button.cpp: -------------------------------------------------------------------------------- 1 | #include "ghuipch.h" 2 | #include "Button.h" 3 | 4 | namespace Ghurund::UI { 5 | const Ghurund::Core::Type& Button::GET_TYPE() { 6 | static const auto CONSTRUCTOR = Constructor 8 | 9 | 10 | 21 | 22 | -------------------------------------------------------------------------------- /resources/layouts/LogRow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /resources/layouts/RadioButtonLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /resources/layouts/TreeItem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 11 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /resources/layouts/VerticalScrollBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | 12 | 18 | 19 | 21 | 22 | 27 | 28 | -------------------------------------------------------------------------------- /resources/layouts/WindowFrame.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /resources/layouts/scrollBar test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /resources/layouts/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /resources/shaders/basic.hlsl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | cbuffer perCamera : register(b0) { 4 | row_major float4x4 viewProjection; 5 | } 6 | 7 | cbuffer perObject : register(b1) { 8 | row_major float4x4 world; 9 | } 10 | 11 | SamplerState linearSampler : register(s0); 12 | Texture2D diffuseTexture : register(t0); 13 | 14 | DefaultPixel vertexMain(DefaultVertex input) { 15 | DefaultPixel output; 16 | 17 | output.position = mul(mul(float4(input.position, 1), world), viewProjection); 18 | output.normal = normalize(mul(input.normal, world)).xyz; 19 | output.tangent = normalize(mul(input.tangent, world)).xyz; 20 | output.texCoord = input.texCoord; 21 | 22 | return output; 23 | } 24 | 25 | float4 pixelMain(DefaultPixel input): SV_Target{ 26 | float4 color = diffuseTexture.Sample(linearSampler, frac(input.texCoord*5)); 27 | return color; 28 | } 29 | -------------------------------------------------------------------------------- /resources/shaders/basicSky.hlsl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | cbuffer constants : register(b0) { 4 | row_major float4x4 world; 5 | row_major float4x4 viewProjection; 6 | } 7 | 8 | struct SkyPixel { 9 | float4 position:SV_Position; 10 | float height:TexCoord0; 11 | }; 12 | 13 | SkyPixel vertexMain(ScreenVertex input) { 14 | SkyPixel output; 15 | 16 | output.position = mul(mul(float4(input.position.xyz, 1), world), viewProjection); 17 | output.height = input.position.y; 18 | 19 | return output; 20 | } 21 | 22 | [maxvertexcount(3)] 23 | void geometryMain(triangle SkyPixel input[3], inout TriangleStream outStream) { 24 | outStream.Append(input[0]); 25 | outStream.Append(input[2]); 26 | outStream.Append(input[1]); 27 | 28 | outStream.RestartStrip(); 29 | } 30 | 31 | float4 pixelMain(SkyPixel input) : SV_Target{ 32 | float4 sky = lerp(float4(1, 1, 1, 1), float4(0.55,0.8,1,1), saturate(input.height*3)); 33 | float4 skyGround = lerp(sky, float4(0,0,0,1), saturate(-input.height *50)); 34 | return skyGround; 35 | } -------------------------------------------------------------------------------- /resources/shaders/normals.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer perCamera : register(b0) { 2 | row_major float4x4 viewProjection; 3 | } 4 | 5 | cbuffer perObject : register(b1) { 6 | row_major float4x4 world; 7 | } 8 | 9 | struct VsInput { 10 | float3 position : POSITION; 11 | float3 normal : NORMAL; 12 | float3 tangent : TANGENT; 13 | float2 texCoord : TEXCOORD0; 14 | }; 15 | 16 | struct PsInput { 17 | float4 position : SV_POSITION; 18 | float3 normal : NORMAL; 19 | }; 20 | 21 | PsInput vertexMain(VsInput input) { 22 | PsInput output; 23 | 24 | output.position = mul(mul(float4(input.position, 1), world), viewProjection); 25 | output.normal = normalize(mul(input.normal, world)).xyz; 26 | 27 | return output; 28 | } 29 | 30 | float4 pixelMain(PsInput input): SV_Target{ 31 | return float4((input.normal+float3(1,1,1))/2, 1); 32 | } 33 | -------------------------------------------------------------------------------- /resources/textures/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZieIony/Ghurund/0ce83cabd91f7ac71286dcd8e12d486bed2d75cf/resources/textures/checker.png -------------------------------------------------------------------------------- /resources/textures/diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZieIony/Ghurund/0ce83cabd91f7ac71286dcd8e12d486bed2d75cf/resources/textures/diffuse.png -------------------------------------------------------------------------------- /resources/textures/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZieIony/Ghurund/0ce83cabd91f7ac71286dcd8e12d486bed2d75cf/resources/textures/normal.png -------------------------------------------------------------------------------- /resources/textures/specular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZieIony/Ghurund/0ce83cabd91f7ac71286dcd8e12d486bed2d75cf/resources/textures/specular.png -------------------------------------------------------------------------------- /samples/UI.Direct2D/premake5.lua: -------------------------------------------------------------------------------- 1 | project "UI.Direct2D" 2 | kind "WindowedApp" 3 | staticruntime "on" 4 | 5 | dependson { 6 | "Engine.Core", 7 | "Engine.UI", 8 | "Engine.UI.Direct2D" 9 | } 10 | 11 | files { 12 | "src/**.h", 13 | "src/**.cpp", 14 | "generated/bindings/**.h" 15 | } 16 | 17 | includedirs { 18 | "src", 19 | "generated/bindings", 20 | includeDir["Engine.Core"], 21 | includeDir["Engine.UI"], 22 | includeDir["Engine.UI_bindings"], 23 | includeDir["Engine.UI.Direct2D"], 24 | includeDir["tinyxml2"], 25 | } 26 | 27 | links { 28 | "Engine.Core", 29 | "Engine.UI", 30 | "Engine.UI.Direct2D" 31 | } 32 | 33 | filter "configurations:Debug" 34 | links { 35 | library["tinyxml2_Debug"] 36 | } 37 | 38 | filter "configurations:Release" 39 | links { 40 | library["tinyxml2_Release"] 41 | } 42 | -------------------------------------------------------------------------------- /samples/UI.GDI/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Ghurund.Core.h" 2 | 3 | #include "core/application/Application.h" 4 | #include "GdiWindow.h" 5 | 6 | namespace Samples { 7 | class SampleApplication:public Ghurund::Core::Application { 8 | public: 9 | virtual void onInit() override { 10 | ResourceManager.Libraries.add(L"test", DirectoryPath(L"./test")); 11 | ResourceManager.Libraries.add(L"icons", DirectoryPath(L"./icons")); 12 | 13 | auto window = ghnew GdiWindow(this->Timer); 14 | window->title = _T("Preview"); 15 | window->Size = { Settings.get("width"), Settings.get("height") }; 16 | Windows.add(window); 17 | window->visible = true; 18 | window->bringToFront(); 19 | } 20 | }; 21 | } 22 | 23 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdLine, int nCmdShow) { 24 | Ghurund::Core::Settings settings; 25 | settings.parse(GetCommandLine()); 26 | Ghurund::Core::main(&settings); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /samples/premake5.lua: -------------------------------------------------------------------------------- 1 | group "samples" 2 | 3 | include "UI.Text" 4 | include "UI.GDI" 5 | include "UI.Direct2D" 6 | -------------------------------------------------------------------------------- /tools/premake5.lua: -------------------------------------------------------------------------------- 1 | group "tools" 2 | 3 | include "SystemInfo" 4 | --------------------------------------------------------------------------------