diff --git a/CMake/FileList.cmake b/CMake/FileList.cmake index 916e1543d..94ba1fb98 100644 --- a/CMake/FileList.cmake +++ b/CMake/FileList.cmake @@ -26,7 +26,24 @@ set(Core_HDR_FILES ${PROJECT_SOURCE_DIR}/Source/Core/ElementDecoration.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementDefinition.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.h - ${PROJECT_SOURCE_DIR}/Source/Core/ElementImage.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementImage.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTextSelection.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputType.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeButton.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeCheckbox.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeRadio.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeRange.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeSubmit.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeText.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetDropDown.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetSlider.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInput.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputMultiLine.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputSingleLine.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputSingleLinePassword.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerDataGrid.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerTabSet.h + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerTextArea.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyle.h ${PROJECT_SOURCE_DIR}/Source/Core/ElementTextDefault.h ${PROJECT_SOURCE_DIR}/Source/Core/EventDispatcher.h @@ -83,8 +100,7 @@ set(Core_HDR_FILES ${PROJECT_SOURCE_DIR}/Source/Core/TextureLayoutTexture.h ${PROJECT_SOURCE_DIR}/Source/Core/TextureResource.h ${PROJECT_SOURCE_DIR}/Source/Core/Utilities.h - ${PROJECT_SOURCE_DIR}/Source/Core/WidgetSlider.h - ${PROJECT_SOURCE_DIR}/Source/Core/WidgetSliderScroll.h + ${PROJECT_SOURCE_DIR}/Source/Core/WidgetScroll.h ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerBody.h ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerDefault.h ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerHead.h @@ -124,6 +140,23 @@ set(Core_PUB_HDR_FILES ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Element.inl ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementDocument.h ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementInstancer.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/DataFormatter.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/DataQuery.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/DataSource.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/DataSourceListener.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementDataGrid.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementDataGridCell.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementDataGridRow.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementForm.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControl.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlInput.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlSelect.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementFormControlTextArea.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementProgressBar.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/ElementTabSet.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Elements/SelectOption.h ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementScroll.h ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementText.h ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ElementUtilities.h @@ -231,8 +264,42 @@ set(Core_SRC_FILES ${PROJECT_SOURCE_DIR}/Source/Core/ElementDefinition.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementDocument.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementHandle.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/ElementImage.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementInstancer.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/DataFormatter.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/DataQuery.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/DataSource.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/DataSourceListener.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementDataGrid.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementDataGridCell.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementDataGridExpandButton.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementDataGridRow.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementForm.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControl.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlDataSelect.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlInput.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlSelect.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementFormControlTextArea.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementImage.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementProgressBar.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTabSet.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/ElementTextSelection.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputType.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeButton.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeCheckbox.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeRadio.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeRange.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeSubmit.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/InputTypeText.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/SelectOption.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetDropDown.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetSlider.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInput.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputMultiLine.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputSingleLine.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/WidgetTextInputSingleLinePassword.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerDataGrid.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerTabSet.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/Elements/XMLNodeHandlerTextArea.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementScroll.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementStyle.cpp ${PROJECT_SOURCE_DIR}/Source/Core/ElementText.cpp @@ -323,8 +390,7 @@ set(Core_SRC_FILES ${PROJECT_SOURCE_DIR}/Source/Core/Variant.cpp ${PROJECT_SOURCE_DIR}/Source/Core/Vector3.cpp ${PROJECT_SOURCE_DIR}/Source/Core/Vector4.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/WidgetSlider.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/WidgetSliderScroll.cpp + ${PROJECT_SOURCE_DIR}/Source/Core/WidgetScroll.cpp ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandler.cpp ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerBody.cpp ${PROJECT_SOURCE_DIR}/Source/Core/XMLNodeHandlerDefault.cpp @@ -334,96 +400,11 @@ set(Core_SRC_FILES ${PROJECT_SOURCE_DIR}/Source/Core/XMLParseTools.cpp ) -set(Controls_HDR_FILES - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementTextSelection.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputType.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeButton.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeCheckbox.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeRadio.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeRange.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeSubmit.h - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeText.h - ${PROJECT_SOURCE_DIR}/Source/Controls/precompiled.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetDropDown.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetSlider.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetSliderInput.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInput.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputMultiLine.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputSingleLine.h - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputSingleLinePassword.h - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerDataGrid.h - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerTabSet.h - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerTextArea.h -) - -set(MASTER_Controls_PUB_HDR_FILES - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls.h -) - -set(Controls_PUB_HDR_FILES - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/Controls.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/DataFormatter.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/DataQuery.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/DataSource.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/DataSourceListener.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementDataGrid.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementDataGridCell.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementDataGridExpandButton.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementDataGridRow.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementForm.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementFormControl.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementFormControlDataSelect.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementFormControlInput.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementFormControlSelect.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementFormControlTextArea.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementProgressBar.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/ElementTabSet.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/Header.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/SelectOption.h -) - -set(Controls_SRC_FILES - ${PROJECT_SOURCE_DIR}/Source/Controls/Controls.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/DataFormatter.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/DataQuery.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/DataSource.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/DataSourceListener.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementDataGrid.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementDataGridCell.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementDataGridExpandButton.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementDataGridRow.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementForm.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementFormControl.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementFormControlDataSelect.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementFormControlInput.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementFormControlSelect.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementFormControlTextArea.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementProgressBar.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementTabSet.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/ElementTextSelection.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputType.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeButton.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeCheckbox.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeRadio.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeRange.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeSubmit.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/InputTypeText.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/SelectOption.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetDropDown.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetSlider.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetSliderInput.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInput.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputMultiLine.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputSingleLine.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/WidgetTextInputSingleLinePassword.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerDataGrid.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerTabSet.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/XMLNodeHandlerTextArea.cpp -) - set(Debugger_HDR_FILES ${PROJECT_SOURCE_DIR}/Source/Debugger/BeaconSource.h ${PROJECT_SOURCE_DIR}/Source/Debugger/CommonSource.h + ${PROJECT_SOURCE_DIR}/Source/Debugger/DebuggerPlugin.h + ${PROJECT_SOURCE_DIR}/Source/Debugger/DebuggerSystemInterface.h ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementContextHook.h ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementInfo.h ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementLog.h @@ -432,8 +413,6 @@ set(Debugger_HDR_FILES ${PROJECT_SOURCE_DIR}/Source/Debugger/InfoSource.h ${PROJECT_SOURCE_DIR}/Source/Debugger/LogSource.h ${PROJECT_SOURCE_DIR}/Source/Debugger/MenuSource.h - ${PROJECT_SOURCE_DIR}/Source/Debugger/Plugin.h - ${PROJECT_SOURCE_DIR}/Source/Debugger/SystemInterface.h ) set(MASTER_Debugger_PUB_HDR_FILES @@ -447,12 +426,12 @@ set(Debugger_PUB_HDR_FILES set(Debugger_SRC_FILES ${PROJECT_SOURCE_DIR}/Source/Debugger/Debugger.cpp + ${PROJECT_SOURCE_DIR}/Source/Debugger/DebuggerPlugin.cpp + ${PROJECT_SOURCE_DIR}/Source/Debugger/DebuggerSystemInterface.cpp ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementContextHook.cpp ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementInfo.cpp ${PROJECT_SOURCE_DIR}/Source/Debugger/ElementLog.cpp ${PROJECT_SOURCE_DIR}/Source/Debugger/Geometry.cpp - ${PROJECT_SOURCE_DIR}/Source/Debugger/Plugin.cpp - ${PROJECT_SOURCE_DIR}/Source/Debugger/SystemInterface.cpp ) if(NOT NO_FONT_INTERFACE_DEFAULT) @@ -480,111 +459,101 @@ if(NOT NO_FONT_INTERFACE_DEFAULT) ) endif() -set(LuaCore_HDR_FILES - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourb.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourf.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Context.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ContextDocumentsProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Document.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Element.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementAttributesProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementChildNodesProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementInstancer.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementStyleProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementText.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Event.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/EventParametersProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/GlobalLuaFunctions.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Log.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaDocument.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaDocumentElementInstancer.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaElement.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaElementInstancer.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaEventListener.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaEventListenerInstancer.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/precompiled.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/RmlUi.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/RmlUiContextsProxy.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Vector2f.h - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Vector2i.h -) - -set(LuaCore_PUB_HDR_FILES - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Lua/Header.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Lua/Interpreter.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Lua/LuaType.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Lua/Utilities.h -) - -set(LuaCore_SRC_FILES - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourb.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Colourf.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Context.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ContextDocumentsProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Document.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Element.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementAttributesProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementChildNodesProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementInstancer.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementStyleProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/ElementText.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Event.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/EventParametersProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/GlobalLuaFunctions.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Interpreter.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Log.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaDocument.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaDocumentElementInstancer.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaElementInstancer.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaEventListener.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/LuaEventListenerInstancer.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/precompiled.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/RmlUi.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/RmlUiContextsProxy.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Utilities.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Vector2f.cpp - ${PROJECT_SOURCE_DIR}/Source/Core/Lua/Vector2i.cpp -) - -set(LuaControls_HDR_FILES - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/As.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/DataFormatter.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/DataSource.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementDataGrid.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementDataGridRow.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementForm.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControl.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlDataSelect.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlInput.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlSelect.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlTextArea.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementTabSet.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/LuaDataFormatter.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/LuaDataSource.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/precompiled.h - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/SelectOptionsProxy.h +set(Lua_HDR_FILES + ${PROJECT_SOURCE_DIR}/Source/Lua/Colourb.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Colourf.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Context.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ContextDocumentsProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Document.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Element.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementAttributesProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementChildNodesProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementInstancer.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/As.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/DataFormatter.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/DataSource.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementDataGrid.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementDataGridRow.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementForm.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControl.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlDataSelect.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlInput.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlSelect.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlTextArea.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementTabSet.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/LuaDataFormatter.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/LuaDataSource.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/SelectOptionsProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementStyleProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementText.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Event.h + ${PROJECT_SOURCE_DIR}/Source/Lua/EventParametersProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/GlobalLuaFunctions.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Log.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaDocument.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaDocumentElementInstancer.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaElementInstancer.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaEventListener.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaEventListenerInstancer.h + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaPlugin.h + ${PROJECT_SOURCE_DIR}/Source/Lua/RmlUi.h + ${PROJECT_SOURCE_DIR}/Source/Lua/RmlUiContextsProxy.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Vector2f.h + ${PROJECT_SOURCE_DIR}/Source/Lua/Vector2i.h ) -set(LuaControls_PUB_HDR_FILES - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/Lua/Controls.h - ${PROJECT_SOURCE_DIR}/Include/RmlUi/Controls/Lua/Header.h +set(Lua_PUB_HDR_FILES + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Header.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/IncludeLua.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Interpreter.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Lua.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/LuaType.h + ${PROJECT_SOURCE_DIR}/Include/RmlUi/Lua/Utilities.h ) -set(LuaControls_SRC_FILES - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/Controls.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/DataFormatter.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/DataSource.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementDataGrid.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementDataGridRow.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementForm.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControl.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlDataSelect.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlInput.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlSelect.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementFormControlTextArea.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/ElementTabSet.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/LuaDataFormatter.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/LuaDataSource.cpp - ${PROJECT_SOURCE_DIR}/Source/Controls/Lua/SelectOptionsProxy.cpp +set(Lua_SRC_FILES + ${PROJECT_SOURCE_DIR}/Source/Lua/Colourb.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Colourf.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Context.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ContextDocumentsProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Document.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Element.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementAttributesProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementChildNodesProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementInstancer.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/DataFormatter.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/DataSource.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementDataGrid.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementDataGridRow.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementForm.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControl.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlDataSelect.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlInput.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlSelect.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementFormControlTextArea.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/ElementTabSet.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/LuaDataFormatter.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/LuaDataSource.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Elements/SelectOptionsProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementStyleProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/ElementText.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Event.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/EventParametersProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/GlobalLuaFunctions.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Interpreter.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Log.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Lua.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaDocument.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaDocumentElementInstancer.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaElementInstancer.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaEventListener.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaEventListenerInstancer.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaPlugin.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/LuaType.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/RmlUi.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/RmlUiContextsProxy.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Utilities.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Vector2f.cpp + ${PROJECT_SOURCE_DIR}/Source/Lua/Vector2i.cpp ) diff --git a/CMake/gen_filelists.sh b/CMake/gen_filelists.sh index b7fbe50c2..121999c44 100644 --- a/CMake/gen_filelists.sh +++ b/CMake/gen_filelists.sh @@ -50,29 +50,27 @@ printfontdefaultfiles() { printluafiles() { # Print headers - echo ${hdr/lib/Lua${1}} >>$file - find $srcpath/$1/$luapath -iname "*.h" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file + echo ${hdr/lib/Lua} >>$file + find $srcpath/$luapath$1 -iname "*.h" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file echo -e ')\n' >>$file # Print public headers - echo ${pubhdr/lib/Lua${1}} >>$file - find $hdrpath/$1/$luapath -iname "*.h" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file 2>/dev/null + echo ${pubhdr/lib/Lua} >>$file + find $hdrpath/$luapath$1 -iname "*.h" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file 2>/dev/null echo -e ')\n' >>$file # Print source files - echo ${src/lib/Lua${1}} >>$file - find $srcpath/$1/$luapath -iname "*.cpp" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file + echo ${src/lib/Lua} >>$file + find $srcpath/$luapath$1 -iname "*.cpp" -exec echo ' '$srcdir/{} \; 2>/dev/null | sort -f >>$file echo -e ')\n' >>$file } pushd $basedir echo -e "# This file was auto-generated with gen_filelists.sh\n" >$file -for lib in "Core" "Controls" "Debugger"; do +for lib in "Core" "Debugger"; do printfiles $lib done printfontdefaultfiles "Core" -for lib in "Core" "Controls"; do - printluafiles $lib -done -popd +printluafiles +popd diff --git a/CMakeLists.txt b/CMakeLists.txt index 491cb73a3..917c7b9f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,7 +238,7 @@ endif() #Lua if(BUILD_LUA_BINDINGS) - find_package(Lua) + find_package(Lua REQUIRED) if(LUA_FOUND) include_directories(${LUA_INCLUDE_DIR}) list(APPEND LUA_BINDINGS_LINK_LIBS ${LUA_LIBRARIES}) @@ -262,7 +262,7 @@ if(NOT BUILD_FRAMEWORK) # Build libraries ================== #=================================== -set(LIBRARIES Core Controls Debugger) +set(LIBRARIES Core Debugger) foreach(library ${LIBRARIES}) set(NAME Rml${library}) @@ -298,7 +298,6 @@ target_compile_definitions(RmlCore PRIVATE RMLUI_VERSION="${RMLUI_VERSION_SHORT} if (PRECOMPILED_HEADERS_ENABLED) target_precompile_headers(RmlCore PRIVATE ${PROJECT_SOURCE_DIR}/Source/Core/precompiled.h) - target_precompile_headers(RmlControls PRIVATE ${PROJECT_SOURCE_DIR}/Source/Controls/precompiled.h) endif() @@ -311,7 +310,6 @@ else(NOT BUILD_FRAMEWORK) set(MASTER_PUB_HDR_FILES ${MASTER_Core_PUB_HDR_FILES} - ${MASTER_Controls_PUB_HDR_FILES} ${MASTER_Debugger_PUB_HDR_FILES} ) @@ -320,10 +318,6 @@ else(NOT BUILD_FRAMEWORK) ${MASTER_Core_PUB_HDR_FILES} ${Core_PUB_HDR_FILES} ${Core_SRC_FILES} - ${Controls_HDR_FILES} - ${MASTER_Controls_PUB_HDR_FILES} - ${Controls_PUB_HDR_FILES} - ${Controls_SRC_FILES} ${Debugger_HDR_FILES} ${MASTER_Debugger_PUB_HDR_FILES} ${Debugger_PUB_HDR_FILES} @@ -341,9 +335,6 @@ else(NOT BUILD_FRAMEWORK) set_property(SOURCE ${Core_PUB_HDR_FILES} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Core ) - set_property(SOURCE ${Controls_PUB_HDR_FILES} - PROPERTY MACOSX_PACKAGE_LOCATION Headers/Controls - ) set_property(SOURCE ${Debugger_PUB_HDR_FILES} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Debugger ) @@ -370,30 +361,26 @@ endif(NOT BUILD_FRAMEWORK) # Build Lua bindings if(BUILD_LUA_BINDINGS) - set(LIBRARIES Core Controls) - - foreach(library ${LIBRARIES}) - set(NAME Rml${library}Lua) + set(NAME RmlLua) - add_library(${NAME} ${Lua${library}_SRC_FILES} - ${Lua${library}_HDR_FILES} - ${Lua${library}_PUB_HDR_FILES} - ) + add_library(${NAME} ${Lua_SRC_FILES} + ${Lua_HDR_FILES} + ${Lua_PUB_HDR_FILES} + ) - set_target_properties(${NAME} PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} - ) + set_target_properties(${NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) - install(TARGETS ${NAME} - EXPORT RmlUiTargets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) - - set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME}) - endforeach(library) + install(TARGETS ${NAME} + EXPORT RmlUiTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + + set(RMLUI_EXPORTED_TARGETS ${RMLUI_EXPORTED_TARGETS} ${NAME}) endif() @@ -423,7 +410,6 @@ endif() if(NOT BUILD_FRAMEWORK) target_link_libraries(RmlCore ${CORE_LINK_LIBS}) -target_link_libraries(RmlControls RmlCore) target_link_libraries(RmlDebugger RmlCore) else(NOT BUILD_FRAMEWORK) target_link_libraries(RmlUi ${CORE_LINK_LIBS}) @@ -431,11 +417,9 @@ endif(NOT BUILD_FRAMEWORK) if(BUILD_LUA_BINDINGS) if(NOT BUILD_FRAMEWORK) - target_link_libraries(RmlCoreLua RmlCore ${LUA_BINDINGS_LINK_LIBS}) - target_link_libraries(RmlControlsLua RmlControls RmlCoreLua ${LUA_BINDINGS_LINK_LIBS}) + target_link_libraries(RmlLua RmlCore ${LUA_BINDINGS_LINK_LIBS}) else(NOT BUILD_FRAMEWORK) - target_link_libraries(RmlCoreLua RmlUi ${LUA_BINDINGS_LINK_LIBS}) - target_link_libraries(RmlControlsLua RmlUi RmlCoreLua ${LUA_BINDINGS_LINK_LIBS}) + target_link_libraries(RmlLua RmlUi ${LUA_BINDINGS_LINK_LIBS}) endif(NOT BUILD_FRAMEWORK) endif() @@ -473,14 +457,13 @@ if(BUILD_SAMPLES) if(NOT BUILD_FRAMEWORK) set(sample_LIBRARIES - shell - RmlCore - RmlControls + shell + RmlCore RmlDebugger ) else(NOT BUILD_FRAMEWORK) set(sample_LIBRARIES - shell + shell RmlUi ) endif(NOT BUILD_FRAMEWORK) @@ -618,7 +601,7 @@ endif(NOT BUILD_FRAMEWORK) BUNDLE DESTINATION ${SAMPLES_DIR}) if(BUILD_LUA_BINDINGS) - bl_sample(luainvaders RmlCoreLua RmlControlsLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS}) + bl_sample(luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS}) install(DIRECTORY DESTINATION ${SAMPLES_DIR}/luainvaders) install(TARGETS luainvaders RUNTIME DESTINATION ${SAMPLES_DIR}/luainvaders diff --git a/Include/RmlUi/Controls.h b/Include/RmlUi/Controls.h deleted file mode 100644 index 86708517e..000000000 --- a/Include/RmlUi/Controls.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICONTROLS_H -#define RMLUICONTROLS_H - -#include "Controls/Controls.h" - -#include "Controls/DataFormatter.h" -#include "Controls/ElementDataGrid.h" -#include "Controls/ElementDataGridCell.h" -#include "Controls/ElementDataGridExpandButton.h" -#include "Controls/ElementDataGridRow.h" -#include "Controls/ElementForm.h" -#include "Controls/ElementFormControl.h" -#include "Controls/ElementFormControlDataSelect.h" -#include "Controls/ElementFormControlInput.h" -#include "Controls/ElementFormControlSelect.h" -#include "Controls/ElementFormControlTextArea.h" -#include "Controls/ElementProgressBar.h" -#include "Controls/ElementTabSet.h" -#include "Controls/SelectOption.h" - -#endif diff --git a/Include/RmlUi/Controls/Controls.h b/Include/RmlUi/Controls/Controls.h deleted file mode 100644 index f8f63e4d3..000000000 --- a/Include/RmlUi/Controls/Controls.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICONTROLSCONTROLS_H -#define RMLUICONTROLSCONTROLS_H - -#include "Header.h" - -namespace Rml { -namespace Controls { - -/// Registers the instancers for the custom controls. -RMLUICONTROLS_API void Initialise(); - -} -} - -#endif diff --git a/Include/RmlUi/Controls/Header.h b/Include/RmlUi/Controls/Header.h deleted file mode 100644 index 46cddc259..000000000 --- a/Include/RmlUi/Controls/Header.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICONTROLSHEADER_H -#define RMLUICONTROLSHEADER_H - -#include "../Core/Platform.h" - -#if !defined RMLUI_STATIC_LIB - #ifdef RMLUI_PLATFORM_WIN32 - #ifdef RmlControls_EXPORTS - #define RMLUICONTROLS_API __declspec(dllexport) - #else - #define RMLUICONTROLS_API __declspec(dllimport) - #endif - #else - #define RMLUICONTROLS_API __attribute__((visibility("default"))) - #endif -#else - #define RMLUICONTROLS_API -#endif - -#endif diff --git a/Include/RmlUi/Core.h b/Include/RmlUi/Core.h index f80ac87b9..c2c4f4abf 100644 --- a/Include/RmlUi/Core.h +++ b/Include/RmlUi/Core.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORE_H -#define RMLUICORE_H +#ifndef RMLUI_CORE_H +#define RMLUI_CORE_H #include "Core/Core.h" @@ -87,4 +87,19 @@ #include "Core/XMLNodeHandler.h" #include "Core/XMLParser.h" +#include "Core/Elements/DataFormatter.h" +#include "Core/Elements/ElementDataGrid.h" +#include "Core/Elements/ElementDataGridCell.h" +#include "Core/Elements/ElementDataGridExpandButton.h" +#include "Core/Elements/ElementDataGridRow.h" +#include "Core/Elements/ElementForm.h" +#include "Core/Elements/ElementFormControl.h" +#include "Core/Elements/ElementFormControlDataSelect.h" +#include "Core/Elements/ElementFormControlInput.h" +#include "Core/Elements/ElementFormControlSelect.h" +#include "Core/Elements/ElementFormControlTextArea.h" +#include "Core/Elements/ElementProgressBar.h" +#include "Core/Elements/ElementTabSet.h" +#include "Core/Elements/SelectOption.h" + #endif diff --git a/Include/RmlUi/Core/Animation.h b/Include/RmlUi/Core/Animation.h index 706e82db9..7b917e72b 100644 --- a/Include/RmlUi/Core/Animation.h +++ b/Include/RmlUi/Core/Animation.h @@ -25,15 +25,14 @@ * */ -#ifndef RMLUICOREANIMATION_H -#define RMLUICOREANIMATION_H +#ifndef RMLUI_CORE_ANIMATION_H +#define RMLUI_CORE_ANIMATION_H #include "Types.h" #include "Tween.h" #include "ID.h" namespace Rml { -namespace Core { /* Data parsed from the 'animation' property. */ struct Animation { @@ -72,7 +71,5 @@ inline bool operator!=(const Transition& a, const Transition& b) { return !(a == inline bool operator==(const TransitionList& a, const TransitionList& b) { return a.none == b.none && a.all == b.all && a.transitions == b.transitions; } inline bool operator!=(const TransitionList& a, const TransitionList& b) { return !(a == b); } -} -} - -#endif \ No newline at end of file +} // namespace Rml +#endif diff --git a/Include/RmlUi/Core/BaseXMLParser.h b/Include/RmlUi/Core/BaseXMLParser.h index e3b5ae3e7..3238b3eb1 100644 --- a/Include/RmlUi/Core/BaseXMLParser.h +++ b/Include/RmlUi/Core/BaseXMLParser.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREBASEXMLPARSER_H -#define RMLUICOREBASEXMLPARSER_H +#ifndef RMLUI_CORE_BASEXMLPARSER_H +#define RMLUI_CORE_BASEXMLPARSER_H #include "Header.h" #include "Types.h" #include "Dictionary.h" namespace Rml { -namespace Core { class Stream; class URL; @@ -136,7 +135,5 @@ class RMLUICORE_API BaseXMLParser SmallUnorderedSet< String > attributes_for_inner_xml_data; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Box.h b/Include/RmlUi/Core/Box.h index 36eff7112..eaecfbb22 100644 --- a/Include/RmlUi/Core/Box.h +++ b/Include/RmlUi/Core/Box.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREBOX_H -#define RMLUICOREBOX_H +#ifndef RMLUI_CORE_BOX_H +#define RMLUI_CORE_BOX_H #include "Types.h" namespace Rml { -namespace Core { /** Stores a box with four sized areas; content, padding, a border and margin. See @@ -119,7 +118,5 @@ class RMLUICORE_API Box Vector2f offset; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Colour.h b/Include/RmlUi/Core/Colour.h index 44151d73f..311365cc2 100644 --- a/Include/RmlUi/Core/Colour.h +++ b/Include/RmlUi/Core/Colour.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORECOLOUR_H -#define RMLUICORECOLOUR_H +#ifndef RMLUI_CORE_COLOUR_H +#define RMLUI_CORE_COLOUR_H #include "Header.h" namespace Rml { -namespace Core { /** Templated class for a four-component RGBA colour. @@ -112,8 +111,7 @@ class Colour ColourType red, green, blue, alpha; }; -} -} +} // namespace Rml #include "Colour.inl" diff --git a/Include/RmlUi/Core/Colour.inl b/Include/RmlUi/Core/Colour.inl index 0e97081ab..049a5f3df 100644 --- a/Include/RmlUi/Core/Colour.inl +++ b/Include/RmlUi/Core/Colour.inl @@ -27,7 +27,6 @@ */ namespace Rml { -namespace Core { // Lightweight, non-initialising constructor. template < typename ColourType, int AlphaDefault > @@ -120,5 +119,4 @@ void RMLUICORE_API Colour< float, 1 >::operator*=(const Colour& rhs); template < > void RMLUICORE_API Colour< byte, 255 >::operator*=(const Colour& rhs); -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/ComputedValues.h b/Include/RmlUi/Core/ComputedValues.h index f284d2e9c..85634dc4c 100644 --- a/Include/RmlUi/Core/ComputedValues.h +++ b/Include/RmlUi/Core/ComputedValues.h @@ -25,14 +25,13 @@ * */ -#ifndef RMLUICORECOMPUTEDVALUES_H -#define RMLUICORECOMPUTEDVALUES_H +#ifndef RMLUI_CORE_COMPUTEDVALUES_H +#define RMLUI_CORE_COMPUTEDVALUES_H #include "Types.h" #include "Animation.h" namespace Rml { -namespace Core { namespace Style { @@ -221,7 +220,5 @@ RMLUICORE_API float ResolveValue(Style::LengthPercentage length, float base_valu using ComputedValues = Style::ComputedValues; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Containers/robin_hood.h b/Include/RmlUi/Core/Containers/robin_hood.h index 28fb514b6..4e93d6817 100644 --- a/Include/RmlUi/Core/Containers/robin_hood.h +++ b/Include/RmlUi/Core/Containers/robin_hood.h @@ -332,7 +332,7 @@ void doThrow(Args&&... args) { #else void doThrow(Args&&... ROBIN_HOOD_UNUSED(args) /*unused*/) { abort(); -} +} // namespace Rml #endif template diff --git a/Include/RmlUi/Core/Context.h b/Include/RmlUi/Core/Context.h index 42a563a4b..05474680c 100644 --- a/Include/RmlUi/Core/Context.h +++ b/Include/RmlUi/Core/Context.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORECONTEXT_H -#define RMLUICORECONTEXT_H +#ifndef RMLUI_CORE_CONTEXT_H +#define RMLUI_CORE_CONTEXT_H #include "Header.h" #include "Types.h" @@ -36,7 +36,6 @@ #include "ScriptInterface.h" namespace Rml { -namespace Core { class Stream; class ContextInstancer; @@ -57,7 +56,7 @@ enum class EventId : uint16_t; class RMLUICORE_API Context : public ScriptInterface { public: - /// Constructs a new, uninitialised context. This should not be called directly, use Core::CreateContext() + /// Constructs a new, uninitialised context. This should not be called directly, use CreateContext() /// instead. /// @param[in] name The name of the context. Context(const String& name); @@ -351,7 +350,5 @@ class RMLUICORE_API Context : public ScriptInterface friend RMLUICORE_API Context* CreateContext(const String&, const Vector2i&, RenderInterface*); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ContextInstancer.h b/Include/RmlUi/Core/ContextInstancer.h index bdd1bf46d..a97549e63 100644 --- a/Include/RmlUi/Core/ContextInstancer.h +++ b/Include/RmlUi/Core/ContextInstancer.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORECONTEXTINSTANCER_H -#define RMLUICORECONTEXTINSTANCER_H +#ifndef RMLUI_CORE_CONTEXTINSTANCER_H +#define RMLUI_CORE_CONTEXTINSTANCER_H #include "Header.h" #include "Traits.h" #include "Types.h" namespace Rml { -namespace Core { class Context; class Event; @@ -64,7 +63,5 @@ class RMLUICORE_API ContextInstancer : public Releasable virtual void Release() = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ConvolutionFilter.h b/Include/RmlUi/Core/ConvolutionFilter.h index bb985aa02..af2cf6c00 100644 --- a/Include/RmlUi/Core/ConvolutionFilter.h +++ b/Include/RmlUi/Core/ConvolutionFilter.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORECONVOLUTIONFILTER_H -#define RMLUICORECONVOLUTIONFILTER_H +#ifndef RMLUI_CORE_CONVOLUTIONFILTER_H +#define RMLUI_CORE_CONVOLUTIONFILTER_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { enum class FilterOperation { // The result is the sum of all the filtered pixels. @@ -95,8 +94,6 @@ class RMLUICORE_API ConvolutionFilter FilterOperation operation = FilterOperation::Sum; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Core.h b/Include/RmlUi/Core/Core.h index 3aaf9912d..0ee12af3f 100644 --- a/Include/RmlUi/Core/Core.h +++ b/Include/RmlUi/Core/Core.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORECORE_H -#define RMLUICORECORE_H +#ifndef RMLUI_CORE_CORE_H +#define RMLUI_CORE_CORE_H #include "Header.h" #include "Types.h" @@ -35,7 +35,6 @@ #include "ComputedValues.h" namespace Rml { -namespace Core { class Plugin; class Context; @@ -63,7 +62,7 @@ RMLUICORE_API String GetVersion(); /// Sets the interface through which all system requests are made. This must be called before Initialise(). /// @param[in] system_interface A non-owning pointer to the application-specified logging interface. -/// @lifetime The interface must be kept alive until after the call to Core::Shutdown. +/// @lifetime The interface must be kept alive until after the call to Rml::Shutdown. RMLUICORE_API void SetSystemInterface(SystemInterface* system_interface); /// Returns RmlUi's system interface. RMLUICORE_API SystemInterface* GetSystemInterface(); @@ -72,7 +71,7 @@ RMLUICORE_API SystemInterface* GetSystemInterface(); /// it must be called before Initialise(). If no render interface is specified, then all contexts must have a custom /// render interface. /// @param[in] render_interface A non-owning pointer to the render interface implementation. -/// @lifetime The interface must be kept alive until after the call to Core::Shutdown. +/// @lifetime The interface must be kept alive until after the call to Rml::Shutdown. RMLUICORE_API void SetRenderInterface(RenderInterface* render_interface); /// Returns RmlUi's default's render interface. RMLUICORE_API RenderInterface* GetRenderInterface(); @@ -80,7 +79,7 @@ RMLUICORE_API RenderInterface* GetRenderInterface(); /// Sets the interface through which all file I/O requests are made. This is not required to be called, but if it is it /// must be called before Initialise(). /// @param[in] file_interface A non-owning pointer to the application-specified file interface. -/// @lifetime The interface must be kept alive until after the call to Core::Shutdown. +/// @lifetime The interface must be kept alive until after the call to Rml::Shutdown. RMLUICORE_API void SetFileInterface(FileInterface* file_interface); /// Returns RmlUi's file interface. RMLUICORE_API FileInterface* GetFileInterface(); @@ -88,7 +87,7 @@ RMLUICORE_API FileInterface* GetFileInterface(); /// Sets the interface through which all font requests are made. This is not required to be called, but if it is /// it must be called before Initialise(). /// @param[in] font_interface A non-owning pointer to the application-specified font engine interface. -/// @lifetime The interface must be kept alive until after the call to Core::Shutdown. +/// @lifetime The interface must be kept alive until after the call to Rml::Shutdown. RMLUICORE_API void SetFontEngineInterface(FontEngineInterface* font_interface); /// Returns RmlUi's font interface. RMLUICORE_API FontEngineInterface* GetFontEngineInterface(); @@ -97,7 +96,7 @@ RMLUICORE_API FontEngineInterface* GetFontEngineInterface(); /// @param[in] name The new name of the context. This must be unique. /// @param[in] dimensions The initial dimensions of the new context. /// @param[in] render_interface The custom render interface to use, or nullptr to use the default. -/// @lifetime If specified, the render interface must be kept alive until after the context is destroyed or the call to Core::Shutdown. +/// @lifetime If specified, the render interface must be kept alive until after the context is destroyed or the call to Rml::Shutdown. /// @return A non-owning pointer to the new context, or nullptr if the context could not be created. RMLUICORE_API Context* CreateContext(const String& name, const Vector2i& dimensions, RenderInterface* render_interface = nullptr); /// Removes and destroys a context. @@ -147,7 +146,6 @@ RMLUICORE_API void ReleaseTextures(); /// Forces all compiled geometry handles generated by RmlUi to be released. RMLUICORE_API void ReleaseCompiledGeometry(); -} -} +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataController.h b/Include/RmlUi/Core/DataController.h index 3fc5fe81b..2d2a43fa3 100644 --- a/Include/RmlUi/Core/DataController.h +++ b/Include/RmlUi/Core/DataController.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATACONTROLLER_H -#define RMLUICOREDATACONTROLLER_H +#ifndef RMLUI_CORE_DATACONTROLLER_H +#define RMLUI_CORE_DATACONTROLLER_H #include "Header.h" #include "Types.h" @@ -35,7 +35,6 @@ #include namespace Rml { -namespace Core { class Element; class DataModel; @@ -117,7 +116,5 @@ class RMLUICORE_API DataControllers : NonCopyMoveable { }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataModel.h b/Include/RmlUi/Core/DataModel.h index f7b16e942..772f4943e 100644 --- a/Include/RmlUi/Core/DataModel.h +++ b/Include/RmlUi/Core/DataModel.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATAMODEL_H -#define RMLUICOREDATAMODEL_H +#ifndef RMLUI_CORE_DATAMODEL_H +#define RMLUI_CORE_DATAMODEL_H #include "Header.h" #include "Types.h" @@ -36,7 +36,6 @@ #include "DataTypeRegister.h" namespace Rml { -namespace Core { class DataViews; class DataControllers; @@ -189,7 +188,5 @@ class RMLUICORE_API DataModelConstructor { DataTypeRegister* type_register; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataTypeRegister.h b/Include/RmlUi/Core/DataTypeRegister.h index a4f68abaa..eea707da4 100644 --- a/Include/RmlUi/Core/DataTypeRegister.h +++ b/Include/RmlUi/Core/DataTypeRegister.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATATYPEREGISTER_H -#define RMLUICOREDATATYPEREGISTER_H +#ifndef RMLUI_CORE_DATATYPEREGISTER_H +#define RMLUI_CORE_DATATYPEREGISTER_H #include "Header.h" #include "Types.h" @@ -38,8 +38,6 @@ namespace Rml { -namespace Core { - template struct is_valid_data_scalar { @@ -202,7 +200,5 @@ inline StructHandle& StructHandle::RegisterMemberFunc(const Stri return *this; } -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataTypes.h b/Include/RmlUi/Core/DataTypes.h index f17b20f65..28be11bd5 100644 --- a/Include/RmlUi/Core/DataTypes.h +++ b/Include/RmlUi/Core/DataTypes.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREDATADEFINITIONS_H -#define RMLUICOREDATADEFINITIONS_H +#ifndef RMLUI_CORE_DATADEFINITIONS_H +#define RMLUI_CORE_DATADEFINITIONS_H #include "Header.h" #include "Types.h" #include namespace Rml { -namespace Core { class VariableDefinition; class DataTypeRegister; @@ -60,7 +59,5 @@ struct DataAddressEntry { }; using DataAddress = std::vector; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataVariable.h b/Include/RmlUi/Core/DataVariable.h index a4efd1eb8..413247723 100644 --- a/Include/RmlUi/Core/DataVariable.h +++ b/Include/RmlUi/Core/DataVariable.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATAVARIABLE_H -#define RMLUICOREDATAVARIABLE_H +#ifndef RMLUI_CORE_DATAVARIABLE_H +#define RMLUI_CORE_DATAVARIABLE_H #include "Header.h" #include "Types.h" @@ -37,8 +37,6 @@ #include namespace Rml { -namespace Core { - enum class DataVariableType { Scalar, Array, Struct, Function, MemberFunction }; @@ -263,7 +261,5 @@ class MemberFuncDefinition final : public VariableDefinition { MemberSetFunc set; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DataView.h b/Include/RmlUi/Core/DataView.h index a175a924b..7b965b291 100644 --- a/Include/RmlUi/Core/DataView.h +++ b/Include/RmlUi/Core/DataView.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATAVIEW_H -#define RMLUICOREDATAVIEW_H +#ifndef RMLUI_CORE_DATAVIEW_H +#define RMLUI_CORE_DATAVIEW_H #include "Header.h" #include "Types.h" @@ -36,7 +36,6 @@ #include namespace Rml { -namespace Core { class Element; class DataModel; @@ -129,7 +128,5 @@ class RMLUICORE_API DataViews : NonCopyMoveable { NameViewMap name_view_map; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Debug.h b/Include/RmlUi/Core/Debug.h index b82f4e30c..354e33a5a 100644 --- a/Include/RmlUi/Core/Debug.h +++ b/Include/RmlUi/Core/Debug.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDEBUG_H -#define RMLUICOREDEBUG_H +#ifndef RMLUI_CORE_DEBUG_H +#define RMLUI_CORE_DEBUG_H #include "Header.h" @@ -47,7 +47,7 @@ #define RMLUI_BREAK #endif #elif defined (RMLUI_PLATFORM_MACOSX) - #define RMLUI_BREAK {__builtin_trap();} + #define RMLUI_BREAK {__builtin_trap();} // namespace Rml #endif @@ -62,13 +62,12 @@ #define RMLUI_ASSERT_NONRECURSIVE #else namespace Rml { -namespace Core { bool RMLUICORE_API Assert(const char* message, const char* file, int line); #define RMLUI_ASSERT(x) \ if (!(x)) \ { \ - if (!Rml::Core::Assert("RMLUI_ASSERT("#x")", __FILE__, __LINE__ )) \ + if (!(::Rml::Assert("RMLUI_ASSERT("#x")", __FILE__, __LINE__ ))) \ { \ RMLUI_BREAK; \ } \ @@ -76,18 +75,18 @@ if (!(x)) \ #define RMLUI_ASSERTMSG(x, m) \ if (!(x)) \ { \ - if (!Rml::Core::Assert(m, __FILE__, __LINE__ )) \ + if (!(::Rml::Assert(m, __FILE__, __LINE__ ))) \ { \ RMLUI_BREAK; \ } \ } #define RMLUI_ERROR \ -if (!Rml::Core::Assert("RMLUI_ERROR", __FILE__, __LINE__)) \ +if (!(::Rml::Assert("RMLUI_ERROR", __FILE__, __LINE__))) \ { \ RMLUI_BREAK; \ } #define RMLUI_ERRORMSG(m) \ -if (!Rml::Core::Assert(m, __FILE__, __LINE__)) \ +if (!(::Rml::Assert(m, __FILE__, __LINE__))) \ { \ RMLUI_BREAK; \ } @@ -108,8 +107,7 @@ struct RmlUiAssertNonrecursive { static bool rmlui_nonrecursive_entered = false; \ RmlUiAssertNonrecursive rmlui_nonrecursive(rmlui_nonrecursive_entered) -} -} +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Decorator.h b/Include/RmlUi/Core/Decorator.h index a66fb6438..5484861d5 100644 --- a/Include/RmlUi/Core/Decorator.h +++ b/Include/RmlUi/Core/Decorator.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDECORATOR_H -#define RMLUICOREDECORATOR_H +#ifndef RMLUI_CORE_DECORATOR_H +#define RMLUI_CORE_DECORATOR_H #include #include "Header.h" @@ -35,7 +35,6 @@ #include "Types.h" namespace Rml { -namespace Core { class DecoratorInstancer; class Element; @@ -95,7 +94,5 @@ class RMLUICORE_API Decorator std::vector< Texture > additional_textures; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/DecoratorInstancer.h b/Include/RmlUi/Core/DecoratorInstancer.h index 6abce1e65..08656d7c2 100644 --- a/Include/RmlUi/Core/DecoratorInstancer.h +++ b/Include/RmlUi/Core/DecoratorInstancer.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREDECORATORINSTANCER_H -#define RMLUICOREDECORATORINSTANCER_H +#ifndef RMLUI_CORE_DECORATORINSTANCER_H +#define RMLUI_CORE_DECORATORINSTANCER_H #include "Header.h" #include "PropertyDictionary.h" #include "PropertySpecification.h" namespace Rml { -namespace Core { struct Sprite; class StyleSheet; @@ -96,7 +95,5 @@ class RMLUICORE_API DecoratorInstancerInterface { const StyleSheet& style_sheet; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Dictionary.h b/Include/RmlUi/Core/Dictionary.h index be060a593..d5c12407c 100644 --- a/Include/RmlUi/Core/Dictionary.h +++ b/Include/RmlUi/Core/Dictionary.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREDICTIONARY_H -#define RMLUICOREDICTIONARY_H +#ifndef RMLUI_CORE_DICTIONARY_H +#define RMLUI_CORE_DICTIONARY_H #include "Header.h" #include "Variant.h" namespace Rml { -namespace Core { inline Variant* GetIf(Dictionary& dictionary, const String& key) { @@ -59,7 +58,5 @@ inline T Get(const Dictionary& dictionary, const String& key, const T& default_v return result; } -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Element.h b/Include/RmlUi/Core/Element.h index 34a8a036f..57f3414ad 100644 --- a/Include/RmlUi/Core/Element.h +++ b/Include/RmlUi/Core/Element.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREELEMENT_H -#define RMLUICOREELEMENT_H +#ifndef RMLUI_CORE_ELEMENT_H +#define RMLUI_CORE_ELEMENT_H #include "ScriptInterface.h" #include "Header.h" @@ -41,7 +41,6 @@ #include "Tween.h" namespace Rml { -namespace Core { class Context; class DataModel; @@ -740,8 +739,7 @@ class RMLUICORE_API Element : public ScriptInterface, public EnableObserverPtr @@ -60,5 +59,4 @@ T Element::GetAttribute(const String& name, const T& default_value) const return Get(attributes, name, default_value); } -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/ElementDocument.h b/Include/RmlUi/Core/ElementDocument.h index e4c3bd22f..c035dc9fd 100644 --- a/Include/RmlUi/Core/ElementDocument.h +++ b/Include/RmlUi/Core/ElementDocument.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREELEMENTDOCUMENT_H -#define RMLUICOREELEMENTDOCUMENT_H +#ifndef RMLUI_CORE_ELEMENTDOCUMENT_H +#define RMLUI_CORE_ELEMENTDOCUMENT_H #include "Element.h" namespace Rml { -namespace Core { class Context; class Stream; @@ -181,7 +180,5 @@ class RMLUICORE_API ElementDocument : public Element }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ElementInstancer.h b/Include/RmlUi/Core/ElementInstancer.h index 2ad34899e..6fce5fbc7 100644 --- a/Include/RmlUi/Core/ElementInstancer.h +++ b/Include/RmlUi/Core/ElementInstancer.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREELEMENTINSTANCER_H -#define RMLUICOREELEMENTINSTANCER_H +#ifndef RMLUI_CORE_ELEMENTINSTANCER_H +#define RMLUI_CORE_ELEMENTINSTANCER_H #include "Traits.h" #include "Types.h" @@ -36,7 +36,6 @@ #include "Profiling.h" namespace Rml { -namespace Core { class Element; @@ -127,7 +126,5 @@ class ElementInstancerGeneric : public ElementInstancer } }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ElementScroll.h b/Include/RmlUi/Core/ElementScroll.h index 25e53a2bc..f9ace26e2 100644 --- a/Include/RmlUi/Core/ElementScroll.h +++ b/Include/RmlUi/Core/ElementScroll.h @@ -26,16 +26,15 @@ * */ -#ifndef RMLUICOREELEMENTSCROLL_H -#define RMLUICOREELEMENTSCROLL_H +#ifndef RMLUI_CORE_ELEMENTSCROLL_H +#define RMLUI_CORE_ELEMENTSCROLL_H #include "Header.h" namespace Rml { -namespace Core { class Element; -class WidgetSliderScroll; +class WidgetScroll; /** Manages an element's scrollbars and scrolling state. @@ -92,7 +91,7 @@ class RMLUICORE_API ElementScroll ~Scrollbar(); Element* element; - WidgetSliderScroll* widget; + WidgetScroll* widget; bool enabled; float size; }; @@ -108,7 +107,5 @@ class RMLUICORE_API ElementScroll Element* corner; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ElementText.h b/Include/RmlUi/Core/ElementText.h index e1da8c250..5743e403b 100644 --- a/Include/RmlUi/Core/ElementText.h +++ b/Include/RmlUi/Core/ElementText.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREELEMENTTEXT_H -#define RMLUICOREELEMENTTEXT_H +#ifndef RMLUI_CORE_ELEMENTTEXT_H +#define RMLUI_CORE_ELEMENTTEXT_H #include "Header.h" #include "Types.h" #include "Element.h" namespace Rml { -namespace Core { /** RmlUi's text-element interface. @@ -86,7 +85,5 @@ class RMLUICORE_API ElementText : public Element virtual void SuppressAutoLayout() = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ElementUtilities.h b/Include/RmlUi/Core/ElementUtilities.h index cfd3b3dfd..9986f5b11 100644 --- a/Include/RmlUi/Core/ElementUtilities.h +++ b/Include/RmlUi/Core/ElementUtilities.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREELEMENTUTILITIES_H -#define RMLUICOREELEMENTUTILITIES_H +#ifndef RMLUI_CORE_ELEMENTUTILITIES_H +#define RMLUI_CORE_ELEMENTUTILITIES_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { class Box; class Context; @@ -144,7 +143,5 @@ class RMLUICORE_API ElementUtilities static bool ApplyStructuralDataViews(Element* element, const String& inner_rml); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/DataFormatter.h b/Include/RmlUi/Core/Elements/DataFormatter.h similarity index 80% rename from Include/RmlUi/Controls/DataFormatter.h rename to Include/RmlUi/Core/Elements/DataFormatter.h index 4a045dcfa..495104c92 100644 --- a/Include/RmlUi/Controls/DataFormatter.h +++ b/Include/RmlUi/Core/Elements/DataFormatter.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSDATAFORMATTER_H -#define RMLUICONTROLSDATAFORMATTER_H +#ifndef RMLUI_CORE_ELEMENTS_DATAFORMATTER_H +#define RMLUI_CORE_ELEMENTS_DATAFORMATTER_H -#include "../Core/Types.h" -#include "../Core/ScriptInterface.h" -#include "Header.h" +#include "../Types.h" +#include "../ScriptInterface.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** Abstract base class for a data formatter. A data formatter takes raw data @@ -44,34 +43,32 @@ namespace Controls { @author Robert Curry */ -class RMLUICONTROLS_API DataFormatter +class RMLUICORE_API DataFormatter { public: - DataFormatter(const Rml::Core::String& name = ""); + DataFormatter(const String& name = ""); virtual ~DataFormatter(); /// Returns the name by which this data formatter is referenced by. /// @return The name of this data formatter. - const Rml::Core::String& GetDataFormatterName(); + const String& GetDataFormatterName(); /// Returns a data formatter with the given name. /// @parameter [in] data_formatter_name The name of the data formatter to /// be returned. /// @return If the data formatter with the specified name has been /// constructed, a pointer to it will be returned. Otherwise, nullptr. - static DataFormatter* GetDataFormatter(const Rml::Core::String& data_formatter_name); + static DataFormatter* GetDataFormatter(const String& data_formatter_name); /// Formats the raw results of a data source request into RML. /// @param[out] formatted_data The formatted RML. /// @param[in] raw_data A list of the raw data fields. - virtual void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) = 0; + virtual void FormatData(String& formatted_data, const StringList& raw_data) = 0; virtual void* GetScriptObject() const; private: - Rml::Core::String name; + String name; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/DataQuery.h b/Include/RmlUi/Core/Elements/DataQuery.h similarity index 67% rename from Include/RmlUi/Controls/DataQuery.h rename to Include/RmlUi/Core/Elements/DataQuery.h index 04d4e9891..eea294aa3 100644 --- a/Include/RmlUi/Controls/DataQuery.h +++ b/Include/RmlUi/Core/Elements/DataQuery.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSDATAQUERY_H -#define RMLUICONTROLSDATAQUERY_H +#ifndef RMLUI_CORE_ELEMENTS_DATAQUERY_H +#define RMLUI_CORE_ELEMENTS_DATAQUERY_H -#include "Header.h" -#include "../Core/TypeConverter.h" -#include "../Core/Log.h" +#include "../Header.h" +#include "../TypeConverter.h" +#include "../Log.h" namespace Rml { -namespace Controls { class DataSource; @@ -46,25 +45,25 @@ class DataSource; mechanisms to iterate through the returned rows. */ -class RMLUICONTROLS_API DataQuery +class RMLUICORE_API DataQuery { public: DataQuery(); - DataQuery(DataSource* data_source, const Rml::Core::String& table, const Rml::Core::String& fields, int offset = 0, int limit = -1, const Rml::Core::String& order = ""); + DataQuery(DataSource* data_source, const String& table, const String& fields, int offset = 0, int limit = -1, const String& order = ""); virtual ~DataQuery(); - void ExecuteQuery(DataSource* data_source, const Rml::Core::String& table, const Rml::Core::String& fields, int offset = 0, int limit = -1, const Rml::Core::String& order = ""); + void ExecuteQuery(DataSource* data_source, const String& table, const String& fields, int offset = 0, int limit = -1, const String& order = ""); bool NextRow(); - bool IsFieldSet(const Rml::Core::String& field) const; + bool IsFieldSet(const String& field) const; template< typename T > - T Get(const Rml::Core::String& field_name, const T& default_value) const + T Get(const String& field_name, const T& default_value) const { FieldIndices::const_iterator itr = field_indices.find(field_name); if (itr == field_indices.end()) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Field %s not found in query", field_name.c_str()); + Log::Message(Log::LT_ERROR, "Field %s not found in query", field_name.c_str()); return default_value; } @@ -76,12 +75,12 @@ class RMLUICONTROLS_API DataQuery } template< typename T > - bool GetInto(const Rml::Core::String& field_name, T& value) const + bool GetInto(const String& field_name, T& value) const { FieldIndices::const_iterator itr = field_indices.find(field_name); if (itr == field_indices.end()) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Field %s not found in query", field_name.c_str()); + Log::Message(Log::LT_ERROR, "Field %s not found in query", field_name.c_str()); return false; } @@ -103,7 +102,7 @@ class RMLUICONTROLS_API DataQuery { if (field_index < rows[current_row].size()) { - return Rml::Core::TypeConverter< Rml::Core::String, T >::Convert(rows[current_row][field_index], value); + return TypeConverter< String, T >::Convert(rows[current_row][field_index], value); } return false; @@ -115,23 +114,21 @@ class RMLUICONTROLS_API DataQuery } private: - Rml::Core::StringList fields; + StringList fields; DataSource* data_source; - Rml::Core::String table; + String table; int current_row; int offset; int limit; - typedef std::vector< Rml::Core::StringList > Rows; + typedef std::vector< StringList > Rows; Rows rows; - typedef Core::UnorderedMap< Rml::Core::String, size_t > FieldIndices; + typedef UnorderedMap< String, size_t > FieldIndices; FieldIndices field_indices; void LoadRow(); }; -} -} - -#endif // RMLUICONTROLSDATAQUERY_H +} // namespace Rml +#endif // RMLUI_CORE_ELEMENTS_DATAQUERY_H diff --git a/Include/RmlUi/Controls/DataSource.h b/Include/RmlUi/Core/Elements/DataSource.h similarity index 73% rename from Include/RmlUi/Controls/DataSource.h rename to Include/RmlUi/Core/Elements/DataSource.h index 55ed1da4d..d3f2f08d9 100644 --- a/Include/RmlUi/Controls/DataSource.h +++ b/Include/RmlUi/Core/Elements/DataSource.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSDATASOURCE_H -#define RMLUICONTROLSDATASOURCE_H +#ifndef RMLUI_CORE_ELEMENTS_DATASOURCE_H +#define RMLUI_CORE_ELEMENTS_DATASOURCE_H -#include "Header.h" -#include "../Core/Types.h" +#include "../Header.h" +#include "../Types.h" #include namespace Rml { -namespace Controls { class DataSourceListener; @@ -43,71 +42,69 @@ class DataSourceListener; @author Robert Curry */ -class RMLUICONTROLS_API DataSource +class RMLUICORE_API DataSource { public: - DataSource(const Rml::Core::String& name = ""); + DataSource(const String& name = ""); virtual ~DataSource(); - const Rml::Core::String& GetDataSourceName(); - static DataSource* GetDataSource(const Rml::Core::String& data_source_name); + const String& GetDataSourceName(); + static DataSource* GetDataSource(const String& data_source_name); /// Fetches the contents of one row of a table within the data source. /// @param[out] row The list of values in the table. /// @param[in] table The name of the table to query. /// @param[in] row_index The index of the desired row. /// @param[in] columns The list of desired columns within the row. - virtual void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) = 0; + virtual void GetRow(StringList& row, const String& table, int row_index, const StringList& columns) = 0; /// Fetches the number of rows within one of this data source's tables. /// @param[in] table The name of the table to query. /// @return The number of rows within the specified table. - virtual int GetNumRows(const Rml::Core::String& table) = 0; + virtual int GetNumRows(const String& table) = 0; void AttachListener(DataSourceListener* listener); void DetachListener(DataSourceListener* listener); virtual void* GetScriptObject() const; - static const Rml::Core::String CHILD_SOURCE; - static const Rml::Core::String DEPTH; - static const Rml::Core::String NUM_CHILDREN; + static const String CHILD_SOURCE; + static const String DEPTH; + static const String NUM_CHILDREN; protected: /// Tells all attached listeners that one or more rows have been added to the data source. /// @param[in] table The name of the table to have rows added to it. /// @param[in] first_row_added The index of the first row added. /// @param[in] num_rows_added The number of rows added (including the first row). - void NotifyRowAdd(const Rml::Core::String& table, int first_row_added, int num_rows_added); + void NotifyRowAdd(const String& table, int first_row_added, int num_rows_added); /// Tells all attached listeners that one or more rows have been removed from the data source. /// @param[in] table The name of the table to have rows removed from it. /// @param[in] first_row_removed The index of the first row removed. /// @param[in] num_rows_removed The number of rows removed (including the first row). - void NotifyRowRemove(const Rml::Core::String& table, int first_row_removed, int num_rows_removed); + void NotifyRowRemove(const String& table, int first_row_removed, int num_rows_removed); /// Tells all attached listeners that one or more rows have been changed in the data source. /// @param[in] table The name of the table to have rows changed in it. /// @param[in] first_row_changed The index of the first row changed. /// @param[in] num_rows_changed The number of rows changed (including the first row). - void NotifyRowChange(const Rml::Core::String& table, int first_row_changed, int num_rows_changed); + void NotifyRowChange(const String& table, int first_row_changed, int num_rows_changed); /// Tells all attached listeners that the row structure has completely changed in the data source. /// @param[in] table The name of the table to have rows changed in it. - void NotifyRowChange(const Rml::Core::String& table); + void NotifyRowChange(const String& table); /// Helper function for building a result set. - typedef Core::UnorderedMap< Rml::Core::String, Rml::Core::String > RowMap; - void BuildRowEntries(Rml::Core::StringList& row, const RowMap& row_map, const Rml::Core::StringList& columns); + typedef UnorderedMap< String, String > RowMap; + void BuildRowEntries(StringList& row, const RowMap& row_map, const StringList& columns); private: - Core::String name; + String name; using ListenerList = std::list< DataSourceListener* >; ListenerList listeners; }; -} -} - -#endif // RMLUICONTROLSDATASOURCE_H +} // namespace Rml +#endif // RMLUI_CORE_ELEMENTS_DATASOURCE_H diff --git a/Include/RmlUi/Controls/DataSourceListener.h b/Include/RmlUi/Core/Elements/DataSourceListener.h similarity index 77% rename from Include/RmlUi/Controls/DataSourceListener.h rename to Include/RmlUi/Core/Elements/DataSourceListener.h index 58a48c617..c0394d03b 100644 --- a/Include/RmlUi/Controls/DataSourceListener.h +++ b/Include/RmlUi/Core/Elements/DataSourceListener.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSDATASOURCELISTENER_H -#define RMLUICONTROLSDATASOURCELISTENER_H +#ifndef RMLUI_CORE_ELEMENTS_DATASOURCELISTENER_H +#define RMLUI_CORE_ELEMENTS_DATASOURCELISTENER_H -#include "Header.h" -#include "../Core/Types.h" +#include "../Header.h" +#include "../Types.h" namespace Rml { -namespace Controls { class DataSource; @@ -44,7 +43,7 @@ class DataSource; @author Robert Curry */ -class RMLUICONTROLS_API DataSourceListener +class RMLUICORE_API DataSourceListener { public: DataSourceListener(); @@ -58,35 +57,32 @@ class RMLUICONTROLS_API DataSourceListener /// @param[in] table The name of the changing table within the data source. /// @param[in] first_row_added Index of the first new row. /// @param[in] num_rows_added Number of new sequential rows being added. - virtual void OnRowAdd(DataSource* data_source, const Rml::Core::String& table, int first_row_added, int num_rows_added); + virtual void OnRowAdd(DataSource* data_source, const String& table, int first_row_added, int num_rows_added); /// Notification of the removal of one or more rows from an observed data source's table. /// @param[in] data_source Data source being changed. /// @param[in] table The name of the changing table within the data source. /// @param[in] first_row_removed Index of the first removed row. /// @param[in] num_rows_removed Number of new sequential rows being removed. - virtual void OnRowRemove(DataSource* data_source, const Rml::Core::String& table, int first_row_removed, int num_rows_removed); + virtual void OnRowRemove(DataSource* data_source, const String& table, int first_row_removed, int num_rows_removed); /// Notification of the changing of one or more rows from an observed data source's table. /// @param[in] data_source Data source being changed. /// @param[in] table The name of the changing table within the data source. /// @param[in] first_row_removed Index of the first changed row. /// @param[in] num_rows_removed Number of new sequential rows being changed. - virtual void OnRowChange(DataSource* data_source, const Rml::Core::String& table, int first_row_changed, int num_rows_changed); + virtual void OnRowChange(DataSource* data_source, const String& table, int first_row_changed, int num_rows_changed); /// Notification of the change of all of the data of an observed data source's table. /// @param[in] data_source Data source being changed. /// @param[in] table The name of the changing table within the data source. - virtual void OnRowChange(DataSource* data_source, const Rml::Core::String& table); + virtual void OnRowChange(DataSource* data_source, const String& table); protected: - /// Sets up data source and table from a given Rml::Core::String. + /// Sets up data source and table from a given String. /// @param[out] data_source A pointer to a data_source that gets loaded with the specified data source. - /// @param[out] table_name A reference to an Rml::Core::String that gets loaded with the specified data table. + /// @param[out] table_name A reference to an String that gets loaded with the specified data table. /// @param[in] data_source_name The data source and table in SOURCE.TABLE format. /// @return True if the data source name was in the correct format, and the data source was found. - bool ParseDataSource(DataSource*& data_source, Rml::Core::String& table_name, const Rml::Core::String& data_source_name); + bool ParseDataSource(DataSource*& data_source, String& table_name, const String& data_source_name); }; -} -} - -#endif // RMLUICONTROLSDATASOURCELISTENER_H - +} // namespace Rml +#endif // RMLUI_CORE_ELEMENTS_DATASOURCELISTENER_H diff --git a/Include/RmlUi/Controls/ElementDataGrid.h b/Include/RmlUi/Core/Elements/ElementDataGrid.h similarity index 83% rename from Include/RmlUi/Controls/ElementDataGrid.h rename to Include/RmlUi/Core/Elements/ElementDataGrid.h index 7f5c5b939..e2c254318 100644 --- a/Include/RmlUi/Controls/ElementDataGrid.h +++ b/Include/RmlUi/Core/Elements/ElementDataGrid.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSELEMENTDATAGRID_H -#define RMLUICONTROLSELEMENTDATAGRID_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTDATAGRID_H +#define RMLUI_CORE_ELEMENTS_ELEMENTDATAGRID_H -#include "Header.h" +#include "../Header.h" +#include "../Element.h" #include "DataSourceListener.h" -#include "../Core/Element.h" namespace Rml { -namespace Controls { class DataFormatter; class ElementDataGridRow; @@ -45,17 +44,17 @@ class ElementDataGridRow; @author Robert Curry */ -class RMLUICONTROLS_API ElementDataGrid : public Core::Element, public DataSourceListener +class RMLUICORE_API ElementDataGrid : public Element, public DataSourceListener { public: - RMLUI_RTTI_DefineWithParent(ElementDataGrid, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementDataGrid, Element) - ElementDataGrid(const Rml::Core::String& tag); + ElementDataGrid(const String& tag); virtual ~ElementDataGrid(); /// Sets a new data source for the contents of the data grid. /// @param[in] data_source_name The name of the new data source. - void SetDataSource(const Rml::Core::String& data_source_name); + void SetDataSource(const String& data_source_name); /** A column inside a table. @@ -66,14 +65,14 @@ class RMLUICONTROLS_API ElementDataGrid : public Core::Element, public DataSourc { /// The list of fields that this column reads from the data source for /// each row. - Rml::Core::StringList fields; + StringList fields; /// The data formatter this is used to process the field information /// into what is finally displayed in the data grid. DataFormatter* formatter; /// The header that is displayed at the top of the column, in the /// header row. - Core::Element* header; + Element* header; /// The width of this column. float current_width; @@ -90,19 +89,19 @@ class RMLUICONTROLS_API ElementDataGrid : public Core::Element, public DataSourc /// @param[in] initial_width The initial width, in pixels, of the column. /// @param[in] header_rml The RML to use as the column header. /// @return True if the column was added successfully, false if not. - bool AddColumn(const Rml::Core::String& fields, const Rml::Core::String& formatter, float initial_width, const Rml::Core::String& header_rml); + bool AddColumn(const String& fields, const String& formatter, float initial_width, const String& header_rml); /// Adds a column to the table. /// @param[in] fields A comma-separated list of fields that this column reads from the data source. /// @param[in] formatter The name of the data formatter to be used to format the raw column data into RML. /// @param[in] initial_width The initial width, in pixels, of the column. /// @param[in] header_element The element hierarchy to use as the column header. - void AddColumn(const Rml::Core::String& fields, const Rml::Core::String& formatter, float initial_width, Core::ElementPtr header_element); + void AddColumn(const String& fields, const String& formatter, float initial_width, ElementPtr header_element); /// Returns the number of columns in this table int GetNumColumns(); /// Returns the column at the specified index. const Column* GetColumn(int column_index); /// Returns a CSV string containing all the fields that each column requires, in order. - const Rml::Core::String& GetAllColumnFields(); + const String& GetAllColumnFields(); /// Adds a new row to the table. This is only called from child rows. /// @param[in] parent The parent row that the row is being added under. @@ -127,14 +126,14 @@ class RMLUICONTROLS_API ElementDataGrid : public Core::Element, public DataSourc /// Gets the markup and content of the element. /// @param content[out] The content of the element. - void GetInnerRML(Rml::Core::String& content) const override; + void GetInnerRML(String& content) const override; private: typedef std::vector< Column > ColumnList; typedef std::vector< ElementDataGridRow* > RowList; ColumnList columns; - Rml::Core::String column_fields; + String column_fields; // The row that contains the header elements of the table. ElementDataGridRow* header; @@ -144,13 +143,11 @@ class RMLUICONTROLS_API ElementDataGrid : public Core::Element, public DataSourc ElementDataGridRow* root; // If this is non-empty, then in the previous update the data source was set // and we must set it this update. - Rml::Core::String new_data_source; + String new_data_source; // The block element that contains all our rows. Only used for applying styles. - Core::Element* body; + Element* body; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementDataGridCell.h b/Include/RmlUi/Core/Elements/ElementDataGridCell.h similarity index 77% rename from Include/RmlUi/Controls/ElementDataGridCell.h rename to Include/RmlUi/Core/Elements/ElementDataGridCell.h index 98a4beec3..cb2ae499e 100644 --- a/Include/RmlUi/Controls/ElementDataGridCell.h +++ b/Include/RmlUi/Core/Elements/ElementDataGridCell.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSELEMENTDATAGRIDCELL_H -#define RMLUICONTROLSELEMENTDATAGRIDCELL_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDCELL_H +#define RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDCELL_H -#include "../Core/Element.h" -#include "../Core/EventListener.h" -#include "Header.h" +#include "../Element.h" +#include "../EventListener.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** The class for cells inside a data table row. @@ -42,23 +41,21 @@ namespace Controls { @author Robert Curry */ -class RMLUICONTROLS_API ElementDataGridCell : public Core::Element +class RMLUICORE_API ElementDataGridCell : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementDataGridCell, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementDataGridCell, Element) - ElementDataGridCell(const Rml::Core::String& tag); + ElementDataGridCell(const String& tag); virtual ~ElementDataGridCell(); - void Initialise(int column, Core::Element* header); + void Initialise(int column, Element* header); int GetColumn(); private: int column; - Core::Element* header; + Element* header; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementDataGridExpandButton.h b/Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h similarity index 80% rename from Include/RmlUi/Controls/ElementDataGridExpandButton.h rename to Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h index fca32d831..6fa98d1f7 100644 --- a/Include/RmlUi/Controls/ElementDataGridExpandButton.h +++ b/Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h @@ -26,30 +26,27 @@ * */ -#ifndef RMLUICONTROLSELEMENTDATAGRIDEXPANDBUTTON_H -#define RMLUICONTROLSELEMENTDATAGRIDEXPANDBUTTON_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDEXPANDBUTTON_H +#define RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDEXPANDBUTTON_H -#include "../Core/Element.h" -#include "Header.h" +#include "../Element.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** @author Robert Curry */ -class RMLUICONTROLS_API ElementDataGridExpandButton : public Core::Element +class RMLUICORE_API ElementDataGridExpandButton : public Element { public: - ElementDataGridExpandButton(const Rml::Core::String& tag); + ElementDataGridExpandButton(const String& tag); virtual ~ElementDataGridExpandButton(); protected: - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementDataGridRow.h b/Include/RmlUi/Core/Elements/ElementDataGridRow.h similarity index 85% rename from Include/RmlUi/Controls/ElementDataGridRow.h rename to Include/RmlUi/Core/Elements/ElementDataGridRow.h index 2922d4936..fe2067653 100644 --- a/Include/RmlUi/Controls/ElementDataGridRow.h +++ b/Include/RmlUi/Core/Elements/ElementDataGridRow.h @@ -26,17 +26,16 @@ * */ -#ifndef RMLUICONTROLSELEMENTDATAGRIDROW_H -#define RMLUICONTROLSELEMENTDATAGRIDROW_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDROW_H +#define RMLUI_CORE_ELEMENTS_ELEMENTDATAGRIDROW_H -#include "Header.h" +#include "../Header.h" +#include "../Element.h" #include "DataSourceListener.h" #include "DataQuery.h" -#include "../Core/Element.h" #include namespace Rml { -namespace Controls { class ElementDataGrid; @@ -46,21 +45,21 @@ class ElementDataGrid; @author Robert Curry */ -class RMLUICONTROLS_API ElementDataGridRow : public Core::Element, public DataSourceListener +class RMLUICORE_API ElementDataGridRow : public Element, public DataSourceListener { friend class ElementDataGrid; public: - RMLUI_RTTI_DefineWithParent(ElementDataGridRow, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementDataGridRow, Element) - ElementDataGridRow(const Rml::Core::String& tag); + ElementDataGridRow(const String& tag); virtual ~ElementDataGridRow(); void Initialise(ElementDataGrid* parent_grid, ElementDataGridRow* parent_row = nullptr, int child_index = -1, ElementDataGridRow* header_row = nullptr, int depth = -1); void SetChildIndex(int child_index); int GetDepth(); - void SetDataSource(const Rml::Core::String& data_source_name); + void SetDataSource(const String& data_source_name); /// Checks dirty children and cells, and loads them if necessary. /// @return True if any children were updated. @@ -92,10 +91,10 @@ friend class ElementDataGrid; protected: void OnDataSourceDestroy(DataSource* data_source) override; - void OnRowAdd(DataSource* data_source, const Rml::Core::String& table, int first_row_added, int num_rows_added) override; - void OnRowRemove(DataSource* data_source, const Rml::Core::String& table, int first_row_removed, int num_rows_removed) override; - void OnRowChange(DataSource* data_source, const Rml::Core::String& table, int first_row_changed, int num_rows_changed) override; - void OnRowChange(DataSource* data_source, const Rml::Core::String& table) override; + void OnRowAdd(DataSource* data_source, const String& table, int first_row_added, int num_rows_added) override; + void OnRowRemove(DataSource* data_source, const String& table, int first_row_removed, int num_rows_removed) override; + void OnRowChange(DataSource* data_source, const String& table, int first_row_changed, int num_rows_changed) override; + void OnRowChange(DataSource* data_source, const String& table) override; private: typedef std::queue< ElementDataGridRow* > RowQueue; @@ -129,7 +128,7 @@ friend class ElementDataGrid; int GetNumDescendants(); // Adds or refreshes the cell contents, and undirties the row's cells. - void Load(const Rml::Controls::DataQuery& row_information); + void Load(const DataQuery& row_information); // Finds all children that have cell information missing (either though being // refreshed or not being loaded yet) and reloads them. void LoadChildren(float time_slice); @@ -164,10 +163,8 @@ friend class ElementDataGrid; // The data source and table that the children are fetched from. DataSource* data_source; - Rml::Core::String data_table; + String data_table; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementForm.h b/Include/RmlUi/Core/Elements/ElementForm.h similarity index 78% rename from Include/RmlUi/Controls/ElementForm.h rename to Include/RmlUi/Core/Elements/ElementForm.h index 9ea44d671..57fa214e6 100644 --- a/Include/RmlUi/Controls/ElementForm.h +++ b/Include/RmlUi/Core/Elements/ElementForm.h @@ -26,38 +26,35 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORM_H -#define RMLUICONTROLSELEMENTFORM_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORM_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORM_H -#include "../Core/Element.h" -#include "Header.h" +#include "../Element.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** - A specialisation of the generic Core::Element representing a form element. + A specialisation of the generic Element representing a form element. @author Peter Curry */ -class RMLUICONTROLS_API ElementForm : public Core::Element +class RMLUICORE_API ElementForm : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementForm, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementForm, Element) /// Constructs a new ElementForm. This should not be called directly; use the Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementForm(const Rml::Core::String& tag); + ElementForm(const String& tag); virtual ~ElementForm(); /// Submits the form. /// @param[in] name The name of the item doing the submit /// @param[in] submit_value The value to send through as the 'submit' parameter. - void Submit(const Rml::Core::String& name = "", const Rml::Core::String& submit_value = ""); + void Submit(const String& name = "", const String& submit_value = ""); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementFormControl.h b/Include/RmlUi/Core/Elements/ElementFormControl.h similarity index 80% rename from Include/RmlUi/Controls/ElementFormControl.h rename to Include/RmlUi/Core/Elements/ElementFormControl.h index 6e54d3468..07c6ef93f 100644 --- a/Include/RmlUi/Controls/ElementFormControl.h +++ b/Include/RmlUi/Core/Elements/ElementFormControl.h @@ -26,46 +26,45 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORMCONTROL_H -#define RMLUICONTROLSELEMENTFORMCONTROL_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROL_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROL_H -#include "../Core/Element.h" -#include "Header.h" +#include "../Element.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** - A generic specialisation of the generic Core::Element for all input controls. + A generic specialisation of the generic Element for all input controls. @author Peter Curry */ -class RMLUICONTROLS_API ElementFormControl : public Core::Element +class RMLUICORE_API ElementFormControl : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementFormControl, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementFormControl, Element) /// Constructs a new ElementFormControl. This should not be called directly; use the Factory /// instead. /// @param[in] tag The tag the element was declared as in RML. - ElementFormControl(const Rml::Core::String& tag); + ElementFormControl(const String& tag); virtual ~ElementFormControl(); /// Returns the name of the form control. This is not guaranteed to be unique, and in the case of some form /// controls (such as radio buttons) most likely will not be. /// @return The name of the form control. - Rml::Core::String GetName() const; + String GetName() const; /// Sets the name of the form control. /// @param[in] name The new name of the form control. - void SetName(const Rml::Core::String& name); + void SetName(const String& name); /// Returns a string representation of the current value of the form control. /// @return The value of the form control. - virtual Rml::Core::String GetValue() const = 0; + virtual String GetValue() const = 0; /// Sets the current value of the form control. /// @param[in] value The new value of the form control. - virtual void SetValue(const Rml::Core::String& value) = 0; + virtual void SetValue(const String& value) = 0; /// Returns if this value should be submitted with the form. /// @return True if the value should be be submitted with the form, false otherwise. virtual bool IsSubmitted(); @@ -80,10 +79,8 @@ class RMLUICONTROLS_API ElementFormControl : public Core::Element protected: /// Checks for changes to the 'disabled' attribute. /// @param[in] changed_attributes List of changed attributes on the element. - void OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + void OnAttributeChange(const ElementAttributes& changed_attributes) override; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementFormControlDataSelect.h b/Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h similarity index 73% rename from Include/RmlUi/Controls/ElementFormControlDataSelect.h rename to Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h index 6c168ff09..6fbb3f92b 100644 --- a/Include/RmlUi/Controls/ElementFormControlDataSelect.h +++ b/Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h @@ -26,15 +26,15 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORMCONTROLDATASELECT_H -#define RMLUICONTROLSELEMENTFORMCONTROLDATASELECT_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLDATASELECT_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLDATASELECT_H -#include "Header.h" +#include "../Header.h" #include "ElementFormControlSelect.h" #include "DataSourceListener.h" namespace Rml { -namespace Controls { + class DataSource; @@ -44,18 +44,18 @@ class DataSource; @author Peter Curry */ -class RMLUICONTROLS_API ElementFormControlDataSelect : public ElementFormControlSelect, public DataSourceListener +class RMLUICORE_API ElementFormControlDataSelect : public ElementFormControlSelect, public DataSourceListener { public: /// Constructs a new ElementFormControlDataSelect. This should not be called directly; use the /// Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementFormControlDataSelect(const Rml::Core::String& tag); + ElementFormControlDataSelect(const String& tag); virtual ~ElementFormControlDataSelect(); /// Sets the data source the control's options are driven from. /// @param[in] data_source The name of the new data source. - void SetDataSource(const Rml::Core::String& data_source); + void SetDataSource(const String& data_source); protected: /// If a new data source has been set on the control, this will attach to it and build the @@ -64,30 +64,28 @@ class RMLUICONTROLS_API ElementFormControlDataSelect : public ElementFormControl /// Checks for changes to the data source or formatting attributes. /// @param[in] changed_attributes List of changed attributes on the element. - void OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + void OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Detaches from the data source and rebuilds the options. void OnDataSourceDestroy(DataSource* data_source) override; /// Rebuilds the available options from the data source. - void OnRowAdd(DataSource* data_source, const Rml::Core::String& table, int first_row_added, int num_rows_added) override; + void OnRowAdd(DataSource* data_source, const String& table, int first_row_added, int num_rows_added) override; /// Rebuilds the available options from the data source. - void OnRowRemove(DataSource* data_source, const Rml::Core::String& table, int first_row_removed, int num_rows_removed) override; + void OnRowRemove(DataSource* data_source, const String& table, int first_row_removed, int num_rows_removed) override; /// Rebuilds the available options from the data source. - void OnRowChange(DataSource* data_source, const Rml::Core::String& table, int first_row_changed, int num_rows_changed) override; + void OnRowChange(DataSource* data_source, const String& table, int first_row_changed, int num_rows_changed) override; /// Rebuilds the available options from the data source. - void OnRowChange(DataSource* data_source, const Rml::Core::String& table) override; + void OnRowChange(DataSource* data_source, const String& table) override; private: // Builds the option list from the data source. void BuildOptions(); DataSource* data_source; - Rml::Core::String data_table; + String data_table; bool initialised; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementFormControlInput.h b/Include/RmlUi/Core/Elements/ElementFormControlInput.h similarity index 80% rename from Include/RmlUi/Controls/ElementFormControlInput.h rename to Include/RmlUi/Core/Elements/ElementFormControlInput.h index 7b7b14aea..0c33a8451 100644 --- a/Include/RmlUi/Controls/ElementFormControlInput.h +++ b/Include/RmlUi/Core/Elements/ElementFormControlInput.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORMCONTROLINPUT_H -#define RMLUICONTROLSELEMENTFORMCONTROLINPUT_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLINPUT_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLINPUT_H -#include "Header.h" +#include "../Header.h" #include "ElementFormControl.h" namespace Rml { -namespace Controls { class InputType; @@ -43,7 +42,7 @@ class InputType; @author Peter Curry */ -class RMLUICONTROLS_API ElementFormControlInput : public ElementFormControl +class RMLUICORE_API ElementFormControlInput : public ElementFormControl { public: RMLUI_RTTI_DefineWithParent(ElementFormControlInput, ElementFormControl) @@ -51,15 +50,15 @@ class RMLUICONTROLS_API ElementFormControlInput : public ElementFormControl /// Constructs a new ElementFormControlInput. This should not be called directly; use the /// Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementFormControlInput(const Rml::Core::String& tag); + ElementFormControlInput(const String& tag); virtual ~ElementFormControlInput(); /// Returns a string representation of the current value of the form control. /// @return The value of the form control. - Rml::Core::String GetValue() const override; + String GetValue() const override; /// Sets the current value of the form control. /// @param value[in] The new value of the form control. - void SetValue(const Rml::Core::String& value) override; + void SetValue(const String& value) override; /// Returns if this value's type should be submitted with the form. /// @return True if the form control is to be submitted, false otherwise. bool IsSubmitted() override; @@ -74,32 +73,30 @@ class RMLUICONTROLS_API ElementFormControlInput : public ElementFormControl /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. - void OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + void OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Called when properties on the control are changed. /// @param[in] changed_properties The properties changed on the element. - void OnPropertyChange(const Core::PropertyIdSet& changed_properties) override; + void OnPropertyChange(const PropertyIdSet& changed_properties) override; /// If we are the added element, this will pass the call onto our type handler. /// @param[in] child The new member of the hierarchy. - void OnChildAdd(Rml::Core::Element* child) override; + void OnChildAdd(Element* child) override; /// If we are the removed element, this will pass the call onto our type handler. /// @param[in] child The member of the hierarchy that was just removed. - void OnChildRemove(Rml::Core::Element* child) override; + void OnChildRemove(Element* child) override; /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; private: InputType* type; - Rml::Core::String type_name; + String type_name; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementFormControlSelect.h b/Include/RmlUi/Core/Elements/ElementFormControlSelect.h similarity index 87% rename from Include/RmlUi/Controls/ElementFormControlSelect.h rename to Include/RmlUi/Core/Elements/ElementFormControlSelect.h index 9092aabcf..04d24ace1 100644 --- a/Include/RmlUi/Controls/ElementFormControlSelect.h +++ b/Include/RmlUi/Core/Elements/ElementFormControlSelect.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORMCONTROLSELECT_H -#define RMLUICONTROLSELEMENTFORMCONTROLSELECT_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLSELECT_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLSELECT_H -#include "Header.h" +#include "../Header.h" #include "ElementFormControl.h" #include "SelectOption.h" namespace Rml { -namespace Controls { class WidgetDropDown; @@ -44,21 +43,21 @@ class WidgetDropDown; @author Peter Curry */ -class RMLUICONTROLS_API ElementFormControlSelect : public ElementFormControl +class RMLUICORE_API ElementFormControlSelect : public ElementFormControl { public: /// Constructs a new ElementFormControlSelect. This should not be called directly; use the /// Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementFormControlSelect(const Rml::Core::String& tag); + ElementFormControlSelect(const String& tag); virtual ~ElementFormControlSelect(); /// Returns a string representation of the current value of the form control. /// @return The value of the form control. - Rml::Core::String GetValue() const override; + String GetValue() const override; /// Sets the current value of the form control. /// @param[in] value The new value of the form control. - void SetValue(const Rml::Core::String& value) override; + void SetValue(const String& value) override; /// Sets the index of the selection. If the new index lies outside of the bounds, it will be clamped. /// @param[in] selection The new selection index. @@ -81,7 +80,7 @@ class RMLUICONTROLS_API ElementFormControlSelect : public ElementFormControl /// @param[in] before The index of the element to insert the new option before. If out of bounds of the control's option list (the default) the new option will be added at the end of the list. /// @param[in] selectable If true this option can be selected. If false, this option is not selectable. /// @return The index of the new option. - int Add(const Rml::Core::String& rml, const Rml::Core::String& value, int before = -1, bool selectable = true); + int Add(const String& rml, const String& value, int before = -1, bool selectable = true); /// Removes an option from the select control. /// @param[in] index The index of the option to remove. If this is outside of the bounds of the control's option list, no option will be removed. void Remove(int index); @@ -101,12 +100,10 @@ class RMLUICONTROLS_API ElementFormControlSelect : public ElementFormControl /// Returns true to mark this element as replaced. /// @param[out] intrinsic_dimensions Set to the arbitrary dimensions of 128 x 16 just to give this element a size. Resize with the 'width' and 'height' properties. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& intrinsic_dimensions) override; + bool GetIntrinsicDimensions(Vector2f& intrinsic_dimensions) override; WidgetDropDown* widget; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementFormControlTextArea.h b/Include/RmlUi/Core/Elements/ElementFormControlTextArea.h similarity index 86% rename from Include/RmlUi/Controls/ElementFormControlTextArea.h rename to Include/RmlUi/Core/Elements/ElementFormControlTextArea.h index b45e42129..01c19149b 100644 --- a/Include/RmlUi/Controls/ElementFormControlTextArea.h +++ b/Include/RmlUi/Core/Elements/ElementFormControlTextArea.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSELEMENTFORMCONTROLTEXTAREA_H -#define RMLUICONTROLSELEMENTFORMCONTROLTEXTAREA_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLTEXTAREA_H +#define RMLUI_CORE_ELEMENTS_ELEMENTFORMCONTROLTEXTAREA_H -#include "Header.h" +#include "../Header.h" #include "ElementFormControl.h" namespace Rml { -namespace Controls { class WidgetTextInput; @@ -43,7 +42,7 @@ class WidgetTextInput; @author Peter Curry */ -class RMLUICONTROLS_API ElementFormControlTextArea : public ElementFormControl +class RMLUICORE_API ElementFormControlTextArea : public ElementFormControl { public: RMLUI_RTTI_DefineWithParent(ElementFormControlTextArea, ElementFormControl) @@ -51,16 +50,16 @@ class RMLUICONTROLS_API ElementFormControlTextArea : public ElementFormControl /// Constructs a new ElementFormControlTextArea. This should not be called directly; use the /// Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementFormControlTextArea(const Rml::Core::String& tag); + ElementFormControlTextArea(const String& tag); virtual ~ElementFormControlTextArea(); /// Returns a string representation of the current value of the form control. This is the value of the control /// regardless of whether it has been selected / checked (as appropriate for the control). /// @return The value of the form control. - Rml::Core::String GetValue() const override; + String GetValue() const override; /// Sets the current value of the form control. /// @param[in] value The new value of the form control. - void SetValue(const Rml::Core::String& value) override; + void SetValue(const String& value) override; /// Sets the number of characters visible across the text area. Note that this will only be precise when using /// a fixed-width font. @@ -94,7 +93,7 @@ class RMLUICONTROLS_API ElementFormControlTextArea : public ElementFormControl /// Returns the control's inherent size, based on the length of the input field and the current font size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; protected: /// Updates the control's widget. @@ -107,20 +106,18 @@ class RMLUICONTROLS_API ElementFormControlTextArea : public ElementFormControl void OnLayout() override; /// Called when attributes on the element are changed. - void OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + void OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Called when properties on the control are changed. /// @param[in] changed_properties The properties changed on the element. - void OnPropertyChange(const Core::PropertyIdSet& changed_properties) override; + void OnPropertyChange(const PropertyIdSet& changed_properties) override; /// Returns the text content of the element. /// @param[out] content The content of the element. - void GetInnerRML(Rml::Core::String& content) const override; + void GetInnerRML(String& content) const override; private: WidgetTextInput* widget; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementProgressBar.h b/Include/RmlUi/Core/Elements/ElementProgressBar.h similarity index 82% rename from Include/RmlUi/Controls/ElementProgressBar.h rename to Include/RmlUi/Core/Elements/ElementProgressBar.h index 0d1dd22ca..7444e048c 100644 --- a/Include/RmlUi/Controls/ElementProgressBar.h +++ b/Include/RmlUi/Core/Elements/ElementProgressBar.h @@ -26,17 +26,16 @@ * */ -#ifndef RMLUICONTROLSELEMENTPROGRESSBAR_H -#define RMLUICONTROLSELEMENTPROGRESSBAR_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTPROGRESSBAR_H +#define RMLUI_CORE_ELEMENTS_ELEMENTPROGRESSBAR_H -#include "Header.h" -#include "../Core/Element.h" -#include "../Core/Geometry.h" -#include "../Core/Texture.h" -#include "../Core/Spritesheet.h" +#include "../Header.h" +#include "../Element.h" +#include "../Geometry.h" +#include "../Texture.h" +#include "../Spritesheet.h" namespace Rml { -namespace Controls { /** The 'progressbar' element. @@ -58,14 +57,14 @@ namespace Controls { */ -class RMLUICONTROLS_API ElementProgressBar : public Core::Element +class RMLUICORE_API ElementProgressBar : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementProgressBar, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementProgressBar, Element) /// Constructs a new ElementProgressBar. This should not be called directly; use the Factory instead. /// @param[in] tag The tag the element was declared as in RML. - ElementProgressBar(const Core::String& tag); + ElementProgressBar(const String& tag); virtual ~ElementProgressBar(); /// Return the value of the progress bar [0, 1] @@ -79,9 +78,9 @@ class RMLUICONTROLS_API ElementProgressBar : public Core::Element void OnResize() override; - void OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + void OnAttributeChange(const ElementAttributes& changed_attributes) override; - void OnPropertyChange(const Core::PropertyIdSet& changed_properties) override; + void OnPropertyChange(const PropertyIdSet& changed_properties) override; private: enum class Direction { Top, Right, Bottom, Left, Clockwise, CounterClockwise, Count }; @@ -98,25 +97,23 @@ class RMLUICONTROLS_API ElementProgressBar : public Core::Element float value; - Core::Element* fill; + Element* fill; // The size of the fill geometry as if fully filled, and the offset relative to the 'progressbar' element. - Core::Vector2f fill_size, fill_offset; + Vector2f fill_size, fill_offset; // The texture this element is rendering from if the 'fill-image' property is set. - Core::Texture texture; + Texture texture; bool texture_dirty; // The rectangle extracted from a sprite, 'rect_set' controls whether it is active. - Core::Rectangle rect; + Rectangle rect; bool rect_set; // The geometry used to render this element. Only applies if the 'fill-image' property is set. - Core::Geometry geometry; + Geometry geometry; bool geometry_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/ElementTabSet.h b/Include/RmlUi/Core/Elements/ElementTabSet.h similarity index 80% rename from Include/RmlUi/Controls/ElementTabSet.h rename to Include/RmlUi/Core/Elements/ElementTabSet.h index 4e3cc002f..0d68e20f6 100644 --- a/Include/RmlUi/Controls/ElementTabSet.h +++ b/Include/RmlUi/Core/Elements/ElementTabSet.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSELEMENTTABSET_H -#define RMLUICONTROLSELEMENTTABSET_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTTABSET_H +#define RMLUI_CORE_ELEMENTS_ELEMENTTABSET_H -#include "../Core/Element.h" -#include "Header.h" +#include "../Element.h" +#include "../Header.h" namespace Rml { -namespace Controls { /** A tabulated set of panels. @@ -41,31 +40,31 @@ namespace Controls { @author Lloyd Weehuizen */ -class RMLUICONTROLS_API ElementTabSet : public Core::Element +class RMLUICORE_API ElementTabSet : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementTabSet, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementTabSet, Element) - ElementTabSet(const Rml::Core::String& tag); + ElementTabSet(const String& tag); ~ElementTabSet(); /// Sets the specifed tab index's tab title RML. /// @param[in] tab_index The tab index to set. If it doesn't already exist, it will be created. /// @param[in] rml The RML to set on the tab title. - void SetTab(int tab_index, const Rml::Core::String& rml); + void SetTab(int tab_index, const String& rml); /// Sets the specifed tab index's tab panel RML. /// @param[in] tab_index The tab index to set. If it doesn't already exist, it will be created. /// @param[in] rml The RML to set on the tab panel. - void SetPanel(int tab_index, const Rml::Core::String& rml); + void SetPanel(int tab_index, const String& rml); /// Set the specifed tab index's title element. /// @param[in] tab_index The tab index to set. If it doesn't already exist, it will be created. /// @param[in] element The root of the element tree to set as the tab title. - void SetTab(int tab_index, Core::ElementPtr element); + void SetTab(int tab_index, ElementPtr element); /// Set the specified tab index's body element. /// @param[in] tab_index The tab index to set. If it doesn't already exist, it will be created. /// @param[in] element The root of the element tree to set as the window. - void SetPanel(int tab_index, Core::ElementPtr element); + void SetPanel(int tab_index, ElementPtr element); /// Remove one of the tab set's panels and its corresponding tab. /// @param[in] tab_index The tab index to remove. If no tab matches this index, nothing will be removed. @@ -84,19 +83,17 @@ class RMLUICONTROLS_API ElementTabSet : public Core::Element int GetActiveTab() const; /// Capture clicks on our tabs. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; protected: // Catch child add so we can correctly set up its properties. - void OnChildAdd(Core::Element* child) override; + void OnChildAdd(Element* child) override; private: - Core::Element* GetChildByTag(const Rml::Core::String& tag); + Element* GetChildByTag(const String& tag); int active_tab; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Controls/SelectOption.h b/Include/RmlUi/Core/Elements/SelectOption.h similarity index 81% rename from Include/RmlUi/Controls/SelectOption.h rename to Include/RmlUi/Core/Elements/SelectOption.h index 48b6539f8..0b0d7c409 100644 --- a/Include/RmlUi/Controls/SelectOption.h +++ b/Include/RmlUi/Core/Elements/SelectOption.h @@ -26,20 +26,16 @@ * */ -#ifndef RMLUICONTROLSSELECTOPTION_H -#define RMLUICONTROLSSELECTOPTION_H +#ifndef RMLUI_CORE_ELEMENTS_SELECTOPTION_H +#define RMLUI_CORE_ELEMENTS_SELECTOPTION_H -#include "Header.h" -#include "../Core/Types.h" +#include "../Header.h" +#include "../Types.h" namespace Rml { -namespace Core { class Element; -} - -namespace Controls { /** Represents individual options within a select control. @@ -47,30 +43,28 @@ namespace Controls { @author Peter Curry */ -class RMLUICONTROLS_API SelectOption +class RMLUICORE_API SelectOption { public: - SelectOption(Core::Element* element, const Rml::Core::String& value, bool selectable); + SelectOption(Element* element, const String& value, bool selectable); ~SelectOption(); /// Returns the element that represents the option visually. /// @return The option's element. - Core::Element* GetElement(); + Element* GetElement(); /// Returns the value of the option. /// @return The option's value. - const Rml::Core::String& GetValue() const; + const String& GetValue() const; /// Returns true if the item is selectable. /// @return True if the item is selectable. bool IsSelectable() { return selectable; } private: - Core::Element* element; - Rml::Core::String value; + Element* element; + String value; bool selectable; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Event.h b/Include/RmlUi/Core/Event.h index 2d2bf4a16..f0d4df963 100644 --- a/Include/RmlUi/Core/Event.h +++ b/Include/RmlUi/Core/Event.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREEVENT_H -#define RMLUICOREEVENT_H +#ifndef RMLUI_CORE_EVENT_H +#define RMLUI_CORE_EVENT_H #include "Header.h" #include "Dictionary.h" @@ -35,7 +35,6 @@ #include "ID.h" namespace Rml { -namespace Core { class Element; class EventInstancer; @@ -149,7 +148,5 @@ class RMLUICORE_API Event : public ScriptInterface }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/EventInstancer.h b/Include/RmlUi/Core/EventInstancer.h index 50968a218..0d19d8fba 100644 --- a/Include/RmlUi/Core/EventInstancer.h +++ b/Include/RmlUi/Core/EventInstancer.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREEVENTINSTANCER_H -#define RMLUICOREEVENTINSTANCER_H +#ifndef RMLUI_CORE_EVENTINSTANCER_H +#define RMLUI_CORE_EVENTINSTANCER_H #include "Traits.h" #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { class Element; class Event; @@ -63,7 +62,5 @@ class RMLUICORE_API EventInstancer : public Releasable virtual void ReleaseEvent(Event* event) = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/EventListener.h b/Include/RmlUi/Core/EventListener.h index 9342b5535..c2afe3191 100644 --- a/Include/RmlUi/Core/EventListener.h +++ b/Include/RmlUi/Core/EventListener.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREEVENTLISTENER_H -#define RMLUICOREEVENTLISTENER_H +#ifndef RMLUI_CORE_EVENTLISTENER_H +#define RMLUI_CORE_EVENTLISTENER_H #include "Header.h" #include "Event.h" #include "ObserverPtr.h" namespace Rml { -namespace Core { class Event; class Element; @@ -66,7 +65,5 @@ class RMLUICORE_API EventListener : public EnableObserverPtr } }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/EventListenerInstancer.h b/Include/RmlUi/Core/EventListenerInstancer.h index 663069b7a..355f8826f 100644 --- a/Include/RmlUi/Core/EventListenerInstancer.h +++ b/Include/RmlUi/Core/EventListenerInstancer.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREEVENTLISTENERINSTANCER_H -#define RMLUICOREEVENTLISTENERINSTANCER_H +#ifndef RMLUI_CORE_EVENTLISTENERINSTANCER_H +#define RMLUI_CORE_EVENTLISTENERINSTANCER_H #include "Traits.h" #include "Types.h" @@ -35,7 +35,6 @@ #include "Element.h" namespace Rml { -namespace Core { class EventListener; @@ -57,7 +56,5 @@ class RMLUICORE_API EventListenerInstancer virtual EventListener* InstanceEventListener(const String& value, Element* element) = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Factory.h b/Include/RmlUi/Core/Factory.h index 47870cc56..24bb7d77d 100644 --- a/Include/RmlUi/Core/Factory.h +++ b/Include/RmlUi/Core/Factory.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREFACTORY_H -#define RMLUICOREFACTORY_H +#ifndef RMLUI_CORE_FACTORY_H +#define RMLUI_CORE_FACTORY_H #include "XMLParser.h" #include "Header.h" namespace Rml { -namespace Core { class Context; class ContextInstancer; @@ -75,7 +74,7 @@ class RMLUICORE_API Factory /// Registers a non-owning pointer to the instancer used to instance contexts. /// @param[in] instancer The new context instancer. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. static void RegisterContextInstancer(ContextInstancer* instancer); /// Instances a new context. /// @param[in] name The name of the new context. @@ -85,7 +84,7 @@ class RMLUICORE_API Factory /// Registers a non-owning pointer to the element instancer that will be used to instance an element when the specified tag is encountered. /// @param[in] name Name of the instancer; elements with this as their tag will use this instancer. /// @param[in] instancer The instancer to call when the tag is encountered. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. static void RegisterElementInstancer(const String& name, ElementInstancer* instancer); /// Returns the element instancer for the specified tag. /// @param[in] tag Name of the tag to get the instancer for. @@ -114,12 +113,12 @@ class RMLUICORE_API Factory /// @param[in] context The context that is creating the document. /// @param[in] stream The stream to instance from. /// @return The instanced document, or nullptr if an error occurred. - static ElementPtr InstanceDocumentStream(Rml::Core::Context* context, Stream* stream); + static ElementPtr InstanceDocumentStream(Context* context, Stream* stream); /// Registers a non-owning pointer to an instancer that will be used to instance decorators. /// @param[in] name The name of the decorator the instancer will be called for. /// @param[in] instancer The instancer to call when the decorator name is encountered. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. /// @return The added instancer if the registration was successful, nullptr otherwise. static void RegisterDecoratorInstancer(const String& name, DecoratorInstancer* instancer); /// Retrieves a decorator instancer registered with the factory. @@ -130,7 +129,7 @@ class RMLUICORE_API Factory /// Registers a non-owning pointer to an instancer that will be used to instance font effects. /// @param[in] name The name of the font effect the instancer will be called for. /// @param[in] instancer The instancer to call when the font effect name is encountered. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. /// @return The added instancer if the registration was successful, nullptr otherwise. static void RegisterFontEffectInstancer(const String& name, FontEffectInstancer* instancer); /// Retrieves a font-effect instancer registered with the factory. @@ -157,7 +156,7 @@ class RMLUICORE_API Factory /// Registers an instancer for all events. /// @param[in] instancer The instancer to be called. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. static void RegisterEventInstancer(EventInstancer* instancer); /// Instance an event object /// @param[in] target Target element of this event. @@ -168,7 +167,7 @@ class RMLUICORE_API Factory static EventPtr InstanceEvent(Element* target, EventId id, const String& type, const Dictionary& parameters, bool interruptible); /// Register the instancer to be used for all event listeners. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown, or until a new instancer is set. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown, or until a new instancer is set. static void RegisterEventListenerInstancer(EventListenerInstancer* instancer); /// Instance an event listener with the given string. This is used for instancing listeners for the on* events from RML. /// @param[in] value The parameters to the event listener. @@ -181,13 +180,13 @@ class RMLUICORE_API Factory /// @param[in] instancer The instancer to be called. /// @param[in] type_name The type name of the view, determines the element attribute that is used to initialize it. /// @param[in] is_structural_view Set true if the view should be parsed as a structural view. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. static void RegisterDataViewInstancer(DataViewInstancer* instancer, const String& type_name, bool is_structural_view = false); /// Register an instancer for data controllers. /// @param[in] instancer The instancer to be called. /// @param[in] type_name The type name of the controller, determines the element attribute that is used to initialize it. - /// @lifetime The instancer must be kept alive until after the call to Core::Shutdown. + /// @lifetime The instancer must be kept alive until after the call to Rml::Shutdown. static void RegisterDataControllerInstancer(DataControllerInstancer* instancer, const String& type_name); /// Instance the data view with the given type name. @@ -204,7 +203,5 @@ class RMLUICORE_API Factory ~Factory(); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/FileInterface.h b/Include/RmlUi/Core/FileInterface.h index 669f39f2a..2df28663e 100644 --- a/Include/RmlUi/Core/FileInterface.h +++ b/Include/RmlUi/Core/FileInterface.h @@ -26,22 +26,21 @@ * */ -#ifndef RMLUICOREFILEINTERFACE_H -#define RMLUICOREFILEINTERFACE_H +#ifndef RMLUI_CORE_FILEINTERFACE_H +#define RMLUI_CORE_FILEINTERFACE_H #include "Header.h" #include "Types.h" #include "Traits.h" namespace Rml { -namespace Core { /** The abstract base class for application-specific file I/O. By default, RmlUi will use a file interface implementing the standard C file functions. If this is not sufficient, or your application wants more control over file I/O, this class should be derived, instanced, and installed - through Core::SetFileInterface() before you initialise RmlUi. + through Rml::SetFileInterface() before you initialise RmlUi. @author Peter Curry */ @@ -84,7 +83,5 @@ class RMLUICORE_API FileInterface : public NonCopyMoveable virtual size_t Length(FileHandle file); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/FontEffect.h b/Include/RmlUi/Core/FontEffect.h index a069f2bba..832899a25 100644 --- a/Include/RmlUi/Core/FontEffect.h +++ b/Include/RmlUi/Core/FontEffect.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREFONTEFFECT_H -#define RMLUICOREFONTEFFECT_H +#ifndef RMLUI_CORE_FONTEFFECT_H +#define RMLUI_CORE_FONTEFFECT_H #include "FontGlyph.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -89,7 +88,5 @@ class RMLUICORE_API FontEffect size_t fingerprint; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/FontEffectInstancer.h b/Include/RmlUi/Core/FontEffectInstancer.h index db8893af4..3bf5bb207 100644 --- a/Include/RmlUi/Core/FontEffectInstancer.h +++ b/Include/RmlUi/Core/FontEffectInstancer.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREFONTEFFECTINSTANCER_H -#define RMLUICOREFONTEFFECTINSTANCER_H +#ifndef RMLUI_CORE_FONTEFFECTINSTANCER_H +#define RMLUI_CORE_FONTEFFECTINSTANCER_H #include "Traits.h" #include "Header.h" @@ -35,7 +35,6 @@ #include "PropertySpecification.h" namespace Rml { -namespace Core { class FontEffect; @@ -87,7 +86,5 @@ class RMLUICORE_API FontEffectInstancer friend class Factory; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/FontEngineInterface.h b/Include/RmlUi/Core/FontEngineInterface.h index b181135f2..cd8787cbb 100644 --- a/Include/RmlUi/Core/FontEngineInterface.h +++ b/Include/RmlUi/Core/FontEngineInterface.h @@ -25,8 +25,8 @@ * */ -#ifndef RMLUICOREFONTENGINEINTERFACE_H -#define RMLUICOREFONTENGINEINTERFACE_H +#ifndef RMLUI_CORE_FONTENGINEINTERFACE_H +#define RMLUI_CORE_FONTENGINEINTERFACE_H #include "Header.h" #include "Types.h" @@ -34,14 +34,12 @@ #include "Geometry.h" namespace Rml { -namespace Core { - /** The abstract base class for an application-specific font engine implementation. By default, RmlUi will use its own font engine with characters rendered through FreeType. To use your own engine, - provide a concrete implementation of this class and install it through Core::SetFontEngineInterface(). + provide a concrete implementation of this class and install it through Rml::SetFontEngineInterface(). */ @@ -131,7 +129,5 @@ class RMLUICORE_API FontEngineInterface virtual int GetVersion(FontFaceHandle handle); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/FontGlyph.h b/Include/RmlUi/Core/FontGlyph.h index 8508f2efd..925acc386 100644 --- a/Include/RmlUi/Core/FontGlyph.h +++ b/Include/RmlUi/Core/FontGlyph.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREFONTGLYPH_H -#define RMLUICOREFONTGLYPH_H +#ifndef RMLUI_CORE_FONTGLYPH_H +#define RMLUI_CORE_FONTGLYPH_H #include "Types.h" namespace Rml { -namespace Core { /** Metrics and bitmap data for a single glyph within a font face. @@ -79,7 +78,5 @@ class RMLUICORE_API FontGlyph using FontGlyphMap = UnorderedMap; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Geometry.h b/Include/RmlUi/Core/Geometry.h index 9b4ed726e..d866037f0 100644 --- a/Include/RmlUi/Core/Geometry.h +++ b/Include/RmlUi/Core/Geometry.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREGEOMETRY_H -#define RMLUICOREGEOMETRY_H +#ifndef RMLUI_CORE_GEOMETRY_H +#define RMLUI_CORE_GEOMETRY_H #include "Header.h" #include "Vertex.h" #include namespace Rml { -namespace Core { class Context; class Element; @@ -109,7 +108,5 @@ class RMLUICORE_API Geometry using GeometryList = std::vector< Geometry >; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/GeometryUtilities.h b/Include/RmlUi/Core/GeometryUtilities.h index ec978f22a..db6acc146 100644 --- a/Include/RmlUi/Core/GeometryUtilities.h +++ b/Include/RmlUi/Core/GeometryUtilities.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREGEOMETRYUTILITIES_H -#define RMLUICOREGEOMETRYUTILITIES_H +#ifndef RMLUI_CORE_GEOMETRYUTILITIES_H +#define RMLUI_CORE_GEOMETRYUTILITIES_H #include "Header.h" #include "Types.h" @@ -35,7 +35,6 @@ #include "ComputedValues.h" namespace Rml { -namespace Core { class Geometry; @@ -80,7 +79,5 @@ class RMLUICORE_API GeometryUtilities ~GeometryUtilities(); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Header.h b/Include/RmlUi/Core/Header.h index f194b903b..68089330a 100644 --- a/Include/RmlUi/Core/Header.h +++ b/Include/RmlUi/Core/Header.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREHEADER_H -#define RMLUICOREHEADER_H +#ifndef RMLUI_CORE_HEADER_H +#define RMLUI_CORE_HEADER_H #include "Platform.h" diff --git a/Include/RmlUi/Core/ID.h b/Include/RmlUi/Core/ID.h index bef254fc6..2440001ef 100644 --- a/Include/RmlUi/Core/ID.h +++ b/Include/RmlUi/Core/ID.h @@ -27,14 +27,12 @@ */ -#ifndef RMLUICOREID_H -#define RMLUICOREID_H +#ifndef RMLUI_CORE_ID_H +#define RMLUI_CORE_ID_H #include namespace Rml { -namespace Core { - enum class ShorthandId : uint8_t { @@ -193,7 +191,7 @@ enum class EventId : uint16_t Animationend, Transitionend, - // Controls events + // Form control events Change, Submit, Tabchange, @@ -212,7 +210,5 @@ enum class EventId : uint16_t MaxNumIds = 0xffff }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Input.h b/Include/RmlUi/Core/Input.h index 0b1c02f13..06fe53474 100644 --- a/Include/RmlUi/Core/Input.h +++ b/Include/RmlUi/Core/Input.h @@ -26,11 +26,10 @@ * */ -#ifndef RMLUICOREINPUT_H -#define RMLUICOREINPUT_H +#ifndef RMLUI_CORE_INPUT_H +#define RMLUI_CORE_INPUT_H namespace Rml { -namespace Core { /* Enumerants for sending input events into RmlUi. @@ -270,7 +269,5 @@ namespace Input }; } -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Log.h b/Include/RmlUi/Core/Log.h index 16fe727f8..5ca20f460 100644 --- a/Include/RmlUi/Core/Log.h +++ b/Include/RmlUi/Core/Log.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORELOG_H -#define RMLUICORELOG_H +#ifndef RMLUI_CORE_LOG_H +#define RMLUI_CORE_LOG_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { /** RmlUi logging API. @@ -74,7 +73,5 @@ class RMLUICORE_API Log static void ParseError(const String& filename, int line_number, const char* format, ...); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Lua/Header.h b/Include/RmlUi/Core/Lua/Header.h deleted file mode 100644 index a859a6c7f..000000000 --- a/Include/RmlUi/Core/Lua/Header.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICORELUAHEADER_H -#define RMLUICORELUAHEADER_H - -#include "../Platform.h" - -#ifdef RMLUILUA_API -#undef RMLUILUA_API -#endif - -#if !defined RMLUI_STATIC_LIB - #ifdef RMLUI_PLATFORM_WIN32 - #if defined RmlCoreLua_EXPORTS - #define RMLUILUA_API __declspec(dllexport) - #elif defined RmlControlsLua_EXPORTS - #define RMLUILUA_API __declspec(dllexport) - #else - #define RMLUILUA_API __declspec(dllimport) - #endif - #else - #define RMLUILUA_API __attribute__((visibility("default"))) - #endif -#else - #define RMLUILUA_API -#endif - -#endif diff --git a/Include/RmlUi/Core/Math.h b/Include/RmlUi/Core/Math.h index c31889a23..d64ba7275 100644 --- a/Include/RmlUi/Core/Math.h +++ b/Include/RmlUi/Core/Math.h @@ -26,13 +26,13 @@ * */ -#ifndef RMLUICOREMATH_H -#define RMLUICOREMATH_H +#ifndef RMLUI_CORE_MATH_H +#define RMLUI_CORE_MATH_H #include "Header.h" namespace Rml { -namespace Core { + namespace Math { // The constant PI. @@ -181,7 +181,5 @@ RMLUICORE_API int RandomInteger(int max_value); RMLUICORE_API bool RandomBool(); } -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/MathTypes.h b/Include/RmlUi/Core/MathTypes.h index 8d0396a8c..9aec39b6d 100644 --- a/Include/RmlUi/Core/MathTypes.h +++ b/Include/RmlUi/Core/MathTypes.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREMATHTYPES_H -#define RMLUICOREMATHTYPES_H +#ifndef RMLUI_CORE_MATHTYPES_H +#define RMLUI_CORE_MATHTYPES_H #include "Header.h" #include "Vector2.h" @@ -35,7 +35,6 @@ #include "Vector4.h" namespace Rml { -namespace Core { // Define common Vector2 types. typedef Vector2< int > Vector2i; @@ -55,7 +54,5 @@ typedef Vector4< float > Vector4f; RMLUICORE_API Vector4i operator*(int lhs, const Vector4i& rhs); RMLUICORE_API Vector4f operator*(float lhs, const Vector4f& rhs); -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Matrix4.h b/Include/RmlUi/Core/Matrix4.h index 42c80ca2d..42f63a00c 100644 --- a/Include/RmlUi/Core/Matrix4.h +++ b/Include/RmlUi/Core/Matrix4.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREMATRIX4_H -#define RMLUICOREMATRIX4_H +#ifndef RMLUI_CORE_MATRIX4_H +#define RMLUI_CORE_MATRIX4_H #include "Debug.h" #include "Math.h" #include "Vector4.h" namespace Rml { -namespace Core { /** Templated class that acts as base strategy for vectors access patterns of matrices. @@ -501,8 +500,8 @@ class Matrix4 const Vector3< Component >& skew, const Vector4< Component >& perspective, const Vector4< Component >& quaternion) noexcept; }; -} -} + +} // namespace Rml #include "Matrix4.inl" diff --git a/Include/RmlUi/Core/Matrix4.inl b/Include/RmlUi/Core/Matrix4.inl index c584f757d..010301e5b 100644 --- a/Include/RmlUi/Core/Matrix4.inl +++ b/Include/RmlUi/Core/Matrix4.inl @@ -27,7 +27,6 @@ */ namespace Rml { -namespace Core { // Initialising constructor. template< typename Component, class Storage > @@ -314,7 +313,7 @@ bool Matrix4< Component, Storage >::Invert() noexcept template -inline float Rml::Core::Matrix4::Determinant() const noexcept +inline float Matrix4::Determinant() const noexcept { const Component *src = data(); float diag[4]; // Diagonal elements of the matrix inverse (see Invert) @@ -688,7 +687,7 @@ Matrix4< Component, Storage > Matrix4< Component, Storage >::SkewY(Component ang } template -Matrix4< Component, Storage > Rml::Core::Matrix4::Compose(const Vector3& translation, +Matrix4< Component, Storage > Matrix4::Compose(const Vector3& translation, const Vector3& scale, const Vector3& skew, const Vector4& perspective, const Vector4& quaternion) noexcept { @@ -853,5 +852,4 @@ struct Matrix4< Component, Storage >::MatrixMultiplier< _Component, ColumnMajorS } }; -} -} \ No newline at end of file +} // namespace Rml diff --git a/Include/RmlUi/Core/ObserverPtr.h b/Include/RmlUi/Core/ObserverPtr.h index 7dca9a17a..a90f63837 100644 --- a/Include/RmlUi/Core/ObserverPtr.h +++ b/Include/RmlUi/Core/ObserverPtr.h @@ -34,7 +34,6 @@ #include "Header.h" namespace Rml { -namespace Core { struct RMLUICORE_API ObserverPtrBlock { int num_observers; @@ -185,7 +184,5 @@ class RMLUICORE_API EnableObserverPtr { -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Platform.h b/Include/RmlUi/Core/Platform.h index 78ae101e0..c889ea197 100644 --- a/Include/RmlUi/Core/Platform.h +++ b/Include/RmlUi/Core/Platform.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREPLATFORM_H -#define RMLUICOREPLATFORM_H +#ifndef RMLUI_CORE_PLATFORM_H +#define RMLUI_CORE_PLATFORM_H #if defined __WIN32__ || defined _WIN32 #define RMLUI_PLATFORM_WIN32 diff --git a/Include/RmlUi/Core/Plugin.h b/Include/RmlUi/Core/Plugin.h index 23162242f..ccbc4cdbd 100644 --- a/Include/RmlUi/Core/Plugin.h +++ b/Include/RmlUi/Core/Plugin.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPLUGIN_H -#define RMLUICOREPLUGIN_H +#ifndef RMLUI_CORE_PLUGIN_H +#define RMLUI_CORE_PLUGIN_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { class Element; class ElementDocument; @@ -88,7 +87,5 @@ class RMLUICORE_API Plugin virtual void OnElementDestroy(Element* element); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Profiling.h b/Include/RmlUi/Core/Profiling.h index 2ebd02ff3..6d46382b3 100644 --- a/Include/RmlUi/Core/Profiling.h +++ b/Include/RmlUi/Core/Profiling.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREPROFILING_H -#define RMLUICOREPROFILING_H +#ifndef RMLUI_CORE_PROFILING_H +#define RMLUI_CORE_PROFILING_H #ifdef RMLUI_ENABLE_PROFILING diff --git a/Include/RmlUi/Core/PropertiesIteratorView.h b/Include/RmlUi/Core/PropertiesIteratorView.h index b40d9417a..7e413080a 100644 --- a/Include/RmlUi/Core/PropertiesIteratorView.h +++ b/Include/RmlUi/Core/PropertiesIteratorView.h @@ -25,14 +25,13 @@ * THE SOFTWARE. * */ -#ifndef RMLUICOREPROPERTIESITERATORVIEW_H -#define RMLUICOREPROPERTIESITERATORVIEW_H +#ifndef RMLUI_CORE_PROPERTIESITERATORVIEW_H +#define RMLUI_CORE_PROPERTIESITERATORVIEW_H #include "Types.h" #include "Property.h" namespace Rml { -namespace Core { class PropertiesIterator; @@ -73,7 +72,5 @@ class RMLUICORE_API PropertiesIteratorView { UniquePtr ptr; }; -} -} - +} // namespace Rml #endif \ No newline at end of file diff --git a/Include/RmlUi/Core/Property.h b/Include/RmlUi/Core/Property.h index 9a4607461..3e31d65c6 100644 --- a/Include/RmlUi/Core/Property.h +++ b/Include/RmlUi/Core/Property.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPROPERTY_H -#define RMLUICOREPROPERTY_H +#ifndef RMLUI_CORE_PROPERTY_H +#define RMLUI_CORE_PROPERTY_H #include "Variant.h" #include "Header.h" namespace Rml { -namespace Core { class PropertyDefinition; @@ -129,7 +128,5 @@ class RMLUICORE_API Property SharedPtr source; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/PropertyDefinition.h b/Include/RmlUi/Core/PropertyDefinition.h index 9ec954278..fc33953e0 100644 --- a/Include/RmlUi/Core/PropertyDefinition.h +++ b/Include/RmlUi/Core/PropertyDefinition.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREPROPERTYDEFINITION_H -#define RMLUICOREPROPERTYDEFINITION_H +#ifndef RMLUI_CORE_PROPERTYDEFINITION_H +#define RMLUI_CORE_PROPERTYDEFINITION_H #include "Header.h" #include "Property.h" #include "PropertyParser.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -103,7 +102,5 @@ class RMLUICORE_API PropertyDefinition final RelativeTarget relative_target; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/PropertyDictionary.h b/Include/RmlUi/Core/PropertyDictionary.h index 4b35d39c0..350c46df3 100644 --- a/Include/RmlUi/Core/PropertyDictionary.h +++ b/Include/RmlUi/Core/PropertyDictionary.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPROPERTYDICTIONARY_H -#define RMLUICOREPROPERTYDICTIONARY_H +#ifndef RMLUI_CORE_PROPERTYDICTIONARY_H +#define RMLUI_CORE_PROPERTYDICTIONARY_H #include "Header.h" #include "Property.h" namespace Rml { -namespace Core { /** A dictionary to property names to values. @@ -80,12 +79,10 @@ class RMLUICORE_API PropertyDictionary // Sets a property on the dictionary and its specificity if there is no name conflict, or its // specificity (given by the parameter, not read from the property itself) is at least equal to // the specificity of the conflicting property. - void SetProperty(PropertyId id, const Rml::Core::Property& property, int specificity); + void SetProperty(PropertyId id, const Property& property, int specificity); PropertyMap properties; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/PropertyIdSet.h b/Include/RmlUi/Core/PropertyIdSet.h index 153f0eaf7..a33167c86 100644 --- a/Include/RmlUi/Core/PropertyIdSet.h +++ b/Include/RmlUi/Core/PropertyIdSet.h @@ -25,15 +25,14 @@ * THE SOFTWARE. * */ -#ifndef RMLUICOREPROPERTYIDSET_H -#define RMLUICOREPROPERTYIDSET_H +#ifndef RMLUI_CORE_PROPERTYIDSET_H +#define RMLUI_CORE_PROPERTYIDSET_H #include "Types.h" #include "ID.h" #include namespace Rml { -namespace Core { class PropertyIdSetIterator; @@ -175,7 +174,5 @@ PropertyIdSetIterator PropertyIdSet::Erase(PropertyIdSetIterator it) { return it; } -} -} - +} // namespace Rml #endif \ No newline at end of file diff --git a/Include/RmlUi/Core/PropertyParser.h b/Include/RmlUi/Core/PropertyParser.h index 74aa1f42e..d9e721e66 100644 --- a/Include/RmlUi/Core/PropertyParser.h +++ b/Include/RmlUi/Core/PropertyParser.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPROPERTYPARSER_H -#define RMLUICOREPROPERTYPARSER_H +#ifndef RMLUI_CORE_PROPERTYPARSER_H +#define RMLUI_CORE_PROPERTYPARSER_H #include "Header.h" #include "Property.h" namespace Rml { -namespace Core { using ParameterMap = UnorderedMap< String, int >; @@ -56,7 +55,5 @@ class RMLUICORE_API PropertyParser virtual bool ParseValue(Property& property, const String& value, const ParameterMap& parameters) const = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/PropertySpecification.h b/Include/RmlUi/Core/PropertySpecification.h index 0fceab53c..d6d94d02d 100644 --- a/Include/RmlUi/Core/PropertySpecification.h +++ b/Include/RmlUi/Core/PropertySpecification.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREPROPERTYSPECIFICATION_H -#define RMLUICOREPROPERTYSPECIFICATION_H +#ifndef RMLUI_CORE_PROPERTYSPECIFICATION_H +#define RMLUI_CORE_PROPERTYSPECIFICATION_H #include "Header.h" #include "Types.h" @@ -35,7 +35,6 @@ #include "ID.h" namespace Rml { -namespace Core { class StyleSheetSpecification; class PropertyDefinition; @@ -140,7 +139,5 @@ class RMLUICORE_API PropertySpecification friend class StyleSheetSpecification; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/RenderInterface.h b/Include/RmlUi/Core/RenderInterface.h index f680963bd..61ec27d63 100644 --- a/Include/RmlUi/Core/RenderInterface.h +++ b/Include/RmlUi/Core/RenderInterface.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORERENDERINTERFACE_H -#define RMLUICORERENDERINTERFACE_H +#ifndef RMLUI_CORE_RENDERINTERFACE_H +#define RMLUI_CORE_RENDERINTERFACE_H #include "Traits.h" #include "Header.h" @@ -36,13 +36,12 @@ #include "Types.h" namespace Rml { -namespace Core { class Context; /** The abstract base class for application-specific rendering implementation. Your application must provide a concrete - implementation of this class and install it through Core::SetRenderInterface() in order for anything to be rendered. + implementation of this class and install it through Rml::SetRenderInterface() in order for anything to be rendered. @author Peter Curry */ @@ -123,7 +122,5 @@ class RMLUICORE_API RenderInterface : public NonCopyMoveable friend class Context; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/ScriptInterface.h b/Include/RmlUi/Core/ScriptInterface.h index 2334d876e..371ef6c89 100644 --- a/Include/RmlUi/Core/ScriptInterface.h +++ b/Include/RmlUi/Core/ScriptInterface.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORESCRIPTINTERFACE_H -#define RMLUICORESCRIPTINTERFACE_H +#ifndef RMLUI_CORE_SCRIPTINTERFACE_H +#define RMLUI_CORE_SCRIPTINTERFACE_H #include "Header.h" #include "Traits.h" #include "Types.h" namespace Rml { -namespace Core { /** Base class for all objects that hold a scriptable object. @@ -53,7 +52,5 @@ class RMLUICORE_API ScriptInterface : public Releasable { } }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Spritesheet.h b/Include/RmlUi/Core/Spritesheet.h index 6f8fa5a6f..4c9f24791 100644 --- a/Include/RmlUi/Core/Spritesheet.h +++ b/Include/RmlUi/Core/Spritesheet.h @@ -32,7 +32,6 @@ #include "Texture.h" namespace Rml { -namespace Core { struct Spritesheet; @@ -95,7 +94,5 @@ class SpritesheetList { }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Stream.h b/Include/RmlUi/Core/Stream.h index 94d27350b..cef020e21 100644 --- a/Include/RmlUi/Core/Stream.h +++ b/Include/RmlUi/Core/Stream.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORESTREAM_H -#define RMLUICORESTREAM_H +#ifndef RMLUI_CORE_STREAM_H +#define RMLUI_CORE_STREAM_H #include "Header.h" #include "Traits.h" @@ -35,7 +35,6 @@ #include "URL.h" namespace Rml { -namespace Core { class StreamListener; @@ -130,7 +129,5 @@ class RMLUICORE_API Stream : public NonCopyMoveable int stream_mode; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/StreamMemory.h b/Include/RmlUi/Core/StreamMemory.h index 9d0373a70..24a0ea55d 100644 --- a/Include/RmlUi/Core/StreamMemory.h +++ b/Include/RmlUi/Core/StreamMemory.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORESTREAMMEMORY_H -#define RMLUICORESTREAMMEMORY_H +#ifndef RMLUI_CORE_STREAMMEMORY_H +#define RMLUI_CORE_STREAMMEMORY_H #include "Header.h" #include "Stream.h" namespace Rml { -namespace Core { /** Memory Byte Stream Class @@ -113,7 +112,5 @@ class RMLUICORE_API StreamMemory : public Stream bool Reallocate(size_t size); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/StringUtilities.h b/Include/RmlUi/Core/StringUtilities.h index 7bfdfa9a1..ef11fe7c1 100644 --- a/Include/RmlUi/Core/StringUtilities.h +++ b/Include/RmlUi/Core/StringUtilities.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORESTRINGUTILITIES_H -#define RMLUICORESTRINGUTILITIES_H +#ifndef RMLUI_CORE_STRINGUTILITIES_H +#define RMLUI_CORE_STRINGUTILITIES_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { /** Helper functions for string manipulation. @@ -220,7 +219,5 @@ class RMLUICORE_API StringIteratorU8 { -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/StyleSheet.h b/Include/RmlUi/Core/StyleSheet.h index 4c9641c1e..e1f088e9b 100644 --- a/Include/RmlUi/Core/StyleSheet.h +++ b/Include/RmlUi/Core/StyleSheet.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORESTYLESHEET_H -#define RMLUICORESTYLESHEET_H +#ifndef RMLUI_CORE_STYLESHEET_H +#define RMLUI_CORE_STYLESHEET_H #include "Traits.h" #include "PropertyDictionary.h" #include "Spritesheet.h" namespace Rml { -namespace Core { class Element; class ElementDefinition; @@ -139,7 +138,5 @@ class RMLUICORE_API StyleSheet : public NonCopyMoveable mutable ElementDefinitionCache node_cache; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/StyleSheetSpecification.h b/Include/RmlUi/Core/StyleSheetSpecification.h index 76ec569ea..543624bf2 100644 --- a/Include/RmlUi/Core/StyleSheetSpecification.h +++ b/Include/RmlUi/Core/StyleSheetSpecification.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORESTYLESHEETSPECIFICATION_H -#define RMLUICORESTYLESHEETSPECIFICATION_H +#ifndef RMLUI_CORE_STYLESHEETSPECIFICATION_H +#define RMLUI_CORE_STYLESHEETSPECIFICATION_H #include "Header.h" #include "PropertySpecification.h" #include "Types.h" namespace Rml { -namespace Core { class PropertyParser; struct DefaultStyleSheetParsers; @@ -56,7 +55,7 @@ class RMLUICORE_API StyleSheetSpecification /// @param[in] parser_name The name to register the new parser under. /// @param[in] parser A non-owning pointer to the parser to register. /// @return True if the parser was registered successfully, false otherwise. - /// @lifetime The parser must be kept alive until after the call to Core::Shutdown. + /// @lifetime The parser must be kept alive until after the call to Rml::Shutdown. static bool RegisterParser(const String& parser_name, PropertyParser* parser); /// Returns the parser registered with a specific name. /// @param[in] parser_name The name of the desired parser. @@ -136,7 +135,5 @@ class RMLUICORE_API StyleSheetSpecification UniquePtr default_parsers; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/SystemInterface.h b/Include/RmlUi/Core/SystemInterface.h index e1ed13405..c3f39730b 100644 --- a/Include/RmlUi/Core/SystemInterface.h +++ b/Include/RmlUi/Core/SystemInterface.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORESYSTEMINTERFACE_H -#define RMLUICORESYSTEMINTERFACE_H +#ifndef RMLUI_CORE_SYSTEMINTERFACE_H +#define RMLUI_CORE_SYSTEMINTERFACE_H #include "Types.h" #include "Log.h" @@ -35,7 +35,6 @@ #include "Header.h" namespace Rml { -namespace Core { /** RmlUi's System Interface. @@ -99,7 +98,5 @@ class RMLUICORE_API SystemInterface : public NonCopyMoveable virtual void DeactivateKeyboard(); }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Texture.h b/Include/RmlUi/Core/Texture.h index 5c454707c..76c02fa24 100644 --- a/Include/RmlUi/Core/Texture.h +++ b/Include/RmlUi/Core/Texture.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORETEXTURE_H -#define RMLUICORETEXTURE_H +#ifndef RMLUI_CORE_TEXTURE_H +#define RMLUI_CORE_TEXTURE_H #include "Header.h" #include "Types.h" #include namespace Rml { -namespace Core { class TextureResource; class RenderInterface; @@ -90,7 +89,5 @@ struct RMLUICORE_API Texture SharedPtr resource; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Traits.h b/Include/RmlUi/Core/Traits.h index f876c27d9..11f3dcc70 100644 --- a/Include/RmlUi/Core/Traits.h +++ b/Include/RmlUi/Core/Traits.h @@ -26,15 +26,13 @@ * */ -#ifndef RMLUICORETRAITS_H -#define RMLUICORETRAITS_H +#ifndef RMLUI_CORE_TRAITS_H +#define RMLUI_CORE_TRAITS_H #include "Header.h" #include namespace Rml { -namespace Core { - class RMLUICORE_API NonCopyMoveable { public: @@ -67,7 +65,7 @@ template class RMLUICORE_API Releaser final : public ReleaserBase { public: void operator()(T* target) const { - static_assert(std::is_base_of::value, "Rml::Core::Releaser can only operate with classes derived from Rml::Core::Releasable."); + static_assert(std::is_base_of::value, "Rml::Releaser can only operate with classes derived from ::Rml::Releasable."); Release(static_cast(target)); } }; @@ -98,8 +96,8 @@ class Family : FamilyBase { } }; -} -} +} // namespace Rml + #ifdef RMLUI_USE_CUSTOM_RTTI @@ -132,7 +130,7 @@ Derived rmlui_dynamic_cast(Base base_instance) } template -const char* rmlui_type_name(const T& var) +const char* rmlui_type_name(const T& /*var*/) { return "(type name unavailable)"; } diff --git a/Include/RmlUi/Core/Transform.h b/Include/RmlUi/Core/Transform.h index 338ea5978..4234de1fe 100644 --- a/Include/RmlUi/Core/Transform.h +++ b/Include/RmlUi/Core/Transform.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORETRANSFORM_H -#define RMLUICORETRANSFORM_H +#ifndef RMLUI_CORE_TRANSFORM_H +#define RMLUI_CORE_TRANSFORM_H #include "Header.h" #include "TransformPrimitive.h" namespace Rml { -namespace Core { class Property; @@ -45,7 +44,7 @@ class Property; projection/view matrix in order to render the associated element. @author Markus Schöngart - @see Rml::Core::Variant + @see Rml::Variant */ class RMLUICORE_API Transform @@ -83,7 +82,5 @@ class RMLUICORE_API Transform -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/TransformPrimitive.h b/Include/RmlUi/Core/TransformPrimitive.h index 6d6d35b43..23698137a 100644 --- a/Include/RmlUi/Core/TransformPrimitive.h +++ b/Include/RmlUi/Core/TransformPrimitive.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORETRANSFORMPRIMITIVE_H -#define RMLUICORETRANSFORMPRIMITIVE_H +#ifndef RMLUI_CORE_TRANSFORMPRIMITIVE_H +#define RMLUI_CORE_TRANSFORMPRIMITIVE_H #include "Header.h" #include "Types.h" @@ -36,7 +36,7 @@ namespace Rml { -namespace Core { + namespace Transforms { @@ -296,13 +296,12 @@ struct RMLUICORE_API PrimitiveVariant { /** The Primitive struct is the base struct of geometric transforms such as rotations, scalings and translations. - Instances of this struct are added to a Rml::Core::Transform instance - by the Rml::Core::PropertyParserTransform, which is responsible for - parsing the `transform' property. + Instances of this struct are added to a Rml::Transform instance by the Rml::PropertyParserTransform, which + is responsible for parsing the `transform' property. @author Markus Schöngart - @see Rml::Core::Transform - @see Rml::Core::PropertyParserTransform + @see Rml::Transform + @see Rml::PropertyParserTransform */ struct RMLUICORE_API Primitive { @@ -355,7 +354,5 @@ struct RMLUICORE_API Primitive } -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/TransformState.h b/Include/RmlUi/Core/TransformState.h index 370e44e6e..887970126 100644 --- a/Include/RmlUi/Core/TransformState.h +++ b/Include/RmlUi/Core/TransformState.h @@ -26,15 +26,13 @@ * */ -#ifndef RMLUICORETRANSFORMSTATE_H -#define RMLUICORETRANSFORMSTATE_H +#ifndef RMLUI_CORE_TRANSFORMSTATE_H +#define RMLUI_CORE_TRANSFORMSTATE_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { - class RMLUICORE_API TransformState { @@ -69,7 +67,5 @@ class RMLUICORE_API TransformState mutable Matrix4f inverse_transform; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Tween.h b/Include/RmlUi/Core/Tween.h index 3818d0d5f..453599c9a 100644 --- a/Include/RmlUi/Core/Tween.h +++ b/Include/RmlUi/Core/Tween.h @@ -25,14 +25,13 @@ * */ -#ifndef RMLUICORETWEEN_H -#define RMLUICORETWEEN_H +#ifndef RMLUI_CORE_TWEEN_H +#define RMLUI_CORE_TWEEN_H #include #include "Header.h" namespace Rml { -namespace Core { using String = std::string; @@ -69,7 +68,5 @@ class RMLUICORE_API Tween { }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/TypeConverter.h b/Include/RmlUi/Core/TypeConverter.h index 3d5dd32d1..c5fe61bc8 100644 --- a/Include/RmlUi/Core/TypeConverter.h +++ b/Include/RmlUi/Core/TypeConverter.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORETYPECONVERTER_H -#define RMLUICORETYPECONVERTER_H +#ifndef RMLUI_CORE_TYPECONVERTER_H +#define RMLUI_CORE_TYPECONVERTER_H #include "Platform.h" #include "Types.h" @@ -38,7 +38,6 @@ #include namespace Rml { -namespace Core { /** Templatised TypeConverters with Template Specialisation. @@ -50,24 +49,24 @@ namespace Core { */ template -class TypeConverter +class TypeConverter { -public: +public: static bool Convert(const SourceType& src, DestType& dest); }; template inline String ToString(const T& value, String default_value = String()) { String result = default_value; - TypeConverter::Convert(value, result); + TypeConverter::Convert(value, result); return result; } template inline T FromString(const String& string, T default_value = T()) { - T result = default_value; - TypeConverter::Convert(string, result); - return result; + T result = default_value; + TypeConverter::Convert(string, result); + return result; } @@ -119,10 +118,7 @@ template<> class TypeConverter< FontEffectsPtr, String > { RMLUICORE_API static bool Convert(const FontEffectsPtr& src, String& dest); }; - - -} -} +} // namespace Rml #include "TypeConverter.inl" diff --git a/Include/RmlUi/Core/TypeConverter.inl b/Include/RmlUi/Core/TypeConverter.inl index c804e29f1..0d73f76c8 100644 --- a/Include/RmlUi/Core/TypeConverter.inl +++ b/Include/RmlUi/Core/TypeConverter.inl @@ -27,7 +27,6 @@ */ namespace Rml { -namespace Core { template bool TypeConverter::Convert(const SourceType& /*src*/, DestType& /*dest*/) @@ -373,8 +372,9 @@ VECTOR_STRING_CONVERTER(Colourb, byte, 4); #undef PASS_THROUGH #undef BASIC_CONVERTER #undef BASIC_CONVERTER_BOOL +#undef FLOAT_STRING_CONVERTER +#undef STRING_FLOAT_CONVERTER #undef STRING_VECTOR_CONVERTER #undef VECTOR_STRING_CONVERTER -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/Types.h b/Include/RmlUi/Core/Types.h index 120b4c424..63399ecc4 100644 --- a/Include/RmlUi/Core/Types.h +++ b/Include/RmlUi/Core/Types.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORETYPES_H -#define RMLUICORETYPES_H +#ifndef RMLUI_CORE_TYPES_H +#define RMLUI_CORE_TYPES_H #include #include @@ -48,7 +48,6 @@ #endif namespace Rml { -namespace Core { // Commonly used basic types using byte = unsigned char; @@ -59,7 +58,7 @@ using std::size_t; enum class Character : char32_t { Null, Replacement = 0xfffd }; } -} + #include "Colour.h" #include "Vector2.h" @@ -69,8 +68,6 @@ enum class Character : char32_t { Null, Replacement = 0xfffd }; #include "ObserverPtr.h" namespace Rml { -namespace Core { - // Color and linear algebra using Colourf = Colour< float, 1 >; @@ -196,18 +193,18 @@ using DataViewPtr = UniqueReleaserPtr; class DataController; using DataControllerPtr = UniqueReleaserPtr; -} -} +} // namespace Rml + namespace std { // Hash specialization for enum class types (required on some older compilers) -template <> struct hash<::Rml::Core::PropertyId> { - using utype = typename ::std::underlying_type<::Rml::Core::PropertyId>::type; - size_t operator() (const ::Rml::Core::PropertyId& t) const { ::std::hash h; return h(static_cast(t)); } +template <> struct hash<::Rml::PropertyId> { + using utype = typename ::std::underlying_type<::Rml::PropertyId>::type; + size_t operator() (const ::Rml::PropertyId& t) const { ::std::hash h; return h(static_cast(t)); } }; -template <> struct hash<::Rml::Core::Character> { - using utype = typename ::std::underlying_type<::Rml::Core::Character>::type; - size_t operator() (const ::Rml::Core::Character& t) const { ::std::hash h; return h(static_cast(t)); } +template <> struct hash<::Rml::Character> { + using utype = typename ::std::underlying_type<::Rml::Character>::type; + size_t operator() (const ::Rml::Character& t) const { ::std::hash h; return h(static_cast(t)); } }; } diff --git a/Include/RmlUi/Core/URL.h b/Include/RmlUi/Core/URL.h index c2bfc0d04..fa49a6aa6 100644 --- a/Include/RmlUi/Core/URL.h +++ b/Include/RmlUi/Core/URL.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREURL_H -#define RMLUICOREURL_H +#ifndef RMLUI_CORE_URL_H +#define RMLUI_CORE_URL_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -144,7 +143,5 @@ class RMLUICORE_API URL mutable int url_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Variant.h b/Include/RmlUi/Core/Variant.h index d968273de..93dee84a2 100644 --- a/Include/RmlUi/Core/Variant.h +++ b/Include/RmlUi/Core/Variant.h @@ -35,7 +35,6 @@ #include "Animation.h" namespace Rml { -namespace Core { /** Variant is a container that can store a selection of basic types. The variant will store the @@ -158,8 +157,7 @@ class RMLUICORE_API Variant alignas(TransitionList) char data[LOCAL_DATA_SIZE]; }; -} -} +} // namespace Rml #include "Variant.inl" diff --git a/Include/RmlUi/Core/Variant.inl b/Include/RmlUi/Core/Variant.inl index 739283117..e05cc9a75 100644 --- a/Include/RmlUi/Core/Variant.inl +++ b/Include/RmlUi/Core/Variant.inl @@ -27,7 +27,6 @@ */ namespace Rml { -namespace Core { inline Variant::Type Variant::GetType() const { @@ -154,5 +153,4 @@ inline const T& Variant::GetReference() const return *(T*)data; } -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/Vector2.h b/Include/RmlUi/Core/Vector2.h index 6b836512b..f0e2e71e1 100644 --- a/Include/RmlUi/Core/Vector2.h +++ b/Include/RmlUi/Core/Vector2.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREVECTOR2_H -#define RMLUICOREVECTOR2_H +#ifndef RMLUI_CORE_VECTOR2_H +#define RMLUI_CORE_VECTOR2_H #include "Debug.h" #include "Math.h" namespace Rml { -namespace Core { /** Templated class for a generic two-component vector. @@ -150,8 +149,7 @@ class Vector2 Type y; }; -} -} +} // namespace Rml #include "Vector2.inl" diff --git a/Include/RmlUi/Core/Vector2.inl b/Include/RmlUi/Core/Vector2.inl index 267a24a2e..459d233ec 100644 --- a/Include/RmlUi/Core/Vector2.inl +++ b/Include/RmlUi/Core/Vector2.inl @@ -27,7 +27,6 @@ */ namespace Rml { -namespace Core { // Initialising constructor. template < typename Type > @@ -239,5 +238,4 @@ Vector2< Type >::operator Type* () return &x; } -} -} \ No newline at end of file +} // namespace Rml diff --git a/Include/RmlUi/Core/Vector3.h b/Include/RmlUi/Core/Vector3.h index f0a08d59a..a4485e04b 100644 --- a/Include/RmlUi/Core/Vector3.h +++ b/Include/RmlUi/Core/Vector3.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREVECTOR3_H -#define RMLUICOREVECTOR3_H +#ifndef RMLUI_CORE_VECTOR3_H +#define RMLUI_CORE_VECTOR3_H #include "Debug.h" #include "Math.h" namespace Rml { -namespace Core { /** Templated class for a generic three-component vector. @@ -136,8 +135,7 @@ class Vector3 Type z; }; -} -} +} // namespace Rml #include "Vector3.inl" diff --git a/Include/RmlUi/Core/Vector3.inl b/Include/RmlUi/Core/Vector3.inl index 79642a29c..c7d8afb67 100644 --- a/Include/RmlUi/Core/Vector3.inl +++ b/Include/RmlUi/Core/Vector3.inl @@ -29,7 +29,6 @@ #include namespace Rml { -namespace Core { // Initialising constructor. template < typename Type > @@ -210,5 +209,4 @@ Vector3< Type >::operator Vector2< Type >() const return Vector2< Type >(x, y); } -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/Vector4.h b/Include/RmlUi/Core/Vector4.h index 5960bec64..fce0db6c9 100644 --- a/Include/RmlUi/Core/Vector4.h +++ b/Include/RmlUi/Core/Vector4.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREVECTOR4_H -#define RMLUICOREVECTOR4_H +#ifndef RMLUI_CORE_VECTOR4_H +#define RMLUI_CORE_VECTOR4_H #include "Debug.h" #include "Math.h" #include "Vector3.h" namespace Rml { -namespace Core { /** Templated class for a generic four-component vector. @@ -141,8 +140,7 @@ class Vector4 Type w; }; -} -} +} // namespace Rml #include "Vector4.inl" diff --git a/Include/RmlUi/Core/Vector4.inl b/Include/RmlUi/Core/Vector4.inl index e4110cac5..a26ee445b 100644 --- a/Include/RmlUi/Core/Vector4.inl +++ b/Include/RmlUi/Core/Vector4.inl @@ -29,7 +29,6 @@ #include namespace Rml { -namespace Core { // Initialising constructor. template < typename Type > @@ -217,5 +216,4 @@ Vector4< Type >::operator Vector2< Type >() const return Vector2< Type >(x, y); } -} -} +} // namespace Rml diff --git a/Include/RmlUi/Core/Vertex.h b/Include/RmlUi/Core/Vertex.h index ffeba5942..7f8e70a5e 100644 --- a/Include/RmlUi/Core/Vertex.h +++ b/Include/RmlUi/Core/Vertex.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREVERTEX_H -#define RMLUICOREVERTEX_H +#ifndef RMLUI_CORE_VERTEX_H +#define RMLUI_CORE_VERTEX_H #include "Header.h" #include "Types.h" namespace Rml { -namespace Core { /** The element that makes up all geometry sent to the renderer. @@ -51,7 +50,5 @@ struct RMLUICORE_API Vertex Vector2f tex_coord; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/XMLNodeHandler.h b/Include/RmlUi/Core/XMLNodeHandler.h index 90b45a0b9..33a8e68a2 100644 --- a/Include/RmlUi/Core/XMLNodeHandler.h +++ b/Include/RmlUi/Core/XMLNodeHandler.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREXMLNODEHANDLER_H -#define RMLUICOREXMLNODEHANDLER_H +#ifndef RMLUI_CORE_XMLNODEHANDLER_H +#define RMLUI_CORE_XMLNODEHANDLER_H #include "Header.h" #include "Traits.h" #include "Types.h" namespace Rml { -namespace Core { class Element; class XMLParser; @@ -69,7 +68,5 @@ class RMLUICORE_API XMLNodeHandler : public NonCopyMoveable virtual bool ElementData(XMLParser* parser, const String& data, XMLDataType type) = 0; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/XMLParser.h b/Include/RmlUi/Core/XMLParser.h index 4c53b3d4b..fe5b7b06b 100644 --- a/Include/RmlUi/Core/XMLParser.h +++ b/Include/RmlUi/Core/XMLParser.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREXMLPARSER_H -#define RMLUICOREXMLPARSER_H +#ifndef RMLUI_CORE_XMLPARSER_H +#define RMLUI_CORE_XMLPARSER_H #include #include "Header.h" #include "BaseXMLParser.h" namespace Rml { -namespace Core { class DocumentHeader; class Element; @@ -114,7 +113,5 @@ class RMLUICORE_API XMLParser : public BaseXMLParser ParserStack stack; }; -} -} - +} // namespace Rml #endif diff --git a/Include/RmlUi/Debugger.h b/Include/RmlUi/Debugger.h index d0a180b4a..0c18e37d4 100644 --- a/Include/RmlUi/Debugger.h +++ b/Include/RmlUi/Debugger.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGER_H -#define RMLUIDEBUGGER_H +#ifndef RMLUI_DEBUGGER_H +#define RMLUI_DEBUGGER_H #include "Debugger/Debugger.h" diff --git a/Include/RmlUi/Debugger/Debugger.h b/Include/RmlUi/Debugger/Debugger.h index dea56d77c..5361a0705 100644 --- a/Include/RmlUi/Debugger/Debugger.h +++ b/Include/RmlUi/Debugger/Debugger.h @@ -26,29 +26,26 @@ * */ -#ifndef RMLUIDEBUGGERDEBUGGER_H -#define RMLUIDEBUGGERDEBUGGER_H +#ifndef RMLUI_DEBUGGER_DEBUGGER_H +#define RMLUI_DEBUGGER_DEBUGGER_H #include "Header.h" namespace Rml { -namespace Core { class Context; -} - namespace Debugger { /// Initialises the debug plugin. The debugger will be loaded into the given context. /// @param[in] context The RmlUi context to load the debugger into. The debugging tools will be displayed on this context. If this context is destroyed, the debugger will be released. /// @return True if the debugger was successfully initialised -RMLUIDEBUGGER_API bool Initialise(Core::Context* context); +RMLUIDEBUGGER_API bool Initialise(Context* context); /// Sets the context to be debugged. /// @param[in] context The context to be debugged. /// @return True if the debugger is initialised and the context was switched, false otherwise. -RMLUIDEBUGGER_API bool SetContext(Core::Context* context); +RMLUIDEBUGGER_API bool SetContext(Context* context); /// Sets the visibility of the debugger. /// @param[in] visibility True to show the debugger, false to hide it. @@ -58,6 +55,6 @@ RMLUIDEBUGGER_API void SetVisible(bool visibility); RMLUIDEBUGGER_API bool IsVisible(); } -} +} // namespace Rml #endif diff --git a/Include/RmlUi/Debugger/Header.h b/Include/RmlUi/Debugger/Header.h index 4f8b3bb23..7d404fff7 100644 --- a/Include/RmlUi/Debugger/Header.h +++ b/Include/RmlUi/Debugger/Header.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGERHEADER_H -#define RMLUIDEBUGGERHEADER_H +#ifndef RMLUI_DEBUGGER_HEADER_H +#define RMLUI_DEBUGGER_HEADER_H #include "../Core/Platform.h" diff --git a/Source/Controls/precompiled.h b/Include/RmlUi/Lua.h similarity index 90% rename from Source/Controls/precompiled.h rename to Include/RmlUi/Lua.h index 53b498990..8b4b04578 100644 --- a/Source/Controls/precompiled.h +++ b/Include/RmlUi/Lua.h @@ -26,9 +26,13 @@ * */ -#ifndef RMLUICONTROLSPRECOMPILED_H -#define RMLUICONTROLSPRECOMPILED_H +#ifndef RMLUI_LUA_H +#define RMLUI_LUA_H -#include "../../Include/RmlUi/Controls.h" +#include "Lua/Lua.h" + +#include "Lua/IncludeLua.h" +#include "Lua/LuaType.h" +#include "Lua/Interpreter.h" #endif diff --git a/Include/RmlUi/Controls/Lua/Header.h b/Include/RmlUi/Lua/Header.h similarity index 87% rename from Include/RmlUi/Controls/Lua/Header.h rename to Include/RmlUi/Lua/Header.h index 800a3fb97..1aa6966f3 100644 --- a/Include/RmlUi/Controls/Lua/Header.h +++ b/Include/RmlUi/Lua/Header.h @@ -26,10 +26,10 @@ * */ -#ifndef RMLUICONTROLSLUAHEADER_H -#define RMLUICONTROLSLUAHEADER_H +#ifndef RMLUI_LUA_HEADER_H +#define RMLUI_LUA_HEADER_H -#include "../../Core/Platform.h" +#include #ifdef RMLUILUA_API #undef RMLUILUA_API @@ -37,11 +37,9 @@ #if !defined RMLUI_STATIC_LIB #ifdef RMLUI_PLATFORM_WIN32 - #if defined RmlCoreLua_EXPORTS + #if defined RmlLua_EXPORTS #define RMLUILUA_API __declspec(dllexport) - #elif defined RmlControlsLua_EXPORTS - #define RMLUILUA_API __declspec(dllexport) - #else + #else #define RMLUILUA_API __declspec(dllimport) #endif #else diff --git a/Include/RmlUi/Core/Lua/lua.hpp b/Include/RmlUi/Lua/IncludeLua.h similarity index 95% rename from Include/RmlUi/Core/Lua/lua.hpp rename to Include/RmlUi/Lua/IncludeLua.h index 0338d9dbe..a2eb1723a 100644 --- a/Include/RmlUi/Core/Lua/lua.hpp +++ b/Include/RmlUi/Lua/IncludeLua.h @@ -26,10 +26,14 @@ * */ -//The standard Lua headers +#ifndef RMLUI_LUA_INCLUDELUA_H +#define RMLUI_LUA_INCLUDELUA_H +//The standard Lua headers extern "C" { #include #include #include } + +#endif diff --git a/Include/RmlUi/Core/Lua/Interpreter.h b/Include/RmlUi/Lua/Interpreter.h similarity index 51% rename from Include/RmlUi/Core/Lua/Interpreter.h rename to Include/RmlUi/Lua/Interpreter.h index d86eb042f..8c5ee217d 100644 --- a/Include/RmlUi/Core/Lua/Interpreter.h +++ b/Include/RmlUi/Lua/Interpreter.h @@ -26,100 +26,59 @@ * */ -#ifndef RMLUICORELUAINTERPRETER_H -#define RMLUICORELUAINTERPRETER_H +#ifndef RMLUI_LUA_INTERPRETER_H +#define RMLUI_LUA_INTERPRETER_H #include "Header.h" -#include "lua.hpp" -#include "../Plugin.h" +#include + +typedef struct lua_State lua_State; namespace Rml { -namespace Core { namespace Lua { -class LuaDocumentElementInstancer; -class LuaEventListenerInstancer; - -/** - This initializes the Lua interpreter, and has functions to load the scripts or - call functions that exist in Lua. - - @author Nathan Starkey -*/ -class RMLUILUA_API Interpreter : public Plugin -{ -public: - /** Creates the plugin. - @remark This is equivilent to calling Initialise(nullptr). */ - static void Initialise(); - /** Creates the plugin and adds RmlUi to an existing Lua state if one is provided. - @remark If nullptr is passed as an argument, the plugin will automatically create the lua state during initialisation - and close the state during the call to Rml::Core::Shutdown(). Otherwise, if a Lua state is provided, the user is - responsible for closing the provided Lua state. The state must then be closed after the call to Rml::Core::Shutdown(). - @remark The plugin registers the "body" tag to generate a LuaDocument rather than a Rml::Core::ElementDocument. */ - static void Initialise(lua_State* L); - - /** - @return The lua_State that the Interpreter created in Interpreter::Startup() - @remark This class lacks a SetLuaState for a reason. If you have to use a seperate Lua binding and want to keep the types - from RmlUi, then use this lua_State; it will already have all of the libraries loaded, and all of the types defined. - Alternatively, you can call RegisterCoreTypes(lua_State*) with your own Lua state if you need them defined in it. */ - static lua_State* GetLuaState(); +namespace Interpreter { + /** + @return The lua_State that the Interpreter created in Interpreter::Startup() + @remark This class lacks a SetLuaState for a reason. If you have to use a seperate Lua binding and want to keep the types + from RmlUi, then use this lua_State; it will already have all of the libraries loaded, and all of the types defined. + Alternatively, you can initialise the plugin with your own Lua state if you need them defined in it. */ + RMLUILUA_API lua_State* GetLuaState(); /** This function calls luaL_loadfile and then lua_pcall, reporting the errors (if any) @param[in] file Fully qualified file name to execute. @remark Somewhat misleading name if you are used to the Lua meaning of "load file". It behaves exactly as luaL_dofile does. */ - static void LoadFile(const Rml::Core::String& file); + RMLUILUA_API void LoadFile(const String& file); /** Calls lua_dostring and reports the errors. @param[in] code String to execute @param[in] name Name for the code that will show up in the Log */ - static void DoString(const Rml::Core::String& code, const Rml::Core::String& name = ""); + RMLUILUA_API void DoString(const String& code, const String& name = ""); /** Same as DoString, except does NOT call pcall on it. It will leave the compiled (but not executed) string on top of the stack. It behaves exactly like luaL_loadstring, but you get to specify the name @param[in] code String to compile @param[in] name Name for the code that will show up in the Log */ - static void LoadString(const Rml::Core::String& code, const Rml::Core::String& name = ""); + RMLUILUA_API void LoadString(const String& code, const String& name = ""); /** Clears all of the items on the stack, and pushes the function from funRef on top of the stack. Only use this if you used lua_ref instead of luaL_ref @param[in] funRef Lua reference that you would recieve from calling lua_ref */ - static void BeginCall(int funRef); + RMLUILUA_API void BeginCall(int funRef); /** Uses lua_pcall on a function, which executes the function with params number of parameters and pushes res number of return values on to the stack. @pre Before you call this, your stack should look like: - [1] function to call; + [1] function to call; [2...top] parameters to pass to the function (if any). Or, in words, make sure to push the function on the stack before the parameters. - @post After this function, the params and function will be popped off, and 'res' + @post After this function, the params and function will be popped off, and 'res' number of items will be pushed. */ - static bool ExecuteCall(int params = 0, int res = 0); + RMLUILUA_API bool ExecuteCall(int params = 0, int res = 0); /** removes 'res' number of items from the stack @param[in] res Number of results to remove from the stack. */ - static void EndCall(int res = 0); - -private: - int GetEventClasses() override; - - void OnInitialise() override; - - void OnShutdown() override; - - /** This will populate the global Lua table with all of the Lua core types by calling LuaType::Register - @param[in] L The lua_State to use to register the types - @remark This is called automatically inside of Interpreter::Startup(), so you do not have to - call this function upon initialization of the Interpreter. If you are using RmlControlsLua, then you - \em will need to call Rml::Controls::Lua::RegisterTypes(lua_State*) */ - static void RegisterCoreTypes(lua_State* L); - - LuaDocumentElementInstancer* lua_document_element_instancer = nullptr; - LuaEventListenerInstancer* lua_event_listener_instancer = nullptr; - bool owns_lua_state = false; -}; - -} -} + RMLUILUA_API void EndCall(int res = 0); } -#endif +} // namespace Lua +} // namespace Rml +#endif diff --git a/Include/RmlUi/Controls/Lua/Controls.h b/Include/RmlUi/Lua/Lua.h similarity index 62% rename from Include/RmlUi/Controls/Lua/Controls.h rename to Include/RmlUi/Lua/Lua.h index ca207fe8a..cc7d675f1 100644 --- a/Include/RmlUi/Controls/Lua/Controls.h +++ b/Include/RmlUi/Lua/Lua.h @@ -25,22 +25,29 @@ * THE SOFTWARE. * */ - -#ifndef RMLUICONTROLSLUACONTROLS_H -#define RMLUICONTROLSLUACONTROLS_H + +#ifndef RMLUI_LUA_LUA_H +#define RMLUI_LUA_LUA_H #include "Header.h" +typedef struct lua_State lua_State; + namespace Rml { -namespace Controls { namespace Lua { -/** Doxygen doesn't like to get the namespace, so the full name is -@c Rml::Controls::Lua::RegisterTypes. -This will define all of the types from RmlControls for Lua. -@sa Rml::Core::Lua::Interpreter::RegisterCoreTypes(lua_State*) -@relatesalso Rml::Core::Lua::Interpreter*/ -void RMLUILUA_API RegisterTypes(lua_State* L); -} -} -} + +/** Initialise the Lua plugin. + @remark This is equivalent to calling Initialise(nullptr). */ +RMLUILUA_API void Initialise(); + +/** Initialise the Lua plugin and add RmlUi to an existing Lua state if one is provided. + @remark If nullptr is passed as an argument, the plugin will automatically create the lua state during initialisation + and close the state during the call to Rml::Shutdown(). Otherwise, if a Lua state is provided, the user is + responsible for closing the provided Lua state. The state must then be closed after the call to Rml::Shutdown(). + @remark The plugin registers the "body" tag to generate a LuaDocument rather than a ElementDocument. */ +RMLUILUA_API void Initialise(lua_State* L); + + +} // namespace Lua +} // namespace Rml #endif diff --git a/Include/RmlUi/Core/Lua/LuaType.h b/Include/RmlUi/Lua/LuaType.h similarity index 79% rename from Include/RmlUi/Core/Lua/LuaType.h rename to Include/RmlUi/Lua/LuaType.h index b55fad204..d18fb8536 100644 --- a/Include/RmlUi/Core/Lua/LuaType.h +++ b/Include/RmlUi/Lua/LuaType.h @@ -26,73 +26,54 @@ * */ -#ifndef RMLUICORELUALUATYPE_H -#define RMLUICORELUALUATYPE_H +#ifndef RMLUI_LUA_LUATYPE_H +#define RMLUI_LUA_LUATYPE_H #include "Header.h" -#include "lua.hpp" - +#include "IncludeLua.h" //As an example, if you used this macro like -//LUAMETHOD(Unit,GetId) +//RMLUI_LUAMETHOD(Unit,GetId) //it would result in code that looks like //{ "GetId", UnitGetId }, //Which would force you to create a global function named UnitGetId in C with the correct function signature, usually int(*)(lua_State*,type*); -#define LUAMETHOD(type,name) { #name, type##name }, +#define RMLUI_LUAMETHOD(type,name) { #name, type##name }, //See above, but the method must match the function signature int(*)(lua_State*) and as example: -//LUAGETTER(Unit,Id) would mean you need a function named UnitGetAttrId +//RMLUI_LUAGETTER(Unit,Id) would mean you need a function named UnitGetAttrId //The first stack position will be the userdata -#define LUAGETTER(type,varname) { #varname, type##GetAttr##varname }, +#define RMLUI_LUAGETTER(type,varname) { #varname, type##GetAttr##varname }, //Same method signature as above, but as example: -//LUASETTER(Unit,Id) would mean you need a function named UnitSetAttrId +//RMLUI_LUASETTER(Unit,Id) would mean you need a function named UnitSetAttrId //The first stack position will be the userdata, and the second will be value on the other side of the equal sign -#define LUASETTER(type,varname) { #varname, type##SetAttr##varname }, +#define RMLUI_LUASETTER(type,varname) { #varname, type##SetAttr##varname }, -#define CHECK_BOOL(L,narg) (lua_toboolean((L),(narg)) > 0 ? true : false ) -#define LUACHECKOBJ(obj) if((obj) == nullptr) { lua_pushnil(L); return 1; } +#define RMLUI_CHECK_BOOL(L,narg) (lua_toboolean((L),(narg)) > 0 ? true : false ) +#define RMLUI_CHECK_OBJ(obj) if((obj) == nullptr) { lua_pushnil(L); return 1; } /** Used to remove repetitive typing at the cost of flexibility. When you use this, you @em must have functions with the same name as defined in the macro. For example, if you used @c Element as type, you would have to have functions named @c ElementMethods, @c ElementGetters, @c ElementSetters that return the appropriate - types. - @param is_reference_counted true if the type inherits from Rml::Core::ReferenceCountable, false otherwise*/ -#define LUACORETYPEDEFINE(type) \ + types.*/ +#define RMLUI_LUATYPE_DEFINE(type) \ template<> const char* GetTClassName() { return #type; } \ template<> RegType* GetMethodTable() { return type##Methods; } \ template<> luaL_Reg* GetAttrTable() { return type##Getters; } \ template<> luaL_Reg* SetAttrTable() { return type##Setters; } \ -//We can't use LUACORETYPEDEFINE due to namespace issues -#define LUACONTROLSTYPEDEFINE(type) \ - template<> const char* GetTClassName() { return #type; } \ - template<> RegType* GetMethodTable() { return Rml::Controls::Lua::type##Methods; } \ - template<> luaL_Reg* GetAttrTable() { return Rml::Controls::Lua::type##Getters; } \ - template<> luaL_Reg* SetAttrTable() { return Rml::Controls::Lua::type##Setters; } \ - /** Used to remove repetitive typing at the cost of flexibility. It creates function prototypes for getting the name of the type, method tables, and if it is reference counted. When you use this, you either must also use -the LUACORETYPEDEFINE macro, or make sure that the function signatures are @em exact.*/ -#define LUACORETYPEDECLARE(type) \ +the RMLUI_LUATYPE_DEFINE macro, or make sure that the function signatures are @em exact.*/ +#define RMLUI_LUATYPE_DECLARE(type) \ template<> RMLUILUA_API const char* GetTClassName(); \ template<> RMLUILUA_API RegType* GetMethodTable(); \ template<> RMLUILUA_API luaL_Reg* GetAttrTable(); \ template<> RMLUILUA_API luaL_Reg* SetAttrTable(); \ -/** Used to remove repetitive typing at the cost of flexibility. It creates function prototypes for -getting the name of the type, method tables, and if it is reference counted. -When you use this, you either must also use -the LUACORETYPEDEFINE macro, or make sure that the function signatures are @em exact.*/ -#define LUACONTROLSTYPEDECLARE(type) \ - template<> RMLUILUA_API const char* GetTClassName(); \ - template<> RMLUILUA_API RegType* GetMethodTable(); \ - template<> RMLUILUA_API luaL_Reg* GetAttrTable(); \ - template<> RMLUILUA_API luaL_Reg* SetAttrTable(); \ namespace Rml { -namespace Core { namespace Lua { //replacement for luaL_Reg that uses a different function pointer signature, but similar syntax template @@ -177,13 +158,15 @@ class RMLUILUA_API LuaType static constexpr size_t max_pointer_string_size = 32; LuaType(); //hide constructor - }; - -} -} +namespace LuaTypeImpl { +RMLUILUA_API int index(lua_State* L, const char* class_name); +RMLUILUA_API int newindex(lua_State* L, const char* class_name); } +} // namespace Lua +} // namespace Rml + #include "LuaType.inl" #endif \ No newline at end of file diff --git a/Include/RmlUi/Core/Lua/LuaType.inl b/Include/RmlUi/Lua/LuaType.inl similarity index 69% rename from Include/RmlUi/Core/Lua/LuaType.inl rename to Include/RmlUi/Lua/LuaType.inl index f2cde508f..ab01f6625 100644 --- a/Include/RmlUi/Core/Lua/LuaType.inl +++ b/Include/RmlUi/Lua/LuaType.inl @@ -25,15 +25,10 @@ * THE SOFTWARE. * */ - -//#include "precompiled.h" -#include "../../Controls/Controls.h" -#include "../Core.h" -#include "Utilities.h" namespace Rml { -namespace Core { namespace Lua { + template void LuaType::Register(lua_State* L) { @@ -201,93 +196,18 @@ int LuaType::tostring_T(lua_State* L) } - template int LuaType::index(lua_State* L) { - /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/ - lua_getglobal(L,GetTClassName()); //stack pos [3] (fairly important, just refered to as [3]) - // string form of the key. - const char* key = luaL_checkstring(L,2); - if(lua_istable(L,-1) ) //[-1 = 3] - { - lua_pushvalue(L,2); //[2] = key, [4] = copy of key - lua_rawget(L,-2); //[-2 = 3] -> pop top and push the return value to top [4] - //If the key were looking for is not in the table, retrieve its' metatables' index value. - if(lua_isnil(L,-1)) //[-1 = 4] is value from rawget above - { - //try __getters - lua_pop(L,1); //remove top item (nil) from the stack - lua_pushstring(L, "__getters"); - lua_rawget(L,-2); //[-2 = 3], ._getters -> result to [4] - lua_pushvalue(L,2); //[2 = key] -> copy to [5] - lua_rawget(L,-2); //[-2 = __getters] -> __getters[key], result to [5] - if(lua_type(L,-1) == LUA_TFUNCTION) //[-1 = 5] - { - lua_pushvalue(L,1); //push the userdata to the stack [6] - if(lua_pcall(L,1,1,0) != 0) //remove one, result is at [6] - Report(L, String(GetTClassName()).append(".__index for ").append(lua_tostring(L,2)).append(": ")); - } - else - { - lua_settop(L,4); //forget everything we did above - lua_getmetatable(L,-2); //[-2 = 3] -> metatable from to top [5] - if(lua_istable(L,-1) ) //[-1 = 5] = the result of the above - { - lua_getfield(L,-1,"__index"); //[-1 = 5] = check the __index metamethod for the metatable-> push result to [6] - if(lua_isfunction(L,-1) ) //[-1 = 6] = __index metamethod - { - lua_pushvalue(L,1); //[1] = object -> [7] = object - lua_pushvalue(L,2); //[2] = key -> [8] = key - if(lua_pcall(L,2,1,0) != 0) //call function at top of stack (__index) -> pop top 2 as args; [7] = return value - Report(L, String(GetTClassName()).append(".__index for ").append(lua_tostring(L,2)).append(": ")); - } - else if(lua_istable(L,-1) ) - lua_getfield(L,-1,key); //shorthand version of above -> [7] = return value - else - lua_pushnil(L); //[7] = nil - } - else - lua_pushnil(L); //[6] = nil - } - } - else if(lua_istable(L,-1) )//[-1 = 4] is value from rawget [3] - { - lua_pushvalue(L,2); //[2] = key, [5] = key - lua_rawget(L,-2); //[-2 = 3] = table of -> pop top and push the return value to top [5] - } - } - else - lua_pushnil(L); //[4] = nil - - lua_insert(L,1); //top element to position 1 -> [1] = top element as calculated in the earlier rest of the function - lua_settop(L,1); // -> [1 = -1], removes the other elements - return 1; + const char* class_name = GetTClassName(); + return LuaTypeImpl::index(L, class_name); } - - template int LuaType::newindex(lua_State* L) { - //[1] = obj, [2] = key, [3] = value - //look for it in __setters - lua_getglobal(L,GetTClassName()); //[4] = this table - lua_pushstring(L,"__setters"); //[5] - lua_rawget(L,-2); //[-2 = 4] -> .__setters to [5] - lua_pushvalue(L,2); //[2 = key] -> [6] = copy of key - lua_rawget(L,-2); //[-2 = __setters] -> __setters[key] to [6] - if(lua_type(L,-1) == LUA_TFUNCTION) - { - lua_pushvalue(L,1); //userdata at [7] - lua_pushvalue(L,3); //[8] = copy of [3] - if(lua_pcall(L,2,0,0) != 0) //call function, pop 2 off push 0 on - Report(L, String(GetTClassName()).append(".__newindex for ").append(lua_tostring(L,2)).append(": ")); - } - else - lua_pop(L,1); //not a setter function. - lua_pop(L,2); //pop __setters and the table - return 0; + const char* class_name = GetTClassName(); + return LuaTypeImpl::newindex(L, class_name); } @@ -336,6 +256,6 @@ void LuaType::_regfunctions(lua_State* L, int /*meta*/, int methods) lua_pop(L,1); //pop __setters } -} -} -} + +} // namespace Lua +} // namespace Rml diff --git a/Include/RmlUi/Core/Lua/Utilities.h b/Include/RmlUi/Lua/Utilities.h similarity index 89% rename from Include/RmlUi/Core/Lua/Utilities.h rename to Include/RmlUi/Lua/Utilities.h index bf7adf17f..b202f1971 100644 --- a/Include/RmlUi/Core/Lua/Utilities.h +++ b/Include/RmlUi/Lua/Utilities.h @@ -26,30 +26,29 @@ * */ -#ifndef RMLUICORELUAUTILITIES_H -#define RMLUICORELUAUTILITIES_H +#ifndef RMLUI_LUA_UTILITIES_H +#define RMLUI_LUA_UTILITIES_H /* This file is for free-floating functions that are used across more than one file. */ #include "Header.h" -#include "lua.hpp" +#include "IncludeLua.h" #include "LuaType.h" -#include "../Variant.h" +#include namespace Rml { -namespace Core { namespace Lua { /** casts the variant to its specific type before pushing it to the stack -@relates Rml::Core::Lua::LuaType */ +@relates LuaType */ void RMLUILUA_API PushVariant(lua_State* L, const Variant* var); /** If there are errors on the top of the stack, this will print those out to the log. @param L A Lua state, and if not passed in, will use the Interpreter's state @param place A string that will be printed to the log right before the error message, seperated by a space. Set this when you would get no information about where the error happens. -@relates Rml::Core::Lua::Interpreter */ -void RMLUILUA_API Report(lua_State* L = nullptr, const Rml::Core::String& place = ""); +@relates Interpreter */ +void RMLUILUA_API Report(lua_State* L = nullptr, const String& place = ""); //Helper function, so that the types don't have to define individual functions themselves // to fill the Elements.As table @@ -57,7 +56,7 @@ template int CastFromElementTo(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); LuaType::push(L,(ToType*)ele,false); return 1; } @@ -76,9 +75,6 @@ void AddTypeToElementAsTable(lua_State* L) } lua_settop(L,top); //pop "As" and "Element" } -} -} -} - - +} // namespace Lua +} // namespace Rml #endif diff --git a/Samples/basic/animation/src/main.cpp b/Samples/basic/animation/src/main.cpp index 475483bb1..c5caf4f2f 100644 --- a/Samples/basic/animation/src/main.cpp +++ b/Samples/basic/animation/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -40,9 +39,9 @@ class DemoWindow { public: - DemoWindow(const Rml::Core::String &title, const Rml::Core::Vector2f &position, Rml::Core::Context *context) + DemoWindow(const Rml::String &title, const Rml::Vector2f &position, Rml::Context *context) { - using namespace Rml::Core; + using namespace Rml; document = context->LoadDocument("basic/animation/data/animation.rml"); if (document != nullptr) { @@ -154,17 +153,17 @@ class DemoWindow } } - Rml::Core::ElementDocument * GetDocument() { + Rml::ElementDocument * GetDocument() { return document; } private: - Rml::Core::ElementDocument *document; + Rml::ElementDocument *document; double t_prev_fade = 0; }; -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; DemoWindow* window = nullptr; @@ -201,9 +200,9 @@ void GameLoop() static float ff = 0.0f; ff += float(nudge)*0.3f; auto el = window->GetDocument()->GetElementById("exit"); - el->SetProperty(Rml::Core::PropertyId::MarginLeft, Rml::Core::Property(ff, Rml::Core::Property::PX)); + el->SetProperty(Rml::PropertyId::MarginLeft, Rml::Property(ff, Rml::Property::PX)); float f_left = el->GetAbsoluteLeft(); - Rml::Core::Log::Message(Rml::Core::Log::LT_INFO, "margin-left: '%f' abs: %f.", ff, f_left); + Rml::Log::Message(Rml::Log::LT_INFO, "margin-left: '%f' abs: %f.", ff, f_left); nudge = 0; } @@ -213,20 +212,20 @@ void GameLoop() auto el = window->GetDocument()->GetElementById("fps"); float fps = float(count_frames) / dt; count_frames = 0; - el->SetInnerRML(Rml::Core::CreateString( 20, "FPS: %f", fps )); + el->SetInnerRML(Rml::CreateString( 20, "FPS: %f", fps )); } } -class Event : public Rml::Core::EventListener +class Event : public Rml::EventListener { public: - Event(const Rml::Core::String& value) : value(value) {} + Event(const Rml::String& value) : value(value) {} - void ProcessEvent(Rml::Core::Event& event) override + void ProcessEvent(Rml::Event& event) override { - using namespace Rml::Core; + using namespace Rml; if(value == "exit") Shell::RequestExit(); @@ -235,46 +234,46 @@ class Event : public Rml::Core::EventListener { case EventId::Keydown: { - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_SPACE) + if (key_identifier == Rml::Input::KI_SPACE) { run_loop = !run_loop; } - else if (key_identifier == Rml::Core::Input::KI_RETURN) + else if (key_identifier == Rml::Input::KI_RETURN) { run_loop = false; single_loop = true; } - else if (key_identifier == Rml::Core::Input::KI_OEM_PLUS) + else if (key_identifier == Rml::Input::KI_OEM_PLUS) { nudge = 1; } - else if (key_identifier == Rml::Core::Input::KI_OEM_MINUS) + else if (key_identifier == Rml::Input::KI_OEM_MINUS) { nudge = -1; } - else if (key_identifier == Rml::Core::Input::KI_ESCAPE) + else if (key_identifier == Rml::Input::KI_ESCAPE) { Shell::RequestExit(); } - else if (key_identifier == Rml::Core::Input::KI_LEFT) + else if (key_identifier == Rml::Input::KI_LEFT) { auto el = context->GetRootElement()->GetElementById("keyevent_response"); if (el) el->Animate("left", Property{ -200.f, Property::PX }, 0.5, Tween{ Tween::Cubic }); } - else if (key_identifier == Rml::Core::Input::KI_RIGHT) + else if (key_identifier == Rml::Input::KI_RIGHT) { auto el = context->GetRootElement()->GetElementById("keyevent_response"); if (el) el->Animate("left", Property{ 200.f, Property::PX }, 0.5, Tween{ Tween::Cubic }); } - else if (key_identifier == Rml::Core::Input::KI_UP) + else if (key_identifier == Rml::Input::KI_UP) { auto el = context->GetRootElement()->GetElementById("keyevent_response"); auto offset_right = Property{ 200.f, Property::PX }; if (el) el->Animate("left", Property{ 0.f, Property::PX }, 0.5, Tween{ Tween::Cubic }, 1, true, 0, &offset_right); } - else if (key_identifier == Rml::Core::Input::KI_DOWN) + else if (key_identifier == Rml::Input::KI_DOWN) { auto el = context->GetRootElement()->GetElementById("keyevent_response"); if (el) el->Animate("left", Property{ 0.f, Property::PX }, 0.5, Tween{ Tween::Cubic }); @@ -308,19 +307,19 @@ class Event : public Rml::Core::EventListener } } - void OnDetach(Rml::Core::Element* /*element*/) override { delete this; } + void OnDetach(Rml::Element* /*element*/) override { delete this; } private: - Rml::Core::String value; + Rml::String value; }; -class EventInstancer : public Rml::Core::EventListenerInstancer +class EventInstancer : public Rml::EventListenerInstancer { public: /// Instances a new event handle for Invaders. - Rml::Core::EventListener* InstanceEventListener(const Rml::Core::String& value, Rml::Core::Element* /*element*/) override + Rml::EventListener* InstanceEventListener(const Rml::String& value, Rml::Element* /*element*/) override { return new Event(value); } @@ -360,37 +359,36 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(width, height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(width, height)); + context = Rml::CreateContext("main", Rml::Vector2i(width, height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); EventInstancer event_listener_instancer; - Rml::Core::Factory::RegisterEventListenerInstancer(&event_listener_instancer); + Rml::Factory::RegisterEventListenerInstancer(&event_listener_instancer); Shell::LoadFonts("assets/"); - window = new DemoWindow("Animation sample", Rml::Core::Vector2f(81, 100), context); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Keydown, new Event("hello")); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Keyup, new Event("hello")); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Animationend, new Event("hello")); + window = new DemoWindow("Animation sample", Rml::Vector2f(81, 100), context); + window->GetDocument()->AddEventListener(Rml::EventId::Keydown, new Event("hello")); + window->GetDocument()->AddEventListener(Rml::EventId::Keyup, new Event("hello")); + window->GetDocument()->AddEventListener(Rml::EventId::Animationend, new Event("hello")); Shell::EventLoop(GameLoop); @@ -398,7 +396,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) delete window; // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/benchmark/src/main.cpp b/Samples/basic/benchmark/src/main.cpp index 50d8825d1..26d64f107 100644 --- a/Samples/basic/benchmark/src/main.cpp +++ b/Samples/basic/benchmark/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -37,9 +36,9 @@ class DemoWindow { public: - DemoWindow(const Rml::Core::String &title, const Rml::Core::Vector2f &position, Rml::Core::Context *context) + DemoWindow(const Rml::String &title, const Rml::Vector2f &position, Rml::Context *context) { - using namespace Rml::Core; + using namespace Rml; document = context->LoadDocument("basic/benchmark/data/benchmark.rml"); if (document != nullptr) { @@ -60,7 +59,7 @@ class DemoWindow if (!document) return; - Rml::Core::String rml; + Rml::String rml; for (int i = 0; i < 50; i++) { @@ -68,7 +67,7 @@ class DemoWindow int route = rand() % 50; int max = (rand() % 40) + 10; int value = rand() % max; - Rml::Core::String rml_row = Rml::Core::CreateString(1000, R"( + Rml::String rml_row = Rml::CreateString(1000, R"(
@@ -95,9 +94,9 @@ class DemoWindow el->SetInnerRML(rml); } - class SimpleEventListener : public Rml::Core::EventListener { + class SimpleEventListener : public Rml::EventListener { public: - void ProcessEvent(Rml::Core::Event& event) override { + void ProcessEvent(Rml::Event& event) override { static int i = 0; event.GetTargetElement()->SetProperty("background-color", i++ % 2 == 0 ? "green" : "orange"); } @@ -111,16 +110,16 @@ class DemoWindow } } - Rml::Core::ElementDocument * GetDocument() { + Rml::ElementDocument * GetDocument() { return document; } private: - Rml::Core::ElementDocument *document; + Rml::ElementDocument *document; }; -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; DemoWindow* window = nullptr; @@ -173,66 +172,66 @@ void GameLoop() auto el = window->GetDocument()->GetElementById("fps"); count_frames = 0; - el->SetInnerRML(Rml::Core::CreateString(20, "FPS: %f", fps_mean)); + el->SetInnerRML(Rml::CreateString(20, "FPS: %f", fps_mean)); } } -class Event : public Rml::Core::EventListener +class Event : public Rml::EventListener { public: - Event(const Rml::Core::String& value) : value(value) {} + Event(const Rml::String& value) : value(value) {} - void ProcessEvent(Rml::Core::Event& event) override + void ProcessEvent(Rml::Event& event) override { - using namespace Rml::Core; + using namespace Rml; if(value == "exit") Shell::RequestExit(); if (event == "keydown") { - auto key_identifier = (Rml::Core::Input::KeyIdentifier)event.GetParameter< int >("key_identifier", 0); + auto key_identifier = (Rml::Input::KeyIdentifier)event.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_SPACE) + if (key_identifier == Rml::Input::KI_SPACE) { run_loop = !run_loop; } - else if (key_identifier == Rml::Core::Input::KI_DOWN) + else if (key_identifier == Rml::Input::KI_DOWN) { run_loop = false; single_loop = true; } - else if (key_identifier == Rml::Core::Input::KI_RIGHT) + else if (key_identifier == Rml::Input::KI_RIGHT) { run_update = false; single_update = true; } - else if (key_identifier == Rml::Core::Input::KI_RETURN) + else if (key_identifier == Rml::Input::KI_RETURN) { run_update = !run_update; } - else if (key_identifier == Rml::Core::Input::KI_ESCAPE) + else if (key_identifier == Rml::Input::KI_ESCAPE) { Shell::RequestExit(); } } } - void OnDetach(Rml::Core::Element* /*element*/) override { delete this; } + void OnDetach(Rml::Element* /*element*/) override { delete this; } private: - Rml::Core::String value; + Rml::String value; }; -class EventInstancer : public Rml::Core::EventListenerInstancer +class EventInstancer : public Rml::EventListenerInstancer { public: /// Instances a new event handle for Invaders. - Rml::Core::EventListener* InstanceEventListener(const Rml::Core::String& value, Rml::Core::Element* /*element*/) override + Rml::EventListener* InstanceEventListener(const Rml::String& value, Rml::Element* /*element*/) override { return new Event(value); } @@ -271,37 +270,36 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(width, height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(width, height)); + context = Rml::CreateContext("main", Rml::Vector2i(width, height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); EventInstancer event_listener_instancer; - Rml::Core::Factory::RegisterEventListenerInstancer(&event_listener_instancer); + Rml::Factory::RegisterEventListenerInstancer(&event_listener_instancer); Shell::LoadFonts("assets/"); - window = new DemoWindow("Benchmark sample", Rml::Core::Vector2f(81, 100), context); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Keydown, new Event("hello")); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Keyup, new Event("hello")); - window->GetDocument()->AddEventListener(Rml::Core::EventId::Animationend, new Event("hello")); + window = new DemoWindow("Benchmark sample", Rml::Vector2f(81, 100), context); + window->GetDocument()->AddEventListener(Rml::EventId::Keydown, new Event("hello")); + window->GetDocument()->AddEventListener(Rml::EventId::Keyup, new Event("hello")); + window->GetDocument()->AddEventListener(Rml::EventId::Animationend, new Event("hello")); Shell::EventLoop(GameLoop); @@ -309,7 +307,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) delete window; // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/bitmapfont/src/FontEngineBitmap.cpp b/Samples/basic/bitmapfont/src/FontEngineBitmap.cpp index c034c48f2..36ce44fbe 100644 --- a/Samples/basic/bitmapfont/src/FontEngineBitmap.cpp +++ b/Samples/basic/bitmapfont/src/FontEngineBitmap.cpp @@ -52,7 +52,7 @@ namespace FontProviderBitmap size_t length = 0; { - auto file_interface = Rml::Core::GetFileInterface(); + auto file_interface = Rml::GetFileInterface(); auto handle = file_interface->Open(file_name); if (!handle) return false; @@ -73,7 +73,7 @@ namespace FontProviderBitmap FontParserBitmap parser; { - auto stream = std::make_unique(data.get(), length); + auto stream = std::make_unique(data.get(), length); stream->SetSourceURL(file_name); parser.Parse(stream.get()); @@ -138,7 +138,7 @@ int FontFaceBitmap::GetStringWidth(const String& string, Character previous_char { int width = 0; - for (auto it_char = Rml::Core::StringIteratorU8(string); it_char; ++it_char) + for (auto it_char = Rml::StringIteratorU8(string); it_char; ++it_char) { Character character = *it_char; @@ -162,7 +162,7 @@ int FontFaceBitmap::GenerateString(const String& string, const Vector2f& string_ int width = 0; geometry_list.resize(1); - Rml::Core::Geometry& geometry = geometry_list[0]; + Rml::Geometry& geometry = geometry_list[0]; geometry.SetTexture(&texture); @@ -175,7 +175,7 @@ int FontFaceBitmap::GenerateString(const String& string, const Vector2f& string_ Vector2f position = string_position.Round(); Character previous_character = Character::Null; - for (auto it_char = Rml::Core::StringIteratorU8(string); it_char; ++it_char) + for (auto it_char = Rml::StringIteratorU8(string); it_char; ++it_char) { Character character = *it_char; @@ -197,7 +197,7 @@ int FontFaceBitmap::GenerateString(const String& string, const Vector2f& string_ Vector2f uv_top_left = glyph.position / texture_dimensions; Vector2f uv_bottom_right = (glyph.position + glyph.dimension) / texture_dimensions; - Rml::Core::GeometryUtilities::GenerateQuad( + Rml::GeometryUtilities::GenerateQuad( &vertices[0] + (vertices.size() - 4), &indices[0] + (indices.size() - 6), Vector2f(position + glyph.offset).Round(), @@ -237,11 +237,11 @@ FontParserBitmap::~FontParserBitmap() } // Called when the parser finds the beginning of an element tag. -void FontParserBitmap::HandleElementStart(const String& name, const Rml::Core::XMLAttributes& attributes) +void FontParserBitmap::HandleElementStart(const String& name, const Rml::XMLAttributes& attributes) { if (name == "info") { - family = Rml::Core::StringUtilities::ToLower( Get(attributes, "face", String()) ); + family = Rml::StringUtilities::ToLower( Get(attributes, "face", String()) ); metrics.size = Get(attributes, "size", 0); style = Get(attributes, "italic", 0) == 1 ? FontStyle::Italic : FontStyle::Normal; @@ -260,7 +260,7 @@ void FontParserBitmap::HandleElementStart(const String& name, const Rml::Core::X int id = Get(attributes, "id", -1); if(id != 0) { - Rml::Core::Log::Message(Rml::Core::Log::LT_WARNING, "Only single font textures are supported in Bitmap Font Engine"); + Rml::Log::Message(Rml::Log::LT_WARNING, "Only single font textures are supported in Bitmap Font Engine"); return; } texture_name = Get(attributes, "file", String()); @@ -310,7 +310,7 @@ void FontParserBitmap::HandleElementEnd(const String& RMLUI_UNUSED_PARAMETER(nam } // Called when the parser encounters data. -void FontParserBitmap::HandleData(const String& RMLUI_UNUSED_PARAMETER(data), Rml::Core::XMLDataType RMLUI_UNUSED_PARAMETER(type)) +void FontParserBitmap::HandleData(const String& RMLUI_UNUSED_PARAMETER(data), Rml::XMLDataType RMLUI_UNUSED_PARAMETER(type)) { RMLUI_UNUSED(data); RMLUI_UNUSED(type); diff --git a/Samples/basic/bitmapfont/src/FontEngineBitmap.h b/Samples/basic/bitmapfont/src/FontEngineBitmap.h index 7de26231d..f9fef43dc 100644 --- a/Samples/basic/bitmapfont/src/FontEngineBitmap.h +++ b/Samples/basic/bitmapfont/src/FontEngineBitmap.h @@ -60,10 +60,10 @@ struct FontMetrics { }; // A mapping of characters to their glyphs. -using FontGlyphs = Rml::Core::UnorderedMap; +using FontGlyphs = Rml::UnorderedMap; // Mapping of combined (left, right) character to kerning in pixels. -using FontKerning = Rml::Core::UnorderedMap; +using FontKerning = Rml::UnorderedMap; class FontFaceBitmap { @@ -104,18 +104,18 @@ class FontFaceBitmap { Parses the font meta data from an xml file. */ -class FontParserBitmap : public Rml::Core::BaseXMLParser +class FontParserBitmap : public Rml::BaseXMLParser { public: FontParserBitmap() {} virtual ~FontParserBitmap(); /// Called when the parser finds the beginning of an element tag. - void HandleElementStart(const String& name, const Rml::Core::XMLAttributes& attributes) override; + void HandleElementStart(const String& name, const Rml::XMLAttributes& attributes) override; /// Called when the parser finds the end of an element tag. void HandleElementEnd(const String& name) override; /// Called when the parser encounters data. - void HandleData(const String& data, Rml::Core::XMLDataType type) override; + void HandleData(const String& data, Rml::XMLDataType type) override; String family; FontStyle style = FontStyle::Normal; diff --git a/Samples/basic/bitmapfont/src/FontEngineInterfaceBitmap.h b/Samples/basic/bitmapfont/src/FontEngineInterfaceBitmap.h index 5d2457bf3..117dba72d 100644 --- a/Samples/basic/bitmapfont/src/FontEngineInterfaceBitmap.h +++ b/Samples/basic/bitmapfont/src/FontEngineInterfaceBitmap.h @@ -33,24 +33,24 @@ #include #include -using Rml::Core::FontFaceHandle; -using Rml::Core::FontEffectsHandle; +using Rml::FontFaceHandle; +using Rml::FontEffectsHandle; -using Rml::Core::Vector2i; -using Rml::Core::Vector2f; -using Rml::Core::Colourb; -using Rml::Core::Texture; -using Rml::Core::String; -using Rml::Core::Character; -using Rml::Core::Style::FontStyle; -using Rml::Core::Style::FontWeight; -using Rml::Core::byte; +using Rml::Vector2i; +using Rml::Vector2f; +using Rml::Colourb; +using Rml::Texture; +using Rml::String; +using Rml::Character; +using Rml::Style::FontStyle; +using Rml::Style::FontWeight; +using Rml::byte; -using Rml::Core::FontEffectList; -using Rml::Core::GeometryList; +using Rml::FontEffectList; +using Rml::GeometryList; -class FontEngineInterfaceBitmap : public Rml::Core::FontEngineInterface +class FontEngineInterfaceBitmap : public Rml::FontEngineInterface { public: FontEngineInterfaceBitmap(); diff --git a/Samples/basic/bitmapfont/src/main.cpp b/Samples/basic/bitmapfont/src/main.cpp index 5f5eda735..1e200bf75 100644 --- a/Samples/basic/bitmapfont/src/main.cpp +++ b/Samples/basic/bitmapfont/src/main.cpp @@ -43,7 +43,7 @@ */ -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -92,23 +92,23 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); shell_renderer->SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); // Construct and load the font interface. FontEngineInterfaceBitmap font_interface; - Rml::Core::SetFontEngineInterface(&font_interface); + Rml::SetFontEngineInterface(&font_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -118,15 +118,15 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) shell_renderer->SetContext(context); // Load bitmap font - if (!Rml::Core::LoadFontFace("basic/bitmapfont/data/Comfortaa_Regular_22.fnt")) + if (!Rml::LoadFontFace("basic/bitmapfont/data/Comfortaa_Regular_22.fnt")) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } // Load and show the demo document. - if (Rml::Core::ElementDocument * document = context->LoadDocument("basic/bitmapfont/data/bitmapfont.rml")) + if (Rml::ElementDocument * document = context->LoadDocument("basic/bitmapfont/data/bitmapfont.rml")) { if (auto el = document->GetElementById("title")) el->SetInnerRML("Bitmap font"); @@ -137,7 +137,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::EventLoop(GameLoop); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/customlog/src/SystemInterface.cpp b/Samples/basic/customlog/src/SystemInterface.cpp index cc3dc851e..be41be6d7 100644 --- a/Samples/basic/customlog/src/SystemInterface.cpp +++ b/Samples/basic/customlog/src/SystemInterface.cpp @@ -52,7 +52,7 @@ double SystemInterface::GetElapsedTime() return Shell::GetElapsedTime(); } -bool SystemInterface::LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) +bool SystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message) { if (fp != nullptr) { @@ -60,12 +60,12 @@ bool SystemInterface::LogMessage(Rml::Core::Log::Type type, const Rml::Core::Str const char* prefix; switch (type) { - case Rml::Core::Log::LT_ERROR: - case Rml::Core::Log::LT_ASSERT: + case Rml::Log::LT_ERROR: + case Rml::Log::LT_ASSERT: prefix = "-!-"; break; - case Rml::Core::Log::LT_WARNING: + case Rml::Log::LT_WARNING: prefix = "-*-"; break; @@ -79,9 +79,9 @@ bool SystemInterface::LogMessage(Rml::Core::Log::Type type, const Rml::Core::Str fflush(fp); #ifdef RMLUI_PLATFORM_WIN32 - if (type == Rml::Core::Log::LT_ASSERT) + if (type == Rml::Log::LT_ASSERT) { - Rml::Core::String assert_message = Rml::Core::CreateString(1024, "%s\nWould you like to interrupt execution?", message.c_str()); + Rml::String assert_message = Rml::CreateString(1024, "%s\nWould you like to interrupt execution?", message.c_str()); // Return TRUE if the user presses NO (continue execution) return MessageBox(nullptr, assert_message.c_str(), "Assertion Failure", MB_YESNO | MB_ICONSTOP | MB_DEFBUTTON2 | MB_SYSTEMMODAL) == IDNO; diff --git a/Samples/basic/customlog/src/SystemInterface.h b/Samples/basic/customlog/src/SystemInterface.h index d52cfad00..68486fd04 100644 --- a/Samples/basic/customlog/src/SystemInterface.h +++ b/Samples/basic/customlog/src/SystemInterface.h @@ -36,7 +36,7 @@ @author Lloyd Weehuizen */ -class SystemInterface : public Rml::Core::SystemInterface +class SystemInterface : public Rml::SystemInterface { public: SystemInterface(); @@ -50,7 +50,7 @@ class SystemInterface : public Rml::Core::SystemInterface /// @param[in] type Type of log message, ERROR, WARNING, etc. /// @param[in] message Message to log. /// @return True to continue execution, false to break into the debugger. - bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) override; + bool LogMessage(Rml::Log::Type type, const Rml::String& message) override; private: FILE* fp; diff --git a/Samples/basic/customlog/src/main.cpp b/Samples/basic/customlog/src/main.cpp index 820d465c9..95d50227b 100644 --- a/Samples/basic/customlog/src/main.cpp +++ b/Samples/basic/customlog/src/main.cpp @@ -33,7 +33,7 @@ #include #include "SystemInterface.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -82,20 +82,20 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); // Initialise our system interface to write the log messages to file. ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -107,7 +107,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Load a non-existent document to spawn an error message. - Rml::Core::ElementDocument* invalid_document = context->LoadDocument("assets/invalid.rml"); + Rml::ElementDocument* invalid_document = context->LoadDocument("assets/invalid.rml"); RMLUI_ASSERTMSG(invalid_document != nullptr, "Testing ASSERT logging."); if (invalid_document != nullptr) { @@ -115,7 +115,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // Load and show the demo document. - Rml::Core::ElementDocument* document = context->LoadDocument("assets/demo.rml"); + Rml::ElementDocument* document = context->LoadDocument("assets/demo.rml"); if (document != nullptr) { document->Show(); @@ -124,7 +124,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::EventLoop(GameLoop); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/databinding/src/main.cpp b/Samples/basic/databinding/src/main.cpp index 9e1a9bd4c..e9e0320a0 100644 --- a/Samples/basic/databinding/src/main.cpp +++ b/Samples/basic/databinding/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -37,17 +36,17 @@ namespace BasicExample { - Rml::Core::DataModelHandle model_handle; + Rml::DataModelHandle model_handle; struct MyData { - Rml::Core::String title = "Simple data binding example"; - Rml::Core::String animal = "dog"; + Rml::String title = "Simple data binding example"; + Rml::String animal = "dog"; bool show_text = true; } my_data; - bool Initialize(Rml::Core::Context* context) + bool Initialize(Rml::Context* context) { - Rml::Core::DataModelConstructor constructor = context->CreateDataModel("basics"); + Rml::DataModelConstructor constructor = context->CreateDataModel("basics"); if (!constructor) return false; @@ -69,18 +68,18 @@ namespace BasicExample { namespace EventsExample { - Rml::Core::DataModelHandle model_handle; + Rml::DataModelHandle model_handle; struct MyData { - Rml::Core::String hello_world = "Hello World!"; - Rml::Core::String mouse_detector = "Mouse-move Detector."; + Rml::String hello_world = "Hello World!"; + Rml::String mouse_detector = "Mouse-move Detector."; int rating = 99; std::vector list = { 1, 2, 3, 4, 5 }; - std::vector positions; + std::vector positions; - void AddMousePos(Rml::Core::DataModelHandle model, Rml::Core::Event& ev, const Rml::Core::VariantList& /*arguments*/) + void AddMousePos(Rml::DataModelHandle model, Rml::Event& ev, const Rml::VariantList& /*arguments*/) { positions.emplace_back(ev.GetParameter("mouse_x", 0.f), ev.GetParameter("mouse_y", 0.f)); model.DirtyVariable("positions"); @@ -89,21 +88,21 @@ namespace EventsExample { } my_data; - void ClearPositions(Rml::Core::DataModelHandle model, Rml::Core::Event& /*ev*/, const Rml::Core::VariantList& /*arguments*/) + void ClearPositions(Rml::DataModelHandle model, Rml::Event& /*ev*/, const Rml::VariantList& /*arguments*/) { my_data.positions.clear(); model.DirtyVariable("positions"); } - void HasGoodRating(Rml::Core::Variant& variant) + void HasGoodRating(Rml::Variant& variant) { variant = int(my_data.rating > 50); } - bool Initialize(Rml::Core::Context* context) + bool Initialize(Rml::Context* context) { - using namespace Rml::Core; + using namespace Rml; DataModelConstructor constructor = context->CreateDataModel("events"); if (!constructor) return false; @@ -164,24 +163,24 @@ namespace EventsExample { namespace InvadersExample { - Rml::Core::DataModelHandle model_handle; + Rml::DataModelHandle model_handle; struct Invader { - Rml::Core::String name; - Rml::Core::String sprite; - Rml::Core::Colourb color{ 255, 255, 255 }; + Rml::String name; + Rml::String sprite; + Rml::Colourb color{ 255, 255, 255 }; std::vector damage; float danger_rating = 50; - void GetColor(Rml::Core::Variant& variant) { - variant = "rgba(" + Rml::Core::ToString(color) + ')'; + void GetColor(Rml::Variant& variant) { + variant = "rgba(" + Rml::ToString(color) + ')'; } - void SetColor(const Rml::Core::Variant& variant) { - using namespace Rml::Core; + void SetColor(const Rml::Variant& variant) { + using namespace Rml; String str = variant.Get(); if (str.size() > 6) str = str.substr(5, str.size() - 6); - color = Rml::Core::FromString(variant.Get()); + color = Rml::FromString(variant.Get()); } }; @@ -195,7 +194,7 @@ namespace InvadersExample { Invader{"Angry invader", "icon-invader", {255, 40, 30}, {3, 6, 7}, 80} }; - void LaunchWeapons(Rml::Core::DataModelHandle model, Rml::Core::Event& /*ev*/, const Rml::Core::VariantList& /*arguments*/) + void LaunchWeapons(Rml::DataModelHandle model, Rml::Event& /*ev*/, const Rml::VariantList& /*arguments*/) { invaders.clear(); model.DirtyVariable("invaders"); @@ -203,9 +202,9 @@ namespace InvadersExample { } invaders_data; - bool Initialize(Rml::Core::Context* context) + bool Initialize(Rml::Context* context) { - Rml::Core::DataModelConstructor constructor = context->CreateDataModel("invaders"); + Rml::DataModelConstructor constructor = context->CreateDataModel("invaders"); if (!constructor) return false; @@ -246,7 +245,7 @@ namespace InvadersExample { const double t_next_spawn = invaders_data.time_last_invader_spawn + 60.0 / double(invaders_data.incoming_invaders_rate); if (t >= t_next_spawn) { - using namespace Rml::Core; + using namespace Rml; const int num_items = 4; static std::array names = { "Angry invader", "Harmless invader", "Deceitful invader", "Cute invader" }; static std::array sprites = { "icon-invader", "icon-flag", "icon-game", "icon-waves" }; @@ -284,12 +283,12 @@ namespace InvadersExample { -class DemoWindow : public Rml::Core::EventListener +class DemoWindow : public Rml::EventListener { public: - DemoWindow(const Rml::Core::String &title, const Rml::Core::Vector2f &position, Rml::Core::Context *context) + DemoWindow(const Rml::String &title, const Rml::Vector2f &position, Rml::Context *context) { - using namespace Rml::Core; + using namespace Rml; document = context->LoadDocument("basic/databinding/data/databinding.rml"); if (document) { @@ -310,21 +309,19 @@ class DemoWindow : public Rml::Core::EventListener } } - void ProcessEvent(Rml::Core::Event& event) override + void ProcessEvent(Rml::Event& event) override { - using namespace Rml::Core; - switch (event.GetId()) { - case EventId::Keydown: + case Rml::EventId::Keydown: { - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_ESCAPE) + if (key_identifier == Rml::Input::KI_ESCAPE) { Shell::RequestExit(); } - else if (key_identifier == Rml::Core::Input::KI_F8) + else if (key_identifier == Rml::Input::KI_F8) { Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible()); } @@ -336,23 +333,23 @@ class DemoWindow : public Rml::Core::EventListener } } - Rml::Core::ElementDocument * GetDocument() { + Rml::ElementDocument * GetDocument() { return document; } private: - Rml::Core::ElementDocument *document = nullptr; + Rml::ElementDocument *document = nullptr; }; -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; void GameLoop() { - const double t = Rml::Core::GetSystemInterface()->GetElapsedTime(); + const double t = Rml::GetSystemInterface()->GetElapsedTime(); BasicExample::Update(); EventsExample::Update(); @@ -399,16 +396,16 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(width, height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(width, height)); + context = Rml::CreateContext("main", Rml::Vector2i(width, height)); if (!context || !BasicExample::Initialize(context) @@ -416,28 +413,27 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) || !InvadersExample::Initialize(context) ) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); Shell::LoadFonts("assets/"); - auto demo_window = std::make_unique("Data binding", Rml::Core::Vector2f(150, 50), context); - demo_window->GetDocument()->AddEventListener(Rml::Core::EventId::Keydown, demo_window.get()); - demo_window->GetDocument()->AddEventListener(Rml::Core::EventId::Keyup, demo_window.get()); + auto demo_window = std::make_unique("Data binding", Rml::Vector2f(150, 50), context); + demo_window->GetDocument()->AddEventListener(Rml::EventId::Keydown, demo_window.get()); + demo_window->GetDocument()->AddEventListener(Rml::EventId::Keyup, demo_window.get()); Shell::EventLoop(GameLoop); demo_window->Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/demo/src/main.cpp b/Samples/basic/demo/src/main.cpp index 813059da7..a2851245d 100644 --- a/Samples/basic/demo/src/main.cpp +++ b/Samples/basic/demo/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -35,7 +34,7 @@ #include #include -static const Rml::Core::String sandbox_default_rcss = R"( +static const Rml::String sandbox_default_rcss = R"( body { top: 0; left: 0; right: 0; bottom: 0; overflow: hidden auto; } scrollbarvertical { width: 15px; } scrollbarvertical slidertrack { background: #eee; } @@ -52,12 +51,12 @@ scrollbarhorizontal sliderbar:active { background: #666; } )"; -class DemoWindow : public Rml::Core::EventListener +class DemoWindow : public Rml::EventListener { public: - DemoWindow(const Rml::Core::String &title, const Rml::Core::Vector2f &position, Rml::Core::Context *context) + DemoWindow(const Rml::String &title, const Rml::Vector2f &position, Rml::Context *context) { - using namespace Rml::Core; + using namespace Rml; document = context->LoadDocument("basic/demo/data/demo.rml"); if (document != nullptr) { @@ -68,7 +67,7 @@ class DemoWindow : public Rml::Core::EventListener } // Add sandbox default text. - if (auto source = static_cast(document->GetElementById("sandbox_rml_source"))) + if (auto source = static_cast(document->GetElementById("sandbox_rml_source"))) { auto value = source->GetValue(); value += "

Write your RML here

\n\n"; @@ -86,11 +85,11 @@ class DemoWindow : public Rml::Core::EventListener iframe->SetInnerRML("

Rendered output goes here.

"); // Load basic RML style sheet - Rml::Core::String style_sheet_content; + Rml::String style_sheet_content; { // Load file into string - auto file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle handle = file_interface->Open("assets/rml.rcss"); + auto file_interface = Rml::GetFileInterface(); + Rml::FileHandle handle = file_interface->Open("assets/rml.rcss"); size_t length = file_interface->Length(handle); style_sheet_content.resize(length); @@ -100,17 +99,17 @@ class DemoWindow : public Rml::Core::EventListener style_sheet_content += sandbox_default_rcss; } - Rml::Core::StreamMemory stream((Rml::Core::byte*)style_sheet_content.data(), style_sheet_content.size()); + Rml::StreamMemory stream((Rml::byte*)style_sheet_content.data(), style_sheet_content.size()); stream.SetSourceURL("sandbox://default_rcss"); - rml_basic_style_sheet = std::make_shared(); + rml_basic_style_sheet = std::make_shared(); rml_basic_style_sheet->LoadStyleSheet(&stream); } // Add sandbox style sheet text. - if (auto source = static_cast(document->GetElementById("sandbox_rcss_source"))) + if (auto source = static_cast(document->GetElementById("sandbox_rcss_source"))) { - Rml::Core::String value = "/* Write your RCSS here */\n\n/* body { color: #fea; background: #224; }\nimg { image-color: red; } */"; + Rml::String value = "/* Write your RCSS here */\n\n/* body { color: #fea; background: #224; }\nimg { image-color: red; } */"; source->SetValue(value); SetSandboxStylesheet(value); } @@ -129,7 +128,7 @@ class DemoWindow : public Rml::Core::EventListener } if (submitting && gauge && progress_horizontal) { - using namespace Rml::Core; + using namespace Rml; constexpr float progressbars_time = 2.f; const float progress = Math::Min(float(GetSystemInterface()->GetElapsedTime() - submitting_start_time) / progressbars_time, 2.f); @@ -184,17 +183,17 @@ class DemoWindow : public Rml::Core::EventListener } } - void ProcessEvent(Rml::Core::Event& event) override + void ProcessEvent(Rml::Event& event) override { - using namespace Rml::Core; + using namespace Rml; switch (event.GetId()) { case EventId::Keydown: { - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_ESCAPE) + if (key_identifier == Rml::Input::KI_ESCAPE) { Shell::RequestExit(); } @@ -206,14 +205,14 @@ class DemoWindow : public Rml::Core::EventListener } } - Rml::Core::ElementDocument * GetDocument() { + Rml::ElementDocument * GetDocument() { return document; } - void SubmitForm(Rml::Core::String in_submit_message) + void SubmitForm(Rml::String in_submit_message) { submitting = true; - submitting_start_time = Rml::Core::GetSystemInterface()->GetElapsedTime(); + submitting_start_time = Rml::GetSystemInterface()->GetElapsedTime(); submit_message = in_submit_message; if (auto el_output = document->GetElementById("form_output")) el_output->SetInnerRML(""); @@ -221,12 +220,12 @@ class DemoWindow : public Rml::Core::EventListener el_progress->SetProperty("display", "block"); } - void SetSandboxStylesheet(const Rml::Core::String& string) + void SetSandboxStylesheet(const Rml::String& string) { if (iframe && rml_basic_style_sheet) { - auto style = std::make_shared(); - Rml::Core::StreamMemory stream((const Rml::Core::byte*)string.data(), string.size()); + auto style = std::make_shared(); + Rml::StreamMemory stream((const Rml::byte*)string.data(), string.size()); stream.SetSourceURL("sandbox://rcss"); style->LoadStyleSheet(&stream); @@ -235,7 +234,7 @@ class DemoWindow : public Rml::Core::EventListener } } - void SetSandboxBody(const Rml::Core::String& string) + void SetSandboxBody(const Rml::String& string) { if (iframe) { @@ -244,24 +243,24 @@ class DemoWindow : public Rml::Core::EventListener } private: - Rml::Core::ElementDocument *document = nullptr; - Rml::Core::ElementDocument *iframe = nullptr; - Rml::Core::Element *gauge = nullptr, *progress_horizontal = nullptr; - Rml::Core::SharedPtr rml_basic_style_sheet; + Rml::ElementDocument *document = nullptr; + Rml::ElementDocument *iframe = nullptr; + Rml::Element *gauge = nullptr, *progress_horizontal = nullptr; + Rml::SharedPtr rml_basic_style_sheet; bool submitting = false; double submitting_start_time = 0; - Rml::Core::String submit_message; + Rml::String submit_message; }; -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; std::unique_ptr demo_window; struct TweeningParameters { - Rml::Core::Tween::Type type = Rml::Core::Tween::Linear; - Rml::Core::Tween::Direction direction = Rml::Core::Tween::Out; + Rml::Tween::Type type = Rml::Tween::Linear; + Rml::Tween::Direction direction = Rml::Tween::Out; float duration = 0.5f; } tweening_parameters; @@ -279,14 +278,14 @@ void GameLoop() -class DemoEventListener : public Rml::Core::EventListener +class DemoEventListener : public Rml::EventListener { public: - DemoEventListener(const Rml::Core::String& value, Rml::Core::Element* element) : value(value), element(element) {} + DemoEventListener(const Rml::String& value, Rml::Element* element) : value(value), element(element) {} - void ProcessEvent(Rml::Core::Event& event) override + void ProcessEvent(Rml::Event& event) override { - using namespace Rml::Core; + using namespace Rml; if (value == "exit") { @@ -362,7 +361,7 @@ class DemoEventListener : public Rml::Core::EventListener } else if (value == "tween_duration") { - float value = (float)std::atof(static_cast(element)->GetValue().c_str()); + float value = (float)std::atof(static_cast(element)->GetValue().c_str()); tweening_parameters.duration = value; if (auto el_duration = element->GetElementById("duration")) el_duration->SetInnerRML(CreateString(20, "%2.2f", value)); @@ -374,13 +373,13 @@ class DemoEventListener : public Rml::Core::EventListener if (el_rating && el_rating_emoji) { enum { Sad, Mediocre, Exciting, Celebrate, Champion, CountEmojis }; - static const Rml::Core::String emojis[CountEmojis] = { + static const Rml::String emojis[CountEmojis] = { (const char*)u8"😢", (const char*)u8"😐", (const char*)u8"😮", (const char*)u8"😎", (const char*)u8"🏆" }; int value = event.GetParameter("value", 50); - Rml::Core::String emoji; + Rml::String emoji; if (value <= 0) emoji = emojis[Sad]; else if(value < 50) @@ -392,17 +391,17 @@ class DemoEventListener : public Rml::Core::EventListener else emoji = emojis[Champion]; - el_rating->SetInnerRML(Rml::Core::CreateString(30, "%d%%", value)); + el_rating->SetInnerRML(Rml::CreateString(30, "%d%%", value)); el_rating_emoji->SetInnerRML(emoji); } } else if (value == "submit_form") { const auto& p = event.GetParameters(); - Rml::Core::String output = "

"; + Rml::String output = "

"; for (auto& entry : p) { - auto value = Rml::Core::StringUtilities::EncodeRml(entry.second.Get()); + auto value = Rml::StringUtilities::EncodeRml(entry.second.Get()); if (entry.first == "message") value = "
" + value; output += "" + entry.first + ": " + value + "
"; @@ -413,7 +412,7 @@ class DemoEventListener : public Rml::Core::EventListener } else if (value == "set_sandbox_body") { - if (auto source = static_cast(element->GetElementById("sandbox_rml_source"))) + if (auto source = static_cast(element->GetElementById("sandbox_rml_source"))) { auto value = source->GetValue(); demo_window->SetSandboxBody(value); @@ -421,7 +420,7 @@ class DemoEventListener : public Rml::Core::EventListener } else if (value == "set_sandbox_style") { - if (auto source = static_cast(element->GetElementById("sandbox_rcss_source"))) + if (auto source = static_cast(element->GetElementById("sandbox_rcss_source"))) { auto value = source->GetValue(); demo_window->SetSandboxStylesheet(value); @@ -429,19 +428,19 @@ class DemoEventListener : public Rml::Core::EventListener } } - void OnDetach(Rml::Core::Element* /*element*/) override { delete this; } + void OnDetach(Rml::Element* /*element*/) override { delete this; } private: - Rml::Core::String value; - Rml::Core::Element* element; + Rml::String value; + Rml::Element* element; }; -class DemoEventListenerInstancer : public Rml::Core::EventListenerInstancer +class DemoEventListenerInstancer : public Rml::EventListenerInstancer { public: - Rml::Core::EventListener* InstanceEventListener(const Rml::Core::String& value, Rml::Core::Element* element) override + Rml::EventListener* InstanceEventListener(const Rml::String& value, Rml::Element* element) override { return new DemoEventListener(value, element); } @@ -480,24 +479,23 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(width, height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(width, height)); + context = Rml::CreateContext("main", Rml::Vector2i(width, height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); @@ -505,21 +503,21 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) context->SetDensityIndependentPixelRatio(1.0f); DemoEventListenerInstancer event_listener_instancer; - Rml::Core::Factory::RegisterEventListenerInstancer(&event_listener_instancer); + Rml::Factory::RegisterEventListenerInstancer(&event_listener_instancer); Shell::LoadFonts("assets/"); - demo_window = std::make_unique("Demo sample", Rml::Core::Vector2f(150, 50), context); - demo_window->GetDocument()->AddEventListener(Rml::Core::EventId::Keydown, demo_window.get()); - demo_window->GetDocument()->AddEventListener(Rml::Core::EventId::Keyup, demo_window.get()); - demo_window->GetDocument()->AddEventListener(Rml::Core::EventId::Animationend, demo_window.get()); + demo_window = std::make_unique("Demo sample", Rml::Vector2f(150, 50), context); + demo_window->GetDocument()->AddEventListener(Rml::EventId::Keydown, demo_window.get()); + demo_window->GetDocument()->AddEventListener(Rml::EventId::Keyup, demo_window.get()); + demo_window->GetDocument()->AddEventListener(Rml::EventId::Animationend, demo_window.get()); Shell::EventLoop(GameLoop); demo_window->Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/drag/src/DragListener.cpp b/Samples/basic/drag/src/DragListener.cpp index 1e9ba9a95..3dcef7d3b 100644 --- a/Samples/basic/drag/src/DragListener.cpp +++ b/Samples/basic/drag/src/DragListener.cpp @@ -32,23 +32,23 @@ static DragListener drag_listener; // Registers an element as being a container of draggable elements. -void DragListener::RegisterDraggableContainer(Rml::Core::Element* element) +void DragListener::RegisterDraggableContainer(Rml::Element* element) { - element->AddEventListener(Rml::Core::EventId::Dragdrop, &drag_listener); + element->AddEventListener(Rml::EventId::Dragdrop, &drag_listener); } -void DragListener::ProcessEvent(Rml::Core::Event& event) +void DragListener::ProcessEvent(Rml::Event& event) { - if (event == Rml::Core::EventId::Dragdrop) + if (event == Rml::EventId::Dragdrop) { - Rml::Core::Element* dest_container = event.GetCurrentElement(); - Rml::Core::Element* dest_element = event.GetTargetElement(); - Rml::Core::Element* drag_element = static_cast< Rml::Core::Element* >(event.GetParameter< void* >("drag_element", nullptr)); + Rml::Element* dest_container = event.GetCurrentElement(); + Rml::Element* dest_element = event.GetTargetElement(); + Rml::Element* drag_element = static_cast< Rml::Element* >(event.GetParameter< void* >("drag_element", nullptr)); if (dest_container == dest_element) { // The dragged element was dragged directly onto a container. - Rml::Core::ElementPtr element = drag_element->GetParentNode()->RemoveChild(drag_element); + Rml::ElementPtr element = drag_element->GetParentNode()->RemoveChild(drag_element); dest_container->AppendChild(std::move(element)); } else @@ -56,7 +56,7 @@ void DragListener::ProcessEvent(Rml::Core::Event& event) // The dragged element was dragged onto an item inside a container. In order to get the // element in the right place, it will be inserted into the container before the item // it was dragged on top of. - Rml::Core::Element* insert_before = dest_element; + Rml::Element* insert_before = dest_element; // Unless of course if it was dragged on top of an item in its own container; we need // to check then if it was moved up or down with the container. @@ -64,7 +64,7 @@ void DragListener::ProcessEvent(Rml::Core::Event& event) { // Check whether we're moving this icon from the left or the right. - Rml::Core::Element* previous_icon = insert_before->GetPreviousSibling(); + Rml::Element* previous_icon = insert_before->GetPreviousSibling(); while (previous_icon != nullptr) { if (previous_icon == drag_element) @@ -77,7 +77,7 @@ void DragListener::ProcessEvent(Rml::Core::Event& event) } } - Rml::Core::ElementPtr element = drag_element->GetParentNode()->RemoveChild(drag_element); + Rml::ElementPtr element = drag_element->GetParentNode()->RemoveChild(drag_element); dest_container->InsertBefore(std::move(element), insert_before); } } diff --git a/Samples/basic/drag/src/DragListener.h b/Samples/basic/drag/src/DragListener.h index 28170ca48..06a8176f3 100644 --- a/Samples/basic/drag/src/DragListener.h +++ b/Samples/basic/drag/src/DragListener.h @@ -36,14 +36,14 @@ @author Pete */ -class DragListener : public Rml::Core::EventListener +class DragListener : public Rml::EventListener { public: /// Registers an elemenet as being a container of draggable elements. - static void RegisterDraggableContainer(Rml::Core::Element* element); + static void RegisterDraggableContainer(Rml::Element* element); protected: - void ProcessEvent(Rml::Core::Event& event) override; + void ProcessEvent(Rml::Event& event) override; }; #endif diff --git a/Samples/basic/drag/src/Inventory.cpp b/Samples/basic/drag/src/Inventory.cpp index ad08d913c..0169e0527 100644 --- a/Samples/basic/drag/src/Inventory.cpp +++ b/Samples/basic/drag/src/Inventory.cpp @@ -31,15 +31,15 @@ #include "DragListener.h" // Constructs a new inventory and opens its window. -Inventory::Inventory(const Rml::Core::String& title, const Rml::Core::Vector2f& position, Rml::Core::Context* context) +Inventory::Inventory(const Rml::String& title, const Rml::Vector2f& position, Rml::Context* context) { document = context->LoadDocument("basic/drag/data/inventory.rml"); if (document != nullptr) { - using Rml::Core::PropertyId; + using Rml::PropertyId; document->GetElementById("title")->SetInnerRML(title); - document->SetProperty(PropertyId::Left, Rml::Core::Property(position.x, Rml::Core::Property::PX)); - document->SetProperty(PropertyId::Top, Rml::Core::Property(position.y, Rml::Core::Property::PX)); + document->SetProperty(PropertyId::Left, Rml::Property(position.x, Rml::Property::PX)); + document->SetProperty(PropertyId::Top, Rml::Property(position.y, Rml::Property::PX)); document->Show(); } @@ -56,16 +56,16 @@ Inventory::~Inventory() } // Adds a brand-new item into this inventory. -void Inventory::AddItem(const Rml::Core::String& name) +void Inventory::AddItem(const Rml::String& name) { if (document == nullptr) return; - Rml::Core::Element* content = document->GetElementById("content"); + Rml::Element* content = document->GetElementById("content"); if (content == nullptr) return; // Create the new 'icon' element. - Rml::Core::Element* icon = content->AppendChild(Rml::Core::Factory::InstanceElement(content, "icon", "icon", Rml::Core::XMLAttributes())); + Rml::Element* icon = content->AppendChild(Rml::Factory::InstanceElement(content, "icon", "icon", Rml::XMLAttributes())); icon->SetInnerRML(name); } diff --git a/Samples/basic/drag/src/Inventory.h b/Samples/basic/drag/src/Inventory.h index c82db0902..d16a71ab5 100644 --- a/Samples/basic/drag/src/Inventory.h +++ b/Samples/basic/drag/src/Inventory.h @@ -44,16 +44,16 @@ class Inventory /// @param[in] title The title of the new inventory. /// @param[in] position The position of the inventory window. /// @param[in] context The context to open the inventory window in. - Inventory(const Rml::Core::String& title, const Rml::Core::Vector2f& position, Rml::Core::Context* context); + Inventory(const Rml::String& title, const Rml::Vector2f& position, Rml::Context* context); /// Destroys the inventory and closes its window. ~Inventory(); /// Adds a brand-new item into this inventory. /// @param[in] name The name of this item. - void AddItem(const Rml::Core::String& name); + void AddItem(const Rml::String& name); private: - Rml::Core::ElementDocument* document; + Rml::ElementDocument* document; }; #endif diff --git a/Samples/basic/drag/src/main.cpp b/Samples/basic/drag/src/main.cpp index 52fd33fbc..e70748575 100644 --- a/Samples/basic/drag/src/main.cpp +++ b/Samples/basic/drag/src/main.cpp @@ -33,7 +33,7 @@ #include #include "Inventory.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -88,19 +88,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -112,8 +112,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Load and show the inventory document. - Inventory* inventory_1 = new Inventory("Inventory 1", Rml::Core::Vector2f(50, 200), context); - Inventory* inventory_2 = new Inventory("Inventory 2", Rml::Core::Vector2f(540, 240), context); + Inventory* inventory_1 = new Inventory("Inventory 1", Rml::Vector2f(50, 200), context); + Inventory* inventory_2 = new Inventory("Inventory 2", Rml::Vector2f(540, 240), context); // Add items into the inventory. inventory_1->AddItem("Mk III L.A.S.E.R."); @@ -127,7 +127,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) delete inventory_2; // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/loaddocument/src/main.cpp b/Samples/basic/loaddocument/src/main.cpp index 9430164e2..cfb405013 100644 --- a/Samples/basic/loaddocument/src/main.cpp +++ b/Samples/basic/loaddocument/src/main.cpp @@ -32,7 +32,7 @@ #include #include -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -81,19 +81,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); shell_renderer->SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -105,13 +105,13 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Load and show the demo document. - if (Rml::Core::ElementDocument * document = context->LoadDocument("assets/demo.rml")) + if (Rml::ElementDocument * document = context->LoadDocument("assets/demo.rml")) document->Show(); Shell::EventLoop(GameLoop); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/sdl2/src/RenderInterfaceSDL2.cpp b/Samples/basic/sdl2/src/RenderInterfaceSDL2.cpp index 12d4e8ea0..4a0c4036d 100644 --- a/Samples/basic/sdl2/src/RenderInterfaceSDL2.cpp +++ b/Samples/basic/sdl2/src/RenderInterfaceSDL2.cpp @@ -42,16 +42,16 @@ RmlUiSDL2Renderer::RmlUiSDL2Renderer(SDL_Renderer* renderer, SDL_Window* screen) } // Called by RmlUi when it wants to render geometry that it does not wish to optimise. -void RmlUiSDL2Renderer::RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) +void RmlUiSDL2Renderer::RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::TextureHandle texture, const Rml::Vector2f& translation) { // SDL uses shaders that we need to disable here glUseProgramObjectARB(0); glPushMatrix(); glTranslatef(translation.x, translation.y, 0); - std::vector Positions(num_vertices); - std::vector Colors(num_vertices); - std::vector TexCoords(num_vertices); + std::vector Positions(num_vertices); + std::vector Colors(num_vertices); + std::vector TexCoords(num_vertices); float texw = 0.0f; float texh = 0.0f; @@ -118,11 +118,11 @@ void RmlUiSDL2Renderer::SetScissorRegion(int x, int y, int width, int height) } // Called by RmlUi when a texture is required by the library. -bool RmlUiSDL2Renderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) +bool RmlUiSDL2Renderer::LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) { - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle file_handle = file_interface->Open(source); + Rml::FileInterface* file_interface = Rml::GetFileInterface(); + Rml::FileHandle file_handle = file_interface->Open(source); if (!file_handle) return false; @@ -141,7 +141,7 @@ bool RmlUiSDL2Renderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rm break; } - Rml::Core::String extension = source.substr(i+1, source.length()-i); + Rml::String extension = source.substr(i+1, source.length()-i); SDL_Surface* surface = IMG_LoadTyped_RW(SDL_RWFromMem(buffer, int(buffer_size)), 1, extension.c_str()); @@ -149,8 +149,8 @@ bool RmlUiSDL2Renderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rm SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer, surface); if (texture) { - texture_handle = (Rml::Core::TextureHandle) texture; - texture_dimensions = Rml::Core::Vector2i(surface->w, surface->h); + texture_handle = (Rml::TextureHandle) texture; + texture_dimensions = Rml::Vector2i(surface->w, surface->h); SDL_FreeSurface(surface); } else @@ -165,7 +165,7 @@ bool RmlUiSDL2Renderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rm } // Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. -bool RmlUiSDL2Renderer::GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) +bool RmlUiSDL2Renderer::GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) { #if SDL_BYTEORDER == SDL_BIG_ENDIAN Uint32 rmask = 0xff000000; @@ -183,12 +183,12 @@ bool RmlUiSDL2Renderer::GenerateTexture(Rml::Core::TextureHandle& texture_handle SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer, surface); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); SDL_FreeSurface(surface); - texture_handle = (Rml::Core::TextureHandle) texture; + texture_handle = (Rml::TextureHandle) texture; return true; } // Called by RmlUi when a loaded texture is no longer required. -void RmlUiSDL2Renderer::ReleaseTexture(Rml::Core::TextureHandle texture_handle) +void RmlUiSDL2Renderer::ReleaseTexture(Rml::TextureHandle texture_handle) { SDL_DestroyTexture((SDL_Texture*) texture_handle); } diff --git a/Samples/basic/sdl2/src/RenderInterfaceSDL2.h b/Samples/basic/sdl2/src/RenderInterfaceSDL2.h index ea10b3b08..0012d4d36 100644 --- a/Samples/basic/sdl2/src/RenderInterfaceSDL2.h +++ b/Samples/basic/sdl2/src/RenderInterfaceSDL2.h @@ -38,13 +38,13 @@ #endif -class RmlUiSDL2Renderer : public Rml::Core::RenderInterface +class RmlUiSDL2Renderer : public Rml::RenderInterface { public: RmlUiSDL2Renderer(SDL_Renderer* renderer, SDL_Window* screen); /// Called by RmlUi when it wants to render geometry that it does not wish to optimise. - void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override; + void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f& translation) override; /// Called by RmlUi when it wants to enable or disable scissoring to clip content. void EnableScissorRegion(bool enable) override; @@ -52,11 +52,11 @@ class RmlUiSDL2Renderer : public Rml::Core::RenderInterface void SetScissorRegion(int x, int y, int width, int height) override; /// Called by RmlUi when a texture is required by the library. - bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override; + bool LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) override; /// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. - bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override; + bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override; /// Called by RmlUi when a loaded texture is no longer required. - void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override; + void ReleaseTexture(Rml::TextureHandle texture_handle) override; private: SDL_Renderer* mRenderer; diff --git a/Samples/basic/sdl2/src/SystemInterfaceSDL2.cpp b/Samples/basic/sdl2/src/SystemInterfaceSDL2.cpp index 41e07b49c..a4648f5df 100644 --- a/Samples/basic/sdl2/src/SystemInterfaceSDL2.cpp +++ b/Samples/basic/sdl2/src/SystemInterfaceSDL2.cpp @@ -28,9 +28,9 @@ #include #include "SystemInterfaceSDL2.h" -Rml::Core::Input::KeyIdentifier RmlUiSDL2SystemInterface::TranslateKey(SDL_Keycode sdlkey) +Rml::Input::KeyIdentifier RmlUiSDL2SystemInterface::TranslateKey(SDL_Keycode sdlkey) { - using namespace Rml::Core::Input; + using namespace Rml::Input; switch(sdlkey) { @@ -392,13 +392,13 @@ int RmlUiSDL2SystemInterface::GetKeyModifiers() int retval = 0; if(sdlMods & KMOD_CTRL) - retval |= Rml::Core::Input::KM_CTRL; + retval |= Rml::Input::KM_CTRL; if(sdlMods & KMOD_SHIFT) - retval |= Rml::Core::Input::KM_SHIFT; + retval |= Rml::Input::KM_SHIFT; if(sdlMods & KMOD_ALT) - retval |= Rml::Core::Input::KM_ALT; + retval |= Rml::Input::KM_ALT; return retval; } @@ -408,31 +408,31 @@ double RmlUiSDL2SystemInterface::GetElapsedTime() return double(SDL_GetTicks()) / 1000.0; } -bool RmlUiSDL2SystemInterface::LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) +bool RmlUiSDL2SystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message) { std::string Type; switch(type) { - case Rml::Core::Log::LT_ALWAYS: + case Rml::Log::LT_ALWAYS: Type = "[Always]"; break; - case Rml::Core::Log::LT_ERROR: + case Rml::Log::LT_ERROR: Type = "[Error]"; break; - case Rml::Core::Log::LT_ASSERT: + case Rml::Log::LT_ASSERT: Type = "[Assert]"; break; - case Rml::Core::Log::LT_WARNING: + case Rml::Log::LT_WARNING: Type = "[Warning]"; break; - case Rml::Core::Log::LT_INFO: + case Rml::Log::LT_INFO: Type = "[Info]"; break; - case Rml::Core::Log::LT_DEBUG: + case Rml::Log::LT_DEBUG: Type = "[Debug]"; break; - case Rml::Core::Log::LT_MAX: + case Rml::Log::LT_MAX: break; }; diff --git a/Samples/basic/sdl2/src/SystemInterfaceSDL2.h b/Samples/basic/sdl2/src/SystemInterfaceSDL2.h index 9492981f8..b5af61daf 100644 --- a/Samples/basic/sdl2/src/SystemInterfaceSDL2.h +++ b/Samples/basic/sdl2/src/SystemInterfaceSDL2.h @@ -33,14 +33,14 @@ #include -class RmlUiSDL2SystemInterface : public Rml::Core::SystemInterface +class RmlUiSDL2SystemInterface : public Rml::SystemInterface { public: - Rml::Core::Input::KeyIdentifier TranslateKey(SDL_Keycode sdlkey); + Rml::Input::KeyIdentifier TranslateKey(SDL_Keycode sdlkey); int TranslateMouseButton(Uint8 button); int GetKeyModifiers(); double GetElapsedTime() override; - bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) override; + bool LogMessage(Rml::Log::Type type, const Rml::String& message) override; }; #endif diff --git a/Samples/basic/sdl2/src/main.cpp b/Samples/basic/sdl2/src/main.cpp index 24c41da23..b5a34875f 100644 --- a/Samples/basic/sdl2/src/main.cpp +++ b/Samples/basic/sdl2/src/main.cpp @@ -84,27 +84,27 @@ int main(int /*argc*/, char** /*argv*/) RmlUiSDL2Renderer Renderer(renderer, screen); RmlUiSDL2SystemInterface SystemInterface; - Rml::Core::String root = Shell::FindSamplesRoot(); + Rml::String root = Shell::FindSamplesRoot(); ShellFileInterface FileInterface(root); - Rml::Core::SetFileInterface(&FileInterface); - Rml::Core::SetRenderInterface(&Renderer); - Rml::Core::SetSystemInterface(&SystemInterface); + Rml::SetFileInterface(&FileInterface); + Rml::SetRenderInterface(&Renderer); + Rml::SetSystemInterface(&SystemInterface); - if (!Rml::Core::Initialise()) + if (!Rml::Initialise()) return 1; - Rml::Core::LoadFontFace("assets/Delicious-Bold.otf"); - Rml::Core::LoadFontFace("assets/Delicious-BoldItalic.otf"); - Rml::Core::LoadFontFace("assets/Delicious-Italic.otf"); - Rml::Core::LoadFontFace("assets/Delicious-Roman.otf"); + Rml::LoadFontFace("assets/Delicious-Bold.otf"); + Rml::LoadFontFace("assets/Delicious-BoldItalic.otf"); + Rml::LoadFontFace("assets/Delicious-Italic.otf"); + Rml::LoadFontFace("assets/Delicious-Roman.otf"); - Rml::Core::Context* Context = Rml::Core::CreateContext("default", - Rml::Core::Vector2i(window_width, window_height)); + Rml::Context* Context = Rml::CreateContext("default", + Rml::Vector2i(window_width, window_height)); Rml::Debugger::Initialise(Context); - Rml::Core::ElementDocument* Document = Context->LoadDocument("assets/demo.rml"); + Rml::ElementDocument* Document = Context->LoadDocument("assets/demo.rml"); if (Document) { @@ -171,7 +171,7 @@ int main(int /*argc*/, char** /*argv*/) Context->Update(); } - Rml::Core::Shutdown(); + Rml::Shutdown(); SDL_DestroyRenderer(renderer); SDL_GL_DeleteContext(glcontext); diff --git a/Samples/basic/sfml2/src/RenderInterfaceSFML.cpp b/Samples/basic/sfml2/src/RenderInterfaceSFML.cpp index fc8dc46bf..a78c428c4 100644 --- a/Samples/basic/sfml2/src/RenderInterfaceSFML.cpp +++ b/Samples/basic/sfml2/src/RenderInterfaceSFML.cpp @@ -39,7 +39,7 @@ class RmlUiSFMLRendererGeometryHandler public: GLuint VertexID, IndexID; int NumVertices; - Rml::Core::TextureHandle Texture; + Rml::TextureHandle Texture; RmlUiSFMLRendererGeometryHandler() : VertexID(0), IndexID(0), NumVertices(0), Texture(0) { @@ -95,14 +95,14 @@ void RmlUiSFMLRenderer::Resize() } // Called by RmlUi when it wants to render geometry that it does not wish to optimise. -void RmlUiSFMLRenderer::RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) +void RmlUiSFMLRenderer::RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::TextureHandle texture, const Rml::Vector2f& translation) { MyWindow->pushGLStates(); glTranslatef(translation.x, translation.y, 0); - std::vector Positions(num_vertices); - std::vector Colors(num_vertices); - std::vector TexCoords(num_vertices); + std::vector Positions(num_vertices); + std::vector Colors(num_vertices); + std::vector TexCoords(num_vertices); for(int i = 0; i < num_vertices; i++) { @@ -146,7 +146,7 @@ void RmlUiSFMLRenderer::RenderGeometry(Rml::Core::Vertex* vertices, int num_vert } // Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future. -Rml::Core::CompiledGeometryHandle RmlUiSFMLRenderer::CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::Core::TextureHandle texture) +Rml::CompiledGeometryHandle RmlUiSFMLRenderer::CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::TextureHandle texture) { #ifdef ENABLE_GLEW std::vector Data(num_vertices); @@ -175,14 +175,14 @@ Rml::Core::CompiledGeometryHandle RmlUiSFMLRenderer::CompileGeometry(Rml::Core:: Geometry->Texture = texture; - return (Rml::Core::CompiledGeometryHandle)Geometry; + return (Rml::CompiledGeometryHandle)Geometry; #else - return (Rml::Core::CompiledGeometryHandle)nullptr; + return (Rml::CompiledGeometryHandle)nullptr; #endif } // Called by RmlUi when it wants to render application-compiled geometry. -void RmlUiSFMLRenderer::RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation) +void RmlUiSFMLRenderer::RenderCompiledGeometry(Rml::CompiledGeometryHandle geometry, const Rml::Vector2f& translation) { #ifdef ENABLE_GLEW RmlUiSFMLRendererGeometryHandler *RealGeometry = (RmlUiSFMLRendererGeometryHandler *)geometry; @@ -230,7 +230,7 @@ void RmlUiSFMLRenderer::RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle } // Called by RmlUi when it wants to release application-compiled geometry. -void RmlUiSFMLRenderer::ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry) +void RmlUiSFMLRenderer::ReleaseCompiledGeometry(Rml::CompiledGeometryHandle geometry) { #ifdef ENABLE_GLEW delete (RmlUiSFMLRendererGeometryHandler *)geometry; @@ -255,10 +255,10 @@ void RmlUiSFMLRenderer::SetScissorRegion(int x, int y, int width, int height) } // Called by RmlUi when a texture is required by the library. -bool RmlUiSFMLRenderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) +bool RmlUiSFMLRenderer::LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) { - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle file_handle = file_interface->Open(source); + Rml::FileInterface* file_interface = Rml::GetFileInterface(); + Rml::FileHandle file_handle = file_interface->Open(source); if (!file_handle) return false; @@ -281,14 +281,14 @@ bool RmlUiSFMLRenderer::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rm }; delete[] buffer; - texture_handle = (Rml::Core::TextureHandle) texture; - texture_dimensions = Rml::Core::Vector2i(texture->getSize().x, texture->getSize().y); + texture_handle = (Rml::TextureHandle) texture; + texture_dimensions = Rml::Vector2i(texture->getSize().x, texture->getSize().y); return true; } // Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. -bool RmlUiSFMLRenderer::GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) +bool RmlUiSFMLRenderer::GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) { sf::Texture *texture = new sf::Texture(); @@ -298,13 +298,13 @@ bool RmlUiSFMLRenderer::GenerateTexture(Rml::Core::TextureHandle& texture_handle } texture->update(source, source_dimensions.x, source_dimensions.y, 0, 0); - texture_handle = (Rml::Core::TextureHandle)texture; + texture_handle = (Rml::TextureHandle)texture; return true; } // Called by RmlUi when a loaded texture is no longer required. -void RmlUiSFMLRenderer::ReleaseTexture(Rml::Core::TextureHandle texture_handle) +void RmlUiSFMLRenderer::ReleaseTexture(Rml::TextureHandle texture_handle) { delete (sf::Texture *)texture_handle; } diff --git a/Samples/basic/sfml2/src/RenderInterfaceSFML.h b/Samples/basic/sfml2/src/RenderInterfaceSFML.h index a55114c4b..5383ee362 100644 --- a/Samples/basic/sfml2/src/RenderInterfaceSFML.h +++ b/Samples/basic/sfml2/src/RenderInterfaceSFML.h @@ -46,7 +46,7 @@ #include "../../../shell/include/ShellOpenGL.h" #endif -class RmlUiSFMLRenderer : public Rml::Core::RenderInterface +class RmlUiSFMLRenderer : public Rml::RenderInterface { public: RmlUiSFMLRenderer(); @@ -61,15 +61,15 @@ class RmlUiSFMLRenderer : public Rml::Core::RenderInterface void Resize(); /// Called by RmlUi when it wants to render geometry that it does not wish to optimise. - void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override; + void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f& translation) override; /// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future. - Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture) override; + Rml::CompiledGeometryHandle CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture) override; /// Called by RmlUi when it wants to render application-compiled geometry. - void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation) override; + void RenderCompiledGeometry(Rml::CompiledGeometryHandle geometry, const Rml::Vector2f& translation) override; /// Called by RmlUi when it wants to release application-compiled geometry. - void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry) override; + void ReleaseCompiledGeometry(Rml::CompiledGeometryHandle geometry) override; /// Called by RmlUi when it wants to enable or disable scissoring to clip content. void EnableScissorRegion(bool enable) override; @@ -77,11 +77,11 @@ class RmlUiSFMLRenderer : public Rml::Core::RenderInterface void SetScissorRegion(int x, int y, int width, int height) override; /// Called by RmlUi when a texture is required by the library. - bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override; + bool LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) override; /// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. - bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override; + bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override; /// Called by RmlUi when a loaded texture is no longer required. - void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override; + void ReleaseTexture(Rml::TextureHandle texture_handle) override; private: sf::RenderWindow *MyWindow; diff --git a/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp b/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp index 234ccd6cd..1753cb890 100644 --- a/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp +++ b/Samples/basic/sfml2/src/SystemInterfaceSFML.cpp @@ -34,277 +34,277 @@ int RmlUiSFMLSystemInterface::GetKeyModifiers() if(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) || sf::Keyboard::isKeyPressed(sf::Keyboard::RShift)) - Modifiers |= Rml::Core::Input::KM_SHIFT; + Modifiers |= Rml::Input::KM_SHIFT; if(sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) || sf::Keyboard::isKeyPressed(sf::Keyboard::RControl)) - Modifiers |= Rml::Core::Input::KM_CTRL; + Modifiers |= Rml::Input::KM_CTRL; if(sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt) || sf::Keyboard::isKeyPressed(sf::Keyboard::RAlt)) - Modifiers |= Rml::Core::Input::KM_ALT; + Modifiers |= Rml::Input::KM_ALT; return Modifiers; } -Rml::Core::Input::KeyIdentifier RmlUiSFMLSystemInterface::TranslateKey(sf::Keyboard::Key Key) +Rml::Input::KeyIdentifier RmlUiSFMLSystemInterface::TranslateKey(sf::Keyboard::Key Key) { switch(Key) { case sf::Keyboard::A: - return Rml::Core::Input::KI_A; + return Rml::Input::KI_A; break; case sf::Keyboard::B: - return Rml::Core::Input::KI_B; + return Rml::Input::KI_B; break; case sf::Keyboard::C: - return Rml::Core::Input::KI_C; + return Rml::Input::KI_C; break; case sf::Keyboard::D: - return Rml::Core::Input::KI_D; + return Rml::Input::KI_D; break; case sf::Keyboard::E: - return Rml::Core::Input::KI_E; + return Rml::Input::KI_E; break; case sf::Keyboard::F: - return Rml::Core::Input::KI_F; + return Rml::Input::KI_F; break; case sf::Keyboard::G: - return Rml::Core::Input::KI_G; + return Rml::Input::KI_G; break; case sf::Keyboard::H: - return Rml::Core::Input::KI_H; + return Rml::Input::KI_H; break; case sf::Keyboard::I: - return Rml::Core::Input::KI_I; + return Rml::Input::KI_I; break; case sf::Keyboard::J: - return Rml::Core::Input::KI_J; + return Rml::Input::KI_J; break; case sf::Keyboard::K: - return Rml::Core::Input::KI_K; + return Rml::Input::KI_K; break; case sf::Keyboard::L: - return Rml::Core::Input::KI_L; + return Rml::Input::KI_L; break; case sf::Keyboard::M: - return Rml::Core::Input::KI_M; + return Rml::Input::KI_M; break; case sf::Keyboard::N: - return Rml::Core::Input::KI_N; + return Rml::Input::KI_N; break; case sf::Keyboard::O: - return Rml::Core::Input::KI_O; + return Rml::Input::KI_O; break; case sf::Keyboard::P: - return Rml::Core::Input::KI_P; + return Rml::Input::KI_P; break; case sf::Keyboard::Q: - return Rml::Core::Input::KI_Q; + return Rml::Input::KI_Q; break; case sf::Keyboard::R: - return Rml::Core::Input::KI_R; + return Rml::Input::KI_R; break; case sf::Keyboard::S: - return Rml::Core::Input::KI_S; + return Rml::Input::KI_S; break; case sf::Keyboard::T: - return Rml::Core::Input::KI_T; + return Rml::Input::KI_T; break; case sf::Keyboard::U: - return Rml::Core::Input::KI_U; + return Rml::Input::KI_U; break; case sf::Keyboard::V: - return Rml::Core::Input::KI_V; + return Rml::Input::KI_V; break; case sf::Keyboard::W: - return Rml::Core::Input::KI_W; + return Rml::Input::KI_W; break; case sf::Keyboard::X: - return Rml::Core::Input::KI_X; + return Rml::Input::KI_X; break; case sf::Keyboard::Y: - return Rml::Core::Input::KI_Y; + return Rml::Input::KI_Y; break; case sf::Keyboard::Z: - return Rml::Core::Input::KI_Z; + return Rml::Input::KI_Z; break; case sf::Keyboard::Num0: - return Rml::Core::Input::KI_0; + return Rml::Input::KI_0; break; case sf::Keyboard::Num1: - return Rml::Core::Input::KI_1; + return Rml::Input::KI_1; break; case sf::Keyboard::Num2: - return Rml::Core::Input::KI_2; + return Rml::Input::KI_2; break; case sf::Keyboard::Num3: - return Rml::Core::Input::KI_3; + return Rml::Input::KI_3; break; case sf::Keyboard::Num4: - return Rml::Core::Input::KI_4; + return Rml::Input::KI_4; break; case sf::Keyboard::Num5: - return Rml::Core::Input::KI_5; + return Rml::Input::KI_5; break; case sf::Keyboard::Num6: - return Rml::Core::Input::KI_6; + return Rml::Input::KI_6; break; case sf::Keyboard::Num7: - return Rml::Core::Input::KI_7; + return Rml::Input::KI_7; break; case sf::Keyboard::Num8: - return Rml::Core::Input::KI_8; + return Rml::Input::KI_8; break; case sf::Keyboard::Num9: - return Rml::Core::Input::KI_9; + return Rml::Input::KI_9; break; case sf::Keyboard::Numpad0: - return Rml::Core::Input::KI_NUMPAD0; + return Rml::Input::KI_NUMPAD0; break; case sf::Keyboard::Numpad1: - return Rml::Core::Input::KI_NUMPAD1; + return Rml::Input::KI_NUMPAD1; break; case sf::Keyboard::Numpad2: - return Rml::Core::Input::KI_NUMPAD2; + return Rml::Input::KI_NUMPAD2; break; case sf::Keyboard::Numpad3: - return Rml::Core::Input::KI_NUMPAD3; + return Rml::Input::KI_NUMPAD3; break; case sf::Keyboard::Numpad4: - return Rml::Core::Input::KI_NUMPAD4; + return Rml::Input::KI_NUMPAD4; break; case sf::Keyboard::Numpad5: - return Rml::Core::Input::KI_NUMPAD5; + return Rml::Input::KI_NUMPAD5; break; case sf::Keyboard::Numpad6: - return Rml::Core::Input::KI_NUMPAD6; + return Rml::Input::KI_NUMPAD6; break; case sf::Keyboard::Numpad7: - return Rml::Core::Input::KI_NUMPAD7; + return Rml::Input::KI_NUMPAD7; break; case sf::Keyboard::Numpad8: - return Rml::Core::Input::KI_NUMPAD8; + return Rml::Input::KI_NUMPAD8; break; case sf::Keyboard::Numpad9: - return Rml::Core::Input::KI_NUMPAD9; + return Rml::Input::KI_NUMPAD9; break; case sf::Keyboard::Left: - return Rml::Core::Input::KI_LEFT; + return Rml::Input::KI_LEFT; break; case sf::Keyboard::Right: - return Rml::Core::Input::KI_RIGHT; + return Rml::Input::KI_RIGHT; break; case sf::Keyboard::Up: - return Rml::Core::Input::KI_UP; + return Rml::Input::KI_UP; break; case sf::Keyboard::Down: - return Rml::Core::Input::KI_DOWN; + return Rml::Input::KI_DOWN; break; case sf::Keyboard::Add: - return Rml::Core::Input::KI_ADD; + return Rml::Input::KI_ADD; break; case sf::Keyboard::BackSpace: - return Rml::Core::Input::KI_BACK; + return Rml::Input::KI_BACK; break; case sf::Keyboard::Delete: - return Rml::Core::Input::KI_DELETE; + return Rml::Input::KI_DELETE; break; case sf::Keyboard::Divide: - return Rml::Core::Input::KI_DIVIDE; + return Rml::Input::KI_DIVIDE; break; case sf::Keyboard::End: - return Rml::Core::Input::KI_END; + return Rml::Input::KI_END; break; case sf::Keyboard::Escape: - return Rml::Core::Input::KI_ESCAPE; + return Rml::Input::KI_ESCAPE; break; case sf::Keyboard::F1: - return Rml::Core::Input::KI_F1; + return Rml::Input::KI_F1; break; case sf::Keyboard::F2: - return Rml::Core::Input::KI_F2; + return Rml::Input::KI_F2; break; case sf::Keyboard::F3: - return Rml::Core::Input::KI_F3; + return Rml::Input::KI_F3; break; case sf::Keyboard::F4: - return Rml::Core::Input::KI_F4; + return Rml::Input::KI_F4; break; case sf::Keyboard::F5: - return Rml::Core::Input::KI_F5; + return Rml::Input::KI_F5; break; case sf::Keyboard::F6: - return Rml::Core::Input::KI_F6; + return Rml::Input::KI_F6; break; case sf::Keyboard::F7: - return Rml::Core::Input::KI_F7; + return Rml::Input::KI_F7; break; case sf::Keyboard::F8: - return Rml::Core::Input::KI_F8; + return Rml::Input::KI_F8; break; case sf::Keyboard::F9: - return Rml::Core::Input::KI_F9; + return Rml::Input::KI_F9; break; case sf::Keyboard::F10: - return Rml::Core::Input::KI_F10; + return Rml::Input::KI_F10; break; case sf::Keyboard::F11: - return Rml::Core::Input::KI_F11; + return Rml::Input::KI_F11; break; case sf::Keyboard::F12: - return Rml::Core::Input::KI_F12; + return Rml::Input::KI_F12; break; case sf::Keyboard::F13: - return Rml::Core::Input::KI_F13; + return Rml::Input::KI_F13; break; case sf::Keyboard::F14: - return Rml::Core::Input::KI_F14; + return Rml::Input::KI_F14; break; case sf::Keyboard::F15: - return Rml::Core::Input::KI_F15; + return Rml::Input::KI_F15; break; case sf::Keyboard::Home: - return Rml::Core::Input::KI_HOME; + return Rml::Input::KI_HOME; break; case sf::Keyboard::Insert: - return Rml::Core::Input::KI_INSERT; + return Rml::Input::KI_INSERT; break; case sf::Keyboard::LControl: - return Rml::Core::Input::KI_LCONTROL; + return Rml::Input::KI_LCONTROL; break; case sf::Keyboard::LShift: - return Rml::Core::Input::KI_LSHIFT; + return Rml::Input::KI_LSHIFT; break; case sf::Keyboard::Multiply: - return Rml::Core::Input::KI_MULTIPLY; + return Rml::Input::KI_MULTIPLY; break; case sf::Keyboard::Pause: - return Rml::Core::Input::KI_PAUSE; + return Rml::Input::KI_PAUSE; break; case sf::Keyboard::RControl: - return Rml::Core::Input::KI_RCONTROL; + return Rml::Input::KI_RCONTROL; break; case sf::Keyboard::Return: - return Rml::Core::Input::KI_RETURN; + return Rml::Input::KI_RETURN; break; case sf::Keyboard::RShift: - return Rml::Core::Input::KI_RSHIFT; + return Rml::Input::KI_RSHIFT; break; case sf::Keyboard::Space: - return Rml::Core::Input::KI_SPACE; + return Rml::Input::KI_SPACE; break; case sf::Keyboard::Subtract: - return Rml::Core::Input::KI_SUBTRACT; + return Rml::Input::KI_SUBTRACT; break; case sf::Keyboard::Tab: - return Rml::Core::Input::KI_TAB; + return Rml::Input::KI_TAB; break; default: break; }; - return Rml::Core::Input::KI_UNKNOWN; + return Rml::Input::KI_UNKNOWN; } double RmlUiSFMLSystemInterface::GetElapsedTime() @@ -312,28 +312,28 @@ double RmlUiSFMLSystemInterface::GetElapsedTime() return timer.getElapsedTime().asSeconds(); } -bool RmlUiSFMLSystemInterface::LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) +bool RmlUiSFMLSystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message) { std::string Type; switch(type) { - case Rml::Core::Log::LT_ALWAYS: + case Rml::Log::LT_ALWAYS: Type = "[Always]"; break; - case Rml::Core::Log::LT_ERROR: + case Rml::Log::LT_ERROR: Type = "[Error]"; break; - case Rml::Core::Log::LT_ASSERT: + case Rml::Log::LT_ASSERT: Type = "[Assert]"; break; - case Rml::Core::Log::LT_WARNING: + case Rml::Log::LT_WARNING: Type = "[Warning]"; break; - case Rml::Core::Log::LT_INFO: + case Rml::Log::LT_INFO: Type = "[Info]"; break; - case Rml::Core::Log::LT_DEBUG: + case Rml::Log::LT_DEBUG: Type = "[Debug]"; break; default: diff --git a/Samples/basic/sfml2/src/SystemInterfaceSFML.h b/Samples/basic/sfml2/src/SystemInterfaceSFML.h index 516829664..e5969d588 100644 --- a/Samples/basic/sfml2/src/SystemInterfaceSFML.h +++ b/Samples/basic/sfml2/src/SystemInterfaceSFML.h @@ -32,14 +32,14 @@ #include #include -class RmlUiSFMLSystemInterface : public Rml::Core::SystemInterface +class RmlUiSFMLSystemInterface : public Rml::SystemInterface { public: - Rml::Core::Input::KeyIdentifier TranslateKey(sf::Keyboard::Key Key); + Rml::Input::KeyIdentifier TranslateKey(sf::Keyboard::Key Key); int GetKeyModifiers(); double GetElapsedTime() override; - bool LogMessage(Rml::Core::Log::Type type, const Rml::Core::String& message) override; + bool LogMessage(Rml::Log::Type type, const Rml::String& message) override; private: sf::Clock timer; diff --git a/Samples/basic/sfml2/src/main.cpp b/Samples/basic/sfml2/src/main.cpp index 98230a76f..a6b385e87 100644 --- a/Samples/basic/sfml2/src/main.cpp +++ b/Samples/basic/sfml2/src/main.cpp @@ -77,7 +77,7 @@ int main(int /*argc*/, char** /*argv*/) // NOTE: if fonts and rml are not found you'll probably have to adjust // the path information in the string - Rml::Core::String root = Shell::FindSamplesRoot(); + Rml::String root = Shell::FindSamplesRoot(); ShellFileInterface FileInterface(root); if (!MyWindow.isOpen()) @@ -85,25 +85,25 @@ int main(int /*argc*/, char** /*argv*/) Renderer.SetWindow(&MyWindow); - Rml::Core::SetFileInterface(&FileInterface); - Rml::Core::SetRenderInterface(&Renderer); - Rml::Core::SetSystemInterface(&SystemInterface); + Rml::SetFileInterface(&FileInterface); + Rml::SetRenderInterface(&Renderer); + Rml::SetSystemInterface(&SystemInterface); - if (!Rml::Core::Initialise()) + if (!Rml::Initialise()) return 1; - Rml::Core::LoadFontFace("assets/Delicious-Bold.otf"); - Rml::Core::LoadFontFace("assets/Delicious-BoldItalic.otf"); - Rml::Core::LoadFontFace("assets/Delicious-Italic.otf"); - Rml::Core::LoadFontFace("assets/Delicious-Roman.otf"); + Rml::LoadFontFace("assets/Delicious-Bold.otf"); + Rml::LoadFontFace("assets/Delicious-BoldItalic.otf"); + Rml::LoadFontFace("assets/Delicious-Italic.otf"); + Rml::LoadFontFace("assets/Delicious-Roman.otf"); - Rml::Core::Context* Context = Rml::Core::CreateContext("default", - Rml::Core::Vector2i(MyWindow.getSize().x, MyWindow.getSize().y)); + Rml::Context* Context = Rml::CreateContext("default", + Rml::Vector2i(MyWindow.getSize().x, MyWindow.getSize().y)); Rml::Debugger::Initialise(Context); - Rml::Core::ElementDocument* Document = Context->LoadDocument("assets/demo.rml"); + Rml::ElementDocument* Document = Context->LoadDocument("assets/demo.rml"); if (Document) { @@ -148,7 +148,7 @@ int main(int /*argc*/, char** /*argv*/) break; case sf::Event::TextEntered: if (event.text.unicode > 32) - Context->ProcessTextInput(Rml::Core::Character(event.text.unicode)); + Context->ProcessTextInput(Rml::Character(event.text.unicode)); break; case sf::Event::KeyPressed: Context->ProcessKeyDown(SystemInterface.TranslateKey(event.key.code), @@ -178,7 +178,7 @@ int main(int /*argc*/, char** /*argv*/) Context->Update(); }; - Rml::Core::Shutdown(); + Rml::Shutdown(); return 0; } diff --git a/Samples/basic/transform/src/main.cpp b/Samples/basic/transform/src/main.cpp index 811f36e39..b1ea46762 100644 --- a/Samples/basic/transform/src/main.cpp +++ b/Samples/basic/transform/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -38,17 +37,17 @@ static bool run_rotate = true; -class DemoWindow : public Rml::Core::EventListener +class DemoWindow : public Rml::EventListener { public: - DemoWindow(const Rml::Core::String &title, const Rml::Core::Vector2f &position, Rml::Core::Context *context) + DemoWindow(const Rml::String &title, const Rml::Vector2f &position, Rml::Context *context) { document = context->LoadDocument("basic/transform/data/transform.rml"); if (document) { document->GetElementById("title")->SetInnerRML(title); - document->SetProperty(Rml::Core::PropertyId::Left, Rml::Core::Property(position.x, Rml::Core::Property::PX)); - document->SetProperty(Rml::Core::PropertyId::Top, Rml::Core::Property(position.y, Rml::Core::Property::PX)); + document->SetProperty(Rml::PropertyId::Left, Rml::Property(position.x, Rml::Property::PX)); + document->SetProperty(Rml::PropertyId::Top, Rml::Property(position.y, Rml::Property::PX)); document->Show(); } } @@ -83,17 +82,17 @@ class DemoWindow : public Rml::Core::EventListener } } - void ProcessEvent(Rml::Core::Event& ev) override + void ProcessEvent(Rml::Event& ev) override { - if (ev == Rml::Core::EventId::Keydown) + if (ev == Rml::EventId::Keydown) { - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) ev.GetParameter< int >("key_identifier", 0); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) ev.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_SPACE) + if (key_identifier == Rml::Input::KI_SPACE) { run_rotate = !run_rotate; } - else if (key_identifier == Rml::Core::Input::KI_ESCAPE) + else if (key_identifier == Rml::Input::KI_ESCAPE) { Shell::RequestExit(); } @@ -102,10 +101,10 @@ class DemoWindow : public Rml::Core::EventListener private: float perspective = 0; - Rml::Core::ElementDocument *document; + Rml::ElementDocument *document; }; -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions* shell_renderer; DemoWindow* window_1 = nullptr; DemoWindow* window_2 = nullptr; @@ -118,7 +117,7 @@ void GameLoop() context->Render(); shell_renderer->PresentRenderBuffer(); - double t = Rml::Core::GetSystemInterface()->GetElapsedTime(); + double t = Rml::GetSystemInterface()->GetElapsedTime(); static double t_prev = t; double dt = t - t_prev; t_prev = t; @@ -166,36 +165,35 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(width, height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(width, height)); + context = Rml::CreateContext("main", Rml::Vector2i(width, height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); Shell::LoadFonts("assets/"); - window_1 = new DemoWindow("Orthographic transform", Rml::Core::Vector2f(120, 180), context); + window_1 = new DemoWindow("Orthographic transform", Rml::Vector2f(120, 180), context); if (window_1) { - context->GetRootElement()->AddEventListener(Rml::Core::EventId::Keydown, window_1); + context->GetRootElement()->AddEventListener(Rml::EventId::Keydown, window_1); } - window_2 = new DemoWindow("Perspective transform", Rml::Core::Vector2f(900, 180), context); + window_2 = new DemoWindow("Perspective transform", Rml::Vector2f(900, 180), context); if (window_2) { window_2->SetPerspective(800); @@ -205,14 +203,14 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) if (window_1) { - context->GetRootElement()->RemoveEventListener(Rml::Core::EventId::Keydown, window_1); + context->GetRootElement()->RemoveEventListener(Rml::EventId::Keydown, window_1); } delete window_1; delete window_2; // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/basic/treeview/src/FileFormatter.cpp b/Samples/basic/treeview/src/FileFormatter.cpp index 65fc9aa97..5bab436b5 100644 --- a/Samples/basic/treeview/src/FileFormatter.cpp +++ b/Samples/basic/treeview/src/FileFormatter.cpp @@ -29,7 +29,7 @@ #include "FileFormatter.h" #include -FileFormatter::FileFormatter() : Rml::Controls::DataFormatter("file") +FileFormatter::FileFormatter() : Rml::DataFormatter("file") { } @@ -37,7 +37,7 @@ FileFormatter::~FileFormatter() { } -void FileFormatter::FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) +void FileFormatter::FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data) { if (raw_data.size() == 3) { diff --git a/Samples/basic/treeview/src/FileFormatter.h b/Samples/basic/treeview/src/FileFormatter.h index dee32fb4d..ae76260be 100644 --- a/Samples/basic/treeview/src/FileFormatter.h +++ b/Samples/basic/treeview/src/FileFormatter.h @@ -29,7 +29,7 @@ #ifndef FILEFORMATTER_H #define FILEFORMATTER_H -#include +#include /** Data formatter for file and directory columns generated from the file system data source. @@ -37,13 +37,13 @@ @author Peter Curry */ -class FileFormatter : public Rml::Controls::DataFormatter +class FileFormatter : public Rml::DataFormatter { public: FileFormatter(); virtual ~FileFormatter(); - void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data); + void FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data); }; #endif diff --git a/Samples/basic/treeview/src/FileSystem.cpp b/Samples/basic/treeview/src/FileSystem.cpp index 4516c307c..9c19225c9 100644 --- a/Samples/basic/treeview/src/FileSystem.cpp +++ b/Samples/basic/treeview/src/FileSystem.cpp @@ -40,7 +40,7 @@ struct FileSystemNode; -typedef Rml::Core::UnorderedMap< Rml::Core::String, FileSystemNode* > NodeMap; +typedef Rml::UnorderedMap< Rml::String, FileSystemNode* > NodeMap; FileSystemNode* file_system_root = nullptr; NodeMap node_map; @@ -53,9 +53,9 @@ NodeMap node_map; struct FileSystemNode { - FileSystemNode(const Rml::Core::String _name, bool _directory, int _depth = -1) : name(_name) + FileSystemNode(const Rml::String _name, bool _directory, int _depth = -1) : name(_name) { - id = Rml::Core::CreateString(16, "%x", this); + id = Rml::CreateString(16, "%x", this); directory = _directory; depth = _depth; @@ -70,7 +70,7 @@ struct FileSystemNode } // Build the list of files and directories within this directory. - void BuildTree(const Rml::Core::String& root = "") + void BuildTree(const Rml::String& root = "") { #ifdef WIN32 _finddata_t find_data; @@ -119,8 +119,8 @@ struct FileSystemNode typedef std::vector< FileSystemNode* > NodeList; - Rml::Core::String id; - Rml::Core::String name; + Rml::String id; + Rml::String name; bool directory; int depth; @@ -128,7 +128,7 @@ struct FileSystemNode }; -FileSystem::FileSystem(const Rml::Core::String& root) : Rml::Controls::DataSource("file") +FileSystem::FileSystem(const Rml::String& root) : Rml::DataSource("file") { // Generate the file system nodes starting at the RmlUi's root directory. file_system_root = new FileSystemNode(".", true); @@ -141,7 +141,7 @@ FileSystem::~FileSystem() file_system_root = nullptr; } -void FileSystem::GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) +void FileSystem::GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns) { // Get the node that data is being queried from; one of its children (as indexed by row_index) // is the actual node the data will be read from. @@ -159,9 +159,9 @@ void FileSystem::GetRow(Rml::Core::StringList& row, const Rml::Core::String& tab else if (columns[i] == "depth") { // Returns the depth of the node (ie, how far down the directory structure it is). - row.push_back(Rml::Core::CreateString(8, "%d", node->child_nodes[row_index]->depth)); + row.push_back(Rml::CreateString(8, "%d", node->child_nodes[row_index]->depth)); } - else if (columns[i] == Rml::Controls::DataSource::CHILD_SOURCE) + else if (columns[i] == Rml::DataSource::CHILD_SOURCE) { // Returns the name of the data source that this node's children can be queried from. row.push_back("file." + node->child_nodes[row_index]->id); @@ -169,7 +169,7 @@ void FileSystem::GetRow(Rml::Core::StringList& row, const Rml::Core::String& tab } } -int FileSystem::GetNumRows(const Rml::Core::String& table) +int FileSystem::GetNumRows(const Rml::String& table) { FileSystemNode* node = GetNode(table); @@ -179,7 +179,7 @@ int FileSystem::GetNumRows(const Rml::Core::String& table) return 0; } -FileSystemNode* FileSystem::GetNode(const Rml::Core::String& table) +FileSystemNode* FileSystem::GetNode(const Rml::String& table) { // Determine which node the row is being requested from. if (table == "root") diff --git a/Samples/basic/treeview/src/FileSystem.h b/Samples/basic/treeview/src/FileSystem.h index c29b243e7..3015f3776 100644 --- a/Samples/basic/treeview/src/FileSystem.h +++ b/Samples/basic/treeview/src/FileSystem.h @@ -30,7 +30,7 @@ #define FILESYSTEM_H #include -#include +#include struct FileSystemNode; @@ -39,17 +39,17 @@ struct FileSystemNode; @author Peter Curry */ -class FileSystem : public Rml::Controls::DataSource +class FileSystem : public Rml::DataSource { public: - FileSystem(const Rml::Core::String& root); + FileSystem(const Rml::String& root); virtual ~FileSystem(); - void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) override; - int GetNumRows(const Rml::Core::String& table) override; + void GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns) override; + int GetNumRows(const Rml::String& table) override; private: - FileSystemNode* GetNode(const Rml::Core::String& table); + FileSystemNode* GetNode(const Rml::String& table); }; #endif diff --git a/Samples/basic/treeview/src/main.cpp b/Samples/basic/treeview/src/main.cpp index 066d8dd9d..c9330e529 100644 --- a/Samples/basic/treeview/src/main.cpp +++ b/Samples/basic/treeview/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -35,7 +34,7 @@ #include "FileFormatter.h" #include "FileSystem.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -84,24 +83,23 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } - Rml::Controls::Initialise(); Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); @@ -109,12 +107,12 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Create the file data source and formatter. - Rml::Core::String root = Shell::FindSamplesRoot(); + Rml::String root = Shell::FindSamplesRoot(); FileSystem file_system(root + "basic/"); FileFormatter file_formatter; // Load and show the demo document. - Rml::Core::ElementDocument* document = context->LoadDocument("basic/treeview/data/treeview.rml"); + Rml::ElementDocument* document = context->LoadDocument("basic/treeview/data/treeview.rml"); if (document) { document->GetElementById("title")->SetInnerRML(document->GetTitle()); @@ -124,7 +122,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::EventLoop(GameLoop); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/invaders/src/DecoratorDefender.cpp b/Samples/invaders/src/DecoratorDefender.cpp index f49e8625b..09320a271 100644 --- a/Samples/invaders/src/DecoratorDefender.cpp +++ b/Samples/invaders/src/DecoratorDefender.cpp @@ -36,7 +36,7 @@ DecoratorDefender::~DecoratorDefender() { } -bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path) +bool DecoratorDefender::Initialise(const Rml::String& image_source, const Rml::String& image_path) { image_index = LoadTexture(image_source, image_path); if (image_index == -1) @@ -48,30 +48,30 @@ bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element)) const +Rml::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Element* RMLUI_UNUSED_PARAMETER(element)) const { RMLUI_UNUSED(element); - return Rml::Core::Decorator::INVALID_DECORATORDATAHANDLE; + return Rml::Decorator::INVALID_DECORATORDATAHANDLE; } // Called to release element data generated by this decorator. -void DecoratorDefender::ReleaseElementData(Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::ReleaseElementData(Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); } // Called to render the decorator on an element. -void DecoratorDefender::RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); - Rml::Core::Vector2f position = element->GetAbsoluteOffset(Rml::Core::Box::PADDING).Round(); - Rml::Core::Vector2f size = element->GetBox().GetSize(Rml::Core::Box::PADDING).Round(); + Rml::Vector2f position = element->GetAbsoluteOffset(Rml::Box::PADDING).Round(); + Rml::Vector2f size = element->GetBox().GetSize(Rml::Box::PADDING).Round(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, (GLuint) GetTexture(image_index)->GetHandle(element->GetRenderInterface())); - Rml::Core::Colourb colour = element->GetProperty< Rml::Core::Colourb >("color"); + Rml::Colourb colour = element->GetProperty< Rml::Colourb >("color"); glColor4ubv(colour); glBegin(GL_QUADS); diff --git a/Samples/invaders/src/DecoratorDefender.h b/Samples/invaders/src/DecoratorDefender.h index a68f90726..ba495a9d6 100644 --- a/Samples/invaders/src/DecoratorDefender.h +++ b/Samples/invaders/src/DecoratorDefender.h @@ -26,30 +26,30 @@ * */ -#ifndef RMLUIINVADERSDECORATORDEFENDER_H -#define RMLUIINVADERSDECORATORDEFENDER_H +#ifndef RMLUI_INVADERS_DECORATORDEFENDER_H +#define RMLUI_INVADERS_DECORATORDEFENDER_H #include -class DecoratorDefender : public Rml::Core::Decorator +class DecoratorDefender : public Rml::Decorator { public: virtual ~DecoratorDefender(); - bool Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path); + bool Initialise(const Rml::String& image_source, const Rml::String& image_path); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param element[in] The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param element_data[in] The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param element[in] The element to render the decorator on. /// @param element_data[in] The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int image_index; diff --git a/Samples/invaders/src/DecoratorInstancerDefender.cpp b/Samples/invaders/src/DecoratorInstancerDefender.cpp index 4df1db8e4..dddc8581a 100644 --- a/Samples/invaders/src/DecoratorInstancerDefender.cpp +++ b/Samples/invaders/src/DecoratorInstancerDefender.cpp @@ -35,7 +35,7 @@ DecoratorInstancerDefender::DecoratorInstancerDefender() { id_image_src = RegisterProperty("image-src", "").AddParser("string").GetId(); - RegisterShorthand("decorator", "image-src", Rml::Core::ShorthandType::FallThrough); + RegisterShorthand("decorator", "image-src", Rml::ShorthandType::FallThrough); } DecoratorInstancerDefender::~DecoratorInstancerDefender() @@ -43,12 +43,12 @@ DecoratorInstancerDefender::~DecoratorInstancerDefender() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - const Rml::Core::Property* image_source_property = properties.GetProperty(id_image_src); - Rml::Core::String image_source = image_source_property->Get< Rml::Core::String >(); - Rml::Core::String source_path; + const Rml::Property* image_source_property = properties.GetProperty(id_image_src); + Rml::String image_source = image_source_property->Get< Rml::String >(); + Rml::String source_path; if (auto & source = image_source_property->source) source_path = source->path; diff --git a/Samples/invaders/src/DecoratorInstancerDefender.h b/Samples/invaders/src/DecoratorInstancerDefender.h index 92529b842..cf3ab8709 100644 --- a/Samples/invaders/src/DecoratorInstancerDefender.h +++ b/Samples/invaders/src/DecoratorInstancerDefender.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDECORATORINSTANCERDEFENDER_H -#define RMLUIINVADERSDECORATORINSTANCERDEFENDER_H +#ifndef RMLUI_INVADERS_DECORATORINSTANCERDEFENDER_H +#define RMLUI_INVADERS_DECORATORINSTANCERDEFENDER_H #include @@ -35,7 +35,7 @@ @author Robert Curry */ -class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer +class DecoratorInstancerDefender : public Rml::DecoratorInstancer { public: DecoratorInstancerDefender(); @@ -45,10 +45,10 @@ class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer /// @param[in] name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple". /// @param[in] properties All RCSS properties associated with the decorator. /// @return The decorator if it was instanced successful, nullptr if an error occured. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_image_src; + Rml::PropertyId id_image_src; }; #endif diff --git a/Samples/invaders/src/DecoratorInstancerStarfield.cpp b/Samples/invaders/src/DecoratorInstancerStarfield.cpp index 17ac61d66..bb1b65426 100644 --- a/Samples/invaders/src/DecoratorInstancerStarfield.cpp +++ b/Samples/invaders/src/DecoratorInstancerStarfield.cpp @@ -47,16 +47,16 @@ DecoratorInstancerStarfield::~DecoratorInstancerStarfield() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerStarfield::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - int num_layers = Rml::Core::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get< float >()); - Rml::Core::Colourb top_colour = properties.GetProperty(id_top_colour)->Get< Rml::Core::Colourb >(); - Rml::Core::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get< Rml::Core::Colourb >(); + int num_layers = Rml::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get< float >()); + Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get< Rml::Colourb >(); + Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get< Rml::Colourb >(); float top_speed = properties.GetProperty(id_top_speed)->Get< float >(); float bottom_speed = properties.GetProperty(id_bottom_speed)->Get< float >(); - int top_density = Rml::Core::Math::RealToInteger(properties.GetProperty(id_top_density)->Get< float >()); - int bottom_density = Rml::Core::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get< float >()); + int top_density = Rml::Math::RealToInteger(properties.GetProperty(id_top_density)->Get< float >()); + int bottom_density = Rml::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get< float >()); auto decorator = std::make_shared(); if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density)) diff --git a/Samples/invaders/src/DecoratorInstancerStarfield.h b/Samples/invaders/src/DecoratorInstancerStarfield.h index 90cce230a..b5ebae151 100644 --- a/Samples/invaders/src/DecoratorInstancerStarfield.h +++ b/Samples/invaders/src/DecoratorInstancerStarfield.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDECORATORINSTANCERSTARFIELD_H -#define RMLUIINVADERSDECORATORINSTANCERSTARFIELD_H +#ifndef RMLUI_INVADERS_DECORATORINSTANCERSTARFIELD_H +#define RMLUI_INVADERS_DECORATORINSTANCERSTARFIELD_H #include #include "DecoratorStarfield.h" @@ -36,7 +36,7 @@ @author Robert Curry */ -class DecoratorInstancerStarfield : public Rml::Core::DecoratorInstancer +class DecoratorInstancerStarfield : public Rml::DecoratorInstancer { public: DecoratorInstancerStarfield(); @@ -46,10 +46,10 @@ class DecoratorInstancerStarfield : public Rml::Core::DecoratorInstancer /// @param name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple". /// @param properties All RCSS properties associated with the decorator. /// @return The decorator if it was instanced successful, nullptr if an error occured. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_num_layers, id_top_colour, id_bottom_colour, id_top_speed, id_bottom_speed, id_top_density, id_bottom_density; + Rml::PropertyId id_num_layers, id_top_colour, id_bottom_colour, id_top_speed, id_bottom_speed, id_top_density, id_bottom_density; }; #endif diff --git a/Samples/invaders/src/DecoratorStarfield.cpp b/Samples/invaders/src/DecoratorStarfield.cpp index 2ecfb342e..f1fa30595 100644 --- a/Samples/invaders/src/DecoratorStarfield.cpp +++ b/Samples/invaders/src/DecoratorStarfield.cpp @@ -39,7 +39,7 @@ DecoratorStarfield::~DecoratorStarfield() { } -bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Core::Colourb& _top_colour, const Rml::Core::Colourb& _bottom_colour, float _top_speed, float _bottom_speed, int _top_density, int _bottom_density) +bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Colourb& _top_colour, const Rml::Colourb& _bottom_colour, float _top_speed, float _bottom_speed, int _top_density, int _bottom_density) { num_layers = _num_layers; top_colour = _top_colour; @@ -53,7 +53,7 @@ bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Core::Colourb& _ } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Core::Element* element) const +Rml::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Element* element) const { StarField* star_field = new StarField(); @@ -63,40 +63,40 @@ Rml::Core::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Core { float layer_depth = i / (float)num_layers; - int density = Rml::Core::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth))); + int density = Rml::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth))); star_field->star_layers[i].stars.resize(density); - Rml::Core::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth)); + Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth)); star_field->star_layers[i].colour = colour; float speed = (top_speed * layer_depth) + (bottom_speed * (1.0f - layer_depth)); star_field->star_layers[i].speed = speed; - star_field->dimensions = element->GetBox().GetSize(Rml::Core::Box::PADDING); + star_field->dimensions = element->GetBox().GetSize(Rml::Box::PADDING); if (star_field->dimensions.x > 0) { for (int j = 0; j < density; j++) { - star_field->star_layers[i].stars[j].x = (float) Rml::Core::Math::RandomReal(star_field->dimensions.x); - star_field->star_layers[i].stars[j].y = (float) Rml::Core::Math::RandomReal(star_field->dimensions.y); + star_field->star_layers[i].stars[j].x = (float) Rml::Math::RandomReal(star_field->dimensions.x); + star_field->star_layers[i].stars[j].y = (float) Rml::Math::RandomReal(star_field->dimensions.y); } } star_field->last_update = Shell::GetElapsedTime(); } - return reinterpret_cast(star_field); + return reinterpret_cast(star_field); } // Called to release element data generated by this decorator. -void DecoratorStarfield::ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const +void DecoratorStarfield::ReleaseElementData(Rml::DecoratorDataHandle element_data) const { delete reinterpret_cast(element_data); } // Called to render the decorator on an element. -void DecoratorStarfield::RenderElement(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element), Rml::Core::DecoratorDataHandle element_data) const +void DecoratorStarfield::RenderElement(Rml::Element* RMLUI_UNUSED_PARAMETER(element), Rml::DecoratorDataHandle element_data) const { RMLUI_UNUSED(element); @@ -140,7 +140,7 @@ void DecoratorStarfield::StarField::Update() if (star_layers[i].stars[j].y > dimensions.y) { star_layers[i].stars[j].y = 0; - star_layers[i].stars[j].x = Rml::Core::Math::RandomReal(dimensions.x); + star_layers[i].stars[j].x = Rml::Math::RandomReal(dimensions.x); } } } diff --git a/Samples/invaders/src/DecoratorStarfield.h b/Samples/invaders/src/DecoratorStarfield.h index a66e9bc58..00430651f 100644 --- a/Samples/invaders/src/DecoratorStarfield.h +++ b/Samples/invaders/src/DecoratorStarfield.h @@ -26,36 +26,36 @@ * */ -#ifndef RMLUIINVADERSDECORATORSTARFIELD_H -#define RMLUIINVADERSDECORATORSTARFIELD_H +#ifndef RMLUI_INVADERS_DECORATORSTARFIELD_H +#define RMLUI_INVADERS_DECORATORSTARFIELD_H #include #include -class DecoratorStarfield : public Rml::Core::Decorator +class DecoratorStarfield : public Rml::Decorator { public: virtual ~DecoratorStarfield(); - bool Initialise(int num_layers, const Rml::Core::Colourb& top_colour, const Rml::Core::Colourb& bottom_colour, float top_speed, float bottom_speed, int top_density, int bottom_density); + bool Initialise(int num_layers, const Rml::Colourb& top_colour, const Rml::Colourb& bottom_colour, float top_speed, float bottom_speed, int top_density, int bottom_density); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param[in] element The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param[in] element_data The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param[in] element The element to render the decorator on. /// @param[in] element_data The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int num_layers; - Rml::Core::Colourb top_colour; - Rml::Core::Colourb bottom_colour; + Rml::Colourb top_colour; + Rml::Colourb bottom_colour; float top_speed; float bottom_speed; int top_density; @@ -63,9 +63,9 @@ class DecoratorStarfield : public Rml::Core::Decorator struct StarLayer { - typedef std::vector< Rml::Core::Vector2f > StarList; + typedef std::vector< Rml::Vector2f > StarList; StarList stars; - Rml::Core::Colourb colour; + Rml::Colourb colour; float speed; }; @@ -73,7 +73,7 @@ class DecoratorStarfield : public Rml::Core::Decorator { void Update(); double last_update; - Rml::Core::Vector2f dimensions; + Rml::Vector2f dimensions; typedef std::vector< StarLayer > StarLayerList; StarLayerList star_layers; diff --git a/Samples/invaders/src/Defender.cpp b/Samples/invaders/src/Defender.cpp index a19ca763c..ddba4c4d9 100644 --- a/Samples/invaders/src/Defender.cpp +++ b/Samples/invaders/src/Defender.cpp @@ -42,9 +42,9 @@ const float BULLET_SPEED = 15; const int SPRITE_WIDTH = 64; const float RESPAWN_TIME = 1.0f; -Sprite defender_sprite(Rml::Core::Vector2f(60, 31), Rml::Core::Vector2f(0, 0.5), Rml::Core::Vector2f(0.23437500, 0.98437500)); -Sprite bullet_sprite(Rml::Core::Vector2f(4, 20), Rml::Core::Vector2f(0.4921875, 0.515625), Rml::Core::Vector2f(0.5078125, 0.828125)); -Sprite explosion_sprite(Rml::Core::Vector2f(52, 28), Rml::Core::Vector2f(0.71484375f, 0.51562500f), Rml::Core::Vector2f(0.91796875f, 0.95312500f)); +Sprite defender_sprite(Rml::Vector2f(60, 31), Rml::Vector2f(0, 0.5), Rml::Vector2f(0.23437500, 0.98437500)); +Sprite bullet_sprite(Rml::Vector2f(4, 20), Rml::Vector2f(0.4921875, 0.515625), Rml::Vector2f(0.5078125, 0.828125)); +Sprite explosion_sprite(Rml::Vector2f(52, 28), Rml::Vector2f(0.71484375f, 0.51562500f), Rml::Vector2f(0.91796875f, 0.95312500f)); Defender::Defender(Game* _game) { @@ -69,7 +69,7 @@ void Defender::Update() if (dt < UPDATE_FREQ) return; - dt = Rml::Core::Math::Min(dt, 0.1f); + dt = Rml::Math::Min(dt, 0.1f); defender_frame_start = Shell::GetElapsedTime(); @@ -109,12 +109,12 @@ void Defender::Render() // Render our sprite if rendering is enabled if (render) - defender_sprite.Render(Rml::Core::Vector2f(position.x, position.y)); + defender_sprite.Render(Rml::Vector2f(position.x, position.y)); // Update the bullet, doing collision detection if (bullet_in_flight) { - bullet_sprite.Render(Rml::Core::Vector2f(bullet_position.x, bullet_position.y)); + bullet_sprite.Render(Rml::Vector2f(bullet_position.x, bullet_position.y)); // Check if we hit the shields for (int i = 0; i < game->GetNumShields(); i++) @@ -158,12 +158,12 @@ void Defender::Fire() { if (!bullet_in_flight) { - bullet_position = position + Rml::Core::Vector2f((SPRITE_WIDTH/2) - 4, 0); + bullet_position = position + Rml::Vector2f((SPRITE_WIDTH/2) - 4, 0); bullet_in_flight = true; } } -bool Defender::CheckHit(const Rml::Core::Vector2f& check_position) +bool Defender::CheckHit(const Rml::Vector2f& check_position) { float sprite_width = defender_sprite.dimensions.x; float sprite_height = defender_sprite.dimensions.y; diff --git a/Samples/invaders/src/Defender.h b/Samples/invaders/src/Defender.h index 1dc6e46eb..47d4f6397 100644 --- a/Samples/invaders/src/Defender.h +++ b/Samples/invaders/src/Defender.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDEFENDER_H -#define RMLUIINVADERSDEFENDER_H +#ifndef RMLUI_INVADERS_DEFENDER_H +#define RMLUI_INVADERS_DEFENDER_H #include @@ -58,16 +58,16 @@ class Defender void Fire(); /// Check if an object at the given position would hit the defender. - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); private: Game* game; - Rml::Core::Vector2f position; + Rml::Vector2f position; float move_direction; bool bullet_in_flight; - Rml::Core::Vector2f bullet_position; + Rml::Vector2f bullet_position; double defender_frame_start; double respawn_start; diff --git a/Samples/invaders/src/ElementGame.cpp b/Samples/invaders/src/ElementGame.cpp index e8d3dbc01..570f241c5 100644 --- a/Samples/invaders/src/ElementGame.cpp +++ b/Samples/invaders/src/ElementGame.cpp @@ -33,7 +33,7 @@ #include "EventManager.h" #include "Game.h" -ElementGame::ElementGame(const Rml::Core::String& tag) : Rml::Core::Element(tag) +ElementGame::ElementGame(const Rml::String& tag) : Rml::Element(tag) { game = new Game(); } @@ -44,15 +44,15 @@ ElementGame::~ElementGame() } // Intercepts and handles key events. -void ElementGame::ProcessEvent(Rml::Core::Event& event) +void ElementGame::ProcessEvent(Rml::Event& event) { - if (event == Rml::Core::EventId::Keydown || - event == Rml::Core::EventId::Keyup) + if (event == Rml::EventId::Keydown || + event == Rml::EventId::Keyup) { - bool key_down = (event == Rml::Core::EventId::Keydown); - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + bool key_down = (event == Rml::EventId::Keydown); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); - if (key_identifier == Rml::Core::Input::KI_ESCAPE && + if (key_identifier == Rml::Input::KI_ESCAPE && !key_down) { EventManager::LoadWindow("pause"); @@ -61,23 +61,23 @@ void ElementGame::ProcessEvent(Rml::Core::Event& event) // Process left and right keys if (key_down) { - if (key_identifier == Rml::Core::Input::KI_LEFT) + if (key_identifier == Rml::Input::KI_LEFT) game->GetDefender()->StartMove(-1.0f); - if (key_identifier == Rml::Core::Input::KI_RIGHT) + if (key_identifier == Rml::Input::KI_RIGHT) game->GetDefender()->StartMove(1.0f); - if (key_identifier == Rml::Core::Input::KI_SPACE) + if (key_identifier == Rml::Input::KI_SPACE) game->GetDefender()->Fire(); } else if (!key_down) { - if (key_identifier == Rml::Core::Input::KI_LEFT) + if (key_identifier == Rml::Input::KI_LEFT) game->GetDefender()->StopMove(-1.0f); - if (key_identifier == Rml::Core::Input::KI_RIGHT) + if (key_identifier == Rml::Input::KI_RIGHT) game->GetDefender()->StopMove(1.0f); } } - if (event == Rml::Core::EventId::Load) + if (event == Rml::EventId::Load) { game->Initialise(); } @@ -95,14 +95,14 @@ void ElementGame::OnRender() game->Render(); } -void ElementGame::OnChildAdd(Rml::Core::Element* element) +void ElementGame::OnChildAdd(Rml::Element* element) { - Rml::Core::Element::OnChildAdd(element); + Rml::Element::OnChildAdd(element); if (element == this) { - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Load, this); - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Keydown, this); - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Keyup, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Load, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Keydown, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Keyup, this); } } diff --git a/Samples/invaders/src/ElementGame.h b/Samples/invaders/src/ElementGame.h index d30a3f643..8e0432d75 100644 --- a/Samples/invaders/src/ElementGame.h +++ b/Samples/invaders/src/ElementGame.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSELEMENTGAME_H -#define RMLUIINVADERSELEMENTGAME_H +#ifndef RMLUI_INVADERS_ELEMENTGAME_H +#define RMLUI_INVADERS_ELEMENTGAME_H #include #include @@ -38,19 +38,19 @@ class Game; @author Peter Curry */ -class ElementGame : public Rml::Core::Element, public Rml::Core::EventListener +class ElementGame : public Rml::Element, public Rml::EventListener { public: - ElementGame(const Rml::Core::String& tag); + ElementGame(const Rml::String& tag); virtual ~ElementGame(); /// Intercepts and handles key events. - void ProcessEvent(Rml::Core::Event& event) override; + void ProcessEvent(Rml::Event& event) override; /// Receive notifications when child elements are added /// This will only get called when we're added to the tree, /// which allows us to bind to onload - void OnChildAdd(Rml::Core::Element* element) override; + void OnChildAdd(Rml::Element* element) override; protected: /// Updates the game. diff --git a/Samples/invaders/src/Event.cpp b/Samples/invaders/src/Event.cpp index 1474201a7..16f16f9ab 100644 --- a/Samples/invaders/src/Event.cpp +++ b/Samples/invaders/src/Event.cpp @@ -29,7 +29,7 @@ #include "Event.h" #include "EventManager.h" -Event::Event(const Rml::Core::String& value) : value(value) +Event::Event(const Rml::String& value) : value(value) { } @@ -38,13 +38,13 @@ Event::~Event() } // Sends the event value through to Invader's event processing system. -void Event::ProcessEvent(Rml::Core::Event& event) +void Event::ProcessEvent(Rml::Event& event) { EventManager::ProcessEvent(event, value); } // Destroys the event. -void Event::OnDetach(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element)) +void Event::OnDetach(Rml::Element* RMLUI_UNUSED_PARAMETER(element)) { RMLUI_UNUSED(element); diff --git a/Samples/invaders/src/Event.h b/Samples/invaders/src/Event.h index 4c5bc0713..71603fac0 100644 --- a/Samples/invaders/src/Event.h +++ b/Samples/invaders/src/Event.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENT_H -#define RMLUIINVADERSEVENT_H +#ifndef RMLUI_INVADERS_EVENT_H +#define RMLUI_INVADERS_EVENT_H #include @@ -35,20 +35,20 @@ @author Peter Curry */ -class Event : public Rml::Core::EventListener +class Event : public Rml::EventListener { public: - Event(const Rml::Core::String& value); + Event(const Rml::String& value); virtual ~Event(); /// Sends the event value through to Invader's event processing system. - void ProcessEvent(Rml::Core::Event& event) override; + void ProcessEvent(Rml::Event& event) override; /// Destroys the event. - void OnDetach(Rml::Core::Element* element) override; + void OnDetach(Rml::Element* element) override; private: - Rml::Core::String value; + Rml::String value; }; #endif diff --git a/Samples/invaders/src/EventHandler.h b/Samples/invaders/src/EventHandler.h index 8e99c5121..9d224cbbb 100644 --- a/Samples/invaders/src/EventHandler.h +++ b/Samples/invaders/src/EventHandler.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTHANDLER_H -#define RMLUIINVADERSEVENTHANDLER_H +#ifndef RMLUI_INVADERS_EVENTHANDLER_H +#define RMLUI_INVADERS_EVENTHANDLER_H #include @@ -47,7 +47,7 @@ class EventHandler { public: virtual ~EventHandler(); - virtual void ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) = 0; + virtual void ProcessEvent(Rml::Event& event, const Rml::String& value) = 0; }; diff --git a/Samples/invaders/src/EventHandlerHighScore.cpp b/Samples/invaders/src/EventHandlerHighScore.cpp index ddea254bc..accae987e 100644 --- a/Samples/invaders/src/EventHandlerHighScore.cpp +++ b/Samples/invaders/src/EventHandlerHighScore.cpp @@ -42,7 +42,7 @@ EventHandlerHighScore::~EventHandlerHighScore() { } -void EventHandlerHighScore::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) +void EventHandlerHighScore::ProcessEvent(Rml::Event& event, const Rml::String& value) { if (value == "add_score") { @@ -57,19 +57,19 @@ void EventHandlerHighScore::ProcessEvent(Rml::Core::Event& event, const Rml::Cor } else if (value == "enter_name") { - if (event.GetParameter< int >("key_identifier", Rml::Core::Input::KI_UNKNOWN) == Rml::Core::Input::KI_RETURN) + if (event.GetParameter< int >("key_identifier", Rml::Input::KI_UNKNOWN) == Rml::Input::KI_RETURN) { - Rml::Core::String name = event.GetCurrentElement()->GetAttribute< Rml::Core::String >("value", "Anon."); + Rml::String name = event.GetCurrentElement()->GetAttribute< Rml::String >("value", "Anon."); HighScores::SubmitName(name); } } else if (value == "check_name") { - Rml::Core::String name = "Anon."; + Rml::String name = "Anon."; // Submit the name the user started typing if(auto element = event.GetCurrentElement()->GetOwnerDocument()->GetElementById("player_input")) - name = element->GetAttribute("value", name); + name = element->GetAttribute("value", name); HighScores::SubmitName(name); } diff --git a/Samples/invaders/src/EventHandlerHighScore.h b/Samples/invaders/src/EventHandlerHighScore.h index 4e19848de..643b763af 100644 --- a/Samples/invaders/src/EventHandlerHighScore.h +++ b/Samples/invaders/src/EventHandlerHighScore.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTHANDLERHIGHSCORE_H -#define RMLUIINVADERSEVENTHANDLERHIGHSCORE_H +#ifndef RMLUI_INVADERS_EVENTHANDLERHIGHSCORE_H +#define RMLUI_INVADERS_EVENTHANDLERHIGHSCORE_H #include "EventHandler.h" @@ -40,7 +40,7 @@ class EventHandlerHighScore : public EventHandler EventHandlerHighScore(); virtual ~EventHandlerHighScore(); - void ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) override; + void ProcessEvent(Rml::Event& event, const Rml::String& value) override; }; #endif diff --git a/Samples/invaders/src/EventHandlerOptions.cpp b/Samples/invaders/src/EventHandlerOptions.cpp index 1c7115892..94afe38c4 100644 --- a/Samples/invaders/src/EventHandlerOptions.cpp +++ b/Samples/invaders/src/EventHandlerOptions.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include "EventManager.h" #include "GameDetails.h" @@ -42,7 +42,7 @@ EventHandlerOptions::~EventHandlerOptions() { } -void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) +void EventHandlerOptions::ProcessEvent(Rml::Event& event, const Rml::String& value) { // Sent from the 'onload' of the options screen; we set the options on the interface to match those previously set // this game session. @@ -50,12 +50,12 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: { // Fetch the document from the target of the 'onload' event. From here we can fetch the options elements by ID // to manipulate them directly. - Rml::Core::ElementDocument* options_body = event.GetTargetElement()->GetOwnerDocument(); + Rml::ElementDocument* options_body = event.GetTargetElement()->GetOwnerDocument(); if (options_body == nullptr) return; // Get the current graphics setting, and translate that into the ID of the radio button we need to set. - Rml::Core::String graphics_option_id; + Rml::String graphics_option_id; switch (GameDetails::GetGraphicsQuality()) { case GameDetails::GOOD: graphics_option_id = "good"; break; @@ -67,12 +67,12 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: // Fetch the radio button from the document by ID, cast it to a radio button interface and set it as checked. // This will automatically pop the other radio buttons in the set. Note that we could have not cast and called // the 'Click()' function instead, but this method will avoid event overhead. - Rml::Controls::ElementFormControlInput* graphics_option = rmlui_dynamic_cast< Rml::Controls::ElementFormControlInput* >(options_body->GetElementById(graphics_option_id)); + Rml::ElementFormControlInput* graphics_option = rmlui_dynamic_cast< Rml::ElementFormControlInput* >(options_body->GetElementById(graphics_option_id)); if (graphics_option != nullptr) graphics_option->SetAttribute("checked", ""); // Fetch the reverb option by ID and set its checked status from the game options. - Rml::Controls::ElementFormControlInput* reverb_option = rmlui_dynamic_cast< Rml::Controls::ElementFormControlInput* >(options_body->GetElementById("reverb")); + Rml::ElementFormControlInput* reverb_option = rmlui_dynamic_cast< Rml::ElementFormControlInput* >(options_body->GetElementById("reverb")); if (reverb_option != nullptr) { if (GameDetails::GetReverb()) @@ -82,7 +82,7 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: } // Similarly, fetch the 3D spatialisation option by ID and set its checked status. - Rml::Controls::ElementFormControlInput* spatialisation_option = rmlui_dynamic_cast< Rml::Controls::ElementFormControlInput* >(options_body->GetElementById("3d")); + Rml::ElementFormControlInput* spatialisation_option = rmlui_dynamic_cast< Rml::ElementFormControlInput* >(options_body->GetElementById("3d")); if (spatialisation_option != nullptr) { if (GameDetails::Get3DSpatialisation()) @@ -92,7 +92,7 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: } // Disable the accept button when default values are given - Rml::Controls::ElementFormControlInput* accept = rmlui_dynamic_cast(options_body->GetElementById("accept")); + Rml::ElementFormControlInput* accept = rmlui_dynamic_cast(options_body->GetElementById("accept")); if (accept != nullptr) { accept->SetDisabled(true); @@ -105,15 +105,15 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: { // First check which button was clicked to submit the form; if it was 'cancel', then we don't want to // propagate the changes. - if (event.GetParameter< Rml::Core::String >("submit", "cancel") == "accept") + if (event.GetParameter< Rml::String >("submit", "cancel") == "accept") { // Fetch the results of the form submission. These are stored as parameters directly on the event itself. // Like HTML form events, the name of the parameter is the 'name' attribute of the control, and the value // is whatever was put into the 'value' attribute. Checkbox values are only sent through if the box was // clicked. Radio buttons send through one value for the active button. - Rml::Core::String graphics = event.GetParameter< Rml::Core::String >("graphics", "ok"); - bool reverb = event.GetParameter< Rml::Core::String >("reverb", "") == "true"; - bool spatialisation = event.GetParameter< Rml::Core::String >("3d", "") == "true"; + Rml::String graphics = event.GetParameter< Rml::String >("graphics", "ok"); + bool reverb = event.GetParameter< Rml::String >("reverb", "") == "true"; + bool spatialisation = event.GetParameter< Rml::String >("3d", "") == "true"; if (graphics == "good") GameDetails::SetGraphicsQuality(GameDetails::GOOD); @@ -131,7 +131,7 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: // warning message. else if (value == "bad_graphics") { - using namespace Rml::Core; + using namespace Rml; ElementDocument* options_body = event.GetTargetElement()->GetOwnerDocument(); if (options_body == nullptr) return; @@ -149,12 +149,12 @@ void EventHandlerOptions::ProcessEvent(Rml::Core::Event& event, const Rml::Core: } else if (value == "enable_accept") { - Rml::Core::ElementDocument* options_body = event.GetTargetElement()->GetOwnerDocument(); + Rml::ElementDocument* options_body = event.GetTargetElement()->GetOwnerDocument(); if (options_body == nullptr) return; // Enable the accept button when values are changed - Rml::Controls::ElementFormControlInput* accept = rmlui_dynamic_cast(options_body->GetElementById("accept")); + Rml::ElementFormControlInput* accept = rmlui_dynamic_cast(options_body->GetElementById("accept")); if (accept != nullptr) { accept->SetDisabled(false); diff --git a/Samples/invaders/src/EventHandlerOptions.h b/Samples/invaders/src/EventHandlerOptions.h index dbed2c533..622f0f4ae 100644 --- a/Samples/invaders/src/EventHandlerOptions.h +++ b/Samples/invaders/src/EventHandlerOptions.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTHANDLEROPTIONS_H -#define RMLUIINVADERSEVENTHANDLEROPTIONS_H +#ifndef RMLUI_INVADERS_EVENTHANDLEROPTIONS_H +#define RMLUI_INVADERS_EVENTHANDLEROPTIONS_H #include "EventHandler.h" @@ -41,7 +41,7 @@ class EventHandlerOptions : public EventHandler EventHandlerOptions(); virtual ~EventHandlerOptions(); - void ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) override; + void ProcessEvent(Rml::Event& event, const Rml::String& value) override; }; #endif diff --git a/Samples/invaders/src/EventHandlerStartGame.cpp b/Samples/invaders/src/EventHandlerStartGame.cpp index 734765720..d1fa7076a 100644 --- a/Samples/invaders/src/EventHandlerStartGame.cpp +++ b/Samples/invaders/src/EventHandlerStartGame.cpp @@ -35,7 +35,7 @@ #include "GameDetails.h" // The game's element context (declared in main.cpp). -extern Rml::Core::Context* context; +extern Rml::Context* context; EventHandlerStartGame::EventHandlerStartGame() { @@ -45,22 +45,22 @@ EventHandlerStartGame::~EventHandlerStartGame() { } -void EventHandlerStartGame::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) +void EventHandlerStartGame::ProcessEvent(Rml::Event& event, const Rml::String& value) { if (value == "start") { // Set the difficulty. - Rml::Core::String difficulty = event.GetParameter< Rml::Core::String >("difficulty", "easy"); + Rml::String difficulty = event.GetParameter< Rml::String >("difficulty", "easy"); if (difficulty == "hard") GameDetails::SetDifficulty(GameDetails::HARD); else GameDetails::SetDifficulty(GameDetails::EASY); // Set the defender colour. - Rml::Core::StringList colour_components; - Rml::Core::StringUtilities::ExpandString(colour_components, event.GetParameter< Rml::Core::String >("colour", "255,255,255")); + Rml::StringList colour_components; + Rml::StringUtilities::ExpandString(colour_components, event.GetParameter< Rml::String >("colour", "255,255,255")); - Rml::Core::Colourb colour(255, 255, 255); + Rml::Colourb colour(255, 255, 255); for (size_t i = 0; i < colour_components.size() && i < 3; ++i) { int colour_component = atoi(colour_components[i].c_str()); @@ -69,7 +69,7 @@ void EventHandlerStartGame::ProcessEvent(Rml::Core::Event& event, const Rml::Cor if (colour_component > 255) colour_component = 255; - colour[i] = (Rml::Core::byte) colour_component; + colour[i] = (Rml::byte) colour_component; } GameDetails::SetDefenderColour(colour); @@ -77,7 +77,7 @@ void EventHandlerStartGame::ProcessEvent(Rml::Core::Event& event, const Rml::Cor // Go to the game window and close the start game window. if (EventManager::LoadWindow("game")) { - Rml::Core::ElementUtilities::GetElementById(context->GetFocusElement(), "game")->Focus(); + Rml::ElementUtilities::GetElementById(context->GetFocusElement(), "game")->Focus(); event.GetTargetElement()->GetOwnerDocument()->Close(); } } diff --git a/Samples/invaders/src/EventHandlerStartGame.h b/Samples/invaders/src/EventHandlerStartGame.h index a3dfde0f4..f6a5939ba 100644 --- a/Samples/invaders/src/EventHandlerStartGame.h +++ b/Samples/invaders/src/EventHandlerStartGame.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTHANDLERSTARTGAME_H -#define RMLUIINVADERSEVENTHANDLERSTARTGAME_H +#ifndef RMLUI_INVADERS_EVENTHANDLERSTARTGAME_H +#define RMLUI_INVADERS_EVENTHANDLERSTARTGAME_H #include "EventHandler.h" @@ -41,7 +41,7 @@ class EventHandlerStartGame : public EventHandler EventHandlerStartGame(); virtual ~EventHandlerStartGame(); - void ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) override; + void ProcessEvent(Rml::Event& event, const Rml::String& value) override; }; #endif diff --git a/Samples/invaders/src/EventInstancer.cpp b/Samples/invaders/src/EventInstancer.cpp index 28dcfc6a7..a2784a00e 100644 --- a/Samples/invaders/src/EventInstancer.cpp +++ b/Samples/invaders/src/EventInstancer.cpp @@ -38,7 +38,7 @@ EventInstancer::~EventInstancer() } // Instances a new event handle for Invaders. -Rml::Core::EventListener* EventInstancer::InstanceEventListener(const Rml::Core::String& value, Rml::Core::Element* /*element*/) +Rml::EventListener* EventInstancer::InstanceEventListener(const Rml::String& value, Rml::Element* /*element*/) { return new Event(value); } diff --git a/Samples/invaders/src/EventInstancer.h b/Samples/invaders/src/EventInstancer.h index d0d48e4c3..fcc398123 100644 --- a/Samples/invaders/src/EventInstancer.h +++ b/Samples/invaders/src/EventInstancer.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTINSTANCER_H -#define RMLUIINVADERSEVENTINSTANCER_H +#ifndef RMLUI_INVADERS_EVENTINSTANCER_H +#define RMLUI_INVADERS_EVENTINSTANCER_H #include @@ -35,14 +35,14 @@ @author Peter Curry */ -class EventInstancer : public Rml::Core::EventListenerInstancer +class EventInstancer : public Rml::EventListenerInstancer { public: EventInstancer(); virtual ~EventInstancer(); /// Instances a new event handle for Invaders. - Rml::Core::EventListener* InstanceEventListener(const Rml::Core::String& value, Rml::Core::Element* element) override; + Rml::EventListener* InstanceEventListener(const Rml::String& value, Rml::Element* element) override; }; diff --git a/Samples/invaders/src/EventManager.cpp b/Samples/invaders/src/EventManager.cpp index dfcd367a0..c7bda1904 100644 --- a/Samples/invaders/src/EventManager.cpp +++ b/Samples/invaders/src/EventManager.cpp @@ -35,13 +35,13 @@ #include "GameDetails.h" // The game's element context (declared in main.cpp). -extern Rml::Core::Context* context; +extern Rml::Context* context; // The event handler for the current screen. This may be nullptr if the current screen has no specific functionality. static EventHandler* event_handler = nullptr; // The event handlers registered with the manager. -typedef Rml::Core::SmallUnorderedMap< Rml::Core::String, EventHandler* > EventHandlerMap; +typedef Rml::SmallUnorderedMap< Rml::String, EventHandler* > EventHandlerMap; EventHandlerMap event_handlers; EventManager::EventManager() @@ -63,7 +63,7 @@ void EventManager::Shutdown() } // Registers a new event handler with the manager. -void EventManager::RegisterEventHandler(const Rml::Core::String& handler_name, EventHandler* handler) +void EventManager::RegisterEventHandler(const Rml::String& handler_name, EventHandler* handler) { // Release any handler bound under the same name. EventHandlerMap::iterator iterator = event_handlers.find(handler_name); @@ -74,15 +74,15 @@ void EventManager::RegisterEventHandler(const Rml::Core::String& handler_name, E } // Processes an event coming through from RmlUi. -void EventManager::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value) +void EventManager::ProcessEvent(Rml::Event& event, const Rml::String& value) { - Rml::Core::StringList commands; - Rml::Core::StringUtilities::ExpandString(commands, value, ';'); + Rml::StringList commands; + Rml::StringUtilities::ExpandString(commands, value, ';'); for (size_t i = 0; i < commands.size(); ++i) { // Check for a generic 'load' or 'exit' command. - Rml::Core::StringList values; - Rml::Core::StringUtilities::ExpandString(values, commands[i], ' '); + Rml::StringList values; + Rml::StringUtilities::ExpandString(values, commands[i], ' '); if (values.empty()) return; @@ -102,7 +102,7 @@ void EventManager::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String } else if (values[0] == "close") { - Rml::Core::ElementDocument* target_document = nullptr; + Rml::ElementDocument* target_document = nullptr; if (values.size() > 1) target_document = context->GetDocument(values[1].c_str()); @@ -133,7 +133,7 @@ void EventManager::ProcessEvent(Rml::Core::Event& event, const Rml::Core::String } // Loads a window and binds the event handler for it. -Rml::Core::ElementDocument* EventManager::LoadWindow(const Rml::Core::String& window_name) +Rml::ElementDocument* EventManager::LoadWindow(const Rml::String& window_name) { // Set the event handler for the new screen, if one has been registered. EventHandler* old_event_handler = event_handler; @@ -144,8 +144,8 @@ Rml::Core::ElementDocument* EventManager::LoadWindow(const Rml::Core::String& wi event_handler = nullptr; // Attempt to load the referenced RML document. - Rml::Core::String document_path = Rml::Core::String("invaders/data/") + window_name + Rml::Core::String(".rml"); - Rml::Core::ElementDocument* document = context->LoadDocument(document_path.c_str()); + Rml::String document_path = Rml::String("invaders/data/") + window_name + Rml::String(".rml"); + Rml::ElementDocument* document = context->LoadDocument(document_path.c_str()); if (document == nullptr) { event_handler = old_event_handler; @@ -153,7 +153,7 @@ Rml::Core::ElementDocument* EventManager::LoadWindow(const Rml::Core::String& wi } // Set the element's title on the title; IDd 'title' in the RML. - Rml::Core::Element* title = document->GetElementById("title"); + Rml::Element* title = document->GetElementById("title"); if (title != nullptr) title->SetInnerRML(document->GetTitle()); diff --git a/Samples/invaders/src/EventManager.h b/Samples/invaders/src/EventManager.h index 04601e17f..ab74cc741 100644 --- a/Samples/invaders/src/EventManager.h +++ b/Samples/invaders/src/EventManager.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSEVENTMANAGER_H -#define RMLUIINVADERSEVENTMANAGER_H +#ifndef RMLUI_INVADERS_EVENTMANAGER_H +#define RMLUI_INVADERS_EVENTMANAGER_H #include #include @@ -47,15 +47,15 @@ class EventManager /// Registers a new event handler with the manager. /// @param[in] handler_name The name of the handler; this must be the same as the window it is handling events for. /// @param[in] handler The event handler. - static void RegisterEventHandler(const Rml::Core::String& handler_name, EventHandler* handler); + static void RegisterEventHandler(const Rml::String& handler_name, EventHandler* handler); /// Processes an event coming through from RmlUi. /// @param[in] event The RmlUi event that spawned the application event. /// @param[in] value The application-specific event value. - static void ProcessEvent(Rml::Core::Event& event, const Rml::Core::String& value); + static void ProcessEvent(Rml::Event& event, const Rml::String& value); /// Loads a window and binds the event handler for it. /// @param[in] window_name The name of the window to load. - static Rml::Core::ElementDocument* LoadWindow(const Rml::Core::String& window_name); + static Rml::ElementDocument* LoadWindow(const Rml::String& window_name); private: EventManager(); diff --git a/Samples/invaders/src/Game.cpp b/Samples/invaders/src/Game.cpp index 1e3823c88..dd51cd2c5 100644 --- a/Samples/invaders/src/Game.cpp +++ b/Samples/invaders/src/Game.cpp @@ -64,7 +64,7 @@ const int SHIELD_START_X = 176; const int SHIELD_START_Y = 600; // The game's element context (declared in main.cpp). -extern Rml::Core::Context* context; +extern Rml::Context* context; Game::Game() { @@ -81,8 +81,8 @@ Game::Game() shields[i] = nullptr; // Use the OpenGL render interface to load our texture. - Rml::Core::Vector2i texture_dimensions; - Rml::Core::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "invaders/data/invaders.tga"); + Rml::Vector2i texture_dimensions; + Rml::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "invaders/data/invaders.tga"); defender = new Defender(this); } @@ -227,9 +227,9 @@ void Game::SetScore(int score) { GameDetails::SetScore(score); - Rml::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("score"); + Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("score"); if (score_element != nullptr) - score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", score).c_str()); + score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str()); // Update the high score if we've beaten it. if (score > HighScores::GetHighScore()) @@ -239,27 +239,27 @@ void Game::SetScore(int score) // Sets the player's high-score. void Game::SetHighScore(int score) { - Rml::Core::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore"); + Rml::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore"); if (high_score_element != nullptr) - high_score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", score).c_str()); + high_score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str()); } void Game::SetLives(int lives) { defender_lives = lives; - Rml::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("lives"); + Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("lives"); if (score_element != nullptr) - score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", defender_lives).c_str()); + score_element->SetInnerRML(Rml::CreateString(128, "%d", defender_lives).c_str()); } void Game::SetWave(int wave) { GameDetails::SetWave(wave); - Rml::Core::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves"); + Rml::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves"); if (waves_element != nullptr) - waves_element->SetInnerRML(Rml::Core::CreateString(128, "%d", wave).c_str()); + waves_element->SetInnerRML(Rml::CreateString(128, "%d", wave).c_str()); } void Game::RemoveLife() @@ -275,14 +275,14 @@ void Game::RemoveLife() } } -const Rml::Core::Vector2f Game::GetWindowDimensions() +const Rml::Vector2f Game::GetWindowDimensions() { - return Rml::Core::Vector2f((float) WINDOW_WIDTH, (float) WINDOW_HEIGHT); + return Rml::Vector2f((float) WINDOW_WIDTH, (float) WINDOW_HEIGHT); } void Game::MoveInvaders() { - Rml::Core::Vector2f new_positions[NUM_INVADERS]; + Rml::Vector2f new_positions[NUM_INVADERS]; // We loop through all invaders, calculating their new positions, if any of them go over the screen bounds, // then we switch direction, move the invaders down and start at 0 again @@ -305,7 +305,7 @@ void Game::MoveInvaders() if (invaders[j]->GetState() == Invader::DEAD) continue; - Rml::Core::Vector2f position = invaders[j]->GetPosition(); + Rml::Vector2f position = invaders[j]->GetPosition(); position.y += INVADER_SPACING_Y; invaders[j]->SetPosition(position); } @@ -352,7 +352,7 @@ void Game::OnGameOver() void Game::InitialiseShields() { - Rml::Core::Vector2f shield_array_start_position((float) SHIELD_START_X, (float) SHIELD_START_Y); + Rml::Vector2f shield_array_start_position((float) SHIELD_START_X, (float) SHIELD_START_Y); for (int x = 0; x < NUM_SHIELD_ARRAYS; x++) { @@ -368,7 +368,7 @@ void Game::InitialiseShields() } shields[(x * NUM_SHIELDS_PER_ARRAY) + i] = new Shield(this, type); - shields[(x * NUM_SHIELDS_PER_ARRAY) + i]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * i, 0)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + i]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * i, 0)); } // Middle row (row of 4) @@ -384,15 +384,15 @@ void Game::InitialiseShields() } shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i] = new Shield(this, type); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * i, (float) SHIELD_SIZE)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * i, (float) SHIELD_SIZE)); } // Bottom row (2, one on each end) shields[(x * NUM_SHIELDS_PER_ARRAY) + 8] = new Shield(this, Shield::REGULAR); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 8]->SetPosition(shield_array_start_position + Rml::Core::Vector2f(0, (float) SHIELD_SIZE * 2)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 8]->SetPosition(shield_array_start_position + Rml::Vector2f(0, (float) SHIELD_SIZE * 2)); shields[(x * NUM_SHIELDS_PER_ARRAY) + 9] = new Shield(this, Shield::REGULAR); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 9]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * 3, (float) SHIELD_SIZE * 2)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 9]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * 3, (float) SHIELD_SIZE * 2)); shield_array_start_position.x += SHIELD_SPACING_X; } @@ -417,7 +417,7 @@ void Game::InitialiseWave() } // Determine position of top left invader - Rml::Core::Vector2f invader_position((float) (WINDOW_WIDTH - (NUM_INVADERS_PER_ROW * INVADER_SPACING_X)) / 2, (float) (INVADER_START_Y + (y * INVADER_SPACING_Y))); + Rml::Vector2f invader_position((float) (WINDOW_WIDTH - (NUM_INVADERS_PER_ROW * INVADER_SPACING_X)) / 2, (float) (INVADER_START_Y + (y * INVADER_SPACING_Y))); for (int x = 0; x < NUM_INVADERS_PER_ROW; x++) { diff --git a/Samples/invaders/src/Game.h b/Samples/invaders/src/Game.h index 6820c8c16..952d502f5 100644 --- a/Samples/invaders/src/Game.h +++ b/Samples/invaders/src/Game.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSGAME_H -#define RMLUIINVADERSGAME_H +#ifndef RMLUI_INVADERS_GAME_H +#define RMLUI_INVADERS_GAME_H #include #include @@ -89,7 +89,7 @@ class Game void RemoveLife(); /// Get the dimensions of the game window. - const Rml::Core::Vector2f GetWindowDimensions(); + const Rml::Vector2f GetWindowDimensions(); private: @@ -116,7 +116,7 @@ class Game Shield** shields; // Texture that contains the sprites - Rml::Core::TextureHandle texture; + Rml::TextureHandle texture; void InitialiseShields(); void InitialiseWave(); diff --git a/Samples/invaders/src/GameDetails.cpp b/Samples/invaders/src/GameDetails.cpp index 923653ebd..508ff081c 100644 --- a/Samples/invaders/src/GameDetails.cpp +++ b/Samples/invaders/src/GameDetails.cpp @@ -29,7 +29,7 @@ #include "GameDetails.h" static GameDetails::Difficulty difficulty = GameDetails::EASY; -static Rml::Core::Colourb colour = Rml::Core::Colourb(255, 0, 0); +static Rml::Colourb colour = Rml::Colourb(255, 0, 0); static int score = -1; static int wave = 0; static bool paused = false; @@ -59,13 +59,13 @@ GameDetails::Difficulty GameDetails::GetDifficulty() } // Sets the colour of the player's ship. -void GameDetails::SetDefenderColour(const Rml::Core::Colourb& _colour) +void GameDetails::SetDefenderColour(const Rml::Colourb& _colour) { colour = _colour; } // Returns the player's ship colour. -const Rml::Core::Colourb& GameDetails::GetDefenderColour() +const Rml::Colourb& GameDetails::GetDefenderColour() { return colour; } diff --git a/Samples/invaders/src/GameDetails.h b/Samples/invaders/src/GameDetails.h index f45bd2c3a..13cf37f5c 100644 --- a/Samples/invaders/src/GameDetails.h +++ b/Samples/invaders/src/GameDetails.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSGAMEDETAILS_H -#define RMLUIINVADERSGAMEDETAILS_H +#ifndef RMLUI_INVADERS_GAMEDETAILS_H +#define RMLUI_INVADERS_GAMEDETAILS_H #include @@ -49,10 +49,10 @@ class GameDetails /// Sets the colour of the player's ship. /// @param[in] colour The new ship colour. - static void SetDefenderColour(const Rml::Core::Colourb& colour); + static void SetDefenderColour(const Rml::Colourb& colour); /// Returns the player's ship colour. /// @return The colour of the player's ship. - static const Rml::Core::Colourb& GetDefenderColour(); + static const Rml::Colourb& GetDefenderColour(); /// Sets the score the player achieved in the last game. /// @param[in] score The player's score. diff --git a/Samples/invaders/src/HighScores.cpp b/Samples/invaders/src/HighScores.cpp index 6e376b875..6bbe0c5ed 100644 --- a/Samples/invaders/src/HighScores.cpp +++ b/Samples/invaders/src/HighScores.cpp @@ -32,7 +32,7 @@ HighScores* HighScores::instance = nullptr; -HighScores::HighScores() : Rml::Controls::DataSource("high_scores") +HighScores::HighScores() : Rml::DataSource("high_scores") { RMLUI_ASSERT(instance == nullptr); instance = this; @@ -64,7 +64,7 @@ void HighScores::Shutdown() delete instance; } -void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) +void HighScores::GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns) { if (table == "scores") { @@ -76,27 +76,27 @@ void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& tab } else if (columns[i] == "name_required") { - row.push_back(Rml::Core::CreateString(4, "%d", scores[row_index].name_required)); + row.push_back(Rml::CreateString(4, "%d", scores[row_index].name_required)); } else if (columns[i] == "score") { - row.push_back(Rml::Core::CreateString(32, "%d", scores[row_index].score)); + row.push_back(Rml::CreateString(32, "%d", scores[row_index].score)); } else if (columns[i] == "colour") { - Rml::Core::String colour_string; - Rml::Core::TypeConverter< Rml::Core::Colourb, Rml::Core::String >::Convert(scores[row_index].colour, colour_string); + Rml::String colour_string; + Rml::TypeConverter< Rml::Colourb, Rml::String >::Convert(scores[row_index].colour, colour_string); row.push_back(colour_string); } else if (columns[i] == "wave") { - row.push_back(Rml::Core::CreateString(8, "%d", scores[row_index].wave)); + row.push_back(Rml::CreateString(8, "%d", scores[row_index].wave)); } } } } -int HighScores::GetNumRows(const Rml::Core::String& table) +int HighScores::GetNumRows(const Rml::String& table) { if (table == "scores") { @@ -124,18 +124,18 @@ int HighScores::GetHighScore() return instance->scores[0].score; } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score) { instance->SubmitScore(name, colour, wave, score, false); } -void HighScores::SubmitScore(const Rml::Core::Colourb& colour, int wave, int score) +void HighScores::SubmitScore(const Rml::Colourb& colour, int wave, int score) { instance->SubmitScore("", colour, wave, score, true); } // Sets the name of the last player to submit their score. -void HighScores::SubmitName(const Rml::Core::String& name) +void HighScores::SubmitName(const Rml::String& name) { for (int i = 0; i < instance->GetNumRows("scores"); i++) { @@ -148,7 +148,7 @@ void HighScores::SubmitName(const Rml::Core::String& name) } } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, bool name_required) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, bool name_required) { for (int i = 0; i < NUM_SCORES; i++) { @@ -196,17 +196,17 @@ void HighScores::LoadScores() char buffer[1024]; while (fgets(buffer, 1024, scores_file)) { - Rml::Core::StringList score_parts; - Rml::Core::StringUtilities::ExpandString(score_parts, Rml::Core::String(buffer), '\t'); + Rml::StringList score_parts; + Rml::StringUtilities::ExpandString(score_parts, Rml::String(buffer), '\t'); if (score_parts.size() == 4) { - Rml::Core::Colourb colour; + Rml::Colourb colour; int wave; int score; - if (Rml::Core::TypeConverter< Rml::Core::String , Rml::Core::Colourb >::Convert(score_parts[1], colour) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[2], wave) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[3], score)) + if (Rml::TypeConverter< Rml::String , Rml::Colourb >::Convert(score_parts[1], colour) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[2], wave) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[3], score)) { SubmitScore(score_parts[0], colour, wave, score); } @@ -225,10 +225,10 @@ void HighScores::SaveScores() { for (int i = 0; i < GetNumRows("scores"); i++) { - Rml::Core::String colour_string; - Rml::Core::TypeConverter< Rml::Core::Colourb, Rml::Core::String >::Convert(scores[i].colour, colour_string); + Rml::String colour_string; + Rml::TypeConverter< Rml::Colourb, Rml::String >::Convert(scores[i].colour, colour_string); - Rml::Core::String score = Rml::Core::CreateString(1024, "%s\t%s\t%d\t%d\n", scores[i].name.c_str(), colour_string.c_str(), scores[i].wave, scores[i].score); + Rml::String score = Rml::CreateString(1024, "%s\t%s\t%d\t%d\n", scores[i].name.c_str(), colour_string.c_str(), scores[i].wave, scores[i].score); fputs(score.c_str(), scores_file); } diff --git a/Samples/invaders/src/HighScores.h b/Samples/invaders/src/HighScores.h index d75b13a79..fccdbf1da 100644 --- a/Samples/invaders/src/HighScores.h +++ b/Samples/invaders/src/HighScores.h @@ -26,32 +26,32 @@ * */ -#ifndef RMLUIINVADERSHIGHSCORES_H -#define RMLUIINVADERSHIGHSCORES_H +#ifndef RMLUI_INVADERS_HIGHSCORES_H +#define RMLUI_INVADERS_HIGHSCORES_H -#include +#include #include const int NUM_SCORES = 10; -class HighScores : public Rml::Controls::DataSource +class HighScores : public Rml::DataSource { public: static void Initialise(); static void Shutdown(); - void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns); - int GetNumRows(const Rml::Core::String& table); + void GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns); + int GetNumRows(const Rml::String& table); static int GetHighScore(); /// Two functions to add a score to the chart. /// Adds a full score, including a name. This won't prompt the user to enter their name. - static void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score); + static void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score); /// Adds a score, and causes an input field to appear to request the user for their name. - static void SubmitScore(const Rml::Core::Colourb& colour, int wave, int score); + static void SubmitScore(const Rml::Colourb& colour, int wave, int score); /// Sets the name of the last player to submit their score. - static void SubmitName(const Rml::Core::String& name); + static void SubmitName(const Rml::String& name); private: HighScores(); @@ -59,15 +59,15 @@ class HighScores : public Rml::Controls::DataSource static HighScores* instance; - void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, bool name_required); + void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, bool name_required); void LoadScores(); void SaveScores(); struct Score { - Rml::Core::String name; + Rml::String name; bool name_required; - Rml::Core::Colourb colour; + Rml::Colourb colour; int score; int wave; }; diff --git a/Samples/invaders/src/HighScoresNameFormatter.cpp b/Samples/invaders/src/HighScoresNameFormatter.cpp index 627f2cdd9..18903a37f 100644 --- a/Samples/invaders/src/HighScoresNameFormatter.cpp +++ b/Samples/invaders/src/HighScoresNameFormatter.cpp @@ -28,7 +28,7 @@ #include "HighScoresNameFormatter.h" -HighScoresNameFormatter::HighScoresNameFormatter() : Rml::Controls::DataFormatter("name") +HighScoresNameFormatter::HighScoresNameFormatter() : Rml::DataFormatter("name") { } @@ -36,7 +36,7 @@ HighScoresNameFormatter::~HighScoresNameFormatter() { } -void HighScoresNameFormatter::FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) +void HighScoresNameFormatter::FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data) { // Data format: // raw_data[0] is the name. diff --git a/Samples/invaders/src/HighScoresNameFormatter.h b/Samples/invaders/src/HighScoresNameFormatter.h index 0a3a30fea..a433d24da 100644 --- a/Samples/invaders/src/HighScoresNameFormatter.h +++ b/Samples/invaders/src/HighScoresNameFormatter.h @@ -26,22 +26,22 @@ * */ -#ifndef RMLUIINVADERSHIGHSCORESNAMEFORMATTER_H -#define RMLUIINVADERSHIGHSCORESNAMEFORMATTER_H +#ifndef RMLUI_INVADERS_HIGHSCORESNAMEFORMATTER_H +#define RMLUI_INVADERS_HIGHSCORESNAMEFORMATTER_H -#include +#include /** @author Robert Curry */ -class HighScoresNameFormatter : public Rml::Controls::DataFormatter +class HighScoresNameFormatter : public Rml::DataFormatter { public: HighScoresNameFormatter(); ~HighScoresNameFormatter(); - void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data); + void FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data); }; #endif diff --git a/Samples/invaders/src/HighScoresShipFormatter.cpp b/Samples/invaders/src/HighScoresShipFormatter.cpp index c3f78420f..7f3059b2f 100644 --- a/Samples/invaders/src/HighScoresShipFormatter.cpp +++ b/Samples/invaders/src/HighScoresShipFormatter.cpp @@ -29,7 +29,7 @@ #include "HighScoresShipFormatter.h" #include -HighScoresShipFormatter::HighScoresShipFormatter() : Rml::Controls::DataFormatter("ship") +HighScoresShipFormatter::HighScoresShipFormatter() : Rml::DataFormatter("ship") { } @@ -37,7 +37,7 @@ HighScoresShipFormatter::~HighScoresShipFormatter() { } -void HighScoresShipFormatter::FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) +void HighScoresShipFormatter::FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data) { // Data format: // raw_data[0] is the colour, in "%d, %d, %d, %d" format. diff --git a/Samples/invaders/src/HighScoresShipFormatter.h b/Samples/invaders/src/HighScoresShipFormatter.h index 15a64e509..a90229f0a 100644 --- a/Samples/invaders/src/HighScoresShipFormatter.h +++ b/Samples/invaders/src/HighScoresShipFormatter.h @@ -26,22 +26,22 @@ * */ -#ifndef RMLUIINVADERSHIGHSCORESSHIPFORMATTER_H -#define RMLUIINVADERSHIGHSCORESSHIPFORMATTER_H +#ifndef RMLUI_INVADERS_HIGHSCORESSHIPFORMATTER_H +#define RMLUI_INVADERS_HIGHSCORESSHIPFORMATTER_H -#include +#include /** @author Robert Curry */ -class HighScoresShipFormatter : public Rml::Controls::DataFormatter +class HighScoresShipFormatter : public Rml::DataFormatter { public: HighScoresShipFormatter(); ~HighScoresShipFormatter(); - void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data); + void FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data); }; #endif diff --git a/Samples/invaders/src/Invader.cpp b/Samples/invaders/src/Invader.cpp index 56202a3f2..404068bbf 100644 --- a/Samples/invaders/src/Invader.cpp +++ b/Samples/invaders/src/Invader.cpp @@ -42,34 +42,34 @@ const float BOMB_MISSILE_SPEED = 7; const float BOMB_PROBABILITY_EASY = 0.002f; const float BOMB_PROBABILITY_HARD = 0.005f; const float EXPLOSION_TIME = 0.25f; -const Rml::Core::Colourb MOTHERSHIP_COLOUR = Rml::Core::Colourb(255, 0, 0, 255); +const Rml::Colourb MOTHERSHIP_COLOUR = Rml::Colourb(255, 0, 0, 255); Sprite invader_sprites[] = { // Rank 1 - Sprite(Rml::Core::Vector2f(48, 32), Rml::Core::Vector2f(0.609375f, 0), Rml::Core::Vector2f(0.796875f, 0.5f)), - Sprite(Rml::Core::Vector2f(48, 32), Rml::Core::Vector2f(0.80078125f, 0), Rml::Core::Vector2f(0.98828125f, 0.5f)), + Sprite(Rml::Vector2f(48, 32), Rml::Vector2f(0.609375f, 0), Rml::Vector2f(0.796875f, 0.5f)), + Sprite(Rml::Vector2f(48, 32), Rml::Vector2f(0.80078125f, 0), Rml::Vector2f(0.98828125f, 0.5f)), // Rank 2 - Sprite(Rml::Core::Vector2f(44, 32), Rml::Core::Vector2f(0.2578125f, 0), Rml::Core::Vector2f(0.4296875f, 0.5f)), - Sprite(Rml::Core::Vector2f(44, 32), Rml::Core::Vector2f(0.43359375f, 0), Rml::Core::Vector2f(0.60546875f, 0.5f)), + Sprite(Rml::Vector2f(44, 32), Rml::Vector2f(0.2578125f, 0), Rml::Vector2f(0.4296875f, 0.5f)), + Sprite(Rml::Vector2f(44, 32), Rml::Vector2f(0.43359375f, 0), Rml::Vector2f(0.60546875f, 0.5f)), // Rank 3 - Sprite(Rml::Core::Vector2f(32, 32), Rml::Core::Vector2f(0, 0), Rml::Core::Vector2f(0.125f, 0.5f)), - Sprite(Rml::Core::Vector2f(32, 32), Rml::Core::Vector2f(0.12890625f, 0), Rml::Core::Vector2f(0.25390625f, 0.5f)), + Sprite(Rml::Vector2f(32, 32), Rml::Vector2f(0, 0), Rml::Vector2f(0.125f, 0.5f)), + Sprite(Rml::Vector2f(32, 32), Rml::Vector2f(0.12890625f, 0), Rml::Vector2f(0.25390625f, 0.5f)), // Mothership - Sprite(Rml::Core::Vector2f(64, 28), Rml::Core::Vector2f(0.23828125f, 0.515625f), Rml::Core::Vector2f(0.48828125f, 0.953125f)), + Sprite(Rml::Vector2f(64, 28), Rml::Vector2f(0.23828125f, 0.515625f), Rml::Vector2f(0.48828125f, 0.953125f)), // Explosion - Sprite(Rml::Core::Vector2f(52, 28), Rml::Core::Vector2f(0.71484375f, 0.51562500f), Rml::Core::Vector2f(0.91796875f, 0.95312500f)) + Sprite(Rml::Vector2f(52, 28), Rml::Vector2f(0.71484375f, 0.51562500f), Rml::Vector2f(0.91796875f, 0.95312500f)) }; Sprite bomb_sprites[] = { // Ray - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.51171875f, 0.51562500f), Rml::Core::Vector2f(0.55859375f, 0.82812500f)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.56250000, 0.51562500), Rml::Core::Vector2f(0.60937500, 0.82812500)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.61328125, 0.51562500), Rml::Core::Vector2f(0.66015625, 0.82812500)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.66406250, 0.51562500), Rml::Core::Vector2f(0.71093750, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.51171875f, 0.51562500f), Rml::Vector2f(0.55859375f, 0.82812500f)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.56250000, 0.51562500), Rml::Vector2f(0.60937500, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.61328125, 0.51562500), Rml::Vector2f(0.66015625, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.66406250, 0.51562500), Rml::Vector2f(0.71093750, 0.82812500)), // Missile - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.92578125, 0.51562500), Rml::Core::Vector2f(0.97265625, 0.82812500)) + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.92578125, 0.51562500), Rml::Vector2f(0.97265625, 0.82812500)) }; Invader::Invader(Game* _game, InvaderType _type, int _index) : position(0,0) @@ -94,12 +94,12 @@ Invader::~Invader() { } -void Invader::SetPosition(const Rml::Core::Vector2f& _position) +void Invader::SetPosition(const Rml::Vector2f& _position) { position = _position; } -const Rml::Core::Vector2f& Invader::GetPosition() const +const Rml::Vector2f& Invader::GetPosition() const { return position; } @@ -147,10 +147,10 @@ void Invader::Update() } } else if ( state == ALIVE - && Rml::Core::Math::RandomReal(1.0f) < bomb_probability + && Rml::Math::RandomReal(1.0f) < bomb_probability && game->CanDropBomb(invader_index)) { - bomb = Rml::Core::Math::RandomInteger(2) == 0 ? RAY : MISSILE; + bomb = Rml::Math::RandomInteger(2) == 0 ? RAY : MISSILE; bomb_position = position; bomb_position.x += invader_sprites[GetSpriteIndex()].dimensions.x / 2; @@ -189,10 +189,10 @@ void Invader::Render() glColor4ubv(MOTHERSHIP_COLOUR); } int sprite_index = GetSpriteIndex(); - int sprite_offset = Rml::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); + int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); if (state != DEAD) - invader_sprites[sprite_index].Render(Rml::Core::Vector2f(position.x - sprite_offset, position.y)); + invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y)); if (bomb != NONE) { @@ -210,11 +210,11 @@ Invader::InvaderState Invader::GetState() return state; } -bool Invader::CheckHit(const Rml::Core::Vector2f& check_position) +bool Invader::CheckHit(const Rml::Vector2f& check_position) { // Get the sprite index we're currently using for collision detection int sprite_index = GetSpriteIndex(); - int sprite_offset = Rml::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); + int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); float sprite_width = invader_sprites[sprite_index].dimensions.x; float sprite_height = invader_sprites[sprite_index].dimensions.y; @@ -230,7 +230,7 @@ bool Invader::CheckHit(const Rml::Core::Vector2f& check_position) switch (type) { RMLUI_UNUSED_SWITCH_ENUM(UNKNOWN); - case MOTHERSHIP: score = (Rml::Core::Math::RandomInteger(6) + 1) * 50; break; // 50 -> 300 + case MOTHERSHIP: score = (Rml::Math::RandomInteger(6) + 1) * 50; break; // 50 -> 300 case RANK3: score = 40; break; case RANK2: score = 20; break; case RANK1: score = 10; break; diff --git a/Samples/invaders/src/Invader.h b/Samples/invaders/src/Invader.h index ea863791a..e0252f489 100644 --- a/Samples/invaders/src/Invader.h +++ b/Samples/invaders/src/Invader.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSINVADER_H -#define RMLUIINVADERSINVADER_H +#ifndef RMLUI_INVADERS_INVADER_H +#define RMLUI_INVADERS_INVADER_H #include @@ -51,10 +51,10 @@ class Invader /// Set the invaders screen position /// @param position Position in screen space - void SetPosition(const Rml::Core::Vector2f& position); + void SetPosition(const Rml::Vector2f& position); /// Get the current invader position /// @returns The invaders position in screen space - const Rml::Core::Vector2f& GetPosition() const; + const Rml::Vector2f& GetPosition() const; /// Update the invader virtual void Update(); @@ -75,7 +75,7 @@ class Invader /// If a hit is detected, will explode and start the death timer /// @param position Position to do the hit check at /// @returns If the invader was hit - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); protected: // Game this invader is in @@ -86,7 +86,7 @@ class Invader // The invader type we represent InvaderType type; // The current position in screen space of the invader - Rml::Core::Vector2f position; + Rml::Vector2f position; // Our current animation frame int animation_frame; @@ -96,7 +96,7 @@ class Invader // Our current in-flight bomb, or none. (may be not none if we're dead.) BombType bomb; // The current position of the bomb in screen space - Rml::Core::Vector2f bomb_position; + Rml::Vector2f bomb_position; // The animation frame the bomb is on int bomb_animation_frame; // When the last bomb update occured diff --git a/Samples/invaders/src/Mothership.cpp b/Samples/invaders/src/Mothership.cpp index 7fa7cda44..dad0e31c6 100644 --- a/Samples/invaders/src/Mothership.cpp +++ b/Samples/invaders/src/Mothership.cpp @@ -44,7 +44,7 @@ Mothership::Mothership(Game* game, int index) : Invader(game, Invader::MOTHERSHI state = DEAD; update_frame_start = 0; direction = 0; - position = Rml::Core::Vector2f(-SPRITE_WIDTH, 64.0f); + position = Rml::Vector2f(-SPRITE_WIDTH, 64.0f); } Mothership::~Mothership() @@ -71,9 +71,9 @@ void Mothership::Update() update_frame_start = Shell::GetElapsedTime(); } // Determine if we should come out of hiding - else if (Rml::Core::Math::RandomReal(1.0f) < APPEARANCE_PROBABILITY) + else if (Rml::Math::RandomReal(1.0f) < APPEARANCE_PROBABILITY) { - direction = Rml::Core::Math::RandomReal(1.0f) < 0.5 ? -1.0f : 1.0f; + direction = Rml::Math::RandomReal(1.0f) < 0.5 ? -1.0f : 1.0f; if (direction < 0) position.x = game->GetWindowDimensions().x + SPRITE_WIDTH; diff --git a/Samples/invaders/src/Mothership.h b/Samples/invaders/src/Mothership.h index 8ce66f49a..6a6bb6929 100644 --- a/Samples/invaders/src/Mothership.h +++ b/Samples/invaders/src/Mothership.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSMOTHERSHIP_H -#define RMLUIINVADERSMOTHERSHIP_H +#ifndef RMLUI_INVADERS_MOTHERSHIP_H +#define RMLUI_INVADERS_MOTHERSHIP_H #include "Invader.h" diff --git a/Samples/invaders/src/Shield.cpp b/Samples/invaders/src/Shield.cpp index dc6845bf5..629dbf838 100644 --- a/Samples/invaders/src/Shield.cpp +++ b/Samples/invaders/src/Shield.cpp @@ -109,12 +109,12 @@ void Shield::InitialiseCells() } } -void Shield::SetPosition(const Rml::Core::Vector2f& _position) +void Shield::SetPosition(const Rml::Vector2f& _position) { position = _position; } -const Rml::Core::Vector2f& Shield::GetPosition() const +const Rml::Vector2f& Shield::GetPosition() const { return position; } @@ -135,7 +135,7 @@ void Shield::Render() { if (shield_cells[i][j] == ON) { - Rml::Core::Vector2f cell_position = position + Rml::Core::Vector2f((float) (PIXEL_SIZE * i), (float) (PIXEL_SIZE * j)); + Rml::Vector2f cell_position = position + Rml::Vector2f((float) (PIXEL_SIZE * i), (float) (PIXEL_SIZE * j)); glVertex2f(cell_position.x, cell_position.y); } } @@ -147,7 +147,7 @@ void Shield::Render() } } -bool Shield::CheckHit(const Rml::Core::Vector2f& check_position) +bool Shield::CheckHit(const Rml::Vector2f& check_position) { float sprite_size = PIXEL_SIZE * NUM_SHIELD_CELLS; @@ -177,8 +177,8 @@ void Shield::SustainDamage() int num_shields_to_lose = (NUM_SHIELD_CELLS * NUM_SHIELD_CELLS) / MAX_HEALTH; while (num_shields_to_lose > 0) { - int x = Rml::Core::Math::RandomInteger(NUM_SHIELD_CELLS); - int y = Rml::Core::Math::RandomInteger(NUM_SHIELD_CELLS); + int x = Rml::Math::RandomInteger(NUM_SHIELD_CELLS); + int y = Rml::Math::RandomInteger(NUM_SHIELD_CELLS); if (shield_cells[x][y] != DESTROYED) { shield_cells[x][y] = DESTROYED; diff --git a/Samples/invaders/src/Shield.h b/Samples/invaders/src/Shield.h index 1c04bcdaf..7d83e745e 100644 --- a/Samples/invaders/src/Shield.h +++ b/Samples/invaders/src/Shield.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSSHIELD_H -#define RMLUIINVADERSSHIELD_H +#ifndef RMLUI_INVADERS_SHIELD_H +#define RMLUI_INVADERS_SHIELD_H #include @@ -56,10 +56,10 @@ class Shield /// Set the shield's screen position /// @param position Position in screen space - void SetPosition(const Rml::Core::Vector2f& position); + void SetPosition(const Rml::Vector2f& position); /// Get the current shield position /// @returns The shield's position in screen space - const Rml::Core::Vector2f& GetPosition() const; + const Rml::Vector2f& GetPosition() const; /// Render the shield. void Render(); @@ -68,7 +68,7 @@ class Shield /// If a hit is detected, will degrade the shield. /// @param position Position to do the hit check at /// @returns If the shield was hit - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); protected: void SustainDamage(); @@ -79,7 +79,7 @@ class Shield // The invader type we represent ShieldType type; // The current position in screen space of the shield - Rml::Core::Vector2f position; + Rml::Vector2f position; // Our current state - starts at 4, degrades once per hit. int health; diff --git a/Samples/invaders/src/Sprite.cpp b/Samples/invaders/src/Sprite.cpp index ffa7cf0d2..b195b2be7 100644 --- a/Samples/invaders/src/Sprite.cpp +++ b/Samples/invaders/src/Sprite.cpp @@ -29,7 +29,7 @@ #include "Sprite.h" #include -Sprite::Sprite(const Rml::Core::Vector2f& dimensions, const Rml::Core::Vector2f& top_left_texcoord, const Rml::Core::Vector2f& bottom_right_texcoord) : dimensions(dimensions), top_left_texcoord(top_left_texcoord), bottom_right_texcoord(bottom_right_texcoord) +Sprite::Sprite(const Rml::Vector2f& dimensions, const Rml::Vector2f& top_left_texcoord, const Rml::Vector2f& bottom_right_texcoord) : dimensions(dimensions), top_left_texcoord(top_left_texcoord), bottom_right_texcoord(bottom_right_texcoord) { } @@ -37,7 +37,7 @@ Sprite::~Sprite() { } -void Sprite::Render(const Rml::Core::Vector2f& position) +void Sprite::Render(const Rml::Vector2f& position) { glTexCoord2f(top_left_texcoord.x, top_left_texcoord.y); glVertex2f(position.x, position.y); diff --git a/Samples/invaders/src/Sprite.h b/Samples/invaders/src/Sprite.h index a1633b0a0..01cda0f15 100644 --- a/Samples/invaders/src/Sprite.h +++ b/Samples/invaders/src/Sprite.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSSPRITE_H -#define RMLUIINVADERSSPRITE_H +#ifndef RMLUI_INVADERS_SPRITE_H +#define RMLUI_INVADERS_SPRITE_H #include @@ -38,14 +38,14 @@ class Sprite { public: - Sprite(const Rml::Core::Vector2f& dimensions, const Rml::Core::Vector2f& top_left_texcoord, const Rml::Core::Vector2f& bottom_right_texcoord); + Sprite(const Rml::Vector2f& dimensions, const Rml::Vector2f& top_left_texcoord, const Rml::Vector2f& bottom_right_texcoord); ~Sprite(); - void Render(const Rml::Core::Vector2f& position); + void Render(const Rml::Vector2f& position); - Rml::Core::Vector2f dimensions; - Rml::Core::Vector2f top_left_texcoord; - Rml::Core::Vector2f bottom_right_texcoord; + Rml::Vector2f dimensions; + Rml::Vector2f top_left_texcoord; + Rml::Vector2f bottom_right_texcoord; }; #endif diff --git a/Samples/invaders/src/main.cpp b/Samples/invaders/src/main.cpp index 780c63b53..da261b5b6 100644 --- a/Samples/invaders/src/main.cpp +++ b/Samples/invaders/src/main.cpp @@ -27,7 +27,6 @@ */ #include -#include #include #include #include @@ -44,7 +43,7 @@ #include "HighScoresNameFormatter.h" #include "HighScoresShipFormatter.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -93,21 +92,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); - // Initialise the RmlUi Controls library. - Rml::Controls::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -121,13 +118,13 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Register Invader's custom element and decorator instancers. - Rml::Core::ElementInstancerGeneric< ElementGame > element_instancer_game; - Rml::Core::Factory::RegisterElementInstancer("game", &element_instancer_game); + Rml::ElementInstancerGeneric< ElementGame > element_instancer_game; + Rml::Factory::RegisterElementInstancer("game", &element_instancer_game); DecoratorInstancerStarfield decorator_instancer_starfield; DecoratorInstancerDefender decorator_instancer_defender; - Rml::Core::Factory::RegisterDecoratorInstancer("starfield", &decorator_instancer_starfield); - Rml::Core::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); + Rml::Factory::RegisterDecoratorInstancer("starfield", &decorator_instancer_starfield); + Rml::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); // Register Invader's data formatters HighScoresNameFormatter name_formatter; @@ -138,7 +135,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) // Initialise the event instancer and handlers. EventInstancer event_listener_instancer; - Rml::Core::Factory::RegisterEventListenerInstancer(&event_listener_instancer); + Rml::Factory::RegisterEventListenerInstancer(&event_listener_instancer); EventManager::RegisterEventHandler("start_game", new EventHandlerStartGame()); EventManager::RegisterEventHandler("high_score", new EventHandlerHighScore()); @@ -156,7 +153,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) EventManager::Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/luainvaders/src/DecoratorDefender.cpp b/Samples/luainvaders/src/DecoratorDefender.cpp index f49e8625b..09320a271 100644 --- a/Samples/luainvaders/src/DecoratorDefender.cpp +++ b/Samples/luainvaders/src/DecoratorDefender.cpp @@ -36,7 +36,7 @@ DecoratorDefender::~DecoratorDefender() { } -bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path) +bool DecoratorDefender::Initialise(const Rml::String& image_source, const Rml::String& image_path) { image_index = LoadTexture(image_source, image_path); if (image_index == -1) @@ -48,30 +48,30 @@ bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element)) const +Rml::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Element* RMLUI_UNUSED_PARAMETER(element)) const { RMLUI_UNUSED(element); - return Rml::Core::Decorator::INVALID_DECORATORDATAHANDLE; + return Rml::Decorator::INVALID_DECORATORDATAHANDLE; } // Called to release element data generated by this decorator. -void DecoratorDefender::ReleaseElementData(Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::ReleaseElementData(Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); } // Called to render the decorator on an element. -void DecoratorDefender::RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); - Rml::Core::Vector2f position = element->GetAbsoluteOffset(Rml::Core::Box::PADDING).Round(); - Rml::Core::Vector2f size = element->GetBox().GetSize(Rml::Core::Box::PADDING).Round(); + Rml::Vector2f position = element->GetAbsoluteOffset(Rml::Box::PADDING).Round(); + Rml::Vector2f size = element->GetBox().GetSize(Rml::Box::PADDING).Round(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, (GLuint) GetTexture(image_index)->GetHandle(element->GetRenderInterface())); - Rml::Core::Colourb colour = element->GetProperty< Rml::Core::Colourb >("color"); + Rml::Colourb colour = element->GetProperty< Rml::Colourb >("color"); glColor4ubv(colour); glBegin(GL_QUADS); diff --git a/Samples/luainvaders/src/DecoratorDefender.h b/Samples/luainvaders/src/DecoratorDefender.h index a68f90726..3f8f43512 100644 --- a/Samples/luainvaders/src/DecoratorDefender.h +++ b/Samples/luainvaders/src/DecoratorDefender.h @@ -26,30 +26,30 @@ * */ -#ifndef RMLUIINVADERSDECORATORDEFENDER_H -#define RMLUIINVADERSDECORATORDEFENDER_H +#ifndef RMLUI_LUAINVADERS_DECORATORDEFENDER_H +#define RMLUI_LUAINVADERS_DECORATORDEFENDER_H #include -class DecoratorDefender : public Rml::Core::Decorator +class DecoratorDefender : public Rml::Decorator { public: virtual ~DecoratorDefender(); - bool Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path); + bool Initialise(const Rml::String& image_source, const Rml::String& image_path); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param element[in] The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param element_data[in] The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param element[in] The element to render the decorator on. /// @param element_data[in] The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int image_index; diff --git a/Samples/luainvaders/src/DecoratorInstancerDefender.cpp b/Samples/luainvaders/src/DecoratorInstancerDefender.cpp index 2e847e361..a3439180b 100644 --- a/Samples/luainvaders/src/DecoratorInstancerDefender.cpp +++ b/Samples/luainvaders/src/DecoratorInstancerDefender.cpp @@ -35,7 +35,7 @@ DecoratorInstancerDefender::DecoratorInstancerDefender() { id_image_src = RegisterProperty("image-src", "").AddParser("string").GetId(); - RegisterShorthand("decorator", "image-src", Rml::Core::ShorthandType::FallThrough); + RegisterShorthand("decorator", "image-src", Rml::ShorthandType::FallThrough); } DecoratorInstancerDefender::~DecoratorInstancerDefender() @@ -43,12 +43,12 @@ DecoratorInstancerDefender::~DecoratorInstancerDefender() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - const Rml::Core::Property* image_source_property = properties.GetProperty(id_image_src); - Rml::Core::String image_source = image_source_property->Get< Rml::Core::String >(); - Rml::Core::String source_path; + const Rml::Property* image_source_property = properties.GetProperty(id_image_src); + Rml::String image_source = image_source_property->Get< Rml::String >(); + Rml::String source_path; if (auto & source = image_source_property->source) source_path = source->path; diff --git a/Samples/luainvaders/src/DecoratorInstancerDefender.h b/Samples/luainvaders/src/DecoratorInstancerDefender.h index 92529b842..1ea8bc941 100644 --- a/Samples/luainvaders/src/DecoratorInstancerDefender.h +++ b/Samples/luainvaders/src/DecoratorInstancerDefender.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDECORATORINSTANCERDEFENDER_H -#define RMLUIINVADERSDECORATORINSTANCERDEFENDER_H +#ifndef RMLUI_LUAINVADERS_DECORATORINSTANCERDEFENDER_H +#define RMLUI_LUAINVADERS_DECORATORINSTANCERDEFENDER_H #include @@ -35,7 +35,7 @@ @author Robert Curry */ -class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer +class DecoratorInstancerDefender : public Rml::DecoratorInstancer { public: DecoratorInstancerDefender(); @@ -45,10 +45,10 @@ class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer /// @param[in] name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple". /// @param[in] properties All RCSS properties associated with the decorator. /// @return The decorator if it was instanced successful, nullptr if an error occured. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_image_src; + Rml::PropertyId id_image_src; }; #endif diff --git a/Samples/luainvaders/src/DecoratorInstancerStarfield.cpp b/Samples/luainvaders/src/DecoratorInstancerStarfield.cpp index 17ac61d66..bb1b65426 100644 --- a/Samples/luainvaders/src/DecoratorInstancerStarfield.cpp +++ b/Samples/luainvaders/src/DecoratorInstancerStarfield.cpp @@ -47,16 +47,16 @@ DecoratorInstancerStarfield::~DecoratorInstancerStarfield() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerStarfield::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - int num_layers = Rml::Core::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get< float >()); - Rml::Core::Colourb top_colour = properties.GetProperty(id_top_colour)->Get< Rml::Core::Colourb >(); - Rml::Core::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get< Rml::Core::Colourb >(); + int num_layers = Rml::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get< float >()); + Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get< Rml::Colourb >(); + Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get< Rml::Colourb >(); float top_speed = properties.GetProperty(id_top_speed)->Get< float >(); float bottom_speed = properties.GetProperty(id_bottom_speed)->Get< float >(); - int top_density = Rml::Core::Math::RealToInteger(properties.GetProperty(id_top_density)->Get< float >()); - int bottom_density = Rml::Core::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get< float >()); + int top_density = Rml::Math::RealToInteger(properties.GetProperty(id_top_density)->Get< float >()); + int bottom_density = Rml::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get< float >()); auto decorator = std::make_shared(); if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density)) diff --git a/Samples/luainvaders/src/DecoratorInstancerStarfield.h b/Samples/luainvaders/src/DecoratorInstancerStarfield.h index 90cce230a..ad202caac 100644 --- a/Samples/luainvaders/src/DecoratorInstancerStarfield.h +++ b/Samples/luainvaders/src/DecoratorInstancerStarfield.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDECORATORINSTANCERSTARFIELD_H -#define RMLUIINVADERSDECORATORINSTANCERSTARFIELD_H +#ifndef RMLUI_LUAINVADERS_DECORATORINSTANCERSTARFIELD_H +#define RMLUI_LUAINVADERS_DECORATORINSTANCERSTARFIELD_H #include #include "DecoratorStarfield.h" @@ -36,7 +36,7 @@ @author Robert Curry */ -class DecoratorInstancerStarfield : public Rml::Core::DecoratorInstancer +class DecoratorInstancerStarfield : public Rml::DecoratorInstancer { public: DecoratorInstancerStarfield(); @@ -46,10 +46,10 @@ class DecoratorInstancerStarfield : public Rml::Core::DecoratorInstancer /// @param name The type of decorator desired. For example, "background-decorator: simple;" is declared as type "simple". /// @param properties All RCSS properties associated with the decorator. /// @return The decorator if it was instanced successful, nullptr if an error occured. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_num_layers, id_top_colour, id_bottom_colour, id_top_speed, id_bottom_speed, id_top_density, id_bottom_density; + Rml::PropertyId id_num_layers, id_top_colour, id_bottom_colour, id_top_speed, id_bottom_speed, id_top_density, id_bottom_density; }; #endif diff --git a/Samples/luainvaders/src/DecoratorStarfield.cpp b/Samples/luainvaders/src/DecoratorStarfield.cpp index 38b9dce47..1899e80a3 100644 --- a/Samples/luainvaders/src/DecoratorStarfield.cpp +++ b/Samples/luainvaders/src/DecoratorStarfield.cpp @@ -39,7 +39,7 @@ DecoratorStarfield::~DecoratorStarfield() { } -bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Core::Colourb& _top_colour, const Rml::Core::Colourb& _bottom_colour, float _top_speed, float _bottom_speed, int _top_density, int _bottom_density) +bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Colourb& _top_colour, const Rml::Colourb& _bottom_colour, float _top_speed, float _bottom_speed, int _top_density, int _bottom_density) { num_layers = _num_layers; top_colour = _top_colour; @@ -53,7 +53,7 @@ bool DecoratorStarfield::Initialise(int _num_layers, const Rml::Core::Colourb& _ } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Core::Element* element) const +Rml::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Element* element) const { StarField* star_field = new StarField(); @@ -63,40 +63,40 @@ Rml::Core::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Core { float layer_depth = i / (float)num_layers; - int density = Rml::Core::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth))); + int density = Rml::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth))); star_field->star_layers[i].stars.resize(density); - Rml::Core::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth)); + Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth)); star_field->star_layers[i].colour = colour; float speed = (top_speed * layer_depth) + (bottom_speed * (1.0f - layer_depth)); star_field->star_layers[i].speed = speed; - star_field->dimensions = element->GetBox().GetSize(Rml::Core::Box::PADDING); + star_field->dimensions = element->GetBox().GetSize(Rml::Box::PADDING); if (star_field->dimensions.x > 0) { for (int j = 0; j < density; j++) { - star_field->star_layers[i].stars[j].x = (float) Rml::Core::Math::RandomReal(star_field->dimensions.x); - star_field->star_layers[i].stars[j].y = (float) Rml::Core::Math::RandomReal(star_field->dimensions.y); + star_field->star_layers[i].stars[j].x = (float) Rml::Math::RandomReal(star_field->dimensions.x); + star_field->star_layers[i].stars[j].y = (float) Rml::Math::RandomReal(star_field->dimensions.y); } } star_field->last_update = Shell::GetElapsedTime(); } - return (Rml::Core::DecoratorDataHandle)star_field; + return (Rml::DecoratorDataHandle)star_field; } // Called to release element data generated by this decorator. -void DecoratorStarfield::ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const +void DecoratorStarfield::ReleaseElementData(Rml::DecoratorDataHandle element_data) const { delete (StarField*)element_data; } // Called to render the decorator on an element. -void DecoratorStarfield::RenderElement(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element), Rml::Core::DecoratorDataHandle element_data) const +void DecoratorStarfield::RenderElement(Rml::Element* RMLUI_UNUSED_PARAMETER(element), Rml::DecoratorDataHandle element_data) const { RMLUI_UNUSED(element); @@ -140,7 +140,7 @@ void DecoratorStarfield::StarField::Update() if (star_layers[i].stars[j].y > dimensions.y) { star_layers[i].stars[j].y = 0; - star_layers[i].stars[j].x = Rml::Core::Math::RandomReal(dimensions.x); + star_layers[i].stars[j].x = Rml::Math::RandomReal(dimensions.x); } } } diff --git a/Samples/luainvaders/src/DecoratorStarfield.h b/Samples/luainvaders/src/DecoratorStarfield.h index a66e9bc58..d3d13e261 100644 --- a/Samples/luainvaders/src/DecoratorStarfield.h +++ b/Samples/luainvaders/src/DecoratorStarfield.h @@ -26,36 +26,36 @@ * */ -#ifndef RMLUIINVADERSDECORATORSTARFIELD_H -#define RMLUIINVADERSDECORATORSTARFIELD_H +#ifndef RMLUI_LUAINVADERS_DECORATORSTARFIELD_H +#define RMLUI_LUAINVADERS_DECORATORSTARFIELD_H #include #include -class DecoratorStarfield : public Rml::Core::Decorator +class DecoratorStarfield : public Rml::Decorator { public: virtual ~DecoratorStarfield(); - bool Initialise(int num_layers, const Rml::Core::Colourb& top_colour, const Rml::Core::Colourb& bottom_colour, float top_speed, float bottom_speed, int top_density, int bottom_density); + bool Initialise(int num_layers, const Rml::Colourb& top_colour, const Rml::Colourb& bottom_colour, float top_speed, float bottom_speed, int top_density, int bottom_density); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param[in] element The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param[in] element_data The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param[in] element The element to render the decorator on. /// @param[in] element_data The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int num_layers; - Rml::Core::Colourb top_colour; - Rml::Core::Colourb bottom_colour; + Rml::Colourb top_colour; + Rml::Colourb bottom_colour; float top_speed; float bottom_speed; int top_density; @@ -63,9 +63,9 @@ class DecoratorStarfield : public Rml::Core::Decorator struct StarLayer { - typedef std::vector< Rml::Core::Vector2f > StarList; + typedef std::vector< Rml::Vector2f > StarList; StarList stars; - Rml::Core::Colourb colour; + Rml::Colourb colour; float speed; }; @@ -73,7 +73,7 @@ class DecoratorStarfield : public Rml::Core::Decorator { void Update(); double last_update; - Rml::Core::Vector2f dimensions; + Rml::Vector2f dimensions; typedef std::vector< StarLayer > StarLayerList; StarLayerList star_layers; diff --git a/Samples/luainvaders/src/Defender.cpp b/Samples/luainvaders/src/Defender.cpp index 6617a3246..802467ac0 100644 --- a/Samples/luainvaders/src/Defender.cpp +++ b/Samples/luainvaders/src/Defender.cpp @@ -42,9 +42,9 @@ static const float BULLET_SPEED = 15; static const int SPRITE_WIDTH = 64; static const float RESPAWN_TIME = 1.0f; -Sprite defender_sprite(Rml::Core::Vector2f(60, 31), Rml::Core::Vector2f(0, 0.5), Rml::Core::Vector2f(0.23437500, 0.98437500)); -Sprite bullet_sprite(Rml::Core::Vector2f(4, 20), Rml::Core::Vector2f(0.4921875, 0.515625), Rml::Core::Vector2f(0.5078125, 0.828125)); -Sprite explosion_sprite(Rml::Core::Vector2f(52, 28), Rml::Core::Vector2f(0.71484375f, 0.51562500f), Rml::Core::Vector2f(0.91796875f, 0.95312500f)); +Sprite defender_sprite(Rml::Vector2f(60, 31), Rml::Vector2f(0, 0.5), Rml::Vector2f(0.23437500, 0.98437500)); +Sprite bullet_sprite(Rml::Vector2f(4, 20), Rml::Vector2f(0.4921875, 0.515625), Rml::Vector2f(0.5078125, 0.828125)); +Sprite explosion_sprite(Rml::Vector2f(52, 28), Rml::Vector2f(0.71484375f, 0.51562500f), Rml::Vector2f(0.91796875f, 0.95312500f)); Defender::Defender(Game* _game) { @@ -69,7 +69,7 @@ void Defender::Update() if (dt < UPDATE_FREQ) return; - dt = Rml::Core::Math::Min(dt, 0.1f); + dt = Rml::Math::Min(dt, 0.1f); defender_frame_start = Shell::GetElapsedTime(); @@ -109,12 +109,12 @@ void Defender::Render() // Render our sprite if rendering is enabled if (render) - defender_sprite.Render(Rml::Core::Vector2f(position.x, position.y)); + defender_sprite.Render(Rml::Vector2f(position.x, position.y)); // Update the bullet, doing collision detection if (bullet_in_flight) { - bullet_sprite.Render(Rml::Core::Vector2f(bullet_position.x, bullet_position.y)); + bullet_sprite.Render(Rml::Vector2f(bullet_position.x, bullet_position.y)); // Check if we hit the shields for (int i = 0; i < game->GetNumShields(); i++) @@ -158,12 +158,12 @@ void Defender::Fire() { if (!bullet_in_flight) { - bullet_position = position + Rml::Core::Vector2f((SPRITE_WIDTH/2) - 4, 0); + bullet_position = position + Rml::Vector2f((SPRITE_WIDTH/2) - 4, 0); bullet_in_flight = true; } } -bool Defender::CheckHit(const Rml::Core::Vector2f& check_position) +bool Defender::CheckHit(const Rml::Vector2f& check_position) { float sprite_width = defender_sprite.dimensions.x; float sprite_height = defender_sprite.dimensions.y; diff --git a/Samples/luainvaders/src/Defender.h b/Samples/luainvaders/src/Defender.h index 1dc6e46eb..5daa830a7 100644 --- a/Samples/luainvaders/src/Defender.h +++ b/Samples/luainvaders/src/Defender.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSDEFENDER_H -#define RMLUIINVADERSDEFENDER_H +#ifndef RMLUI_LUAINVADERS_DEFENDER_H +#define RMLUI_LUAINVADERS_DEFENDER_H #include @@ -58,16 +58,16 @@ class Defender void Fire(); /// Check if an object at the given position would hit the defender. - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); private: Game* game; - Rml::Core::Vector2f position; + Rml::Vector2f position; float move_direction; bool bullet_in_flight; - Rml::Core::Vector2f bullet_position; + Rml::Vector2f bullet_position; double defender_frame_start; double respawn_start; diff --git a/Samples/luainvaders/src/ElementGame.cpp b/Samples/luainvaders/src/ElementGame.cpp index 5034b5d01..643937940 100644 --- a/Samples/luainvaders/src/ElementGame.cpp +++ b/Samples/luainvaders/src/ElementGame.cpp @@ -33,7 +33,7 @@ #include "Defender.h" #include "Game.h" -ElementGame::ElementGame(const Rml::Core::String& tag) : Rml::Core::Element(tag) +ElementGame::ElementGame(const Rml::String& tag) : Rml::Element(tag) { game = new Game(); } @@ -44,34 +44,34 @@ ElementGame::~ElementGame() } // Intercepts and handles key events. -void ElementGame::ProcessEvent(Rml::Core::Event& event) +void ElementGame::ProcessEvent(Rml::Event& event) { - if (event == Rml::Core::EventId::Keydown || - event == Rml::Core::EventId::Keyup) + if (event == Rml::EventId::Keydown || + event == Rml::EventId::Keyup) { - bool key_down = (event == Rml::Core::EventId::Keydown); - Rml::Core::Input::KeyIdentifier key_identifier = (Rml::Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + bool key_down = (event == Rml::EventId::Keydown); + Rml::Input::KeyIdentifier key_identifier = (Rml::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); // Process left and right keys if (key_down) { - if (key_identifier == Rml::Core::Input::KI_LEFT) + if (key_identifier == Rml::Input::KI_LEFT) game->GetDefender()->StartMove(-1.0f); - if (key_identifier == Rml::Core::Input::KI_RIGHT) + if (key_identifier == Rml::Input::KI_RIGHT) game->GetDefender()->StartMove(1.0f); - if (key_identifier == Rml::Core::Input::KI_SPACE) + if (key_identifier == Rml::Input::KI_SPACE) game->GetDefender()->Fire(); } else if (!key_down) { - if (key_identifier == Rml::Core::Input::KI_LEFT) + if (key_identifier == Rml::Input::KI_LEFT) game->GetDefender()->StopMove(-1.0f); - if (key_identifier == Rml::Core::Input::KI_RIGHT) + if (key_identifier == Rml::Input::KI_RIGHT) game->GetDefender()->StopMove(1.0f); } } - if (event == Rml::Core::EventId::Load) + if (event == Rml::EventId::Load) { game->Initialise(); } @@ -83,7 +83,7 @@ void ElementGame::OnUpdate() game->Update(); if (game->IsGameOver()) - DispatchEvent("gameover", Rml::Core::Dictionary()); + DispatchEvent("gameover", Rml::Dictionary()); } // Renders the game. @@ -92,14 +92,14 @@ void ElementGame::OnRender() game->Render(); } -void ElementGame::OnChildAdd(Rml::Core::Element* element) +void ElementGame::OnChildAdd(Rml::Element* element) { - Rml::Core::Element::OnChildAdd(element); + Rml::Element::OnChildAdd(element); if (element == this) { - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Load, this); - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Keydown, this); - GetOwnerDocument()->AddEventListener(Rml::Core::EventId::Keyup, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Load, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Keydown, this); + GetOwnerDocument()->AddEventListener(Rml::EventId::Keyup, this); } } diff --git a/Samples/luainvaders/src/ElementGame.h b/Samples/luainvaders/src/ElementGame.h index d30a3f643..98603a1aa 100644 --- a/Samples/luainvaders/src/ElementGame.h +++ b/Samples/luainvaders/src/ElementGame.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSELEMENTGAME_H -#define RMLUIINVADERSELEMENTGAME_H +#ifndef RMLUI_LUAINVADERS_ELEMENTGAME_H +#define RMLUI_LUAINVADERS_ELEMENTGAME_H #include #include @@ -38,19 +38,19 @@ class Game; @author Peter Curry */ -class ElementGame : public Rml::Core::Element, public Rml::Core::EventListener +class ElementGame : public Rml::Element, public Rml::EventListener { public: - ElementGame(const Rml::Core::String& tag); + ElementGame(const Rml::String& tag); virtual ~ElementGame(); /// Intercepts and handles key events. - void ProcessEvent(Rml::Core::Event& event) override; + void ProcessEvent(Rml::Event& event) override; /// Receive notifications when child elements are added /// This will only get called when we're added to the tree, /// which allows us to bind to onload - void OnChildAdd(Rml::Core::Element* element) override; + void OnChildAdd(Rml::Element* element) override; protected: /// Updates the game. diff --git a/Samples/luainvaders/src/ElementGameInstancer.cpp b/Samples/luainvaders/src/ElementGameInstancer.cpp index 8e7ba73b4..e82111998 100644 --- a/Samples/luainvaders/src/ElementGameInstancer.cpp +++ b/Samples/luainvaders/src/ElementGameInstancer.cpp @@ -6,15 +6,15 @@ ElementGameInstancer::~ElementGameInstancer() } // Instances an element given the tag name and attributes -Rml::Core::ElementPtr ElementGameInstancer::InstanceElement(Rml::Core::Element* /*parent*/, const Rml::Core::String& tag, const Rml::Core::XMLAttributes& /*attributes*/) +Rml::ElementPtr ElementGameInstancer::InstanceElement(Rml::Element* /*parent*/, const Rml::String& tag, const Rml::XMLAttributes& /*attributes*/) { - return Rml::Core::ElementPtr(new ElementGame(tag)); + return Rml::ElementPtr(new ElementGame(tag)); } // Releases the given element -void ElementGameInstancer::ReleaseElement(Rml::Core::Element* element) +void ElementGameInstancer::ReleaseElement(Rml::Element* element) { delete element; } diff --git a/Samples/luainvaders/src/ElementGameInstancer.h b/Samples/luainvaders/src/ElementGameInstancer.h index bbe77fa10..7021bd837 100644 --- a/Samples/luainvaders/src/ElementGameInstancer.h +++ b/Samples/luainvaders/src/ElementGameInstancer.h @@ -1,8 +1,9 @@ -#ifndef ELEMENTGAMEINSTANCER_H -#define ELEMENTGAMEINSTANCER_H +#ifndef RMLUI_LUAINVADERS_ELEMENTGAMEINSTANCER_H +#define RMLUI_LUAINVADERS_ELEMENTGAMEINSTANCER_H + #include -class ElementGameInstancer : public Rml::Core::ElementInstancer +class ElementGameInstancer : public Rml::ElementInstancer { public: virtual ~ElementGameInstancer(); @@ -10,11 +11,11 @@ class ElementGameInstancer : public Rml::Core::ElementInstancer /// Instances an element given the tag name and attributes /// @param tag Name of the element to instance /// @param attributes vector of name value pairs - Rml::Core::ElementPtr InstanceElement(Rml::Core::Element* parent, const Rml::Core::String& tag, const Rml::Core::XMLAttributes& attributes) override; + Rml::ElementPtr InstanceElement(Rml::Element* parent, const Rml::String& tag, const Rml::XMLAttributes& attributes) override; /// Releases the given element /// @param element to release - void ReleaseElement(Rml::Core::Element* element) override; + void ReleaseElement(Rml::Element* element) override; }; #endif diff --git a/Samples/luainvaders/src/Game.cpp b/Samples/luainvaders/src/Game.cpp index 3d7b68053..e06ad1248 100644 --- a/Samples/luainvaders/src/Game.cpp +++ b/Samples/luainvaders/src/Game.cpp @@ -63,7 +63,7 @@ const int SHIELD_START_X = 176; const int SHIELD_START_Y = 600; // The game's element context (declared in main.cpp). -extern Rml::Core::Context* context; +extern Rml::Context* context; Game::Game() { @@ -81,8 +81,8 @@ Game::Game() shields[i] = nullptr; // Use the OpenGL render interface to load our texture. - Rml::Core::Vector2i texture_dimensions; - Rml::Core::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "luainvaders/data/invaders.tga"); + Rml::Vector2i texture_dimensions; + Rml::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "luainvaders/data/invaders.tga"); defender = new Defender(this); } @@ -225,9 +225,9 @@ void Game::SetScore(int score) { GameDetails::SetScore(score); - Rml::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("score"); + Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("score"); if (score_element != nullptr) - score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", score).c_str()); + score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str()); // Update the high score if we've beaten it. if (score > HighScores::GetHighScore()) @@ -237,27 +237,27 @@ void Game::SetScore(int score) // Sets the player's high-score. void Game::SetHighScore(int score) { - Rml::Core::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore"); + Rml::Element* high_score_element = context->GetDocument("game_window")->GetElementById("hiscore"); if (high_score_element != nullptr) - high_score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", score).c_str()); + high_score_element->SetInnerRML(Rml::CreateString(128, "%d", score).c_str()); } void Game::SetLives(int lives) { defender_lives = lives; - Rml::Core::Element* score_element = context->GetDocument("game_window")->GetElementById("lives"); + Rml::Element* score_element = context->GetDocument("game_window")->GetElementById("lives"); if (score_element != nullptr) - score_element->SetInnerRML(Rml::Core::CreateString(128, "%d", defender_lives).c_str()); + score_element->SetInnerRML(Rml::CreateString(128, "%d", defender_lives).c_str()); } void Game::SetWave(int wave) { GameDetails::SetWave(wave); - Rml::Core::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves"); + Rml::Element* waves_element = context->GetDocument("game_window")->GetElementById("waves"); if (waves_element != nullptr) - waves_element->SetInnerRML(Rml::Core::CreateString(128, "%d", wave).c_str()); + waves_element->SetInnerRML(Rml::CreateString(128, "%d", wave).c_str()); } void Game::RemoveLife() @@ -278,14 +278,14 @@ bool Game::IsGameOver() const return game_over; } -const Rml::Core::Vector2f Game::GetWindowDimensions() +const Rml::Vector2f Game::GetWindowDimensions() { - return Rml::Core::Vector2f((float) WINDOW_WIDTH, (float) WINDOW_HEIGHT); + return Rml::Vector2f((float) WINDOW_WIDTH, (float) WINDOW_HEIGHT); } void Game::MoveInvaders() { - Rml::Core::Vector2f new_positions[NUM_INVADERS]; + Rml::Vector2f new_positions[NUM_INVADERS]; // We loop through all invaders, calculating their new positions, if any of them go over the screen bounds, // then we switch direction, move the invaders down and start at 0 again @@ -308,7 +308,7 @@ void Game::MoveInvaders() if (invaders[j]->GetState() == Invader::DEAD) continue; - Rml::Core::Vector2f position = invaders[j]->GetPosition(); + Rml::Vector2f position = invaders[j]->GetPosition(); position.y += INVADER_SPACING_Y; invaders[j]->SetPosition(position); } @@ -355,7 +355,7 @@ void Game::OnGameOver() void Game::InitialiseShields() { - Rml::Core::Vector2f shield_array_start_position((float) SHIELD_START_X, (float) SHIELD_START_Y); + Rml::Vector2f shield_array_start_position((float) SHIELD_START_X, (float) SHIELD_START_Y); for (int x = 0; x < NUM_SHIELD_ARRAYS; x++) { @@ -371,7 +371,7 @@ void Game::InitialiseShields() } shields[(x * NUM_SHIELDS_PER_ARRAY) + i] = new Shield(this, type); - shields[(x * NUM_SHIELDS_PER_ARRAY) + i]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * i, 0)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + i]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * i, 0)); } // Middle row (row of 4) @@ -387,15 +387,15 @@ void Game::InitialiseShields() } shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i] = new Shield(this, type); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * i, (float) SHIELD_SIZE)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 4 + i]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * i, (float) SHIELD_SIZE)); } // Bottom row (2, one on each end) shields[(x * NUM_SHIELDS_PER_ARRAY) + 8] = new Shield(this, Shield::REGULAR); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 8]->SetPosition(shield_array_start_position + Rml::Core::Vector2f(0, (float) SHIELD_SIZE * 2)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 8]->SetPosition(shield_array_start_position + Rml::Vector2f(0, (float) SHIELD_SIZE * 2)); shields[(x * NUM_SHIELDS_PER_ARRAY) + 9] = new Shield(this, Shield::REGULAR); - shields[(x * NUM_SHIELDS_PER_ARRAY) + 9]->SetPosition(shield_array_start_position + Rml::Core::Vector2f((float) SHIELD_SIZE * 3, (float) SHIELD_SIZE * 2)); + shields[(x * NUM_SHIELDS_PER_ARRAY) + 9]->SetPosition(shield_array_start_position + Rml::Vector2f((float) SHIELD_SIZE * 3, (float) SHIELD_SIZE * 2)); shield_array_start_position.x += SHIELD_SPACING_X; } @@ -420,7 +420,7 @@ void Game::InitialiseWave() } // Determine position of top left invader - Rml::Core::Vector2f invader_position((float) (WINDOW_WIDTH - (NUM_INVADERS_PER_ROW * INVADER_SPACING_X)) / 2, (float) (INVADER_START_Y + (y * INVADER_SPACING_Y))); + Rml::Vector2f invader_position((float) (WINDOW_WIDTH - (NUM_INVADERS_PER_ROW * INVADER_SPACING_X)) / 2, (float) (INVADER_START_Y + (y * INVADER_SPACING_Y))); for (int x = 0; x < NUM_INVADERS_PER_ROW; x++) { diff --git a/Samples/luainvaders/src/Game.h b/Samples/luainvaders/src/Game.h index 5d7652b5f..93fcffddf 100644 --- a/Samples/luainvaders/src/Game.h +++ b/Samples/luainvaders/src/Game.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSGAME_H -#define RMLUIINVADERSGAME_H +#ifndef RMLUI_LUAINVADERS_GAME_H +#define RMLUI_LUAINVADERS_GAME_H #include #include @@ -91,7 +91,7 @@ class Game bool IsGameOver() const; /// Get the dimensions of the game window. - const Rml::Core::Vector2f GetWindowDimensions(); + const Rml::Vector2f GetWindowDimensions(); private: @@ -119,7 +119,7 @@ class Game Shield** shields; // Texture that contains the sprites - Rml::Core::TextureHandle texture; + Rml::TextureHandle texture; void InitialiseShields(); void InitialiseWave(); diff --git a/Samples/luainvaders/src/GameDetails.cpp b/Samples/luainvaders/src/GameDetails.cpp index 923653ebd..508ff081c 100644 --- a/Samples/luainvaders/src/GameDetails.cpp +++ b/Samples/luainvaders/src/GameDetails.cpp @@ -29,7 +29,7 @@ #include "GameDetails.h" static GameDetails::Difficulty difficulty = GameDetails::EASY; -static Rml::Core::Colourb colour = Rml::Core::Colourb(255, 0, 0); +static Rml::Colourb colour = Rml::Colourb(255, 0, 0); static int score = -1; static int wave = 0; static bool paused = false; @@ -59,13 +59,13 @@ GameDetails::Difficulty GameDetails::GetDifficulty() } // Sets the colour of the player's ship. -void GameDetails::SetDefenderColour(const Rml::Core::Colourb& _colour) +void GameDetails::SetDefenderColour(const Rml::Colourb& _colour) { colour = _colour; } // Returns the player's ship colour. -const Rml::Core::Colourb& GameDetails::GetDefenderColour() +const Rml::Colourb& GameDetails::GetDefenderColour() { return colour; } diff --git a/Samples/luainvaders/src/GameDetails.h b/Samples/luainvaders/src/GameDetails.h index f45bd2c3a..806a8eea4 100644 --- a/Samples/luainvaders/src/GameDetails.h +++ b/Samples/luainvaders/src/GameDetails.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSGAMEDETAILS_H -#define RMLUIINVADERSGAMEDETAILS_H +#ifndef RMLUI_LUAINVADERS_GAMEDETAILS_H +#define RMLUI_LUAINVADERS_GAMEDETAILS_H #include @@ -49,10 +49,10 @@ class GameDetails /// Sets the colour of the player's ship. /// @param[in] colour The new ship colour. - static void SetDefenderColour(const Rml::Core::Colourb& colour); + static void SetDefenderColour(const Rml::Colourb& colour); /// Returns the player's ship colour. /// @return The colour of the player's ship. - static const Rml::Core::Colourb& GetDefenderColour(); + static const Rml::Colourb& GetDefenderColour(); /// Sets the score the player achieved in the last game. /// @param[in] score The player's score. diff --git a/Samples/luainvaders/src/HighScores.cpp b/Samples/luainvaders/src/HighScores.cpp index 88c313fc8..915aa34c7 100644 --- a/Samples/luainvaders/src/HighScores.cpp +++ b/Samples/luainvaders/src/HighScores.cpp @@ -32,7 +32,7 @@ HighScores* HighScores::instance = nullptr; -HighScores::HighScores() : Rml::Controls::DataSource("high_scores") +HighScores::HighScores() : Rml::DataSource("high_scores") { RMLUI_ASSERT(instance == nullptr); instance = this; @@ -64,7 +64,7 @@ void HighScores::Shutdown() delete instance; } -void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) +void HighScores::GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns) { if (table == "scores") { @@ -76,27 +76,27 @@ void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& tab } else if (columns[i] == "name_required") { - row.push_back(Rml::Core::CreateString(4, "%d", scores[row_index].name_required)); + row.push_back(Rml::CreateString(4, "%d", scores[row_index].name_required)); } else if (columns[i] == "score") { - row.push_back(Rml::Core::CreateString(32, "%d", scores[row_index].score)); + row.push_back(Rml::CreateString(32, "%d", scores[row_index].score)); } else if (columns[i] == "colour") { - Rml::Core::String colour_string; - Rml::Core::TypeConverter< Rml::Core::Colourb, Rml::Core::String >::Convert(scores[row_index].colour, colour_string); + Rml::String colour_string; + Rml::TypeConverter< Rml::Colourb, Rml::String >::Convert(scores[row_index].colour, colour_string); row.push_back(colour_string); } else if (columns[i] == "wave") { - row.push_back(Rml::Core::CreateString(8, "%d", scores[row_index].wave)); + row.push_back(Rml::CreateString(8, "%d", scores[row_index].wave)); } } } } -int HighScores::GetNumRows(const Rml::Core::String& table) +int HighScores::GetNumRows(const Rml::String& table) { if (table == "scores") { @@ -124,18 +124,18 @@ int HighScores::GetHighScore() return instance->scores[0].score; } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score) { instance->SubmitScore(name, colour, wave, score, false); } -void HighScores::SubmitScore(const Rml::Core::Colourb& colour, int wave, int score) +void HighScores::SubmitScore(const Rml::Colourb& colour, int wave, int score) { instance->SubmitScore("", colour, wave, score, true); } // Sets the name of the last player to submit their score. -void HighScores::SubmitName(const Rml::Core::String& name) +void HighScores::SubmitName(const Rml::String& name) { for (int i = 0; i < instance->GetNumRows("scores"); i++) { @@ -148,7 +148,7 @@ void HighScores::SubmitName(const Rml::Core::String& name) } } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, bool name_required) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, bool name_required) { for (int i = 0; i < NUM_SCORES; i++) { @@ -196,17 +196,17 @@ void HighScores::LoadScores() char buffer[1024]; while (fgets(buffer, 1024, scores_file)) { - Rml::Core::StringList score_parts; - Rml::Core::StringUtilities::ExpandString(score_parts, Rml::Core::String(buffer), '\t'); + Rml::StringList score_parts; + Rml::StringUtilities::ExpandString(score_parts, Rml::String(buffer), '\t'); if (score_parts.size() == 4) { - Rml::Core::Colourb colour; + Rml::Colourb colour; int wave; int score; - if (Rml::Core::TypeConverter< Rml::Core::String , Rml::Core::Colourb >::Convert(score_parts[1], colour) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[2], wave) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[3], score)) + if (Rml::TypeConverter< Rml::String , Rml::Colourb >::Convert(score_parts[1], colour) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[2], wave) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[3], score)) { SubmitScore(score_parts[0], colour, wave, score); } @@ -225,10 +225,10 @@ void HighScores::SaveScores() { for (int i = 0; i < GetNumRows("scores"); i++) { - Rml::Core::String colour_string; - Rml::Core::TypeConverter< Rml::Core::Colourb, Rml::Core::String >::Convert(scores[i].colour, colour_string); + Rml::String colour_string; + Rml::TypeConverter< Rml::Colourb, Rml::String >::Convert(scores[i].colour, colour_string); - Rml::Core::String score = Rml::Core::CreateString(1024, "%s\t%s\t%d\t%d\n", scores[i].name.c_str(), colour_string.c_str(), scores[i].wave, scores[i].score); + Rml::String score = Rml::CreateString(1024, "%s\t%s\t%d\t%d\n", scores[i].name.c_str(), colour_string.c_str(), scores[i].wave, scores[i].score); fputs(score.c_str(), scores_file); } diff --git a/Samples/luainvaders/src/HighScores.h b/Samples/luainvaders/src/HighScores.h index d75b13a79..7f6eaa900 100644 --- a/Samples/luainvaders/src/HighScores.h +++ b/Samples/luainvaders/src/HighScores.h @@ -26,32 +26,32 @@ * */ -#ifndef RMLUIINVADERSHIGHSCORES_H -#define RMLUIINVADERSHIGHSCORES_H +#ifndef RMLUI_LUAINVADERS_HIGHSCORES_H +#define RMLUI_LUAINVADERS_HIGHSCORES_H -#include +#include #include const int NUM_SCORES = 10; -class HighScores : public Rml::Controls::DataSource +class HighScores : public Rml::DataSource { public: static void Initialise(); static void Shutdown(); - void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns); - int GetNumRows(const Rml::Core::String& table); + void GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns); + int GetNumRows(const Rml::String& table); static int GetHighScore(); /// Two functions to add a score to the chart. /// Adds a full score, including a name. This won't prompt the user to enter their name. - static void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score); + static void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score); /// Adds a score, and causes an input field to appear to request the user for their name. - static void SubmitScore(const Rml::Core::Colourb& colour, int wave, int score); + static void SubmitScore(const Rml::Colourb& colour, int wave, int score); /// Sets the name of the last player to submit their score. - static void SubmitName(const Rml::Core::String& name); + static void SubmitName(const Rml::String& name); private: HighScores(); @@ -59,15 +59,15 @@ class HighScores : public Rml::Controls::DataSource static HighScores* instance; - void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, bool name_required); + void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, bool name_required); void LoadScores(); void SaveScores(); struct Score { - Rml::Core::String name; + Rml::String name; bool name_required; - Rml::Core::Colourb colour; + Rml::Colourb colour; int score; int wave; }; diff --git a/Samples/luainvaders/src/Invader.cpp b/Samples/luainvaders/src/Invader.cpp index 0794bca65..8070150f0 100644 --- a/Samples/luainvaders/src/Invader.cpp +++ b/Samples/luainvaders/src/Invader.cpp @@ -42,34 +42,34 @@ static const float BOMB_MISSILE_SPEED = 7; static const float BOMB_PROBABILITY_EASY = 0.002f; static const float BOMB_PROBABILITY_HARD = 0.005f; static const float EXPLOSION_TIME = 0.25; -static const Rml::Core::Colourb MOTHERSHIP_COLOUR = Rml::Core::Colourb(255, 0, 0, 255); +static const Rml::Colourb MOTHERSHIP_COLOUR = Rml::Colourb(255, 0, 0, 255); Sprite invader_sprites[] = { // Rank 1 - Sprite(Rml::Core::Vector2f(48, 32), Rml::Core::Vector2f(0.609375f, 0), Rml::Core::Vector2f(0.796875f, 0.5f)), - Sprite(Rml::Core::Vector2f(48, 32), Rml::Core::Vector2f(0.80078125f, 0), Rml::Core::Vector2f(0.98828125f, 0.5f)), + Sprite(Rml::Vector2f(48, 32), Rml::Vector2f(0.609375f, 0), Rml::Vector2f(0.796875f, 0.5f)), + Sprite(Rml::Vector2f(48, 32), Rml::Vector2f(0.80078125f, 0), Rml::Vector2f(0.98828125f, 0.5f)), // Rank 2 - Sprite(Rml::Core::Vector2f(44, 32), Rml::Core::Vector2f(0.2578125f, 0), Rml::Core::Vector2f(0.4296875f, 0.5f)), - Sprite(Rml::Core::Vector2f(44, 32), Rml::Core::Vector2f(0.43359375f, 0), Rml::Core::Vector2f(0.60546875f, 0.5f)), + Sprite(Rml::Vector2f(44, 32), Rml::Vector2f(0.2578125f, 0), Rml::Vector2f(0.4296875f, 0.5f)), + Sprite(Rml::Vector2f(44, 32), Rml::Vector2f(0.43359375f, 0), Rml::Vector2f(0.60546875f, 0.5f)), // Rank 3 - Sprite(Rml::Core::Vector2f(32, 32), Rml::Core::Vector2f(0, 0), Rml::Core::Vector2f(0.125f, 0.5f)), - Sprite(Rml::Core::Vector2f(32, 32), Rml::Core::Vector2f(0.12890625f, 0), Rml::Core::Vector2f(0.25390625f, 0.5f)), + Sprite(Rml::Vector2f(32, 32), Rml::Vector2f(0, 0), Rml::Vector2f(0.125f, 0.5f)), + Sprite(Rml::Vector2f(32, 32), Rml::Vector2f(0.12890625f, 0), Rml::Vector2f(0.25390625f, 0.5f)), // Mothership - Sprite(Rml::Core::Vector2f(64, 28), Rml::Core::Vector2f(0.23828125f, 0.515625f), Rml::Core::Vector2f(0.48828125f, 0.953125f)), + Sprite(Rml::Vector2f(64, 28), Rml::Vector2f(0.23828125f, 0.515625f), Rml::Vector2f(0.48828125f, 0.953125f)), // Explosion - Sprite(Rml::Core::Vector2f(52, 28), Rml::Core::Vector2f(0.71484375f, 0.51562500f), Rml::Core::Vector2f(0.91796875f, 0.95312500f)) + Sprite(Rml::Vector2f(52, 28), Rml::Vector2f(0.71484375f, 0.51562500f), Rml::Vector2f(0.91796875f, 0.95312500f)) }; Sprite bomb_sprites[] = { // Ray - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.51171875f, 0.51562500f), Rml::Core::Vector2f(0.55859375f, 0.82812500f)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.56250000, 0.51562500), Rml::Core::Vector2f(0.60937500, 0.82812500)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.61328125, 0.51562500), Rml::Core::Vector2f(0.66015625, 0.82812500)), - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.66406250, 0.51562500), Rml::Core::Vector2f(0.71093750, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.51171875f, 0.51562500f), Rml::Vector2f(0.55859375f, 0.82812500f)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.56250000, 0.51562500), Rml::Vector2f(0.60937500, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.61328125, 0.51562500), Rml::Vector2f(0.66015625, 0.82812500)), + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.66406250, 0.51562500), Rml::Vector2f(0.71093750, 0.82812500)), // Missile - Sprite(Rml::Core::Vector2f(12, 20), Rml::Core::Vector2f(0.92578125, 0.51562500), Rml::Core::Vector2f(0.97265625, 0.82812500)) + Sprite(Rml::Vector2f(12, 20), Rml::Vector2f(0.92578125, 0.51562500), Rml::Vector2f(0.97265625, 0.82812500)) }; Invader::Invader(Game* _game, InvaderType _type, int _index) : position(0,0) @@ -94,12 +94,12 @@ Invader::~Invader() { } -void Invader::SetPosition(const Rml::Core::Vector2f& _position) +void Invader::SetPosition(const Rml::Vector2f& _position) { position = _position; } -const Rml::Core::Vector2f& Invader::GetPosition() const +const Rml::Vector2f& Invader::GetPosition() const { return position; } @@ -147,10 +147,10 @@ void Invader::Update() } } else if (state == ALIVE && - Rml::Core::Math::RandomReal(1.0f) < bomb_probability && + Rml::Math::RandomReal(1.0f) < bomb_probability && game->CanDropBomb(invader_index)) { - bomb = Rml::Core::Math::RandomInteger(2) == 0 ? RAY : MISSILE; + bomb = Rml::Math::RandomInteger(2) == 0 ? RAY : MISSILE; bomb_position = position; bomb_position.x += invader_sprites[GetSpriteIndex()].dimensions.x / 2; @@ -189,10 +189,10 @@ void Invader::Render() glColor4ubv(MOTHERSHIP_COLOUR); } int sprite_index = GetSpriteIndex(); - int sprite_offset = Rml::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); + int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); if (state != DEAD) - invader_sprites[sprite_index].Render(Rml::Core::Vector2f(position.x - sprite_offset, position.y)); + invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y)); if (bomb != NONE) { @@ -210,11 +210,11 @@ Invader::InvaderState Invader::GetState() return state; } -bool Invader::CheckHit(const Rml::Core::Vector2f& check_position) +bool Invader::CheckHit(const Rml::Vector2f& check_position) { // Get the sprite index we're currently using for collision detection int sprite_index = GetSpriteIndex(); - int sprite_offset = Rml::Core::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); + int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2); float sprite_width = invader_sprites[sprite_index].dimensions.x; float sprite_height = invader_sprites[sprite_index].dimensions.y; @@ -230,7 +230,7 @@ bool Invader::CheckHit(const Rml::Core::Vector2f& check_position) switch (type) { RMLUI_UNUSED_SWITCH_ENUM(UNKNOWN); - case MOTHERSHIP: score = (Rml::Core::Math::RandomInteger(6) + 1) * 50; break; // 50 -> 300 + case MOTHERSHIP: score = (Rml::Math::RandomInteger(6) + 1) * 50; break; // 50 -> 300 case RANK3: score = 40; break; case RANK2: score = 20; break; case RANK1: score = 10; break; diff --git a/Samples/luainvaders/src/Invader.h b/Samples/luainvaders/src/Invader.h index c0b7ef7f3..c1388ecdf 100644 --- a/Samples/luainvaders/src/Invader.h +++ b/Samples/luainvaders/src/Invader.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSINVADER_H -#define RMLUIINVADERSINVADER_H +#ifndef RMLUI_LUAINVADERS_INVADER_H +#define RMLUI_LUAINVADERS_INVADER_H #include @@ -51,10 +51,10 @@ class Invader /// Set the invaders screen position /// @param position Position in screen space - void SetPosition(const Rml::Core::Vector2f& position); + void SetPosition(const Rml::Vector2f& position); /// Get the current invader position /// @returns The invaders position in screen space - const Rml::Core::Vector2f& GetPosition() const; + const Rml::Vector2f& GetPosition() const; /// Update the invader virtual void Update(); @@ -75,7 +75,7 @@ class Invader /// If a hit is detected, will explode and start the death timer /// @param position Position to do the hit check at /// @returns If the invader was hit - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); protected: // Game this invader is in @@ -86,7 +86,7 @@ class Invader // The invader type we represent InvaderType type; // The current position in screen space of the invader - Rml::Core::Vector2f position; + Rml::Vector2f position; // Our current animation frame int animation_frame; @@ -96,7 +96,7 @@ class Invader // Our current in-flight bomb, or none. (may be not none if we're dead.) BombType bomb; // The current position of the bomb in screen space - Rml::Core::Vector2f bomb_position; + Rml::Vector2f bomb_position; // The animation frame the bomb is on int bomb_animation_frame; // When the last bomb update occured diff --git a/Samples/luainvaders/src/LuaInterface.cpp b/Samples/luainvaders/src/LuaInterface.cpp index eb11ea57a..c527dcffb 100644 --- a/Samples/luainvaders/src/LuaInterface.cpp +++ b/Samples/luainvaders/src/LuaInterface.cpp @@ -1,6 +1,6 @@ #include "LuaInterface.h" -#include -#include +#include +#include #include "Game.h" #include "GameDetails.h" #include @@ -24,7 +24,7 @@ static ElementGameInstancer game_instancer; void LuaInterface::Initialise(lua_State* L) { InitGame(L); - Rml::Core::Factory::RegisterElementInstancer("game", &game_instancer); + Rml::Factory::RegisterElementInstancer("game", &game_instancer); } void LuaInterface::InitGame(lua_State *L) @@ -35,7 +35,7 @@ void LuaInterface::InitGame(lua_State *L) if(lua_isnil(L,game)) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Error creating the Game table from C++ in LuaInterface::InitGame"); + Rml::Log::Message(Rml::Log::LT_ERROR, "Error creating the Game table from C++ in LuaInterface::InitGame"); return; } @@ -79,7 +79,7 @@ int GameShutdown(lua_State* /*L*/) int GameSetPaused(lua_State* L) { - bool paused = CHECK_BOOL(L,1); //CHECK_BOOL defined in LuaType.h + bool paused = RMLUI_CHECK_BOOL(L,1); //RMLUI_CHECK_BOOL defined in LuaType.h GameDetails::SetPaused(paused); return 0; } @@ -93,7 +93,7 @@ int GameSetDifficulty(lua_State* L) int GameSetDefenderColour(lua_State* L) { - Rml::Core::Colourb* colour = Rml::Core::Lua::LuaType::check(L,1); + Rml::Colourb* colour = Rml::Lua::LuaType::check(L,1); GameDetails::SetDefenderColour(*colour); return 0; } diff --git a/Samples/luainvaders/src/LuaInterface.h b/Samples/luainvaders/src/LuaInterface.h index 4e5c63908..f9cb66955 100644 --- a/Samples/luainvaders/src/LuaInterface.h +++ b/Samples/luainvaders/src/LuaInterface.h @@ -1,5 +1,5 @@ -#ifndef LUAINTERFACE_H -#define LUAINTERFACE_H +#ifndef RMLUI_LUAINVADERS_LUAINTERFACE_H +#define RMLUI_LUAINVADERS_LUAINTERFACE_H /* This will define the "Game" global table in Lua and some functions with it. diff --git a/Samples/luainvaders/src/Mothership.cpp b/Samples/luainvaders/src/Mothership.cpp index 2a8d072ee..c9c6976d2 100644 --- a/Samples/luainvaders/src/Mothership.cpp +++ b/Samples/luainvaders/src/Mothership.cpp @@ -44,7 +44,7 @@ Mothership::Mothership(Game* game, int index) : Invader(game, Invader::MOTHERSHI state = DEAD; update_frame_start = 0; direction = 0; - position = Rml::Core::Vector2f(-SPRITE_WIDTH, 64.0f); + position = Rml::Vector2f(-SPRITE_WIDTH, 64.0f); } Mothership::~Mothership() @@ -71,9 +71,9 @@ void Mothership::Update() update_frame_start = Shell::GetElapsedTime(); } // Determine if we should come out of hiding - else if (Rml::Core::Math::RandomReal(1.0f) < APPEARANCE_PROBABILITY) + else if (Rml::Math::RandomReal(1.0f) < APPEARANCE_PROBABILITY) { - direction = Rml::Core::Math::RandomReal(1.0f) < 0.5 ? -1.0f : 1.0f; + direction = Rml::Math::RandomReal(1.0f) < 0.5 ? -1.0f : 1.0f; if (direction < 0) position.x = game->GetWindowDimensions().x + SPRITE_WIDTH; diff --git a/Samples/luainvaders/src/Mothership.h b/Samples/luainvaders/src/Mothership.h index 8ce66f49a..d1a771e18 100644 --- a/Samples/luainvaders/src/Mothership.h +++ b/Samples/luainvaders/src/Mothership.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSMOTHERSHIP_H -#define RMLUIINVADERSMOTHERSHIP_H +#ifndef RMLUI_LUAINVADERS_MOTHERSHIP_H +#define RMLUI_LUAINVADERS_MOTHERSHIP_H #include "Invader.h" diff --git a/Samples/luainvaders/src/Shield.cpp b/Samples/luainvaders/src/Shield.cpp index dc6845bf5..629dbf838 100644 --- a/Samples/luainvaders/src/Shield.cpp +++ b/Samples/luainvaders/src/Shield.cpp @@ -109,12 +109,12 @@ void Shield::InitialiseCells() } } -void Shield::SetPosition(const Rml::Core::Vector2f& _position) +void Shield::SetPosition(const Rml::Vector2f& _position) { position = _position; } -const Rml::Core::Vector2f& Shield::GetPosition() const +const Rml::Vector2f& Shield::GetPosition() const { return position; } @@ -135,7 +135,7 @@ void Shield::Render() { if (shield_cells[i][j] == ON) { - Rml::Core::Vector2f cell_position = position + Rml::Core::Vector2f((float) (PIXEL_SIZE * i), (float) (PIXEL_SIZE * j)); + Rml::Vector2f cell_position = position + Rml::Vector2f((float) (PIXEL_SIZE * i), (float) (PIXEL_SIZE * j)); glVertex2f(cell_position.x, cell_position.y); } } @@ -147,7 +147,7 @@ void Shield::Render() } } -bool Shield::CheckHit(const Rml::Core::Vector2f& check_position) +bool Shield::CheckHit(const Rml::Vector2f& check_position) { float sprite_size = PIXEL_SIZE * NUM_SHIELD_CELLS; @@ -177,8 +177,8 @@ void Shield::SustainDamage() int num_shields_to_lose = (NUM_SHIELD_CELLS * NUM_SHIELD_CELLS) / MAX_HEALTH; while (num_shields_to_lose > 0) { - int x = Rml::Core::Math::RandomInteger(NUM_SHIELD_CELLS); - int y = Rml::Core::Math::RandomInteger(NUM_SHIELD_CELLS); + int x = Rml::Math::RandomInteger(NUM_SHIELD_CELLS); + int y = Rml::Math::RandomInteger(NUM_SHIELD_CELLS); if (shield_cells[x][y] != DESTROYED) { shield_cells[x][y] = DESTROYED; diff --git a/Samples/luainvaders/src/Shield.h b/Samples/luainvaders/src/Shield.h index 1c04bcdaf..1a8aab7ff 100644 --- a/Samples/luainvaders/src/Shield.h +++ b/Samples/luainvaders/src/Shield.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSSHIELD_H -#define RMLUIINVADERSSHIELD_H +#ifndef RMLUI_LUAINVADERS_SHIELD_H +#define RMLUI_LUAINVADERS_SHIELD_H #include @@ -56,10 +56,10 @@ class Shield /// Set the shield's screen position /// @param position Position in screen space - void SetPosition(const Rml::Core::Vector2f& position); + void SetPosition(const Rml::Vector2f& position); /// Get the current shield position /// @returns The shield's position in screen space - const Rml::Core::Vector2f& GetPosition() const; + const Rml::Vector2f& GetPosition() const; /// Render the shield. void Render(); @@ -68,7 +68,7 @@ class Shield /// If a hit is detected, will degrade the shield. /// @param position Position to do the hit check at /// @returns If the shield was hit - bool CheckHit(const Rml::Core::Vector2f& position); + bool CheckHit(const Rml::Vector2f& position); protected: void SustainDamage(); @@ -79,7 +79,7 @@ class Shield // The invader type we represent ShieldType type; // The current position in screen space of the shield - Rml::Core::Vector2f position; + Rml::Vector2f position; // Our current state - starts at 4, degrades once per hit. int health; diff --git a/Samples/luainvaders/src/Sprite.cpp b/Samples/luainvaders/src/Sprite.cpp index ffa7cf0d2..b195b2be7 100644 --- a/Samples/luainvaders/src/Sprite.cpp +++ b/Samples/luainvaders/src/Sprite.cpp @@ -29,7 +29,7 @@ #include "Sprite.h" #include -Sprite::Sprite(const Rml::Core::Vector2f& dimensions, const Rml::Core::Vector2f& top_left_texcoord, const Rml::Core::Vector2f& bottom_right_texcoord) : dimensions(dimensions), top_left_texcoord(top_left_texcoord), bottom_right_texcoord(bottom_right_texcoord) +Sprite::Sprite(const Rml::Vector2f& dimensions, const Rml::Vector2f& top_left_texcoord, const Rml::Vector2f& bottom_right_texcoord) : dimensions(dimensions), top_left_texcoord(top_left_texcoord), bottom_right_texcoord(bottom_right_texcoord) { } @@ -37,7 +37,7 @@ Sprite::~Sprite() { } -void Sprite::Render(const Rml::Core::Vector2f& position) +void Sprite::Render(const Rml::Vector2f& position) { glTexCoord2f(top_left_texcoord.x, top_left_texcoord.y); glVertex2f(position.x, position.y); diff --git a/Samples/luainvaders/src/Sprite.h b/Samples/luainvaders/src/Sprite.h index a1633b0a0..df130882f 100644 --- a/Samples/luainvaders/src/Sprite.h +++ b/Samples/luainvaders/src/Sprite.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINVADERSSPRITE_H -#define RMLUIINVADERSSPRITE_H +#ifndef RMLUI_LUAINVADERS_SPRITE_H +#define RMLUI_LUAINVADERS_SPRITE_H #include @@ -38,14 +38,14 @@ class Sprite { public: - Sprite(const Rml::Core::Vector2f& dimensions, const Rml::Core::Vector2f& top_left_texcoord, const Rml::Core::Vector2f& bottom_right_texcoord); + Sprite(const Rml::Vector2f& dimensions, const Rml::Vector2f& top_left_texcoord, const Rml::Vector2f& bottom_right_texcoord); ~Sprite(); - void Render(const Rml::Core::Vector2f& position); + void Render(const Rml::Vector2f& position); - Rml::Core::Vector2f dimensions; - Rml::Core::Vector2f top_left_texcoord; - Rml::Core::Vector2f bottom_right_texcoord; + Rml::Vector2f dimensions; + Rml::Vector2f top_left_texcoord; + Rml::Vector2f bottom_right_texcoord; }; #endif diff --git a/Samples/luainvaders/src/main.cpp b/Samples/luainvaders/src/main.cpp index 68de372d9..42de965dd 100644 --- a/Samples/luainvaders/src/main.cpp +++ b/Samples/luainvaders/src/main.cpp @@ -26,10 +26,9 @@ * */ -#define _WIN32_WINNT 0x0500 #include -#include #include +#include #include #include @@ -38,11 +37,9 @@ #include "DecoratorInstancerStarfield.h" #include "ElementGame.h" #include "HighScores.h" -#include -#include #include "LuaInterface.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; void DoAllocConsole(); @@ -84,25 +81,22 @@ int main(int, char**) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); - // Initialise the RmlUi Controls library. - Rml::Controls::Initialise(); + Rml::Initialise(); // Initialise the Lua interface - Rml::Core::Lua::Interpreter::Initialise(); - Rml::Controls::Lua::RegisterTypes(Rml::Core::Lua::Interpreter::GetLuaState()); + Rml::Lua::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -117,15 +111,15 @@ int main(int, char**) // Register Invader's custom decorator instancers. DecoratorInstancerStarfield decorator_starfield; DecoratorInstancerDefender decorator_defender; - Rml::Core::Factory::RegisterDecoratorInstancer("starfield", &decorator_starfield); - Rml::Core::Factory::RegisterDecoratorInstancer("defender", &decorator_defender); + Rml::Factory::RegisterDecoratorInstancer("starfield", &decorator_starfield); + Rml::Factory::RegisterDecoratorInstancer("defender", &decorator_defender); // Construct the game singletons. HighScores::Initialise(); // Fire off the startup script. - LuaInterface::Initialise(Rml::Core::Lua::Interpreter::GetLuaState()); //the tables/functions defined in the samples - Rml::Core::Lua::Interpreter::LoadFile(Rml::Core::String("luainvaders/lua/start.lua")); + LuaInterface::Initialise(Rml::Lua::Interpreter::GetLuaState()); //the tables/functions defined in the samples + Rml::Lua::Interpreter::LoadFile(Rml::String("luainvaders/lua/start.lua")); Shell::EventLoop(GameLoop); @@ -133,7 +127,7 @@ int main(int, char**) HighScores::Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/shell/include/Input.h b/Samples/shell/include/Input.h index 9f463008e..e9a6d980c 100644 --- a/Samples/shell/include/Input.h +++ b/Samples/shell/include/Input.h @@ -26,37 +26,26 @@ * */ -#ifndef SHELLINPUT_H -#define SHELLINPUT_H +#ifndef RMLUI_SHELL_INPUT_H +#define RMLUI_SHELL_INPUT_H #include #include -namespace Rml { -namespace Core { - -class Context; - -} -} - -/** - */ - class Input { public: /// Sets the context to send input events to. /// @param[in] context The context to send input events to. - static void SetContext(Rml::Core::Context* context); + static void SetContext(Rml::Context* context); /// Returns the character code for a key identifer / key modifier combination. /// @param[in] key_identifier The key to generate a character code for. /// @param[in] key_modifier_state The configuration of the key modifiers. /// @return The character code. - static Rml::Core::Character GetCharacterCode(Rml::Core::Input::KeyIdentifier key_identifier, int key_modifier_state); + static Rml::Character GetCharacterCode(Rml::Input::KeyIdentifier key_identifier, int key_modifier_state); protected: - static Rml::Core::Context* context; + static Rml::Context* context; }; #endif diff --git a/Samples/shell/include/Shell.h b/Samples/shell/include/Shell.h index 1993ff774..4b112202b 100644 --- a/Samples/shell/include/Shell.h +++ b/Samples/shell/include/Shell.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUISHELL_H -#define RMLUISHELL_H +#ifndef RMLUI_SHELL_H +#define RMLUI_SHELL_H #include #include @@ -48,7 +48,7 @@ class Shell static void Shutdown(); /// Finds the Samples root directory. - static Rml::Core::String FindSamplesRoot(); + static Rml::String FindSamplesRoot(); /// Loads the default fonts from the given path. static void LoadFonts(const char* directory); @@ -77,20 +77,20 @@ class Shell static double GetElapsedTime(); /// Set mouse cursor. - static void SetMouseCursor(const Rml::Core::String& cursor_name); + static void SetMouseCursor(const Rml::String& cursor_name); /// Set clipboard text. - static void SetClipboardText(const Rml::Core::String& text); + static void SetClipboardText(const Rml::String& text); /// Get clipboard text. - static void GetClipboardText(Rml::Core::String& text); + static void GetClipboardText(Rml::String& text); /// Sets the context to send window resized events to. /// @param[in] context The context to send events to. - static void SetContext(Rml::Core::Context* context); + static void SetContext(Rml::Context* context); private: - static Rml::Core::Context* context; + static Rml::Context* context; }; #include "ShellSystemInterface.h" diff --git a/Samples/shell/include/ShellFileInterface.h b/Samples/shell/include/ShellFileInterface.h index cbbc1ec84..6b98a3948 100644 --- a/Samples/shell/include/ShellFileInterface.h +++ b/Samples/shell/include/ShellFileInterface.h @@ -26,8 +26,8 @@ * */ -#ifndef SHELLFILEINTERFACE_H -#define SHELLFILEINTERFACE_H +#ifndef RMLUI_SHELL_SHELLFILEINTERFACE_H +#define RMLUI_SHELL_SHELLFILEINTERFACE_H #include #include @@ -37,29 +37,29 @@ @author Lloyd Weehuizen */ -class ShellFileInterface : public Rml::Core::FileInterface +class ShellFileInterface : public Rml::FileInterface { public: - ShellFileInterface(const Rml::Core::String& root); + ShellFileInterface(const Rml::String& root); virtual ~ShellFileInterface(); /// Opens a file. - Rml::Core::FileHandle Open(const Rml::Core::String& path) override; + Rml::FileHandle Open(const Rml::String& path) override; /// Closes a previously opened file. - void Close(Rml::Core::FileHandle file) override; + void Close(Rml::FileHandle file) override; /// Reads data from a previously opened file. - size_t Read(void* buffer, size_t size, Rml::Core::FileHandle file) override; + size_t Read(void* buffer, size_t size, Rml::FileHandle file) override; /// Seeks to a point in a previously opened file. - bool Seek(Rml::Core::FileHandle file, long offset, int origin) override; + bool Seek(Rml::FileHandle file, long offset, int origin) override; /// Returns the current position of the file pointer. - size_t Tell(Rml::Core::FileHandle file) override; + size_t Tell(Rml::FileHandle file) override; private: - Rml::Core::String root; + Rml::String root; }; #endif diff --git a/Samples/shell/include/ShellOpenGL.h b/Samples/shell/include/ShellOpenGL.h index 92c47dbb6..bc311c2d1 100644 --- a/Samples/shell/include/ShellOpenGL.h +++ b/Samples/shell/include/ShellOpenGL.h @@ -26,13 +26,13 @@ * */ -#ifndef RMLUISHELLOPENGL_H -#define RMLUISHELLOPENGL_H +#ifndef RMLUI_SHELL_SHELLOPENGL_H +#define RMLUI_SHELL_SHELLOPENGL_H #include #if defined RMLUI_PLATFORM_WIN32 -#include +#include "win32/IncludeWindows.h" #include #include #elif defined RMLUI_PLATFORM_MACOSX diff --git a/Samples/shell/include/ShellRenderInterfaceExtensions.h b/Samples/shell/include/ShellRenderInterfaceExtensions.h index 6fbc7b244..b8d008f98 100644 --- a/Samples/shell/include/ShellRenderInterfaceExtensions.h +++ b/Samples/shell/include/ShellRenderInterfaceExtensions.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUISHELLRENDERINTERFACE_H -#define RMLUISHELLRENDERINTERFACE_H +#ifndef RMLUI_SHELL_SHELLRENDERINTERFACEEXTENSIONS_H +#define RMLUI_SHELL_SHELLRENDERINTERFACEEXTENSIONS_H /** Extensions to the RenderInterface class used by the Samples Shell to @@ -46,7 +46,7 @@ class ShellRenderInterfaceExtensions virtual void SetViewport(int width, int height) = 0; /** - * @param[in] context Rml::Core::Context to set dimensions on when SetViewport is called + * @param[in] context Rml::Context to set dimensions on when SetViewport is called */ virtual void SetContext(void *context) = 0; diff --git a/Samples/shell/include/ShellRenderInterfaceOpenGL.h b/Samples/shell/include/ShellRenderInterfaceOpenGL.h index 51678a5ed..80b028255 100644 --- a/Samples/shell/include/ShellRenderInterfaceOpenGL.h +++ b/Samples/shell/include/ShellRenderInterfaceOpenGL.h @@ -26,10 +26,10 @@ * */ -#ifndef RMLUISHELLRENDERINTERFACEOPENGL_H -#define RMLUISHELLRENDERINTERFACEOPENGL_H +#ifndef RMLUI_SHELL_SHELLRENDERINTERFACEOPENGL_H +#define RMLUI_SHELL_SHELLRENDERINTERFACEOPENGL_H -#include "RmlUi/Core/RenderInterface.h" +#include #include "ShellOpenGL.h" /** @@ -37,21 +37,21 @@ @author Peter Curry */ -class ShellRenderInterfaceOpenGL : public Rml::Core::RenderInterface, public ShellRenderInterfaceExtensions +class ShellRenderInterfaceOpenGL : public Rml::RenderInterface, public ShellRenderInterfaceExtensions { public: ShellRenderInterfaceOpenGL(); /// Called by RmlUi when it wants to render geometry that it does not wish to optimise. - void RenderGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) override; + void RenderGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture, const Rml::Vector2f& translation) override; /// Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future. - Rml::Core::CompiledGeometryHandle CompileGeometry(Rml::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::Core::TextureHandle texture) override; + Rml::CompiledGeometryHandle CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rml::TextureHandle texture) override; /// Called by RmlUi when it wants to render application-compiled geometry. - void RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry, const Rml::Core::Vector2f& translation) override; + void RenderCompiledGeometry(Rml::CompiledGeometryHandle geometry, const Rml::Vector2f& translation) override; /// Called by RmlUi when it wants to release application-compiled geometry. - void ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle geometry) override; + void ReleaseCompiledGeometry(Rml::CompiledGeometryHandle geometry) override; /// Called by RmlUi when it wants to enable or disable scissoring to clip content. void EnableScissorRegion(bool enable) override; @@ -59,14 +59,14 @@ class ShellRenderInterfaceOpenGL : public Rml::Core::RenderInterface, public Sh void SetScissorRegion(int x, int y, int width, int height) override; /// Called by RmlUi when a texture is required by the library. - bool LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) override; + bool LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) override; /// Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. - bool GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) override; + bool GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) override; /// Called by RmlUi when a loaded texture is no longer required. - void ReleaseTexture(Rml::Core::TextureHandle texture_handle) override; + void ReleaseTexture(Rml::TextureHandle texture_handle) override; /// Called by RmlUi when it wants to set the current transform matrix to a new matrix. - void SetTransform(const Rml::Core::Matrix4f* transform) override; + void SetTransform(const Rml::Matrix4f* transform) override; // ShellRenderInterfaceExtensions void SetViewport(int width, int height) override; diff --git a/Samples/shell/include/ShellSystemInterface.h b/Samples/shell/include/ShellSystemInterface.h index 2ef2950c0..2c19df3b5 100644 --- a/Samples/shell/include/ShellSystemInterface.h +++ b/Samples/shell/include/ShellSystemInterface.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUISHELLSYSTEMINTERFACE_H -#define RMLUISHELLSYSTEMINTERFACE_H +#ifndef RMLUI_SHELL_SHELLSYSTEMINTERFACE_H +#define RMLUI_SHELL_SHELLSYSTEMINTERFACE_H #include @@ -36,7 +36,7 @@ @author Lloyd Weehuizen */ -class ShellSystemInterface : public Rml::Core::SystemInterface +class ShellSystemInterface : public Rml::SystemInterface { public: /// Get the number of seconds elapsed since the start of the application @@ -45,15 +45,15 @@ class ShellSystemInterface : public Rml::Core::SystemInterface /// Set mouse cursor. /// @param[in] cursor_name Cursor name to activate. - void SetMouseCursor(const Rml::Core::String& cursor_name) override; + void SetMouseCursor(const Rml::String& cursor_name) override; /// Set clipboard text. /// @param[in] text Text to apply to clipboard. - void SetClipboardText(const Rml::Core::String& text) override; + void SetClipboardText(const Rml::String& text) override; /// Get clipboard text. /// @param[out] text Retrieved text from clipboard. - void GetClipboardText(Rml::Core::String& text) override; + void GetClipboardText(Rml::String& text) override; }; #endif diff --git a/Samples/shell/include/macosx/InputMacOSX.h b/Samples/shell/include/macosx/InputMacOSX.h index fbd5364ae..5b23e5b61 100644 --- a/Samples/shell/include/macosx/InputMacOSX.h +++ b/Samples/shell/include/macosx/InputMacOSX.h @@ -26,8 +26,8 @@ * */ -#ifndef INPUTMACOSX_H -#define INPUTMACOSX_H +#ifndef RMLUI_SHELL_MACOSX_INPUTMACOSX_H +#define RMLUI_SHELL_MACOSX_INPUTMACOSX_H #include "Input.h" #include diff --git a/Samples/shell/include/win32/IncludeWindows.h b/Samples/shell/include/win32/IncludeWindows.h index ad819a5b7..28ecab4ea 100644 --- a/Samples/shell/include/win32/IncludeWindows.h +++ b/Samples/shell/include/win32/IncludeWindows.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINCLUDEWINDOWS_H -#define RMLUIINCLUDEWINDOWS_H +#ifndef RMLUI_SHELL_WIN32_INCLUDEWINDOWS_H +#define RMLUI_SHELL_WIN32_INCLUDEWINDOWS_H #if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0501 #undef _WIN32_WINNT diff --git a/Samples/shell/include/win32/InputWin32.h b/Samples/shell/include/win32/InputWin32.h index f27a8ed53..dc2e80ffb 100644 --- a/Samples/shell/include/win32/InputWin32.h +++ b/Samples/shell/include/win32/InputWin32.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIINPUTWIN32_H -#define RMLUIINPUTWIN32_H +#ifndef RMLUI_SHELL_INPUTWIN32_H +#define RMLUI_SHELL_INPUTWIN32_H #include #include diff --git a/Samples/shell/include/x11/InputX11.h b/Samples/shell/include/x11/InputX11.h index 62d650e82..9209f3096 100644 --- a/Samples/shell/include/x11/InputX11.h +++ b/Samples/shell/include/x11/InputX11.h @@ -26,8 +26,8 @@ * */ -#ifndef INPUTX11_H -#define INPUTX11_H +#ifndef RMLUI_SHELL_X11_INPUTX11_H +#define RMLUI_SHELL_X11_INPUTX11_H #include diff --git a/Samples/shell/src/Input.cpp b/Samples/shell/src/Input.cpp index 0a614c88e..6054b3140 100644 --- a/Samples/shell/src/Input.cpp +++ b/Samples/shell/src/Input.cpp @@ -303,12 +303,12 @@ char keypad_map[2][18] = -Rml::Core::Context* Input::context = nullptr; +Rml::Context* Input::context = nullptr; // Sets the context to send input events to. -void Input::SetContext(Rml::Core::Context* _context) +void Input::SetContext(Rml::Context* _context) { context = _context; } @@ -316,17 +316,17 @@ void Input::SetContext(Rml::Core::Context* _context) // Returns the character code for a key identifer / key modifier combination. -Rml::Core::Character Input::GetCharacterCode(Rml::Core::Input::KeyIdentifier key_identifier, int key_modifier_state) +Rml::Character Input::GetCharacterCode(Rml::Input::KeyIdentifier key_identifier, int key_modifier_state) { - using Rml::Core::Character; + using Rml::Character; // Check if we have a keycode capable of generating characters on the main keyboard (ie, not on the numeric // keypad; that is dealt with below). - if (key_identifier <= Rml::Core::Input::KI_OEM_102) + if (key_identifier <= Rml::Input::KI_OEM_102) { // Get modifier states - bool shift = (key_modifier_state & Rml::Core::Input::KM_SHIFT) > 0; - bool capslock = (key_modifier_state & Rml::Core::Input::KM_CAPSLOCK) > 0; + bool shift = (key_modifier_state & Rml::Input::KM_SHIFT) > 0; + bool capslock = (key_modifier_state & Rml::Input::KM_CAPSLOCK) > 0; // Return character code based on identifier and modifiers if (shift && !capslock) @@ -342,15 +342,15 @@ Rml::Core::Character Input::GetCharacterCode(Rml::Core::Input::KeyIdentifier key } // Check if we have a keycode from the numeric keypad. - else if (key_identifier <= Rml::Core::Input::KI_OEM_NEC_EQUAL) + else if (key_identifier <= Rml::Input::KI_OEM_NEC_EQUAL) { - if (key_modifier_state & Rml::Core::Input::KM_NUMLOCK) - return (Character)keypad_map[0][key_identifier - Rml::Core::Input::KI_NUMPAD0]; + if (key_modifier_state & Rml::Input::KM_NUMLOCK) + return (Character)keypad_map[0][key_identifier - Rml::Input::KI_NUMPAD0]; else - return (Character)keypad_map[1][key_identifier - Rml::Core::Input::KI_NUMPAD0]; + return (Character)keypad_map[1][key_identifier - Rml::Input::KI_NUMPAD0]; } - else if (key_identifier == Rml::Core::Input::KI_RETURN) + else if (key_identifier == Rml::Input::KI_RETURN) return (Character)'\n'; return Character::Null; diff --git a/Samples/shell/src/Shell.cpp b/Samples/shell/src/Shell.cpp index 3f3c623e4..a33d73a0e 100644 --- a/Samples/shell/src/Shell.cpp +++ b/Samples/shell/src/Shell.cpp @@ -32,7 +32,7 @@ /// Loads the default fonts from the given path. void Shell::LoadFonts(const char* directory) { - Rml::Core::String font_names[5]; + Rml::String font_names[5]; font_names[0] = "Delicious-Roman.otf"; font_names[1] = "Delicious-Italic.otf"; font_names[2] = "Delicious-Bold.otf"; @@ -41,9 +41,9 @@ void Shell::LoadFonts(const char* directory) const int fallback_face = 4; - for (size_t i = 0; i < sizeof(font_names) / sizeof(Rml::Core::String); i++) + for (size_t i = 0; i < sizeof(font_names) / sizeof(Rml::String); i++) { - Rml::Core::LoadFontFace(Rml::Core::String(directory) + font_names[i], i == fallback_face); + Rml::LoadFontFace(Rml::String(directory) + font_names[i], i == fallback_face); } } diff --git a/Samples/shell/src/ShellFileInterface.cpp b/Samples/shell/src/ShellFileInterface.cpp index 276ce763a..080c1e2c7 100644 --- a/Samples/shell/src/ShellFileInterface.cpp +++ b/Samples/shell/src/ShellFileInterface.cpp @@ -29,7 +29,7 @@ #include #include -ShellFileInterface::ShellFileInterface(const Rml::Core::String& root) : root(root) +ShellFileInterface::ShellFileInterface(const Rml::String& root) : root(root) { } @@ -38,38 +38,38 @@ ShellFileInterface::~ShellFileInterface() } // Opens a file. -Rml::Core::FileHandle ShellFileInterface::Open(const Rml::Core::String& path) +Rml::FileHandle ShellFileInterface::Open(const Rml::String& path) { // Attempt to open the file relative to the application's root. FILE* fp = fopen((root + path).c_str(), "rb"); if (fp != nullptr) - return (Rml::Core::FileHandle) fp; + return (Rml::FileHandle) fp; // Attempt to open the file relative to the current working directory. fp = fopen(path.c_str(), "rb"); - return (Rml::Core::FileHandle) fp; + return (Rml::FileHandle) fp; } // Closes a previously opened file. -void ShellFileInterface::Close(Rml::Core::FileHandle file) +void ShellFileInterface::Close(Rml::FileHandle file) { fclose((FILE*) file); } // Reads data from a previously opened file. -size_t ShellFileInterface::Read(void* buffer, size_t size, Rml::Core::FileHandle file) +size_t ShellFileInterface::Read(void* buffer, size_t size, Rml::FileHandle file) { return fread(buffer, 1, size, (FILE*) file); } // Seeks to a point in a previously opened file. -bool ShellFileInterface::Seek(Rml::Core::FileHandle file, long offset, int origin) +bool ShellFileInterface::Seek(Rml::FileHandle file, long offset, int origin) { return fseek((FILE*) file, offset, origin) == 0; } // Returns the current position of the file pointer. -size_t ShellFileInterface::Tell(Rml::Core::FileHandle file) +size_t ShellFileInterface::Tell(Rml::FileHandle file) { return ftell((FILE*) file); } diff --git a/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp b/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp index 42302c131..547df2833 100644 --- a/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp +++ b/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp @@ -41,16 +41,16 @@ ShellRenderInterfaceOpenGL::ShellRenderInterfaceOpenGL() : m_width(0), m_height( } // Called by RmlUi when it wants to render geometry that it does not wish to optimise. -void ShellRenderInterfaceOpenGL::RenderGeometry(Rml::Core::Vertex* vertices, int RMLUI_UNUSED_PARAMETER(num_vertices), int* indices, int num_indices, const Rml::Core::TextureHandle texture, const Rml::Core::Vector2f& translation) +void ShellRenderInterfaceOpenGL::RenderGeometry(Rml::Vertex* vertices, int RMLUI_UNUSED_PARAMETER(num_vertices), int* indices, int num_indices, const Rml::TextureHandle texture, const Rml::Vector2f& translation) { RMLUI_UNUSED(num_vertices); glPushMatrix(); glTranslatef(translation.x, translation.y, 0); - glVertexPointer(2, GL_FLOAT, sizeof(Rml::Core::Vertex), &vertices[0].position); + glVertexPointer(2, GL_FLOAT, sizeof(Rml::Vertex), &vertices[0].position); glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rml::Core::Vertex), &vertices[0].colour); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rml::Vertex), &vertices[0].colour); if (!texture) { @@ -62,7 +62,7 @@ void ShellRenderInterfaceOpenGL::RenderGeometry(Rml::Core::Vertex* vertices, int glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, (GLuint) texture); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, sizeof(Rml::Core::Vertex), &vertices[0].tex_coord); + glTexCoordPointer(2, GL_FLOAT, sizeof(Rml::Vertex), &vertices[0].tex_coord); } glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices); @@ -71,7 +71,7 @@ void ShellRenderInterfaceOpenGL::RenderGeometry(Rml::Core::Vertex* vertices, int } // Called by RmlUi when it wants to compile geometry it believes will be static for the forseeable future. -Rml::Core::CompiledGeometryHandle ShellRenderInterfaceOpenGL::CompileGeometry(Rml::Core::Vertex* RMLUI_UNUSED_PARAMETER(vertices), int RMLUI_UNUSED_PARAMETER(num_vertices), int* RMLUI_UNUSED_PARAMETER(indices), int RMLUI_UNUSED_PARAMETER(num_indices), const Rml::Core::TextureHandle RMLUI_UNUSED_PARAMETER(texture)) +Rml::CompiledGeometryHandle ShellRenderInterfaceOpenGL::CompileGeometry(Rml::Vertex* RMLUI_UNUSED_PARAMETER(vertices), int RMLUI_UNUSED_PARAMETER(num_vertices), int* RMLUI_UNUSED_PARAMETER(indices), int RMLUI_UNUSED_PARAMETER(num_indices), const Rml::TextureHandle RMLUI_UNUSED_PARAMETER(texture)) { RMLUI_UNUSED(vertices); RMLUI_UNUSED(num_vertices); @@ -79,18 +79,18 @@ Rml::Core::CompiledGeometryHandle ShellRenderInterfaceOpenGL::CompileGeometry(Rm RMLUI_UNUSED(num_indices); RMLUI_UNUSED(texture); - return (Rml::Core::CompiledGeometryHandle) nullptr; + return (Rml::CompiledGeometryHandle) nullptr; } // Called by RmlUi when it wants to render application-compiled geometry. -void ShellRenderInterfaceOpenGL::RenderCompiledGeometry(Rml::Core::CompiledGeometryHandle RMLUI_UNUSED_PARAMETER(geometry), const Rml::Core::Vector2f& RMLUI_UNUSED_PARAMETER(translation)) +void ShellRenderInterfaceOpenGL::RenderCompiledGeometry(Rml::CompiledGeometryHandle RMLUI_UNUSED_PARAMETER(geometry), const Rml::Vector2f& RMLUI_UNUSED_PARAMETER(translation)) { RMLUI_UNUSED(geometry); RMLUI_UNUSED(translation); } // Called by RmlUi when it wants to release application-compiled geometry. -void ShellRenderInterfaceOpenGL::ReleaseCompiledGeometry(Rml::Core::CompiledGeometryHandle RMLUI_UNUSED_PARAMETER(geometry)) +void ShellRenderInterfaceOpenGL::ReleaseCompiledGeometry(Rml::CompiledGeometryHandle RMLUI_UNUSED_PARAMETER(geometry)) { RMLUI_UNUSED(geometry); } @@ -175,10 +175,10 @@ struct TGAHeader #pragma pack() // Called by RmlUi when a texture is required by the library. -bool ShellRenderInterfaceOpenGL::LoadTexture(Rml::Core::TextureHandle& texture_handle, Rml::Core::Vector2i& texture_dimensions, const Rml::Core::String& source) +bool ShellRenderInterfaceOpenGL::LoadTexture(Rml::TextureHandle& texture_handle, Rml::Vector2i& texture_dimensions, const Rml::String& source) { - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle file_handle = file_interface->Open(source); + Rml::FileInterface* file_interface = Rml::GetFileInterface(); + Rml::FileHandle file_handle = file_interface->Open(source); if (!file_handle) { return false; @@ -207,14 +207,14 @@ bool ShellRenderInterfaceOpenGL::LoadTexture(Rml::Core::TextureHandle& texture_h if (header.dataType != 2) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Only 24/32bit uncompressed TGAs are supported."); + Rml::Log::Message(Rml::Log::LT_ERROR, "Only 24/32bit uncompressed TGAs are supported."); return false; } // Ensure we have at least 3 colors if (color_mode < 3) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Only 24 and 32bit textures are supported"); + Rml::Log::Message(Rml::Log::LT_ERROR, "Only 24 and 32bit textures are supported"); return false; } @@ -253,7 +253,7 @@ bool ShellRenderInterfaceOpenGL::LoadTexture(Rml::Core::TextureHandle& texture_h } // Called by RmlUi when a texture is required to be built from an internally-generated sequence of pixels. -bool ShellRenderInterfaceOpenGL::GenerateTexture(Rml::Core::TextureHandle& texture_handle, const Rml::Core::byte* source, const Rml::Core::Vector2i& source_dimensions) +bool ShellRenderInterfaceOpenGL::GenerateTexture(Rml::TextureHandle& texture_handle, const Rml::byte* source, const Rml::Vector2i& source_dimensions) { GLuint texture_id = 0; glGenTextures(1, &texture_id); @@ -272,27 +272,27 @@ bool ShellRenderInterfaceOpenGL::GenerateTexture(Rml::Core::TextureHandle& textu glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - texture_handle = (Rml::Core::TextureHandle) texture_id; + texture_handle = (Rml::TextureHandle) texture_id; return true; } // Called by RmlUi when a loaded texture is no longer required. -void ShellRenderInterfaceOpenGL::ReleaseTexture(Rml::Core::TextureHandle texture_handle) +void ShellRenderInterfaceOpenGL::ReleaseTexture(Rml::TextureHandle texture_handle) { glDeleteTextures(1, (GLuint*) &texture_handle); } // Called by RmlUi when it wants to set the current transform matrix to a new matrix. -void ShellRenderInterfaceOpenGL::SetTransform(const Rml::Core::Matrix4f* transform) +void ShellRenderInterfaceOpenGL::SetTransform(const Rml::Matrix4f* transform) { m_transform_enabled = (bool)transform; if (transform) { - if (std::is_same::value) + if (std::is_same::value) glLoadMatrixf(transform->data()); - else if (std::is_same::value) + else if (std::is_same::value) glLoadMatrixf(transform->Transpose().data()); } else diff --git a/Samples/shell/src/ShellSystemInterface.cpp b/Samples/shell/src/ShellSystemInterface.cpp index 2dfb3b123..9cd2cfe3d 100644 --- a/Samples/shell/src/ShellSystemInterface.cpp +++ b/Samples/shell/src/ShellSystemInterface.cpp @@ -35,17 +35,17 @@ double ShellSystemInterface::GetElapsedTime() return Shell::GetElapsedTime(); } -void ShellSystemInterface::SetMouseCursor(const Rml::Core::String& cursor_name) +void ShellSystemInterface::SetMouseCursor(const Rml::String& cursor_name) { Shell::SetMouseCursor(cursor_name); } -void ShellSystemInterface::SetClipboardText(const Rml::Core::String& text) +void ShellSystemInterface::SetClipboardText(const Rml::String& text) { Shell::SetClipboardText(text); } -void ShellSystemInterface::GetClipboardText(Rml::Core::String& text) +void ShellSystemInterface::GetClipboardText(Rml::String& text) { Shell::GetClipboardText(text); } diff --git a/Samples/shell/src/macosx/InputMacOSX.cpp b/Samples/shell/src/macosx/InputMacOSX.cpp index d2e0798ad..fc68bfbc4 100644 --- a/Samples/shell/src/macosx/InputMacOSX.cpp +++ b/Samples/shell/src/macosx/InputMacOSX.cpp @@ -44,7 +44,7 @@ static void InitialiseKeymap(); static int GetKeyModifierState(EventRef event); static const int KEYMAP_SIZE = 256; -static Rml::Core::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; +static Rml::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; bool InputMacOSX::Initialise() { @@ -116,21 +116,21 @@ OSStatus InputMacOSX::EventHandler(EventHandlerCallRef next_handler, EventRef ev UInt32 key_code; if (GetEventParameter(event, kEventParamKeyCode, typeUInt32, nullptr, sizeof(UInt32), nullptr, &key_code) == noErr) { - Rml::Core::Input::KeyIdentifier key_identifier = key_identifier_map[key_code & 0xFF]; + Rml::Input::KeyIdentifier key_identifier = key_identifier_map[key_code & 0xFF]; int key_modifier_state = GetKeyModifierState(event); // Check for F8 to toggle the debugger. - if (key_identifier == Rml::Core::Input::KI_F8) + if (key_identifier == Rml::Input::KI_F8) { Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible()); break; } - if (key_identifier != Rml::Core::Input::KI_UNKNOWN) + if (key_identifier != Rml::Input::KI_UNKNOWN) context->ProcessKeyDown(key_identifier, key_modifier_state); - Rml::Core::Character character = GetCharacterCode(key_identifier, key_modifier_state); - if (character != Rml::Core::Character::Null) + Rml::Character character = GetCharacterCode(key_identifier, key_modifier_state); + if (character != Rml::Character::Null) context->ProcessTextInput(character); } } @@ -141,10 +141,10 @@ OSStatus InputMacOSX::EventHandler(EventHandlerCallRef next_handler, EventRef ev UInt32 key_code; if (GetEventParameter(event, kEventParamKeyCode, typeUInt32, nullptr, sizeof(UInt32), nullptr, &key_code) == noErr) { - Rml::Core::Input::KeyIdentifier key_identifier = key_identifier_map[key_code & 0xFF]; + Rml::Input::KeyIdentifier key_identifier = key_identifier_map[key_code & 0xFF]; int key_modifier_state = GetKeyModifierState(event); - if (key_identifier != Rml::Core::Input::KI_UNKNOWN) + if (key_identifier != Rml::Input::KI_UNKNOWN) context->ProcessKeyUp(key_identifier, key_modifier_state); } } @@ -165,15 +165,15 @@ static int GetKeyModifierState(EventRef event) if (GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, nullptr, sizeof(UInt32), nullptr, &carbon_key_modifier_state) == noErr) { if (carbon_key_modifier_state & KEY_ALT) - key_modifier_state |= Rml::Core::Input::KM_ALT; + key_modifier_state |= Rml::Input::KM_ALT; if (carbon_key_modifier_state & KEY_SHIFT) - key_modifier_state |= Rml::Core::Input::KM_SHIFT; + key_modifier_state |= Rml::Input::KM_SHIFT; if (carbon_key_modifier_state & KEY_CAPS) - key_modifier_state |= Rml::Core::Input::KM_CAPSLOCK; + key_modifier_state |= Rml::Input::KM_CAPSLOCK; if (carbon_key_modifier_state & KEY_OPTION) - key_modifier_state |= Rml::Core::Input::KM_META; + key_modifier_state |= Rml::Input::KM_META; if (carbon_key_modifier_state & KEY_CTRL) - key_modifier_state |= Rml::Core::Input::KM_CTRL; + key_modifier_state |= Rml::Input::KM_CTRL; } return key_modifier_state; @@ -184,102 +184,102 @@ static void InitialiseKeymap() // Initialise the key map with default values. memset(key_identifier_map, sizeof(key_identifier_map), 0); - key_identifier_map[0x00] = Rml::Core::Input::KI_A; - key_identifier_map[0x01] = Rml::Core::Input::KI_S; - key_identifier_map[0x02] = Rml::Core::Input::KI_D; - key_identifier_map[0x03] = Rml::Core::Input::KI_F; - key_identifier_map[0x04] = Rml::Core::Input::KI_H; - key_identifier_map[0x05] = Rml::Core::Input::KI_G; - key_identifier_map[0x06] = Rml::Core::Input::KI_Z; - key_identifier_map[0x07] = Rml::Core::Input::KI_X; - key_identifier_map[0x08] = Rml::Core::Input::KI_C; - key_identifier_map[0x09] = Rml::Core::Input::KI_V; - key_identifier_map[0x0B] = Rml::Core::Input::KI_B; - key_identifier_map[0x0C] = Rml::Core::Input::KI_Q; - key_identifier_map[0x0D] = Rml::Core::Input::KI_W; - key_identifier_map[0x0E] = Rml::Core::Input::KI_E; - key_identifier_map[0x0F] = Rml::Core::Input::KI_R; - key_identifier_map[0x10] = Rml::Core::Input::KI_Y; - key_identifier_map[0x11] = Rml::Core::Input::KI_T; - key_identifier_map[0x12] = Rml::Core::Input::KI_1; - key_identifier_map[0x13] = Rml::Core::Input::KI_2; - key_identifier_map[0x14] = Rml::Core::Input::KI_3; - key_identifier_map[0x15] = Rml::Core::Input::KI_4; - key_identifier_map[0x16] = Rml::Core::Input::KI_6; - key_identifier_map[0x17] = Rml::Core::Input::KI_5; - key_identifier_map[0x18] = Rml::Core::Input::KI_OEM_PLUS; - key_identifier_map[0x19] = Rml::Core::Input::KI_9; - key_identifier_map[0x1A] = Rml::Core::Input::KI_7; - key_identifier_map[0x1B] = Rml::Core::Input::KI_OEM_MINUS; - key_identifier_map[0x1C] = Rml::Core::Input::KI_8; - key_identifier_map[0x1D] = Rml::Core::Input::KI_0; - key_identifier_map[0x1E] = Rml::Core::Input::KI_OEM_6; - key_identifier_map[0x1F] = Rml::Core::Input::KI_O; - key_identifier_map[0x20] = Rml::Core::Input::KI_U; - key_identifier_map[0x21] = Rml::Core::Input::KI_OEM_4; - key_identifier_map[0x22] = Rml::Core::Input::KI_I; - key_identifier_map[0x23] = Rml::Core::Input::KI_P; - key_identifier_map[0x24] = Rml::Core::Input::KI_RETURN; - key_identifier_map[0x25] = Rml::Core::Input::KI_L; - key_identifier_map[0x26] = Rml::Core::Input::KI_J; - key_identifier_map[0x27] = Rml::Core::Input::KI_OEM_7; - key_identifier_map[0x28] = Rml::Core::Input::KI_K; - key_identifier_map[0x29] = Rml::Core::Input::KI_OEM_1; - key_identifier_map[0x2A] = Rml::Core::Input::KI_OEM_5; - key_identifier_map[0x2B] = Rml::Core::Input::KI_OEM_COMMA; - key_identifier_map[0x2C] = Rml::Core::Input::KI_OEM_2; - key_identifier_map[0x2D] = Rml::Core::Input::KI_N; - key_identifier_map[0x2E] = Rml::Core::Input::KI_M; - key_identifier_map[0x2F] = Rml::Core::Input::KI_OEM_PERIOD; - key_identifier_map[0x30] = Rml::Core::Input::KI_TAB; - key_identifier_map[0x31] = Rml::Core::Input::KI_SPACE; - key_identifier_map[0x32] = Rml::Core::Input::KI_OEM_3; - key_identifier_map[0x33] = Rml::Core::Input::KI_BACK; - key_identifier_map[0x35] = Rml::Core::Input::KI_ESCAPE; - key_identifier_map[0x37] = Rml::Core::Input::KI_LMETA; - key_identifier_map[0x38] = Rml::Core::Input::KI_LSHIFT; - key_identifier_map[0x39] = Rml::Core::Input::KI_CAPITAL; - key_identifier_map[0x3A] = Rml::Core::Input::KI_LMENU; - key_identifier_map[0x3B] = Rml::Core::Input::KI_LCONTROL; - key_identifier_map[0x41] = Rml::Core::Input::KI_DECIMAL; - key_identifier_map[0x43] = Rml::Core::Input::KI_MULTIPLY; - key_identifier_map[0x45] = Rml::Core::Input::KI_ADD; - key_identifier_map[0x4B] = Rml::Core::Input::KI_DIVIDE; - key_identifier_map[0x4C] = Rml::Core::Input::KI_NUMPADENTER; - key_identifier_map[0x4E] = Rml::Core::Input::KI_SUBTRACT; - key_identifier_map[0x51] = Rml::Core::Input::KI_OEM_PLUS; - key_identifier_map[0x52] = Rml::Core::Input::KI_NUMPAD0; - key_identifier_map[0x53] = Rml::Core::Input::KI_NUMPAD1; - key_identifier_map[0x54] = Rml::Core::Input::KI_NUMPAD2; - key_identifier_map[0x55] = Rml::Core::Input::KI_NUMPAD3; - key_identifier_map[0x56] = Rml::Core::Input::KI_NUMPAD4; - key_identifier_map[0x57] = Rml::Core::Input::KI_NUMPAD5; - key_identifier_map[0x58] = Rml::Core::Input::KI_NUMPAD6; - key_identifier_map[0x59] = Rml::Core::Input::KI_NUMPAD7; - key_identifier_map[0x5B] = Rml::Core::Input::KI_NUMPAD8; - key_identifier_map[0x5C] = Rml::Core::Input::KI_NUMPAD9; - key_identifier_map[0x60] = Rml::Core::Input::KI_F5; - key_identifier_map[0x61] = Rml::Core::Input::KI_F6; - key_identifier_map[0x62] = Rml::Core::Input::KI_F7; - key_identifier_map[0x63] = Rml::Core::Input::KI_F3; - key_identifier_map[0x64] = Rml::Core::Input::KI_F8; - key_identifier_map[0x65] = Rml::Core::Input::KI_F9; - key_identifier_map[0x67] = Rml::Core::Input::KI_F11; - key_identifier_map[0x69] = Rml::Core::Input::KI_F13; - key_identifier_map[0x6B] = Rml::Core::Input::KI_F14; - key_identifier_map[0x6D] = Rml::Core::Input::KI_F10; - key_identifier_map[0x6F] = Rml::Core::Input::KI_F12; - key_identifier_map[0x71] = Rml::Core::Input::KI_F15; - key_identifier_map[0x73] = Rml::Core::Input::KI_HOME; - key_identifier_map[0x74] = Rml::Core::Input::KI_PRIOR; - key_identifier_map[0x75] = Rml::Core::Input::KI_DELETE; - key_identifier_map[0x76] = Rml::Core::Input::KI_F4; - key_identifier_map[0x77] = Rml::Core::Input::KI_END; - key_identifier_map[0x78] = Rml::Core::Input::KI_F2; - key_identifier_map[0x79] = Rml::Core::Input::KI_NEXT; - key_identifier_map[0x7A] = Rml::Core::Input::KI_F1; - key_identifier_map[0x7B] = Rml::Core::Input::KI_LEFT; - key_identifier_map[0x7C] = Rml::Core::Input::KI_RIGHT; - key_identifier_map[0x7D] = Rml::Core::Input::KI_DOWN; - key_identifier_map[0x7E] = Rml::Core::Input::KI_UP; + key_identifier_map[0x00] = Rml::Input::KI_A; + key_identifier_map[0x01] = Rml::Input::KI_S; + key_identifier_map[0x02] = Rml::Input::KI_D; + key_identifier_map[0x03] = Rml::Input::KI_F; + key_identifier_map[0x04] = Rml::Input::KI_H; + key_identifier_map[0x05] = Rml::Input::KI_G; + key_identifier_map[0x06] = Rml::Input::KI_Z; + key_identifier_map[0x07] = Rml::Input::KI_X; + key_identifier_map[0x08] = Rml::Input::KI_C; + key_identifier_map[0x09] = Rml::Input::KI_V; + key_identifier_map[0x0B] = Rml::Input::KI_B; + key_identifier_map[0x0C] = Rml::Input::KI_Q; + key_identifier_map[0x0D] = Rml::Input::KI_W; + key_identifier_map[0x0E] = Rml::Input::KI_E; + key_identifier_map[0x0F] = Rml::Input::KI_R; + key_identifier_map[0x10] = Rml::Input::KI_Y; + key_identifier_map[0x11] = Rml::Input::KI_T; + key_identifier_map[0x12] = Rml::Input::KI_1; + key_identifier_map[0x13] = Rml::Input::KI_2; + key_identifier_map[0x14] = Rml::Input::KI_3; + key_identifier_map[0x15] = Rml::Input::KI_4; + key_identifier_map[0x16] = Rml::Input::KI_6; + key_identifier_map[0x17] = Rml::Input::KI_5; + key_identifier_map[0x18] = Rml::Input::KI_OEM_PLUS; + key_identifier_map[0x19] = Rml::Input::KI_9; + key_identifier_map[0x1A] = Rml::Input::KI_7; + key_identifier_map[0x1B] = Rml::Input::KI_OEM_MINUS; + key_identifier_map[0x1C] = Rml::Input::KI_8; + key_identifier_map[0x1D] = Rml::Input::KI_0; + key_identifier_map[0x1E] = Rml::Input::KI_OEM_6; + key_identifier_map[0x1F] = Rml::Input::KI_O; + key_identifier_map[0x20] = Rml::Input::KI_U; + key_identifier_map[0x21] = Rml::Input::KI_OEM_4; + key_identifier_map[0x22] = Rml::Input::KI_I; + key_identifier_map[0x23] = Rml::Input::KI_P; + key_identifier_map[0x24] = Rml::Input::KI_RETURN; + key_identifier_map[0x25] = Rml::Input::KI_L; + key_identifier_map[0x26] = Rml::Input::KI_J; + key_identifier_map[0x27] = Rml::Input::KI_OEM_7; + key_identifier_map[0x28] = Rml::Input::KI_K; + key_identifier_map[0x29] = Rml::Input::KI_OEM_1; + key_identifier_map[0x2A] = Rml::Input::KI_OEM_5; + key_identifier_map[0x2B] = Rml::Input::KI_OEM_COMMA; + key_identifier_map[0x2C] = Rml::Input::KI_OEM_2; + key_identifier_map[0x2D] = Rml::Input::KI_N; + key_identifier_map[0x2E] = Rml::Input::KI_M; + key_identifier_map[0x2F] = Rml::Input::KI_OEM_PERIOD; + key_identifier_map[0x30] = Rml::Input::KI_TAB; + key_identifier_map[0x31] = Rml::Input::KI_SPACE; + key_identifier_map[0x32] = Rml::Input::KI_OEM_3; + key_identifier_map[0x33] = Rml::Input::KI_BACK; + key_identifier_map[0x35] = Rml::Input::KI_ESCAPE; + key_identifier_map[0x37] = Rml::Input::KI_LMETA; + key_identifier_map[0x38] = Rml::Input::KI_LSHIFT; + key_identifier_map[0x39] = Rml::Input::KI_CAPITAL; + key_identifier_map[0x3A] = Rml::Input::KI_LMENU; + key_identifier_map[0x3B] = Rml::Input::KI_LCONTROL; + key_identifier_map[0x41] = Rml::Input::KI_DECIMAL; + key_identifier_map[0x43] = Rml::Input::KI_MULTIPLY; + key_identifier_map[0x45] = Rml::Input::KI_ADD; + key_identifier_map[0x4B] = Rml::Input::KI_DIVIDE; + key_identifier_map[0x4C] = Rml::Input::KI_NUMPADENTER; + key_identifier_map[0x4E] = Rml::Input::KI_SUBTRACT; + key_identifier_map[0x51] = Rml::Input::KI_OEM_PLUS; + key_identifier_map[0x52] = Rml::Input::KI_NUMPAD0; + key_identifier_map[0x53] = Rml::Input::KI_NUMPAD1; + key_identifier_map[0x54] = Rml::Input::KI_NUMPAD2; + key_identifier_map[0x55] = Rml::Input::KI_NUMPAD3; + key_identifier_map[0x56] = Rml::Input::KI_NUMPAD4; + key_identifier_map[0x57] = Rml::Input::KI_NUMPAD5; + key_identifier_map[0x58] = Rml::Input::KI_NUMPAD6; + key_identifier_map[0x59] = Rml::Input::KI_NUMPAD7; + key_identifier_map[0x5B] = Rml::Input::KI_NUMPAD8; + key_identifier_map[0x5C] = Rml::Input::KI_NUMPAD9; + key_identifier_map[0x60] = Rml::Input::KI_F5; + key_identifier_map[0x61] = Rml::Input::KI_F6; + key_identifier_map[0x62] = Rml::Input::KI_F7; + key_identifier_map[0x63] = Rml::Input::KI_F3; + key_identifier_map[0x64] = Rml::Input::KI_F8; + key_identifier_map[0x65] = Rml::Input::KI_F9; + key_identifier_map[0x67] = Rml::Input::KI_F11; + key_identifier_map[0x69] = Rml::Input::KI_F13; + key_identifier_map[0x6B] = Rml::Input::KI_F14; + key_identifier_map[0x6D] = Rml::Input::KI_F10; + key_identifier_map[0x6F] = Rml::Input::KI_F12; + key_identifier_map[0x71] = Rml::Input::KI_F15; + key_identifier_map[0x73] = Rml::Input::KI_HOME; + key_identifier_map[0x74] = Rml::Input::KI_PRIOR; + key_identifier_map[0x75] = Rml::Input::KI_DELETE; + key_identifier_map[0x76] = Rml::Input::KI_F4; + key_identifier_map[0x77] = Rml::Input::KI_END; + key_identifier_map[0x78] = Rml::Input::KI_F2; + key_identifier_map[0x79] = Rml::Input::KI_NEXT; + key_identifier_map[0x7A] = Rml::Input::KI_F1; + key_identifier_map[0x7B] = Rml::Input::KI_LEFT; + key_identifier_map[0x7C] = Rml::Input::KI_RIGHT; + key_identifier_map[0x7D] = Rml::Input::KI_DOWN; + key_identifier_map[0x7E] = Rml::Input::KI_UP; } diff --git a/Samples/shell/src/macosx/ShellMacOSX.cpp b/Samples/shell/src/macosx/ShellMacOSX.cpp index 02a07230c..593fe7376 100644 --- a/Samples/shell/src/macosx/ShellMacOSX.cpp +++ b/Samples/shell/src/macosx/ShellMacOSX.cpp @@ -55,7 +55,7 @@ static const EventTypeSpec WINDOW_EVENTS[] = { static WindowRef window; static timeval start_time; -static Rml::Core::String clipboard_text; +static Rml::String clipboard_text; static std::unique_ptr file_interface; @@ -68,10 +68,10 @@ bool Shell::Initialise() InputMacOSX::Initialise(); - Rml::Core::String root = FindSamplesRoot(); + Rml::String root = FindSamplesRoot(); file_interface = std::make_unique(root); - Rml::Core::SetFileInterface(file_interface.get()); + Rml::SetFileInterface(file_interface.get()); return true; } @@ -81,9 +81,9 @@ void Shell::Shutdown() file_interface.reset(); } -Rml::Core::String Shell::FindSamplesRoot() +Rml::String Shell::FindSamplesRoot() { - Rml::Core::String path = "../../Samples/"; + Rml::String path = "../../Samples/"; // Find the location of the executable. CFBundleRef bundle = CFBundleGetMainBundle(); @@ -94,7 +94,7 @@ Rml::Core::String Shell::FindSamplesRoot() if (!CFStringGetFileSystemRepresentation(executable_posix_file_name, executable_file_name, max_length)) executable_file_name[0] = 0; - Rml::Core::String executable_path = Rml::Core::String(executable_file_name); + Rml::String executable_path = Rml::String(executable_file_name); executable_path = executable_path.substr(0, executable_path.rfind("/") + 1); delete[] executable_file_name; @@ -252,19 +252,19 @@ double Shell::GetElapsedTime() return result; } -void Shell::SetMouseCursor(const Rml::Core::String& cursor_name) +void Shell::SetMouseCursor(const Rml::String& cursor_name) { // Not implemented } -void Shell::SetClipboardText(const Rml::Core::String& text) +void Shell::SetClipboardText(const Rml::String& text) { // Todo: interface with system clipboard clipboard_text = text; } -void Shell::GetClipboardText(Rml::Core::String& text) +void Shell::GetClipboardText(Rml::String& text) { // Todo: interface with system clipboard text = clipboard_text; diff --git a/Samples/shell/src/macosx/ShellRenderInterfaceExtensionsOpenGL_MacOSX.cpp b/Samples/shell/src/macosx/ShellRenderInterfaceExtensionsOpenGL_MacOSX.cpp index d768c414e..818df6ea2 100644 --- a/Samples/shell/src/macosx/ShellRenderInterfaceExtensionsOpenGL_MacOSX.cpp +++ b/Samples/shell/src/macosx/ShellRenderInterfaceExtensionsOpenGL_MacOSX.cpp @@ -41,16 +41,16 @@ void ShellRenderInterfaceOpenGL::SetContext(void *context) void ShellRenderInterfaceOpenGL::SetViewport(int width, int height) { if(m_width != width || m_height != height) { - Rml::Core::Matrix4f projection, view; + Rml::Matrix4f projection, view; m_width = width; m_height = height; glViewport(0, 0, width, height); - projection = Rml::Core::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); + projection = Rml::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); glMatrixMode(GL_PROJECTION); glLoadMatrixf(projection); - view = Rml::Core::Matrix4f::Identity(); + view = Rml::Matrix4f::Identity(); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(view); @@ -58,7 +58,7 @@ void ShellRenderInterfaceOpenGL::SetViewport(int width, int height) if(m_rmlui_context != nullptr) { - ((Rml::Core::Context*)m_rmlui_context)->SetDimensions(Rml::Core::Vector2i(width, height)); + ((Rml::Context*)m_rmlui_context)->SetDimensions(Rml::Vector2i(width, height)); } } } diff --git a/Samples/shell/src/win32/InputWin32.cpp b/Samples/shell/src/win32/InputWin32.cpp index 96e0ed2c2..0ce26c283 100644 --- a/Samples/shell/src/win32/InputWin32.cpp +++ b/Samples/shell/src/win32/InputWin32.cpp @@ -38,7 +38,7 @@ static int GetKeyModifierState(); static void InitialiseKeymap(); static const int KEYMAP_SIZE = 256; -static Rml::Core::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; +static Rml::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; bool InputWin32::Initialise() { @@ -92,11 +92,11 @@ void InputWin32::ProcessWindowsEvent(UINT message, WPARAM w_param, LPARAM l_para case WM_KEYDOWN: { - Rml::Core::Input::KeyIdentifier key_identifier = key_identifier_map[w_param]; + Rml::Input::KeyIdentifier key_identifier = key_identifier_map[w_param]; int key_modifier_state = GetKeyModifierState(); // Check for F8 to toggle the debugger. - if (key_identifier == Rml::Core::Input::KI_F8) + if (key_identifier == Rml::Input::KI_F8) { Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible()); break; @@ -112,7 +112,7 @@ void InputWin32::ProcessWindowsEvent(UINT message, WPARAM w_param, LPARAM l_para static char16_t first_u16_code_unit = 0; char16_t c = (char16_t)w_param; - Rml::Core::Character character = (Rml::Core::Character)c; + Rml::Character character = (Rml::Character)c; // Windows sends two-wide characters as two messages. if (c >= 0xD800 && c < 0xDC00) @@ -125,19 +125,19 @@ void InputWin32::ProcessWindowsEvent(UINT message, WPARAM w_param, LPARAM l_para if (c >= 0xDC00 && c < 0xE000 && first_u16_code_unit != 0) { // Second 16-bit code unit of a two-wide character. - Rml::Core::String utf8 = Rml::Core::StringUtilities::ToUTF8({ first_u16_code_unit, c }); - character = Rml::Core::StringUtilities::ToCharacter(utf8.data()); + Rml::String utf8 = Rml::StringUtilities::ToUTF8({ first_u16_code_unit, c }); + character = Rml::StringUtilities::ToCharacter(utf8.data()); } else if (c == '\r') { // Windows sends new-lines as carriage returns, convert to endlines. - character = (Rml::Core::Character)'\n'; + character = (Rml::Character)'\n'; } first_u16_code_unit = 0; // Only send through printable characters. - if (((char32_t)character >= 32 || character == (Rml::Core::Character)'\n') && character != (Rml::Core::Character)127) + if (((char32_t)character >= 32 || character == (Rml::Character)'\n') && character != (Rml::Character)127) context->ProcessTextInput(character); } } @@ -156,27 +156,27 @@ static int GetKeyModifierState() // Query the state of all modifier keys if (GetKeyState(VK_CAPITAL) & 1) { - key_modifier_state |= Rml::Core::Input::KM_CAPSLOCK; + key_modifier_state |= Rml::Input::KM_CAPSLOCK; } if (HIWORD(GetKeyState(VK_SHIFT)) & 1) { - key_modifier_state |= Rml::Core::Input::KM_SHIFT; + key_modifier_state |= Rml::Input::KM_SHIFT; } if (GetKeyState(VK_NUMLOCK) & 1) { - key_modifier_state |= Rml::Core::Input::KM_NUMLOCK; + key_modifier_state |= Rml::Input::KM_NUMLOCK; } if (HIWORD(GetKeyState(VK_CONTROL)) & 1) { - key_modifier_state |= Rml::Core::Input::KM_CTRL; + key_modifier_state |= Rml::Input::KM_CTRL; } if (HIWORD(GetKeyState(VK_MENU)) & 1) { - key_modifier_state |= Rml::Core::Input::KM_ALT; + key_modifier_state |= Rml::Input::KM_ALT; } return key_modifier_state; @@ -203,195 +203,195 @@ static void InitialiseKeymap() memset(key_identifier_map, 0, sizeof(key_identifier_map)); // Assign individual values. - key_identifier_map['A'] = Rml::Core::Input::KI_A; - key_identifier_map['B'] = Rml::Core::Input::KI_B; - key_identifier_map['C'] = Rml::Core::Input::KI_C; - key_identifier_map['D'] = Rml::Core::Input::KI_D; - key_identifier_map['E'] = Rml::Core::Input::KI_E; - key_identifier_map['F'] = Rml::Core::Input::KI_F; - key_identifier_map['G'] = Rml::Core::Input::KI_G; - key_identifier_map['H'] = Rml::Core::Input::KI_H; - key_identifier_map['I'] = Rml::Core::Input::KI_I; - key_identifier_map['J'] = Rml::Core::Input::KI_J; - key_identifier_map['K'] = Rml::Core::Input::KI_K; - key_identifier_map['L'] = Rml::Core::Input::KI_L; - key_identifier_map['M'] = Rml::Core::Input::KI_M; - key_identifier_map['N'] = Rml::Core::Input::KI_N; - key_identifier_map['O'] = Rml::Core::Input::KI_O; - key_identifier_map['P'] = Rml::Core::Input::KI_P; - key_identifier_map['Q'] = Rml::Core::Input::KI_Q; - key_identifier_map['R'] = Rml::Core::Input::KI_R; - key_identifier_map['S'] = Rml::Core::Input::KI_S; - key_identifier_map['T'] = Rml::Core::Input::KI_T; - key_identifier_map['U'] = Rml::Core::Input::KI_U; - key_identifier_map['V'] = Rml::Core::Input::KI_V; - key_identifier_map['W'] = Rml::Core::Input::KI_W; - key_identifier_map['X'] = Rml::Core::Input::KI_X; - key_identifier_map['Y'] = Rml::Core::Input::KI_Y; - key_identifier_map['Z'] = Rml::Core::Input::KI_Z; - - key_identifier_map['0'] = Rml::Core::Input::KI_0; - key_identifier_map['1'] = Rml::Core::Input::KI_1; - key_identifier_map['2'] = Rml::Core::Input::KI_2; - key_identifier_map['3'] = Rml::Core::Input::KI_3; - key_identifier_map['4'] = Rml::Core::Input::KI_4; - key_identifier_map['5'] = Rml::Core::Input::KI_5; - key_identifier_map['6'] = Rml::Core::Input::KI_6; - key_identifier_map['7'] = Rml::Core::Input::KI_7; - key_identifier_map['8'] = Rml::Core::Input::KI_8; - key_identifier_map['9'] = Rml::Core::Input::KI_9; - - key_identifier_map[VK_BACK] = Rml::Core::Input::KI_BACK; - key_identifier_map[VK_TAB] = Rml::Core::Input::KI_TAB; - - key_identifier_map[VK_CLEAR] = Rml::Core::Input::KI_CLEAR; - key_identifier_map[VK_RETURN] = Rml::Core::Input::KI_RETURN; - - key_identifier_map[VK_PAUSE] = Rml::Core::Input::KI_PAUSE; - key_identifier_map[VK_CAPITAL] = Rml::Core::Input::KI_CAPITAL; - - key_identifier_map[VK_KANA] = Rml::Core::Input::KI_KANA; - key_identifier_map[VK_HANGUL] = Rml::Core::Input::KI_HANGUL; - key_identifier_map[VK_JUNJA] = Rml::Core::Input::KI_JUNJA; - key_identifier_map[VK_FINAL] = Rml::Core::Input::KI_FINAL; - key_identifier_map[VK_HANJA] = Rml::Core::Input::KI_HANJA; - key_identifier_map[VK_KANJI] = Rml::Core::Input::KI_KANJI; - - key_identifier_map[VK_ESCAPE] = Rml::Core::Input::KI_ESCAPE; - - key_identifier_map[VK_CONVERT] = Rml::Core::Input::KI_CONVERT; - key_identifier_map[VK_NONCONVERT] = Rml::Core::Input::KI_NONCONVERT; - key_identifier_map[VK_ACCEPT] = Rml::Core::Input::KI_ACCEPT; - key_identifier_map[VK_MODECHANGE] = Rml::Core::Input::KI_MODECHANGE; - - key_identifier_map[VK_SPACE] = Rml::Core::Input::KI_SPACE; - key_identifier_map[VK_PRIOR] = Rml::Core::Input::KI_PRIOR; - key_identifier_map[VK_NEXT] = Rml::Core::Input::KI_NEXT; - key_identifier_map[VK_END] = Rml::Core::Input::KI_END; - key_identifier_map[VK_HOME] = Rml::Core::Input::KI_HOME; - key_identifier_map[VK_LEFT] = Rml::Core::Input::KI_LEFT; - key_identifier_map[VK_UP] = Rml::Core::Input::KI_UP; - key_identifier_map[VK_RIGHT] = Rml::Core::Input::KI_RIGHT; - key_identifier_map[VK_DOWN] = Rml::Core::Input::KI_DOWN; - key_identifier_map[VK_SELECT] = Rml::Core::Input::KI_SELECT; - key_identifier_map[VK_PRINT] = Rml::Core::Input::KI_PRINT; - key_identifier_map[VK_EXECUTE] = Rml::Core::Input::KI_EXECUTE; - key_identifier_map[VK_SNAPSHOT] = Rml::Core::Input::KI_SNAPSHOT; - key_identifier_map[VK_INSERT] = Rml::Core::Input::KI_INSERT; - key_identifier_map[VK_DELETE] = Rml::Core::Input::KI_DELETE; - key_identifier_map[VK_HELP] = Rml::Core::Input::KI_HELP; - - key_identifier_map[VK_LWIN] = Rml::Core::Input::KI_LWIN; - key_identifier_map[VK_RWIN] = Rml::Core::Input::KI_RWIN; - key_identifier_map[VK_APPS] = Rml::Core::Input::KI_APPS; - - key_identifier_map[VK_SLEEP] = Rml::Core::Input::KI_SLEEP; - - key_identifier_map[VK_NUMPAD0] = Rml::Core::Input::KI_NUMPAD0; - key_identifier_map[VK_NUMPAD1] = Rml::Core::Input::KI_NUMPAD1; - key_identifier_map[VK_NUMPAD2] = Rml::Core::Input::KI_NUMPAD2; - key_identifier_map[VK_NUMPAD3] = Rml::Core::Input::KI_NUMPAD3; - key_identifier_map[VK_NUMPAD4] = Rml::Core::Input::KI_NUMPAD4; - key_identifier_map[VK_NUMPAD5] = Rml::Core::Input::KI_NUMPAD5; - key_identifier_map[VK_NUMPAD6] = Rml::Core::Input::KI_NUMPAD6; - key_identifier_map[VK_NUMPAD7] = Rml::Core::Input::KI_NUMPAD7; - key_identifier_map[VK_NUMPAD8] = Rml::Core::Input::KI_NUMPAD8; - key_identifier_map[VK_NUMPAD9] = Rml::Core::Input::KI_NUMPAD9; - key_identifier_map[VK_MULTIPLY] = Rml::Core::Input::KI_MULTIPLY; - key_identifier_map[VK_ADD] = Rml::Core::Input::KI_ADD; - key_identifier_map[VK_SEPARATOR] = Rml::Core::Input::KI_SEPARATOR; - key_identifier_map[VK_SUBTRACT] = Rml::Core::Input::KI_SUBTRACT; - key_identifier_map[VK_DECIMAL] = Rml::Core::Input::KI_DECIMAL; - key_identifier_map[VK_DIVIDE] = Rml::Core::Input::KI_DIVIDE; - key_identifier_map[VK_F1] = Rml::Core::Input::KI_F1; - key_identifier_map[VK_F2] = Rml::Core::Input::KI_F2; - key_identifier_map[VK_F3] = Rml::Core::Input::KI_F3; - key_identifier_map[VK_F4] = Rml::Core::Input::KI_F4; - key_identifier_map[VK_F5] = Rml::Core::Input::KI_F5; - key_identifier_map[VK_F6] = Rml::Core::Input::KI_F6; - key_identifier_map[VK_F7] = Rml::Core::Input::KI_F7; - key_identifier_map[VK_F8] = Rml::Core::Input::KI_F8; - key_identifier_map[VK_F9] = Rml::Core::Input::KI_F9; - key_identifier_map[VK_F10] = Rml::Core::Input::KI_F10; - key_identifier_map[VK_F11] = Rml::Core::Input::KI_F11; - key_identifier_map[VK_F12] = Rml::Core::Input::KI_F12; - key_identifier_map[VK_F13] = Rml::Core::Input::KI_F13; - key_identifier_map[VK_F14] = Rml::Core::Input::KI_F14; - key_identifier_map[VK_F15] = Rml::Core::Input::KI_F15; - key_identifier_map[VK_F16] = Rml::Core::Input::KI_F16; - key_identifier_map[VK_F17] = Rml::Core::Input::KI_F17; - key_identifier_map[VK_F18] = Rml::Core::Input::KI_F18; - key_identifier_map[VK_F19] = Rml::Core::Input::KI_F19; - key_identifier_map[VK_F20] = Rml::Core::Input::KI_F20; - key_identifier_map[VK_F21] = Rml::Core::Input::KI_F21; - key_identifier_map[VK_F22] = Rml::Core::Input::KI_F22; - key_identifier_map[VK_F23] = Rml::Core::Input::KI_F23; - key_identifier_map[VK_F24] = Rml::Core::Input::KI_F24; - - key_identifier_map[VK_NUMLOCK] = Rml::Core::Input::KI_NUMLOCK; - key_identifier_map[VK_SCROLL] = Rml::Core::Input::KI_SCROLL; - - key_identifier_map[VK_OEM_NEC_EQUAL] = Rml::Core::Input::KI_OEM_NEC_EQUAL; - - key_identifier_map[VK_OEM_FJ_JISHO] = Rml::Core::Input::KI_OEM_FJ_JISHO; - key_identifier_map[VK_OEM_FJ_MASSHOU] = Rml::Core::Input::KI_OEM_FJ_MASSHOU; - key_identifier_map[VK_OEM_FJ_TOUROKU] = Rml::Core::Input::KI_OEM_FJ_TOUROKU; - key_identifier_map[VK_OEM_FJ_LOYA] = Rml::Core::Input::KI_OEM_FJ_LOYA; - key_identifier_map[VK_OEM_FJ_ROYA] = Rml::Core::Input::KI_OEM_FJ_ROYA; - - key_identifier_map[VK_SHIFT] = Rml::Core::Input::KI_LSHIFT; - key_identifier_map[VK_CONTROL] = Rml::Core::Input::KI_LCONTROL; - key_identifier_map[VK_MENU] = Rml::Core::Input::KI_LMENU; - - key_identifier_map[VK_BROWSER_BACK] = Rml::Core::Input::KI_BROWSER_BACK; - key_identifier_map[VK_BROWSER_FORWARD] = Rml::Core::Input::KI_BROWSER_FORWARD; - key_identifier_map[VK_BROWSER_REFRESH] = Rml::Core::Input::KI_BROWSER_REFRESH; - key_identifier_map[VK_BROWSER_STOP] = Rml::Core::Input::KI_BROWSER_STOP; - key_identifier_map[VK_BROWSER_SEARCH] = Rml::Core::Input::KI_BROWSER_SEARCH; - key_identifier_map[VK_BROWSER_FAVORITES] = Rml::Core::Input::KI_BROWSER_FAVORITES; - key_identifier_map[VK_BROWSER_HOME] = Rml::Core::Input::KI_BROWSER_HOME; - - key_identifier_map[VK_VOLUME_MUTE] = Rml::Core::Input::KI_VOLUME_MUTE; - key_identifier_map[VK_VOLUME_DOWN] = Rml::Core::Input::KI_VOLUME_DOWN; - key_identifier_map[VK_VOLUME_UP] = Rml::Core::Input::KI_VOLUME_UP; - key_identifier_map[VK_MEDIA_NEXT_TRACK] = Rml::Core::Input::KI_MEDIA_NEXT_TRACK; - key_identifier_map[VK_MEDIA_PREV_TRACK] = Rml::Core::Input::KI_MEDIA_PREV_TRACK; - key_identifier_map[VK_MEDIA_STOP] = Rml::Core::Input::KI_MEDIA_STOP; - key_identifier_map[VK_MEDIA_PLAY_PAUSE] = Rml::Core::Input::KI_MEDIA_PLAY_PAUSE; - key_identifier_map[VK_LAUNCH_MAIL] = Rml::Core::Input::KI_LAUNCH_MAIL; - key_identifier_map[VK_LAUNCH_MEDIA_SELECT] = Rml::Core::Input::KI_LAUNCH_MEDIA_SELECT; - key_identifier_map[VK_LAUNCH_APP1] = Rml::Core::Input::KI_LAUNCH_APP1; - key_identifier_map[VK_LAUNCH_APP2] = Rml::Core::Input::KI_LAUNCH_APP2; - - key_identifier_map[VK_OEM_1] = Rml::Core::Input::KI_OEM_1; - key_identifier_map[VK_OEM_PLUS] = Rml::Core::Input::KI_OEM_PLUS; - key_identifier_map[VK_OEM_COMMA] = Rml::Core::Input::KI_OEM_COMMA; - key_identifier_map[VK_OEM_MINUS] = Rml::Core::Input::KI_OEM_MINUS; - key_identifier_map[VK_OEM_PERIOD] = Rml::Core::Input::KI_OEM_PERIOD; - key_identifier_map[VK_OEM_2] = Rml::Core::Input::KI_OEM_2; - key_identifier_map[VK_OEM_3] = Rml::Core::Input::KI_OEM_3; - - key_identifier_map[VK_OEM_4] = Rml::Core::Input::KI_OEM_4; - key_identifier_map[VK_OEM_5] = Rml::Core::Input::KI_OEM_5; - key_identifier_map[VK_OEM_6] = Rml::Core::Input::KI_OEM_6; - key_identifier_map[VK_OEM_7] = Rml::Core::Input::KI_OEM_7; - key_identifier_map[VK_OEM_8] = Rml::Core::Input::KI_OEM_8; - - key_identifier_map[VK_OEM_AX] = Rml::Core::Input::KI_OEM_AX; - key_identifier_map[VK_OEM_102] = Rml::Core::Input::KI_OEM_102; - key_identifier_map[VK_ICO_HELP] = Rml::Core::Input::KI_ICO_HELP; - key_identifier_map[VK_ICO_00] = Rml::Core::Input::KI_ICO_00; - - key_identifier_map[VK_PROCESSKEY] = Rml::Core::Input::KI_PROCESSKEY; - - key_identifier_map[VK_ICO_CLEAR] = Rml::Core::Input::KI_ICO_CLEAR; - - key_identifier_map[VK_ATTN] = Rml::Core::Input::KI_ATTN; - key_identifier_map[VK_CRSEL] = Rml::Core::Input::KI_CRSEL; - key_identifier_map[VK_EXSEL] = Rml::Core::Input::KI_EXSEL; - key_identifier_map[VK_EREOF] = Rml::Core::Input::KI_EREOF; - key_identifier_map[VK_PLAY] = Rml::Core::Input::KI_PLAY; - key_identifier_map[VK_ZOOM] = Rml::Core::Input::KI_ZOOM; - key_identifier_map[VK_PA1] = Rml::Core::Input::KI_PA1; - key_identifier_map[VK_OEM_CLEAR] = Rml::Core::Input::KI_OEM_CLEAR; + key_identifier_map['A'] = Rml::Input::KI_A; + key_identifier_map['B'] = Rml::Input::KI_B; + key_identifier_map['C'] = Rml::Input::KI_C; + key_identifier_map['D'] = Rml::Input::KI_D; + key_identifier_map['E'] = Rml::Input::KI_E; + key_identifier_map['F'] = Rml::Input::KI_F; + key_identifier_map['G'] = Rml::Input::KI_G; + key_identifier_map['H'] = Rml::Input::KI_H; + key_identifier_map['I'] = Rml::Input::KI_I; + key_identifier_map['J'] = Rml::Input::KI_J; + key_identifier_map['K'] = Rml::Input::KI_K; + key_identifier_map['L'] = Rml::Input::KI_L; + key_identifier_map['M'] = Rml::Input::KI_M; + key_identifier_map['N'] = Rml::Input::KI_N; + key_identifier_map['O'] = Rml::Input::KI_O; + key_identifier_map['P'] = Rml::Input::KI_P; + key_identifier_map['Q'] = Rml::Input::KI_Q; + key_identifier_map['R'] = Rml::Input::KI_R; + key_identifier_map['S'] = Rml::Input::KI_S; + key_identifier_map['T'] = Rml::Input::KI_T; + key_identifier_map['U'] = Rml::Input::KI_U; + key_identifier_map['V'] = Rml::Input::KI_V; + key_identifier_map['W'] = Rml::Input::KI_W; + key_identifier_map['X'] = Rml::Input::KI_X; + key_identifier_map['Y'] = Rml::Input::KI_Y; + key_identifier_map['Z'] = Rml::Input::KI_Z; + + key_identifier_map['0'] = Rml::Input::KI_0; + key_identifier_map['1'] = Rml::Input::KI_1; + key_identifier_map['2'] = Rml::Input::KI_2; + key_identifier_map['3'] = Rml::Input::KI_3; + key_identifier_map['4'] = Rml::Input::KI_4; + key_identifier_map['5'] = Rml::Input::KI_5; + key_identifier_map['6'] = Rml::Input::KI_6; + key_identifier_map['7'] = Rml::Input::KI_7; + key_identifier_map['8'] = Rml::Input::KI_8; + key_identifier_map['9'] = Rml::Input::KI_9; + + key_identifier_map[VK_BACK] = Rml::Input::KI_BACK; + key_identifier_map[VK_TAB] = Rml::Input::KI_TAB; + + key_identifier_map[VK_CLEAR] = Rml::Input::KI_CLEAR; + key_identifier_map[VK_RETURN] = Rml::Input::KI_RETURN; + + key_identifier_map[VK_PAUSE] = Rml::Input::KI_PAUSE; + key_identifier_map[VK_CAPITAL] = Rml::Input::KI_CAPITAL; + + key_identifier_map[VK_KANA] = Rml::Input::KI_KANA; + key_identifier_map[VK_HANGUL] = Rml::Input::KI_HANGUL; + key_identifier_map[VK_JUNJA] = Rml::Input::KI_JUNJA; + key_identifier_map[VK_FINAL] = Rml::Input::KI_FINAL; + key_identifier_map[VK_HANJA] = Rml::Input::KI_HANJA; + key_identifier_map[VK_KANJI] = Rml::Input::KI_KANJI; + + key_identifier_map[VK_ESCAPE] = Rml::Input::KI_ESCAPE; + + key_identifier_map[VK_CONVERT] = Rml::Input::KI_CONVERT; + key_identifier_map[VK_NONCONVERT] = Rml::Input::KI_NONCONVERT; + key_identifier_map[VK_ACCEPT] = Rml::Input::KI_ACCEPT; + key_identifier_map[VK_MODECHANGE] = Rml::Input::KI_MODECHANGE; + + key_identifier_map[VK_SPACE] = Rml::Input::KI_SPACE; + key_identifier_map[VK_PRIOR] = Rml::Input::KI_PRIOR; + key_identifier_map[VK_NEXT] = Rml::Input::KI_NEXT; + key_identifier_map[VK_END] = Rml::Input::KI_END; + key_identifier_map[VK_HOME] = Rml::Input::KI_HOME; + key_identifier_map[VK_LEFT] = Rml::Input::KI_LEFT; + key_identifier_map[VK_UP] = Rml::Input::KI_UP; + key_identifier_map[VK_RIGHT] = Rml::Input::KI_RIGHT; + key_identifier_map[VK_DOWN] = Rml::Input::KI_DOWN; + key_identifier_map[VK_SELECT] = Rml::Input::KI_SELECT; + key_identifier_map[VK_PRINT] = Rml::Input::KI_PRINT; + key_identifier_map[VK_EXECUTE] = Rml::Input::KI_EXECUTE; + key_identifier_map[VK_SNAPSHOT] = Rml::Input::KI_SNAPSHOT; + key_identifier_map[VK_INSERT] = Rml::Input::KI_INSERT; + key_identifier_map[VK_DELETE] = Rml::Input::KI_DELETE; + key_identifier_map[VK_HELP] = Rml::Input::KI_HELP; + + key_identifier_map[VK_LWIN] = Rml::Input::KI_LWIN; + key_identifier_map[VK_RWIN] = Rml::Input::KI_RWIN; + key_identifier_map[VK_APPS] = Rml::Input::KI_APPS; + + key_identifier_map[VK_SLEEP] = Rml::Input::KI_SLEEP; + + key_identifier_map[VK_NUMPAD0] = Rml::Input::KI_NUMPAD0; + key_identifier_map[VK_NUMPAD1] = Rml::Input::KI_NUMPAD1; + key_identifier_map[VK_NUMPAD2] = Rml::Input::KI_NUMPAD2; + key_identifier_map[VK_NUMPAD3] = Rml::Input::KI_NUMPAD3; + key_identifier_map[VK_NUMPAD4] = Rml::Input::KI_NUMPAD4; + key_identifier_map[VK_NUMPAD5] = Rml::Input::KI_NUMPAD5; + key_identifier_map[VK_NUMPAD6] = Rml::Input::KI_NUMPAD6; + key_identifier_map[VK_NUMPAD7] = Rml::Input::KI_NUMPAD7; + key_identifier_map[VK_NUMPAD8] = Rml::Input::KI_NUMPAD8; + key_identifier_map[VK_NUMPAD9] = Rml::Input::KI_NUMPAD9; + key_identifier_map[VK_MULTIPLY] = Rml::Input::KI_MULTIPLY; + key_identifier_map[VK_ADD] = Rml::Input::KI_ADD; + key_identifier_map[VK_SEPARATOR] = Rml::Input::KI_SEPARATOR; + key_identifier_map[VK_SUBTRACT] = Rml::Input::KI_SUBTRACT; + key_identifier_map[VK_DECIMAL] = Rml::Input::KI_DECIMAL; + key_identifier_map[VK_DIVIDE] = Rml::Input::KI_DIVIDE; + key_identifier_map[VK_F1] = Rml::Input::KI_F1; + key_identifier_map[VK_F2] = Rml::Input::KI_F2; + key_identifier_map[VK_F3] = Rml::Input::KI_F3; + key_identifier_map[VK_F4] = Rml::Input::KI_F4; + key_identifier_map[VK_F5] = Rml::Input::KI_F5; + key_identifier_map[VK_F6] = Rml::Input::KI_F6; + key_identifier_map[VK_F7] = Rml::Input::KI_F7; + key_identifier_map[VK_F8] = Rml::Input::KI_F8; + key_identifier_map[VK_F9] = Rml::Input::KI_F9; + key_identifier_map[VK_F10] = Rml::Input::KI_F10; + key_identifier_map[VK_F11] = Rml::Input::KI_F11; + key_identifier_map[VK_F12] = Rml::Input::KI_F12; + key_identifier_map[VK_F13] = Rml::Input::KI_F13; + key_identifier_map[VK_F14] = Rml::Input::KI_F14; + key_identifier_map[VK_F15] = Rml::Input::KI_F15; + key_identifier_map[VK_F16] = Rml::Input::KI_F16; + key_identifier_map[VK_F17] = Rml::Input::KI_F17; + key_identifier_map[VK_F18] = Rml::Input::KI_F18; + key_identifier_map[VK_F19] = Rml::Input::KI_F19; + key_identifier_map[VK_F20] = Rml::Input::KI_F20; + key_identifier_map[VK_F21] = Rml::Input::KI_F21; + key_identifier_map[VK_F22] = Rml::Input::KI_F22; + key_identifier_map[VK_F23] = Rml::Input::KI_F23; + key_identifier_map[VK_F24] = Rml::Input::KI_F24; + + key_identifier_map[VK_NUMLOCK] = Rml::Input::KI_NUMLOCK; + key_identifier_map[VK_SCROLL] = Rml::Input::KI_SCROLL; + + key_identifier_map[VK_OEM_NEC_EQUAL] = Rml::Input::KI_OEM_NEC_EQUAL; + + key_identifier_map[VK_OEM_FJ_JISHO] = Rml::Input::KI_OEM_FJ_JISHO; + key_identifier_map[VK_OEM_FJ_MASSHOU] = Rml::Input::KI_OEM_FJ_MASSHOU; + key_identifier_map[VK_OEM_FJ_TOUROKU] = Rml::Input::KI_OEM_FJ_TOUROKU; + key_identifier_map[VK_OEM_FJ_LOYA] = Rml::Input::KI_OEM_FJ_LOYA; + key_identifier_map[VK_OEM_FJ_ROYA] = Rml::Input::KI_OEM_FJ_ROYA; + + key_identifier_map[VK_SHIFT] = Rml::Input::KI_LSHIFT; + key_identifier_map[VK_CONTROL] = Rml::Input::KI_LCONTROL; + key_identifier_map[VK_MENU] = Rml::Input::KI_LMENU; + + key_identifier_map[VK_BROWSER_BACK] = Rml::Input::KI_BROWSER_BACK; + key_identifier_map[VK_BROWSER_FORWARD] = Rml::Input::KI_BROWSER_FORWARD; + key_identifier_map[VK_BROWSER_REFRESH] = Rml::Input::KI_BROWSER_REFRESH; + key_identifier_map[VK_BROWSER_STOP] = Rml::Input::KI_BROWSER_STOP; + key_identifier_map[VK_BROWSER_SEARCH] = Rml::Input::KI_BROWSER_SEARCH; + key_identifier_map[VK_BROWSER_FAVORITES] = Rml::Input::KI_BROWSER_FAVORITES; + key_identifier_map[VK_BROWSER_HOME] = Rml::Input::KI_BROWSER_HOME; + + key_identifier_map[VK_VOLUME_MUTE] = Rml::Input::KI_VOLUME_MUTE; + key_identifier_map[VK_VOLUME_DOWN] = Rml::Input::KI_VOLUME_DOWN; + key_identifier_map[VK_VOLUME_UP] = Rml::Input::KI_VOLUME_UP; + key_identifier_map[VK_MEDIA_NEXT_TRACK] = Rml::Input::KI_MEDIA_NEXT_TRACK; + key_identifier_map[VK_MEDIA_PREV_TRACK] = Rml::Input::KI_MEDIA_PREV_TRACK; + key_identifier_map[VK_MEDIA_STOP] = Rml::Input::KI_MEDIA_STOP; + key_identifier_map[VK_MEDIA_PLAY_PAUSE] = Rml::Input::KI_MEDIA_PLAY_PAUSE; + key_identifier_map[VK_LAUNCH_MAIL] = Rml::Input::KI_LAUNCH_MAIL; + key_identifier_map[VK_LAUNCH_MEDIA_SELECT] = Rml::Input::KI_LAUNCH_MEDIA_SELECT; + key_identifier_map[VK_LAUNCH_APP1] = Rml::Input::KI_LAUNCH_APP1; + key_identifier_map[VK_LAUNCH_APP2] = Rml::Input::KI_LAUNCH_APP2; + + key_identifier_map[VK_OEM_1] = Rml::Input::KI_OEM_1; + key_identifier_map[VK_OEM_PLUS] = Rml::Input::KI_OEM_PLUS; + key_identifier_map[VK_OEM_COMMA] = Rml::Input::KI_OEM_COMMA; + key_identifier_map[VK_OEM_MINUS] = Rml::Input::KI_OEM_MINUS; + key_identifier_map[VK_OEM_PERIOD] = Rml::Input::KI_OEM_PERIOD; + key_identifier_map[VK_OEM_2] = Rml::Input::KI_OEM_2; + key_identifier_map[VK_OEM_3] = Rml::Input::KI_OEM_3; + + key_identifier_map[VK_OEM_4] = Rml::Input::KI_OEM_4; + key_identifier_map[VK_OEM_5] = Rml::Input::KI_OEM_5; + key_identifier_map[VK_OEM_6] = Rml::Input::KI_OEM_6; + key_identifier_map[VK_OEM_7] = Rml::Input::KI_OEM_7; + key_identifier_map[VK_OEM_8] = Rml::Input::KI_OEM_8; + + key_identifier_map[VK_OEM_AX] = Rml::Input::KI_OEM_AX; + key_identifier_map[VK_OEM_102] = Rml::Input::KI_OEM_102; + key_identifier_map[VK_ICO_HELP] = Rml::Input::KI_ICO_HELP; + key_identifier_map[VK_ICO_00] = Rml::Input::KI_ICO_00; + + key_identifier_map[VK_PROCESSKEY] = Rml::Input::KI_PROCESSKEY; + + key_identifier_map[VK_ICO_CLEAR] = Rml::Input::KI_ICO_CLEAR; + + key_identifier_map[VK_ATTN] = Rml::Input::KI_ATTN; + key_identifier_map[VK_CRSEL] = Rml::Input::KI_CRSEL; + key_identifier_map[VK_EXSEL] = Rml::Input::KI_EXSEL; + key_identifier_map[VK_EREOF] = Rml::Input::KI_EREOF; + key_identifier_map[VK_PLAY] = Rml::Input::KI_PLAY; + key_identifier_map[VK_ZOOM] = Rml::Input::KI_ZOOM; + key_identifier_map[VK_PA1] = Rml::Input::KI_PA1; + key_identifier_map[VK_OEM_CLEAR] = Rml::Input::KI_OEM_CLEAR; } diff --git a/Samples/shell/src/win32/ShellRenderInterfaceExtensionsOpenGL_Win32.cpp b/Samples/shell/src/win32/ShellRenderInterfaceExtensionsOpenGL_Win32.cpp index fa02b0279..eb3140cb2 100644 --- a/Samples/shell/src/win32/ShellRenderInterfaceExtensionsOpenGL_Win32.cpp +++ b/Samples/shell/src/win32/ShellRenderInterfaceExtensionsOpenGL_Win32.cpp @@ -44,22 +44,22 @@ void ShellRenderInterfaceOpenGL::SetContext(void *context) void ShellRenderInterfaceOpenGL::SetViewport(int width, int height) { if(m_width != width || m_height != height) { - Rml::Core::Matrix4f projection, view; + Rml::Matrix4f projection, view; m_width = width; m_height = height; glViewport(0, 0, width, height); - projection = Rml::Core::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); + projection = Rml::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); glMatrixMode(GL_PROJECTION); glLoadMatrixf(projection.data()); - view = Rml::Core::Matrix4f::Identity(); + view = Rml::Matrix4f::Identity(); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(view.data()); if(m_rmlui_context != nullptr) { - ((Rml::Core::Context*)m_rmlui_context)->SetDimensions(Rml::Core::Vector2i(width, height)); + ((Rml::Context*)m_rmlui_context)->SetDimensions(Rml::Vector2i(width, height)); } } } diff --git a/Samples/shell/src/win32/ShellWin32.cpp b/Samples/shell/src/win32/ShellWin32.cpp index 3687d82a6..86e7b7b4e 100644 --- a/Samples/shell/src/win32/ShellWin32.cpp +++ b/Samples/shell/src/win32/ShellWin32.cpp @@ -40,7 +40,7 @@ static LRESULT CALLBACK WindowProcedure(HWND window_handle, UINT message, WPARAM static bool activated = true; static bool running = false; -static Rml::Core::U16String instance_name; +static Rml::U16String instance_name; static HWND window_handle = nullptr; static HINSTANCE instance_handle = nullptr; @@ -78,11 +78,11 @@ bool Shell::Initialise() cursor_text = LoadCursor(nullptr, IDC_IBEAM); cursor_unavailable = LoadCursor(nullptr, IDC_NO); - Rml::Core::String root = FindSamplesRoot(); + Rml::String root = FindSamplesRoot(); bool result = !root.empty(); file_interface = std::make_unique(root); - Rml::Core::SetFileInterface(file_interface.get()); + Rml::SetFileInterface(file_interface.get()); return result; } @@ -94,7 +94,7 @@ void Shell::Shutdown() file_interface.reset(); } -Rml::Core::String Shell::FindSamplesRoot() +Rml::String Shell::FindSamplesRoot() { const char* candidate_paths[] = { "", "..\\..\\Samples\\", "..\\Samples\\", "..\\..\\..\\Samples\\" }; @@ -106,7 +106,7 @@ Rml::Core::String Shell::FindSamplesRoot() executable_file_name[0] = 0; } - Rml::Core::String executable_path(executable_file_name); + Rml::String executable_path(executable_file_name); executable_path = executable_path.substr(0, executable_path.rfind('\\') + 1); // We assume we have found the correct path if we can find the lookup file from it @@ -114,19 +114,19 @@ Rml::Core::String Shell::FindSamplesRoot() for(const char* relative_path : candidate_paths) { - Rml::Core::String absolute_path = executable_path + relative_path; + Rml::String absolute_path = executable_path + relative_path; - if (PathFileExistsA(Rml::Core::String(absolute_path + lookup_file).c_str())) + if (PathFileExistsA(Rml::String(absolute_path + lookup_file).c_str())) { char canonical_path[MAX_PATH]; if (!PathCanonicalizeA(canonical_path, absolute_path.c_str())) canonical_path[0] = 0; - return Rml::Core::String(canonical_path); + return Rml::String(canonical_path); } } - return Rml::Core::String(); + return Rml::String(); } static ShellRenderInterfaceExtensions *shell_renderer = nullptr; @@ -134,7 +134,7 @@ bool Shell::OpenWindow(const char* in_name, ShellRenderInterfaceExtensions *_she { WNDCLASSW window_class; - Rml::Core::U16String name = Rml::Core::StringUtilities::ToUTF16(Rml::Core::String(in_name)); + Rml::U16String name = Rml::StringUtilities::ToUTF16(Rml::String(in_name)); // Fill out the window class struct. window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; @@ -269,7 +269,7 @@ void Shell::DisplayError(const char* fmt, ...) buffer[len + 1] = '\0'; va_end(argument_list); - MessageBox(window_handle, (LPCWSTR)Rml::Core::StringUtilities::ToUTF16(buffer).c_str(), L"Shell Error", MB_OK); + MessageBox(window_handle, (LPCWSTR)Rml::StringUtilities::ToUTF16(buffer).c_str(), L"Shell Error", MB_OK); } void Shell::Log(const char* fmt, ...) @@ -289,7 +289,7 @@ void Shell::Log(const char* fmt, ...) buffer[len + 1] = '\0'; va_end(argument_list); - OutputDebugString((LPCWSTR)Rml::Core::StringUtilities::ToUTF16(buffer).c_str()); + OutputDebugString((LPCWSTR)Rml::StringUtilities::ToUTF16(buffer).c_str()); } double Shell::GetElapsedTime() @@ -300,7 +300,7 @@ double Shell::GetElapsedTime() return double(counter.QuadPart - time_startup.QuadPart) * time_frequency; } -void Shell::SetMouseCursor(const Rml::Core::String& cursor_name) +void Shell::SetMouseCursor(const Rml::String& cursor_name) { if (window_handle) { @@ -328,7 +328,7 @@ void Shell::SetMouseCursor(const Rml::Core::String& cursor_name) } } -void Shell::SetClipboardText(const Rml::Core::String& text_utf8) +void Shell::SetClipboardText(const Rml::String& text_utf8) { if (window_handle) { @@ -337,7 +337,7 @@ void Shell::SetClipboardText(const Rml::Core::String& text_utf8) EmptyClipboard(); - const Rml::Core::U16String text = Rml::Core::StringUtilities::ToUTF16(text_utf8); + const Rml::U16String text = Rml::StringUtilities::ToUTF16(text_utf8); size_t size = sizeof(char16_t) * (text.size() + 1); @@ -354,7 +354,7 @@ void Shell::SetClipboardText(const Rml::Core::String& text_utf8) } } -void Shell::GetClipboardText(Rml::Core::String& text) +void Shell::GetClipboardText(Rml::String& text) { if (window_handle) { @@ -370,7 +370,7 @@ void Shell::GetClipboardText(Rml::Core::String& text) const char16_t* clipboard_text = (const char16_t*)GlobalLock(clipboard_data); if (clipboard_text) - text = Rml::Core::StringUtilities::ToUTF8(clipboard_text); + text = Rml::StringUtilities::ToUTF8(clipboard_text); GlobalUnlock(clipboard_data); CloseClipboard(); diff --git a/Samples/shell/src/x11/InputX11.cpp b/Samples/shell/src/x11/InputX11.cpp index a93342d13..0007e479f 100644 --- a/Samples/shell/src/x11/InputX11.cpp +++ b/Samples/shell/src/x11/InputX11.cpp @@ -43,7 +43,7 @@ static void InitialiseKeymap(); static int GetKeyModifierState(int x_state); static const int KEYMAP_SIZE = 256; -static Rml::Core::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; +static Rml::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; #ifdef HAS_X11XKBLIB static bool has_xkblib = false; @@ -137,7 +137,7 @@ void InputX11::ProcessXEvent(Display* display, const XEvent& event) case KeyPress: { int group_index = 0; // this is always 0 for our limited example - Rml::Core::Input::KeyIdentifier key_identifier; + Rml::Input::KeyIdentifier key_identifier; #ifdef HAS_X11XKBLIB if(has_xkblib) { @@ -159,17 +159,17 @@ void InputX11::ProcessXEvent(Display* display, const XEvent& event) int key_modifier_state = GetKeyModifierState(event.xkey.state); // Check for F8 to toggle the debugger. - if (key_identifier == Rml::Core::Input::KI_F8) + if (key_identifier == Rml::Input::KI_F8) { Rml::Debugger::SetVisible(!Rml::Debugger::IsVisible()); break; } - if (key_identifier != Rml::Core::Input::KI_UNKNOWN) + if (key_identifier != Rml::Input::KI_UNKNOWN) context->ProcessKeyDown(key_identifier, key_modifier_state); - Rml::Core::Character character = GetCharacterCode(key_identifier, key_modifier_state); - if (character != Rml::Core::Character::Null) + Rml::Character character = GetCharacterCode(key_identifier, key_modifier_state); + if (character != Rml::Character::Null) context->ProcessTextInput(character); } break; @@ -177,7 +177,7 @@ void InputX11::ProcessXEvent(Display* display, const XEvent& event) case KeyRelease: { int group_index = 0; // this is always 0 for our limited example - Rml::Core::Input::KeyIdentifier key_identifier; + Rml::Input::KeyIdentifier key_identifier; #ifdef HAS_X11XKBLIB if(has_xkblib) { @@ -197,7 +197,7 @@ void InputX11::ProcessXEvent(Display* display, const XEvent& event) } int key_modifier_state = GetKeyModifierState(event.xkey.state); - if (key_identifier != Rml::Core::Input::KI_UNKNOWN) + if (key_identifier != Rml::Input::KI_UNKNOWN) context->ProcessKeyUp(key_identifier, key_modifier_state); } break; @@ -209,19 +209,19 @@ static int GetKeyModifierState(int x_state) int key_modifier_state = 0; if (x_state & ShiftMask) - key_modifier_state |= Rml::Core::Input::KM_SHIFT; + key_modifier_state |= Rml::Input::KM_SHIFT; if (x_state & LockMask) - key_modifier_state |= Rml::Core::Input::KM_CAPSLOCK; + key_modifier_state |= Rml::Input::KM_CAPSLOCK; if (x_state & ControlMask) - key_modifier_state |= Rml::Core::Input::KM_CTRL; + key_modifier_state |= Rml::Input::KM_CTRL; if (x_state & Mod5Mask) - key_modifier_state |= Rml::Core::Input::KM_ALT; + key_modifier_state |= Rml::Input::KM_ALT; if (x_state & Mod2Mask) - key_modifier_state |= Rml::Core::Input::KM_NUMLOCK; + key_modifier_state |= Rml::Input::KM_NUMLOCK; return key_modifier_state; } @@ -231,153 +231,153 @@ static void InitialiseKeymap() // Initialise the key map with default values. memset(key_identifier_map, 0, sizeof(key_identifier_map)); - key_identifier_map[XK_BackSpace & 0xFF] = Rml::Core::Input::KI_BACK; - key_identifier_map[XK_Tab & 0xFF] = Rml::Core::Input::KI_TAB; - key_identifier_map[XK_Clear & 0xFF] = Rml::Core::Input::KI_CLEAR; - key_identifier_map[XK_Return & 0xFF] = Rml::Core::Input::KI_RETURN; - key_identifier_map[XK_Pause & 0xFF] = Rml::Core::Input::KI_PAUSE; - key_identifier_map[XK_Scroll_Lock & 0xFF] = Rml::Core::Input::KI_SCROLL; - key_identifier_map[XK_Escape & 0xFF] = Rml::Core::Input::KI_ESCAPE; - key_identifier_map[XK_Delete & 0xFF] = Rml::Core::Input::KI_DELETE; - - key_identifier_map[XK_Kanji & 0xFF] = Rml::Core::Input::KI_KANJI; -// key_identifier_map[XK_Muhenkan & 0xFF] = Rml::Core::Input::; /* Cancel Conversion */ -// key_identifier_map[XK_Henkan_Mode & 0xFF] = Rml::Core::Input::; /* Start/Stop Conversion */ -// key_identifier_map[XK_Henkan & 0xFF] = Rml::Core::Input::; /* Alias for Henkan_Mode */ -// key_identifier_map[XK_Romaji & 0xFF] = Rml::Core::Input::; /* to Romaji */ -// key_identifier_map[XK_Hiragana & 0xFF] = Rml::Core::Input::; /* to Hiragana */ -// key_identifier_map[XK_Katakana & 0xFF] = Rml::Core::Input::; /* to Katakana */ -// key_identifier_map[XK_Hiragana_Katakana & 0xFF] = Rml::Core::Input::; /* Hiragana/Katakana toggle */ -// key_identifier_map[XK_Zenkaku & 0xFF] = Rml::Core::Input::; /* to Zenkaku */ -// key_identifier_map[XK_Hankaku & 0xFF] = Rml::Core::Input::; /* to Hankaku */ -// key_identifier_map[XK_Zenkaku_Hankaku & 0xFF] = Rml::Core::Input::; /* Zenkaku/Hankaku toggle */ - key_identifier_map[XK_Touroku & 0xFF] = Rml::Core::Input::KI_OEM_FJ_TOUROKU; - key_identifier_map[XK_Massyo & 0xFF] = Rml::Core::Input::KI_OEM_FJ_MASSHOU; -// key_identifier_map[XK_Kana_Lock & 0xFF] = Rml::Core::Input::; /* Kana Lock */ -// key_identifier_map[XK_Kana_Shift & 0xFF] = Rml::Core::Input::; /* Kana Shift */ -// key_identifier_map[XK_Eisu_Shift & 0xFF] = Rml::Core::Input::; /* Alphanumeric Shift */ -// key_identifier_map[XK_Eisu_toggle & 0xFF] = Rml::Core::Input::; /* Alphanumeric toggle */ - - key_identifier_map[XK_Home & 0xFF] = Rml::Core::Input::KI_HOME; - key_identifier_map[XK_Left & 0xFF] = Rml::Core::Input::KI_LEFT; - key_identifier_map[XK_Up & 0xFF] = Rml::Core::Input::KI_UP; - key_identifier_map[XK_Right & 0xFF] = Rml::Core::Input::KI_RIGHT; - key_identifier_map[XK_Down & 0xFF] = Rml::Core::Input::KI_DOWN; - key_identifier_map[XK_Prior & 0xFF] = Rml::Core::Input::KI_PRIOR; - key_identifier_map[XK_Next & 0xFF] = Rml::Core::Input::KI_NEXT; - key_identifier_map[XK_End & 0xFF] = Rml::Core::Input::KI_END; - key_identifier_map[XK_Begin & 0xFF] = Rml::Core::Input::KI_HOME; - - key_identifier_map[XK_Print & 0xFF] = Rml::Core::Input::KI_SNAPSHOT; - key_identifier_map[XK_Insert & 0xFF] = Rml::Core::Input::KI_INSERT; - key_identifier_map[XK_Num_Lock & 0xFF] = Rml::Core::Input::KI_NUMLOCK; - - key_identifier_map[XK_KP_Space & 0xFF] = Rml::Core::Input::KI_SPACE; - key_identifier_map[XK_KP_Tab & 0xFF] = Rml::Core::Input::KI_TAB; - key_identifier_map[XK_KP_Enter & 0xFF] = Rml::Core::Input::KI_NUMPADENTER; - key_identifier_map[XK_KP_F1 & 0xFF] = Rml::Core::Input::KI_F1; - key_identifier_map[XK_KP_F2 & 0xFF] = Rml::Core::Input::KI_F2; - key_identifier_map[XK_KP_F3 & 0xFF] = Rml::Core::Input::KI_F3; - key_identifier_map[XK_KP_F4 & 0xFF] = Rml::Core::Input::KI_F4; - key_identifier_map[XK_KP_Home & 0xFF] = Rml::Core::Input::KI_NUMPAD7; - key_identifier_map[XK_KP_Left & 0xFF] = Rml::Core::Input::KI_NUMPAD4; - key_identifier_map[XK_KP_Up & 0xFF] = Rml::Core::Input::KI_NUMPAD8; - key_identifier_map[XK_KP_Right & 0xFF] = Rml::Core::Input::KI_NUMPAD6; - key_identifier_map[XK_KP_Down & 0xFF] = Rml::Core::Input::KI_NUMPAD2; - key_identifier_map[XK_KP_Prior & 0xFF] = Rml::Core::Input::KI_NUMPAD9; - key_identifier_map[XK_KP_Next & 0xFF] = Rml::Core::Input::KI_NUMPAD3; - key_identifier_map[XK_KP_End & 0xFF] = Rml::Core::Input::KI_NUMPAD1; - key_identifier_map[XK_KP_Begin & 0xFF] = Rml::Core::Input::KI_NUMPAD5; - key_identifier_map[XK_KP_Insert & 0xFF] = Rml::Core::Input::KI_NUMPAD0; - key_identifier_map[XK_KP_Delete & 0xFF] = Rml::Core::Input::KI_DECIMAL; - key_identifier_map[XK_KP_Equal & 0xFF] = Rml::Core::Input::KI_OEM_NEC_EQUAL; - key_identifier_map[XK_KP_Multiply & 0xFF] = Rml::Core::Input::KI_MULTIPLY; - key_identifier_map[XK_KP_Add & 0xFF] = Rml::Core::Input::KI_ADD; - key_identifier_map[XK_KP_Separator & 0xFF] = Rml::Core::Input::KI_SEPARATOR; - key_identifier_map[XK_KP_Subtract & 0xFF] = Rml::Core::Input::KI_SUBTRACT; - key_identifier_map[XK_KP_Decimal & 0xFF] = Rml::Core::Input::KI_DECIMAL; - key_identifier_map[XK_KP_Divide & 0xFF] = Rml::Core::Input::KI_DIVIDE; - - key_identifier_map[XK_F1 & 0xFF] = Rml::Core::Input::KI_F1; - key_identifier_map[XK_F2 & 0xFF] = Rml::Core::Input::KI_F2; - key_identifier_map[XK_F3 & 0xFF] = Rml::Core::Input::KI_F3; - key_identifier_map[XK_F4 & 0xFF] = Rml::Core::Input::KI_F4; - key_identifier_map[XK_F5 & 0xFF] = Rml::Core::Input::KI_F5; - key_identifier_map[XK_F6 & 0xFF] = Rml::Core::Input::KI_F6; - key_identifier_map[XK_F7 & 0xFF] = Rml::Core::Input::KI_F7; - key_identifier_map[XK_F8 & 0xFF] = Rml::Core::Input::KI_F8; - key_identifier_map[XK_F9 & 0xFF] = Rml::Core::Input::KI_F9; - key_identifier_map[XK_F10 & 0xFF] = Rml::Core::Input::KI_F10; - key_identifier_map[XK_F11 & 0xFF] = Rml::Core::Input::KI_F11; - key_identifier_map[XK_F12 & 0xFF] = Rml::Core::Input::KI_F12; - key_identifier_map[XK_F13 & 0xFF] = Rml::Core::Input::KI_F13; - key_identifier_map[XK_F14 & 0xFF] = Rml::Core::Input::KI_F14; - key_identifier_map[XK_F15 & 0xFF] = Rml::Core::Input::KI_F15; - key_identifier_map[XK_F16 & 0xFF] = Rml::Core::Input::KI_F16; - key_identifier_map[XK_F17 & 0xFF] = Rml::Core::Input::KI_F17; - key_identifier_map[XK_F18 & 0xFF] = Rml::Core::Input::KI_F18; - key_identifier_map[XK_F19 & 0xFF] = Rml::Core::Input::KI_F19; - key_identifier_map[XK_F20 & 0xFF] = Rml::Core::Input::KI_F20; - key_identifier_map[XK_F21 & 0xFF] = Rml::Core::Input::KI_F21; - key_identifier_map[XK_F22 & 0xFF] = Rml::Core::Input::KI_F22; - key_identifier_map[XK_F23 & 0xFF] = Rml::Core::Input::KI_F23; - key_identifier_map[XK_F24 & 0xFF] = Rml::Core::Input::KI_F24; - - key_identifier_map[XK_Shift_L & 0xFF] = Rml::Core::Input::KI_LSHIFT; - key_identifier_map[XK_Shift_R & 0xFF] = Rml::Core::Input::KI_RSHIFT; - key_identifier_map[XK_Control_L & 0xFF] = Rml::Core::Input::KI_LCONTROL; - key_identifier_map[XK_Control_R & 0xFF] = Rml::Core::Input::KI_RCONTROL; - key_identifier_map[XK_Caps_Lock & 0xFF] = Rml::Core::Input::KI_CAPITAL; - - key_identifier_map[XK_Alt_L & 0xFF] = Rml::Core::Input::KI_LMENU; - key_identifier_map[XK_Alt_R & 0xFF] = Rml::Core::Input::KI_RMENU; - - key_identifier_map[XK_space & 0xFF] = Rml::Core::Input::KI_SPACE; - key_identifier_map[XK_apostrophe & 0xFF] = Rml::Core::Input::KI_OEM_7; - key_identifier_map[XK_comma & 0xFF] = Rml::Core::Input::KI_OEM_COMMA; - key_identifier_map[XK_minus & 0xFF] = Rml::Core::Input::KI_OEM_MINUS; - key_identifier_map[XK_period & 0xFF] = Rml::Core::Input::KI_OEM_PERIOD; - key_identifier_map[XK_slash & 0xFF] = Rml::Core::Input::KI_OEM_2; - key_identifier_map[XK_0 & 0xFF] = Rml::Core::Input::KI_0; - key_identifier_map[XK_1 & 0xFF] = Rml::Core::Input::KI_1; - key_identifier_map[XK_2 & 0xFF] = Rml::Core::Input::KI_2; - key_identifier_map[XK_3 & 0xFF] = Rml::Core::Input::KI_3; - key_identifier_map[XK_4 & 0xFF] = Rml::Core::Input::KI_4; - key_identifier_map[XK_5 & 0xFF] = Rml::Core::Input::KI_5; - key_identifier_map[XK_6 & 0xFF] = Rml::Core::Input::KI_6; - key_identifier_map[XK_7 & 0xFF] = Rml::Core::Input::KI_7; - key_identifier_map[XK_8 & 0xFF] = Rml::Core::Input::KI_8; - key_identifier_map[XK_9 & 0xFF] = Rml::Core::Input::KI_9; - key_identifier_map[XK_semicolon & 0xFF] = Rml::Core::Input::KI_OEM_1; - key_identifier_map[XK_equal & 0xFF] = Rml::Core::Input::KI_OEM_PLUS; - key_identifier_map[XK_bracketleft & 0xFF] = Rml::Core::Input::KI_OEM_4; - key_identifier_map[XK_backslash & 0xFF] = Rml::Core::Input::KI_OEM_5; - key_identifier_map[XK_bracketright & 0xFF] = Rml::Core::Input::KI_OEM_6; - key_identifier_map[XK_grave & 0xFF] = Rml::Core::Input::KI_OEM_3; - key_identifier_map[XK_a & 0xFF] = Rml::Core::Input::KI_A; - key_identifier_map[XK_b & 0xFF] = Rml::Core::Input::KI_B; - key_identifier_map[XK_c & 0xFF] = Rml::Core::Input::KI_C; - key_identifier_map[XK_d & 0xFF] = Rml::Core::Input::KI_D; - key_identifier_map[XK_e & 0xFF] = Rml::Core::Input::KI_E; - key_identifier_map[XK_f & 0xFF] = Rml::Core::Input::KI_F; - key_identifier_map[XK_g & 0xFF] = Rml::Core::Input::KI_G; - key_identifier_map[XK_h & 0xFF] = Rml::Core::Input::KI_H; - key_identifier_map[XK_i & 0xFF] = Rml::Core::Input::KI_I; - key_identifier_map[XK_j & 0xFF] = Rml::Core::Input::KI_J; - key_identifier_map[XK_k & 0xFF] = Rml::Core::Input::KI_K; - key_identifier_map[XK_l & 0xFF] = Rml::Core::Input::KI_L; - key_identifier_map[XK_m & 0xFF] = Rml::Core::Input::KI_M; - key_identifier_map[XK_n & 0xFF] = Rml::Core::Input::KI_N; - key_identifier_map[XK_o & 0xFF] = Rml::Core::Input::KI_O; - key_identifier_map[XK_p & 0xFF] = Rml::Core::Input::KI_P; - key_identifier_map[XK_q & 0xFF] = Rml::Core::Input::KI_Q; - key_identifier_map[XK_r & 0xFF] = Rml::Core::Input::KI_R; - key_identifier_map[XK_s & 0xFF] = Rml::Core::Input::KI_S; - key_identifier_map[XK_t & 0xFF] = Rml::Core::Input::KI_T; - key_identifier_map[XK_u & 0xFF] = Rml::Core::Input::KI_U; - key_identifier_map[XK_v & 0xFF] = Rml::Core::Input::KI_V; - key_identifier_map[XK_w & 0xFF] = Rml::Core::Input::KI_W; - key_identifier_map[XK_x & 0xFF] = Rml::Core::Input::KI_X; - key_identifier_map[XK_y & 0xFF] = Rml::Core::Input::KI_Y; - key_identifier_map[XK_z & 0xFF] = Rml::Core::Input::KI_Z; + key_identifier_map[XK_BackSpace & 0xFF] = Rml::Input::KI_BACK; + key_identifier_map[XK_Tab & 0xFF] = Rml::Input::KI_TAB; + key_identifier_map[XK_Clear & 0xFF] = Rml::Input::KI_CLEAR; + key_identifier_map[XK_Return & 0xFF] = Rml::Input::KI_RETURN; + key_identifier_map[XK_Pause & 0xFF] = Rml::Input::KI_PAUSE; + key_identifier_map[XK_Scroll_Lock & 0xFF] = Rml::Input::KI_SCROLL; + key_identifier_map[XK_Escape & 0xFF] = Rml::Input::KI_ESCAPE; + key_identifier_map[XK_Delete & 0xFF] = Rml::Input::KI_DELETE; + + key_identifier_map[XK_Kanji & 0xFF] = Rml::Input::KI_KANJI; +// key_identifier_map[XK_Muhenkan & 0xFF] = Rml::Input::; /* Cancel Conversion */ +// key_identifier_map[XK_Henkan_Mode & 0xFF] = Rml::Input::; /* Start/Stop Conversion */ +// key_identifier_map[XK_Henkan & 0xFF] = Rml::Input::; /* Alias for Henkan_Mode */ +// key_identifier_map[XK_Romaji & 0xFF] = Rml::Input::; /* to Romaji */ +// key_identifier_map[XK_Hiragana & 0xFF] = Rml::Input::; /* to Hiragana */ +// key_identifier_map[XK_Katakana & 0xFF] = Rml::Input::; /* to Katakana */ +// key_identifier_map[XK_Hiragana_Katakana & 0xFF] = Rml::Input::; /* Hiragana/Katakana toggle */ +// key_identifier_map[XK_Zenkaku & 0xFF] = Rml::Input::; /* to Zenkaku */ +// key_identifier_map[XK_Hankaku & 0xFF] = Rml::Input::; /* to Hankaku */ +// key_identifier_map[XK_Zenkaku_Hankaku & 0xFF] = Rml::Input::; /* Zenkaku/Hankaku toggle */ + key_identifier_map[XK_Touroku & 0xFF] = Rml::Input::KI_OEM_FJ_TOUROKU; + key_identifier_map[XK_Massyo & 0xFF] = Rml::Input::KI_OEM_FJ_MASSHOU; +// key_identifier_map[XK_Kana_Lock & 0xFF] = Rml::Input::; /* Kana Lock */ +// key_identifier_map[XK_Kana_Shift & 0xFF] = Rml::Input::; /* Kana Shift */ +// key_identifier_map[XK_Eisu_Shift & 0xFF] = Rml::Input::; /* Alphanumeric Shift */ +// key_identifier_map[XK_Eisu_toggle & 0xFF] = Rml::Input::; /* Alphanumeric toggle */ + + key_identifier_map[XK_Home & 0xFF] = Rml::Input::KI_HOME; + key_identifier_map[XK_Left & 0xFF] = Rml::Input::KI_LEFT; + key_identifier_map[XK_Up & 0xFF] = Rml::Input::KI_UP; + key_identifier_map[XK_Right & 0xFF] = Rml::Input::KI_RIGHT; + key_identifier_map[XK_Down & 0xFF] = Rml::Input::KI_DOWN; + key_identifier_map[XK_Prior & 0xFF] = Rml::Input::KI_PRIOR; + key_identifier_map[XK_Next & 0xFF] = Rml::Input::KI_NEXT; + key_identifier_map[XK_End & 0xFF] = Rml::Input::KI_END; + key_identifier_map[XK_Begin & 0xFF] = Rml::Input::KI_HOME; + + key_identifier_map[XK_Print & 0xFF] = Rml::Input::KI_SNAPSHOT; + key_identifier_map[XK_Insert & 0xFF] = Rml::Input::KI_INSERT; + key_identifier_map[XK_Num_Lock & 0xFF] = Rml::Input::KI_NUMLOCK; + + key_identifier_map[XK_KP_Space & 0xFF] = Rml::Input::KI_SPACE; + key_identifier_map[XK_KP_Tab & 0xFF] = Rml::Input::KI_TAB; + key_identifier_map[XK_KP_Enter & 0xFF] = Rml::Input::KI_NUMPADENTER; + key_identifier_map[XK_KP_F1 & 0xFF] = Rml::Input::KI_F1; + key_identifier_map[XK_KP_F2 & 0xFF] = Rml::Input::KI_F2; + key_identifier_map[XK_KP_F3 & 0xFF] = Rml::Input::KI_F3; + key_identifier_map[XK_KP_F4 & 0xFF] = Rml::Input::KI_F4; + key_identifier_map[XK_KP_Home & 0xFF] = Rml::Input::KI_NUMPAD7; + key_identifier_map[XK_KP_Left & 0xFF] = Rml::Input::KI_NUMPAD4; + key_identifier_map[XK_KP_Up & 0xFF] = Rml::Input::KI_NUMPAD8; + key_identifier_map[XK_KP_Right & 0xFF] = Rml::Input::KI_NUMPAD6; + key_identifier_map[XK_KP_Down & 0xFF] = Rml::Input::KI_NUMPAD2; + key_identifier_map[XK_KP_Prior & 0xFF] = Rml::Input::KI_NUMPAD9; + key_identifier_map[XK_KP_Next & 0xFF] = Rml::Input::KI_NUMPAD3; + key_identifier_map[XK_KP_End & 0xFF] = Rml::Input::KI_NUMPAD1; + key_identifier_map[XK_KP_Begin & 0xFF] = Rml::Input::KI_NUMPAD5; + key_identifier_map[XK_KP_Insert & 0xFF] = Rml::Input::KI_NUMPAD0; + key_identifier_map[XK_KP_Delete & 0xFF] = Rml::Input::KI_DECIMAL; + key_identifier_map[XK_KP_Equal & 0xFF] = Rml::Input::KI_OEM_NEC_EQUAL; + key_identifier_map[XK_KP_Multiply & 0xFF] = Rml::Input::KI_MULTIPLY; + key_identifier_map[XK_KP_Add & 0xFF] = Rml::Input::KI_ADD; + key_identifier_map[XK_KP_Separator & 0xFF] = Rml::Input::KI_SEPARATOR; + key_identifier_map[XK_KP_Subtract & 0xFF] = Rml::Input::KI_SUBTRACT; + key_identifier_map[XK_KP_Decimal & 0xFF] = Rml::Input::KI_DECIMAL; + key_identifier_map[XK_KP_Divide & 0xFF] = Rml::Input::KI_DIVIDE; + + key_identifier_map[XK_F1 & 0xFF] = Rml::Input::KI_F1; + key_identifier_map[XK_F2 & 0xFF] = Rml::Input::KI_F2; + key_identifier_map[XK_F3 & 0xFF] = Rml::Input::KI_F3; + key_identifier_map[XK_F4 & 0xFF] = Rml::Input::KI_F4; + key_identifier_map[XK_F5 & 0xFF] = Rml::Input::KI_F5; + key_identifier_map[XK_F6 & 0xFF] = Rml::Input::KI_F6; + key_identifier_map[XK_F7 & 0xFF] = Rml::Input::KI_F7; + key_identifier_map[XK_F8 & 0xFF] = Rml::Input::KI_F8; + key_identifier_map[XK_F9 & 0xFF] = Rml::Input::KI_F9; + key_identifier_map[XK_F10 & 0xFF] = Rml::Input::KI_F10; + key_identifier_map[XK_F11 & 0xFF] = Rml::Input::KI_F11; + key_identifier_map[XK_F12 & 0xFF] = Rml::Input::KI_F12; + key_identifier_map[XK_F13 & 0xFF] = Rml::Input::KI_F13; + key_identifier_map[XK_F14 & 0xFF] = Rml::Input::KI_F14; + key_identifier_map[XK_F15 & 0xFF] = Rml::Input::KI_F15; + key_identifier_map[XK_F16 & 0xFF] = Rml::Input::KI_F16; + key_identifier_map[XK_F17 & 0xFF] = Rml::Input::KI_F17; + key_identifier_map[XK_F18 & 0xFF] = Rml::Input::KI_F18; + key_identifier_map[XK_F19 & 0xFF] = Rml::Input::KI_F19; + key_identifier_map[XK_F20 & 0xFF] = Rml::Input::KI_F20; + key_identifier_map[XK_F21 & 0xFF] = Rml::Input::KI_F21; + key_identifier_map[XK_F22 & 0xFF] = Rml::Input::KI_F22; + key_identifier_map[XK_F23 & 0xFF] = Rml::Input::KI_F23; + key_identifier_map[XK_F24 & 0xFF] = Rml::Input::KI_F24; + + key_identifier_map[XK_Shift_L & 0xFF] = Rml::Input::KI_LSHIFT; + key_identifier_map[XK_Shift_R & 0xFF] = Rml::Input::KI_RSHIFT; + key_identifier_map[XK_Control_L & 0xFF] = Rml::Input::KI_LCONTROL; + key_identifier_map[XK_Control_R & 0xFF] = Rml::Input::KI_RCONTROL; + key_identifier_map[XK_Caps_Lock & 0xFF] = Rml::Input::KI_CAPITAL; + + key_identifier_map[XK_Alt_L & 0xFF] = Rml::Input::KI_LMENU; + key_identifier_map[XK_Alt_R & 0xFF] = Rml::Input::KI_RMENU; + + key_identifier_map[XK_space & 0xFF] = Rml::Input::KI_SPACE; + key_identifier_map[XK_apostrophe & 0xFF] = Rml::Input::KI_OEM_7; + key_identifier_map[XK_comma & 0xFF] = Rml::Input::KI_OEM_COMMA; + key_identifier_map[XK_minus & 0xFF] = Rml::Input::KI_OEM_MINUS; + key_identifier_map[XK_period & 0xFF] = Rml::Input::KI_OEM_PERIOD; + key_identifier_map[XK_slash & 0xFF] = Rml::Input::KI_OEM_2; + key_identifier_map[XK_0 & 0xFF] = Rml::Input::KI_0; + key_identifier_map[XK_1 & 0xFF] = Rml::Input::KI_1; + key_identifier_map[XK_2 & 0xFF] = Rml::Input::KI_2; + key_identifier_map[XK_3 & 0xFF] = Rml::Input::KI_3; + key_identifier_map[XK_4 & 0xFF] = Rml::Input::KI_4; + key_identifier_map[XK_5 & 0xFF] = Rml::Input::KI_5; + key_identifier_map[XK_6 & 0xFF] = Rml::Input::KI_6; + key_identifier_map[XK_7 & 0xFF] = Rml::Input::KI_7; + key_identifier_map[XK_8 & 0xFF] = Rml::Input::KI_8; + key_identifier_map[XK_9 & 0xFF] = Rml::Input::KI_9; + key_identifier_map[XK_semicolon & 0xFF] = Rml::Input::KI_OEM_1; + key_identifier_map[XK_equal & 0xFF] = Rml::Input::KI_OEM_PLUS; + key_identifier_map[XK_bracketleft & 0xFF] = Rml::Input::KI_OEM_4; + key_identifier_map[XK_backslash & 0xFF] = Rml::Input::KI_OEM_5; + key_identifier_map[XK_bracketright & 0xFF] = Rml::Input::KI_OEM_6; + key_identifier_map[XK_grave & 0xFF] = Rml::Input::KI_OEM_3; + key_identifier_map[XK_a & 0xFF] = Rml::Input::KI_A; + key_identifier_map[XK_b & 0xFF] = Rml::Input::KI_B; + key_identifier_map[XK_c & 0xFF] = Rml::Input::KI_C; + key_identifier_map[XK_d & 0xFF] = Rml::Input::KI_D; + key_identifier_map[XK_e & 0xFF] = Rml::Input::KI_E; + key_identifier_map[XK_f & 0xFF] = Rml::Input::KI_F; + key_identifier_map[XK_g & 0xFF] = Rml::Input::KI_G; + key_identifier_map[XK_h & 0xFF] = Rml::Input::KI_H; + key_identifier_map[XK_i & 0xFF] = Rml::Input::KI_I; + key_identifier_map[XK_j & 0xFF] = Rml::Input::KI_J; + key_identifier_map[XK_k & 0xFF] = Rml::Input::KI_K; + key_identifier_map[XK_l & 0xFF] = Rml::Input::KI_L; + key_identifier_map[XK_m & 0xFF] = Rml::Input::KI_M; + key_identifier_map[XK_n & 0xFF] = Rml::Input::KI_N; + key_identifier_map[XK_o & 0xFF] = Rml::Input::KI_O; + key_identifier_map[XK_p & 0xFF] = Rml::Input::KI_P; + key_identifier_map[XK_q & 0xFF] = Rml::Input::KI_Q; + key_identifier_map[XK_r & 0xFF] = Rml::Input::KI_R; + key_identifier_map[XK_s & 0xFF] = Rml::Input::KI_S; + key_identifier_map[XK_t & 0xFF] = Rml::Input::KI_T; + key_identifier_map[XK_u & 0xFF] = Rml::Input::KI_U; + key_identifier_map[XK_v & 0xFF] = Rml::Input::KI_V; + key_identifier_map[XK_w & 0xFF] = Rml::Input::KI_W; + key_identifier_map[XK_x & 0xFF] = Rml::Input::KI_X; + key_identifier_map[XK_y & 0xFF] = Rml::Input::KI_Y; + key_identifier_map[XK_z & 0xFF] = Rml::Input::KI_Z; } diff --git a/Samples/shell/src/x11/ShellRenderInterfaceExtensionsOpenGL_X11.cpp b/Samples/shell/src/x11/ShellRenderInterfaceExtensionsOpenGL_X11.cpp index 17763df40..f0b6501b2 100644 --- a/Samples/shell/src/x11/ShellRenderInterfaceExtensionsOpenGL_X11.cpp +++ b/Samples/shell/src/x11/ShellRenderInterfaceExtensionsOpenGL_X11.cpp @@ -44,22 +44,22 @@ void ShellRenderInterfaceOpenGL::SetContext(void *context) void ShellRenderInterfaceOpenGL::SetViewport(int width, int height) { if(m_width != width || m_height != height) { - Rml::Core::Matrix4f projection, view; + Rml::Matrix4f projection, view; m_width = width; m_height = height; glViewport(0, 0, width, height); - projection = Rml::Core::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); + projection = Rml::Matrix4f::ProjectOrtho(0, (float)width, (float)height, 0, -10000, 10000); glMatrixMode(GL_PROJECTION); glLoadMatrixf(projection.data()); - view = Rml::Core::Matrix4f::Identity(); + view = Rml::Matrix4f::Identity(); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(view.data()); if(m_rmlui_context != nullptr) { - ((Rml::Core::Context*)m_rmlui_context)->SetDimensions(Rml::Core::Vector2i(width, height)); + ((Rml::Context*)m_rmlui_context)->SetDimensions(Rml::Vector2i(width, height)); } } } diff --git a/Samples/shell/src/x11/ShellX11.cpp b/Samples/shell/src/x11/ShellX11.cpp index f53df8398..202eac393 100644 --- a/Samples/shell/src/x11/ShellX11.cpp +++ b/Samples/shell/src/x11/ShellX11.cpp @@ -48,7 +48,7 @@ static bool running = false; static int screen = -1; static timeval start_time; -static Rml::Core::String clipboard_text; +static Rml::String clipboard_text; static std::unique_ptr file_interface; @@ -60,7 +60,7 @@ static Cursor cursor_cross = 0; static Cursor cursor_text = 0; static Cursor cursor_unavailable = 0; -static bool isRegularFile(const Rml::Core::String& path) +static bool isRegularFile(const Rml::String& path) { struct stat sb; return (stat(path.c_str(), &sb) == 0 && S_ISREG(sb.st_mode)); @@ -71,11 +71,11 @@ bool Shell::Initialise() gettimeofday(&start_time, nullptr); InputX11::Initialise(); - Rml::Core::String root = FindSamplesRoot(); + Rml::String root = FindSamplesRoot(); bool result = !root.empty(); file_interface = std::make_unique(root); - Rml::Core::SetFileInterface(file_interface.get()); + Rml::SetFileInterface(file_interface.get()); return result; } @@ -87,7 +87,7 @@ void Shell::Shutdown() file_interface.reset(); } -Rml::Core::String Shell::FindSamplesRoot() +Rml::String Shell::FindSamplesRoot() { char executable_file_name[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", executable_file_name, PATH_MAX); @@ -98,7 +98,7 @@ Rml::Core::String Shell::FindSamplesRoot() // readlink() does not append a null byte to buf. executable_file_name[len] = 0; } - Rml::Core::String executable_path = Rml::Core::String(executable_file_name); + Rml::String executable_path = Rml::String(executable_file_name); executable_path = executable_path.substr(0, executable_path.rfind("/") + 1); // We assume we have found the correct path if we can find the lookup file from it. @@ -111,8 +111,8 @@ Rml::Core::String Shell::FindSamplesRoot() for (const char* relative_path : candidate_paths) { - Rml::Core::String absolute_path = executable_path + relative_path; - Rml::Core::String absolute_lookup_file = absolute_path + lookup_file; + Rml::String absolute_path = executable_path + relative_path; + Rml::String absolute_lookup_file = absolute_path + lookup_file; if (isRegularFile(absolute_lookup_file)) { @@ -120,7 +120,7 @@ Rml::Core::String Shell::FindSamplesRoot() } } - return Rml::Core::String(); + return Rml::String(); } static Display* display = nullptr; @@ -371,7 +371,7 @@ double Shell::GetElapsedTime() return result; } -void Shell::SetMouseCursor(const Rml::Core::String& cursor_name) +void Shell::SetMouseCursor(const Rml::String& cursor_name) { if (display && window) { @@ -398,13 +398,13 @@ void Shell::SetMouseCursor(const Rml::Core::String& cursor_name) } } -void Shell::SetClipboardText(const Rml::Core::String& text) +void Shell::SetClipboardText(const Rml::String& text) { // Todo: interface with system clipboard clipboard_text = text; } -void Shell::GetClipboardText(Rml::Core::String& text) +void Shell::GetClipboardText(Rml::String& text) { // Todo: interface with system clipboard text = clipboard_text; diff --git a/Samples/tutorial/datagrid/src/DecoratorDefender.cpp b/Samples/tutorial/datagrid/src/DecoratorDefender.cpp index dc6f15b0a..ca1d775f6 100644 --- a/Samples/tutorial/datagrid/src/DecoratorDefender.cpp +++ b/Samples/tutorial/datagrid/src/DecoratorDefender.cpp @@ -19,7 +19,7 @@ DecoratorDefender::~DecoratorDefender() { } -bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path) +bool DecoratorDefender::Initialise(const Rml::String& image_source, const Rml::String& image_path) { image_index = LoadTexture(image_source, image_path); if (image_index == -1) @@ -31,30 +31,30 @@ bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element)) const +Rml::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Element* RMLUI_UNUSED_PARAMETER(element)) const { RMLUI_UNUSED(element); - return Rml::Core::Decorator::INVALID_DECORATORDATAHANDLE; + return Rml::Decorator::INVALID_DECORATORDATAHANDLE; } // Called to release element data generated by this decorator. -void DecoratorDefender::ReleaseElementData(Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::ReleaseElementData(Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); } // Called to render the decorator on an element. -void DecoratorDefender::RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); - Rml::Core::Vector2f position = element->GetAbsoluteOffset(Rml::Core::Box::PADDING); - Rml::Core::Vector2f size = element->GetBox().GetSize(Rml::Core::Box::PADDING); + Rml::Vector2f position = element->GetAbsoluteOffset(Rml::Box::PADDING); + Rml::Vector2f size = element->GetBox().GetSize(Rml::Box::PADDING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, (GLuint) GetTexture(image_index)->GetHandle(element->GetRenderInterface())); - Rml::Core::Colourb colour = element->GetProperty< Rml::Core::Colourb >("color"); + Rml::Colourb colour = element->GetProperty< Rml::Colourb >("color"); glColor4ubv(colour); glBegin(GL_QUADS); diff --git a/Samples/tutorial/datagrid/src/DecoratorDefender.h b/Samples/tutorial/datagrid/src/DecoratorDefender.h index 8e9eeda9b..bf9979044 100644 --- a/Samples/tutorial/datagrid/src/DecoratorDefender.h +++ b/Samples/tutorial/datagrid/src/DecoratorDefender.h @@ -19,25 +19,25 @@ @author Robert Curry */ -class DecoratorDefender : public Rml::Core::Decorator +class DecoratorDefender : public Rml::Decorator { public: virtual ~DecoratorDefender(); - bool Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path); + bool Initialise(const Rml::String& image_source, const Rml::String& image_path); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param element[in] The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param element_data[in] The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param element[in] The element to render the decorator on. /// @param element_data[in] The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int image_index; diff --git a/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp b/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp index 0b0bdd15a..8deb08e13 100644 --- a/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp +++ b/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.cpp @@ -18,7 +18,7 @@ DecoratorInstancerDefender::DecoratorInstancerDefender() { id_image_src = RegisterProperty("image-src", "").AddParser("string").GetId(); - RegisterShorthand("decorator", "image-src", Rml::Core::ShorthandType::FallThrough); + RegisterShorthand("decorator", "image-src", Rml::ShorthandType::FallThrough); } DecoratorInstancerDefender::~DecoratorInstancerDefender() @@ -26,12 +26,12 @@ DecoratorInstancerDefender::~DecoratorInstancerDefender() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - const Rml::Core::Property* image_source_property = properties.GetProperty(id_image_src); - Rml::Core::String image_source = image_source_property->Get< Rml::Core::String >(); - Rml::Core::String source_path; + const Rml::Property* image_source_property = properties.GetProperty(id_image_src); + Rml::String image_source = image_source_property->Get< Rml::String >(); + Rml::String source_path; if (auto & source = image_source_property->source) source_path = source->path; diff --git a/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h b/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h index 5cfbef47f..fe17dc7c4 100644 --- a/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h +++ b/Samples/tutorial/datagrid/src/DecoratorInstancerDefender.h @@ -19,7 +19,7 @@ @author Robert Curry */ -class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer +class DecoratorInstancerDefender : public Rml::DecoratorInstancer { public: DecoratorInstancerDefender(); @@ -30,10 +30,10 @@ class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer /// @param[in] properties All RCSS properties associated with the decorator. /// @param[in] interface An interface for querying the active style sheet. /// @return A shared_ptr to the decorator if it was instanced successfully. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_image_src; + Rml::PropertyId id_image_src; }; #endif diff --git a/Samples/tutorial/datagrid/src/HighScores.cpp b/Samples/tutorial/datagrid/src/HighScores.cpp index cd5996d3b..3c2692823 100644 --- a/Samples/tutorial/datagrid/src/HighScores.cpp +++ b/Samples/tutorial/datagrid/src/HighScores.cpp @@ -46,7 +46,7 @@ void HighScores::Shutdown() delete instance; } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score) { for (size_t i = 0; i < NUM_SCORES; i++) { @@ -72,8 +72,8 @@ void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Col void HighScores::LoadScores() { // Open and read the high score file. - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle scores_file = file_interface->Open("tutorial/datagrid/data/high_score.txt"); + Rml::FileInterface* file_interface = Rml::GetFileInterface(); + Rml::FileHandle scores_file = file_interface->Open("tutorial/datagrid/data/high_score.txt"); if (scores_file) { @@ -88,23 +88,23 @@ void HighScores::LoadScores() file_interface->Close(scores_file); buffer[scores_length] = 0; - Rml::Core::StringList score_lines; - Rml::Core::StringUtilities::ExpandString(score_lines, buffer, '\n'); + Rml::StringList score_lines; + Rml::StringUtilities::ExpandString(score_lines, buffer, '\n'); delete[] buffer; for (size_t i = 0; i < score_lines.size(); i++) { - Rml::Core::StringList score_parts; - Rml::Core::StringUtilities::ExpandString(score_parts, score_lines[i], '\t'); + Rml::StringList score_parts; + Rml::StringUtilities::ExpandString(score_parts, score_lines[i], '\t'); if (score_parts.size() == 4) { - Rml::Core::Colourb colour; + Rml::Colourb colour; int wave; int score; - if (Rml::Core::TypeConverter< Rml::Core::String , Rml::Core::Colourb >::Convert(score_parts[1], colour) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[2], wave) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[3], score)) + if (Rml::TypeConverter< Rml::String , Rml::Colourb >::Convert(score_parts[1], colour) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[2], wave) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[3], score)) { SubmitScore(score_parts[0], colour, wave, score); } diff --git a/Samples/tutorial/datagrid/src/HighScores.h b/Samples/tutorial/datagrid/src/HighScores.h index 9d5a2abbb..379dab0eb 100644 --- a/Samples/tutorial/datagrid/src/HighScores.h +++ b/Samples/tutorial/datagrid/src/HighScores.h @@ -33,13 +33,13 @@ class HighScores static HighScores* instance; - void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score); + void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score); void LoadScores(); struct Score { - Rml::Core::String name; - Rml::Core::Colourb colour; + Rml::String name; + Rml::Colourb colour; int score; int wave; }; diff --git a/Samples/tutorial/datagrid/src/main.cpp b/Samples/tutorial/datagrid/src/main.cpp index 089cc5334..83b4ebc91 100644 --- a/Samples/tutorial/datagrid/src/main.cpp +++ b/Samples/tutorial/datagrid/src/main.cpp @@ -10,7 +10,6 @@ */ #include -#include #include #include #include @@ -18,7 +17,7 @@ #include "DecoratorInstancerDefender.h" #include "HighScores.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -64,20 +63,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(1024,768); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); - Rml::Controls::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(1024, 768)); + context = Rml::CreateContext("main", Rml::Vector2i(1024, 768)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -90,13 +88,13 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) // Load the defender decorator. DecoratorInstancerDefender decorator_instancer_defender; - Rml::Core::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); + Rml::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); // Construct the high scores. HighScores::Initialise(); // Load and show the tutorial document. - Rml::Core::ElementDocument* document = context->LoadDocument("tutorial/datagrid/data/tutorial.rml"); + Rml::ElementDocument* document = context->LoadDocument("tutorial/datagrid/data/tutorial.rml"); if (document) { document->GetElementById("title")->SetInnerRML(document->GetTitle()); @@ -109,7 +107,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) HighScores::Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp b/Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp index dc6f15b0a..ca1d775f6 100644 --- a/Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp +++ b/Samples/tutorial/datagrid_tree/src/DecoratorDefender.cpp @@ -19,7 +19,7 @@ DecoratorDefender::~DecoratorDefender() { } -bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path) +bool DecoratorDefender::Initialise(const Rml::String& image_source, const Rml::String& image_path) { image_index = LoadTexture(image_source, image_path); if (image_index == -1) @@ -31,30 +31,30 @@ bool DecoratorDefender::Initialise(const Rml::Core::String& image_source, const } /// Called on a decorator to generate any required per-element data for a newly decorated element. -Rml::Core::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Core::Element* RMLUI_UNUSED_PARAMETER(element)) const +Rml::DecoratorDataHandle DecoratorDefender::GenerateElementData(Rml::Element* RMLUI_UNUSED_PARAMETER(element)) const { RMLUI_UNUSED(element); - return Rml::Core::Decorator::INVALID_DECORATORDATAHANDLE; + return Rml::Decorator::INVALID_DECORATORDATAHANDLE; } // Called to release element data generated by this decorator. -void DecoratorDefender::ReleaseElementData(Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::ReleaseElementData(Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); } // Called to render the decorator on an element. -void DecoratorDefender::RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const +void DecoratorDefender::RenderElement(Rml::Element* element, Rml::DecoratorDataHandle RMLUI_UNUSED_PARAMETER(element_data)) const { RMLUI_UNUSED(element_data); - Rml::Core::Vector2f position = element->GetAbsoluteOffset(Rml::Core::Box::PADDING); - Rml::Core::Vector2f size = element->GetBox().GetSize(Rml::Core::Box::PADDING); + Rml::Vector2f position = element->GetAbsoluteOffset(Rml::Box::PADDING); + Rml::Vector2f size = element->GetBox().GetSize(Rml::Box::PADDING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, (GLuint) GetTexture(image_index)->GetHandle(element->GetRenderInterface())); - Rml::Core::Colourb colour = element->GetProperty< Rml::Core::Colourb >("color"); + Rml::Colourb colour = element->GetProperty< Rml::Colourb >("color"); glColor4ubv(colour); glBegin(GL_QUADS); diff --git a/Samples/tutorial/datagrid_tree/src/DecoratorDefender.h b/Samples/tutorial/datagrid_tree/src/DecoratorDefender.h index 8e9eeda9b..bf9979044 100644 --- a/Samples/tutorial/datagrid_tree/src/DecoratorDefender.h +++ b/Samples/tutorial/datagrid_tree/src/DecoratorDefender.h @@ -19,25 +19,25 @@ @author Robert Curry */ -class DecoratorDefender : public Rml::Core::Decorator +class DecoratorDefender : public Rml::Decorator { public: virtual ~DecoratorDefender(); - bool Initialise(const Rml::Core::String& image_source, const Rml::Core::String& image_path); + bool Initialise(const Rml::String& image_source, const Rml::String& image_path); /// Called on a decorator to generate any required per-element data for a newly decorated element. /// @param element[in] The newly decorated element. /// @return A handle to a decorator-defined data handle, or nullptr if none is needed for the element. - Rml::Core::DecoratorDataHandle GenerateElementData(Rml::Core::Element* element) const override; + Rml::DecoratorDataHandle GenerateElementData(Rml::Element* element) const override; /// Called to release element data generated by this decorator. /// @param element_data[in] The element data handle to release. - void ReleaseElementData(Rml::Core::DecoratorDataHandle element_data) const override; + void ReleaseElementData(Rml::DecoratorDataHandle element_data) const override; /// Called to render the decorator on an element. /// @param element[in] The element to render the decorator on. /// @param element_data[in] The handle to the data generated by the decorator for the element. - void RenderElement(Rml::Core::Element* element, Rml::Core::DecoratorDataHandle element_data) const override; + void RenderElement(Rml::Element* element, Rml::DecoratorDataHandle element_data) const override; private: int image_index; diff --git a/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp b/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp index 8094f537f..8c3587ece 100644 --- a/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp +++ b/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.cpp @@ -18,7 +18,7 @@ DecoratorInstancerDefender::DecoratorInstancerDefender() { id_image_src = RegisterProperty("image-src", "").AddParser("string").GetId(); - RegisterShorthand("decorator", "image-src", Rml::Core::ShorthandType::FallThrough); + RegisterShorthand("decorator", "image-src", Rml::ShorthandType::FallThrough); } DecoratorInstancerDefender::~DecoratorInstancerDefender() @@ -26,12 +26,12 @@ DecoratorInstancerDefender::~DecoratorInstancerDefender() } // Instances a decorator given the property tag and attributes from the RCSS file. -std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::Core::String& /*name*/, - const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& /*interface*/) +std::shared_ptr DecoratorInstancerDefender::InstanceDecorator(const Rml::String& /*name*/, + const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& /*interface*/) { - const Rml::Core::Property* image_source_property = properties.GetProperty(id_image_src); - Rml::Core::String image_source = image_source_property->Get< Rml::Core::String >(); - Rml::Core::String source_path; + const Rml::Property* image_source_property = properties.GetProperty(id_image_src); + Rml::String image_source = image_source_property->Get< Rml::String >(); + Rml::String source_path; if (auto & source = image_source_property->source) source_path = source->path; diff --git a/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h b/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h index 5cfbef47f..fe17dc7c4 100644 --- a/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h +++ b/Samples/tutorial/datagrid_tree/src/DecoratorInstancerDefender.h @@ -19,7 +19,7 @@ @author Robert Curry */ -class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer +class DecoratorInstancerDefender : public Rml::DecoratorInstancer { public: DecoratorInstancerDefender(); @@ -30,10 +30,10 @@ class DecoratorInstancerDefender : public Rml::Core::DecoratorInstancer /// @param[in] properties All RCSS properties associated with the decorator. /// @param[in] interface An interface for querying the active style sheet. /// @return A shared_ptr to the decorator if it was instanced successfully. - std::shared_ptr InstanceDecorator(const Rml::Core::String& name, const Rml::Core::PropertyDictionary& properties, const Rml::Core::DecoratorInstancerInterface& interface) override; + std::shared_ptr InstanceDecorator(const Rml::String& name, const Rml::PropertyDictionary& properties, const Rml::DecoratorInstancerInterface& interface) override; private: - Rml::Core::PropertyId id_image_src; + Rml::PropertyId id_image_src; }; #endif diff --git a/Samples/tutorial/datagrid_tree/src/HighScores.cpp b/Samples/tutorial/datagrid_tree/src/HighScores.cpp index c9ffe7e1d..01755a64d 100644 --- a/Samples/tutorial/datagrid_tree/src/HighScores.cpp +++ b/Samples/tutorial/datagrid_tree/src/HighScores.cpp @@ -17,7 +17,7 @@ HighScores* HighScores::instance = nullptr; -HighScores::HighScores() : Rml::Controls::DataSource("high_scores") +HighScores::HighScores() : Rml::DataSource("high_scores") { RMLUI_ASSERT(instance == nullptr); instance = this; @@ -46,7 +46,7 @@ void HighScores::Shutdown() delete instance; } -void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) +void HighScores::GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns) { if (table == "scores") { @@ -58,23 +58,23 @@ void HighScores::GetRow(Rml::Core::StringList& row, const Rml::Core::String& tab } else if (columns[i] == "score") { - row.push_back(Rml::Core::CreateString(32, "%d", scores[row_index].score)); + row.push_back(Rml::CreateString(32, "%d", scores[row_index].score)); } else if (columns[i] == "colour") { - Rml::Core::String colour_string; - Rml::Core::TypeConverter< Rml::Core::Colourb, Rml::Core::String >::Convert(scores[row_index].colour, colour_string); + Rml::String colour_string; + Rml::TypeConverter< Rml::Colourb, Rml::String >::Convert(scores[row_index].colour, colour_string); row.push_back(colour_string); } else if (columns[i] == "wave") { - row.push_back(Rml::Core::CreateString(8, "%d", scores[row_index].wave)); + row.push_back(Rml::CreateString(8, "%d", scores[row_index].wave)); } } } } -int HighScores::GetNumRows(const Rml::Core::String& table) +int HighScores::GetNumRows(const Rml::String& table) { if (table == "scores") { @@ -92,7 +92,7 @@ int HighScores::GetNumRows(const Rml::Core::String& table) return 0; } -void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, int alien_kills[]) +void HighScores::SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, int alien_kills[]) { for (size_t i = 0; i < NUM_SCORES; i++) { @@ -125,8 +125,8 @@ void HighScores::SubmitScore(const Rml::Core::String& name, const Rml::Core::Col void HighScores::LoadScores() { // Open and read the high score file. - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle scores_file = file_interface->Open("tutorial/datagrid_tree/data/high_score.txt"); + Rml::FileInterface* file_interface = Rml::GetFileInterface(); + Rml::FileHandle scores_file = file_interface->Open("tutorial/datagrid_tree/data/high_score.txt"); if (scores_file) { @@ -141,28 +141,28 @@ void HighScores::LoadScores() file_interface->Close(scores_file); buffer[scores_length] = 0; - Rml::Core::StringList score_lines; - Rml::Core::StringUtilities::ExpandString(score_lines, buffer, '\n'); + Rml::StringList score_lines; + Rml::StringUtilities::ExpandString(score_lines, buffer, '\n'); delete[] buffer; for (size_t i = 0; i < score_lines.size(); i++) { - Rml::Core::StringList score_parts; - Rml::Core::StringUtilities::ExpandString(score_parts, score_lines[i], '\t'); + Rml::StringList score_parts; + Rml::StringUtilities::ExpandString(score_parts, score_lines[i], '\t'); if (score_parts.size() == 4 + NUM_ALIEN_TYPES) { - Rml::Core::Colourb colour; + Rml::Colourb colour; int wave; int score; int alien_kills[NUM_ALIEN_TYPES]; - if (Rml::Core::TypeConverter< Rml::Core::String , Rml::Core::Colourb >::Convert(score_parts[1], colour) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[2], wave) && - Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[3], score)) + if (Rml::TypeConverter< Rml::String , Rml::Colourb >::Convert(score_parts[1], colour) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[2], wave) && + Rml::TypeConverter< Rml::String, int >::Convert(score_parts[3], score)) { for (int j = 0; j < NUM_ALIEN_TYPES; j++) { - if (!Rml::Core::TypeConverter< Rml::Core::String, int >::Convert(score_parts[4 + j], alien_kills[j])) + if (!Rml::TypeConverter< Rml::String, int >::Convert(score_parts[4 + j], alien_kills[j])) { break; } diff --git a/Samples/tutorial/datagrid_tree/src/HighScores.h b/Samples/tutorial/datagrid_tree/src/HighScores.h index e8245894d..7f558303f 100644 --- a/Samples/tutorial/datagrid_tree/src/HighScores.h +++ b/Samples/tutorial/datagrid_tree/src/HighScores.h @@ -13,7 +13,7 @@ #define HIGHSCORES_H #include -#include +#include const int NUM_SCORES = 10; const int NUM_ALIEN_TYPES = 3; @@ -23,14 +23,14 @@ const int NUM_ALIEN_TYPES = 3; @author Robert Curry */ -class HighScores : public Rml::Controls::DataSource +class HighScores : public Rml::DataSource { public: static void Initialise(); static void Shutdown(); - void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns); - int GetNumRows(const Rml::Core::String& table); + void GetRow(Rml::StringList& row, const Rml::String& table, int row_index, const Rml::StringList& columns); + int GetNumRows(const Rml::String& table); private: HighScores(); @@ -38,13 +38,13 @@ class HighScores : public Rml::Controls::DataSource static HighScores* instance; - void SubmitScore(const Rml::Core::String& name, const Rml::Core::Colourb& colour, int wave, int score, int alien_kills[]); + void SubmitScore(const Rml::String& name, const Rml::Colourb& colour, int wave, int score, int alien_kills[]); void LoadScores(); struct Score { - Rml::Core::String name; - Rml::Core::Colourb colour; + Rml::String name; + Rml::Colourb colour; int score; int wave; diff --git a/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp b/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp index c444d8b5b..85c7ea3d8 100644 --- a/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp +++ b/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.cpp @@ -12,7 +12,7 @@ #include "HighScoresShipFormatter.h" #include -HighScoresShipFormatter::HighScoresShipFormatter() : Rml::Controls::DataFormatter("ship") +HighScoresShipFormatter::HighScoresShipFormatter() : Rml::DataFormatter("ship") { } @@ -20,15 +20,15 @@ HighScoresShipFormatter::~HighScoresShipFormatter() { } -void HighScoresShipFormatter::FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) +void HighScoresShipFormatter::FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data) { // Data format: // raw_data[0] is the colour, in "%d, %d, %d, %d" format. - Rml::Core::Colourb ship_colour; - Rml::Core::TypeConverter< Rml::Core::String, Rml::Core::Colourb >::Convert(raw_data[0], ship_colour); + Rml::Colourb ship_colour; + Rml::TypeConverter< Rml::String, Rml::Colourb >::Convert(raw_data[0], ship_colour); - Rml::Core::String colour_string = Rml::Core::CreateString(32, "%d,%d,%d", ship_colour.red, ship_colour.green, ship_colour.blue); + Rml::String colour_string = Rml::CreateString(32, "%d,%d,%d", ship_colour.red, ship_colour.green, ship_colour.blue); formatted_data = ""; } diff --git a/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h b/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h index 2b24256a5..66876f5bf 100644 --- a/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h +++ b/Samples/tutorial/datagrid_tree/src/HighScoresShipFormatter.h @@ -12,20 +12,20 @@ #ifndef HIGHSCORESSHIPFORMATTER_H #define HIGHSCORESSHIPFORMATTER_H -#include +#include /** Formats the colour of the player's ship to a tag, which is linked to the defender decorator. @author Robert Curry */ -class HighScoresShipFormatter : public Rml::Controls::DataFormatter +class HighScoresShipFormatter : public Rml::DataFormatter { public: HighScoresShipFormatter(); ~HighScoresShipFormatter(); - void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data); + void FormatData(Rml::String& formatted_data, const Rml::StringList& raw_data); }; #endif diff --git a/Samples/tutorial/datagrid_tree/src/main.cpp b/Samples/tutorial/datagrid_tree/src/main.cpp index 0c5f92c37..29edb6113 100644 --- a/Samples/tutorial/datagrid_tree/src/main.cpp +++ b/Samples/tutorial/datagrid_tree/src/main.cpp @@ -10,7 +10,6 @@ */ #include -#include #include #include #include @@ -19,7 +18,7 @@ #include "HighScores.h" #include "HighScoresShipFormatter.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -68,20 +67,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); - Rml::Controls::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -94,7 +92,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) // Load the defender decorator. DecoratorInstancerDefender decorator_instancer_defender; - Rml::Core::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); + Rml::Factory::RegisterDecoratorInstancer("defender", &decorator_instancer_defender); // Add the ship formatter. HighScoresShipFormatter ship_formatter; @@ -103,7 +101,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) HighScores::Initialise(); // Load and show the tutorial document. - Rml::Core::ElementDocument* document = context->LoadDocument("tutorial/datagrid_tree/data/tutorial.rml"); + Rml::ElementDocument* document = context->LoadDocument("tutorial/datagrid_tree/data/tutorial.rml"); if (document) { document->GetElementById("title")->SetInnerRML(document->GetTitle()); @@ -116,7 +114,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) HighScores::Shutdown(); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/tutorial/drag/src/Inventory.cpp b/Samples/tutorial/drag/src/Inventory.cpp index c21ea0888..934bfeffd 100644 --- a/Samples/tutorial/drag/src/Inventory.cpp +++ b/Samples/tutorial/drag/src/Inventory.cpp @@ -2,14 +2,14 @@ #include // Constructs a new inventory and opens its window. -Inventory::Inventory(const Rml::Core::String& title, const Rml::Core::Vector2f& position, Rml::Core::Context* context) +Inventory::Inventory(const Rml::String& title, const Rml::Vector2f& position, Rml::Context* context) { document = context->LoadDocument("tutorial/drag/data/inventory.rml"); if (document) { document->GetElementById("title")->SetInnerRML(title); - document->SetProperty(Rml::Core::PropertyId::Left, Rml::Core::Property(position.x, Rml::Core::Property::PX)); - document->SetProperty(Rml::Core::PropertyId::Top, Rml::Core::Property(position.y, Rml::Core::Property::PX)); + document->SetProperty(Rml::PropertyId::Left, Rml::Property(position.x, Rml::Property::PX)); + document->SetProperty(Rml::PropertyId::Top, Rml::Property(position.y, Rml::Property::PX)); document->Show(); } } @@ -22,17 +22,17 @@ Inventory::~Inventory() } // Adds a brand-new item into this inventory. -void Inventory::AddItem(const Rml::Core::String& name) +void Inventory::AddItem(const Rml::String& name) { if (!document) return; - Rml::Core::Element* content = document->GetElementById("content"); + Rml::Element* content = document->GetElementById("content"); if (!content) return; // Create the new 'icon' element. - Rml::Core::ElementPtr icon = Rml::Core::Factory::InstanceElement(content, "icon", "icon", Rml::Core::XMLAttributes()); + Rml::ElementPtr icon = Rml::Factory::InstanceElement(content, "icon", "icon", Rml::XMLAttributes()); icon->SetInnerRML(name); content->AppendChild(std::move(icon)); } diff --git a/Samples/tutorial/drag/src/Inventory.h b/Samples/tutorial/drag/src/Inventory.h index e37ce1c03..901260eea 100644 --- a/Samples/tutorial/drag/src/Inventory.h +++ b/Samples/tutorial/drag/src/Inventory.h @@ -16,16 +16,16 @@ class Inventory /// @param[in] title The title of the new inventory. /// @param[in] position The position of the inventory window. /// @param[in] context The context to open the inventory window in. - Inventory(const Rml::Core::String& title, const Rml::Core::Vector2f& position, Rml::Core::Context* context); + Inventory(const Rml::String& title, const Rml::Vector2f& position, Rml::Context* context); /// Destroys the inventory and closes its window. ~Inventory(); /// Adds a brand-new item into this inventory. /// @param[in] name The name of this item. - void AddItem(const Rml::Core::String& name); + void AddItem(const Rml::String& name); private: - Rml::Core::ElementDocument* document; + Rml::ElementDocument* document; }; #endif diff --git a/Samples/tutorial/drag/src/main.cpp b/Samples/tutorial/drag/src/main.cpp index 53c2201b4..3977a6702 100644 --- a/Samples/tutorial/drag/src/main.cpp +++ b/Samples/tutorial/drag/src/main.cpp @@ -16,7 +16,7 @@ #include #include "Inventory.h" -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -65,19 +65,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -89,8 +89,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Load and show the inventory document. - Inventory* inventory_1 = new Inventory("Inventory 1", Rml::Core::Vector2f(50, 200), context); - Inventory* inventory_2 = new Inventory("Inventory 2", Rml::Core::Vector2f(540, 240), context); + Inventory* inventory_1 = new Inventory("Inventory 1", Rml::Vector2f(50, 200), context); + Inventory* inventory_2 = new Inventory("Inventory 2", Rml::Vector2f(540, 240), context); // Add items into the inventory. inventory_1->AddItem("Mk III L.A.S.E.R."); @@ -104,7 +104,7 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) delete inventory_2; // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Samples/tutorial/template/src/main.cpp b/Samples/tutorial/template/src/main.cpp index 4c126628f..a102f5d26 100644 --- a/Samples/tutorial/template/src/main.cpp +++ b/Samples/tutorial/template/src/main.cpp @@ -15,7 +15,7 @@ #include #include -Rml::Core::Context* context = nullptr; +Rml::Context* context = nullptr; ShellRenderInterfaceExtensions *shell_renderer; @@ -64,19 +64,19 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) } // RmlUi initialisation. - Rml::Core::SetRenderInterface(&opengl_renderer); + Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; - Rml::Core::SetSystemInterface(&system_interface); + Rml::SetSystemInterface(&system_interface); - Rml::Core::Initialise(); + Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. - context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); + context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::Shutdown(); return -1; } @@ -88,13 +88,13 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) Shell::LoadFonts("assets/"); // Load and show the tutorial document. - if (Rml::Core::ElementDocument * document = context->LoadDocument("tutorial/template/data/tutorial.rml")) + if (Rml::ElementDocument * document = context->LoadDocument("tutorial/template/data/tutorial.rml")) document->Show(); Shell::EventLoop(GameLoop); // Shutdown RmlUi. - Rml::Core::Shutdown(); + Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); diff --git a/Source/Controls/Controls.cpp b/Source/Controls/Controls.cpp deleted file mode 100644 index 0d9ec9bd1..000000000 --- a/Source/Controls/Controls.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "../../Include/RmlUi/Controls/Controls.h" -#include "../../Include/RmlUi/Core/ElementInstancer.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/StyleSheetSpecification.h" -#include "../../Include/RmlUi/Core/XMLParser.h" -#include "../../Include/RmlUi/Core/Plugin.h" -#include "../../Include/RmlUi/Core/Core.h" -#include "../../Include/RmlUi/Core/Types.h" -#include "ElementTextSelection.h" -#include "XMLNodeHandlerDataGrid.h" -#include "XMLNodeHandlerTabSet.h" -#include "XMLNodeHandlerTextArea.h" -#include "../../Include/RmlUi/Controls/ElementForm.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" -#include "../../Include/RmlUi/Controls/ElementFormControlDataSelect.h" -#include "../../Include/RmlUi/Controls/ElementFormControlSelect.h" -#include "../../Include/RmlUi/Controls/ElementFormControlSelect.h" -#include "../../Include/RmlUi/Controls/ElementFormControlTextArea.h" -#include "../../Include/RmlUi/Controls/ElementTabSet.h" -#include "../../Include/RmlUi/Controls/ElementProgressBar.h" -#include "../../Include/RmlUi/Controls/ElementDataGrid.h" -#include "../../Include/RmlUi/Controls/ElementDataGridExpandButton.h" -#include "../../Include/RmlUi/Controls/ElementDataGridCell.h" -#include "../../Include/RmlUi/Controls/ElementDataGridRow.h" - -namespace Rml { -namespace Controls { - -struct ElementInstancers { - using Ptr = std::unique_ptr; - template using ElementInstancerGeneric = Core::ElementInstancerGeneric; - - Ptr form = std::make_unique>(); - Ptr input = std::make_unique>(); - Ptr dataselect = std::make_unique>(); - Ptr select = std::make_unique>(); - - Ptr textarea = std::make_unique>(); - Ptr selection = std::make_unique>(); - Ptr tabset = std::make_unique>(); - - Ptr progressbar = std::make_unique>(); - - Ptr datagrid = std::make_unique>(); - Ptr datagrid_expand = std::make_unique>(); - Ptr datagrid_cell = std::make_unique>(); - Ptr datagrid_row = std::make_unique>(); -}; - -static std::unique_ptr element_instancers; - - -// Registers the custom element instancers. -void RegisterElementInstancers() -{ - element_instancers = std::make_unique(); - - Core::Factory::RegisterElementInstancer("form", element_instancers->form.get()); - Core::Factory::RegisterElementInstancer("input", element_instancers->input.get()); - Core::Factory::RegisterElementInstancer("dataselect", element_instancers->dataselect.get()); - Core::Factory::RegisterElementInstancer("select", element_instancers->select.get()); - - Core::Factory::RegisterElementInstancer("textarea", element_instancers->textarea.get()); - Core::Factory::RegisterElementInstancer("#selection", element_instancers->selection.get()); - Core::Factory::RegisterElementInstancer("tabset", element_instancers->tabset.get()); - - Core::Factory::RegisterElementInstancer("progressbar", element_instancers->progressbar.get()); - - Core::Factory::RegisterElementInstancer("datagrid", element_instancers->datagrid.get()); - Core::Factory::RegisterElementInstancer("datagridexpand", element_instancers->datagrid_expand.get()); - Core::Factory::RegisterElementInstancer("#rmlctl_datagridcell", element_instancers->datagrid_cell.get()); - Core::Factory::RegisterElementInstancer("#rmlctl_datagridrow", element_instancers->datagrid_row.get()); -} - -void RegisterXMLNodeHandlers() -{ - Core::XMLParser::RegisterNodeHandler("datagrid", std::make_shared()); - Core::XMLParser::RegisterNodeHandler("tabset", std::make_shared()); - Core::XMLParser::RegisterNodeHandler("textarea", std::make_shared()); -} - -static bool initialised = false; - -class ControlsPlugin : public Rml::Core::Plugin -{ -public: - void OnShutdown() override - { - element_instancers.reset(); - initialised = false; - delete this; - } - - int GetEventClasses() override - { - return Rml::Core::Plugin::EVT_BASIC; - } -}; - -void Initialise() -{ - // Prevent double initialisation - if (!initialised) - { - // Register the element instancers for our custom elements. - RegisterElementInstancers(); - - // Register the XML node handlers for our elements that require special parsing. - RegisterXMLNodeHandlers(); - - // Register the controls plugin, so we'll be notified on Shutdown - Rml::Core::RegisterPlugin(new ControlsPlugin()); - - initialised = true; - } -} - -} -} diff --git a/Source/Controls/Lua/Controls.cpp b/Source/Controls/Lua/Controls.cpp deleted file mode 100644 index 587301b68..000000000 --- a/Source/Controls/Lua/Controls.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "precompiled.h" -#include -#include -#include -#include -#include -#include "SelectOptionsProxy.h" -#include "DataFormatter.h" -#include "DataSource.h" -#include "ElementForm.h" -#include "ElementFormControl.h" -#include "ElementFormControlSelect.h" -#include "ElementFormControlDataSelect.h" -#include "ElementFormControlInput.h" -#include "ElementFormControlTextArea.h" -#include "ElementDataGrid.h" -#include "ElementDataGridRow.h" -#include "ElementTabSet.h" - -using Rml::Core::Lua::LuaType; -namespace Rml { -namespace Controls { -namespace Lua { - -//This will define all of the types from RmlControls for Lua. There is not a -//corresponding function for types of RmlCore, because they are defined automatically -//when the Interpreter starts. -void RegisterTypes(lua_State* L) -{ - if(Rml::Core::Lua::Interpreter::GetLuaState() == nullptr) - { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, - "In Rml::Controls::Lua::RegisterTypes: Tried to register the \'Controls\' types for Lua without first initializing the Interpreter."); - return; - } - LuaType::Register(L); - LuaType::Register(L); - //Inherits from ElementFormControl - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - //proxy tables - LuaType::Register(L); -} - -} -} -} diff --git a/Source/Controls/Lua/precompiled.h b/Source/Controls/Lua/precompiled.h deleted file mode 100644 index 9efaa6c6f..000000000 --- a/Source/Controls/Lua/precompiled.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICORELUAPRECOMPILED_H -#define RMLUICORELUAPRECOMPILED_H - -#include -#include -#include -#include -#endif diff --git a/Source/Controls/WidgetSliderInput.cpp b/Source/Controls/WidgetSliderInput.cpp deleted file mode 100644 index 6b05ed7c9..000000000 --- a/Source/Controls/WidgetSliderInput.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "WidgetSliderInput.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/Element.h" -#include "../../Include/RmlUi/Core/Profiling.h" - -namespace Rml { -namespace Controls { - -WidgetSliderInput::WidgetSliderInput(ElementFormControl* parent) : WidgetSlider(parent) -{ - value = 0; - min_value = 0; - max_value = 100; - step = 1; -} - -WidgetSliderInput::~WidgetSliderInput() -{ -} - -void WidgetSliderInput::SetValue(float target_value) -{ - float num_steps = (target_value - min_value) / step; - float new_value = min_value + Rml::Core::Math::RoundFloat(num_steps) * step; - - if(new_value != value) - SetBarPosition(SetValueInternal(new_value)); -} - -float WidgetSliderInput::GetValue() const -{ - return value; -} - -// Sets the minimum value of the slider. -void WidgetSliderInput::SetMinValue(float _min_value) -{ - min_value = _min_value; -} - -// Sets the maximum value of the slider. -void WidgetSliderInput::SetMaxValue(float _max_value) -{ - max_value = _max_value; -} - -// Sets the slider's value increment. -void WidgetSliderInput::SetStep(float _step) -{ - // Can't have a zero step! - if (_step == 0) - return; - - step = _step; -} - -// Formats the slider's elements. -void WidgetSliderInput::FormatElements() -{ - RMLUI_ZoneScopedNC("RangeOnResize", 0x228044); - - Rml::Core::Vector2f box = GetParent()->GetBox().GetSize(); - WidgetSlider::FormatElements(box, GetOrientation() == VERTICAL ? box.y : box.x); -} - -// Called when the slider's bar position is set or dragged. -float WidgetSliderInput::OnBarChange(float bar_position) -{ - float new_value = min_value + bar_position * (max_value - min_value); - int num_steps = Rml::Core::Math::RoundToInteger((new_value - value) / step); - - return SetValueInternal(value + num_steps * step); -} - -// Called when the slider is incremented by one 'line'. -float WidgetSliderInput::OnLineIncrement() -{ - return SetValueInternal(value + step); -} - -// Called when the slider is decremented by one 'line'. -float WidgetSliderInput::OnLineDecrement() -{ - return SetValueInternal(value - step); -} - -// Clamps the new value, sets it on the slider. -float WidgetSliderInput::SetValueInternal(float new_value) -{ - if (min_value < max_value) - { - value = Rml::Core::Math::Clamp(new_value, min_value, max_value); - } - else if (min_value > max_value) - { - value = Rml::Core::Math::Clamp(new_value, max_value, min_value); - } - else - { - value = min_value; - return 0; - } - - Rml::Core::Dictionary parameters; - parameters["value"] = value; - GetParent()->DispatchEvent(Core::EventId::Change, parameters); - - - // TODO: This might not be the safest approach as this will call SetValue(), - // thus, a slight mismatch will result in infinite recursion. - GetParent()->SetAttribute("value", value); - - return (value - min_value) / (max_value - min_value); -} - -} -} diff --git a/Source/Controls/WidgetSliderInput.h b/Source/Controls/WidgetSliderInput.h deleted file mode 100644 index 2ba2e58c1..000000000 --- a/Source/Controls/WidgetSliderInput.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICONTROLSWIDGETSLIDERINPUT_H -#define RMLUICONTROLSWIDGETSLIDERINPUT_H - -#include "WidgetSlider.h" - -namespace Rml { -namespace Controls { - -/** - A specialisation of the slider widget for input sliders. - - @author Peter Curry - */ - -class WidgetSliderInput : public WidgetSlider -{ -public: - WidgetSliderInput(ElementFormControl* parent); - virtual ~WidgetSliderInput(); - - /// Sets a new value on the slider. - /// @param[in] value The new value for the slider. This will be clamped between the min and max values, and set to the nearest increment. - void SetValue(float value); - /// Returns the current value of the slider. - /// @return The current value of the slider. - float GetValue() const; - - /// Sets the minimum value of the slider. - /// @param[in] min_value The new minimum value of the slider. - void SetMinValue(float min_value); - /// Sets the maximum value of the slider. - /// @param[in] max_value The new minimum value of the slider. - void SetMaxValue(float max_value); - /// Sets the slider's value increment. - /// @param[in] step The new increment for the slider's value. - void SetStep(float step); - - /// Formats the slider's elements. - void FormatElements(); - -protected: - /// Called when the slider's bar position is set or dragged. - /// @param bar_position[in] The new position of the bar (0 representing the start of the track, 1 representing the end). - /// @return The new position of the bar. - float OnBarChange(float bar_position) override; - /// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the - /// increment arrow. - /// @return The new position of the bar. - float OnLineIncrement() override; - /// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the - /// decrement arrow. - /// @return The new position of the bar. - float OnLineDecrement() override; - -private: - /// Clamps the new value, sets it on the slider and returns it as a number from 0 to 1, 0 being the minimum - /// value and 1 the maximum. - /// @param[in] new_value The new value to set on the slider. - /// @return The new parametric value of the slider. - float SetValueInternal(float new_value); - - float value; - float min_value; - float max_value; - - float step; -}; - -} -} - -#endif diff --git a/Source/Core/BaseXMLParser.cpp b/Source/Core/BaseXMLParser.cpp index 8cb30a79a..5a7e24e1b 100644 --- a/Source/Core/BaseXMLParser.cpp +++ b/Source/Core/BaseXMLParser.cpp @@ -33,7 +33,6 @@ #include namespace Rml { -namespace Core { BaseXMLParser::BaseXMLParser() {} @@ -561,5 +560,4 @@ bool BaseXMLParser::PeekString(const char* string, bool consume) return success; } -} -} +} // namespace Rml diff --git a/Source/Core/Box.cpp b/Source/Core/Box.cpp index afc45c7e3..020d56c11 100644 --- a/Source/Core/Box.cpp +++ b/Source/Core/Box.cpp @@ -30,7 +30,6 @@ #include namespace Rml { -namespace Core { // Initialises a zero-sized box. Box::Box() : content(0, 0), offset(0, 0) @@ -127,5 +126,4 @@ bool Box::operator!=(const Box& rhs) const return !(*this == rhs); } -} -} +} // namespace Rml diff --git a/Source/Core/Clock.cpp b/Source/Core/Clock.cpp index 2e68746f6..26027aeea 100644 --- a/Source/Core/Clock.cpp +++ b/Source/Core/Clock.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/SystemInterface.h" namespace Rml { -namespace Core { RMLUICORE_API double Clock::GetElapsedTime() { @@ -42,5 +41,4 @@ RMLUICORE_API double Clock::GetElapsedTime() return 0; } -} -} +} // namespace Rml diff --git a/Source/Core/Clock.h b/Source/Core/Clock.h index 9f208d81b..2223a4f46 100644 --- a/Source/Core/Clock.h +++ b/Source/Core/Clock.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORECLOCK_H -#define RMLUICORECLOCK_H +#ifndef RMLUI_CORE_CLOCK_H +#define RMLUI_CORE_CLOCK_H #include "../../Include/RmlUi/Core/Header.h" namespace Rml { -namespace Core { /** RmlUi's Interface to Time. @@ -47,7 +46,5 @@ class Clock RMLUICORE_API static double GetElapsedTime(); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ComputeProperty.cpp b/Source/Core/ComputeProperty.cpp index aa6ff7094..051af9752 100644 --- a/Source/Core/ComputeProperty.cpp +++ b/Source/Core/ComputeProperty.cpp @@ -30,8 +30,6 @@ #include "ComputeProperty.h" namespace Rml { -namespace Core { - const Style::ComputedValues DefaultComputedValues = Style::ComputedValues{}; @@ -300,5 +298,4 @@ Style::LengthPercentage ComputeOrigin(const Property* property, float font_size, } -} -} +} // namespace Rml diff --git a/Source/Core/ComputeProperty.h b/Source/Core/ComputeProperty.h index 52873db74..bb9217d90 100644 --- a/Source/Core/ComputeProperty.h +++ b/Source/Core/ComputeProperty.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORECOMPUTEPROPERTY_H -#define RMLUICORECOMPUTEPROPERTY_H +#ifndef RMLUI_CORE_COMPUTEPROPERTY_H +#define RMLUI_CORE_COMPUTEPROPERTY_H #include "../../Include/RmlUi/Core/ComputedValues.h" namespace Rml { -namespace Core { class Property; @@ -59,7 +58,5 @@ Style::LengthPercentage ComputeOrigin(const Property* property, float font_size, extern const Style::ComputedValues DefaultComputedValues; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Context.cpp b/Source/Core/Context.cpp index 26fd39953..bee784a99 100644 --- a/Source/Core/Context.cpp +++ b/Source/Core/Context.cpp @@ -47,7 +47,6 @@ namespace Rml { -namespace Core { static constexpr float DOUBLE_CLICK_TIME = 0.5f; // [s] static constexpr float DOUBLE_CLICK_MAX_DIST = 3.f; // [dp] @@ -56,7 +55,7 @@ Context::Context(const String& name) : name(name), dimensions(0, 0), density_ind { instancer = nullptr; - // Initialise this to nullptr; this will be set in Rml::Core::CreateContext(). + // Initialise this to nullptr; this will be set in Rml::CreateContext(). render_interface = nullptr; root = Factory::InstanceElement(nullptr, "*", "#root", XMLAttributes()); @@ -1299,5 +1298,4 @@ void Context::Release() } } -} -} +} // namespace Rml diff --git a/Source/Core/ContextInstancer.cpp b/Source/Core/ContextInstancer.cpp index 132de3ed8..472215251 100644 --- a/Source/Core/ContextInstancer.cpp +++ b/Source/Core/ContextInstancer.cpp @@ -29,11 +29,9 @@ #include "../../Include/RmlUi/Core/ContextInstancer.h" namespace Rml { -namespace Core { ContextInstancer::~ContextInstancer() { } -} -} +} // namespace Rml diff --git a/Source/Core/ContextInstancerDefault.cpp b/Source/Core/ContextInstancerDefault.cpp index c3b2930f4..6d1f8949b 100644 --- a/Source/Core/ContextInstancerDefault.cpp +++ b/Source/Core/ContextInstancerDefault.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/Context.h" namespace Rml { -namespace Core { ContextInstancerDefault::ContextInstancerDefault() { @@ -56,5 +55,4 @@ void ContextInstancerDefault::Release() delete this; } -} -} +} // namespace Rml diff --git a/Source/Core/ContextInstancerDefault.h b/Source/Core/ContextInstancerDefault.h index 4f09c3174..034b8e36a 100644 --- a/Source/Core/ContextInstancerDefault.h +++ b/Source/Core/ContextInstancerDefault.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORECONTEXTINSTANCERDEFAULT_H -#define RMLUICORECONTEXTINSTANCERDEFAULT_H +#ifndef RMLUI_CORE_CONTEXTINSTANCERDEFAULT_H +#define RMLUI_CORE_CONTEXTINSTANCERDEFAULT_H #include "../../Include/RmlUi/Core/ContextInstancer.h" namespace Rml { -namespace Core { /** Default instancer for instancing contexts. @@ -59,7 +58,5 @@ class ContextInstancerDefault : public ContextInstancer void Release() override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ConvolutionFilter.cpp b/Source/Core/ConvolutionFilter.cpp index 3cbe83557..46aa4dc6a 100644 --- a/Source/Core/ConvolutionFilter.cpp +++ b/Source/Core/ConvolutionFilter.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { ConvolutionFilter::ConvolutionFilter() {} @@ -127,5 +126,4 @@ void ConvolutionFilter::Run(byte* destination, const Vector2i destination_dimens } } -} -} +} // namespace Rml diff --git a/Source/Core/Core.cpp b/Source/Core/Core.cpp index b26e58e89..588dc06b9 100644 --- a/Source/Core/Core.cpp +++ b/Source/Core/Core.cpp @@ -52,7 +52,6 @@ namespace Rml { -namespace Core { // RmlUi's renderer interface. static RenderInterface* render_interface = nullptr; @@ -333,5 +332,4 @@ void ReleaseCompiledGeometry() return GeometryDatabase::ReleaseAll(); } -} -} +} // namespace Rml diff --git a/Source/Core/DataController.cpp b/Source/Core/DataController.cpp index 09b2564f3..7b7c0e726 100644 --- a/Source/Core/DataController.cpp +++ b/Source/Core/DataController.cpp @@ -32,8 +32,6 @@ #include "EventSpecification.h" namespace Rml { -namespace Core { - DataController::DataController(Element* element) : attached_element(element->GetObserverPtr()) {} @@ -73,5 +71,4 @@ void DataControllers::OnElementRemove(Element* element) } -} -} +} // namespace Rml diff --git a/Source/Core/DataControllerDefault.cpp b/Source/Core/DataControllerDefault.cpp index 21e90a0b3..c6946b144 100644 --- a/Source/Core/DataControllerDefault.cpp +++ b/Source/Core/DataControllerDefault.cpp @@ -34,9 +34,6 @@ #include "EventSpecification.h" namespace Rml { -namespace Core { - - DataControllerValue::DataControllerValue(Element* element) : DataController(element) {} @@ -156,5 +153,4 @@ void DataControllerEvent::Release() delete this; } -} -} +} // namespace Rml diff --git a/Source/Core/DataControllerDefault.h b/Source/Core/DataControllerDefault.h index 0280f0241..6a0cc5213 100644 --- a/Source/Core/DataControllerDefault.h +++ b/Source/Core/DataControllerDefault.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATACONTROLLERDEFAULT_H -#define RMLUICOREDATACONTROLLERDEFAULT_H +#ifndef RMLUI_CORE_DATACONTROLLERDEFAULT_H +#define RMLUI_CORE_DATACONTROLLERDEFAULT_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Types.h" @@ -36,7 +36,6 @@ #include "../../Include/RmlUi/Core/DataController.h" namespace Rml { -namespace Core { class Element; class DataModel; @@ -84,7 +83,5 @@ class DataControllerEvent final : public DataController, private EventListener { DataExpressionPtr expression; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DataExpression.cpp b/Source/Core/DataExpression.cpp index 6217d7fcd..547bc064f 100644 --- a/Source/Core/DataExpression.cpp +++ b/Source/Core/DataExpression.cpp @@ -38,7 +38,6 @@ #endif namespace Rml { -namespace Core { class DataParser; @@ -980,7 +979,7 @@ struct TestParser { DataModelConstructor handle(&model, &type_register); handle.Bind("radius", &radius); handle.Bind("color_name", &color_name); - handle.BindFunc("color_value", [this](Rml::Core::Variant& variant) { + handle.BindFunc("color_value", [this](Variant& variant) { variant = ToString(color_value); }); @@ -1187,5 +1186,4 @@ bool DataExpressionInterface::EventCallback(const String& name, const VariantLis return true; } -} -} +} // namespace Rml diff --git a/Source/Core/DataExpression.h b/Source/Core/DataExpression.h index 1d914f215..615c217ae 100644 --- a/Source/Core/DataExpression.h +++ b/Source/Core/DataExpression.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREDATAEXPRESSION_H -#define RMLUICOREDATAEXPRESSION_H +#ifndef RMLUI_CORE_DATAEXPRESSION_H +#define RMLUI_CORE_DATAEXPRESSION_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Types.h" #include "../../Include/RmlUi/Core/DataTypes.h" namespace Rml { -namespace Core { class Element; class DataModel; @@ -79,7 +78,5 @@ class DataExpression { AddressList addresses; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DataModel.cpp b/Source/Core/DataModel.cpp index aeb18ed69..74c416ab2 100644 --- a/Source/Core/DataModel.cpp +++ b/Source/Core/DataModel.cpp @@ -32,8 +32,6 @@ #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { - static DataAddress ParseAddress(const String& address_str) { @@ -466,5 +464,4 @@ static struct TestDataVariables { #endif -} -} +} // namespace Rml diff --git a/Source/Core/DataTypeRegister.cpp b/Source/Core/DataTypeRegister.cpp index 03f8eb708..24e4a554d 100644 --- a/Source/Core/DataTypeRegister.cpp +++ b/Source/Core/DataTypeRegister.cpp @@ -29,8 +29,6 @@ #include "../../Include/RmlUi/Core/DataTypeRegister.h" namespace Rml { -namespace Core { - DataTypeRegister::DataTypeRegister() { @@ -122,5 +120,4 @@ bool TransformFuncRegister::Call(const String& name, Variant& inout_result, cons return transform_func(inout_result, arguments); } -} -} +} // namespace Rml diff --git a/Source/Core/DataVariable.cpp b/Source/Core/DataVariable.cpp index dfea84cf0..d5694483e 100644 --- a/Source/Core/DataVariable.cpp +++ b/Source/Core/DataVariable.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/DataVariable.h" namespace Rml { -namespace Core { bool DataVariable::Get(Variant& variant) { return definition->Get(ptr, variant); @@ -86,5 +85,4 @@ DataVariable MakeLiteralIntVariable(int value) return DataVariable(&literal_int_definition, reinterpret_cast(static_cast(value))); } -} -} +} // namespace Rml diff --git a/Source/Core/DataView.cpp b/Source/Core/DataView.cpp index a835bbb26..c999e8337 100644 --- a/Source/Core/DataView.cpp +++ b/Source/Core/DataView.cpp @@ -31,7 +31,6 @@ #include namespace Rml { -namespace Core { DataView::~DataView() {} @@ -158,5 +157,4 @@ bool DataViews::Update(DataModel& model, const DirtyVariables& dirty_variables) return result; } -} -} +} // namespace Rml diff --git a/Source/Core/DataViewDefault.cpp b/Source/Core/DataViewDefault.cpp index 6b8d6b3f3..942df1f93 100644 --- a/Source/Core/DataViewDefault.cpp +++ b/Source/Core/DataViewDefault.cpp @@ -35,8 +35,6 @@ #include "../../Include/RmlUi/Core/Variant.h" namespace Rml { -namespace Core { - DataViewCommon::DataViewCommon(Element* element, String override_modifier) : DataView(element), modifier(override_modifier) {} @@ -492,5 +490,4 @@ void DataViewFor::Release() delete this; } -} -} +} // namespace Rml diff --git a/Source/Core/DataViewDefault.h b/Source/Core/DataViewDefault.h index 8e8f94c4e..f2205382d 100644 --- a/Source/Core/DataViewDefault.h +++ b/Source/Core/DataViewDefault.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDATAVIEWDEFAULT_H -#define RMLUICOREDATAVIEWDEFAULT_H +#ifndef RMLUI_CORE_DATAVIEWDEFAULT_H +#define RMLUI_CORE_DATAVIEWDEFAULT_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Types.h" @@ -35,7 +35,6 @@ #include "../../Include/RmlUi/Core/Variant.h" namespace Rml { -namespace Core { class Element; class DataExpression; @@ -170,7 +169,5 @@ class DataViewFor final : public DataView { ElementList elements; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Decorator.cpp b/Source/Core/Decorator.cpp index 3a44c1d3c..dd67e6161 100644 --- a/Source/Core/Decorator.cpp +++ b/Source/Core/Decorator.cpp @@ -33,7 +33,6 @@ #include namespace Rml { -namespace Core { Decorator::Decorator() { @@ -102,5 +101,4 @@ const Texture* Decorator::GetTexture(int index) const } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorGradient.cpp b/Source/Core/DecoratorGradient.cpp index 9b753fbd4..b6ce87552 100644 --- a/Source/Core/DecoratorGradient.cpp +++ b/Source/Core/DecoratorGradient.cpp @@ -44,7 +44,6 @@ stop-color: #00ff00; */ namespace Rml { -namespace Core { //======================================================= @@ -139,5 +138,4 @@ SharedPtr DecoratorGradientInstancer::InstanceDecorator(const String return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorGradient.h b/Source/Core/DecoratorGradient.h index accb1ec59..8b2c20da4 100644 --- a/Source/Core/DecoratorGradient.h +++ b/Source/Core/DecoratorGradient.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREDECORATORGRADIENT_H -#define RMLUICOREDECORATORGRADIENT_H +#ifndef RMLUI_CORE_DECORATORGRADIENT_H +#define RMLUI_CORE_DECORATORGRADIENT_H #include "../../Include/RmlUi/Core/Decorator.h" #include "../../Include/RmlUi/Core/DecoratorInstancer.h" #include "../../Include/RmlUi/Core/Property.h" namespace Rml { -namespace Core { class DecoratorGradient : public Decorator { @@ -68,13 +67,11 @@ class DecoratorGradientInstancer : public DecoratorInstancer private: struct GradientPropertyIds { - Rml::Core::PropertyId direction, start, stop; + PropertyId direction, start, stop; }; GradientPropertyIds ids; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorInstancer.cpp b/Source/Core/DecoratorInstancer.cpp index 1e1ba1fd7..8016efcb5 100644 --- a/Source/Core/DecoratorInstancer.cpp +++ b/Source/Core/DecoratorInstancer.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/DecoratorInstancer.h" namespace Rml { -namespace Core { DecoratorInstancer::DecoratorInstancer() : properties(10, 10) { @@ -63,5 +62,4 @@ const Sprite* DecoratorInstancerInterface::GetSprite(const String& name) const { return style_sheet.GetSprite(name); } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorNinePatch.cpp b/Source/Core/DecoratorNinePatch.cpp index 9fb3d218f..101f70ff8 100644 --- a/Source/Core/DecoratorNinePatch.cpp +++ b/Source/Core/DecoratorNinePatch.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { DecoratorNinePatch::DecoratorNinePatch() { @@ -248,5 +247,4 @@ SharedPtr DecoratorNinePatchInstancer::InstanceDecorator(const String return decorator; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorNinePatch.h b/Source/Core/DecoratorNinePatch.h index 1ee4518b2..c83de3215 100644 --- a/Source/Core/DecoratorNinePatch.h +++ b/Source/Core/DecoratorNinePatch.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREDECORATORNINEPATCH_H -#define RMLUICOREDECORATORNINEPATCH_H +#ifndef RMLUI_CORE_DECORATORNINEPATCH_H +#define RMLUI_CORE_DECORATORNINEPATCH_H #include "../../Include/RmlUi/Core/Decorator.h" #include "../../Include/RmlUi/Core/DecoratorInstancer.h" @@ -35,7 +35,6 @@ #include "../../Include/RmlUi/Core/Spritesheet.h" namespace Rml { -namespace Core { class DecoratorNinePatch : public Decorator { @@ -71,7 +70,5 @@ class DecoratorNinePatchInstancer : public DecoratorInstancer }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiled.cpp b/Source/Core/DecoratorTiled.cpp index 18c5b5527..0828cc87a 100644 --- a/Source/Core/DecoratorTiled.cpp +++ b/Source/Core/DecoratorTiled.cpp @@ -33,7 +33,6 @@ #include namespace Rml { -namespace Core { DecoratorTiled::DecoratorTiled() { @@ -246,5 +245,4 @@ void DecoratorTiled::ScaleTileDimensions(Vector2f& tile_dimensions, float axis_v } } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiled.h b/Source/Core/DecoratorTiled.h index 7f65cec68..068f03db7 100644 --- a/Source/Core/DecoratorTiled.h +++ b/Source/Core/DecoratorTiled.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREDECORATORTILED_H -#define RMLUICOREDECORATORTILED_H +#ifndef RMLUI_CORE_DECORATORTILED_H +#define RMLUI_CORE_DECORATORTILED_H #include "../../Include/RmlUi/Core/ComputedValues.h" #include "../../Include/RmlUi/Core/Decorator.h" #include "../../Include/RmlUi/Core/Vertex.h" namespace Rml { -namespace Core { struct Texture; @@ -127,7 +126,5 @@ class DecoratorTiled : public Decorator void ScaleTileDimensions(Vector2f& tile_dimensions, float axis_value, int axis) const; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledBox.cpp b/Source/Core/DecoratorTiledBox.cpp index 9a134f86d..70d009212 100644 --- a/Source/Core/DecoratorTiledBox.cpp +++ b/Source/Core/DecoratorTiledBox.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/Geometry.h" namespace Rml { -namespace Core { struct DecoratorTiledBoxData { @@ -296,5 +295,4 @@ void DecoratorTiledBox::RenderElement(Element* element, DecoratorDataHandle elem data->geometry[i].Render(translation); } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledBox.h b/Source/Core/DecoratorTiledBox.h index 9ae911172..d4cfb95cb 100644 --- a/Source/Core/DecoratorTiledBox.h +++ b/Source/Core/DecoratorTiledBox.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDBOX_H -#define RMLUICOREDECORATORTILEDBOX_H +#ifndef RMLUI_CORE_DECORATORTILEDBOX_H +#define RMLUI_CORE_DECORATORTILEDBOX_H #include "DecoratorTiled.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -75,7 +74,5 @@ class DecoratorTiledBox : public DecoratorTiled Tile tiles[9]; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledBoxInstancer.cpp b/Source/Core/DecoratorTiledBoxInstancer.cpp index 5bafa1bd0..23a8baa69 100644 --- a/Source/Core/DecoratorTiledBoxInstancer.cpp +++ b/Source/Core/DecoratorTiledBoxInstancer.cpp @@ -30,7 +30,6 @@ #include "DecoratorTiledBox.h" namespace Rml { -namespace Core { DecoratorTiledBoxInstancer::DecoratorTiledBoxInstancer() : DecoratorTiledInstancer(9) { @@ -73,5 +72,4 @@ SharedPtrDecoratorTiledBoxInstancer::InstanceDecorator(const String& return decorator; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledBoxInstancer.h b/Source/Core/DecoratorTiledBoxInstancer.h index 2cf19add2..842786b71 100644 --- a/Source/Core/DecoratorTiledBoxInstancer.h +++ b/Source/Core/DecoratorTiledBoxInstancer.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDBOXINSTANCER_H -#define RMLUICOREDECORATORTILEDBOXINSTANCER_H +#ifndef RMLUI_CORE_DECORATORTILEDBOXINSTANCER_H +#define RMLUI_CORE_DECORATORTILEDBOXINSTANCER_H #include "DecoratorTiledInstancer.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -48,7 +47,5 @@ class DecoratorTiledBoxInstancer : public DecoratorTiledInstancer SharedPtr InstanceDecorator(const String& name, const PropertyDictionary& properties, const DecoratorInstancerInterface& interface) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledHorizontal.cpp b/Source/Core/DecoratorTiledHorizontal.cpp index 94821d7fe..ce0785baf 100644 --- a/Source/Core/DecoratorTiledHorizontal.cpp +++ b/Source/Core/DecoratorTiledHorizontal.cpp @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/Texture.h" namespace Rml { -namespace Core { struct DecoratorTiledHorizontalData { @@ -155,5 +154,4 @@ void DecoratorTiledHorizontal::RenderElement(Element* element, DecoratorDataHand data->geometry[i].Render(translation); } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledHorizontal.h b/Source/Core/DecoratorTiledHorizontal.h index 6b0b98672..b70f1dc69 100644 --- a/Source/Core/DecoratorTiledHorizontal.h +++ b/Source/Core/DecoratorTiledHorizontal.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDHORIZONTAL_H -#define RMLUICOREDECORATORTILEDHORIZONTAL_H +#ifndef RMLUI_CORE_DECORATORTILEDHORIZONTAL_H +#define RMLUI_CORE_DECORATORTILEDHORIZONTAL_H #include "DecoratorTiled.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -69,7 +68,5 @@ class DecoratorTiledHorizontal : public DecoratorTiled Tile tiles[3]; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledHorizontalInstancer.cpp b/Source/Core/DecoratorTiledHorizontalInstancer.cpp index c89bcb02f..1193f1a51 100644 --- a/Source/Core/DecoratorTiledHorizontalInstancer.cpp +++ b/Source/Core/DecoratorTiledHorizontalInstancer.cpp @@ -30,7 +30,6 @@ #include "DecoratorTiledHorizontal.h" namespace Rml { -namespace Core { DecoratorTiledHorizontalInstancer::DecoratorTiledHorizontalInstancer() : DecoratorTiledInstancer(3) { @@ -64,5 +63,4 @@ SharedPtr DecoratorTiledHorizontalInstancer::InstanceDecorator(const } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledHorizontalInstancer.h b/Source/Core/DecoratorTiledHorizontalInstancer.h index 4904348f8..afe1aa957 100644 --- a/Source/Core/DecoratorTiledHorizontalInstancer.h +++ b/Source/Core/DecoratorTiledHorizontalInstancer.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDHORIZONTALINSTANCER_H -#define RMLUICOREDECORATORTILEDHORIZONTALINSTANCER_H +#ifndef RMLUI_CORE_DECORATORTILEDHORIZONTALINSTANCER_H +#define RMLUI_CORE_DECORATORTILEDHORIZONTALINSTANCER_H #include "DecoratorTiledInstancer.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -48,7 +47,5 @@ class DecoratorTiledHorizontalInstancer : public DecoratorTiledInstancer SharedPtr InstanceDecorator(const String& name, const PropertyDictionary& properties, const DecoratorInstancerInterface& interface) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledImage.cpp b/Source/Core/DecoratorTiledImage.cpp index fc2bbcfd5..d8d3c7fd8 100644 --- a/Source/Core/DecoratorTiledImage.cpp +++ b/Source/Core/DecoratorTiledImage.cpp @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/GeometryUtilities.h" namespace Rml { -namespace Core { DecoratorTiledImage::DecoratorTiledImage() { @@ -77,5 +76,4 @@ void DecoratorTiledImage::RenderElement(Element* element, DecoratorDataHandle el data->Render(element->GetAbsoluteOffset(Box::PADDING).Round()); } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledImage.h b/Source/Core/DecoratorTiledImage.h index 47c262c68..d369c58b7 100644 --- a/Source/Core/DecoratorTiledImage.h +++ b/Source/Core/DecoratorTiledImage.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDIMAGE_H -#define RMLUICOREDECORATORTILEDIMAGE_H +#ifndef RMLUI_CORE_DECORATORTILEDIMAGE_H +#define RMLUI_CORE_DECORATORTILEDIMAGE_H #include "DecoratorTiled.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -62,7 +61,5 @@ class DecoratorTiledImage : public DecoratorTiled Tile tile; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledImageInstancer.cpp b/Source/Core/DecoratorTiledImageInstancer.cpp index cb2826884..36ad792fb 100644 --- a/Source/Core/DecoratorTiledImageInstancer.cpp +++ b/Source/Core/DecoratorTiledImageInstancer.cpp @@ -30,7 +30,6 @@ #include "DecoratorTiledImage.h" namespace Rml { -namespace Core { DecoratorTiledImageInstancer::DecoratorTiledImageInstancer() : DecoratorTiledInstancer(1) { @@ -61,5 +60,4 @@ SharedPtr DecoratorTiledImageInstancer::InstanceDecorator(const Strin return decorator; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledImageInstancer.h b/Source/Core/DecoratorTiledImageInstancer.h index ff7b98fff..daa0e1d77 100644 --- a/Source/Core/DecoratorTiledImageInstancer.h +++ b/Source/Core/DecoratorTiledImageInstancer.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDIMAGEINSTANCER_H -#define RMLUICOREDECORATORTILEDIMAGEINSTANCER_H +#ifndef RMLUI_CORE_DECORATORTILEDIMAGEINSTANCER_H +#define RMLUI_CORE_DECORATORTILEDIMAGEINSTANCER_H #include "DecoratorTiledInstancer.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -48,7 +47,5 @@ class DecoratorTiledImageInstancer : public DecoratorTiledInstancer SharedPtr InstanceDecorator(const String& name, const PropertyDictionary& properties, const DecoratorInstancerInterface& interface) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledInstancer.cpp b/Source/Core/DecoratorTiledInstancer.cpp index 9182966f1..320878109 100644 --- a/Source/Core/DecoratorTiledInstancer.cpp +++ b/Source/Core/DecoratorTiledInstancer.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/Spritesheet.h" namespace Rml { -namespace Core { DecoratorTiledInstancer::DecoratorTiledInstancer(size_t num_tiles) { @@ -194,5 +193,4 @@ bool DecoratorTiledInstancer::GetTileProperties(DecoratorTiled::Tile* tiles, Tex return true; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledInstancer.h b/Source/Core/DecoratorTiledInstancer.h index 93c3d4640..f5205d3a7 100644 --- a/Source/Core/DecoratorTiledInstancer.h +++ b/Source/Core/DecoratorTiledInstancer.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREDECORATORTILEDINSTANCER_H -#define RMLUICOREDECORATORTILEDINSTANCER_H +#ifndef RMLUI_CORE_DECORATORTILEDINSTANCER_H +#define RMLUI_CORE_DECORATORTILEDINSTANCER_H #include "../../Include/RmlUi/Core/DecoratorInstancer.h" #include "DecoratorTiled.h" namespace Rml { -namespace Core { class StyleSheet; @@ -68,7 +67,5 @@ class DecoratorTiledInstancer : public DecoratorInstancer std::vector tile_property_ids; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledVertical.cpp b/Source/Core/DecoratorTiledVertical.cpp index 94cc0f3ef..fdaeba686 100644 --- a/Source/Core/DecoratorTiledVertical.cpp +++ b/Source/Core/DecoratorTiledVertical.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Texture.h" namespace Rml { -namespace Core { struct DecoratorTiledVerticalData { @@ -156,5 +155,4 @@ void DecoratorTiledVertical::RenderElement(Element* element, DecoratorDataHandle data->geometry[i].Render(translation); } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledVertical.h b/Source/Core/DecoratorTiledVertical.h index ef6446365..e74abe4b7 100644 --- a/Source/Core/DecoratorTiledVertical.h +++ b/Source/Core/DecoratorTiledVertical.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDVERTICAL_H -#define RMLUICOREDECORATORTILEDVERTICAL_H +#ifndef RMLUI_CORE_DECORATORTILEDVERTICAL_H +#define RMLUI_CORE_DECORATORTILEDVERTICAL_H #include "DecoratorTiled.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -69,7 +68,5 @@ class DecoratorTiledVertical : public DecoratorTiled Tile tiles[3]; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DecoratorTiledVerticalInstancer.cpp b/Source/Core/DecoratorTiledVerticalInstancer.cpp index cc23ecc43..9420c28fe 100644 --- a/Source/Core/DecoratorTiledVerticalInstancer.cpp +++ b/Source/Core/DecoratorTiledVerticalInstancer.cpp @@ -30,7 +30,6 @@ #include "DecoratorTiledVerticalInstancer.h" namespace Rml { -namespace Core { DecoratorTiledVerticalInstancer::DecoratorTiledVerticalInstancer() : DecoratorTiledInstancer(3) { @@ -63,5 +62,4 @@ SharedPtr DecoratorTiledVerticalInstancer::InstanceDecorator(const St return decorator; } -} -} +} // namespace Rml diff --git a/Source/Core/DecoratorTiledVerticalInstancer.h b/Source/Core/DecoratorTiledVerticalInstancer.h index d29465532..3827ca928 100644 --- a/Source/Core/DecoratorTiledVerticalInstancer.h +++ b/Source/Core/DecoratorTiledVerticalInstancer.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDECORATORTILEDVERTICALINSTANCER_H -#define RMLUICOREDECORATORTILEDVERTICALINSTANCER_H +#ifndef RMLUI_CORE_DECORATORTILEDVERTICALINSTANCER_H +#define RMLUI_CORE_DECORATORTILEDVERTICALINSTANCER_H #include "DecoratorTiledInstancer.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -48,7 +47,5 @@ class DecoratorTiledVerticalInstancer : public DecoratorTiledInstancer SharedPtr InstanceDecorator(const String& name, const PropertyDictionary& properties, const DecoratorInstancerInterface& interface) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/DocumentHeader.cpp b/Source/Core/DocumentHeader.cpp index 06f1f7639..8e7bab11c 100644 --- a/Source/Core/DocumentHeader.cpp +++ b/Source/Core/DocumentHeader.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/StringUtilities.h" namespace Rml { -namespace Core { void DocumentHeader::MergeHeader(const DocumentHeader& header) { @@ -60,11 +59,10 @@ void DocumentHeader::MergePaths(StringList& target, const StringList& source, co for (size_t i = 0; i < source.size(); i++) { String joined_path; - Rml::Core::GetSystemInterface()->JoinPath(joined_path, StringUtilities::Replace(source_path, '|', ':'), StringUtilities::Replace(source[i], '|', ':')); + ::Rml::GetSystemInterface()->JoinPath(joined_path, StringUtilities::Replace(source_path, '|', ':'), StringUtilities::Replace(source[i], '|', ':')); target.push_back(StringUtilities::Replace(joined_path, ':', '|')); } } -} -} +} // namespace Rml diff --git a/Source/Core/DocumentHeader.h b/Source/Core/DocumentHeader.h index c600dfc3e..b4a600f5a 100644 --- a/Source/Core/DocumentHeader.h +++ b/Source/Core/DocumentHeader.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREDOCUMENTHEADER_H -#define RMLUICOREDOCUMENTHEADER_H +#ifndef RMLUI_CORE_DOCUMENTHEADER_H +#define RMLUI_CORE_DOCUMENTHEADER_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { using LineNumberList = std::vector; @@ -72,7 +71,5 @@ class DocumentHeader void MergePaths(StringList& target, const StringList& source, const String& base_path); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Element.cpp b/Source/Core/Element.cpp index f4e36c585..6990828c6 100644 --- a/Source/Core/Element.cpp +++ b/Source/Core/Element.cpp @@ -64,7 +64,6 @@ #include namespace Rml { -namespace Core { /** STL function object for sorting elements by z-type (ie, float-types before general types, etc). @@ -1557,7 +1556,7 @@ RenderInterface* Element::GetRenderInterface() if (Context* context = GetContext()) return context->GetRenderInterface(); - return Rml::Core::GetRenderInterface(); + return ::Rml::GetRenderInterface(); } void Element::SetInstancer(ElementInstancer* _instancer) @@ -2647,5 +2646,4 @@ void Element::UpdateTransformState() } } -} -} +} // namespace Rml diff --git a/Source/Core/ElementAnimation.cpp b/Source/Core/ElementAnimation.cpp index b46f3de77..968c58879 100644 --- a/Source/Core/ElementAnimation.cpp +++ b/Source/Core/ElementAnimation.cpp @@ -35,8 +35,6 @@ #include "../../Include/RmlUi/Core/TransformPrimitive.h" namespace Rml { -namespace Core { - static Colourf ColourToLinearSpace(Colourb c) { @@ -52,10 +50,10 @@ static Colourf ColourToLinearSpace(Colourb c) static Colourb ColourFromLinearSpace(Colourf c) { Colourb result; - result.red = (Rml::Core::byte)Math::Clamp(c.red*c.red*255.f, 0.0f, 255.f); - result.green = (Rml::Core::byte)Math::Clamp(c.green*c.green*255.f, 0.0f, 255.f); - result.blue = (Rml::Core::byte)Math::Clamp(c.blue*c.blue*255.f, 0.0f, 255.f); - result.alpha = (Rml::Core::byte)Math::Clamp(c.alpha*255.f, 0.0f, 255.f); + result.red = (byte)Math::Clamp(c.red*c.red*255.f, 0.0f, 255.f); + result.green = (byte)Math::Clamp(c.green*c.green*255.f, 0.0f, 255.f); + result.blue = (byte)Math::Clamp(c.blue*c.blue*255.f, 0.0f, 255.f); + result.alpha = (byte)Math::Clamp(c.alpha*255.f, 0.0f, 255.f); return result; } @@ -134,8 +132,6 @@ static Property InterpolateProperties(const Property & p0, const Property& p1, f if (p0.unit == Property::TRANSFORM && p1.unit == Property::TRANSFORM) { - using namespace Rml::Core::Transforms; - auto& t0 = p0.value.GetReference(); auto& t1 = p1.value.GetReference(); @@ -154,7 +150,7 @@ static Property InterpolateProperties(const Property & p0, const Property& p1, f for (size_t i = 0; i < prim0.size(); i++) { - Primitive p = prim0[i]; + Transforms::Primitive p = prim0[i]; if (!p.InterpolateWith(prim1[i], alpha)) { RMLUI_ERRORMSG("Transform primitives can not be interpolated. Were the transforms properly prepared for interpolation?"); @@ -543,5 +539,4 @@ Property ElementAnimation::UpdateAndGetProperty(double world_time, Element& elem } -} -} +} // namespace Rml diff --git a/Source/Core/ElementAnimation.h b/Source/Core/ElementAnimation.h index eb6da5f3e..c16b6a867 100644 --- a/Source/Core/ElementAnimation.h +++ b/Source/Core/ElementAnimation.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICOREELEMENTANIMATION_H -#define RMLUICOREELEMENTANIMATION_H +#ifndef RMLUI_CORE_ELEMENTANIMATION_H +#define RMLUI_CORE_ELEMENTANIMATION_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Property.h" #include "../../Include/RmlUi/Core/Tween.h" namespace Rml { -namespace Core { - struct AnimationKey { AnimationKey(float time, const Property& property, Tween tween) : time(time), property(property), tween(tween) {} @@ -92,7 +90,5 @@ class ElementAnimation }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementBackground.cpp b/Source/Core/ElementBackground.cpp index 3ec6cd9d0..9d8e0b7e9 100644 --- a/Source/Core/ElementBackground.cpp +++ b/Source/Core/ElementBackground.cpp @@ -35,7 +35,6 @@ namespace Rml { -namespace Core { ElementBackground::ElementBackground(Element* _element) : geometry(_element) { @@ -132,5 +131,4 @@ void ElementBackground::GenerateBackground(Vertex*& vertices, int*& indices, int index_offset += 4; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementBackground.h b/Source/Core/ElementBackground.h index 1f66fc265..a55eedb9e 100644 --- a/Source/Core/ElementBackground.h +++ b/Source/Core/ElementBackground.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREELEMENTBACKGROUND_H -#define RMLUICOREELEMENTBACKGROUND_H +#ifndef RMLUI_CORE_ELEMENTBACKGROUND_H +#define RMLUI_CORE_ELEMENTBACKGROUND_H #include "../../Include/RmlUi/Core/Geometry.h" namespace Rml { -namespace Core { class Box; class Element; @@ -67,7 +66,5 @@ class ElementBackground bool background_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementBorder.cpp b/Source/Core/ElementBorder.cpp index 8088c503d..6cfdf5fad 100644 --- a/Source/Core/ElementBorder.cpp +++ b/Source/Core/ElementBorder.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Profiling.h" namespace Rml { -namespace Core { ElementBorder::ElementBorder(Element* _element) : geometry(_element) { @@ -159,5 +158,4 @@ void ElementBorder::GenerateBorder(Vertex*& vertices, int*& indices, int& index_ } } -} -} +} // namespace Rml diff --git a/Source/Core/ElementBorder.h b/Source/Core/ElementBorder.h index 62f8ee952..b7a63a866 100644 --- a/Source/Core/ElementBorder.h +++ b/Source/Core/ElementBorder.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREELEMENTBORDER_H -#define RMLUICOREELEMENTBORDER_H +#ifndef RMLUI_CORE_ELEMENTBORDER_H +#define RMLUI_CORE_ELEMENTBORDER_H #include "../../Include/RmlUi/Core/Geometry.h" namespace Rml { -namespace Core { class Box; class Element; @@ -67,7 +66,5 @@ class ElementBorder bool border_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementDecoration.cpp b/Source/Core/ElementDecoration.cpp index d4adb32f3..478126cb9 100644 --- a/Source/Core/ElementDecoration.cpp +++ b/Source/Core/ElementDecoration.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Profiling.h" namespace Rml { -namespace Core { ElementDecoration::ElementDecoration(Element* _element) { @@ -114,5 +113,4 @@ void ElementDecoration::DirtyDecorators() decorators_dirty = true; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementDecoration.h b/Source/Core/ElementDecoration.h index 5106ffe77..4bdce59ad 100644 --- a/Source/Core/ElementDecoration.h +++ b/Source/Core/ElementDecoration.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREELEMENTDECORATION_H -#define RMLUICOREELEMENTDECORATION_H +#ifndef RMLUI_CORE_ELEMENTDECORATION_H +#define RMLUI_CORE_ELEMENTDECORATION_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class Decorator; class Element; @@ -83,7 +82,5 @@ class ElementDecoration bool decorators_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementDefinition.cpp b/Source/Core/ElementDefinition.cpp index 1f5f64bc7..11d45a803 100644 --- a/Source/Core/ElementDefinition.cpp +++ b/Source/Core/ElementDefinition.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/PropertyIdSet.h" namespace Rml { -namespace Core { ElementDefinition::ElementDefinition(const std::vector< const StyleSheetNode* >& style_sheet_nodes) { @@ -53,5 +52,4 @@ const PropertyIdSet& ElementDefinition::GetPropertyIds() const return property_ids; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementDefinition.h b/Source/Core/ElementDefinition.h index 81e06f0a0..d1d527162 100644 --- a/Source/Core/ElementDefinition.h +++ b/Source/Core/ElementDefinition.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREELEMENTDEFINITION_H -#define RMLUICOREELEMENTDEFINITION_H +#ifndef RMLUI_CORE_ELEMENTDEFINITION_H +#define RMLUI_CORE_ELEMENTDEFINITION_H #include "../../Include/RmlUi/Core/PropertyDictionary.h" #include "../../Include/RmlUi/Core/PropertyIdSet.h" #include "../../Include/RmlUi/Core/Traits.h" namespace Rml { -namespace Core { class StyleSheetNode; class ElementDefinitionIterator; @@ -65,7 +64,5 @@ class ElementDefinition : public NonCopyMoveable PropertyIdSet property_ids; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementDocument.cpp b/Source/Core/ElementDocument.cpp index 0511ca741..7600b9f10 100644 --- a/Source/Core/ElementDocument.cpp +++ b/Source/Core/ElementDocument.cpp @@ -44,7 +44,6 @@ #include "XMLParseTools.h" namespace Rml { -namespace Core { ElementDocument::ElementDocument(const String& tag) : Element(tag) { @@ -214,9 +213,9 @@ void ElementDocument::Show(ModalFlag modal_flag, FocusFlag focus_flag) { switch (modal_flag) { - case Rml::Core::ModalFlag::None: modal = false; break; - case Rml::Core::ModalFlag::Modal: modal = true; break; - case Rml::Core::ModalFlag::Keep: break; + case ModalFlag::None: modal = false; break; + case ModalFlag::Modal: modal = true; break; + case ModalFlag::Keep: break; } bool focus = false; @@ -584,5 +583,4 @@ Element* ElementDocument::SearchFocusSubtree(Element* element, bool forward) return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementHandle.cpp b/Source/Core/ElementHandle.cpp index 1acadcfee..dbb95f9ca 100644 --- a/Source/Core/ElementHandle.cpp +++ b/Source/Core/ElementHandle.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Event.h" namespace Rml { -namespace Core { ElementHandle::ElementHandle(const String& tag) : Element(tag), drag_start(0, 0) { @@ -139,5 +138,4 @@ void ElementHandle::ProcessDefaultAction(Event& event) } } -} -} +} // namespace Rml diff --git a/Source/Core/ElementHandle.h b/Source/Core/ElementHandle.h index 721e34252..401d2dde2 100644 --- a/Source/Core/ElementHandle.h +++ b/Source/Core/ElementHandle.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREELEMENTHANDLE_H -#define RMLUICOREELEMENTHANDLE_H +#ifndef RMLUI_CORE_ELEMENTHANDLE_H +#define RMLUI_CORE_ELEMENTHANDLE_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { /** A derivation of an element for use as a mouse handle. A handle is designed to be instanced and attached as a non- @@ -65,7 +64,5 @@ class RMLUICORE_API ElementHandle : public Element bool initialised; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementInstancer.cpp b/Source/Core/ElementInstancer.cpp index e66452c2c..6ea92c145 100644 --- a/Source/Core/ElementInstancer.cpp +++ b/Source/Core/ElementInstancer.cpp @@ -32,7 +32,6 @@ #include "ElementTextDefault.h" namespace Rml { -namespace Core { ElementInstancer::~ElementInstancer() { @@ -78,5 +77,4 @@ void ElementInstancerTextDefault::ReleaseElement(Element* element) pool_text_default.DestroyAndDeallocate(static_cast(element)); } -} -} +} // namespace Rml diff --git a/Source/Core/ElementScroll.cpp b/Source/Core/ElementScroll.cpp index 4a5f1517d..8d657b8e3 100644 --- a/Source/Core/ElementScroll.cpp +++ b/Source/Core/ElementScroll.cpp @@ -28,14 +28,13 @@ #include "../../Include/RmlUi/Core/ElementScroll.h" #include "LayoutEngine.h" -#include "WidgetSliderScroll.h" +#include "WidgetScroll.h" #include "../../Include/RmlUi/Core/Element.h" #include "../../Include/RmlUi/Core/ElementUtilities.h" #include "../../Include/RmlUi/Core/Event.h" #include "../../Include/RmlUi/Core/Factory.h" namespace Rml { -namespace Core { ElementScroll::ElementScroll(Element* _element) { @@ -238,8 +237,8 @@ bool ElementScroll::CreateScrollbar(Orientation orientation) scrollbars[orientation].element = scrollbar_element.get(); scrollbars[orientation].element->SetProperty(PropertyId::Clip, Property(1, Property::NUMBER)); - scrollbars[orientation].widget = new WidgetSliderScroll(scrollbars[orientation].element); - scrollbars[orientation].widget->Initialise(orientation == VERTICAL ? WidgetSlider::VERTICAL : WidgetSlider::HORIZONTAL); + scrollbars[orientation].widget = new WidgetScroll(scrollbars[orientation].element); + scrollbars[orientation].widget->Initialise(orientation == VERTICAL ? WidgetScroll::VERTICAL : WidgetScroll::HORIZONTAL); Element* child = element->AppendChild(std::move(scrollbar_element), false); @@ -282,5 +281,4 @@ ElementScroll::Scrollbar::~Scrollbar() } } -} -} +} // namespace Rml diff --git a/Source/Core/ElementStyle.cpp b/Source/Core/ElementStyle.cpp index bed34b9c1..c65140c49 100644 --- a/Source/Core/ElementStyle.cpp +++ b/Source/Core/ElementStyle.cpp @@ -51,7 +51,6 @@ namespace Rml { -namespace Core { ElementStyle::ElementStyle(Element* _element) { @@ -911,5 +910,4 @@ PropertyIdSet ElementStyle::ComputeValues(Style::ComputedValues& values, const S return result; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementStyle.h b/Source/Core/ElementStyle.h index e0cff8c86..a52f44d52 100644 --- a/Source/Core/ElementStyle.h +++ b/Source/Core/ElementStyle.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREELEMENTSTYLE_H -#define RMLUICOREELEMENTSTYLE_H +#ifndef RMLUI_CORE_ELEMENTSTYLE_H +#define RMLUI_CORE_ELEMENTSTYLE_H #include "../../Include/RmlUi/Core/ComputedValues.h" #include "../../Include/RmlUi/Core/Types.h" @@ -35,7 +35,6 @@ #include "../../Include/RmlUi/Core/PropertyDictionary.h" namespace Rml { -namespace Core { class ElementDefinition; class PropertiesIterator; @@ -167,7 +166,5 @@ class ElementStyle PropertyIdSet dirty_properties; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementText.cpp b/Source/Core/ElementText.cpp index d25d2b236..40ec851ee 100644 --- a/Source/Core/ElementText.cpp +++ b/Source/Core/ElementText.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { ElementText::ElementText(const String& tag) : Element(tag) { @@ -39,5 +38,4 @@ ElementText::~ElementText() { } -} -} +} // namespace Rml diff --git a/Source/Core/ElementTextDefault.cpp b/Source/Core/ElementTextDefault.cpp index 23b585d5d..c2e175e21 100644 --- a/Source/Core/ElementTextDefault.cpp +++ b/Source/Core/ElementTextDefault.cpp @@ -40,7 +40,6 @@ #include "../../Include/RmlUi/Core/Profiling.h" namespace Rml { -namespace Core { static bool BuildToken(String& token, const char*& token_begin, const char* string_end, bool first_token, bool collapse_white_space, bool break_at_endline, Style::TextTransform text_transformation, bool decode_escape_characters); static bool LastToken(const char* token_begin, const char* string_end, bool collapse_white_space, bool break_at_endline); @@ -598,5 +597,4 @@ static bool LastToken(const char* token_begin, const char* string_end, bool coll return last_token; } -} -} +} // namespace Rml diff --git a/Source/Core/ElementTextDefault.h b/Source/Core/ElementTextDefault.h index 8af0909ff..ed7d79e8f 100644 --- a/Source/Core/ElementTextDefault.h +++ b/Source/Core/ElementTextDefault.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREELEMENTTEXTDEFAULT_H -#define RMLUICOREELEMENTTEXTDEFAULT_H +#ifndef RMLUI_CORE_ELEMENTTEXTDEFAULT_H +#define RMLUI_CORE_ELEMENTTEXTDEFAULT_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/ElementText.h" #include "../../Include/RmlUi/Core/Geometry.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -134,7 +133,5 @@ class RMLUICORE_API ElementTextDefault : public ElementText int font_handle_version; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ElementUtilities.cpp b/Source/Core/ElementUtilities.cpp index c17596d39..8e82142f2 100644 --- a/Source/Core/ElementUtilities.cpp +++ b/Source/Core/ElementUtilities.cpp @@ -44,7 +44,6 @@ #include namespace Rml { -namespace Core { // Builds and sets the box for an element. static void SetBox(Element* element) @@ -253,7 +252,7 @@ bool ElementUtilities::GetClippingRegion(Vector2i& clip_origin, Vector2i& clip_d // Sets the clipping region from an element and its ancestors. bool ElementUtilities::SetClippingRegion(Element* element, Context* context) { - Rml::Core::RenderInterface* render_interface = nullptr; + RenderInterface* render_interface = nullptr; if (element) { render_interface = element->GetRenderInterface(); @@ -500,5 +499,4 @@ bool ElementUtilities::ApplyStructuralDataViews(Element* element, const String& return ApplyDataViewsControllersInternal(element, true, inner_rml); } -} -} +} // namespace Rml diff --git a/Source/Controls/DataFormatter.cpp b/Source/Core/Elements/DataFormatter.cpp similarity index 78% rename from Source/Controls/DataFormatter.cpp rename to Source/Core/Elements/DataFormatter.cpp index 9f83777d8..6a872c2ed 100644 --- a/Source/Controls/DataFormatter.cpp +++ b/Source/Core/Elements/DataFormatter.cpp @@ -26,16 +26,15 @@ * */ -#include "../../Include/RmlUi/Controls/DataFormatter.h" -#include "../../Include/RmlUi/Core/StringUtilities.h" +#include "../../../Include/RmlUi/Core/Elements/DataFormatter.h" +#include "../../../Include/RmlUi/Core/StringUtilities.h" namespace Rml { -namespace Controls { -typedef Core::UnorderedMap< Rml::Core::String, DataFormatter* > DataFormatterMap; +typedef UnorderedMap< String, DataFormatter* > DataFormatterMap; static DataFormatterMap data_formatters; -DataFormatter::DataFormatter(const Rml::Core::String& _name) +DataFormatter::DataFormatter(const String& _name) { if (!_name.empty()) { @@ -43,7 +42,7 @@ DataFormatter::DataFormatter(const Rml::Core::String& _name) } else { - name = Core::CreateString(64, "%x", this); + name = CreateString(64, "%x", this); } data_formatters[name] = this; } @@ -52,12 +51,12 @@ DataFormatter::~DataFormatter() { } -const Rml::Core::String& DataFormatter::GetDataFormatterName() +const String& DataFormatter::GetDataFormatterName() { return name; } -DataFormatter* DataFormatter::GetDataFormatter(const Rml::Core::String& data_formatter_name) +DataFormatter* DataFormatter::GetDataFormatter(const String& data_formatter_name) { DataFormatterMap::iterator i = data_formatters.find(data_formatter_name); if (i == data_formatters.end()) @@ -73,5 +72,4 @@ void* DataFormatter::GetScriptObject() const return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Controls/DataQuery.cpp b/Source/Core/Elements/DataQuery.cpp similarity index 75% rename from Source/Controls/DataQuery.cpp rename to Source/Core/Elements/DataQuery.cpp index 2e11500c9..d674ce1d1 100644 --- a/Source/Controls/DataQuery.cpp +++ b/Source/Core/Elements/DataQuery.cpp @@ -26,22 +26,21 @@ * */ -#include "../../Include/RmlUi/Controls/DataQuery.h" -#include "../../Include/RmlUi/Controls/DataSource.h" +#include "../../../Include/RmlUi/Core/Elements/DataQuery.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" #include namespace Rml { -namespace Controls { class DataQuerySort { public: - DataQuerySort(const Rml::Core::StringList& _order_parameters) + DataQuerySort(const StringList& _order_parameters) { order_parameters = _order_parameters; } - bool operator()(const Rml::Core::StringList& RMLUI_UNUSED_PARAMETER(left), const Rml::Core::StringList& RMLUI_UNUSED_PARAMETER(right)) + bool operator()(const StringList& RMLUI_UNUSED_PARAMETER(left), const StringList& RMLUI_UNUSED_PARAMETER(right)) { RMLUI_UNUSED(left); RMLUI_UNUSED(right); @@ -50,12 +49,12 @@ class DataQuerySort } private: - Rml::Core::StringList order_parameters; + StringList order_parameters; }; -DataQuery::DataQuery(DataSource* data_source, const Rml::Core::String& table, const Rml::Core::String& _fields, int offset, int limit, const Rml::Core::String& order) +DataQuery::DataQuery(DataSource* data_source, const String& table, const String& _fields, int offset, int limit, const String& order) { ExecuteQuery(data_source, table, _fields, offset, limit, order); } @@ -78,7 +77,7 @@ DataQuery::~DataQuery() -void DataQuery::ExecuteQuery(DataSource* _data_source, const Rml::Core::String& _table, const Rml::Core::String& _fields, int _offset, int _limit, const Rml::Core::String& order) +void DataQuery::ExecuteQuery(DataSource* _data_source, const String& _table, const String& _fields, int _offset, int _limit, const String& order) { data_source = _data_source; table = _table; @@ -86,7 +85,7 @@ void DataQuery::ExecuteQuery(DataSource* _data_source, const Rml::Core::String& limit = _limit; // Set up the field list and field index cache. - Rml::Core::StringUtilities::ExpandString(fields, _fields); + StringUtilities::ExpandString(fields, _fields); for (size_t i = 0; i < fields.size(); i++) { field_indices[fields[i]] = i; @@ -111,8 +110,8 @@ void DataQuery::ExecuteQuery(DataSource* _data_source, const Rml::Core::String& } // Now sort the rows, based on the ordering requirements. - Rml::Core::StringList order_parameters; - Rml::Core::StringUtilities::ExpandString(order_parameters, order); + StringList order_parameters; + StringUtilities::ExpandString(order_parameters, order); std::sort(rows.begin(), rows.end(), DataQuerySort(order_parameters)); } } @@ -134,7 +133,7 @@ bool DataQuery::NextRow() -bool DataQuery::IsFieldSet(const Rml::Core::String& field) const +bool DataQuery::IsFieldSet(const String& field) const { FieldIndices::const_iterator itr = field_indices.find(field); if (itr == field_indices.end() || (*itr).second >= rows[current_row].size()) @@ -152,10 +151,9 @@ void DataQuery::LoadRow() RMLUI_ASSERT(current_row <= (int)rows.size()); if (current_row >= (int)rows.size()) { - rows.push_back(Rml::Core::StringList()); + rows.push_back(StringList()); data_source->GetRow(rows[current_row], table, offset + current_row, fields); } } -} -} +} // namespace Rml diff --git a/Source/Controls/DataSource.cpp b/Source/Core/Elements/DataSource.cpp similarity index 72% rename from Source/Controls/DataSource.cpp rename to Source/Core/Elements/DataSource.cpp index 58f55aade..4547a50af 100644 --- a/Source/Controls/DataSource.cpp +++ b/Source/Core/Elements/DataSource.cpp @@ -26,23 +26,22 @@ * */ -#include "../../Include/RmlUi/Controls/DataSource.h" -#include "../../Include/RmlUi/Controls/DataSourceListener.h" -#include "../../Include/RmlUi/Core/StringUtilities.h" -#include "../../Include/RmlUi/Core/Log.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" +#include "../../../Include/RmlUi/Core/Elements/DataSourceListener.h" +#include "../../../Include/RmlUi/Core/StringUtilities.h" +#include "../../../Include/RmlUi/Core/Log.h" #include namespace Rml { -namespace Controls { -const Rml::Core::String DataSource::CHILD_SOURCE("#child_data_source"); -const Rml::Core::String DataSource::DEPTH("#depth"); -const Rml::Core::String DataSource::NUM_CHILDREN("#num_children"); +const String DataSource::CHILD_SOURCE("#child_data_source"); +const String DataSource::DEPTH("#depth"); +const String DataSource::NUM_CHILDREN("#num_children"); -typedef Core::UnorderedMap< Rml::Core::String, DataSource* > DataSourceMap; +typedef UnorderedMap< String, DataSource* > DataSourceMap; static DataSourceMap data_sources; -DataSource::DataSource(const Rml::Core::String& _name) +DataSource::DataSource(const String& _name) { if (!_name.empty()) { @@ -50,7 +49,7 @@ DataSource::DataSource(const Rml::Core::String& _name) } else { - name = Core::CreateString(64, "%x", this); + name = CreateString(64, "%x", this); } data_sources[name] = this; } @@ -71,12 +70,12 @@ DataSource::~DataSource() } } -const Rml::Core::String& DataSource::GetDataSourceName() +const String& DataSource::GetDataSourceName() { return name; } -DataSource* DataSource::GetDataSource(const Rml::Core::String& data_source_name) +DataSource* DataSource::GetDataSource(const String& data_source_name) { DataSourceMap::iterator i = data_sources.find(data_source_name); if (i == data_sources.end()) @@ -112,7 +111,7 @@ void* DataSource::GetScriptObject() const return nullptr; } -void DataSource::NotifyRowAdd(const Rml::Core::String& table, int first_row_added, int num_rows_added) +void DataSource::NotifyRowAdd(const String& table, int first_row_added, int num_rows_added) { ListenerList listeners_copy = listeners; for (ListenerList::iterator i = listeners_copy.begin(); i != listeners_copy.end(); ++i) @@ -121,7 +120,7 @@ void DataSource::NotifyRowAdd(const Rml::Core::String& table, int first_row_adde } } -void DataSource::NotifyRowRemove(const Rml::Core::String& table, int first_row_removed, int num_rows_removed) +void DataSource::NotifyRowRemove(const String& table, int first_row_removed, int num_rows_removed) { ListenerList listeners_copy = listeners; for (ListenerList::iterator i = listeners_copy.begin(); i != listeners_copy.end(); ++i) @@ -130,7 +129,7 @@ void DataSource::NotifyRowRemove(const Rml::Core::String& table, int first_row_r } } -void DataSource::NotifyRowChange(const Rml::Core::String& table, int first_row_changed, int num_rows_changed) +void DataSource::NotifyRowChange(const String& table, int first_row_changed, int num_rows_changed) { ListenerList listeners_copy = listeners; for (ListenerList::iterator i = listeners_copy.begin(); i != listeners_copy.end(); ++i) @@ -139,7 +138,7 @@ void DataSource::NotifyRowChange(const Rml::Core::String& table, int first_row_c } } -void DataSource::NotifyRowChange(const Rml::Core::String& table) +void DataSource::NotifyRowChange(const String& table) { ListenerList listeners_copy = listeners; for (ListenerList::iterator i = listeners_copy.begin(); i != listeners_copy.end(); ++i) @@ -148,7 +147,7 @@ void DataSource::NotifyRowChange(const Rml::Core::String& table) } } -void DataSource::BuildRowEntries(Rml::Core::StringList& row, const RowMap& row_map, const Rml::Core::StringList& columns) +void DataSource::BuildRowEntries(StringList& row, const RowMap& row_map, const StringList& columns) { // Reserve the number of entries. row.resize(columns.size()); @@ -163,10 +162,9 @@ void DataSource::BuildRowEntries(Rml::Core::StringList& row, const RowMap& row_m else { row[i] = ""; - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Failed to find required data source column %s", columns[i].c_str()); + Log::Message(Log::LT_ERROR, "Failed to find required data source column %s", columns[i].c_str()); } } } -} -} +} // namespace Rml diff --git a/Source/Controls/DataSourceListener.cpp b/Source/Core/Elements/DataSourceListener.cpp similarity index 73% rename from Source/Controls/DataSourceListener.cpp rename to Source/Core/Elements/DataSourceListener.cpp index 571f2fba2..3628b63d9 100644 --- a/Source/Controls/DataSourceListener.cpp +++ b/Source/Core/Elements/DataSourceListener.cpp @@ -26,13 +26,12 @@ * */ -#include "../../Include/RmlUi/Controls/DataSourceListener.h" -#include "../../Include/RmlUi/Controls/DataSource.h" -#include "../../Include/RmlUi/Core/StringUtilities.h" -#include "../../Include/RmlUi/Core/Log.h" +#include "../../../Include/RmlUi/Core/Elements/DataSourceListener.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" +#include "../../../Include/RmlUi/Core/StringUtilities.h" +#include "../../../Include/RmlUi/Core/Log.h" namespace Rml { -namespace Controls { DataSourceListener::DataSourceListener() { @@ -49,7 +48,7 @@ void DataSourceListener::OnDataSourceDestroy(DataSource* RMLUI_UNUSED_PARAMETER( } // Notification of the addition of one or more rows to an observed data source's table. -void DataSourceListener::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_added), int RMLUI_UNUSED_PARAMETER(num_rows_added)) +void DataSourceListener::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_added), int RMLUI_UNUSED_PARAMETER(num_rows_added)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(table); @@ -58,7 +57,7 @@ void DataSourceListener::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(data_source } // Notification of the removal of one or more rows from an observed data source's table. -void DataSourceListener::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_removed), int RMLUI_UNUSED_PARAMETER(num_rows_removed)) +void DataSourceListener::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_removed), int RMLUI_UNUSED_PARAMETER(num_rows_removed)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(table); @@ -67,7 +66,7 @@ void DataSourceListener::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETER(data_sou } // Notification of the changing of one or more rows from an observed data source's table. -void DataSourceListener::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_changed), int RMLUI_UNUSED_PARAMETER(num_rows_changed)) +void DataSourceListener::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& RMLUI_UNUSED_PARAMETER(table), int RMLUI_UNUSED_PARAMETER(first_row_changed), int RMLUI_UNUSED_PARAMETER(num_rows_changed)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(table); @@ -76,14 +75,14 @@ void DataSourceListener::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_sou } // Notification of the change of all of the data of an observed data source's table. -void DataSourceListener::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(table)) +void DataSourceListener::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& RMLUI_UNUSED_PARAMETER(table)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(table); } // Sets up data source and table from a given string. -bool DataSourceListener::ParseDataSource(DataSource*& data_source, Rml::Core::String& table_name, const Rml::Core::String& data_source_name) +bool DataSourceListener::ParseDataSource(DataSource*& data_source, String& table_name, const String& data_source_name) { if (data_source_name.size() == 0) { @@ -92,14 +91,14 @@ bool DataSourceListener::ParseDataSource(DataSource*& data_source, Rml::Core::St return false; } - Rml::Core::StringList data_source_parts; - Rml::Core::StringUtilities::ExpandString(data_source_parts, data_source_name, '.'); + StringList data_source_parts; + StringUtilities::ExpandString(data_source_parts, data_source_name, '.'); DataSource* new_data_source = DataSource::GetDataSource(data_source_parts[0]); if (data_source_parts.size() != 2 || !new_data_source) { - Rml::Core::Log::Message(Rml::Core::Log::LT_ERROR, "Bad data source name %s", data_source_name.c_str()); + Log::Message(Log::LT_ERROR, "Bad data source name %s", data_source_name.c_str()); data_source = nullptr; table_name = ""; return false; @@ -110,5 +109,4 @@ bool DataSourceListener::ParseDataSource(DataSource*& data_source, Rml::Core::St return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementDataGrid.cpp b/Source/Core/Elements/ElementDataGrid.cpp similarity index 62% rename from Source/Controls/ElementDataGrid.cpp rename to Source/Core/Elements/ElementDataGrid.cpp index 77c2be7ec..e940f6834 100644 --- a/Source/Controls/ElementDataGrid.cpp +++ b/Source/Core/Elements/ElementDataGrid.cpp @@ -26,45 +26,44 @@ * */ -#include "../../Include/RmlUi/Controls/ElementDataGrid.h" -#include "../../Include/RmlUi/Controls/DataSource.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/XMLParser.h" -#include "../../Include/RmlUi/Core/Event.h" -#include "../../Include/RmlUi/Core/ElementDocument.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/Property.h" -#include "../../Include/RmlUi/Controls/DataFormatter.h" -#include "../../Include/RmlUi/Controls/ElementDataGridRow.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGrid.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" +#include "../../../Include/RmlUi/Core/Math.h" +#include "../../../Include/RmlUi/Core/XMLParser.h" +#include "../../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/ElementDocument.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/Property.h" +#include "../../../Include/RmlUi/Core/Elements/DataFormatter.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridRow.h" namespace Rml { -namespace Controls { -ElementDataGrid::ElementDataGrid(const Rml::Core::String& tag) : Core::Element(tag) +ElementDataGrid::ElementDataGrid(const String& tag) : Element(tag) { - Rml::Core::XMLAttributes attributes; + XMLAttributes attributes; // Create the row for the column headers: - Core::ElementPtr element = Core::Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridheader", attributes); + ElementPtr element = Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridheader", attributes); header = static_cast(element.get()); - header->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::Block)); + header->SetProperty(PropertyId::Display, Property(Style::Display::Block)); header->Initialise(this); AppendChild(std::move(element)); - element = Core::Factory::InstanceElement(this, "*", "datagridbody", attributes); + element = Factory::InstanceElement(this, "*", "datagridbody", attributes); body = element.get(); - body->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::Block)); - body->SetProperty(Core::PropertyId::Width, Core::Property(Core::Style::Width::Auto)); + body->SetProperty(PropertyId::Display, Property(Style::Display::Block)); + body->SetProperty(PropertyId::Width, Property(Style::Width::Auto)); AppendChild(std::move(element)); - element = Core::Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridroot", attributes); + element = Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridroot", attributes); root = static_cast(element.get()); - root->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::None)); + root->SetProperty(PropertyId::Display, Property(Style::Display::None)); root->Initialise(this); AppendChild(std::move(element), false); - SetProperty(Core::PropertyId::OverflowX, Core::Property(Core::Style::Overflow::Auto)); - SetProperty(Core::PropertyId::OverflowY, Core::Property(Core::Style::Overflow::Auto)); + SetProperty(PropertyId::OverflowX, Property(Style::Overflow::Auto)); + SetProperty(PropertyId::OverflowY, Property(Style::Overflow::Auto)); new_data_source = ""; } @@ -73,19 +72,19 @@ ElementDataGrid::~ElementDataGrid() { } -void ElementDataGrid::SetDataSource(const Rml::Core::String& data_source_name) +void ElementDataGrid::SetDataSource(const String& data_source_name) { new_data_source = data_source_name; } // Adds a column to the table. -bool ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core::String& formatter, float initial_width, const Rml::Core::String& header_rml) +bool ElementDataGrid::AddColumn(const String& fields, const String& formatter, float initial_width, const String& header_rml) { - Core::ElementPtr header_element = Core::Factory::InstanceElement(this, "datagridcolumn", "datagridcolumn", Rml::Core::XMLAttributes()); + ElementPtr header_element = Factory::InstanceElement(this, "datagridcolumn", "datagridcolumn", XMLAttributes()); if (!header_element) return false; - if (!Core::Factory::InstanceElementText(header_element.get(), header_rml)) + if (!Factory::InstanceElementText(header_element.get(), header_rml)) { return false; } @@ -95,10 +94,10 @@ bool ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core } // Adds a column to the table. -void ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core::String& formatter, float initial_width, Core::ElementPtr header_element) +void ElementDataGrid::AddColumn(const String& fields, const String& formatter, float initial_width, ElementPtr header_element) { Column column; - Rml::Core::StringUtilities::ExpandString(column.fields, fields); + StringUtilities::ExpandString(column.fields, fields); column.formatter = DataFormatter::GetDataFormatter(formatter); column.header = header; column.current_width = initial_width; @@ -107,10 +106,10 @@ void ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core // The header elements are added to the header row at the top of the table. if (header_element) { - header_element->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + header_element->SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); // Push all the width properties from the column onto the header element. - Rml::Core::String width = header_element->GetAttribute("width", "100%"); + String width = header_element->GetAttribute("width", "100%"); header_element->SetProperty("width", width); header->AppendChild(std::move(header_element)); @@ -120,11 +119,11 @@ void ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core for (size_t i = 0; i < column.fields.size(); i++) { // Don't append the depth or num_children fields, as they're handled by the row. - if (column.fields[i] == Rml::Controls::DataSource::NUM_CHILDREN) + if (column.fields[i] == DataSource::NUM_CHILDREN) { column.refresh_on_child_change = true; } - else if (column.fields[i] != Rml::Controls::DataSource::DEPTH) + else if (column.fields[i] != DataSource::DEPTH) { if (!column_fields.empty()) { @@ -136,9 +135,9 @@ void ElementDataGrid::AddColumn(const Rml::Core::String& fields, const Rml::Core columns.push_back(column); - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["index"] = (int)(columns.size() - 1); - if (DispatchEvent(Core::EventId::Columnadd, parameters)) + if (DispatchEvent(EventId::Columnadd, parameters)) { root->RefreshRows(); DirtyLayout(); @@ -164,7 +163,7 @@ const ElementDataGrid::Column* ElementDataGrid::GetColumn(int column_index) } /// Returns a CSV string containing all the fields that each column requires, in order. -const Rml::Core::String& ElementDataGrid::GetAllColumnFields() +const String& ElementDataGrid::GetAllColumnFields() { return column_fields; } @@ -173,8 +172,8 @@ const Rml::Core::String& ElementDataGrid::GetAllColumnFields() ElementDataGridRow* ElementDataGrid::AddRow(ElementDataGridRow* parent, int index) { // Now we make a new row at the right place then return it. - Rml::Core::XMLAttributes attributes; - Core::ElementPtr element = Core::Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridrow", attributes); + XMLAttributes attributes; + ElementPtr element = Factory::InstanceElement(this, "#rmlctl_datagridrow", "datagridrow", attributes); ElementDataGridRow* new_row = rmlui_dynamic_cast< ElementDataGridRow* >(element.get()); new_row->Initialise(this, parent, index, header, parent->GetDepth() + 1); @@ -182,7 +181,7 @@ ElementDataGridRow* ElementDataGrid::AddRow(ElementDataGridRow* parent, int inde // We need to work out the table-specific row. int table_relative_index = parent->GetChildTableRelativeIndex(index); - Core::Element* child_to_insert_before = nullptr; + Element* child_to_insert_before = nullptr; if (table_relative_index < body->GetNumChildren()) { child_to_insert_before = body->GetChild(table_relative_index); @@ -234,7 +233,7 @@ void ElementDataGrid::OnUpdate() bool any_new_children = root->UpdateChildren(); if (any_new_children) { - DispatchEvent(Core::EventId::Rowupdate, Rml::Core::Dictionary()); + DispatchEvent(EventId::Rowupdate, Dictionary()); } } @@ -245,20 +244,20 @@ void ElementDataGrid::OnResize() for (int i = 0; i < header->GetNumChildren(); i++) { - Core::Element* child = header->GetChild(i); - columns[i].current_width = child->GetBox().GetSize(Core::Box::MARGIN).x; + Element* child = header->GetChild(i); + columns[i].current_width = child->GetBox().GetSize(Box::MARGIN).x; } } // Gets the markup and content of the element. -void ElementDataGrid::GetInnerRML(Rml::Core::String& content) const +void ElementDataGrid::GetInnerRML(String& content) const { // The only content we have is the columns, and inside them the header elements. for (size_t i = 0; i < columns.size(); i++) { - Core::Element* header_element = header->GetChild((int)i); + Element* header_element = header->GetChild((int)i); - Rml::Core::String column_fields; + String column_fields; for (size_t j = 0; j < columns[i].fields.size(); j++) { if (j != columns[i].fields.size() - 1) @@ -267,16 +266,15 @@ void ElementDataGrid::GetInnerRML(Rml::Core::String& content) const } column_fields += columns[i].fields[j]; } - Rml::Core::String width_attribute = header_element->GetAttribute("width", ""); + String width_attribute = header_element->GetAttribute("width", ""); - content += Core::CreateString(column_fields.size() + 32, "GetInnerRML(content); content += ""; } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementDataGridCell.cpp b/Source/Core/Elements/ElementDataGridCell.cpp similarity index 77% rename from Source/Controls/ElementDataGridCell.cpp rename to Source/Core/Elements/ElementDataGridCell.cpp index 5e694c8ed..706d5f31f 100644 --- a/Source/Controls/ElementDataGridCell.cpp +++ b/Source/Core/Elements/ElementDataGridCell.cpp @@ -26,15 +26,14 @@ * */ -#include "../../Include/RmlUi/Controls/ElementDataGridCell.h" -#include "../../Include/RmlUi/Core/Event.h" -#include "../../Include/RmlUi/Core/Property.h" -#include "../../Include/RmlUi/Controls/ElementDataGrid.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridCell.h" +#include "../../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/Property.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGrid.h" namespace Rml { -namespace Controls { -ElementDataGridCell::ElementDataGridCell(const Rml::Core::String& tag) : Core::Element(tag), column(0), header(nullptr) +ElementDataGridCell::ElementDataGridCell(const String& tag) : Element(tag), column(0), header(nullptr) { } @@ -42,14 +41,14 @@ ElementDataGridCell::~ElementDataGridCell() { } -void ElementDataGridCell::Initialise(int _column, Core::Element* _header) +void ElementDataGridCell::Initialise(int _column, Element* _header) { column = _column; header = _header; if (header) { if(auto p = header->GetLocalProperty("width")) - SetProperty(Core::PropertyId::Width, *p); + SetProperty(PropertyId::Width, *p); } } @@ -58,5 +57,4 @@ int ElementDataGridCell::GetColumn() return column; } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementDataGridExpandButton.cpp b/Source/Core/Elements/ElementDataGridExpandButton.cpp similarity index 80% rename from Source/Controls/ElementDataGridExpandButton.cpp rename to Source/Core/Elements/ElementDataGridExpandButton.cpp index 441d73303..35b1faa57 100644 --- a/Source/Controls/ElementDataGridExpandButton.cpp +++ b/Source/Core/Elements/ElementDataGridExpandButton.cpp @@ -26,13 +26,12 @@ * */ -#include "../../Include/RmlUi/Controls/ElementDataGridExpandButton.h" -#include "../../Include/RmlUi/Controls/ElementDataGridRow.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridRow.h" namespace Rml { -namespace Controls { -ElementDataGridExpandButton::ElementDataGridExpandButton(const Rml::Core::String& tag) : Core::Element(tag) +ElementDataGridExpandButton::ElementDataGridExpandButton(const String& tag) : Element(tag) { SetClass("collapsed", true); } @@ -41,15 +40,15 @@ ElementDataGridExpandButton::~ElementDataGridExpandButton() { } -void ElementDataGridExpandButton::ProcessDefaultAction(Core::Event& event) +void ElementDataGridExpandButton::ProcessDefaultAction(Event& event) { - Core::Element::ProcessDefaultAction(event); + Element::ProcessDefaultAction(event); - if (event == Core::EventId::Click && event.GetCurrentElement() == this) + if (event == EventId::Click && event.GetCurrentElement() == this) { // Look for the first data grid row above us, and toggle their on/off // state. - Core::Element* parent = GetParentNode(); + Element* parent = GetParentNode(); ElementDataGridRow* parent_row; do { @@ -76,5 +75,4 @@ void ElementDataGridExpandButton::ProcessDefaultAction(Core::Event& event) } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementDataGridRow.cpp b/Source/Core/Elements/ElementDataGridRow.cpp similarity index 82% rename from Source/Controls/ElementDataGridRow.cpp rename to Source/Core/Elements/ElementDataGridRow.cpp index 27187ac83..b33478369 100644 --- a/Source/Controls/ElementDataGridRow.cpp +++ b/Source/Core/Elements/ElementDataGridRow.cpp @@ -26,21 +26,20 @@ * */ -#include "../../Include/RmlUi/Controls/ElementDataGridRow.h" -#include "../../Include/RmlUi/Controls/DataSource.h" -#include "../../Include/RmlUi/Controls/DataFormatter.h" -#include "../../Include/RmlUi/Controls/ElementDataGrid.h" -#include "../../Include/RmlUi/Controls/ElementDataGridCell.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/Types.h" -#include "../Core/Clock.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridRow.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" +#include "../../../Include/RmlUi/Core/Elements/DataFormatter.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGrid.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGridCell.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/Types.h" +#include "../Clock.h" namespace Rml { -namespace Controls { static const float MAX_UPDATE_TIME = 0.001f; -ElementDataGridRow::ElementDataGridRow(const Rml::Core::String& tag) : Core::Element(tag) +ElementDataGridRow::ElementDataGridRow(const String& tag) : Element(tag) { parent_grid = nullptr; parent_row = nullptr; @@ -55,8 +54,8 @@ ElementDataGridRow::ElementDataGridRow(const Rml::Core::String& tag) : Core::Ele dirty_children = false; row_expanded = true; - SetProperty(Core::PropertyId::WhiteSpace, Core::Property(Core::Style::WhiteSpace::Nowrap)); - SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + SetProperty(PropertyId::WhiteSpace, Property(Style::WhiteSpace::Nowrap)); + SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); } ElementDataGridRow::~ElementDataGridRow() @@ -82,13 +81,13 @@ void ElementDataGridRow::Initialise(ElementDataGrid* _parent_grid, ElementDataGr } int num_columns = parent_grid->GetNumColumns(); - Rml::Core::XMLAttributes cell_attributes; + XMLAttributes cell_attributes; for (int i = 0; i < num_columns; i++) { - Core::ElementPtr element = Core::Factory::InstanceElement(this, "#rmlctl_datagridcell", "datagridcell", cell_attributes); + ElementPtr element = Factory::InstanceElement(this, "#rmlctl_datagridcell", "datagridcell", cell_attributes); ElementDataGridCell* cell = rmlui_dynamic_cast< ElementDataGridCell* >(element.get()); cell->Initialise(i, header_row->GetChild(i)); - cell->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + cell->SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); AppendChild(std::move(element)); } } @@ -111,7 +110,7 @@ int ElementDataGridRow::GetDepth() return depth; } -void ElementDataGridRow::SetDataSource(const Rml::Core::String& data_source_name) +void ElementDataGridRow::SetDataSource(const String& data_source_name) { if (data_source != nullptr) { @@ -130,7 +129,7 @@ bool ElementDataGridRow::UpdateChildren() { if (dirty_children) { - double start_time = Core::Clock::GetElapsedTime(); + double start_time = Clock::GetElapsedTime(); RowQueue dirty_rows; dirty_rows.push(this); @@ -140,7 +139,7 @@ bool ElementDataGridRow::UpdateChildren() ElementDataGridRow* dirty_row = dirty_rows.front(); dirty_rows.pop(); - float time_slice = MAX_UPDATE_TIME - float(Core::Clock::GetElapsedTime() - start_time); + float time_slice = MAX_UPDATE_TIME - float(Clock::GetElapsedTime() - start_time); if (time_slice <= 0.0f) break; @@ -262,25 +261,25 @@ void ElementDataGridRow::OnDataSourceDestroy(DataSource* /*data_source*/) RemoveChildren(); } -void ElementDataGridRow::OnRowAdd(DataSource* _data_source, const Rml::Core::String& _data_table, int first_row_added, int num_rows_added) +void ElementDataGridRow::OnRowAdd(DataSource* _data_source, const String& _data_table, int first_row_added, int num_rows_added) { if (_data_source == data_source && _data_table == data_table) AddChildren(first_row_added, num_rows_added); } -void ElementDataGridRow::OnRowRemove(DataSource* _data_source, const Rml::Core::String& _data_table, int first_row_removed, int num_rows_removed) +void ElementDataGridRow::OnRowRemove(DataSource* _data_source, const String& _data_table, int first_row_removed, int num_rows_removed) { if (_data_source == data_source && _data_table == data_table) RemoveChildren(first_row_removed, num_rows_removed); } -void ElementDataGridRow::OnRowChange(DataSource* _data_source, const Rml::Core::String& _data_table, int first_row_changed, int num_rows_changed) +void ElementDataGridRow::OnRowChange(DataSource* _data_source, const String& _data_table, int first_row_changed, int num_rows_changed) { if (_data_source == data_source && _data_table == data_table) ChangeChildren(first_row_changed, num_rows_changed); } -void ElementDataGridRow::OnRowChange(DataSource* _data_source, const Rml::Core::String& _data_table) +void ElementDataGridRow::OnRowChange(DataSource* _data_source, const String& _data_table) { if (_data_source == data_source && _data_table == data_table) RefreshRows(); @@ -388,7 +387,7 @@ void ElementDataGridRow::AddChildren(int first_row_added, int num_rows_added) if (!row_expanded) { - new_row->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::None)); + new_row->SetProperty(PropertyId::Display, Property(Style::Display::None)); } } @@ -407,11 +406,11 @@ void ElementDataGridRow::AddChildren(int first_row_added, int num_rows_added) RefreshChildDependentCells(); DirtyRow(); - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["first_row_added"] = GetChildTableRelativeIndex(first_row_added); parameters["num_rows_added"] = num_rows_added; - parent_grid->DispatchEvent(Core::EventId::Rowadd, parameters); + parent_grid->DispatchEvent(EventId::Rowadd, parameters); } void ElementDataGridRow::RemoveChildren(int first_row_removed, int num_rows_removed) @@ -432,11 +431,11 @@ void ElementDataGridRow::RemoveChildren(int first_row_removed, int num_rows_remo children[i]->DirtyTableRelativeIndex(); } - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["first_row_removed"] = GetChildTableRelativeIndex(first_row_removed); parameters["num_rows_removed"] = num_rows_removed; - parent_grid->DispatchEvent(Core::EventId::Rowremove, parameters); + parent_grid->DispatchEvent(EventId::Rowremove, parameters); } void ElementDataGridRow::ChangeChildren(int first_row_changed, int num_rows_changed) @@ -444,11 +443,11 @@ void ElementDataGridRow::ChangeChildren(int first_row_changed, int num_rows_chan for (int i = first_row_changed; i < first_row_changed + num_rows_changed; i++) children[i]->DirtyCells(); - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["first_row_changed"] = GetChildTableRelativeIndex(first_row_changed); parameters["num_rows_changed"] = num_rows_changed; - parent_grid->DispatchEvent(Core::EventId::Rowchange, parameters); + parent_grid->DispatchEvent(EventId::Rowchange, parameters); } // Returns the number of rows under this row (children, grandchildren, etc) @@ -469,7 +468,7 @@ void ElementDataGridRow::Load(const DataQuery& row_information) // ourselves up with it. if (row_information.IsFieldSet(DataSource::CHILD_SOURCE)) { - Rml::Core::String data_source = row_information.Get< Rml::Core::String >(DataSource::CHILD_SOURCE, ""); + String data_source = row_information.Get< String >(DataSource::CHILD_SOURCE, ""); if (!data_source.empty()) { SetDataSource(data_source); @@ -484,7 +483,7 @@ void ElementDataGridRow::Load(const DataQuery& row_information) // Now load our cells. for (int i = 0; i < parent_grid->GetNumColumns(); i++) { - Core::Element* cell = GetChild(i); + Element* cell = GetChild(i); if (cell) { @@ -492,31 +491,31 @@ void ElementDataGridRow::Load(const DataQuery& row_information) const ElementDataGrid::Column* column = parent_grid->GetColumn(i); // Now we use the column's formatter to process the raw data into the - // XML string, and parse that into the actual Core::Elements. If there is + // XML string, and parse that into the actual Elements. If there is // no formatter, then we just send through the raw text, in CVS form. - Rml::Core::StringList raw_data; + StringList raw_data; raw_data.reserve(column->fields.size()); size_t raw_data_total_len = 0; for (size_t j = 0; j < column->fields.size(); j++) { if (column->fields[j] == DataSource::DEPTH) { - raw_data.push_back(Rml::Core::CreateString(8, "%d", depth)); + raw_data.push_back(CreateString(8, "%d", depth)); raw_data_total_len += raw_data.back().length(); } else if (column->fields[j] == DataSource::NUM_CHILDREN) { - raw_data.push_back(Rml::Core::CreateString(8, "%d", children.size())); + raw_data.push_back(CreateString(8, "%d", children.size())); raw_data_total_len += raw_data.back().length(); } else { - raw_data.push_back(row_information.Get< Rml::Core::String >(column->fields[j], "")); + raw_data.push_back(row_information.Get< String >(column->fields[j], "")); raw_data_total_len += raw_data.back().length(); } } - Rml::Core::String cell_string; + String cell_string; if (column->formatter) { column->formatter->FormatData(cell_string, raw_data); @@ -541,7 +540,7 @@ void ElementDataGridRow::Load(const DataQuery& row_information) } // Add the new contents to the cell. - Core::Factory::InstanceElementText(cell, cell_string); + Factory::InstanceElementText(cell, cell_string); } else { @@ -555,7 +554,7 @@ void ElementDataGridRow::Load(const DataQuery& row_information) // Instantiates the children that haven't been fully loaded yet. void ElementDataGridRow::LoadChildren(float time_slice) { - double start_time = Core::Clock::GetElapsedTime(); + double start_time = Clock::GetElapsedTime(); int data_query_offset = -1; int data_query_limit = -1; @@ -571,7 +570,7 @@ void ElementDataGridRow::LoadChildren(float time_slice) // In either case, we check if we have a hole that's unfilled, and if // so, we fill it. bool any_dirty_children = false; - for (size_t i = 0; i < children.size() && float(Core::Clock::GetElapsedTime() - start_time) < time_slice; i++) + for (size_t i = 0; i < children.size() && float(Clock::GetElapsedTime() - start_time) < time_slice; i++) { if (children[i]->dirty_cells) { @@ -608,7 +607,7 @@ void ElementDataGridRow::LoadChildren(float time_slice) // end of the list or the end of the hole, fill the hole. else if (unfilled_hole && (end_of_list || end_of_hole_found)) { - float load_time_slice = time_slice - float(Core::Clock::GetElapsedTime() - start_time); + float load_time_slice = time_slice - float(Clock::GetElapsedTime() - start_time); LoadChildren(data_query_offset, data_query_limit, load_time_slice); data_query_offset = -1; data_query_limit = -1; @@ -623,12 +622,12 @@ void ElementDataGridRow::LoadChildren(float time_slice) void ElementDataGridRow::LoadChildren(int first_row_to_load, int num_rows_to_load, double time_slice) { - double start_time = Core::Clock::GetElapsedTime(); + double start_time = Clock::GetElapsedTime(); // Now fetch these new children from the data source, pass them // through each column's data formatter, and add them as our new // child rows. - Rml::Core::String column_query = parent_grid->GetAllColumnFields() + "," + DataSource::CHILD_SOURCE; + String column_query = parent_grid->GetAllColumnFields() + "," + DataSource::CHILD_SOURCE; DataQuery query(data_source, data_table, column_query, first_row_to_load, num_rows_to_load); for (int i = 0; i < num_rows_to_load; i++) @@ -637,13 +636,13 @@ void ElementDataGridRow::LoadChildren(int first_row_to_load, int num_rows_to_loa if (!query.NextRow()) { - Core::Log::Message(Rml::Core::Log::LT_WARNING, "Failed to load row %d from data source %s", i, data_table.c_str()); + Log::Message(Log::LT_WARNING, "Failed to load row %d from data source %s", i, data_table.c_str()); } // Now load the child with the row in the query. children[index]->Load(query); - if (float(Core::Clock::GetElapsedTime() - start_time) > time_slice) + if (float(Clock::GetElapsedTime() - start_time) > time_slice) { break; } @@ -671,7 +670,7 @@ void ElementDataGridRow::DirtyRow() // Sets this row's child rows to be visible. void ElementDataGridRow::Show() { - SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); if (row_expanded) { @@ -685,7 +684,7 @@ void ElementDataGridRow::Show() // Sets this row's children to be invisible. void ElementDataGridRow::Hide() { - SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::None)); + SetProperty(PropertyId::Display, Property(Style::Display::None)); for (size_t i = 0; i < children.size(); i++) { @@ -693,5 +692,4 @@ void ElementDataGridRow::Hide() } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementForm.cpp b/Source/Core/Elements/ElementForm.cpp similarity index 66% rename from Source/Controls/ElementForm.cpp rename to Source/Core/Elements/ElementForm.cpp index 29c2a9dc1..f1361d011 100644 --- a/Source/Controls/ElementForm.cpp +++ b/Source/Core/Elements/ElementForm.cpp @@ -26,16 +26,15 @@ * */ -#include "../../Include/RmlUi/Controls/ElementForm.h" -#include "../../Include/RmlUi/Core/Dictionary.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Controls/ElementFormControl.h" +#include "../../../Include/RmlUi/Core/Elements/ElementForm.h" +#include "../../../Include/RmlUi/Core/Dictionary.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControl.h" namespace Rml { -namespace Controls { // Constructs a new ElementForm. This should not be called directly; use the Factory instead. -ElementForm::ElementForm(const Rml::Core::String& tag) : Core::Element(tag) +ElementForm::ElementForm(const String& tag) : Element(tag) { } @@ -44,19 +43,19 @@ ElementForm::~ElementForm() } // Submits the form. -void ElementForm::Submit(const Rml::Core::String& name, const Rml::Core::String& submit_value) +void ElementForm::Submit(const String& name, const String& submit_value) { - Rml::Core::Dictionary values; + Dictionary values; if (name.empty()) values["submit"] = submit_value; else values[name] = submit_value; - Core::ElementList form_controls; - Core::ElementUtilities::GetElementsByTagName(form_controls, this, "input"); - Core::ElementUtilities::GetElementsByTagName(form_controls, this, "textarea"); - Core::ElementUtilities::GetElementsByTagName(form_controls, this, "select"); - Core::ElementUtilities::GetElementsByTagName(form_controls, this, "dataselect"); + ElementList form_controls; + ElementUtilities::GetElementsByTagName(form_controls, this, "input"); + ElementUtilities::GetElementsByTagName(form_controls, this, "textarea"); + ElementUtilities::GetElementsByTagName(form_controls, this, "select"); + ElementUtilities::GetElementsByTagName(form_controls, this, "dataselect"); for (size_t i = 0; i < form_controls.size(); i++) { @@ -72,23 +71,22 @@ void ElementForm::Submit(const Rml::Core::String& name, const Rml::Core::String& if (!control->IsSubmitted()) continue; - Rml::Core::String control_name = control->GetName(); - Rml::Core::String control_value = control->GetValue(); + String control_name = control->GetName(); + String control_value = control->GetValue(); // Skip over unnamed form controls. if (control_name.empty()) continue; // If the item already exists, append to it. - Rml::Core::Variant* value = GetIf(values, control_name); + Variant* value = GetIf(values, control_name); if (value != nullptr) - *value = value->Get< Rml::Core::String >() + ", " + control_value; + *value = value->Get< String >() + ", " + control_value; else values[control_name] = control_value; } - DispatchEvent(Core::EventId::Submit, values); + DispatchEvent(EventId::Submit, values); } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementFormControl.cpp b/Source/Core/Elements/ElementFormControl.cpp similarity index 77% rename from Source/Controls/ElementFormControl.cpp rename to Source/Core/Elements/ElementFormControl.cpp index 0dbcd2265..59a1e031f 100644 --- a/Source/Controls/ElementFormControl.cpp +++ b/Source/Core/Elements/ElementFormControl.cpp @@ -26,15 +26,14 @@ * */ -#include "../../Include/RmlUi/Controls/ElementFormControl.h" -#include "../../Include/RmlUi/Core/ComputedValues.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControl.h" +#include "../../../Include/RmlUi/Core/ComputedValues.h" namespace Rml { -namespace Controls { -ElementFormControl::ElementFormControl(const Rml::Core::String& tag) : Core::Element(tag) +ElementFormControl::ElementFormControl(const String& tag) : Element(tag) { - SetProperty(Core::PropertyId::TabIndex, Core::Property(Core::Style::TabIndex::Auto)); + SetProperty(PropertyId::TabIndex, Property(Style::TabIndex::Auto)); } ElementFormControl::~ElementFormControl() @@ -42,13 +41,13 @@ ElementFormControl::~ElementFormControl() } // Returns the name of the form control. -Rml::Core::String ElementFormControl::GetName() const +String ElementFormControl::GetName() const { - return GetAttribute("name", ""); + return GetAttribute("name", ""); } // Sets the name of the form control. -void ElementFormControl::SetName(const Rml::Core::String& name) +void ElementFormControl::SetName(const String& name) { SetAttribute("name", name); } @@ -75,9 +74,9 @@ void ElementFormControl::SetDisabled(bool disable) } // Checks for changes to the 'disabled' attribute. -void ElementFormControl::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +void ElementFormControl::OnAttributeChange(const ElementAttributes& changed_attributes) { - Core::Element::OnAttributeChange(changed_attributes); + Element::OnAttributeChange(changed_attributes); if (changed_attributes.find("disabled") != changed_attributes.end()) { @@ -88,7 +87,7 @@ void ElementFormControl::OnAttributeChange(const Core::ElementAttributes& change // events (when originating from user inputs, see Context) to reach the element. if (is_disabled) { - SetProperty(Core::PropertyId::Focus, Core::Property(Core::Style::Focus::None)); + SetProperty(PropertyId::Focus, Property(Style::Focus::None)); Blur(); } else @@ -96,5 +95,4 @@ void ElementFormControl::OnAttributeChange(const Core::ElementAttributes& change } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementFormControlDataSelect.cpp b/Source/Core/Elements/ElementFormControlDataSelect.cpp similarity index 73% rename from Source/Controls/ElementFormControlDataSelect.cpp rename to Source/Core/Elements/ElementFormControlDataSelect.cpp index 8175d7a5b..6d1460015 100644 --- a/Source/Controls/ElementFormControlDataSelect.cpp +++ b/Source/Core/Elements/ElementFormControlDataSelect.cpp @@ -26,17 +26,16 @@ * */ -#include "../../Include/RmlUi/Controls/ElementFormControlDataSelect.h" -#include "../../Include/RmlUi/Controls/DataQuery.h" -#include "../../Include/RmlUi/Controls/DataSource.h" -#include "../../Include/RmlUi/Controls/DataFormatter.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h" +#include "../../../Include/RmlUi/Core/Elements/DataQuery.h" +#include "../../../Include/RmlUi/Core/Elements/DataSource.h" +#include "../../../Include/RmlUi/Core/Elements/DataFormatter.h" #include "WidgetDropDown.h" namespace Rml { -namespace Controls { // Constructs a new ElementFormControlDataSelect. -ElementFormControlDataSelect::ElementFormControlDataSelect(const Rml::Core::String& tag) : ElementFormControlSelect(tag) +ElementFormControlDataSelect::ElementFormControlDataSelect(const String& tag) : ElementFormControlSelect(tag) { data_source = nullptr; initialised = false; @@ -51,7 +50,7 @@ ElementFormControlDataSelect::~ElementFormControlDataSelect() } // Sets the data source the control's options are driven from. -void ElementFormControlDataSelect::SetDataSource(const Rml::Core::String& _data_source) +void ElementFormControlDataSelect::SetDataSource(const String& _data_source) { SetAttribute("source", _data_source); } @@ -64,7 +63,7 @@ void ElementFormControlDataSelect::OnUpdate() { initialised = true; - if (ParseDataSource(data_source, data_table, GetAttribute< Rml::Core::String >("source", ""))) + if (ParseDataSource(data_source, data_table, GetAttribute< String >("source", ""))) { data_source->AttachListener(this); BuildOptions(); @@ -73,7 +72,7 @@ void ElementFormControlDataSelect::OnUpdate() } // Checks for changes to the data source or formatting attributes. -void ElementFormControlDataSelect::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +void ElementFormControlDataSelect::OnAttributeChange(const ElementAttributes& changed_attributes) { ElementFormControlSelect::OnAttributeChange(changed_attributes); @@ -108,7 +107,7 @@ void ElementFormControlDataSelect::OnDataSourceDestroy(DataSource* _data_source) } // Rebuilds the available options from the data source. -void ElementFormControlDataSelect::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& table, int RMLUI_UNUSED_PARAMETER(first_row_added), int RMLUI_UNUSED_PARAMETER(num_rows_added)) +void ElementFormControlDataSelect::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& table, int RMLUI_UNUSED_PARAMETER(first_row_added), int RMLUI_UNUSED_PARAMETER(num_rows_added)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(first_row_added); @@ -119,7 +118,7 @@ void ElementFormControlDataSelect::OnRowAdd(DataSource* RMLUI_UNUSED_PARAMETER(d } // Rebuilds the available options from the data source. -void ElementFormControlDataSelect::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& table, int RMLUI_UNUSED_PARAMETER(first_row_removed), int RMLUI_UNUSED_PARAMETER(num_rows_removed)) +void ElementFormControlDataSelect::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& table, int RMLUI_UNUSED_PARAMETER(first_row_removed), int RMLUI_UNUSED_PARAMETER(num_rows_removed)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(first_row_removed); @@ -130,7 +129,7 @@ void ElementFormControlDataSelect::OnRowRemove(DataSource* RMLUI_UNUSED_PARAMETE } // Rebuilds the available options from the data source. -void ElementFormControlDataSelect::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& table, int RMLUI_UNUSED_PARAMETER(first_row_changed), int RMLUI_UNUSED_PARAMETER(num_rows_changed)) +void ElementFormControlDataSelect::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& table, int RMLUI_UNUSED_PARAMETER(first_row_changed), int RMLUI_UNUSED_PARAMETER(num_rows_changed)) { RMLUI_UNUSED(data_source); RMLUI_UNUSED(first_row_changed); @@ -141,7 +140,7 @@ void ElementFormControlDataSelect::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETE } // Rebuilds the available options from the data source. -void ElementFormControlDataSelect::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const Rml::Core::String& table) +void ElementFormControlDataSelect::OnRowChange(DataSource* RMLUI_UNUSED_PARAMETER(data_source), const String& table) { RMLUI_UNUSED(data_source); @@ -159,18 +158,18 @@ void ElementFormControlDataSelect::BuildOptions() // Store the old selection value and index. These will be used to restore the selection to the // most appropriate option after the options have been rebuilt. - Rml::Core::String old_value = GetValue(); + String old_value = GetValue(); int old_selection = GetSelection(); - Rml::Core::String fields_attribute = GetAttribute("fields", ""); - Rml::Core::String valuefield_attribute = GetAttribute("valuefield", ""); - Rml::Core::String data_formatter_attribute = GetAttribute("formatter", ""); + String fields_attribute = GetAttribute("fields", ""); + String valuefield_attribute = GetAttribute("valuefield", ""); + String data_formatter_attribute = GetAttribute("formatter", ""); DataFormatter* data_formatter = nullptr; // Process the attributes. if (fields_attribute.empty()) { - Core::Log::Message(Rml::Core::Log::LT_ERROR, "DataQuery failed, no fields specified for %s.", GetTagName().c_str()); + Log::Message(Log::LT_ERROR, "DataQuery failed, no fields specified for %s.", GetTagName().c_str()); return; } @@ -183,24 +182,24 @@ void ElementFormControlDataSelect::BuildOptions() { data_formatter = DataFormatter::GetDataFormatter(data_formatter_attribute); if (!data_formatter) - Core::Log::Message(Rml::Core::Log::LT_WARNING, "Unable to find data formatter named '%s', formatting skipped.", data_formatter_attribute.c_str()); + Log::Message(Log::LT_WARNING, "Unable to find data formatter named '%s', formatting skipped.", data_formatter_attribute.c_str()); } // Build a list of attributes - Rml::Core::String fields(valuefield_attribute); + String fields(valuefield_attribute); fields += ","; fields += fields_attribute; DataQuery query(data_source, data_table, fields); while (query.NextRow()) { - Rml::Core::StringList fields_list; - Rml::Core::String value = query.Get(0, ""); + StringList fields_list; + String value = query.Get(0, ""); for (size_t i = 1; i < query.GetNumFields(); ++i) - fields_list.push_back(query.Get< Rml::Core::String>(i, "")); + fields_list.push_back(query.Get< String>(i, "")); - Rml::Core::String formatted; + String formatted; if (fields_list.size() > 0) formatted = fields_list[0]; @@ -226,7 +225,7 @@ void ElementFormControlDataSelect::BuildOptions() } // Failed to find an option with the same value. Attempt to at least set the same index. - int new_selection = Rml::Core::Math::Clamp(old_selection, 0, GetNumOptions() - 1); + int new_selection = Math::Clamp(old_selection, 0, GetNumOptions() - 1); if (GetNumOptions() == 0) new_selection = -1; @@ -234,5 +233,4 @@ void ElementFormControlDataSelect::BuildOptions() } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementFormControlInput.cpp b/Source/Core/Elements/ElementFormControlInput.cpp similarity index 81% rename from Source/Controls/ElementFormControlInput.cpp rename to Source/Core/Elements/ElementFormControlInput.cpp index a8a9599d9..8a39ba73e 100644 --- a/Source/Controls/ElementFormControlInput.cpp +++ b/Source/Core/Elements/ElementFormControlInput.cpp @@ -26,8 +26,8 @@ * */ -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" -#include "../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/Event.h" #include "InputTypeButton.h" #include "InputTypeCheckbox.h" #include "InputTypeRadio.h" @@ -36,10 +36,9 @@ #include "InputTypeText.h" namespace Rml { -namespace Controls { // Constructs a new ElementFormControlInput. -ElementFormControlInput::ElementFormControlInput(const Rml::Core::String& tag) : ElementFormControl(tag) +ElementFormControlInput::ElementFormControlInput(const String& tag) : ElementFormControl(tag) { // OnAttributeChange will be called right after this, possible with a non-default type. Thus, // creating the default InputTypeText here may result in it being destroyed in just a few moments. @@ -53,14 +52,14 @@ ElementFormControlInput::~ElementFormControlInput() } // Returns a string representation of the current value of the form control. -Rml::Core::String ElementFormControlInput::GetValue() const +String ElementFormControlInput::GetValue() const { RMLUI_ASSERT(type); return type->GetValue(); } // Sets the current value of the form control. -void ElementFormControlInput::SetValue(const Rml::Core::String& value) +void ElementFormControlInput::SetValue(const String& value) { SetAttribute("value", value); } @@ -93,16 +92,16 @@ void ElementFormControlInput::OnResize() } // Checks for necessary functional changes in the control as a result of changed attributes. -void ElementFormControlInput::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +void ElementFormControlInput::OnAttributeChange(const ElementAttributes& changed_attributes) { ElementFormControl::OnAttributeChange(changed_attributes); - Rml::Core::String new_type_name; + String new_type_name; auto it_type = changed_attributes.find("type"); if (it_type != changed_attributes.end()) { - new_type_name = it_type->second.Get("text"); + new_type_name = it_type->second.Get("text"); } if (!type || (!new_type_name.empty() && new_type_name != type_name)) @@ -110,7 +109,7 @@ void ElementFormControlInput::OnAttributeChange(const Core::ElementAttributes& c InputType* new_type = nullptr; if (new_type_name == "password") - new_type = new InputTypeText(this, Rml::Controls::InputTypeText::OBSCURED); + new_type = new InputTypeText(this, InputTypeText::OBSCURED); else if (new_type_name == "radio") new_type = new InputTypeRadio(this); else if (new_type_name == "checkbox") @@ -148,7 +147,7 @@ void ElementFormControlInput::OnAttributeChange(const Core::ElementAttributes& c } // Called when properties on the element are changed. -void ElementFormControlInput::OnPropertyChange(const Core::PropertyIdSet& changed_properties) +void ElementFormControlInput::OnPropertyChange(const PropertyIdSet& changed_properties) { ElementFormControl::OnPropertyChange(changed_properties); @@ -157,33 +156,32 @@ void ElementFormControlInput::OnPropertyChange(const Core::PropertyIdSet& change } // If we are the added element, this will pass the call onto our type handler. -void ElementFormControlInput::OnChildAdd(Rml::Core::Element* child) +void ElementFormControlInput::OnChildAdd(Element* child) { if (child == this && type != nullptr) type->OnChildAdd(); } // If we are the removed element, this will pass the call onto our type handler. -void ElementFormControlInput::OnChildRemove(Rml::Core::Element* child) +void ElementFormControlInput::OnChildRemove(Element* child) { if (child == this && type != nullptr) type->OnChildRemove(); } // Handles the "click" event to toggle the control's checked status. -void ElementFormControlInput::ProcessDefaultAction(Core::Event& event) +void ElementFormControlInput::ProcessDefaultAction(Event& event) { ElementFormControl::ProcessDefaultAction(event); if(type != nullptr) type->ProcessDefaultAction(event); } -bool ElementFormControlInput::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool ElementFormControlInput::GetIntrinsicDimensions(Vector2f& dimensions) { if (!type) return false; return type->GetIntrinsicDimensions(dimensions); } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementFormControlSelect.cpp b/Source/Core/Elements/ElementFormControlSelect.cpp similarity index 82% rename from Source/Controls/ElementFormControlSelect.cpp rename to Source/Core/Elements/ElementFormControlSelect.cpp index 7b787e6a0..5e8e36e45 100644 --- a/Source/Controls/ElementFormControlSelect.cpp +++ b/Source/Core/Elements/ElementFormControlSelect.cpp @@ -26,17 +26,16 @@ * */ -#include "../../Include/RmlUi/Controls/ElementFormControlSelect.h" -#include "../../Include/RmlUi/Core/ElementText.h" -#include "../../Include/RmlUi/Core/Event.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlSelect.h" +#include "../../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" #include "WidgetDropDown.h" namespace Rml { -namespace Controls { // Constructs a new ElementFormControlSelect. -ElementFormControlSelect::ElementFormControlSelect(const Rml::Core::String& tag) : ElementFormControl(tag) +ElementFormControlSelect::ElementFormControlSelect(const String& tag) : ElementFormControl(tag) { widget = new WidgetDropDown(this); } @@ -47,14 +46,14 @@ ElementFormControlSelect::~ElementFormControlSelect() } // Returns a string representation of the current value of the form control. -Rml::Core::String ElementFormControlSelect::GetValue() const +String ElementFormControlSelect::GetValue() const { RMLUI_ASSERT(widget != nullptr); return widget->GetValue(); } // Sets the current value of the form control. -void ElementFormControlSelect::SetValue(const Rml::Core::String& value) +void ElementFormControlSelect::SetValue(const String& value) { OnUpdate(); @@ -97,7 +96,7 @@ int ElementFormControlSelect::GetNumOptions() } // Adds a new option to the select control. -int ElementFormControlSelect::Add(const Rml::Core::String& rml, const Rml::Core::String& value, int before, bool selectable) +int ElementFormControlSelect::Add(const String& rml, const String& value, int before, bool selectable) { OnUpdate(); @@ -129,13 +128,13 @@ void ElementFormControlSelect::OnUpdate() ElementFormControl::OnUpdate(); // Move any child elements into the widget (except for the three functional elements). - while (Core::Element * raw_child = GetFirstChild()) + while (Element * raw_child = GetFirstChild()) { - Core::ElementPtr child = RemoveChild(raw_child); + ElementPtr child = RemoveChild(raw_child); bool select = child->GetAttribute("selected"); bool selectable = !child->GetAttribute("disabled"); - Core::String option_value = child->GetAttribute("value", Core::String()); + String option_value = child->GetAttribute("value", String()); child->RemoveAttribute("selected"); child->RemoveAttribute("disabled"); @@ -160,12 +159,11 @@ void ElementFormControlSelect::OnLayout() } // Returns true to mark this element as replaced. -bool ElementFormControlSelect::GetIntrinsicDimensions(Rml::Core::Vector2f& intrinsic_dimensions) +bool ElementFormControlSelect::GetIntrinsicDimensions(Vector2f& intrinsic_dimensions) { intrinsic_dimensions.x = 128; intrinsic_dimensions.y = 16; return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementFormControlTextArea.cpp b/Source/Core/Elements/ElementFormControlTextArea.cpp similarity index 70% rename from Source/Controls/ElementFormControlTextArea.cpp rename to Source/Core/Elements/ElementFormControlTextArea.cpp index bc554eee7..88350ab34 100644 --- a/Source/Controls/ElementFormControlTextArea.cpp +++ b/Source/Core/Elements/ElementFormControlTextArea.cpp @@ -26,24 +26,23 @@ * */ -#include "../../Include/RmlUi/Controls/ElementFormControlTextArea.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Core/ElementText.h" -#include "../../Include/RmlUi/Core/PropertyIdSet.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlTextArea.h" +#include "../../../Include/RmlUi/Core/Math.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/PropertyIdSet.h" #include "WidgetTextInputMultiLine.h" namespace Rml { -namespace Controls { // Constructs a new ElementFormControlTextArea. -ElementFormControlTextArea::ElementFormControlTextArea(const Rml::Core::String& tag) : ElementFormControl(tag) +ElementFormControlTextArea::ElementFormControlTextArea(const String& tag) : ElementFormControl(tag) { widget = new WidgetTextInputMultiLine(this); - SetProperty(Core::PropertyId::OverflowX, Core::Property(Core::Style::Overflow::Auto)); - SetProperty(Core::PropertyId::OverflowY, Core::Property(Core::Style::Overflow::Auto)); - SetProperty(Core::PropertyId::WhiteSpace, Core::Property(Core::Style::WhiteSpace::Prewrap)); + SetProperty(PropertyId::OverflowX, Property(Style::Overflow::Auto)); + SetProperty(PropertyId::OverflowY, Property(Style::Overflow::Auto)); + SetProperty(PropertyId::WhiteSpace, Property(Style::WhiteSpace::Prewrap)); } ElementFormControlTextArea::~ElementFormControlTextArea() @@ -52,13 +51,13 @@ ElementFormControlTextArea::~ElementFormControlTextArea() } // Returns a string representation of the current value of the form control. -Rml::Core::String ElementFormControlTextArea::GetValue() const +String ElementFormControlTextArea::GetValue() const { - return GetAttribute< Rml::Core::String >("value", ""); + return GetAttribute< String >("value", ""); } // Sets the current value of the form control. -void ElementFormControlTextArea::SetValue(const Rml::Core::String& value) +void ElementFormControlTextArea::SetValue(const String& value) { SetAttribute("value", value); } @@ -67,7 +66,7 @@ void ElementFormControlTextArea::SetValue(const Rml::Core::String& value) // fixed-width font. void ElementFormControlTextArea::SetNumColumns(int num_columns) { - SetAttribute< int >("cols", Rml::Core::Math::Max(1, num_columns)); + SetAttribute< int >("cols", Math::Max(1, num_columns)); } // Returns the approximate number of characters visible at once. @@ -79,7 +78,7 @@ int ElementFormControlTextArea::GetNumColumns() const // Sets the number of visible lines of text in the text area. void ElementFormControlTextArea::SetNumRows(int num_rows) { - SetAttribute< int >("rows", Rml::Core::Math::Max(1, num_rows)); + SetAttribute< int >("rows", Math::Max(1, num_rows)); } // Returns the number of visible lines of text in the text area. @@ -115,14 +114,14 @@ void ElementFormControlTextArea::SetWordWrap(bool word_wrap) // Returns the state of word-wrapping in the text area. bool ElementFormControlTextArea::GetWordWrap() { - Rml::Core::String attribute = GetAttribute< Rml::Core::String >("wrap", ""); + String attribute = GetAttribute< String >("wrap", ""); return attribute != "nowrap"; } // Returns the control's inherent size, based on the length of the input field and the current font size. -bool ElementFormControlTextArea::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool ElementFormControlTextArea::GetIntrinsicDimensions(Vector2f& dimensions) { - dimensions.x = (float) (GetNumColumns() * Core::ElementUtilities::GetStringWidth(this, "m")); + dimensions.x = (float) (GetNumColumns() * ElementUtilities::GetStringWidth(this, "m")); dimensions.y = (float)GetNumRows() * GetLineHeight(); return true; @@ -153,16 +152,16 @@ void ElementFormControlTextArea::OnLayout() } // Called when attributes on the element are changed. -void ElementFormControlTextArea::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +void ElementFormControlTextArea::OnAttributeChange(const ElementAttributes& changed_attributes) { ElementFormControl::OnAttributeChange(changed_attributes); if (changed_attributes.find("wrap") != changed_attributes.end()) { if (GetWordWrap()) - SetProperty(Core::PropertyId::WhiteSpace, Core::Property(Core::Style::WhiteSpace::Prewrap)); + SetProperty(PropertyId::WhiteSpace, Property(Style::WhiteSpace::Prewrap)); else - SetProperty(Core::PropertyId::WhiteSpace, Core::Property(Core::Style::WhiteSpace::Pre)); + SetProperty(PropertyId::WhiteSpace, Property(Style::WhiteSpace::Pre)); } if (changed_attributes.find("rows") != changed_attributes.end() || @@ -177,20 +176,19 @@ void ElementFormControlTextArea::OnAttributeChange(const Core::ElementAttributes } // Called when properties on the control are changed. -void ElementFormControlTextArea::OnPropertyChange(const Core::PropertyIdSet& changed_properties) +void ElementFormControlTextArea::OnPropertyChange(const PropertyIdSet& changed_properties) { ElementFormControl::OnPropertyChange(changed_properties); - if (changed_properties.Contains(Core::PropertyId::Color) || - changed_properties.Contains(Core::PropertyId::BackgroundColor)) + if (changed_properties.Contains(PropertyId::Color) || + changed_properties.Contains(PropertyId::BackgroundColor)) widget->UpdateSelectionColours(); } // Returns the text content of the element. -void ElementFormControlTextArea::GetInnerRML(Rml::Core::String& content) const +void ElementFormControlTextArea::GetInnerRML(String& content) const { content = GetValue(); } -} -} +} // namespace Rml diff --git a/Source/Core/ElementImage.cpp b/Source/Core/Elements/ElementImage.cpp similarity index 88% rename from Source/Core/ElementImage.cpp rename to Source/Core/Elements/ElementImage.cpp index e10dd8e09..8948dbbb0 100644 --- a/Source/Core/ElementImage.cpp +++ b/Source/Core/Elements/ElementImage.cpp @@ -27,15 +27,14 @@ */ #include "ElementImage.h" -#include "TextureDatabase.h" -#include "../../Include/RmlUi/Core/URL.h" -#include "../../Include/RmlUi/Core/PropertyIdSet.h" -#include "../../Include/RmlUi/Core/GeometryUtilities.h" -#include "../../Include/RmlUi/Core/ElementDocument.h" -#include "../../Include/RmlUi/Core/StyleSheet.h" +#include "../TextureDatabase.h" +#include "../../../Include/RmlUi/Core/URL.h" +#include "../../../Include/RmlUi/Core/PropertyIdSet.h" +#include "../../../Include/RmlUi/Core/GeometryUtilities.h" +#include "../../../Include/RmlUi/Core/ElementDocument.h" +#include "../../../Include/RmlUi/Core/StyleSheet.h" namespace Rml { -namespace Core { // Constructs a new ElementImage. ElementImage::ElementImage(const String& tag) : Element(tag), dimensions(-1, -1), rect_source(RectSource::None), geometry(this) @@ -85,14 +84,14 @@ void ElementImage::OnRender() GenerateGeometry(); // Render the geometry beginning at this element's content region. - geometry.Render(GetAbsoluteOffset(Rml::Core::Box::CONTENT).Round()); + geometry.Render(GetAbsoluteOffset(Box::CONTENT).Round()); } // Called when attributes on the element are changed. -void ElementImage::OnAttributeChange(const Rml::Core::ElementAttributes& changed_attributes) +void ElementImage::OnAttributeChange(const ElementAttributes& changed_attributes) { // Call through to the base element's OnAttributeChange(). - Rml::Core::Element::OnAttributeChange(changed_attributes); + Element::OnAttributeChange(changed_attributes); float dirty_layout = false; @@ -148,7 +147,7 @@ void ElementImage::GenerateGeometry() // Release the old geometry before specifying the new vertices. geometry.Release(true); - std::vector< Rml::Core::Vertex >& vertices = geometry.GetVertices(); + std::vector< Vertex >& vertices = geometry.GetVertices(); std::vector< int >& indices = geometry.GetIndices(); vertices.resize(4); @@ -182,9 +181,9 @@ void ElementImage::GenerateGeometry() Colourb quad_colour = computed.image_color; quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha); - Vector2f quad_size = GetBox().GetSize(Rml::Core::Box::CONTENT).Round(); + Vector2f quad_size = GetBox().GetSize(Box::CONTENT).Round(); - Rml::Core::GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0, 0), quad_size, quad_colour, texcoords[0], texcoords[1]); + GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0, 0), quad_size, quad_colour, texcoords[0], texcoords[1]); geometry_dirty = false; } @@ -263,7 +262,7 @@ void ElementImage::UpdateRect() if (coords_list.size() != 4) { - Rml::Core::Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'rect' attribute; rect requires 4 space-separated values, found %d.", GetAddress().c_str(), coords_list.size()); + Log::Message(Log::LT_WARNING, "Element '%s' has an invalid 'rect' attribute; rect requires 4 space-separated values, found %d.", GetAddress().c_str(), coords_list.size()); } else { @@ -287,5 +286,4 @@ void ElementImage::UpdateRect() } } -} -} +} // namespace Rml diff --git a/Source/Core/ElementImage.h b/Source/Core/Elements/ElementImage.h similarity index 92% rename from Source/Core/ElementImage.h rename to Source/Core/Elements/ElementImage.h index bae15c8d0..a47164b7f 100644 --- a/Source/Core/ElementImage.h +++ b/Source/Core/Elements/ElementImage.h @@ -26,17 +26,16 @@ * */ -#ifndef RMLUICOREELEMENTIMAGE_H -#define RMLUICOREELEMENTIMAGE_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTIMAGE_H +#define RMLUI_CORE_ELEMENTS_ELEMENTIMAGE_H -#include "../../Include/RmlUi/Core/Header.h" -#include "../../Include/RmlUi/Core/Element.h" -#include "../../Include/RmlUi/Core/Geometry.h" -#include "../../Include/RmlUi/Core/Texture.h" -#include "../../Include/RmlUi/Core/Spritesheet.h" +#include "../../../Include/RmlUi/Core/Header.h" +#include "../../../Include/RmlUi/Core/Element.h" +#include "../../../Include/RmlUi/Core/Geometry.h" +#include "../../../Include/RmlUi/Core/Texture.h" +#include "../../../Include/RmlUi/Core/Spritesheet.h" namespace Rml { -namespace Core { /** The 'img' element can render images and sprites. @@ -119,7 +118,5 @@ class RMLUICORE_API ElementImage : public Element bool geometry_dirty; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/ElementProgressBar.cpp b/Source/Core/Elements/ElementProgressBar.cpp similarity index 80% rename from Source/Controls/ElementProgressBar.cpp rename to Source/Core/Elements/ElementProgressBar.cpp index f1baa711a..2bef2596b 100644 --- a/Source/Controls/ElementProgressBar.cpp +++ b/Source/Core/Elements/ElementProgressBar.cpp @@ -26,27 +26,26 @@ * */ -#include "../../Include/RmlUi/Controls/ElementProgressBar.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/GeometryUtilities.h" -#include "../../Include/RmlUi/Core/PropertyIdSet.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/ElementDocument.h" -#include "../../Include/RmlUi/Core/StyleSheet.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Core/URL.h" +#include "../../../Include/RmlUi/Core/Elements/ElementProgressBar.h" +#include "../../../Include/RmlUi/Core/Math.h" +#include "../../../Include/RmlUi/Core/GeometryUtilities.h" +#include "../../../Include/RmlUi/Core/PropertyIdSet.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/ElementDocument.h" +#include "../../../Include/RmlUi/Core/StyleSheet.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/URL.h" #include namespace Rml { -namespace Controls { -ElementProgressBar::ElementProgressBar(const Core::String& tag) : Element(tag), direction(DefaultDirection), start_edge(DefaultStartEdge), value(0), fill(nullptr), rect_set(false), geometry(this) +ElementProgressBar::ElementProgressBar(const String& tag) : Element(tag), direction(DefaultDirection), start_edge(DefaultStartEdge), value(0), fill(nullptr), rect_set(false), geometry(this) { geometry_dirty = false; texture_dirty = true; // Add the fill element as a non-DOM element. - Core::ElementPtr fill_element = Core::Factory::InstanceElement(this, "*", "fill", Core::XMLAttributes()); + ElementPtr fill_element = Factory::InstanceElement(this, "*", "fill", XMLAttributes()); RMLUI_ASSERT(fill_element); fill = AppendChild(std::move(fill_element), false); } @@ -75,24 +74,24 @@ void ElementProgressBar::OnRender() geometry.Render(fill->GetAbsoluteOffset().Round()); } -void ElementProgressBar::OnAttributeChange(const Rml::Core::ElementAttributes& changed_attributes) +void ElementProgressBar::OnAttributeChange(const ElementAttributes& changed_attributes) { - Rml::Core::Element::OnAttributeChange(changed_attributes); + Element::OnAttributeChange(changed_attributes); if (changed_attributes.find("value") != changed_attributes.end()) { - value = Core::Math::Clamp( GetAttribute< float >("value", 0.0f), 0.0f, 1.0f); + value = Math::Clamp( GetAttribute< float >("value", 0.0f), 0.0f, 1.0f); geometry_dirty = true; } if (changed_attributes.find("direction") != changed_attributes.end()) { - using DirectionNameList = std::array; + using DirectionNameList = std::array; static const DirectionNameList names = { "top", "right", "bottom", "left", "clockwise", "counter-clockwise" }; direction = DefaultDirection; - Core::String name = Core::StringUtilities::ToLower( GetAttribute< Core::String >("direction", "") ); + String name = StringUtilities::ToLower( GetAttribute< String >("direction", "") ); auto it = std::find(names.begin(), names.end(), name); size_t index = size_t(it - names.begin()); @@ -104,12 +103,12 @@ void ElementProgressBar::OnAttributeChange(const Rml::Core::ElementAttributes& c if (changed_attributes.find("start-edge") != changed_attributes.end()) { - using StartEdgeNameList = std::array; + using StartEdgeNameList = std::array; static const StartEdgeNameList names = { "top", "right", "bottom", "left" }; start_edge = DefaultStartEdge; - Core::String name = Core::StringUtilities::ToLower(GetAttribute< Core::String >("start-edge", "")); + String name = StringUtilities::ToLower(GetAttribute< String >("start-edge", "")); auto it = std::find(names.begin(), names.end(), name); size_t index = size_t(it - names.begin()); @@ -120,25 +119,22 @@ void ElementProgressBar::OnAttributeChange(const Rml::Core::ElementAttributes& c } } -void ElementProgressBar::OnPropertyChange(const Core::PropertyIdSet& changed_properties) +void ElementProgressBar::OnPropertyChange(const PropertyIdSet& changed_properties) { Element::OnPropertyChange(changed_properties); - if (changed_properties.Contains(Core::PropertyId::ImageColor) || - changed_properties.Contains(Core::PropertyId::Opacity)) { + if (changed_properties.Contains(PropertyId::ImageColor) || + changed_properties.Contains(PropertyId::Opacity)) { geometry_dirty = true; } - if (changed_properties.Contains(Core::PropertyId::FillImage)) { + if (changed_properties.Contains(PropertyId::FillImage)) { texture_dirty = true; } } void ElementProgressBar::OnResize() { - using Core::Box; - using Core::Vector2f; - const Vector2f element_size = GetBox().GetSize(); // Build and set the 'fill' element's box. Here we are mainly interested in all the edge sizes set by the user. @@ -146,7 +142,7 @@ void ElementProgressBar::OnResize() // the 'fill' element's content size is further shrunk according to 'value' along the proper direction. Box fill_box; - Core::ElementUtilities::BuildBox(fill_box, element_size, fill); + ElementUtilities::BuildBox(fill_box, element_size, fill); const Vector2f margin_top_left( fill_box.GetEdge(Box::MARGIN, Box::LEFT), @@ -165,8 +161,6 @@ void ElementProgressBar::OnResize() void ElementProgressBar::GenerateGeometry() { - using Core::Vector2f; - Vector2f render_size = fill_size; { @@ -197,7 +191,7 @@ void ElementProgressBar::GenerateGeometry() RMLUI_UNUSED_SWITCH_ENUM(Direction::Count); } - Core::Box fill_box = fill->GetBox(); + Box fill_box = fill->GetBox(); fill_box.SetContent(render_size); fill->SetBox(fill_box); fill->SetOffset(offset, this); @@ -239,12 +233,12 @@ void ElementProgressBar::GenerateGeometry() texcoords[1] = Vector2f(1, 1); } - Core::Colourb quad_colour; + Colourb quad_colour; { - const Core::ComputedValues& computed = GetComputedValues(); + const ComputedValues& computed = GetComputedValues(); const float opacity = computed.opacity; quad_colour = computed.image_color; - quad_colour.alpha = (Core::byte)(opacity * (float)quad_colour.alpha); + quad_colour.alpha = (byte)(opacity * (float)quad_colour.alpha); } @@ -263,7 +257,7 @@ void ElementProgressBar::GenerateGeometry() // The circular directions require custom geometry as a box is insufficient. // We divide the "circle" into eight parts, here called octants, such that each part can be represented by a triangle. // 'num_octants' tells us how many of these are completely or partially filled. - const int num_octants = Core::Math::Clamp(Core::Math::RoundUpToInteger(8.f * value), 0, 8); + const int num_octants = Math::Clamp(Math::RoundUpToInteger(8.f * value), 0, 8); const int num_vertices = 2 + num_octants; const int num_triangles = num_octants; const bool cw = (direction == Direction::Clockwise); @@ -294,7 +288,7 @@ void ElementProgressBar::GenerateGeometry() // Find the position of the vertex representing the partially filled triangle. if (value < 1.f) { - using namespace Core::Math; + using namespace Math; const float angle_offset = float(start_octant) / 8.f * 2.f * RMLUI_PI; const float angle = angle_offset + (cw ? 1.f : -1.f) * value * 2.f * RMLUI_PI; Vector2f pos(Sin(angle), -Cos(angle)); @@ -332,7 +326,7 @@ void ElementProgressBar::GenerateGeometry() { vertices.resize(4); indices.resize(6); - Rml::Core::GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0), render_size, quad_colour, texcoords[0], texcoords[1]); + GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0), render_size, quad_colour, texcoords[0], texcoords[1]); } } @@ -342,12 +336,12 @@ bool ElementProgressBar::LoadTexture() geometry_dirty = true; rect_set = false; - Core::String name; + String name; - if (auto property = fill->GetLocalProperty(Core::PropertyId::FillImage)) - name = property->Get(); + if (auto property = fill->GetLocalProperty(PropertyId::FillImage)) + name = property->Get(); - Core::ElementDocument* document = GetOwnerDocument(); + ElementDocument* document = GetOwnerDocument(); bool texture_set = false; @@ -356,7 +350,7 @@ bool ElementProgressBar::LoadTexture() // Check for a sprite first, this takes precedence. if (auto& style_sheet = document->GetStyleSheet()) { - if (const Core::Sprite* sprite = style_sheet->GetSprite(name)) + if (const Sprite* sprite = style_sheet->GetSprite(name)) { rect = sprite->rectangle; rect_set = true; @@ -368,7 +362,7 @@ bool ElementProgressBar::LoadTexture() // Otherwise, treat it as a path if (!texture_set) { - Core::URL source_url; + URL source_url; source_url.SetURL(document->GetSourceURL()); texture.Set(name, source_url.GetPath()); texture_set = true; @@ -387,5 +381,4 @@ bool ElementProgressBar::LoadTexture() return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementTabSet.cpp b/Source/Core/Elements/ElementTabSet.cpp similarity index 62% rename from Source/Controls/ElementTabSet.cpp rename to Source/Core/Elements/ElementTabSet.cpp index cc7c1343e..2be8bde57 100644 --- a/Source/Controls/ElementTabSet.cpp +++ b/Source/Core/Elements/ElementTabSet.cpp @@ -26,14 +26,13 @@ * */ -#include "../../Include/RmlUi/Controls/ElementTabSet.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/Elements/ElementTabSet.h" +#include "../../../Include/RmlUi/Core/Math.h" +#include "../../../Include/RmlUi/Core/Factory.h" namespace Rml { -namespace Controls { -ElementTabSet::ElementTabSet(const Rml::Core::String& tag) : Core::Element(tag) +ElementTabSet::ElementTabSet(const String& tag) : Element(tag) { active_tab = 0; } @@ -43,25 +42,25 @@ ElementTabSet::~ElementTabSet() } // Sets the specifed tab index's tab title RML. -void ElementTabSet::SetTab(int tab_index, const Rml::Core::String& rml) +void ElementTabSet::SetTab(int tab_index, const String& rml) { - Core::ElementPtr element = Core::Factory::InstanceElement(nullptr, "*", "tab", Rml::Core::XMLAttributes()); - Core::Factory::InstanceElementText(element.get(), rml); + ElementPtr element = Factory::InstanceElement(nullptr, "*", "tab", XMLAttributes()); + Factory::InstanceElementText(element.get(), rml); SetTab(tab_index, std::move(element)); } // Sets the specifed tab index's tab panel RML. -void ElementTabSet::SetPanel(int tab_index, const Rml::Core::String& rml) +void ElementTabSet::SetPanel(int tab_index, const String& rml) { - Core::ElementPtr element = Core::Factory::InstanceElement(nullptr, "*", "panel", Rml::Core::XMLAttributes()); - Core::Factory::InstanceElementText(element.get(), rml); + ElementPtr element = Factory::InstanceElement(nullptr, "*", "panel", XMLAttributes()); + Factory::InstanceElementText(element.get(), rml); SetPanel(tab_index, std::move(element)); } // Set the specifed tab index's title element. -void ElementTabSet::SetTab(int tab_index, Core::ElementPtr element) +void ElementTabSet::SetTab(int tab_index, ElementPtr element) { - Core::Element* tabs = GetChildByTag("tabs"); + Element* tabs = GetChildByTag("tabs"); if (tab_index >= 0 && tab_index < tabs->GetNumChildren()) tabs->ReplaceChild(std::move(element), GetChild(tab_index)); @@ -70,10 +69,10 @@ void ElementTabSet::SetTab(int tab_index, Core::ElementPtr element) } // Set the specified tab index's body element. -void ElementTabSet::SetPanel(int tab_index, Core::ElementPtr element) +void ElementTabSet::SetPanel(int tab_index, ElementPtr element) { // append the window - Core::Element* windows = GetChildByTag("panels"); + Element* windows = GetChildByTag("panels"); if (tab_index >= 0 && tab_index < windows->GetNumChildren()) windows->ReplaceChild(std::move(element), GetChild(tab_index)); @@ -87,8 +86,8 @@ void ElementTabSet::RemoveTab(int tab_index) if (tab_index < 0) return; - Core::Element* panels = GetChildByTag("panels"); - Core::Element* tabs = GetChildByTag("tabs"); + Element* panels = GetChildByTag("panels"); + Element* tabs = GetChildByTag("tabs"); if (panels->GetNumChildren() > tab_index && tabs->GetNumChildren() > tab_index) @@ -109,29 +108,29 @@ void ElementTabSet::SetActiveTab(int tab_index) // Update display if the tab has changed if (tab_index != active_tab) { - Core::Element* tabs = GetChildByTag("tabs"); - Core::Element* old_tab = tabs->GetChild(active_tab); - Core::Element* new_tab = tabs->GetChild(tab_index); + Element* tabs = GetChildByTag("tabs"); + Element* old_tab = tabs->GetChild(active_tab); + Element* new_tab = tabs->GetChild(tab_index); if (old_tab) old_tab->SetPseudoClass("selected", false); if (new_tab) new_tab->SetPseudoClass("selected", true); - Core::Element* windows = GetChildByTag("panels"); - Core::Element* old_window = windows->GetChild(active_tab); - Core::Element* new_window = windows->GetChild(tab_index); + Element* windows = GetChildByTag("panels"); + Element* old_window = windows->GetChild(active_tab); + Element* new_window = windows->GetChild(tab_index); if (old_window) - old_window->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::None)); + old_window->SetProperty(PropertyId::Display, Property(Style::Display::None)); if (new_window) - new_window->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + new_window->SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); active_tab = tab_index; - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["tab_index"] = active_tab; - DispatchEvent(Core::EventId::Tabchange, parameters); + DispatchEvent(EventId::Tabchange, parameters); } } @@ -140,15 +139,15 @@ int ElementTabSet::GetActiveTab() const return active_tab; } -void ElementTabSet::ProcessDefaultAction(Core::Event& event) +void ElementTabSet::ProcessDefaultAction(Event& event) { Element::ProcessDefaultAction(event); - if (event == Core::EventId::Click) + if (event == EventId::Click) { // Find the tab that this click occured on - Core::Element* tabs = GetChildByTag("tabs"); - Core::Element* tab = event.GetTargetElement(); + Element* tabs = GetChildByTag("tabs"); + Element* tab = event.GetTargetElement(); while (tab && tab != this && tab->GetParentNode() != tabs) tab = tab->GetParentNode(); @@ -171,14 +170,14 @@ void ElementTabSet::ProcessDefaultAction(Core::Event& event) } } -void ElementTabSet::OnChildAdd(Core::Element* child) +void ElementTabSet::OnChildAdd(Element* child) { - Core::Element::OnChildAdd(child); + Element::OnChildAdd(child); if (child->GetParentNode() == GetChildByTag("tabs")) { // Set up the new button and append it - child->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + child->SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); if (child->GetParentNode()->GetChild(active_tab) == child) child->SetPseudoClass("selected", true); @@ -187,15 +186,15 @@ void ElementTabSet::OnChildAdd(Core::Element* child) if (child->GetParentNode() == GetChildByTag("panels")) { // Hide the new tab window - child->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::None)); + child->SetProperty(PropertyId::Display, Property(Style::Display::None)); // Make the new element visible if its the active tab if (child->GetParentNode()->GetChild(active_tab) == child) - child->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::InlineBlock)); + child->SetProperty(PropertyId::Display, Property(Style::Display::InlineBlock)); } } -Core::Element* ElementTabSet::GetChildByTag(const Rml::Core::String& tag) +Element* ElementTabSet::GetChildByTag(const String& tag) { // Look for the existing child for (int i = 0; i < GetNumChildren(); i++) @@ -205,11 +204,10 @@ Core::Element* ElementTabSet::GetChildByTag(const Rml::Core::String& tag) } // If it doesn't exist, create it - Core::ElementPtr element = Core::Factory::InstanceElement(this, "*", tag, Rml::Core::XMLAttributes()); - Core::Element* result = AppendChild(std::move(element)); + ElementPtr element = Factory::InstanceElement(this, "*", tag, XMLAttributes()); + Element* result = AppendChild(std::move(element)); return result; } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementTextSelection.cpp b/Source/Core/Elements/ElementTextSelection.cpp similarity index 82% rename from Source/Controls/ElementTextSelection.cpp rename to Source/Core/Elements/ElementTextSelection.cpp index c405ed517..036e61408 100644 --- a/Source/Controls/ElementTextSelection.cpp +++ b/Source/Core/Elements/ElementTextSelection.cpp @@ -28,12 +28,11 @@ #include "ElementTextSelection.h" #include "WidgetTextInput.h" -#include "../../Include/RmlUi/Core/PropertyIdSet.h" +#include "../../../Include/RmlUi/Core/PropertyIdSet.h" namespace Rml { -namespace Controls { -ElementTextSelection::ElementTextSelection(const Rml::Core::String& tag) : Rml::Core::Element(tag) +ElementTextSelection::ElementTextSelection(const String& tag) : Element(tag) { widget = nullptr; } @@ -49,7 +48,7 @@ void ElementTextSelection::SetWidget(WidgetTextInput* _widget) } // Processes 'color' and 'background-color' property changes. -void ElementTextSelection::OnPropertyChange(const Rml::Core::PropertyIdSet& changed_properties) +void ElementTextSelection::OnPropertyChange(const PropertyIdSet& changed_properties) { Element::OnPropertyChange(changed_properties); @@ -57,12 +56,11 @@ void ElementTextSelection::OnPropertyChange(const Rml::Core::PropertyIdSet& chan return; // Check for a colour change. - if (changed_properties.Contains(Core::PropertyId::Color) || - changed_properties.Contains(Core::PropertyId::BackgroundColor)) + if (changed_properties.Contains(PropertyId::Color) || + changed_properties.Contains(PropertyId::BackgroundColor)) { widget->UpdateSelectionColours(); } } -} -} +} // namespace Rml diff --git a/Source/Controls/ElementTextSelection.h b/Source/Core/Elements/ElementTextSelection.h similarity index 82% rename from Source/Controls/ElementTextSelection.h rename to Source/Core/Elements/ElementTextSelection.h index 48d0932bc..3eb1bd18c 100644 --- a/Source/Controls/ElementTextSelection.h +++ b/Source/Core/Elements/ElementTextSelection.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSELEMENTTEXTSELECTION_H -#define RMLUICONTROLSELEMENTTEXTSELECTION_H +#ifndef RMLUI_CORE_ELEMENTS_ELEMENTTEXTSELECTION_H +#define RMLUI_CORE_ELEMENTS_ELEMENTTEXTSELECTION_H -#include "../../Include/RmlUi/Core/Element.h" +#include "../../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Controls { class WidgetTextInput; @@ -43,12 +42,12 @@ class WidgetTextInput; @author Peter Curry */ -class ElementTextSelection : public Core::Element +class ElementTextSelection : public Element { public: - RMLUI_RTTI_DefineWithParent(ElementTextSelection, Core::Element) + RMLUI_RTTI_DefineWithParent(ElementTextSelection, Element) - ElementTextSelection(const Rml::Core::String& tag); + ElementTextSelection(const String& tag); virtual ~ElementTextSelection(); /// Set the widget that this selection element was created for. This is the widget that will be @@ -57,13 +56,11 @@ class ElementTextSelection : public Core::Element protected: /// Processes 'color' and 'background-color' property changes. - void OnPropertyChange(const Rml::Core::PropertyIdSet& changed_properties) override; + void OnPropertyChange(const PropertyIdSet& changed_properties) override; private: WidgetTextInput* widget; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputType.cpp b/Source/Core/Elements/InputType.cpp similarity index 84% rename from Source/Controls/InputType.cpp rename to Source/Core/Elements/InputType.cpp index 9dd4a5380..ce69e6560 100644 --- a/Source/Controls/InputType.cpp +++ b/Source/Core/Elements/InputType.cpp @@ -27,10 +27,9 @@ */ #include "InputType.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" namespace Rml { -namespace Controls { InputType::InputType(ElementFormControlInput* element) : element(element) { @@ -41,9 +40,9 @@ InputType::~InputType() } // Returns a string representation of the current value of the form control. -Rml::Core::String InputType::GetValue() const +String InputType::GetValue() const { - return element->GetAttribute< Rml::Core::String >("value", ""); + return element->GetAttribute< String >("value", ""); } // Returns if this value should be submitted with the form. @@ -67,7 +66,7 @@ void InputType::OnResize() } // Checks for necessary functional changes in the control as a result of changed attributes. -bool InputType::OnAttributeChange(const Core::ElementAttributes& RMLUI_UNUSED_PARAMETER(changed_attributes)) +bool InputType::OnAttributeChange(const ElementAttributes& RMLUI_UNUSED_PARAMETER(changed_attributes)) { RMLUI_UNUSED(changed_attributes); @@ -75,7 +74,7 @@ bool InputType::OnAttributeChange(const Core::ElementAttributes& RMLUI_UNUSED_PA } // Called when properties on the control are changed. -void InputType::OnPropertyChange(const Core::PropertyIdSet& RMLUI_UNUSED_PARAMETER(changed_properties)) +void InputType::OnPropertyChange(const PropertyIdSet& RMLUI_UNUSED_PARAMETER(changed_properties)) { RMLUI_UNUSED(changed_properties); } @@ -90,5 +89,4 @@ void InputType::OnChildRemove() { } -} -} +} // namespace Rml diff --git a/Source/Controls/InputType.h b/Source/Core/Elements/InputType.h similarity index 85% rename from Source/Controls/InputType.h rename to Source/Core/Elements/InputType.h index 5a2be8a8b..3e95d0433 100644 --- a/Source/Controls/InputType.h +++ b/Source/Core/Elements/InputType.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPE_H -#define RMLUICONTROLSINPUTTYPE_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPE_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPE_H -#include "../../Include/RmlUi/Core/Event.h" -#include "../../Include/RmlUi/Core/Types.h" +#include "../../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Controls { class ElementFormControlInput; @@ -52,7 +51,7 @@ class InputType /// Returns a string representation of the current value of the form control. /// @return The value of the form control. - virtual Rml::Core::String GetValue() const; + virtual String GetValue() const; /// Returns if this value should be submitted with the form. /// @return True if the form control is to be submitted, false otherwise. virtual bool IsSubmitted(); @@ -69,10 +68,10 @@ class InputType /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. /// @return True if no layout is required, false if the layout needs to be dirtied. - virtual bool OnAttributeChange(const Core::ElementAttributes& changed_attributes); + virtual bool OnAttributeChange(const ElementAttributes& changed_attributes); /// Called when properties on the control are changed. /// @param[in] changed_properties The properties changed on the element. - virtual void OnPropertyChange(const Core::PropertyIdSet& changed_properties); + virtual void OnPropertyChange(const PropertyIdSet& changed_properties); /// Called when the element is added into a hierarchy. virtual void OnChildAdd(); @@ -81,17 +80,15 @@ class InputType /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - virtual void ProcessDefaultAction(Core::Event& event) = 0; + virtual void ProcessDefaultAction(Event& event) = 0; /// Sizes the dimensions to the element's inherent size. /// @return True. - virtual bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) = 0; + virtual bool GetIntrinsicDimensions(Vector2f& dimensions) = 0; protected: ElementFormControlInput* element; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeButton.cpp b/Source/Core/Elements/InputTypeButton.cpp similarity index 85% rename from Source/Controls/InputTypeButton.cpp rename to Source/Core/Elements/InputTypeButton.cpp index 19453f551..8b736618f 100644 --- a/Source/Controls/InputTypeButton.cpp +++ b/Source/Core/Elements/InputTypeButton.cpp @@ -27,11 +27,10 @@ */ #include "InputTypeButton.h" -#include "../../Include/RmlUi/Controls/ElementForm.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/Elements/ElementForm.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" namespace Rml { -namespace Controls { InputTypeButton::InputTypeButton(ElementFormControlInput* element) : InputType(element) { @@ -47,15 +46,14 @@ bool InputTypeButton::IsSubmitted() return false; } -void InputTypeButton::ProcessDefaultAction(Core::Event& /*event*/) +void InputTypeButton::ProcessDefaultAction(Event& /*event*/) { } // Sizes the dimensions to the element's inherent size. -bool InputTypeButton::GetIntrinsicDimensions(Rml::Core::Vector2f& /*dimensions*/) +bool InputTypeButton::GetIntrinsicDimensions(Vector2f& /*dimensions*/) { return false; } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeButton.h b/Source/Core/Elements/InputTypeButton.h similarity index 86% rename from Source/Controls/InputTypeButton.h rename to Source/Core/Elements/InputTypeButton.h index 23dfe09d1..1478bac83 100644 --- a/Source/Controls/InputTypeButton.h +++ b/Source/Core/Elements/InputTypeButton.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPEBUTTON_H -#define RMLUICONTROLSINPUTTYPEBUTTON_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPEBUTTON_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPEBUTTON_H -#include "../../Include/RmlUi/Core/EventListener.h" -#include "../../Include/RmlUi/Core/ElementDocument.h" +#include "../../../Include/RmlUi/Core/EventListener.h" +#include "../../../Include/RmlUi/Core/ElementDocument.h" #include "InputType.h" namespace Rml { -namespace Controls { /** A button input type handler. The only functionality a button provides over a normal element is the ability @@ -55,14 +54,12 @@ class InputTypeButton : public InputType /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return False. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeCheckbox.cpp b/Source/Core/Elements/InputTypeCheckbox.cpp similarity index 81% rename from Source/Controls/InputTypeCheckbox.cpp rename to Source/Core/Elements/InputTypeCheckbox.cpp index a84292920..1060c3dde 100644 --- a/Source/Controls/InputTypeCheckbox.cpp +++ b/Source/Core/Elements/InputTypeCheckbox.cpp @@ -27,10 +27,9 @@ */ #include "InputTypeCheckbox.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" namespace Rml { -namespace Controls { InputTypeCheckbox::InputTypeCheckbox(ElementFormControlInput* element) : InputType(element) { @@ -47,7 +46,7 @@ bool InputTypeCheckbox::IsSubmitted() } // Checks for necessary functional changes in the control as a result of changed attributes. -bool InputTypeCheckbox::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +bool InputTypeCheckbox::OnAttributeChange(const ElementAttributes& changed_attributes) { // Check if maxlength has been defined. if (changed_attributes.find("checked") != changed_attributes.end()) @@ -55,18 +54,18 @@ bool InputTypeCheckbox::OnAttributeChange(const Core::ElementAttributes& changed bool checked = element->HasAttribute("checked"); element->SetPseudoClass("checked", checked); - Rml::Core::Dictionary parameters; - parameters["value"] = Rml::Core::String(checked ? GetValue() : ""); - element->DispatchEvent(Core::EventId::Change, parameters); + Dictionary parameters; + parameters["value"] = String(checked ? GetValue() : ""); + element->DispatchEvent(EventId::Change, parameters); } return true; } // Checks for necessary functional changes in the control as a result of the event. -void InputTypeCheckbox::ProcessDefaultAction(Core::Event& event) +void InputTypeCheckbox::ProcessDefaultAction(Event& event) { - if (event == Core::EventId::Click && + if (event == EventId::Click && !element->IsDisabled()) { if (element->HasAttribute("checked")) @@ -77,7 +76,7 @@ void InputTypeCheckbox::ProcessDefaultAction(Core::Event& event) } // Sizes the dimensions to the element's inherent size. -bool InputTypeCheckbox::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool InputTypeCheckbox::GetIntrinsicDimensions(Vector2f& dimensions) { dimensions.x = 16; dimensions.y = 16; @@ -85,5 +84,4 @@ bool InputTypeCheckbox::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeCheckbox.h b/Source/Core/Elements/InputTypeCheckbox.h similarity index 87% rename from Source/Controls/InputTypeCheckbox.h rename to Source/Core/Elements/InputTypeCheckbox.h index f7f7577c8..abd17e016 100644 --- a/Source/Controls/InputTypeCheckbox.h +++ b/Source/Core/Elements/InputTypeCheckbox.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPECHECKBOX_H -#define RMLUICONTROLSINPUTTYPECHECKBOX_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPECHECKBOX_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPECHECKBOX_H #include "InputType.h" namespace Rml { -namespace Controls { /** A checkbox input type handler. @@ -53,18 +52,16 @@ class InputTypeCheckbox : public InputType /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. /// @return True if no layout is required, false if the layout needs to be dirtied. - bool OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + bool OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeRadio.cpp b/Source/Core/Elements/InputTypeRadio.cpp similarity index 78% rename from Source/Controls/InputTypeRadio.cpp rename to Source/Core/Elements/InputTypeRadio.cpp index 5e284e239..fb801d583 100644 --- a/Source/Controls/InputTypeRadio.cpp +++ b/Source/Core/Elements/InputTypeRadio.cpp @@ -27,12 +27,11 @@ */ #include "InputTypeRadio.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Controls/ElementForm.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/Elements/ElementForm.h" namespace Rml { -namespace Controls { InputTypeRadio::InputTypeRadio(ElementFormControlInput* element) : InputType(element) { @@ -51,7 +50,7 @@ bool InputTypeRadio::IsSubmitted() } // Checks for necessary functional changes in the control as a result of changed attributes. -bool InputTypeRadio::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +bool InputTypeRadio::OnAttributeChange(const ElementAttributes& changed_attributes) { // Check if maxlength has been defined. if (changed_attributes.find("checked") != changed_attributes.end()) @@ -62,9 +61,9 @@ bool InputTypeRadio::OnAttributeChange(const Core::ElementAttributes& changed_at if (checked) PopRadioSet(); - Rml::Core::Dictionary parameters; - parameters["value"] = Rml::Core::String(checked ? GetValue() : ""); - element->DispatchEvent(Core::EventId::Change, parameters); + Dictionary parameters; + parameters["value"] = String(checked ? GetValue() : ""); + element->DispatchEvent(EventId::Change, parameters); } return true; @@ -78,15 +77,15 @@ void InputTypeRadio::OnChildAdd() } // Checks for necessary functional changes in the control as a result of the event. -void InputTypeRadio::ProcessDefaultAction(Core::Event& event) +void InputTypeRadio::ProcessDefaultAction(Event& event) { - if (event == Core::EventId::Click && + if (event == EventId::Click && !element->IsDisabled()) element->SetAttribute("checked", ""); } // Sizes the dimensions to the element's inherent size. -bool InputTypeRadio::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool InputTypeRadio::GetIntrinsicDimensions(Vector2f& dimensions) { dimensions.x = 16; dimensions.y = 16; @@ -99,22 +98,22 @@ void InputTypeRadio::PopRadioSet() { // Uncheck all other radio buttons with our name in the form. ElementForm* form = nullptr; - Core::Element* parent = element->GetParentNode(); + Element* parent = element->GetParentNode(); while (parent != nullptr && (form = rmlui_dynamic_cast< ElementForm* >(parent)) == nullptr) parent = parent->GetParentNode(); if (form != nullptr) { - Core::ElementList form_controls; - Core::ElementUtilities::GetElementsByTagName(form_controls, form, "input"); + ElementList form_controls; + ElementUtilities::GetElementsByTagName(form_controls, form, "input"); for (size_t i = 0; i < form_controls.size(); ++i) { ElementFormControlInput* radio_control = rmlui_dynamic_cast< ElementFormControlInput* >(form_controls[i]); if (radio_control != nullptr && element != radio_control && - radio_control->GetAttribute< Rml::Core::String >("type", "text") == "radio" && + radio_control->GetAttribute< String >("type", "text") == "radio" && radio_control->GetName() == element->GetName()) { radio_control->RemoveAttribute("checked"); @@ -123,5 +122,4 @@ void InputTypeRadio::PopRadioSet() } } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeRadio.h b/Source/Core/Elements/InputTypeRadio.h similarity index 88% rename from Source/Controls/InputTypeRadio.h rename to Source/Core/Elements/InputTypeRadio.h index ee9393c8c..b97a4497c 100644 --- a/Source/Controls/InputTypeRadio.h +++ b/Source/Core/Elements/InputTypeRadio.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPERADIO_H -#define RMLUICONTROLSINPUTTYPERADIO_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPERADIO_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPERADIO_H #include "InputType.h" namespace Rml { -namespace Controls { /** A radio button input type handler. @@ -53,25 +52,23 @@ class InputTypeRadio : public InputType /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. /// @return True if no layout is required, false if the layout needs to be dirtied. - bool OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + bool OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Pops the element's radio set if we are checked. void OnChildAdd() override; /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; private: /// Pops all other radio buttons in our form that share our name. void PopRadioSet(); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeRange.cpp b/Source/Core/Elements/InputTypeRange.cpp similarity index 80% rename from Source/Controls/InputTypeRange.cpp rename to Source/Core/Elements/InputTypeRange.cpp index 676a6ffc0..a7651ca72 100644 --- a/Source/Controls/InputTypeRange.cpp +++ b/Source/Core/Elements/InputTypeRange.cpp @@ -27,15 +27,14 @@ */ #include "InputTypeRange.h" -#include "WidgetSliderInput.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" +#include "WidgetSlider.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" namespace Rml { -namespace Controls { InputTypeRange::InputTypeRange(ElementFormControlInput* element) : InputType(element) { - widget = new WidgetSliderInput(element); + widget = new WidgetSlider(element); widget->Initialise(); } @@ -45,9 +44,9 @@ InputTypeRange::~InputTypeRange() } // Returns a string representation of the current value of the form control. -Rml::Core::String InputTypeRange::GetValue() const +String InputTypeRange::GetValue() const { - return Rml::Core::CreateString(32, "%f", widget->GetValue()); + return CreateString(32, "%f", widget->GetValue()); } // Called every update from the host element. @@ -62,15 +61,15 @@ void InputTypeRange::OnResize() } // Checks for necessary functional changes in the control as a result of changed attributes. -bool InputTypeRange::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +bool InputTypeRange::OnAttributeChange(const ElementAttributes& changed_attributes) { bool dirty_layout = false; auto it_orientation = changed_attributes.find("orientation"); if (it_orientation != changed_attributes.end()) { - bool is_vertical = (it_orientation->second.Get() == "vertical"); - widget->SetOrientation(is_vertical ? WidgetSliderInput::VERTICAL : WidgetSliderInput::HORIZONTAL); + bool is_vertical = (it_orientation->second.Get() == "vertical"); + widget->SetOrientation(is_vertical ? WidgetSlider::VERTICAL : WidgetSlider::HORIZONTAL); dirty_layout = true; } @@ -94,16 +93,15 @@ bool InputTypeRange::OnAttributeChange(const Core::ElementAttributes& changed_at } // Checks for necessary functional changes in the control as a result of the event. -void InputTypeRange::ProcessDefaultAction(Core::Event& /*event*/) +void InputTypeRange::ProcessDefaultAction(Event& /*event*/) { } // Sizes the dimensions to the element's inherent size. -bool InputTypeRange::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool InputTypeRange::GetIntrinsicDimensions(Vector2f& dimensions) { widget->GetDimensions(dimensions); return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeRange.h b/Source/Core/Elements/InputTypeRange.h similarity index 84% rename from Source/Controls/InputTypeRange.h rename to Source/Core/Elements/InputTypeRange.h index 6d307b0f8..1722940c7 100644 --- a/Source/Controls/InputTypeRange.h +++ b/Source/Core/Elements/InputTypeRange.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPERANGE_H -#define RMLUICONTROLSINPUTTYPERANGE_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPERANGE_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPERANGE_H #include "InputType.h" namespace Rml { -namespace Controls { -class WidgetSliderInput; +class WidgetSlider; /** A range input type handler. @@ -50,7 +49,7 @@ class InputTypeRange : public InputType /// Returns a string representation of the current value of the form control. /// @return The value of the form control. - Rml::Core::String GetValue() const override; + String GetValue() const override; /// Called every update from the host element. void OnUpdate() override; @@ -61,21 +60,19 @@ class InputTypeRange : public InputType /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. /// @return True if no layout is required, false if the layout needs to be dirtied. - bool OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + bool OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; private: - WidgetSliderInput* widget; + WidgetSlider* widget; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeSubmit.cpp b/Source/Core/Elements/InputTypeSubmit.cpp similarity index 79% rename from Source/Controls/InputTypeSubmit.cpp rename to Source/Core/Elements/InputTypeSubmit.cpp index c9e4753dc..c4fdaca11 100644 --- a/Source/Controls/InputTypeSubmit.cpp +++ b/Source/Core/Elements/InputTypeSubmit.cpp @@ -27,11 +27,10 @@ */ #include "InputTypeSubmit.h" -#include "../../Include/RmlUi/Controls/ElementForm.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/Elements/ElementForm.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" namespace Rml { -namespace Controls { InputTypeSubmit::InputTypeSubmit(ElementFormControlInput* element) : InputType(element) { @@ -48,18 +47,18 @@ bool InputTypeSubmit::IsSubmitted() } // Checks for necessary functional changes in the control as a result of the event. -void InputTypeSubmit::ProcessDefaultAction(Core::Event& event) +void InputTypeSubmit::ProcessDefaultAction(Event& event) { - if (event == Core::EventId::Click && + if (event == EventId::Click && !element->IsDisabled()) { - Core::Element* parent = element->GetParentNode(); + Element* parent = element->GetParentNode(); while (parent) { ElementForm* form = rmlui_dynamic_cast< ElementForm* >(parent); if (form != nullptr) { - form->Submit(element->GetAttribute< Rml::Core::String >("name", ""), element->GetAttribute< Rml::Core::String >("value", "")); + form->Submit(element->GetAttribute< String >("name", ""), element->GetAttribute< String >("value", "")); return; } else @@ -71,12 +70,11 @@ void InputTypeSubmit::ProcessDefaultAction(Core::Event& event) } // Sizes the dimensions to the element's inherent size. -bool InputTypeSubmit::GetIntrinsicDimensions(Rml::Core::Vector2f& RMLUI_UNUSED_PARAMETER(dimensions)) +bool InputTypeSubmit::GetIntrinsicDimensions(Vector2f& RMLUI_UNUSED_PARAMETER(dimensions)) { RMLUI_UNUSED(dimensions); return false; } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeSubmit.h b/Source/Core/Elements/InputTypeSubmit.h similarity index 89% rename from Source/Controls/InputTypeSubmit.h rename to Source/Core/Elements/InputTypeSubmit.h index 69436ee73..38ca46833 100644 --- a/Source/Controls/InputTypeSubmit.h +++ b/Source/Core/Elements/InputTypeSubmit.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPESUBMIT_H -#define RMLUICONTROLSINPUTTYPESUBMIT_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPESUBMIT_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPESUBMIT_H #include "InputType.h" namespace Rml { -namespace Controls { /** A submit input type handler. @@ -52,14 +51,12 @@ class InputTypeSubmit : public InputType /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return False. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/InputTypeText.cpp b/Source/Core/Elements/InputTypeText.cpp similarity index 78% rename from Source/Controls/InputTypeText.cpp rename to Source/Core/Elements/InputTypeText.cpp index e3855d984..d7f32e36b 100644 --- a/Source/Controls/InputTypeText.cpp +++ b/Source/Core/Elements/InputTypeText.cpp @@ -27,14 +27,13 @@ */ #include "InputTypeText.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" #include "WidgetTextInputSingleLine.h" #include "WidgetTextInputSingleLinePassword.h" -#include "../../Include/RmlUi/Controls/ElementFormControlInput.h" -#include "../../Include/RmlUi/Core/PropertyIdSet.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" +#include "../../../Include/RmlUi/Core/PropertyIdSet.h" namespace Rml { -namespace Controls { InputTypeText::InputTypeText(ElementFormControlInput* element, Visibility visibility) : InputType(element) { @@ -44,7 +43,7 @@ InputTypeText::InputTypeText(ElementFormControlInput* element, Visibility visibi widget = new WidgetTextInputSingleLinePassword(element); widget->SetMaxLength(element->GetAttribute< int >("maxlength", -1)); - widget->SetValue(element->GetAttribute< Rml::Core::String >("value", "")); + widget->SetValue(element->GetAttribute< String >("value", "")); size = element->GetAttribute< int >("size", 20); } @@ -72,7 +71,7 @@ void InputTypeText::OnResize() } // Checks for necessary functional changes in the control as a result of changed attributes. -bool InputTypeText::OnAttributeChange(const Core::ElementAttributes& changed_attributes) +bool InputTypeText::OnAttributeChange(const ElementAttributes& changed_attributes) { bool dirty_layout = false; @@ -92,33 +91,32 @@ bool InputTypeText::OnAttributeChange(const Core::ElementAttributes& changed_att // Check if the value has been changed. it = changed_attributes.find("value"); if (it != changed_attributes.end()) - widget->SetValue(it->second.Get()); + widget->SetValue(it->second.Get()); return !dirty_layout; } // Called when properties on the control are changed. -void InputTypeText::OnPropertyChange(const Core::PropertyIdSet& changed_properties) +void InputTypeText::OnPropertyChange(const PropertyIdSet& changed_properties) { - if (changed_properties.Contains(Core::PropertyId::Color) || - changed_properties.Contains(Core::PropertyId::BackgroundColor)) + if (changed_properties.Contains(PropertyId::Color) || + changed_properties.Contains(PropertyId::BackgroundColor)) widget->UpdateSelectionColours(); } // Checks for necessary functional changes in the control as a result of the event. -void InputTypeText::ProcessDefaultAction(Core::Event& RMLUI_UNUSED_PARAMETER(event)) +void InputTypeText::ProcessDefaultAction(Event& RMLUI_UNUSED_PARAMETER(event)) { RMLUI_UNUSED(event); } // Sizes the dimensions to the element's inherent size. -bool InputTypeText::GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) +bool InputTypeText::GetIntrinsicDimensions(Vector2f& dimensions) { - dimensions.x = (float) (size * Core::ElementUtilities::GetStringWidth(element, "m")); + dimensions.x = (float) (size * ElementUtilities::GetStringWidth(element, "m")); dimensions.y = element->GetLineHeight() + 2.0f; return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/InputTypeText.h b/Source/Core/Elements/InputTypeText.h similarity index 86% rename from Source/Controls/InputTypeText.h rename to Source/Core/Elements/InputTypeText.h index e456075f3..95513a528 100644 --- a/Source/Controls/InputTypeText.h +++ b/Source/Core/Elements/InputTypeText.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSINPUTTYPETEXT_H -#define RMLUICONTROLSINPUTTYPETEXT_H +#ifndef RMLUI_CORE_ELEMENTS_INPUTTYPETEXT_H +#define RMLUI_CORE_ELEMENTS_INPUTTYPETEXT_H #include "InputType.h" namespace Rml { -namespace Controls { class WidgetTextInput; @@ -66,18 +65,18 @@ class InputTypeText : public InputType /// Checks for necessary functional changes in the control as a result of changed attributes. /// @param[in] changed_attributes The list of changed attributes. /// @return True if no layout is required, false if the layout needs to be dirtied. - bool OnAttributeChange(const Core::ElementAttributes& changed_attributes) override; + bool OnAttributeChange(const ElementAttributes& changed_attributes) override; /// Called when properties on the control are changed. /// @param[in] changed_properties The properties changed on the element. - void OnPropertyChange(const Core::PropertyIdSet& changed_properties) override; + void OnPropertyChange(const PropertyIdSet& changed_properties) override; /// Checks for necessary functional changes in the control as a result of the event. /// @param[in] event The event to process. - void ProcessDefaultAction(Core::Event& event) override; + void ProcessDefaultAction(Event& event) override; /// Sizes the dimensions to the element's inherent size. /// @return True. - bool GetIntrinsicDimensions(Rml::Core::Vector2f& dimensions) override; + bool GetIntrinsicDimensions(Vector2f& dimensions) override; private: int size; @@ -85,7 +84,5 @@ class InputTypeText : public InputType WidgetTextInput* widget; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/SelectOption.cpp b/Source/Core/Elements/SelectOption.cpp similarity index 83% rename from Source/Controls/SelectOption.cpp rename to Source/Core/Elements/SelectOption.cpp index 2ca0f3721..9c8978961 100644 --- a/Source/Controls/SelectOption.cpp +++ b/Source/Core/Elements/SelectOption.cpp @@ -26,12 +26,11 @@ * */ -#include "../../Include/RmlUi/Controls/SelectOption.h" +#include "../../../Include/RmlUi/Core/Elements/SelectOption.h" namespace Rml { -namespace Controls { -SelectOption::SelectOption(Core::Element* _element, const Rml::Core::String& value, bool selectable) : value(value) , selectable(selectable) +SelectOption::SelectOption(Element* _element, const String& value, bool selectable) : value(value) , selectable(selectable) { element = _element; } @@ -41,16 +40,15 @@ SelectOption::~SelectOption() } // Returns the element that represents the option visually. -Core::Element* SelectOption::GetElement() +Element* SelectOption::GetElement() { return element; } // Returns the value of the option. -const Rml::Core::String& SelectOption::GetValue() const +const String& SelectOption::GetValue() const { return value; } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetDropDown.cpp b/Source/Core/Elements/WidgetDropDown.cpp similarity index 60% rename from Source/Controls/WidgetDropDown.cpp rename to Source/Core/Elements/WidgetDropDown.cpp index 08edd13e1..11b58060e 100644 --- a/Source/Controls/WidgetDropDown.cpp +++ b/Source/Core/Elements/WidgetDropDown.cpp @@ -27,19 +27,18 @@ */ #include "WidgetDropDown.h" -#include "../../Include/RmlUi/Core/Context.h" -#include "../../Include/RmlUi/Core/ElementDocument.h" -#include "../../Include/RmlUi/Core/Math.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Core/Event.h" -#include "../../Include/RmlUi/Core/Input.h" -#include "../../Include/RmlUi/Core/Property.h" -#include "../../Include/RmlUi/Core/Profiling.h" -#include "../../Include/RmlUi/Controls/ElementFormControl.h" +#include "../../../Include/RmlUi/Core/Context.h" +#include "../../../Include/RmlUi/Core/ElementDocument.h" +#include "../../../Include/RmlUi/Core/Math.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/Event.h" +#include "../../../Include/RmlUi/Core/Input.h" +#include "../../../Include/RmlUi/Core/Property.h" +#include "../../../Include/RmlUi/Core/Profiling.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControl.h" namespace Rml { -namespace Controls { WidgetDropDown::WidgetDropDown(ElementFormControl* element) { @@ -52,24 +51,24 @@ WidgetDropDown::WidgetDropDown(ElementFormControl* element) selected_option = -1; // Create the button and selection elements. - button_element = parent_element->AppendChild(Core::Factory::InstanceElement(parent_element, "*", "selectarrow", Rml::Core::XMLAttributes()), false); - value_element = parent_element->AppendChild(Core::Factory::InstanceElement(parent_element, "*", "selectvalue", Rml::Core::XMLAttributes()), false); - selection_element = parent_element->AppendChild(Core::Factory::InstanceElement(parent_element, "*", "selectbox", Rml::Core::XMLAttributes()), false); + button_element = parent_element->AppendChild(Factory::InstanceElement(parent_element, "*", "selectarrow", XMLAttributes()), false); + value_element = parent_element->AppendChild(Factory::InstanceElement(parent_element, "*", "selectvalue", XMLAttributes()), false); + selection_element = parent_element->AppendChild(Factory::InstanceElement(parent_element, "*", "selectbox", XMLAttributes()), false); - value_element->SetProperty(Core::PropertyId::OverflowX, Core::Property(Core::Style::Overflow::Hidden)); - value_element->SetProperty(Core::PropertyId::OverflowY, Core::Property(Core::Style::Overflow::Hidden)); + value_element->SetProperty(PropertyId::OverflowX, Property(Style::Overflow::Hidden)); + value_element->SetProperty(PropertyId::OverflowY, Property(Style::Overflow::Hidden)); - selection_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); - selection_element->SetProperty(Core::PropertyId::ZIndex, Core::Property(1.0f, Core::Property::NUMBER)); - selection_element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::Type::None)); - selection_element->SetProperty(Core::PropertyId::OverflowY, Core::Property(Core::Style::Overflow::Auto)); + selection_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); + selection_element->SetProperty(PropertyId::ZIndex, Property(1.0f, Property::NUMBER)); + selection_element->SetProperty(PropertyId::Clip, Property(Style::Clip::Type::None)); + selection_element->SetProperty(PropertyId::OverflowY, Property(Style::Overflow::Auto)); - parent_element->AddEventListener(Core::EventId::Click, this, true); - parent_element->AddEventListener(Core::EventId::Blur, this); - parent_element->AddEventListener(Core::EventId::Focus, this); - parent_element->AddEventListener(Core::EventId::Keydown, this, true); + parent_element->AddEventListener(EventId::Click, this, true); + parent_element->AddEventListener(EventId::Blur, this); + parent_element->AddEventListener(EventId::Focus, this); + parent_element->AddEventListener(EventId::Keydown, this, true); - selection_element->AddEventListener(Core::EventId::Mousescroll, this); + selection_element->AddEventListener(EventId::Mousescroll, this); } WidgetDropDown::~WidgetDropDown() @@ -77,14 +76,14 @@ WidgetDropDown::~WidgetDropDown() // We shouldn't clear the options ourselves, as removing the element will automatically clear children. // However, we do need to remove events of children. for(auto& option : options) - option.GetElement()->RemoveEventListener(Core::EventId::Click, this); + option.GetElement()->RemoveEventListener(EventId::Click, this); - parent_element->RemoveEventListener(Core::EventId::Click, this, true); - parent_element->RemoveEventListener(Core::EventId::Blur, this); - parent_element->RemoveEventListener(Core::EventId::Focus, this); - parent_element->RemoveEventListener(Core::EventId::Keydown, this, true); + parent_element->RemoveEventListener(EventId::Click, this, true); + parent_element->RemoveEventListener(EventId::Blur, this); + parent_element->RemoveEventListener(EventId::Focus, this); + parent_element->RemoveEventListener(EventId::Keydown, this, true); - selection_element->RemoveEventListener(Core::EventId::Mousescroll, this); + selection_element->RemoveEventListener(EventId::Mousescroll, this); DetachScrollEvent(); } @@ -100,36 +99,35 @@ void WidgetDropDown::OnRender() // the element's height. // We try to respect user values of 'height', 'min-height', and 'max-height'. However, when we need to shrink the box // we will override the 'height' property. - using Rml::Core::Vector2f; // Previously set 'height' property from this procedure must be removed for the calculations below to work as intended. - if(selection_element->GetLocalStyleProperties().count(Core::PropertyId::Height) == 1) + if(selection_element->GetLocalStyleProperties().count(PropertyId::Height) == 1) { - selection_element->RemoveProperty(Core::PropertyId::Height); + selection_element->RemoveProperty(PropertyId::Height); selection_element->GetOwnerDocument()->UpdateDocument(); } - Core::Box box; - Core::ElementUtilities::BuildBox(box, parent_element->GetBox().GetSize(), selection_element); + Box box; + ElementUtilities::BuildBox(box, parent_element->GetBox().GetSize(), selection_element); // The user can use 'margin-left/top/bottom' to offset the box away from the 'select' element, respectively // horizontally, vertically when box below, and vertically when box above. - const float offset_x = box.GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - const float offset_y_below = parent_element->GetBox().GetSize(Core::Box::BORDER).y + box.GetEdge(Core::Box::MARGIN, Core::Box::TOP); - const float offset_y_above = -box.GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM); + const float offset_x = box.GetEdge(Box::MARGIN, Box::LEFT); + const float offset_y_below = parent_element->GetBox().GetSize(Box::BORDER).y + box.GetEdge(Box::MARGIN, Box::TOP); + const float offset_y_above = -box.GetEdge(Box::MARGIN, Box::BOTTOM); float window_height = 100'000.f; - if (Core::Context* context = parent_element->GetContext()) + if (Context* context = parent_element->GetContext()) window_height = float(context->GetDimensions().y); - const float absolute_y = parent_element->GetAbsoluteOffset(Rml::Core::Box::BORDER).y; + const float absolute_y = parent_element->GetAbsoluteOffset(Box::BORDER).y; const float height_below = window_height - absolute_y - offset_y_below; const float height_above = absolute_y + offset_y_above; // Format the selection box and retrieve the 'native' height occupied by all the options, while respecting // the 'min/max-height' properties. - Core::ElementUtilities::FormatElement(selection_element, parent_element->GetBox().GetSize(Core::Box::BORDER)); + ElementUtilities::FormatElement(selection_element, parent_element->GetBox().GetSize(Box::BORDER)); const float content_height = selection_element->GetOffsetHeight(); if (content_height < height_below) @@ -146,8 +144,8 @@ void WidgetDropDown::OnRender() { // Shrink box and position either below or above const float padding_border_size = - box.GetEdge(Core::Box::BORDER, Core::Box::TOP) + box.GetEdge(Core::Box::BORDER, Core::Box::BOTTOM) + - box.GetEdge(Core::Box::PADDING, Core::Box::TOP) + box.GetEdge(Core::Box::PADDING, Core::Box::BOTTOM); + box.GetEdge(Box::BORDER, Box::TOP) + box.GetEdge(Box::BORDER, Box::BOTTOM) + + box.GetEdge(Box::PADDING, Box::TOP) + box.GetEdge(Box::PADDING, Box::BOTTOM); float height = 0.f; float offset_y = 0.f; @@ -166,9 +164,9 @@ void WidgetDropDown::OnRender() } // Set the height and re-format the selection box. - selection_element->SetProperty(Core::PropertyId::Height, Core::Property(height, Core::Property::PX)); + selection_element->SetProperty(PropertyId::Height, Property(height, Property::PX)); selection_element->GetOwnerDocument()->UpdateDocument(); - Core::ElementUtilities::FormatElement(selection_element, parent_element->GetBox().GetSize(Core::Box::BORDER)); + ElementUtilities::FormatElement(selection_element, parent_element->GetBox().GetSize(Box::BORDER)); selection_element->SetOffset(Vector2f(offset_x, offset_y), parent_element); } @@ -178,8 +176,8 @@ void WidgetDropDown::OnRender() if (value_layout_dirty) { - Core::ElementUtilities::FormatElement(value_element, parent_element->GetBox().GetSize(Core::Box::BORDER)); - value_element->SetOffset(parent_element->GetBox().GetPosition(Core::Box::CONTENT), parent_element); + ElementUtilities::FormatElement(value_element, parent_element->GetBox().GetSize(Box::BORDER)); + value_element->SetOffset(parent_element->GetBox().GetPosition(Box::CONTENT), parent_element); value_layout_dirty = false; } @@ -197,25 +195,25 @@ void WidgetDropDown::OnLayout() } // Layout the button and selection boxes. - Core::Box parent_box = parent_element->GetBox(); + Box parent_box = parent_element->GetBox(); - Core::ElementUtilities::PositionElement(button_element, Rml::Core::Vector2f(0, 0), Core::ElementUtilities::TOP_RIGHT); - Core::ElementUtilities::PositionElement(selection_element, Rml::Core::Vector2f(0, 0), Core::ElementUtilities::TOP_LEFT); + ElementUtilities::PositionElement(button_element, Vector2f(0, 0), ElementUtilities::TOP_RIGHT); + ElementUtilities::PositionElement(selection_element, Vector2f(0, 0), ElementUtilities::TOP_LEFT); // Calculate the value element position and size. - Rml::Core::Vector2f size; - size.x = parent_element->GetBox().GetSize(Core::Box::CONTENT).x - button_element->GetBox().GetSize(Core::Box::MARGIN).x; - size.y = parent_element->GetBox().GetSize(Core::Box::CONTENT).y; + Vector2f size; + size.x = parent_element->GetBox().GetSize(Box::CONTENT).x - button_element->GetBox().GetSize(Box::MARGIN).x; + size.y = parent_element->GetBox().GetSize(Box::CONTENT).y; - value_element->SetOffset(parent_element->GetBox().GetPosition(Core::Box::CONTENT), parent_element); - value_element->SetBox(Core::Box(size)); + value_element->SetOffset(parent_element->GetBox().GetPosition(Box::CONTENT), parent_element); + value_element->SetBox(Box(size)); box_layout_dirty = true; value_layout_dirty = true; } // Sets the value of the widget. -void WidgetDropDown::SetValue(const Rml::Core::String& _value) +void WidgetDropDown::SetValue(const String& _value) { for (size_t i = 0; i < options.size(); ++i) { @@ -237,7 +235,7 @@ void WidgetDropDown::SetValue(const Rml::Core::String& _value) } // Returns the current value of the widget. -const Rml::Core::String& WidgetDropDown::GetValue() const +const String& WidgetDropDown::GetValue() const { return value; } @@ -245,7 +243,7 @@ const Rml::Core::String& WidgetDropDown::GetValue() const // Sets the index of the selection. If the new index lies outside of the bounds, it will be clamped. void WidgetDropDown::SetSelection(int selection, bool force) { - Rml::Core::String new_value; + String new_value; if (selection < 0 || selection >= (int) options.size()) @@ -267,7 +265,7 @@ void WidgetDropDown::SetSelection(int selection, bool force) selected_option = selection; value = new_value; - Rml::Core::String value_rml; + String value_rml; if (selected_option >= 0) { auto* el = options[selected_option].GetElement(); @@ -279,9 +277,9 @@ void WidgetDropDown::SetSelection(int selection, bool force) value_element->SetInnerRML(value_rml); value_layout_dirty = true; - Rml::Core::Dictionary parameters; + Dictionary parameters; parameters["value"] = value; - parent_element->DispatchEvent(Core::EventId::Change, parameters); + parent_element->DispatchEvent(EventId::Change, parameters); } } @@ -292,9 +290,9 @@ int WidgetDropDown::GetSelection() const } // Adds a new option to the select control. -int WidgetDropDown::AddOption(const Rml::Core::String& rml, const Rml::Core::String& new_value, int before, bool select, bool selectable) +int WidgetDropDown::AddOption(const String& rml, const String& new_value, int before, bool select, bool selectable) { - Core::ElementPtr element = Core::Factory::InstanceElement(selection_element, "*", "option", Rml::Core::XMLAttributes()); + ElementPtr element = Factory::InstanceElement(selection_element, "*", "option", XMLAttributes()); element->SetInnerRML(rml); int result = AddOption(std::move(element), new_value, before, select, selectable); @@ -302,31 +300,31 @@ int WidgetDropDown::AddOption(const Rml::Core::String& rml, const Rml::Core::Str return result; } -int WidgetDropDown::AddOption(Rml::Core::ElementPtr element, const Rml::Core::String& new_value, int before, bool select, bool selectable) +int WidgetDropDown::AddOption(ElementPtr element, const String& new_value, int before, bool select, bool selectable) { - static const Core::String str_option = "option"; + static const String str_option = "option"; if (element->GetTagName() != str_option) { - Core::Log::Message(Core::Log::LT_WARNING, "A child of '%s' must be of type 'option' but '%s' was given. See element '%s'.", parent_element->GetTagName().c_str(), element->GetTagName().c_str(), parent_element->GetAddress().c_str()); + Log::Message(Log::LT_WARNING, "A child of '%s' must be of type 'option' but '%s' was given. See element '%s'.", parent_element->GetTagName().c_str(), element->GetTagName().c_str(), parent_element->GetAddress().c_str()); return -1; } // Force to block display. Register a click handler so we can be notified of selection. - element->SetProperty(Core::PropertyId::Display, Core::Property(Core::Style::Display::Block)); - element->SetProperty(Core::PropertyId::Clip, Core::Property(Core::Style::Clip::Type::Auto)); - element->AddEventListener(Core::EventId::Click, this); + element->SetProperty(PropertyId::Display, Property(Style::Display::Block)); + element->SetProperty(PropertyId::Clip, Property(Style::Clip::Type::Auto)); + element->AddEventListener(EventId::Click, this); int option_index; if (before < 0 || before >= (int)options.size()) { - Core::Element* ptr = selection_element->AppendChild(std::move(element)); + Element* ptr = selection_element->AppendChild(std::move(element)); options.push_back(SelectOption(ptr, new_value, selectable)); option_index = (int)options.size() - 1; } else { - Core::Element* ptr = selection_element->InsertBefore(std::move(element), selection_element->GetChild(before)); + Element* ptr = selection_element->InsertBefore(std::move(element), selection_element->GetChild(before)); options.insert(options.begin() + before, SelectOption(ptr, new_value, selectable)); option_index = before; } @@ -347,7 +345,7 @@ void WidgetDropDown::RemoveOption(int index) return; // Remove the listener and delete the option element. - options[index].GetElement()->RemoveEventListener(Core::EventId::Click, this); + options[index].GetElement()->RemoveEventListener(EventId::Click, this); selection_element->RemoveChild(options[index].GetElement()); options.erase(options.begin() + index); @@ -379,17 +377,17 @@ int WidgetDropDown::GetNumOptions() const void WidgetDropDown::AttachScrollEvent() { - if (Core::ElementDocument* document = parent_element->GetOwnerDocument()) - document->AddEventListener(Core::EventId::Scroll, this, true); + if (ElementDocument* document = parent_element->GetOwnerDocument()) + document->AddEventListener(EventId::Scroll, this, true); } void WidgetDropDown::DetachScrollEvent() { - if (Core::ElementDocument* document = parent_element->GetOwnerDocument()) - document->RemoveEventListener(Core::EventId::Scroll, this, true); + if (ElementDocument* document = parent_element->GetOwnerDocument()) + document->RemoveEventListener(EventId::Scroll, this, true); } -void WidgetDropDown::ProcessEvent(Core::Event& event) +void WidgetDropDown::ProcessEvent(Event& event) { if (parent_element->IsDisabled()) return; @@ -397,7 +395,7 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) // Process the button onclick switch (event.GetId()) { - case Core::EventId::Click: + case EventId::Click: { if (event.GetCurrentElement()->GetParentNode() == selection_element) @@ -424,7 +422,7 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) // inside the selection box as we'll get all events coming from our // root level select element as well as the ones coming from options (which // get caught in the above if) - Core::Element* element = event.GetTargetElement(); + Element* element = event.GetTargetElement(); while (element && element != parent_element) { if (element == selection_element) @@ -432,14 +430,14 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) element = element->GetParentNode(); } - if (selection_element->GetComputedValues().visibility == Core::Style::Visibility::Hidden) + if (selection_element->GetComputedValues().visibility == Style::Visibility::Hidden) ShowSelectBox(true); else ShowSelectBox(false); } } break; - case Core::EventId::Focus: + case EventId::Focus: { if (event.GetTargetElement() == parent_element) { @@ -448,7 +446,7 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) } } break; - case Core::EventId::Blur: + case EventId::Blur: { if (event.GetTargetElement() == parent_element) { @@ -458,16 +456,16 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) } } break; - case Core::EventId::Keydown: + case EventId::Keydown: { - Core::Input::KeyIdentifier key_identifier = (Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Input::KeyIdentifier key_identifier = (Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); switch (key_identifier) { - case Core::Input::KI_UP: + case Input::KI_UP: SetSelection((selected_option - 1 + (int)options.size()) % (int)options.size()); break; - case Core::Input::KI_DOWN: + case Input::KI_DOWN: SetSelection((selected_option + 1) % (int)options.size()); break; default: @@ -475,7 +473,7 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) } } break; - case Core::EventId::Mousescroll: + case EventId::Mousescroll: { if (event.GetCurrentElement() == selection_element) { @@ -487,14 +485,14 @@ void WidgetDropDown::ProcessEvent(Core::Event& event) } } break; - case Core::EventId::Scroll: + case EventId::Scroll: { if (box_visible) { // Close the select box if we scroll outside the select box. bool scrolls_selection_box = false; - for (Core::Element* element = event.GetTargetElement(); element; element = element->GetParentNode()) + for (Element* element = event.GetTargetElement(); element; element = element->GetParentNode()) { if (element == selection_element) { @@ -518,7 +516,7 @@ void WidgetDropDown::ShowSelectBox(bool show) { if (show) { - selection_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + selection_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); value_element->SetPseudoClass("checked", true); button_element->SetPseudoClass("checked", true); box_layout_dirty = true; @@ -526,8 +524,8 @@ void WidgetDropDown::ShowSelectBox(bool show) } else { - selection_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); - selection_element->RemoveProperty(Core::PropertyId::Height); + selection_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); + selection_element->RemoveProperty(PropertyId::Height); value_element->SetPseudoClass("checked", false); button_element->SetPseudoClass("checked", false); DetachScrollEvent(); @@ -535,5 +533,4 @@ void WidgetDropDown::ShowSelectBox(bool show) box_visible = show; } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetDropDown.h b/Source/Core/Elements/WidgetDropDown.h similarity index 84% rename from Source/Controls/WidgetDropDown.h rename to Source/Core/Elements/WidgetDropDown.h index 7eb57b6c5..033ffa6a5 100644 --- a/Source/Controls/WidgetDropDown.h +++ b/Source/Core/Elements/WidgetDropDown.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICONTROLSWIDGETDROPDOWN_H -#define RMLUICONTROLSWIDGETDROPDOWN_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETDROPDOWN_H +#define RMLUI_CORE_ELEMENTS_WIDGETDROPDOWN_H -#include "../../Include/RmlUi/Core/EventListener.h" -#include "../../Include/RmlUi/Controls/SelectOption.h" +#include "../../../Include/RmlUi/Core/EventListener.h" +#include "../../../Include/RmlUi/Core/Elements/SelectOption.h" #include namespace Rml { -namespace Controls { class ElementFormControl; @@ -43,7 +42,7 @@ class ElementFormControl; @author Lloyd Weehuizen */ -class WidgetDropDown : public Core::EventListener +class WidgetDropDown : public EventListener { public: WidgetDropDown(ElementFormControl* element); @@ -56,10 +55,10 @@ class WidgetDropDown : public Core::EventListener /// Sets the value of the widget. /// @param[in] value The new value to set. - void SetValue(const Rml::Core::String& value); + void SetValue(const String& value); /// Returns the current value of the widget. /// @return The current value of the widget. - const Rml::Core::String& GetValue() const; + const String& GetValue() const; /// Sets the index of the selection. If the new index lies outside of the bounds, the selection index will be set to -1. /// @param[in] selection The new selection index. @@ -76,7 +75,7 @@ class WidgetDropDown : public Core::EventListener /// @param[in] select True to select the new option. /// @param[in] selectable If true this option can be selected. If false, this option is not selectable. /// @return The index of the new option. - int AddOption(const Rml::Core::String& rml, const Rml::Core::String& value, int before, bool select, bool selectable = true); + int AddOption(const String& rml, const String& value, int before, bool select, bool selectable = true); /// Moves an option element to the select control. /// @param[in] element Element to move. /// @param[in] value The value of the option. @@ -84,7 +83,7 @@ class WidgetDropDown : public Core::EventListener /// @param[in] select True to select the new option. /// @param[in] selectable If true this option can be selected. If false, this option is not selectable. /// @return The index of the new option, or -1 if invalid. - int AddOption(Rml::Core::ElementPtr element, const Rml::Core::String& value, int before, bool select, bool selectable); + int AddOption(ElementPtr element, const String& value, int before, bool select, bool selectable); /// Removes an option from the select control. /// @param[in] index The index of the option to remove. void RemoveOption(int index); @@ -100,7 +99,7 @@ class WidgetDropDown : public Core::EventListener int GetNumOptions() const; /// Processes the incoming event. - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; private: typedef std::vector< SelectOption > OptionList; @@ -115,23 +114,21 @@ class WidgetDropDown : public Core::EventListener ElementFormControl* parent_element; // The elements making up the drop-down process. - Core::Element* button_element; - Core::Element* selection_element; - Core::Element* value_element; + Element* button_element; + Element* selection_element; + Element* value_element; // The options in the drop down. OptionList options; int selected_option; // The current value of the widget. - Rml::Core::String value; + String value; bool box_layout_dirty; bool value_layout_dirty; bool box_visible; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/WidgetSlider.cpp b/Source/Core/Elements/WidgetSlider.cpp similarity index 58% rename from Source/Controls/WidgetSlider.cpp rename to Source/Core/Elements/WidgetSlider.cpp index 47c8b6c2f..6d5bf8b1c 100644 --- a/Source/Controls/WidgetSlider.cpp +++ b/Source/Core/Elements/WidgetSlider.cpp @@ -27,14 +27,14 @@ */ #include "WidgetSlider.h" -#include "../../Include/RmlUi/Controls/ElementFormControl.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/Input.h" -#include "../Core/Clock.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControl.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/Input.h" +#include "../../../Include/RmlUi/Core/Profiling.h" +#include "../Clock.h" namespace Rml { -namespace Controls { static const float DEFAULT_REPEAT_DELAY = 0.5f; static const float DEFAULT_REPEAT_PERIOD = 0.1f; @@ -56,6 +56,11 @@ WidgetSlider::WidgetSlider(ElementFormControl* _parent) arrow_timers[0] = -1; arrow_timers[1] = -1; last_update_time = 0; + + value = 0; + min_value = 0; + max_value = 100; + step = 1; } WidgetSlider::~WidgetSlider() @@ -70,7 +75,6 @@ WidgetSlider::~WidgetSlider() parent->RemoveChild(track); } - using Core::EventId; parent->RemoveEventListener(EventId::Blur, this); parent->RemoveEventListener(EventId::Focus, this); parent->RemoveEventListener(EventId::Keydown, this, true); @@ -93,14 +97,14 @@ WidgetSlider::~WidgetSlider() // Initialises the slider to a given orientation. bool WidgetSlider::Initialise() { - Core::Property drag_property = Core::Property(Core::Style::Drag::Drag); - parent->SetProperty(Core::PropertyId::Drag, drag_property); + Property drag_property = Property(Style::Drag::Drag); + parent->SetProperty(PropertyId::Drag, drag_property); // Create all of our child elements as standard elements, and abort if we can't create them. - Core::ElementPtr track_element = Core::Factory::InstanceElement(parent, "*", "slidertrack", Core::XMLAttributes()); - Core::ElementPtr bar_element = Core::Factory::InstanceElement(parent, "*", "sliderbar", Core::XMLAttributes()); - Core::ElementPtr arrow0_element = Core::Factory::InstanceElement(parent, "*", "sliderarrowdec", Core::XMLAttributes()); - Core::ElementPtr arrow1_element = Core::Factory::InstanceElement(parent, "*", "sliderarrowinc", Core::XMLAttributes()); + ElementPtr track_element = Factory::InstanceElement(parent, "*", "slidertrack", XMLAttributes()); + ElementPtr bar_element = Factory::InstanceElement(parent, "*", "sliderbar", XMLAttributes()); + ElementPtr arrow0_element = Factory::InstanceElement(parent, "*", "sliderarrowdec", XMLAttributes()); + ElementPtr arrow1_element = Factory::InstanceElement(parent, "*", "sliderarrowinc", XMLAttributes()); if (!track_element || !bar_element || !arrow0_element || !arrow1_element) { @@ -113,12 +117,11 @@ bool WidgetSlider::Initialise() arrows[0] = parent->AppendChild(std::move(arrow0_element), false); arrows[1] = parent->AppendChild(std::move(arrow1_element), false); - arrows[0]->SetProperty(Core::PropertyId::Drag, drag_property); - arrows[1]->SetProperty(Core::PropertyId::Drag, drag_property); + arrows[0]->SetProperty(PropertyId::Drag, drag_property); + arrows[1]->SetProperty(PropertyId::Drag, drag_property); // Attach the listeners // All listeners are attached to parent, ensuring that we don't get duplicate events when it bubbles from child to parent - using Core::EventId; parent->AddEventListener(EventId::Blur, this); parent->AddEventListener(EventId::Focus, this); parent->AddEventListener(EventId::Keydown, this, true); @@ -144,7 +147,7 @@ void WidgetSlider::Update() { if (!updated_time) { - double current_time = Core::Clock::GetElapsedTime(); + double current_time = Clock::GetElapsedTime(); delta_time = float(current_time - last_update_time); last_update_time = current_time; } @@ -162,7 +165,7 @@ void WidgetSlider::Update() // Sets the position of the bar. void WidgetSlider::SetBarPosition(float _bar_position) { - bar_position = Rml::Core::Math::Clamp(_bar_position, 0.0f, 1.0f); + bar_position = Math::Clamp(_bar_position, 0.0f, 1.0f); PositionBar(); } @@ -185,7 +188,7 @@ WidgetSlider::Orientation WidgetSlider::GetOrientation() const } // Sets the dimensions to the size of the slider. -void WidgetSlider::GetDimensions(Rml::Core::Vector2f& dimensions) const +void WidgetSlider::GetDimensions(Vector2f& dimensions) const { switch (orientation) { @@ -194,27 +197,74 @@ void WidgetSlider::GetDimensions(Rml::Core::Vector2f& dimensions) const } } + +void WidgetSlider::SetValue(float target_value) +{ + float num_steps = (target_value - min_value) / step; + float new_value = min_value + Math::RoundFloat(num_steps) * step; + + if (new_value != value) + SetBarPosition(SetValueInternal(new_value)); +} + +float WidgetSlider::GetValue() const +{ + return value; +} + +// Sets the minimum value of the slider. +void WidgetSlider::SetMinValue(float _min_value) +{ + min_value = _min_value; +} + +// Sets the maximum value of the slider. +void WidgetSlider::SetMaxValue(float _max_value) +{ + max_value = _max_value; +} + +// Sets the slider's value increment. +void WidgetSlider::SetStep(float _step) +{ + // Can't have a zero step! + if (_step == 0) + return; + + step = _step; +} + +// Formats the slider's elements. +void WidgetSlider::FormatElements() +{ + RMLUI_ZoneScopedNC("RangeOnResize", 0x228044); + + Vector2f box = GetParent()->GetBox().GetSize(); + WidgetSlider::FormatElements(box, GetOrientation() == VERTICAL ? box.y : box.x); +} + + // Lays out and resizes the internal elements. -void WidgetSlider::FormatElements(const Rml::Core::Vector2f& containing_block, float slider_length, float bar_length) +void WidgetSlider::FormatElements(const Vector2f& containing_block, float slider_length, float bar_length) { int length_axis = orientation == VERTICAL ? 1 : 0; // Build the box for the containing slider element. As the containing block is not guaranteed to have a defined // height, we must use the width for both axes. - Core::Box parent_box; - Core::ElementUtilities::BuildBox(parent_box, Rml::Core::Vector2f(containing_block.x, containing_block.x), parent); + Box parent_box; + ElementUtilities::BuildBox(parent_box, Vector2f(containing_block.x, containing_block.x), parent); // Set the length of the slider. - Rml::Core::Vector2f content = parent_box.GetSize(); + Vector2f content = parent_box.GetSize(); content[length_axis] = slider_length; parent_box.SetContent(content); // Generate the initial dimensions for the track. It'll need to be cut down to fit the arrows. - Core::Box track_box; - Core::ElementUtilities::BuildBox(track_box, parent_box.GetSize(), track); + Box track_box; + ElementUtilities::BuildBox(track_box, parent_box.GetSize(), track); content = track_box.GetSize(); - content[length_axis] = slider_length -= orientation == VERTICAL ? (track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::TOP) + track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::BOTTOM)) : - (track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::LEFT) + track_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::RIGHT)); + content[length_axis] = slider_length -= orientation == VERTICAL ? (track_box.GetCumulativeEdge(Box::CONTENT, Box::TOP) + track_box.GetCumulativeEdge(Box::CONTENT, Box::BOTTOM)) : + (track_box.GetCumulativeEdge(Box::CONTENT, Box::LEFT) + track_box.GetCumulativeEdge(Box::CONTENT, Box::RIGHT)); // If no height has been explicitly specified for the track, it'll be initialised to -1 as per normal block // elements. We'll fix that up here. if (orientation == HORIZONTAL && @@ -224,19 +274,19 @@ void WidgetSlider::FormatElements(const Rml::Core::Vector2f& containing_block, f // Now we size the arrows. for (int i = 0; i < 2; i++) { - Core::Box arrow_box; - Core::ElementUtilities::BuildBox(arrow_box, parent_box.GetSize(), arrows[i]); + Box arrow_box; + ElementUtilities::BuildBox(arrow_box, parent_box.GetSize(), arrows[i]); // Clamp the size to (0, 0). - Rml::Core::Vector2f arrow_size = arrow_box.GetSize(); + Vector2f arrow_size = arrow_box.GetSize(); if (arrow_size.x < 0 || arrow_size.y < 0) - arrow_box.SetContent(Rml::Core::Vector2f(0, 0)); + arrow_box.SetContent(Vector2f(0, 0)); arrows[i]->SetBox(arrow_box); // Shrink the track length by the arrow size. - content[length_axis] -= arrow_box.GetSize(Core::Box::MARGIN)[length_axis]; + content[length_axis] -= arrow_box.GetSize(Box::MARGIN)[length_axis]; } // Now the track has been sized, we can fix everything into position. @@ -245,28 +295,28 @@ void WidgetSlider::FormatElements(const Rml::Core::Vector2f& containing_block, f if (orientation == VERTICAL) { - Rml::Core::Vector2f offset(arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP)); + Vector2f offset(arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::LEFT), arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::TOP)); arrows[0]->SetOffset(offset, parent); - offset.x = track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - offset.y += arrows[0]->GetBox().GetSize(Core::Box::BORDER).y + arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM) + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); + offset.x = track->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + offset.y += arrows[0]->GetBox().GetSize(Box::BORDER).y + arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM) + track->GetBox().GetEdge(Box::MARGIN, Box::TOP); track->SetOffset(offset, parent); - offset.x = arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - offset.y += track->GetBox().GetSize(Core::Box::BORDER).y + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM) + arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); + offset.x = arrows[1]->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + offset.y += track->GetBox().GetSize(Box::BORDER).y + track->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM) + arrows[1]->GetBox().GetEdge(Box::MARGIN, Box::TOP); arrows[1]->SetOffset(offset, parent); } else { - Rml::Core::Vector2f offset(arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP)); + Vector2f offset(arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::LEFT), arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::TOP)); arrows[0]->SetOffset(offset, parent); - offset.x += arrows[0]->GetBox().GetSize(Core::Box::BORDER).x + arrows[0]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT) + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - offset.y = track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); + offset.x += arrows[0]->GetBox().GetSize(Box::BORDER).x + arrows[0]->GetBox().GetEdge(Box::MARGIN, Box::RIGHT) + track->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + offset.y = track->GetBox().GetEdge(Box::MARGIN, Box::TOP); track->SetOffset(offset, parent); - offset.x += track->GetBox().GetSize(Core::Box::BORDER).x + track->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT) + arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - offset.y = arrows[1]->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); + offset.x += track->GetBox().GetSize(Box::BORDER).x + track->GetBox().GetEdge(Box::MARGIN, Box::RIGHT) + arrows[1]->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + offset.y = arrows[1]->GetBox().GetEdge(Box::MARGIN, Box::TOP); arrows[1]->SetOffset(offset, parent); } @@ -285,62 +335,62 @@ void WidgetSlider::FormatElements(const Rml::Core::Vector2f& containing_block, f // Lays out and positions the bar element. void WidgetSlider::FormatBar(float bar_length) { - Core::Box bar_box; - Core::ElementUtilities::BuildBox(bar_box, parent->GetBox().GetSize(), bar); + Box bar_box; + ElementUtilities::BuildBox(bar_box, parent->GetBox().GetSize(), bar); auto& computed = bar->GetComputedValues(); - Rml::Core::Vector2f bar_box_content = bar_box.GetSize(); + Vector2f bar_box_content = bar_box.GetSize(); if (orientation == HORIZONTAL) { - if (computed.height.type == Core::Style::Height::Auto) + if (computed.height.type == Style::Height::Auto) bar_box_content.y = parent->GetBox().GetSize().y; } if (bar_length >= 0) { - Rml::Core::Vector2f track_size = track->GetBox().GetSize(); + Vector2f track_size = track->GetBox().GetSize(); if (orientation == VERTICAL) { - float track_length = track_size.y - (bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::TOP) + bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::BOTTOM)); + float track_length = track_size.y - (bar_box.GetCumulativeEdge(Box::CONTENT, Box::TOP) + bar_box.GetCumulativeEdge(Box::CONTENT, Box::BOTTOM)); - if (computed.height.type == Core::Style::Height::Auto) + if (computed.height.type == Style::Height::Auto) { bar_box_content.y = track_length * bar_length; // Check for 'min-height' restrictions. - float min_track_length = Core::ResolveValue(computed.min_height, track_length); - bar_box_content.y = Rml::Core::Math::Max(min_track_length, bar_box_content.y); + float min_track_length = ResolveValue(computed.min_height, track_length); + bar_box_content.y = Math::Max(min_track_length, bar_box_content.y); // Check for 'max-height' restrictions. - float max_track_length = Core::ResolveValue(computed.max_height, track_length); + float max_track_length = ResolveValue(computed.max_height, track_length); if (max_track_length > 0) - bar_box_content.y = Rml::Core::Math::Min(max_track_length, bar_box_content.y); + bar_box_content.y = Math::Min(max_track_length, bar_box_content.y); } // Make sure we haven't gone further than we're allowed to (min-height may have made us too big). - bar_box_content.y = Rml::Core::Math::Min(bar_box_content.y, track_length); + bar_box_content.y = Math::Min(bar_box_content.y, track_length); } else { - float track_length = track_size.x - (bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::LEFT) + bar_box.GetCumulativeEdge(Core::Box::CONTENT, Core::Box::RIGHT)); + float track_length = track_size.x - (bar_box.GetCumulativeEdge(Box::CONTENT, Box::LEFT) + bar_box.GetCumulativeEdge(Box::CONTENT, Box::RIGHT)); - if (computed.width.type == Core::Style::Width::Auto) + if (computed.width.type == Style::Width::Auto) { bar_box_content.x = track_length * bar_length; // Check for 'min-width' restrictions. - float min_track_length = Core::ResolveValue(computed.min_width, track_length); - bar_box_content.x = Rml::Core::Math::Max(min_track_length, bar_box_content.x); + float min_track_length = ResolveValue(computed.min_width, track_length); + bar_box_content.x = Math::Max(min_track_length, bar_box_content.x); // Check for 'max-width' restrictions. - float max_track_length = Core::ResolveValue(computed.max_width, track_length); + float max_track_length = ResolveValue(computed.max_width, track_length); if (max_track_length > 0) - bar_box_content.x = Rml::Core::Math::Min(max_track_length, bar_box_content.x); + bar_box_content.x = Math::Min(max_track_length, bar_box_content.x); } // Make sure we haven't gone further than we're allowed to (min-width may have made us too big). - bar_box_content.x = Rml::Core::Math::Min(bar_box_content.x, track_length); + bar_box_content.x = Math::Min(bar_box_content.x, track_length); } } @@ -353,19 +403,17 @@ void WidgetSlider::FormatBar(float bar_length) } // Returns the widget's parent element. -Core::Element* WidgetSlider::GetParent() const +Element* WidgetSlider::GetParent() const { return parent; } // Handles events coming through from the slider's components. -void WidgetSlider::ProcessEvent(Core::Event& event) +void WidgetSlider::ProcessEvent(Event& event) { if (parent->IsDisabled()) return; - using Rml::Core::EventId; - switch (event.GetId()) { case EventId::Mousedown: @@ -377,12 +425,12 @@ void WidgetSlider::ProcessEvent(Core::Event& event) if (orientation == HORIZONTAL) { mouse_position = event.GetParameter< float >("mouse_x", 0); - bar_halfsize = 0.5f * bar->GetBox().GetSize(Core::Box::BORDER).x; + bar_halfsize = 0.5f * bar->GetBox().GetSize(Box::BORDER).x; } else { mouse_position = event.GetParameter< float >("mouse_y", 0); - bar_halfsize = 0.5f * bar->GetBox().GetSize(Core::Box::BORDER).y; + bar_halfsize = 0.5f * bar->GetBox().GetSize(Box::BORDER).y; } float new_bar_position = AbsolutePositionToBarPosition(mouse_position - bar_halfsize); @@ -391,13 +439,13 @@ void WidgetSlider::ProcessEvent(Core::Event& event) else if (event.GetTargetElement() == arrows[0]) { arrow_timers[0] = DEFAULT_REPEAT_DELAY; - last_update_time = Core::Clock::GetElapsedTime(); + last_update_time = Clock::GetElapsedTime(); SetBarPosition(OnLineDecrement()); } else if (event.GetTargetElement() == arrows[1]) { arrow_timers[1] = DEFAULT_REPEAT_DELAY; - last_update_time = Core::Clock::GetElapsedTime(); + last_update_time = Clock::GetElapsedTime(); SetBarPosition(OnLineIncrement()); } } @@ -449,20 +497,20 @@ void WidgetSlider::ProcessEvent(Core::Event& event) case EventId::Keydown: { - Core::Input::KeyIdentifier key_identifier = (Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Input::KeyIdentifier key_identifier = (Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); switch (key_identifier) { - case Core::Input::KI_LEFT: + case Input::KI_LEFT: if (orientation == HORIZONTAL) SetBarPosition(OnLineDecrement()); break; - case Core::Input::KI_UP: + case Input::KI_UP: if (orientation == VERTICAL) SetBarPosition(OnLineDecrement()); break; - case Core::Input::KI_RIGHT: + case Input::KI_RIGHT: if (orientation == HORIZONTAL) SetBarPosition(OnLineIncrement()); break; - case Core::Input::KI_DOWN: + case Input::KI_DOWN: if (orientation == VERTICAL) SetBarPosition(OnLineIncrement()); break; default: @@ -489,6 +537,26 @@ void WidgetSlider::ProcessEvent(Core::Event& event) } } +// Called when the slider's bar position is set or dragged. +float WidgetSlider::OnBarChange(float bar_position) +{ + float new_value = min_value + bar_position * (max_value - min_value); + int num_steps = Math::RoundToInteger((new_value - value) / step); + + return SetValueInternal(value + num_steps * step); +} + +// Called when the slider is incremented by one 'line'. +float WidgetSlider::OnLineIncrement() +{ + return SetValueInternal(value + step); +} + +// Called when the slider is decremented by one 'line'. +float WidgetSlider::OnLineDecrement() +{ + return SetValueInternal(value - step); +} float WidgetSlider::AbsolutePositionToBarPosition(float absolute_position) const { @@ -496,28 +564,28 @@ float WidgetSlider::AbsolutePositionToBarPosition(float absolute_position) const if (orientation == HORIZONTAL) { - const float edge_left = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - const float edge_right = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT); + const float edge_left = bar->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + const float edge_right = bar->GetBox().GetEdge(Box::MARGIN, Box::RIGHT); - float traversable_track_length = track->GetBox().GetSize(Core::Box::CONTENT).x - bar->GetBox().GetSize(Core::Box::BORDER).x - edge_left - edge_right; + float traversable_track_length = track->GetBox().GetSize(Box::CONTENT).x - bar->GetBox().GetSize(Box::BORDER).x - edge_left - edge_right; if (traversable_track_length > 0) { float traversable_track_origin = track->GetAbsoluteOffset().x + edge_left; new_bar_position = (absolute_position - traversable_track_origin) / traversable_track_length; - new_bar_position = Rml::Core::Math::Clamp(new_bar_position, 0.0f, 1.0f); + new_bar_position = Math::Clamp(new_bar_position, 0.0f, 1.0f); } } else { - const float edge_top = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); - const float edge_bottom = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM); + const float edge_top = bar->GetBox().GetEdge(Box::MARGIN, Box::TOP); + const float edge_bottom = bar->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM); - float traversable_track_length = track->GetBox().GetSize(Core::Box::CONTENT).y - bar->GetBox().GetSize(Core::Box::BORDER).y - edge_top - edge_bottom; + float traversable_track_length = track->GetBox().GetSize(Box::CONTENT).y - bar->GetBox().GetSize(Box::BORDER).y - edge_top - edge_bottom; if (traversable_track_length > 0) { float traversable_track_origin = track->GetAbsoluteOffset().y + edge_top; new_bar_position = (absolute_position - traversable_track_origin) / traversable_track_length; - new_bar_position = Rml::Core::Math::Clamp(new_bar_position, 0.0f, 1.0f); + new_bar_position = Math::Clamp(new_bar_position, 0.0f, 1.0f); } } @@ -527,18 +595,18 @@ float WidgetSlider::AbsolutePositionToBarPosition(float absolute_position) const void WidgetSlider::PositionBar() { - const Rml::Core::Vector2f track_dimensions = track->GetBox().GetSize(); - const Rml::Core::Vector2f bar_dimensions = bar->GetBox().GetSize(Core::Box::BORDER); + const Vector2f track_dimensions = track->GetBox().GetSize(); + const Vector2f bar_dimensions = bar->GetBox().GetSize(Box::BORDER); if (orientation == VERTICAL) { - const float edge_top = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP); - const float edge_bottom = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::BOTTOM); + const float edge_top = bar->GetBox().GetEdge(Box::MARGIN, Box::TOP); + const float edge_bottom = bar->GetBox().GetEdge(Box::MARGIN, Box::BOTTOM); float traversable_track_length = track_dimensions.y - bar_dimensions.y - edge_top - edge_bottom; bar->SetOffset( - Core::Vector2f( - bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT), + Vector2f( + bar->GetBox().GetEdge(Box::MARGIN, Box::LEFT), track->GetRelativeOffset().y + edge_top + traversable_track_length * bar_position ), parent @@ -546,19 +614,47 @@ void WidgetSlider::PositionBar() } else { - const float edge_left = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::LEFT); - const float edge_right = bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::RIGHT); + const float edge_left = bar->GetBox().GetEdge(Box::MARGIN, Box::LEFT); + const float edge_right = bar->GetBox().GetEdge(Box::MARGIN, Box::RIGHT); float traversable_track_length = track_dimensions.x - bar_dimensions.x - edge_left - edge_right; bar->SetOffset( - Core::Vector2f( + Vector2f( track->GetRelativeOffset().x + edge_left + traversable_track_length * bar_position, - bar->GetBox().GetEdge(Core::Box::MARGIN, Core::Box::TOP) + bar->GetBox().GetEdge(Box::MARGIN, Box::TOP) ), parent ); } } +// Clamps the new value, sets it on the slider. +float WidgetSlider::SetValueInternal(float new_value) +{ + if (min_value < max_value) + { + value = Math::Clamp(new_value, min_value, max_value); + } + else if (min_value > max_value) + { + value = Math::Clamp(new_value, max_value, min_value); + } + else + { + value = min_value; + return 0; + } + + Dictionary parameters; + parameters["value"] = value; + GetParent()->DispatchEvent(EventId::Change, parameters); + + + // TODO: This might not be the safest approach as this will call SetValue(), + // thus, a slight mismatch will result in infinite recursion. + GetParent()->SetAttribute("value", value); + + return (value - min_value) / (max_value - min_value); } -} + +} // namespace Rml diff --git a/Source/Controls/WidgetSlider.h b/Source/Core/Elements/WidgetSlider.h similarity index 76% rename from Source/Controls/WidgetSlider.h rename to Source/Core/Elements/WidgetSlider.h index fec716fd1..faf3904c1 100644 --- a/Source/Controls/WidgetSlider.h +++ b/Source/Core/Elements/WidgetSlider.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSWIDGETSLIDER_H -#define RMLUICONTROLSWIDGETSLIDER_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETSLIDER_H +#define RMLUI_CORE_ELEMENTS_WIDGETSLIDER_H -#include "../../Include/RmlUi/Core/EventListener.h" +#include "../../../Include/RmlUi/Core/EventListener.h" namespace Rml { -namespace Controls { class ElementFormControl; @@ -42,7 +41,7 @@ class ElementFormControl; @author Peter Curry */ -class WidgetSlider : public Core::EventListener +class WidgetSlider final : public EventListener { public: enum Orientation @@ -68,46 +67,57 @@ class WidgetSlider : public Core::EventListener float GetBarPosition(); /// Sets the orientation of the slider. - /// @param[in] orientation The slider's new orientation. void SetOrientation(Orientation orientation); /// Returns the slider's orientation. - /// @return The orientation of the slider. Orientation GetOrientation() const; /// Sets the dimensions to the size of the slider. - /// @param[in] dimensions The dimensions to size. - void GetDimensions(Rml::Core::Vector2f& dimensions) const; + void GetDimensions(Vector2f& dimensions) const; -protected: + /// Sets a new value on the slider, clamped to the min and max values, and rounded to the nearest increment. + void SetValue(float value); + /// Returns the current value of the slider. + float GetValue() const; + + /// Sets the minimum value of the slider. + void SetMinValue(float min_value); + /// Sets the maximum value of the slider. + void SetMaxValue(float max_value); + /// Sets the slider's value increment. + void SetStep(float step); + + /// Formats the slider's elements. + void FormatElements(); + +private: /// Lays out and resizes the slider's internal elements. /// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties. /// @param[in] slider_length The total length, in pixels, of the slider widget. /// @param[in] bar_length The total length of the bar, as a proportion of the track length. If this is -1, the intrinsic length will be used. - void FormatElements(const Rml::Core::Vector2f& containing_block, float slider_length, float bar_length = -1); + void FormatElements(const Vector2f& containing_block, float slider_length, float bar_length = -1); /// Lays out and positions the bar element. /// @param[in] bar_length The total length of the bar, as a proportion of the track length. If this is -1, the intrinsic length will be used. void FormatBar(float bar_length = -1); /// Returns the widget's parent element. - Core::Element* GetParent() const; + Element* GetParent() const; /// Handles events coming through from the slider's components. - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; /// Called when the slider's bar position is set or dragged. /// @param[in] bar_position The new position of the bar (0 representing the start of the track, 1 representing the end). /// @return The new position of the bar. - virtual float OnBarChange(float bar_position) = 0; + float OnBarChange(float bar_position); /// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the /// increment arrow. /// @return The new position of the bar. - virtual float OnLineIncrement() = 0; + float OnLineIncrement(); /// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the /// decrement arrow. /// @return The new position of the bar. - virtual float OnLineDecrement() = 0; + float OnLineDecrement(); -private: /// Determine the normalized bar position given an absolute position coordinate. /// @param[in] absolute_position Absolute position along the axis determined by 'orientation'. /// @return The normalized bar position [0, 1] @@ -115,16 +125,22 @@ class WidgetSlider : public Core::EventListener void PositionBar(); + /// Clamps the new value, sets it on the slider and returns it as a number from 0 to 1, 0 being the minimum + /// value and 1 the maximum. + /// @param[in] new_value The new value to set on the slider. + /// @return The new parametric value of the slider. + float SetValueInternal(float new_value); + ElementFormControl* parent; Orientation orientation; // The background track element, across which the bar slides. - Core::Element* track; + Element* track; // The bar element. This is the element that is dragged across the trough. - Core::Element* bar; + Element* bar; // The two (optional) buttons for incrementing and decrementing the slider. - Core::Element* arrows[2]; + Element* arrows[2]; // A number from 0 to 1, indicating how far along the track the bar is. float bar_position; @@ -134,9 +150,13 @@ class WidgetSlider : public Core::EventListener // Set to the auto-repeat timer if either of the arrow buttons have been pressed, -1 if they haven't. float arrow_timers[2]; double last_update_time; -}; -} -} + float value; + float min_value; + float max_value; + + float step; +}; +} // namespace Rml #endif diff --git a/Source/Controls/WidgetTextInput.cpp b/Source/Core/Elements/WidgetTextInput.cpp similarity index 72% rename from Source/Controls/WidgetTextInput.cpp rename to Source/Core/Elements/WidgetTextInput.cpp index 64da16319..73b69162f 100644 --- a/Source/Controls/WidgetTextInput.cpp +++ b/Source/Core/Elements/WidgetTextInput.cpp @@ -28,22 +28,21 @@ #include "WidgetTextInput.h" #include "ElementTextSelection.h" -#include "../../Include/RmlUi/Controls/ElementFormControl.h" -#include "../../Include/RmlUi/Core/Core.h" -#include "../../Include/RmlUi/Core/ElementScroll.h" -#include "../../Include/RmlUi/Core/ElementText.h" -#include "../../Include/RmlUi/Core/ElementUtilities.h" -#include "../../Include/RmlUi/Core/GeometryUtilities.h" -#include "../../Include/RmlUi/Core/Input.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/SystemInterface.h" -#include "../../Include/RmlUi/Core/StringUtilities.h" -#include "../Core/Clock.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControl.h" +#include "../../../Include/RmlUi/Core/Core.h" +#include "../../../Include/RmlUi/Core/ElementScroll.h" +#include "../../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/ElementUtilities.h" +#include "../../../Include/RmlUi/Core/GeometryUtilities.h" +#include "../../../Include/RmlUi/Core/Input.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/SystemInterface.h" +#include "../../../Include/RmlUi/Core/StringUtilities.h" +#include "../Clock.h" #include #include namespace Rml { -namespace Controls { static constexpr float CURSOR_BLINK_TIME = 0.7f; @@ -56,24 +55,24 @@ WidgetTextInput::WidgetTextInput(ElementFormControl* _parent) : internal_dimensi keyboard_showed = false; parent = _parent; - parent->SetProperty(Core::PropertyId::WhiteSpace, Core::Property(Core::Style::WhiteSpace::Pre)); - parent->SetProperty(Core::PropertyId::OverflowX, Core::Property(Core::Style::Overflow::Hidden)); - parent->SetProperty(Core::PropertyId::OverflowY, Core::Property(Core::Style::Overflow::Hidden)); - parent->SetProperty(Core::PropertyId::Drag, Core::Property(Core::Style::Drag::Drag)); - parent->SetClientArea(Rml::Core::Box::CONTENT); - - parent->AddEventListener(Core::EventId::Keydown, this, true); - parent->AddEventListener(Core::EventId::Textinput, this, true); - parent->AddEventListener(Core::EventId::Focus, this, true); - parent->AddEventListener(Core::EventId::Blur, this, true); - parent->AddEventListener(Core::EventId::Mousedown, this, true); - parent->AddEventListener(Core::EventId::Dblclick, this, true); - parent->AddEventListener(Core::EventId::Drag, this, true); - - Core::ElementPtr unique_text = Core::Factory::InstanceElement(parent, "#text", "#text", Rml::Core::XMLAttributes()); - text_element = rmlui_dynamic_cast< Core::ElementText* >(unique_text.get()); - Core::ElementPtr unique_selected_text = Core::Factory::InstanceElement(parent, "#text", "#text", Rml::Core::XMLAttributes()); - selected_text_element = rmlui_dynamic_cast< Core::ElementText* >(unique_selected_text.get()); + parent->SetProperty(PropertyId::WhiteSpace, Property(Style::WhiteSpace::Pre)); + parent->SetProperty(PropertyId::OverflowX, Property(Style::Overflow::Hidden)); + parent->SetProperty(PropertyId::OverflowY, Property(Style::Overflow::Hidden)); + parent->SetProperty(PropertyId::Drag, Property(Style::Drag::Drag)); + parent->SetClientArea(Box::CONTENT); + + parent->AddEventListener(EventId::Keydown, this, true); + parent->AddEventListener(EventId::Textinput, this, true); + parent->AddEventListener(EventId::Focus, this, true); + parent->AddEventListener(EventId::Blur, this, true); + parent->AddEventListener(EventId::Mousedown, this, true); + parent->AddEventListener(EventId::Dblclick, this, true); + parent->AddEventListener(EventId::Drag, this, true); + + ElementPtr unique_text = Factory::InstanceElement(parent, "#text", "#text", XMLAttributes()); + text_element = rmlui_dynamic_cast< ElementText* >(unique_text.get()); + ElementPtr unique_selected_text = Factory::InstanceElement(parent, "#text", "#text", XMLAttributes()); + selected_text_element = rmlui_dynamic_cast< ElementText* >(unique_selected_text.get()); if (text_element) { text_element->SuppressAutoLayout(); @@ -84,7 +83,7 @@ WidgetTextInput::WidgetTextInput(ElementFormControl* _parent) : internal_dimensi } // Create the dummy selection element. - Core::ElementPtr unique_selection = Core::Factory::InstanceElement(parent, "#selection", "selection", Rml::Core::XMLAttributes()); + ElementPtr unique_selection = Factory::InstanceElement(parent, "#selection", "selection", XMLAttributes()); if (ElementTextSelection* text_selection_element = rmlui_dynamic_cast(unique_selection.get())) { selection_element = text_selection_element; @@ -114,13 +113,13 @@ WidgetTextInput::WidgetTextInput(ElementFormControl* _parent) : internal_dimensi WidgetTextInput::~WidgetTextInput() { - parent->RemoveEventListener(Core::EventId::Keydown, this, true); - parent->RemoveEventListener(Core::EventId::Textinput, this, true); - parent->RemoveEventListener(Core::EventId::Focus, this, true); - parent->RemoveEventListener(Core::EventId::Blur, this, true); - parent->RemoveEventListener(Core::EventId::Mousedown, this, true); - parent->RemoveEventListener(Core::EventId::Dblclick, this, true); - parent->RemoveEventListener(Core::EventId::Drag, this, true); + parent->RemoveEventListener(EventId::Keydown, this, true); + parent->RemoveEventListener(EventId::Textinput, this, true); + parent->RemoveEventListener(EventId::Focus, this, true); + parent->RemoveEventListener(EventId::Blur, this, true); + parent->RemoveEventListener(EventId::Mousedown, this, true); + parent->RemoveEventListener(EventId::Dblclick, this, true); + parent->RemoveEventListener(EventId::Drag, this, true); // Remove all the children added by the text widget. parent->RemoveChild(text_element); @@ -129,7 +128,7 @@ WidgetTextInput::~WidgetTextInput() } // Sets the value of the text field. -void WidgetTextInput::SetValue(const Core::String& value) +void WidgetTextInput::SetValue(const String& value) { text_element->SetText(value); FormatElement(); @@ -145,12 +144,12 @@ void WidgetTextInput::SetMaxLength(int _max_length) max_length = _max_length; if (max_length >= 0) { - Core::String value = GetElement()->GetAttribute< Rml::Core::String >("value", ""); + String value = GetElement()->GetAttribute< String >("value", ""); int num_characters = 0; size_t i_erase = value.size(); - for (auto it = Core::StringIteratorU8(value); it; ++it) + for (auto it = StringIteratorU8(value); it; ++it) { num_characters += 1; if (num_characters > max_length) @@ -177,8 +176,8 @@ int WidgetTextInput::GetMaxLength() const int WidgetTextInput::GetLength() const { - Core::String value = GetElement()->GetAttribute< Core::String >("value", ""); - size_t result = Core::StringUtilities::LengthUTF8(value); + String value = GetElement()->GetAttribute< String >("value", ""); + size_t result = StringUtilities::LengthUTF8(value); return (int)result; } @@ -187,10 +186,10 @@ void WidgetTextInput::UpdateSelectionColours() { // Determine what the colour of the selected text is. If our 'selection' element has the 'color' // attribute set, then use that. Otherwise, use the inverse of our own text colour. - Rml::Core::Colourb colour; - const Rml::Core::Property* colour_property = selection_element->GetLocalProperty("color"); + Colourb colour; + const Property* colour_property = selection_element->GetLocalProperty("color"); if (colour_property != nullptr) - colour = colour_property->Get< Rml::Core::Colourb >(); + colour = colour_property->Get< Colourb >(); else { colour = parent->GetComputedValues().color; @@ -200,16 +199,16 @@ void WidgetTextInput::UpdateSelectionColours() } // Set the computed text colour on the element holding the selected text. - selected_text_element->SetProperty(Core::PropertyId::Color, Rml::Core::Property(colour, Rml::Core::Property::COLOUR)); + selected_text_element->SetProperty(PropertyId::Color, Property(colour, Property::COLOUR)); // If the 'background-color' property has been set on the 'selection' element, use that as the // background colour for the selected text. Otherwise, use the inverse of the selected text // colour. colour_property = selection_element->GetLocalProperty("background-color"); if (colour_property != nullptr) - selection_colour = colour_property->Get< Rml::Core::Colourb >(); + selection_colour = colour_property->Get< Colourb >(); else - selection_colour = Rml::Core::Colourb(255 - colour.red, 255 - colour.green, 255 - colour.blue, colour.alpha); + selection_colour = Colourb(255 - colour.red, 255 - colour.green, 255 - colour.blue, colour.alpha); } // Updates the cursor, if necessary. @@ -217,7 +216,7 @@ void WidgetTextInput::OnUpdate() { if (cursor_timer > 0) { - double current_time = Core::Clock::GetElapsedTime(); + double current_time = Clock::GetElapsedTime(); cursor_timer -= float(current_time - last_update_time); last_update_time = current_time; @@ -233,11 +232,11 @@ void WidgetTextInput::OnResize() { GenerateCursor(); - Rml::Core::Vector2f text_position = parent->GetBox().GetPosition(Core::Box::CONTENT); + Vector2f text_position = parent->GetBox().GetPosition(Box::CONTENT); text_element->SetOffset(text_position, parent); selected_text_element->SetOffset(text_position, parent); - Rml::Core::Vector2f new_internal_dimensions = parent->GetBox().GetSize(Core::Box::CONTENT); + Vector2f new_internal_dimensions = parent->GetBox().GetSize(Box::CONTENT); if (new_internal_dimensions != internal_dimensions) { internal_dimensions = new_internal_dimensions; @@ -250,9 +249,9 @@ void WidgetTextInput::OnResize() // Renders the cursor, if it is visible. void WidgetTextInput::OnRender() { - Core::ElementUtilities::SetClippingRegion(text_element); + ElementUtilities::SetClippingRegion(text_element); - Rml::Core::Vector2f text_translation = parent->GetAbsoluteOffset() - Rml::Core::Vector2f(parent->GetScrollLeft(), parent->GetScrollTop()); + Vector2f text_translation = parent->GetAbsoluteOffset() - Vector2f(parent->GetScrollLeft(), parent->GetScrollTop()); selection_geometry.Render(text_translation); if (cursor_visible && @@ -271,19 +270,19 @@ void WidgetTextInput::OnLayout() } // Returns the input element's underlying text element. -Core::ElementText* WidgetTextInput::GetTextElement() +ElementText* WidgetTextInput::GetTextElement() { return text_element; } // Returns the input element's maximum allowed text dimensions. -const Rml::Core::Vector2f& WidgetTextInput::GetTextDimensions() const +const Vector2f& WidgetTextInput::GetTextDimensions() const { return internal_dimensions; } // Gets the parent element containing the widget. -Core::Element* WidgetTextInput::GetElement() const +Element* WidgetTextInput::GetElement() const { return parent; } @@ -291,57 +290,55 @@ Core::Element* WidgetTextInput::GetElement() const // Dispatches a change event to the widget's element. void WidgetTextInput::DispatchChangeEvent(bool linebreak) { - Rml::Core::Dictionary parameters; - parameters["value"] = GetElement()->GetAttribute< Rml::Core::String >("value", ""); - parameters["linebreak"] = Core::Variant(linebreak); - GetElement()->DispatchEvent(Core::EventId::Change, parameters); + Dictionary parameters; + parameters["value"] = GetElement()->GetAttribute< String >("value", ""); + parameters["linebreak"] = Variant(linebreak); + GetElement()->DispatchEvent(EventId::Change, parameters); } // Processes the "keydown" and "textinput" event to write to the input field, and the "focus" and "blur" to set // the state of the cursor. -void WidgetTextInput::ProcessEvent(Core::Event& event) +void WidgetTextInput::ProcessEvent(Event& event) { if (parent->IsDisabled()) return; - using Rml::Core::EventId; - switch (event.GetId()) { case EventId::Keydown: { - Core::Input::KeyIdentifier key_identifier = (Core::Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); + Input::KeyIdentifier key_identifier = (Input::KeyIdentifier) event.GetParameter< int >("key_identifier", 0); bool numlock = event.GetParameter< int >("num_lock_key", 0) > 0; bool shift = event.GetParameter< int >("shift_key", 0) > 0; bool ctrl = event.GetParameter< int >("ctrl_key", 0) > 0; switch (key_identifier) { - case Core::Input::KI_NUMPAD4: if (numlock) break; //-fallthrough - case Core::Input::KI_LEFT: MoveCursorHorizontal(ctrl ? CursorMovement::PreviousWord : CursorMovement::Left, shift); break; + case Input::KI_NUMPAD4: if (numlock) break; //-fallthrough + case Input::KI_LEFT: MoveCursorHorizontal(ctrl ? CursorMovement::PreviousWord : CursorMovement::Left, shift); break; - case Core::Input::KI_NUMPAD6: if (numlock) break; //-fallthrough - case Core::Input::KI_RIGHT: MoveCursorHorizontal(ctrl ? CursorMovement::NextWord : CursorMovement::Right, shift); break; + case Input::KI_NUMPAD6: if (numlock) break; //-fallthrough + case Input::KI_RIGHT: MoveCursorHorizontal(ctrl ? CursorMovement::NextWord : CursorMovement::Right, shift); break; - case Core::Input::KI_NUMPAD8: if (numlock) break; //-fallthrough - case Core::Input::KI_UP: MoveCursorVertical(-1, shift); break; + case Input::KI_NUMPAD8: if (numlock) break; //-fallthrough + case Input::KI_UP: MoveCursorVertical(-1, shift); break; - case Core::Input::KI_NUMPAD2: if (numlock) break; //-fallthrough - case Core::Input::KI_DOWN: MoveCursorVertical(1, shift); break; + case Input::KI_NUMPAD2: if (numlock) break; //-fallthrough + case Input::KI_DOWN: MoveCursorVertical(1, shift); break; - case Core::Input::KI_NUMPAD7: if (numlock) break; //-fallthrough - case Core::Input::KI_HOME: MoveCursorHorizontal(ctrl ? CursorMovement::Begin : CursorMovement::BeginLine, shift); break; + case Input::KI_NUMPAD7: if (numlock) break; //-fallthrough + case Input::KI_HOME: MoveCursorHorizontal(ctrl ? CursorMovement::Begin : CursorMovement::BeginLine, shift); break; - case Core::Input::KI_NUMPAD1: if (numlock) break; //-fallthrough - case Core::Input::KI_END: MoveCursorHorizontal(ctrl ? CursorMovement::End : CursorMovement::EndLine, shift); break; + case Input::KI_NUMPAD1: if (numlock) break; //-fallthrough + case Input::KI_END: MoveCursorHorizontal(ctrl ? CursorMovement::End : CursorMovement::EndLine, shift); break; - case Core::Input::KI_NUMPAD3: if (numlock) break; //-fallthrough - case Core::Input::KI_PRIOR: MoveCursorVertical(-int(internal_dimensions.y / parent->GetLineHeight()) + 1, shift); break; + case Input::KI_NUMPAD3: if (numlock) break; //-fallthrough + case Input::KI_PRIOR: MoveCursorVertical(-int(internal_dimensions.y / parent->GetLineHeight()) + 1, shift); break; - case Core::Input::KI_NUMPAD9: if (numlock) break; //-fallthrough - case Core::Input::KI_NEXT: MoveCursorVertical(int(internal_dimensions.y / parent->GetLineHeight()) - 1, shift); break; + case Input::KI_NUMPAD9: if (numlock) break; //-fallthrough + case Input::KI_NEXT: MoveCursorVertical(int(internal_dimensions.y / parent->GetLineHeight()) - 1, shift); break; - case Core::Input::KI_BACK: + case Input::KI_BACK: { CursorMovement direction = (ctrl ? CursorMovement::PreviousWord : CursorMovement::Left); if (DeleteCharacters(direction)) @@ -354,8 +351,8 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) } break; - case Core::Input::KI_DECIMAL: if (numlock) break; //-fallthrough - case Core::Input::KI_DELETE: + case Input::KI_DECIMAL: if (numlock) break; //-fallthrough + case Input::KI_DELETE: { CursorMovement direction = (ctrl ? CursorMovement::NextWord : CursorMovement::Right); if (DeleteCharacters(direction)) @@ -368,14 +365,14 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) } break; - case Core::Input::KI_NUMPADENTER: - case Core::Input::KI_RETURN: + case Input::KI_NUMPADENTER: + case Input::KI_RETURN: { LineBreak(); } break; - case Core::Input::KI_A: + case Input::KI_A: { if (ctrl) { @@ -385,14 +382,14 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) } break; - case Core::Input::KI_C: + case Input::KI_C: { if (ctrl) CopySelection(); } break; - case Core::Input::KI_X: + case Input::KI_X: { if (ctrl) { @@ -402,12 +399,12 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) } break; - case Core::Input::KI_V: + case Input::KI_V: { if (ctrl) { - Core::String clipboard_text; - Core::GetSystemInterface()->GetClipboardText(clipboard_text); + String clipboard_text; + GetSystemInterface()->GetClipboardText(clipboard_text); AddCharacters(clipboard_text); } @@ -415,7 +412,7 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) break; // Ignore tabs so input fields can be navigated through with keys. - case Core::Input::KI_TAB: + case Input::KI_TAB: return; default: @@ -433,7 +430,7 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) event.GetParameter< int >("alt_key", 0) == 0 && event.GetParameter< int >("meta_key", 0) == 0) { - Core::String text = event.GetParameter("text", Core::String{}); + String text = event.GetParameter("text", String{}); AddCharacters(text); } @@ -471,7 +468,7 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) { if (event.GetTargetElement() == parent) { - Core::Vector2f mouse_position = Core::Vector2f(event.GetParameter< float >("mouse_x", 0), event.GetParameter< float >("mouse_y", 0)); + Vector2f mouse_position = Vector2f(event.GetParameter< float >("mouse_x", 0), event.GetParameter< float >("mouse_y", 0)); mouse_position -= text_element->GetAbsoluteOffset(); cursor_line_index = CalculateLineIndex(mouse_position.y); @@ -483,7 +480,7 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) UpdateCursorPosition(); ideal_cursor_position = cursor_position.x; - UpdateSelection(event == Core::EventId::Drag || event.GetParameter< int >("shift_key", 0) > 0); + UpdateSelection(event == EventId::Drag || event.GetParameter< int >("shift_key", 0) > 0); ShowCursor(true); cancel_next_drag = false; @@ -507,7 +504,7 @@ void WidgetTextInput::ProcessEvent(Core::Event& event) } // Adds a new character to the string at the cursor position. -bool WidgetTextInput::AddCharacters(Rml::Core::String string) +bool WidgetTextInput::AddCharacters(String string) { // Erase invalid characters from string auto invalid_character = [this](char c) { @@ -527,7 +524,7 @@ bool WidgetTextInput::AddCharacters(Rml::Core::String string) if (max_length >= 0 && GetLength() >= max_length) return false; - Core::String value = GetElement()->GetAttribute< Rml::Core::String >("value", ""); + String value = GetElement()->GetAttribute< String >("value", ""); value.insert(std::min(size_t(GetCursorIndex()), value.size()), string); @@ -565,9 +562,9 @@ bool WidgetTextInput::DeleteCharacters(CursorMovement direction) // Copies the selection (if any) to the clipboard. void WidgetTextInput::CopySelection() { - const Core::String& value = GetElement()->GetAttribute< Rml::Core::String >("value", ""); - const Core::String snippet = value.substr(std::min(size_t(selection_begin_index), value.size()), selection_length); - Core::GetSystemInterface()->SetClipboardText(snippet); + const String& value = GetElement()->GetAttribute< String >("value", ""); + const String snippet = value.substr(std::min(size_t(selection_begin_index), value.size()), selection_length); + GetSystemInterface()->SetClipboardText(snippet); } // Returns the absolute index of the cursor. @@ -658,7 +655,7 @@ void WidgetTextInput::MoveCursorHorizontal(CursorMovement movement, bool select) break; } - absolute_cursor_index = Rml::Core::Math::Max(0, absolute_cursor_index); + absolute_cursor_index = Math::Max(0, absolute_cursor_index); UpdateRelativeCursor(); MoveCursorToCharacterBoundaries(seek_forward); @@ -713,9 +710,9 @@ void WidgetTextInput::MoveCursorToCharacterBoundaries(bool forward) const char* p = p_cursor; if (forward) - p = Core::StringUtilities::SeekForwardUTF8(p_cursor, p_line_end); + p = StringUtilities::SeekForwardUTF8(p_cursor, p_line_end); else - p = Core::StringUtilities::SeekBackwardUTF8(p_cursor, p_line_begin); + p = StringUtilities::SeekBackwardUTF8(p_cursor, p_line_begin); if (p != p_cursor) { @@ -838,8 +835,8 @@ void WidgetTextInput::UpdateRelativeCursor() int WidgetTextInput::CalculateLineIndex(float position) { float line_height = parent->GetLineHeight(); - int line_index = Rml::Core::Math::RealToInteger(position / line_height); - return Rml::Core::Math::Clamp(line_index, 0, (int) (lines.size() - 1)); + int line_index = Math::RealToInteger(position / line_height); + return Math::Clamp(line_index, 0, (int) (lines.size() - 1)); } // Calculates the character index along a line under a specific horizontal position. @@ -850,12 +847,12 @@ int WidgetTextInput::CalculateCharacterIndex(int line_index, float position) cursor_on_right_side_of_character = true; - for(auto it = Core::StringIteratorU8(lines[line_index].content, 0, lines[line_index].content_length); it; ) + for(auto it = StringIteratorU8(lines[line_index].content, 0, lines[line_index].content_length); it; ) { ++it; int offset = (int)it.offset(); - float line_width = (float) Core::ElementUtilities::GetStringWidth(text_element, lines[line_index].content.substr(0, offset)); + float line_width = (float) ElementUtilities::GetStringWidth(text_element, lines[line_index].content.substr(0, offset)); if (line_width > position) { if (position - prev_line_width < line_width - position) @@ -886,7 +883,7 @@ void WidgetTextInput::ShowCursor(bool show, bool move_to_cursor) keyboard_showed = true; cursor_timer = CURSOR_BLINK_TIME; - last_update_time = Core::GetSystemInterface()->GetElapsedTime(); + last_update_time = GetSystemInterface()->GetElapsedTime(); // Shift the cursor into view. if (move_to_cursor) @@ -923,31 +920,31 @@ void WidgetTextInput::ShowCursor(bool show, bool move_to_cursor) // Formats the element, laying out the text and inserting scrollbars as appropriate. void WidgetTextInput::FormatElement() { - using namespace Core::Style; - Core::ElementScroll* scroll = parent->GetElementScroll(); - float width = parent->GetBox().GetSize(Core::Box::PADDING).x; + using namespace Style; + ElementScroll* scroll = parent->GetElementScroll(); + float width = parent->GetBox().GetSize(Box::PADDING).x; Overflow x_overflow_property = parent->GetComputedValues().overflow_x; Overflow y_overflow_property = parent->GetComputedValues().overflow_y; if (x_overflow_property == Overflow::Scroll) - scroll->EnableScrollbar(Core::ElementScroll::HORIZONTAL, width); + scroll->EnableScrollbar(ElementScroll::HORIZONTAL, width); else - scroll->DisableScrollbar(Core::ElementScroll::HORIZONTAL); + scroll->DisableScrollbar(ElementScroll::HORIZONTAL); if (y_overflow_property == Overflow::Scroll) - scroll->EnableScrollbar(Core::ElementScroll::VERTICAL, width); + scroll->EnableScrollbar(ElementScroll::VERTICAL, width); else - scroll->DisableScrollbar(Core::ElementScroll::VERTICAL); + scroll->DisableScrollbar(ElementScroll::VERTICAL); // Format the text and determine its total area. - Rml::Core::Vector2f content_area = FormatText(); + Vector2f content_area = FormatText(); // If we're set to automatically generate horizontal scrollbars, check for that now. if (x_overflow_property == Overflow::Auto) { if (parent->GetClientWidth() < content_area.x) - scroll->EnableScrollbar(Core::ElementScroll::HORIZONTAL, width); + scroll->EnableScrollbar(ElementScroll::HORIZONTAL, width); } // Now check for vertical overflow. If we do turn on the scrollbar, this will cause a reflow. @@ -955,27 +952,27 @@ void WidgetTextInput::FormatElement() { if (parent->GetClientHeight() < content_area.y) { - scroll->EnableScrollbar(Core::ElementScroll::VERTICAL, width); + scroll->EnableScrollbar(ElementScroll::VERTICAL, width); content_area = FormatText(); if (x_overflow_property == Overflow::Auto && parent->GetClientWidth() < content_area.y) { - scroll->EnableScrollbar(Core::ElementScroll::HORIZONTAL, width); + scroll->EnableScrollbar(ElementScroll::HORIZONTAL, width); } } } - parent->SetContentBox(Rml::Core::Vector2f(0, 0), content_area); + parent->SetContentBox(Vector2f(0, 0), content_area); scroll->FormatScrollbars(); } // Formats the input element's text field. -Rml::Core::Vector2f WidgetTextInput::FormatText() +Vector2f WidgetTextInput::FormatText() { absolute_cursor_index = edit_index; - Rml::Core::Vector2f content_area(0, 0); + Vector2f content_area(0, 0); // Clear the old lines, and all the lines in the text elements. lines.clear(); @@ -985,14 +982,14 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() // Clear the selection background geometry, and get the vertices and indices so the new geo can // be generated. selection_geometry.Release(true); - std::vector< Core::Vertex >& selection_vertices = selection_geometry.GetVertices(); + std::vector< Vertex >& selection_vertices = selection_geometry.GetVertices(); std::vector< int >& selection_indices = selection_geometry.GetIndices(); // Determine the line-height of the text element. float line_height = parent->GetLineHeight(); int line_begin = 0; - Rml::Core::Vector2f line_position(0, 0); + Vector2f line_position(0, 0); bool last_line = false; // Keep generating lines until all the text content is placed. @@ -1015,8 +1012,8 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() { soft_return = true; - const Core::String& text = text_element->GetText(); - Core::String orphan; + const String& text = text_element->GetText(); + String orphan; for (int i = 1; i >= 0; --i) { int index = line_begin + line.content_length + i; @@ -1040,7 +1037,7 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() { line.content += orphan; line.content_length += (int) orphan.size(); - line_width += Core::ElementUtilities::GetStringWidth(text_element, orphan); + line_width += ElementUtilities::GetStringWidth(text_element, orphan); } } @@ -1048,7 +1045,7 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() // Now that we have the string of characters appearing on the new line, we split it into // three parts; the unselected text appearing before any selected text on the line, the // selected text on the line, and any unselected text after the selection. - Core::String pre_selection, selection, post_selection; + String pre_selection, selection, post_selection; GetLineSelection(pre_selection, selection, post_selection, line.content, line_begin); // The pre-selected text is placed, if there is any (if the selection starts on or before @@ -1056,7 +1053,7 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() if (!pre_selection.empty()) { text_element->AddLine(line_position, pre_selection); - line_position.x += Core::ElementUtilities::GetStringWidth(text_element, pre_selection); + line_position.x += ElementUtilities::GetStringWidth(text_element, pre_selection); } // If there is any selected text on this line, place it in the selected text element and @@ -1064,11 +1061,11 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() if (!selection.empty()) { selected_text_element->AddLine(line_position, selection); - int selection_width = Core::ElementUtilities::GetStringWidth(selected_text_element, selection); + int selection_width = ElementUtilities::GetStringWidth(selected_text_element, selection); selection_vertices.resize(selection_vertices.size() + 4); selection_indices.resize(selection_indices.size() + 6); - Core::GeometryUtilities::GenerateQuad(&selection_vertices[selection_vertices.size() - 4], &selection_indices[selection_indices.size() - 6], line_position, Rml::Core::Vector2f((float)selection_width, line_height), selection_colour, (int)selection_vertices.size() - 4); + GeometryUtilities::GenerateQuad(&selection_vertices[selection_vertices.size() - 4], &selection_indices[selection_indices.size() - 6], line_position, Vector2f((float)selection_width, line_height), selection_colour, (int)selection_vertices.size() - 4); line_position.x += selection_width; } @@ -1086,7 +1083,7 @@ Rml::Core::Vector2f WidgetTextInput::FormatText() // Grow the content area width-wise if this line is the longest so far, and push the // height out. - content_area.x = Rml::Core::Math::Max(content_area.x, line_width + cursor_size.x); + content_area.x = Math::Max(content_area.x, line_width + cursor_size.x); content_area.y = line_position.y; // Push a trailing '\r' token onto the back to indicate a soft return if necessary. @@ -1117,15 +1114,15 @@ void WidgetTextInput::GenerateCursor() // Generates the cursor. cursor_geometry.Release(); - std::vector< Core::Vertex >& vertices = cursor_geometry.GetVertices(); + std::vector< Vertex >& vertices = cursor_geometry.GetVertices(); vertices.resize(4); std::vector< int >& indices = cursor_geometry.GetIndices(); indices.resize(6); - cursor_size.x = Core::ElementUtilities::GetDensityIndependentPixelRatio(text_element); + cursor_size.x = ElementUtilities::GetDensityIndependentPixelRatio(text_element); cursor_size.y = text_element->GetLineHeight() + 2.0f; - Core::GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Rml::Core::Vector2f(0, 0), cursor_size, parent->GetProperty< Rml::Core::Colourb >("color")); + GeometryUtilities::GenerateQuad(&vertices[0], &indices[0], Vector2f(0, 0), cursor_size, parent->GetProperty< Colourb >("color")); } void WidgetTextInput::UpdateCursorPosition() @@ -1133,7 +1130,7 @@ void WidgetTextInput::UpdateCursorPosition() if (text_element->GetFontFaceHandle() == 0) return; - cursor_position.x = (float) Core::ElementUtilities::GetStringWidth(text_element, lines[cursor_line_index].content.substr(0, cursor_character_index)); + cursor_position.x = (float) ElementUtilities::GetStringWidth(text_element, lines[cursor_line_index].content.substr(0, cursor_character_index)); cursor_position.y = -1.f + (float)cursor_line_index * text_element->GetLineHeight(); } @@ -1187,9 +1184,9 @@ void WidgetTextInput::DeleteSelection() { if (selection_length > 0) { - const Core::String& value = GetElement()->GetAttribute< Rml::Core::String >("value", ""); + const String& value = GetElement()->GetAttribute< String >("value", ""); - Rml::Core::String new_value = value.substr(0, selection_begin_index) + value.substr(std::min(size_t(selection_begin_index + selection_length), value.size())); + String new_value = value.substr(0, selection_begin_index) + value.substr(std::min(size_t(selection_begin_index + selection_length), value.size())); GetElement()->SetAttribute("value", new_value); // Move the cursor to the beginning of the old selection. @@ -1202,7 +1199,7 @@ void WidgetTextInput::DeleteSelection() } // Split one line of text into three parts, based on the current selection. -void WidgetTextInput::GetLineSelection(Core::String& pre_selection, Core::String& selection, Core::String& post_selection, const Core::String& line, int line_begin) +void WidgetTextInput::GetLineSelection(String& pre_selection, String& selection, String& post_selection, const String& line, int line_begin) { // Check if we have any selection at all, and if so if the selection is on this line. if (selection_length <= 0 || @@ -1214,7 +1211,7 @@ void WidgetTextInput::GetLineSelection(Core::String& pre_selection, Core::String } int line_length = (int)line.size(); - using namespace Rml::Core::Math; + using namespace Math; // Split the line up into its three parts, depending on the size and placement of the selection. pre_selection = line.substr(0, Max(0, selection_begin_index - line_begin)); @@ -1224,7 +1221,7 @@ void WidgetTextInput::GetLineSelection(Core::String& pre_selection, Core::String void WidgetTextInput::SetKeyboardActive(bool active) { - Core::SystemInterface* system = Core::GetSystemInterface(); + SystemInterface* system = GetSystemInterface(); if (system) { if (active) { @@ -1236,5 +1233,4 @@ void WidgetTextInput::SetKeyboardActive(bool active) } } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetTextInput.h b/Source/Core/Elements/WidgetTextInput.h similarity index 88% rename from Source/Controls/WidgetTextInput.h rename to Source/Core/Elements/WidgetTextInput.h index a2b7f72d9..1842a6356 100644 --- a/Source/Controls/WidgetTextInput.h +++ b/Source/Core/Elements/WidgetTextInput.h @@ -26,22 +26,16 @@ * */ -#ifndef RMLUICONTROLSWIDGETTEXTINPUT_H -#define RMLUICONTROLSWIDGETTEXTINPUT_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUT_H +#define RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUT_H -#include "../../Include/RmlUi/Core/EventListener.h" -#include "../../Include/RmlUi/Core/Geometry.h" -#include "../../Include/RmlUi/Core/Vertex.h" +#include "../../../Include/RmlUi/Core/EventListener.h" +#include "../../../Include/RmlUi/Core/Geometry.h" +#include "../../../Include/RmlUi/Core/Vertex.h" namespace Rml { -namespace Core { class ElementText; - -} - -namespace Controls { - class ElementFormControl; /** @@ -50,7 +44,7 @@ class ElementFormControl; @author Peter Curry */ -class WidgetTextInput : public Core::EventListener +class WidgetTextInput : public EventListener { public: WidgetTextInput(ElementFormControl* parent); @@ -58,7 +52,7 @@ class WidgetTextInput : public Core::EventListener /// Sets the value of the text field. /// @param[in] value The new value to set on the text field. - virtual void SetValue(const Core::String& value); + virtual void SetValue(const String& value); /// Sets the maximum length (in characters) of this text field. /// @param[in] max_length The new maximum length of the text field. A number lower than zero will mean infinite characters. @@ -82,21 +76,21 @@ class WidgetTextInput : public Core::EventListener void OnResize(); /// Returns the input element's underlying text element. - Core::ElementText* GetTextElement(); + ElementText* GetTextElement(); /// Returns the input element's maximum allowed text dimensions. - const Rml::Core::Vector2f& GetTextDimensions() const; + const Vector2f& GetTextDimensions() const; protected: enum class CursorMovement { Begin = -4, BeginLine = -3, PreviousWord = -2, Left = -1, Right = 1, NextWord = 2, EndLine = 3, End = 4 }; /// Processes the "keydown" and "textinput" event to write to the input field, and the "focus" and /// "blur" to set the state of the cursor. - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; /// Adds new characters to the string at the cursor position. /// @param[in] string The characters to add. /// @return True if at least one character was successfully added, false otherwise. - bool AddCharacters(Core::String string); + bool AddCharacters(String string); /// Deletes characters from the string. /// @param[in] direction Movement of cursor for deletion. /// @return True if a character was deleted, false otherwise. @@ -112,7 +106,7 @@ class WidgetTextInput : public Core::EventListener int GetCursorIndex() const; /// Gets the parent element containing the widget. - Core::Element* GetElement() const; + Element* GetElement() const; /// Dispatches a change event to the widget's element. void DispatchChangeEvent(bool linebreak = false); @@ -158,7 +152,7 @@ class WidgetTextInput : public Core::EventListener void FormatElement(); /// Formats the input element's text field. /// @return The content area of the element. - Rml::Core::Vector2f FormatText(); + Vector2f FormatText(); /// Generates the text cursor. void GenerateCursor(); @@ -181,12 +175,12 @@ class WidgetTextInput : public Core::EventListener /// @param[out] post_selection The section of unselected text after any selected text on the line. If there is no selection on the line, then this will be empty. /// @param[in] line The text making up the line. /// @param[in] line_begin The absolute index at the beginning of the line. - void GetLineSelection(Core::String& pre_selection, Core::String& selection, Core::String& post_selection, const Core::String& line, int line_begin); + void GetLineSelection(String& pre_selection, String& selection, String& post_selection, const String& line, int line_begin); struct Line { // The contents of the line (including the trailing endline, if that terminated the line). - Core::String content; + String content; // The length of the editable characters on the line (excluding any trailing endline). int content_length; @@ -197,10 +191,10 @@ class WidgetTextInput : public Core::EventListener ElementFormControl* parent; - Core::ElementText* text_element; - Core::ElementText* selected_text_element; - Rml::Core::Vector2f internal_dimensions; - Rml::Core::Vector2f scroll_offset; + ElementText* text_element; + ElementText* selected_text_element; + Vector2f internal_dimensions; + Vector2f scroll_offset; typedef std::vector< Line > LineList; LineList lines; @@ -219,15 +213,15 @@ class WidgetTextInput : public Core::EventListener bool cancel_next_drag; // Selection. The start and end indices of the selection are in absolute coordinates. - Core::Element* selection_element; + Element* selection_element; int selection_anchor_index; int selection_begin_index; int selection_length; // The colour of the background of selected text. - Rml::Core::Colourb selection_colour; + Colourb selection_colour; // The selection background. - Core::Geometry selection_geometry; + Geometry selection_geometry; // Cursor visibility and timings. float cursor_timer; @@ -241,12 +235,10 @@ class WidgetTextInput : public Core::EventListener // The cursor geometry. float ideal_cursor_position; - Rml::Core::Vector2f cursor_position; - Rml::Core::Vector2f cursor_size; - Core::Geometry cursor_geometry; + Vector2f cursor_position; + Vector2f cursor_size; + Geometry cursor_geometry; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/WidgetTextInputMultiLine.cpp b/Source/Core/Elements/WidgetTextInputMultiLine.cpp similarity index 93% rename from Source/Controls/WidgetTextInputMultiLine.cpp rename to Source/Core/Elements/WidgetTextInputMultiLine.cpp index 809585c55..ca1c583be 100644 --- a/Source/Controls/WidgetTextInputMultiLine.cpp +++ b/Source/Core/Elements/WidgetTextInputMultiLine.cpp @@ -27,11 +27,10 @@ */ #include "WidgetTextInputMultiLine.h" -#include "../../Include/RmlUi/Core/Dictionary.h" -#include "../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/Dictionary.h" +#include "../../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Controls { WidgetTextInputMultiLine::WidgetTextInputMultiLine(ElementFormControl* parent) : WidgetTextInput(parent) { @@ -52,5 +51,4 @@ void WidgetTextInputMultiLine::LineBreak() { } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetTextInputMultiLine.h b/Source/Core/Elements/WidgetTextInputMultiLine.h similarity index 93% rename from Source/Controls/WidgetTextInputMultiLine.h rename to Source/Core/Elements/WidgetTextInputMultiLine.h index b53f1b6cb..c5c9069b2 100644 --- a/Source/Controls/WidgetTextInputMultiLine.h +++ b/Source/Core/Elements/WidgetTextInputMultiLine.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSWIDGETTEXTINPUTMULTILINE_H -#define RMLUICONTROLSWIDGETTEXTINPUTMULTILINE_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTMULTILINE_H +#define RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTMULTILINE_H #include "WidgetTextInput.h" namespace Rml { -namespace Controls { /** A specialisation of the text input widget for multi-line text fields. @@ -55,7 +54,5 @@ class WidgetTextInputMultiLine : public WidgetTextInput void LineBreak() override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/WidgetTextInputSingleLine.cpp b/Source/Core/Elements/WidgetTextInputSingleLine.cpp similarity index 85% rename from Source/Controls/WidgetTextInputSingleLine.cpp rename to Source/Core/Elements/WidgetTextInputSingleLine.cpp index d7cb42c81..a0f67ee2c 100644 --- a/Source/Controls/WidgetTextInputSingleLine.cpp +++ b/Source/Core/Elements/WidgetTextInputSingleLine.cpp @@ -26,12 +26,11 @@ * */ -#include "../../Include/RmlUi/Core/Dictionary.h" -#include "../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/Dictionary.h" +#include "../../../Include/RmlUi/Core/ElementText.h" #include "WidgetTextInputSingleLine.h" namespace Rml { -namespace Controls { WidgetTextInputSingleLine::WidgetTextInputSingleLine(ElementFormControl* parent) : WidgetTextInput(parent) { @@ -42,9 +41,9 @@ WidgetTextInputSingleLine::~WidgetTextInputSingleLine() } // Sets the value of the text field. The value will be stripped of end-lines. -void WidgetTextInputSingleLine::SetValue(const Core::String& value) +void WidgetTextInputSingleLine::SetValue(const String& value) { - Core::String new_value = value; + String new_value = value; SanitiseValue(new_value); WidgetTextInput::SetValue(new_value); @@ -63,10 +62,10 @@ void WidgetTextInputSingleLine::LineBreak() } // Strips all \n and \r characters from the string. -void WidgetTextInputSingleLine::SanitiseValue(Core::String& value) +void WidgetTextInputSingleLine::SanitiseValue(String& value) { - Core::String new_value; - for (Core::String::size_type i = 0; i < value.size(); ++i) + String new_value; + for (String::size_type i = 0; i < value.size(); ++i) { switch (value[i]) { @@ -83,5 +82,4 @@ void WidgetTextInputSingleLine::SanitiseValue(Core::String& value) value = new_value; } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetTextInputSingleLine.h b/Source/Core/Elements/WidgetTextInputSingleLine.h similarity index 91% rename from Source/Controls/WidgetTextInputSingleLine.h rename to Source/Core/Elements/WidgetTextInputSingleLine.h index 2d4fd33a9..6b74c0668 100644 --- a/Source/Controls/WidgetTextInputSingleLine.h +++ b/Source/Core/Elements/WidgetTextInputSingleLine.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSWIDGETTEXTINPUTSINGLELINE_H -#define RMLUICONTROLSWIDGETTEXTINPUTSINGLELINE_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTSINGLELINE_H +#define RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTSINGLELINE_H #include "WidgetTextInput.h" namespace Rml { -namespace Controls { /** A specialisation of the text input widget for single-line input fields. @@ -48,7 +47,7 @@ class WidgetTextInputSingleLine : public WidgetTextInput /// Sets the value of the text field. The value will be stripped of end-lines. /// @param value[in] The new value to set on the text field. - void SetValue(const Core::String& value) override; + void SetValue(const String& value) override; protected: /// Returns true if the given character is permitted in the input field, false if not. @@ -59,10 +58,8 @@ class WidgetTextInputSingleLine : public WidgetTextInput void LineBreak() override; /// Strips all \n and \r characters from the string. - void SanitiseValue(Core::String& value); + void SanitiseValue(String& value); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/WidgetTextInputSingleLinePassword.cpp b/Source/Core/Elements/WidgetTextInputSingleLinePassword.cpp similarity index 86% rename from Source/Controls/WidgetTextInputSingleLinePassword.cpp rename to Source/Core/Elements/WidgetTextInputSingleLinePassword.cpp index 8a8fe2fe9..727a33db0 100644 --- a/Source/Controls/WidgetTextInputSingleLinePassword.cpp +++ b/Source/Core/Elements/WidgetTextInputSingleLinePassword.cpp @@ -26,11 +26,10 @@ * */ -#include "../../Include/RmlUi/Core/ElementText.h" +#include "../../../Include/RmlUi/Core/ElementText.h" #include "WidgetTextInputSingleLinePassword.h" namespace Rml { -namespace Controls { WidgetTextInputSingleLinePassword::WidgetTextInputSingleLinePassword(ElementFormControl* parent) : WidgetTextInputSingleLine(parent) { @@ -41,12 +40,11 @@ WidgetTextInputSingleLinePassword::~WidgetTextInputSingleLinePassword() } // Sets the value of the password field. -void WidgetTextInputSingleLinePassword::SetValue(const Core::String& value) +void WidgetTextInputSingleLinePassword::SetValue(const String& value) { - Core::String sanitised_value(value); + String sanitised_value(value); SanitiseValue(sanitised_value); - WidgetTextInput::SetValue(Core::String(sanitised_value.size(), '*')); + WidgetTextInput::SetValue(String(sanitised_value.size(), '*')); } -} -} +} // namespace Rml diff --git a/Source/Controls/WidgetTextInputSingleLinePassword.h b/Source/Core/Elements/WidgetTextInputSingleLinePassword.h similarity index 90% rename from Source/Controls/WidgetTextInputSingleLinePassword.h rename to Source/Core/Elements/WidgetTextInputSingleLinePassword.h index 1be6e12d2..13c050754 100644 --- a/Source/Controls/WidgetTextInputSingleLinePassword.h +++ b/Source/Core/Elements/WidgetTextInputSingleLinePassword.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSWIDGETTEXTINPUTSINGLELINEPASSWORD_H -#define RMLUICONTROLSWIDGETTEXTINPUTSINGLELINEPASSWORD_H +#ifndef RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTSINGLELINEPASSWORD_H +#define RMLUI_CORE_ELEMENTS_WIDGETTEXTINPUTSINGLELINEPASSWORD_H #include "WidgetTextInputSingleLine.h" namespace Rml { -namespace Controls { /** @author Peter Curry @@ -46,10 +45,8 @@ class WidgetTextInputSingleLinePassword : public WidgetTextInputSingleLine /// Sets the value of the password field. /// @param value[in] The new password to set on the field. - void SetValue(const Core::String& value) override; + void SetValue(const String& value) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/XMLNodeHandlerDataGrid.cpp b/Source/Core/Elements/XMLNodeHandlerDataGrid.cpp similarity index 62% rename from Source/Controls/XMLNodeHandlerDataGrid.cpp rename to Source/Core/Elements/XMLNodeHandlerDataGrid.cpp index 52bdc579a..f05f2bc8e 100644 --- a/Source/Controls/XMLNodeHandlerDataGrid.cpp +++ b/Source/Core/Elements/XMLNodeHandlerDataGrid.cpp @@ -27,14 +27,13 @@ */ #include "XMLNodeHandlerDataGrid.h" -#include "../../Include/RmlUi/Core/StreamMemory.h" -#include "../../Include/RmlUi/Core/Log.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/XMLParser.h" -#include "../../Include/RmlUi/Controls/ElementDataGrid.h" +#include "../../../Include/RmlUi/Core/StreamMemory.h" +#include "../../../Include/RmlUi/Core/Log.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/XMLParser.h" +#include "../../../Include/RmlUi/Core/Elements/ElementDataGrid.h" namespace Rml { -namespace Controls { XMLNodeHandlerDataGrid::XMLNodeHandlerDataGrid() { @@ -44,27 +43,27 @@ XMLNodeHandlerDataGrid::~XMLNodeHandlerDataGrid() { } -Core::Element* XMLNodeHandlerDataGrid::ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) +Element* XMLNodeHandlerDataGrid::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) { - Core::Element* result = nullptr; - Core::Element* parent = parser->GetParseFrame()->element; + Element* result = nullptr; + Element* parent = parser->GetParseFrame()->element; RMLUI_ASSERT(name == "datagrid" || name == "col"); if (name == "datagrid") { // Attempt to instance the grid. - Core::ElementPtr element = Core::Factory::InstanceElement(parent, name, name, attributes); + ElementPtr element = Factory::InstanceElement(parent, name, name, attributes); ElementDataGrid* grid = rmlui_dynamic_cast< ElementDataGrid* >(element.get()); if (!grid) { element.reset(); - Core::Log::Message(Rml::Core::Log::LT_ERROR, "Instancer failed to create data grid for tag %s.", name.c_str()); + Log::Message(Log::LT_ERROR, "Instancer failed to create data grid for tag %s.", name.c_str()); return nullptr; } // Set the data source and table on the data grid. - Rml::Core::String data_source = Core::Get(attributes, "source", ""); + String data_source = Get(attributes, "source", ""); grid->SetDataSource(data_source); result = parent->AppendChild(std::move(element)); @@ -75,7 +74,7 @@ Core::Element* XMLNodeHandlerDataGrid::ElementStart(Core::XMLParser* parser, con else if (name == "col") { // Make a new node handler to handle the header elements. - Core::ElementPtr element = Core::Factory::InstanceElement(parent, "datagridcolumn", "datagridcolumn", attributes); + ElementPtr element = Factory::InstanceElement(parent, "datagridcolumn", "datagridcolumn", attributes); if (!element) return nullptr; @@ -83,7 +82,7 @@ Core::Element* XMLNodeHandlerDataGrid::ElementStart(Core::XMLParser* parser, con ElementDataGrid* grid = rmlui_dynamic_cast< ElementDataGrid* >(parent); if (grid) - grid->AddColumn(Core::Get(attributes, "fields", ""), Core::Get(attributes, "formatter", ""), Core::Get(attributes, "width", 0.0f), std::move(element)); + grid->AddColumn(Get(attributes, "fields", ""), Get(attributes, "formatter", ""), Get(attributes, "width", 0.0f), std::move(element)); // Switch to element handler for all children. parser->PushDefaultHandler(); @@ -96,7 +95,7 @@ Core::Element* XMLNodeHandlerDataGrid::ElementStart(Core::XMLParser* parser, con return result; } -bool XMLNodeHandlerDataGrid::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER(parser), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(name)) +bool XMLNodeHandlerDataGrid::ElementEnd(XMLParser* RMLUI_UNUSED_PARAMETER(parser), const String& RMLUI_UNUSED_PARAMETER(name)) { RMLUI_UNUSED(parser); RMLUI_UNUSED(name); @@ -104,14 +103,13 @@ bool XMLNodeHandlerDataGrid::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER( return true; } -bool XMLNodeHandlerDataGrid::ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType RMLUI_UNUSED_PARAMETER(type)) +bool XMLNodeHandlerDataGrid::ElementData(XMLParser* parser, const String& data, XMLDataType RMLUI_UNUSED_PARAMETER(type)) { RMLUI_UNUSED(type); - Core::Element* parent = parser->GetParseFrame()->element; + Element* parent = parser->GetParseFrame()->element; // Parse the text into the parent element. - return Core::Factory::InstanceElementText(parent, data); + return Factory::InstanceElementText(parent, data); } -} -} +} // namespace Rml diff --git a/Source/Controls/XMLNodeHandlerDataGrid.h b/Source/Core/Elements/XMLNodeHandlerDataGrid.h similarity index 73% rename from Source/Controls/XMLNodeHandlerDataGrid.h rename to Source/Core/Elements/XMLNodeHandlerDataGrid.h index e1ca5c22d..82de3dca4 100644 --- a/Source/Controls/XMLNodeHandlerDataGrid.h +++ b/Source/Core/Elements/XMLNodeHandlerDataGrid.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICONTROLSXMLNODEHANDLERDATAGRID_H -#define RMLUICONTROLSXMLNODEHANDLERDATAGRID_H +#ifndef RMLUI_CORE_ELEMENTS_XMLNODEHANDLERDATAGRID_H +#define RMLUI_CORE_ELEMENTS_XMLNODEHANDLERDATAGRID_H -#include "../../Include/RmlUi/Core/Types.h" -#include "../../Include/RmlUi/Core/XMLNodeHandler.h" +#include "../../../Include/RmlUi/Core/Types.h" +#include "../../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Controls { /** Node handler for the construction of a data grid. @@ -41,21 +40,19 @@ namespace Controls { @author Robert Curry */ -class XMLNodeHandlerDataGrid : public Core::XMLNodeHandler +class XMLNodeHandlerDataGrid : public XMLNodeHandler { public: XMLNodeHandlerDataGrid(); virtual ~XMLNodeHandlerDataGrid(); /// Called when a new element is opened. - Core::Element* ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) override; + Element* ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) override; /// Called when an element is closed. - bool ElementEnd(Core::XMLParser* parser, const Rml::Core::String& name) override; + bool ElementEnd(XMLParser* parser, const String& name) override; /// Called for element data. - bool ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType type) override; + bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/XMLNodeHandlerTabSet.cpp b/Source/Core/Elements/XMLNodeHandlerTabSet.cpp similarity index 65% rename from Source/Controls/XMLNodeHandlerTabSet.cpp rename to Source/Core/Elements/XMLNodeHandlerTabSet.cpp index 103f83b9f..1c67d391e 100644 --- a/Source/Controls/XMLNodeHandlerTabSet.cpp +++ b/Source/Core/Elements/XMLNodeHandlerTabSet.cpp @@ -27,13 +27,12 @@ */ #include "XMLNodeHandlerTabSet.h" -#include "../../Include/RmlUi/Core/Log.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/XMLParser.h" -#include "../../Include/RmlUi/Controls/ElementTabSet.h" +#include "../../../Include/RmlUi/Core/Log.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/XMLParser.h" +#include "../../../Include/RmlUi/Core/Elements/ElementTabSet.h" namespace Rml { -namespace Controls { XMLNodeHandlerTabSet::XMLNodeHandlerTabSet() { @@ -43,7 +42,7 @@ XMLNodeHandlerTabSet::~XMLNodeHandlerTabSet() { } -Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) +Element* XMLNodeHandlerTabSet::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) { RMLUI_ASSERT(name == "tabset" || name == "tabs" || @@ -57,16 +56,16 @@ Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const parser->PushHandler("tabset"); // Attempt to instance the tabset - Core::ElementPtr element = Core::Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes); + ElementPtr element = Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes); ElementTabSet* tabset = rmlui_dynamic_cast< ElementTabSet* >(element.get()); if (!tabset) { - Core::Log::Message(Rml::Core::Log::LT_ERROR, "Instancer failed to create element for tag %s.", name.c_str()); + Log::Message(Log::LT_ERROR, "Instancer failed to create element for tag %s.", name.c_str()); return nullptr; } // Add the TabSet into the document - Core::Element* result = parser->GetParseFrame()->element->AppendChild(std::move(element)); + Element* result = parser->GetParseFrame()->element->AppendChild(std::move(element)); return result; } @@ -75,8 +74,8 @@ Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const // Call default element handler for all children. parser->PushDefaultHandler(); - Core::ElementPtr tab_element = Core::Factory::InstanceElement(parser->GetParseFrame()->element, "*", "tab", attributes); - Core::Element* result = nullptr; + ElementPtr tab_element = Factory::InstanceElement(parser->GetParseFrame()->element, "*", "tab", attributes); + Element* result = nullptr; ElementTabSet* tabset = rmlui_dynamic_cast< ElementTabSet* >(parser->GetParseFrame()->element); if (tabset) @@ -93,8 +92,8 @@ Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const // Call default element handler for all children. parser->PushDefaultHandler(); - Core::ElementPtr panel_element = Core::Factory::InstanceElement(parser->GetParseFrame()->element, "*", "panel", attributes); - Core::Element* result = nullptr; + ElementPtr panel_element = Factory::InstanceElement(parser->GetParseFrame()->element, "*", "panel", attributes); + Element* result = nullptr; ElementTabSet* tabset = rmlui_dynamic_cast< ElementTabSet* >(parser->GetParseFrame()->element); if (tabset) @@ -111,12 +110,12 @@ Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const // style them nicely), but don't return the new element, as we still want the tabset to be the top of the // parser's node stack. - Core::Element* parent = parser->GetParseFrame()->element; + Element* parent = parser->GetParseFrame()->element; - Core::ElementPtr element = Core::Factory::InstanceElement(parent, name, name, attributes); + ElementPtr element = Factory::InstanceElement(parent, name, name, attributes); if (!element) { - Core::Log::Message(Rml::Core::Log::LT_ERROR, "Instancer failed to create element for tag %s.", name.c_str()); + Log::Message(Log::LT_ERROR, "Instancer failed to create element for tag %s.", name.c_str()); return nullptr; } @@ -128,7 +127,7 @@ Core::Element* XMLNodeHandlerTabSet::ElementStart(Core::XMLParser* parser, const return nullptr; } -bool XMLNodeHandlerTabSet::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER(parser), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(name)) +bool XMLNodeHandlerTabSet::ElementEnd(XMLParser* RMLUI_UNUSED_PARAMETER(parser), const String& RMLUI_UNUSED_PARAMETER(name)) { RMLUI_UNUSED(parser); RMLUI_UNUSED(name); @@ -136,11 +135,10 @@ bool XMLNodeHandlerTabSet::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER(pa return true; } -bool XMLNodeHandlerTabSet::ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType RMLUI_UNUSED_PARAMETER(type)) +bool XMLNodeHandlerTabSet::ElementData(XMLParser* parser, const String& data, XMLDataType RMLUI_UNUSED_PARAMETER(type)) { RMLUI_UNUSED(type); - return Core::Factory::InstanceElementText(parser->GetParseFrame()->element, data); + return Factory::InstanceElementText(parser->GetParseFrame()->element, data); } -} -} +} // namespace Rml diff --git a/Source/Controls/XMLNodeHandlerTabSet.h b/Source/Core/Elements/XMLNodeHandlerTabSet.h similarity index 74% rename from Source/Controls/XMLNodeHandlerTabSet.h rename to Source/Core/Elements/XMLNodeHandlerTabSet.h index c5c5d4a86..dd6c7a324 100644 --- a/Source/Controls/XMLNodeHandlerTabSet.h +++ b/Source/Core/Elements/XMLNodeHandlerTabSet.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSXMLNODEHANDLERTABSET_H -#define RMLUICONTROLSXMLNODEHANDLERTABSET_H +#ifndef RMLUI_CORE_ELEMENTS_XMLNODEHANDLERTABSET_H +#define RMLUI_CORE_ELEMENTS_XMLNODEHANDLERTABSET_H -#include "../../Include/RmlUi/Core/XMLNodeHandler.h" +#include "../../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Controls { /** XML node handler for processing the tabset tags. @@ -40,21 +39,19 @@ namespace Controls { @author Lloyd Weehuizen */ -class XMLNodeHandlerTabSet : public Core::XMLNodeHandler +class XMLNodeHandlerTabSet : public XMLNodeHandler { public: XMLNodeHandlerTabSet(); virtual ~XMLNodeHandlerTabSet(); /// Called when a new element start is opened - Core::Element* ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) override; + Element* ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) override; /// Called when an element is closed - bool ElementEnd(Core::XMLParser* parser, const Rml::Core::String& name) override; + bool ElementEnd(XMLParser* parser, const String& name) override; /// Called for element data - bool ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType type) override; + bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Controls/XMLNodeHandlerTextArea.cpp b/Source/Core/Elements/XMLNodeHandlerTextArea.cpp similarity index 66% rename from Source/Controls/XMLNodeHandlerTextArea.cpp rename to Source/Core/Elements/XMLNodeHandlerTextArea.cpp index 331a92ea0..45cd7a7a5 100644 --- a/Source/Controls/XMLNodeHandlerTextArea.cpp +++ b/Source/Core/Elements/XMLNodeHandlerTextArea.cpp @@ -27,14 +27,13 @@ */ #include "XMLNodeHandlerTextArea.h" -#include "../../Include/RmlUi/Controls/ElementFormControlTextArea.h" -#include "../../Include/RmlUi/Core/Core.h" -#include "../../Include/RmlUi/Core/Factory.h" -#include "../../Include/RmlUi/Core/SystemInterface.h" -#include "../../Include/RmlUi/Core/XMLParser.h" +#include "../../../Include/RmlUi/Core/Elements/ElementFormControlTextArea.h" +#include "../../../Include/RmlUi/Core/Core.h" +#include "../../../Include/RmlUi/Core/Factory.h" +#include "../../../Include/RmlUi/Core/SystemInterface.h" +#include "../../../Include/RmlUi/Core/XMLParser.h" namespace Rml { -namespace Controls { XMLNodeHandlerTextArea::XMLNodeHandlerTextArea() { @@ -44,16 +43,16 @@ XMLNodeHandlerTextArea::~XMLNodeHandlerTextArea() { } -Core::Element* XMLNodeHandlerTextArea::ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) +Element* XMLNodeHandlerTextArea::ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) { ElementFormControlTextArea* text_area = rmlui_dynamic_cast< ElementFormControlTextArea* >(parser->GetParseFrame()->element); if (!text_area) { - Core::ElementPtr new_element = Core::Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes); + ElementPtr new_element = Factory::InstanceElement(parser->GetParseFrame()->element, name, name, attributes); if (!new_element) return nullptr; - Core::Element* result = parser->GetParseFrame()->element->AppendChild(std::move(new_element)); + Element* result = parser->GetParseFrame()->element->AppendChild(std::move(new_element)); return result; } @@ -61,7 +60,7 @@ Core::Element* XMLNodeHandlerTextArea::ElementStart(Core::XMLParser* parser, con return nullptr; } -bool XMLNodeHandlerTextArea::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER(parser), const Rml::Core::String& RMLUI_UNUSED_PARAMETER(name)) +bool XMLNodeHandlerTextArea::ElementEnd(XMLParser* RMLUI_UNUSED_PARAMETER(parser), const String& RMLUI_UNUSED_PARAMETER(name)) { RMLUI_UNUSED(parser); RMLUI_UNUSED(name); @@ -69,7 +68,7 @@ bool XMLNodeHandlerTextArea::ElementEnd(Core::XMLParser* RMLUI_UNUSED_PARAMETER( return true; } -bool XMLNodeHandlerTextArea::ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType RMLUI_UNUSED_PARAMETER(type)) +bool XMLNodeHandlerTextArea::ElementData(XMLParser* parser, const String& data, XMLDataType RMLUI_UNUSED_PARAMETER(type)) { RMLUI_UNUSED(type); @@ -77,8 +76,8 @@ bool XMLNodeHandlerTextArea::ElementData(Core::XMLParser* parser, const Rml::Cor if (text_area != nullptr) { // Do any necessary translation. - Rml::Core::String translated_data; - Core::GetSystemInterface()->TranslateString(translated_data, data); + String translated_data; + GetSystemInterface()->TranslateString(translated_data, data); text_area->SetValue(translated_data); } @@ -86,5 +85,4 @@ bool XMLNodeHandlerTextArea::ElementData(Core::XMLParser* parser, const Rml::Cor return true; } -} -} +} // namespace Rml diff --git a/Source/Controls/XMLNodeHandlerTextArea.h b/Source/Core/Elements/XMLNodeHandlerTextArea.h similarity index 74% rename from Source/Controls/XMLNodeHandlerTextArea.h rename to Source/Core/Elements/XMLNodeHandlerTextArea.h index 88ab08f99..daaedb395 100644 --- a/Source/Controls/XMLNodeHandlerTextArea.h +++ b/Source/Core/Elements/XMLNodeHandlerTextArea.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICONTROLSXMLNODEHANDLERTEXTAREA_H -#define RMLUICONTROLSXMLNODEHANDLERTEXTAREA_H +#ifndef RMLUI_CORE_ELEMENTS_XMLNODEHANDLERTEXTAREA_H +#define RMLUI_CORE_ELEMENTS_XMLNODEHANDLERTEXTAREA_H -#include "../../Include/RmlUi/Core/XMLNodeHandler.h" +#include "../../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Controls { /** Node handler that processes the contents of the textarea tag. @@ -40,21 +39,19 @@ namespace Controls { @author Peter Curry */ -class XMLNodeHandlerTextArea : public Core::XMLNodeHandler +class XMLNodeHandlerTextArea : public XMLNodeHandler { public: XMLNodeHandlerTextArea(); virtual ~XMLNodeHandlerTextArea(); /// Called when a new element is opened. - Core::Element* ElementStart(Core::XMLParser* parser, const Rml::Core::String& name, const Rml::Core::XMLAttributes& attributes) override; + Element* ElementStart(XMLParser* parser, const String& name, const XMLAttributes& attributes) override; /// Called when an element is closed. - bool ElementEnd(Core::XMLParser* parser, const Rml::Core::String& name) override; + bool ElementEnd(XMLParser* parser, const String& name) override; /// Called for element data. - bool ElementData(Core::XMLParser* parser, const Rml::Core::String& data, Core::XMLDataType type) override; + bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Event.cpp b/Source/Core/Event.cpp index dbcfbecfc..610e53de3 100644 --- a/Source/Core/Event.cpp +++ b/Source/Core/Event.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { Event::Event() { @@ -187,5 +186,4 @@ void Event::ProjectMouse(Element* element) } } -} -} +} // namespace Rml diff --git a/Source/Core/EventDispatcher.cpp b/Source/Core/EventDispatcher.cpp index 97bc2af97..dc02b4652 100644 --- a/Source/Core/EventDispatcher.cpp +++ b/Source/Core/EventDispatcher.cpp @@ -36,8 +36,6 @@ #include namespace Rml { -namespace Core { - bool operator==(EventListenerEntry a, EventListenerEntry b) { return a.id == b.id && a.in_capture_phase == b.in_capture_phase && a.listener == b.listener; } bool operator!=(EventListenerEntry a, EventListenerEntry b) { return !(a == b); } @@ -294,5 +292,4 @@ String EventDispatcher::ToString() const } -} -} +} // namespace Rml diff --git a/Source/Core/EventDispatcher.h b/Source/Core/EventDispatcher.h index 84be61fe7..43e961c6a 100644 --- a/Source/Core/EventDispatcher.h +++ b/Source/Core/EventDispatcher.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREEVENTDISPATCHER_H -#define RMLUICOREEVENTDISPATCHER_H +#ifndef RMLUI_CORE_EVENTDISPATCHER_H +#define RMLUI_CORE_EVENTDISPATCHER_H #include "../../Include/RmlUi/Core/Types.h" #include "../../Include/RmlUi/Core/Event.h" namespace Rml { -namespace Core { class Element; class EventListener; @@ -108,7 +107,5 @@ class EventDispatcher -} -} - +} // namespace Rml #endif diff --git a/Source/Core/EventInstancer.cpp b/Source/Core/EventInstancer.cpp index 6da1b1620..2a97fedbb 100644 --- a/Source/Core/EventInstancer.cpp +++ b/Source/Core/EventInstancer.cpp @@ -29,11 +29,9 @@ #include "../../Include/RmlUi/Core/EventInstancer.h" namespace Rml { -namespace Core { EventInstancer::~EventInstancer() { } -} -} +} // namespace Rml diff --git a/Source/Core/EventInstancerDefault.cpp b/Source/Core/EventInstancerDefault.cpp index 03965b45b..dd3a345fd 100644 --- a/Source/Core/EventInstancerDefault.cpp +++ b/Source/Core/EventInstancerDefault.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/Event.h" namespace Rml { -namespace Core { EventInstancerDefault::EventInstancerDefault() { @@ -56,5 +55,4 @@ void EventInstancerDefault::Release() delete this; } -} -} +} // namespace Rml diff --git a/Source/Core/EventInstancerDefault.h b/Source/Core/EventInstancerDefault.h index 3f0928627..4d6fd3284 100644 --- a/Source/Core/EventInstancerDefault.h +++ b/Source/Core/EventInstancerDefault.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREEVENTINSTANCERDEFAULT_H -#define RMLUICOREEVENTINSTANCERDEFAULT_H +#ifndef RMLUI_CORE_EVENTINSTANCERDEFAULT_H +#define RMLUI_CORE_EVENTINSTANCERDEFAULT_H #include "../../Include/RmlUi/Core/EventInstancer.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { /** Default instancer for instancing events. @@ -62,7 +61,5 @@ class EventInstancerDefault : public EventInstancer void Release() override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/EventIterators.h b/Source/Core/EventIterators.h index 6da41b01e..5c61a3775 100644 --- a/Source/Core/EventIterators.h +++ b/Source/Core/EventIterators.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREEVENTITERATORS_H -#define RMLUICOREEVENTITERATORS_H +#ifndef RMLUI_CORE_EVENTITERATORS_H +#define RMLUI_CORE_EVENTITERATORS_H #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { /** An STL unary functor for dispatching an event to a Element. @@ -79,7 +78,5 @@ class PseudoClassFunctor bool set; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/EventListenerInstancer.cpp b/Source/Core/EventListenerInstancer.cpp index f01e7a945..0875f3f9d 100644 --- a/Source/Core/EventListenerInstancer.cpp +++ b/Source/Core/EventListenerInstancer.cpp @@ -29,11 +29,9 @@ #include "../../Include/RmlUi/Core/EventListenerInstancer.h" namespace Rml { -namespace Core { EventListenerInstancer::~EventListenerInstancer() { } -} -} +} // namespace Rml diff --git a/Source/Core/EventSpecification.cpp b/Source/Core/EventSpecification.cpp index 6b29242ae..151a9cd6a 100644 --- a/Source/Core/EventSpecification.cpp +++ b/Source/Core/EventSpecification.cpp @@ -31,7 +31,6 @@ namespace Rml { -namespace Core { // An EventId is an index into the specifications vector. static std::vector specifications = { { EventId::Invalid, "invalid", false, false, DefaultActionPhase::None } }; @@ -180,5 +179,4 @@ EventId InsertOrReplaceCustom(const String& event_type, bool interruptible, bool } -} -} +} // namespace Rml diff --git a/Source/Core/EventSpecification.h b/Source/Core/EventSpecification.h index 0f5c2bde4..061d23409 100644 --- a/Source/Core/EventSpecification.h +++ b/Source/Core/EventSpecification.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICOREEVENTSPECIFICATION_H -#define RMLUICOREEVENTSPECIFICATION_H +#ifndef RMLUI_CORE_EVENTSPECIFICATION_H +#define RMLUI_CORE_EVENTSPECIFICATION_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Event.h" #include "../../Include/RmlUi/Core/ID.h" namespace Rml { -namespace Core { - struct EventSpecification { EventId id; @@ -66,7 +64,5 @@ namespace EventSpecificationInterface { EventId InsertOrReplaceCustom(const String& event_type, bool interruptible, bool bubbles, DefaultActionPhase default_action_phase); } -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Factory.cpp b/Source/Core/Factory.cpp index ba9c33932..a40bbfb73 100644 --- a/Source/Core/Factory.cpp +++ b/Source/Core/Factory.cpp @@ -38,6 +38,19 @@ #include "../../Include/RmlUi/Core/StyleSheet.h" #include "../../Include/RmlUi/Core/SystemInterface.h" +#include "../../Include/RmlUi/Core/Elements/ElementForm.h" +#include "../../Include/RmlUi/Core/Elements/ElementFormControlInput.h" +#include "../../Include/RmlUi/Core/Elements/ElementFormControlDataSelect.h" +#include "../../Include/RmlUi/Core/Elements/ElementFormControlSelect.h" +#include "../../Include/RmlUi/Core/Elements/ElementFormControlSelect.h" +#include "../../Include/RmlUi/Core/Elements/ElementFormControlTextArea.h" +#include "../../Include/RmlUi/Core/Elements/ElementTabSet.h" +#include "../../Include/RmlUi/Core/Elements/ElementProgressBar.h" +#include "../../Include/RmlUi/Core/Elements/ElementDataGrid.h" +#include "../../Include/RmlUi/Core/Elements/ElementDataGridExpandButton.h" +#include "../../Include/RmlUi/Core/Elements/ElementDataGridCell.h" +#include "../../Include/RmlUi/Core/Elements/ElementDataGridRow.h" + #include "ContextInstancerDefault.h" #include "DataControllerDefault.h" #include "DataViewDefault.h" @@ -48,7 +61,6 @@ #include "DecoratorNinePatch.h" #include "DecoratorGradient.h" #include "ElementHandle.h" -#include "ElementImage.h" #include "ElementTextDefault.h" #include "EventInstancerDefault.h" #include "FontEffectBlur.h" @@ -65,10 +77,16 @@ #include "XMLNodeHandlerHead.h" #include "XMLNodeHandlerTemplate.h" #include "XMLParseTools.h" + +#include "Elements/ElementImage.h" +#include "Elements/ElementTextSelection.h" +#include "Elements/XMLNodeHandlerDataGrid.h" +#include "Elements/XMLNodeHandlerTabSet.h" +#include "Elements/XMLNodeHandlerTextArea.h" + #include namespace Rml { -namespace Core { // Element instancers. using ElementInstancerMap = UnorderedMap< String, ElementInstancer* >; @@ -106,46 +124,65 @@ static EventInstancer* event_instancer = nullptr; // Event listener instancer. static EventListenerInstancer* event_listener_instancer = nullptr; - // Default instancers are constructed and destroyed on Initialise and Shutdown, respectively. struct DefaultInstancers { - template using Ptr = UniquePtr; - - Ptr context_default; - Ptr event_default; - - Ptr element_default = std::make_unique(); - Ptr element_text_default = std::make_unique(); - Ptr element_img = std::make_unique>(); - Ptr element_handle = std::make_unique>(); - Ptr element_body = std::make_unique>(); - - Ptr decorator_tiled_horizontal = std::make_unique(); - Ptr decorator_tiled_vertical = std::make_unique(); - Ptr decorator_tiled_box = std::make_unique(); - Ptr decorator_image = std::make_unique(); - Ptr decorator_ninepatch = std::make_unique(); - Ptr decorator_gradient = std::make_unique(); - - Ptr font_effect_blur = std::make_unique(); - Ptr font_effect_glow = std::make_unique(); - Ptr font_effect_outline = std::make_unique(); - Ptr font_effect_shadow = std::make_unique(); - - Ptr data_view_attribute = std::make_unique>(); - Ptr data_view_class = std::make_unique>(); - Ptr data_view_if = std::make_unique>(); - Ptr data_view_visible = std::make_unique>(); - Ptr data_view_rml = std::make_unique>(); - Ptr data_view_style = std::make_unique>(); - Ptr data_view_text = std::make_unique>(); - Ptr data_view_value = std::make_unique>(); - - Ptr structural_data_view_for = std::make_unique>(); - - Ptr data_controller_value = std::make_unique>(); - Ptr data_controller_event = std::make_unique>(); + UniquePtr context_default; + UniquePtr event_default; + + // Basic elements + ElementInstancerElement element_default; + ElementInstancerTextDefault element_text_default; + ElementInstancerGeneric element_img; + ElementInstancerGeneric element_handle; + ElementInstancerGeneric element_body; + + // Control elements + ElementInstancerGeneric form; + ElementInstancerGeneric input; + ElementInstancerGeneric dataselect; + ElementInstancerGeneric select; + + ElementInstancerGeneric textarea; + ElementInstancerGeneric selection; + ElementInstancerGeneric tabset; + + ElementInstancerGeneric progressbar; + + ElementInstancerGeneric datagrid; + ElementInstancerGeneric datagrid_expand; + ElementInstancerGeneric datagrid_cell; + ElementInstancerGeneric datagrid_row; + + // Decorators + DecoratorTiledHorizontalInstancer decorator_tiled_horizontal; + DecoratorTiledVerticalInstancer decorator_tiled_vertical; + DecoratorTiledBoxInstancer decorator_tiled_box; + DecoratorTiledImageInstancer decorator_image; + DecoratorNinePatchInstancer decorator_ninepatch; + DecoratorGradientInstancer decorator_gradient; + + // Font effects + FontEffectBlurInstancer font_effect_blur; + FontEffectGlowInstancer font_effect_glow; + FontEffectOutlineInstancer font_effect_outline; + FontEffectShadowInstancer font_effect_shadow; + + // Data binding views + DataViewInstancerDefault data_view_attribute; + DataViewInstancerDefault data_view_class; + DataViewInstancerDefault data_view_if; + DataViewInstancerDefault data_view_visible; + DataViewInstancerDefault data_view_rml; + DataViewInstancerDefault data_view_style; + DataViewInstancerDefault data_view_text; + DataViewInstancerDefault data_view_value; + + DataViewInstancerDefault structural_data_view_for; + + // Data binding controllers + DataControllerInstancerDefault data_controller_value; + DataControllerInstancerDefault data_controller_event; }; static UniquePtr default_instancers; @@ -164,14 +201,14 @@ bool Factory::Initialise() { default_instancers = std::make_unique(); - // Bind the default context instancer. + // Default context instancer if (!context_instancer) { default_instancers->context_default = std::make_unique(); context_instancer = default_instancers->context_default.get(); } - // Bind default event instancer + // Default event instancer if (!event_instancer) { default_instancers->event_default = std::make_unique(); @@ -182,46 +219,69 @@ bool Factory::Initialise() if (!event_listener_instancer) event_listener_instancer = nullptr; - // Bind the default element instancers - RegisterElementInstancer("*", default_instancers->element_default.get()); - RegisterElementInstancer("img", default_instancers->element_img.get()); - RegisterElementInstancer("#text", default_instancers->element_text_default.get()); - RegisterElementInstancer("handle", default_instancers->element_handle.get()); - RegisterElementInstancer("body", default_instancers->element_body.get()); - - // Bind the default decorator instancers - RegisterDecoratorInstancer("tiled-horizontal", default_instancers->decorator_tiled_horizontal.get()); - RegisterDecoratorInstancer("tiled-vertical", default_instancers->decorator_tiled_vertical.get()); - RegisterDecoratorInstancer("tiled-box", default_instancers->decorator_tiled_box.get()); - RegisterDecoratorInstancer("image", default_instancers->decorator_image.get()); - RegisterDecoratorInstancer("ninepatch", default_instancers->decorator_ninepatch.get()); - RegisterDecoratorInstancer("gradient", default_instancers->decorator_gradient.get()); - - RegisterFontEffectInstancer("blur", default_instancers->font_effect_blur.get()); - RegisterFontEffectInstancer("glow", default_instancers->font_effect_glow.get()); - RegisterFontEffectInstancer("outline", default_instancers->font_effect_outline.get()); - RegisterFontEffectInstancer("shadow", default_instancers->font_effect_shadow.get()); - - // Register the core XML node handlers. + // Basic element instancers + RegisterElementInstancer("*", &default_instancers->element_default); + RegisterElementInstancer("img", &default_instancers->element_img); + RegisterElementInstancer("#text", &default_instancers->element_text_default); + RegisterElementInstancer("handle", &default_instancers->element_handle); + RegisterElementInstancer("body", &default_instancers->element_body); + + // Control element instancers + RegisterElementInstancer("form", &default_instancers->form); + RegisterElementInstancer("input", &default_instancers->input); + RegisterElementInstancer("dataselect", &default_instancers->dataselect); + RegisterElementInstancer("select", &default_instancers->select); + + RegisterElementInstancer("textarea", &default_instancers->textarea); + RegisterElementInstancer("#selection", &default_instancers->selection); + RegisterElementInstancer("tabset", &default_instancers->tabset); + + RegisterElementInstancer("progressbar", &default_instancers->progressbar); + + RegisterElementInstancer("datagrid", &default_instancers->datagrid); + RegisterElementInstancer("datagridexpand", &default_instancers->datagrid_expand); + RegisterElementInstancer("#rmlctl_datagridcell", &default_instancers->datagrid_cell); + RegisterElementInstancer("#rmlctl_datagridrow", &default_instancers->datagrid_row); + + // Decorator instancers + RegisterDecoratorInstancer("tiled-horizontal", &default_instancers->decorator_tiled_horizontal); + RegisterDecoratorInstancer("tiled-vertical", &default_instancers->decorator_tiled_vertical); + RegisterDecoratorInstancer("tiled-box", &default_instancers->decorator_tiled_box); + RegisterDecoratorInstancer("image", &default_instancers->decorator_image); + RegisterDecoratorInstancer("ninepatch", &default_instancers->decorator_ninepatch); + RegisterDecoratorInstancer("gradient", &default_instancers->decorator_gradient); + + // Font effect instancers + RegisterFontEffectInstancer("blur", &default_instancers->font_effect_blur); + RegisterFontEffectInstancer("glow", &default_instancers->font_effect_glow); + RegisterFontEffectInstancer("outline", &default_instancers->font_effect_outline); + RegisterFontEffectInstancer("shadow", &default_instancers->font_effect_shadow); + + // Data binding views + RegisterDataViewInstancer(&default_instancers->data_view_attribute, "attr", false); + RegisterDataViewInstancer(&default_instancers->data_view_class, "class", false); + RegisterDataViewInstancer(&default_instancers->data_view_if, "if", false); + RegisterDataViewInstancer(&default_instancers->data_view_visible, "visible", false); + RegisterDataViewInstancer(&default_instancers->data_view_rml, "rml", false); + RegisterDataViewInstancer(&default_instancers->data_view_style, "style", false); + RegisterDataViewInstancer(&default_instancers->data_view_text, "text", false); + RegisterDataViewInstancer(&default_instancers->data_view_value, "value", false); + RegisterDataViewInstancer(&default_instancers->structural_data_view_for, "for", true ); + + // Data binding controllers + RegisterDataControllerInstancer(&default_instancers->data_controller_value, "value"); + RegisterDataControllerInstancer(&default_instancers->data_controller_event, "event"); + + // XML node handlers XMLParser::RegisterNodeHandler("", std::make_shared()); XMLParser::RegisterNodeHandler("body", std::make_shared()); XMLParser::RegisterNodeHandler("head", std::make_shared()); XMLParser::RegisterNodeHandler("template", std::make_shared()); - // Register the default data views - RegisterDataViewInstancer(default_instancers->data_view_attribute.get(), "attr", false); - RegisterDataViewInstancer(default_instancers->data_view_class.get(), "class", false); - RegisterDataViewInstancer(default_instancers->data_view_if.get(), "if", false); - RegisterDataViewInstancer(default_instancers->data_view_visible.get(), "visible", false); - RegisterDataViewInstancer(default_instancers->data_view_rml.get(), "rml", false); - RegisterDataViewInstancer(default_instancers->data_view_style.get(), "style", false); - RegisterDataViewInstancer(default_instancers->data_view_text.get(), "text", false); - RegisterDataViewInstancer(default_instancers->data_view_value.get(), "value", false); - RegisterDataViewInstancer(default_instancers->structural_data_view_for.get(), "for", true ); - - RegisterDataControllerInstancer(default_instancers->data_controller_value.get(), "value"); - RegisterDataControllerInstancer(default_instancers->data_controller_event.get(), "event"); - + // XML node handlers for control elements + XMLParser::RegisterNodeHandler("datagrid", std::make_shared()); + XMLParser::RegisterNodeHandler("tabset", std::make_shared()); + XMLParser::RegisterNodeHandler("textarea", std::make_shared()); return true; } @@ -401,7 +461,7 @@ bool Factory::InstanceElementStream(Element* parent, Stream* stream) } // Instances a element tree based on the stream -ElementPtr Factory::InstanceDocumentStream(Rml::Core::Context* context, Stream* stream) +ElementPtr Factory::InstanceDocumentStream(Context* context, Stream* stream) { RMLUI_ZoneScoped; @@ -588,5 +648,4 @@ const StringList& Factory::GetStructuralDataViewAttributeNames() return structural_data_view_attribute_names; } -} -} +} // namespace Rml diff --git a/Source/Core/FileInterface.cpp b/Source/Core/FileInterface.cpp index 584f52750..80b61262e 100644 --- a/Source/Core/FileInterface.cpp +++ b/Source/Core/FileInterface.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/FileInterface.h" namespace Rml { -namespace Core { FileInterface::FileInterface() { @@ -49,5 +48,4 @@ size_t FileInterface::Length(FileHandle file) return length; } -} -} +} // namespace Rml diff --git a/Source/Core/FileInterfaceDefault.cpp b/Source/Core/FileInterfaceDefault.cpp index ad489e8e5..c29f2d60e 100644 --- a/Source/Core/FileInterfaceDefault.cpp +++ b/Source/Core/FileInterfaceDefault.cpp @@ -31,7 +31,6 @@ #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT namespace Rml { -namespace Core { FileInterfaceDefault::~FileInterfaceDefault() { @@ -67,7 +66,5 @@ size_t FileInterfaceDefault::Tell(FileHandle file) return ftell((FILE*) file); } -} -} - +} // namespace Rml #endif /*RMLUI_NO_FILE_INTERFACE_DEFAULT*/ diff --git a/Source/Core/FileInterfaceDefault.h b/Source/Core/FileInterfaceDefault.h index d4b96653c..4e38ab2f3 100644 --- a/Source/Core/FileInterfaceDefault.h +++ b/Source/Core/FileInterfaceDefault.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREFILEINTERFACEDEFAULT_H -#define RMLUICOREFILEINTERFACEDEFAULT_H +#ifndef RMLUI_CORE_FILEINTERFACEDEFAULT_H +#define RMLUI_CORE_FILEINTERFACEDEFAULT_H #include "../../Include/RmlUi/Core/FileInterface.h" #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT namespace Rml { -namespace Core { /** Implementation of the RmlUi file interface using the Standard C file functions. @@ -73,9 +72,7 @@ class FileInterfaceDefault : public FileInterface size_t Tell(FileHandle file) override; }; -} -} - +} // namespace Rml #endif /*RMLUI_NO_FILE_INTERFACE_DEFAULT*/ #endif diff --git a/Source/Core/FontEffect.cpp b/Source/Core/FontEffect.cpp index 97ad9874c..799a17d01 100644 --- a/Source/Core/FontEffect.cpp +++ b/Source/Core/FontEffect.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/FontEffectInstancer.h" namespace Rml { -namespace Core { FontEffect::FontEffect() : colour(255, 255, 255) { @@ -93,5 +92,4 @@ void FontEffect::SetFingerprint(size_t _fingerprint) fingerprint = _fingerprint; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectBlur.cpp b/Source/Core/FontEffectBlur.cpp index 364451055..7588c92f5 100644 --- a/Source/Core/FontEffectBlur.cpp +++ b/Source/Core/FontEffectBlur.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { FontEffectBlur::FontEffectBlur() { @@ -146,5 +145,4 @@ SharedPtr FontEffectBlurInstancer::InstanceFontEffect(const String& return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectBlur.h b/Source/Core/FontEffectBlur.h index a15f172ee..eee351a06 100644 --- a/Source/Core/FontEffectBlur.h +++ b/Source/Core/FontEffectBlur.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREFONTEFFECTBLUR_H -#define RMLUICOREFONTEFFECTBLUR_H +#ifndef RMLUI_CORE_FONTEFFECTBLUR_H +#define RMLUI_CORE_FONTEFFECTBLUR_H #include "../../Include/RmlUi/Core/ConvolutionFilter.h" #include "../../Include/RmlUi/Core/FontEffect.h" #include "../../Include/RmlUi/Core/FontEffectInstancer.h" namespace Rml { -namespace Core { /** A concrete font effect for rendering Gaussian blurred text. @@ -78,7 +77,5 @@ class FontEffectBlurInstancer : public FontEffectInstancer }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEffectGlow.cpp b/Source/Core/FontEffectGlow.cpp index 2640aa4f5..0e1007930 100644 --- a/Source/Core/FontEffectGlow.cpp +++ b/Source/Core/FontEffectGlow.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { FontEffectGlow::FontEffectGlow() { @@ -184,5 +183,4 @@ SharedPtr FontEffectGlowInstancer::InstanceFontEffect(const String& return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectGlow.h b/Source/Core/FontEffectGlow.h index 671b3ebf8..dea66212e 100644 --- a/Source/Core/FontEffectGlow.h +++ b/Source/Core/FontEffectGlow.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREFONTEFFECTGLOW_H -#define RMLUICOREFONTEFFECTGLOW_H +#ifndef RMLUI_CORE_FONTEFFECTGLOW_H +#define RMLUI_CORE_FONTEFFECTGLOW_H #include "../../Include/RmlUi/Core/ConvolutionFilter.h" #include "../../Include/RmlUi/Core/FontEffect.h" #include "../../Include/RmlUi/Core/FontEffectInstancer.h" namespace Rml { -namespace Core { /** A font effect for rendering glow around text. @@ -82,7 +81,5 @@ class FontEffectGlowInstancer : public FontEffectInstancer }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEffectInstancer.cpp b/Source/Core/FontEffectInstancer.cpp index 966a0c6b4..6cfbfef46 100644 --- a/Source/Core/FontEffectInstancer.cpp +++ b/Source/Core/FontEffectInstancer.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { FontEffectInstancer::FontEffectInstancer() : properties(10, 10) { @@ -62,5 +61,4 @@ ShorthandId FontEffectInstancer::RegisterShorthand(const String& shorthand_name, return properties.RegisterShorthand(shorthand_name, property_names, type); } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectOutline.cpp b/Source/Core/FontEffectOutline.cpp index 97d5afdc0..d4d96ea28 100644 --- a/Source/Core/FontEffectOutline.cpp +++ b/Source/Core/FontEffectOutline.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { FontEffectOutline::FontEffectOutline() { @@ -128,5 +127,4 @@ SharedPtr FontEffectOutlineInstancer::InstanceFontEffect(const Strin return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectOutline.h b/Source/Core/FontEffectOutline.h index f8feba752..dfd9c122d 100644 --- a/Source/Core/FontEffectOutline.h +++ b/Source/Core/FontEffectOutline.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREFONTEFFECTOUTLINE_H -#define RMLUICOREFONTEFFECTOUTLINE_H +#ifndef RMLUI_CORE_FONTEFFECTOUTLINE_H +#define RMLUI_CORE_FONTEFFECTOUTLINE_H #include "../../Include/RmlUi/Core/ConvolutionFilter.h" #include "../../Include/RmlUi/Core/FontEffect.h" #include "../../Include/RmlUi/Core/FontEffectInstancer.h" namespace Rml { -namespace Core { /** A concrete font effect for rendering outlines around text. @@ -82,7 +81,5 @@ class FontEffectOutlineInstancer : public FontEffectInstancer }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEffectShadow.cpp b/Source/Core/FontEffectShadow.cpp index 9e76e806e..c44aa49f1 100644 --- a/Source/Core/FontEffectShadow.cpp +++ b/Source/Core/FontEffectShadow.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { FontEffectShadow::FontEffectShadow() : offset(0, 0) { @@ -95,5 +94,4 @@ SharedPtr FontEffectShadowInstancer::InstanceFontEffect(const String return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEffectShadow.h b/Source/Core/FontEffectShadow.h index efd899b63..48126d76b 100644 --- a/Source/Core/FontEffectShadow.h +++ b/Source/Core/FontEffectShadow.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREFONTEFFECTSHADOW_H -#define RMLUICOREFONTEFFECTSHADOW_H +#ifndef RMLUI_CORE_FONTEFFECTSHADOW_H +#define RMLUI_CORE_FONTEFFECTSHADOW_H #include "../../Include/RmlUi/Core/FontEffect.h" #include "../../Include/RmlUi/Core/FontEffectInstancer.h" namespace Rml { -namespace Core { /** A concrete font effect for rendering text shadows. @@ -78,7 +77,5 @@ class FontEffectShadowInstancer : public FontEffectInstancer }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp b/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp index 2aed00c40..23969dd0a 100644 --- a/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp +++ b/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.cpp @@ -31,7 +31,6 @@ #include "FontEngineInterfaceDefault.h" namespace Rml { -namespace Core { FontEngineInterfaceDefault::FontEngineInterfaceDefault() { @@ -114,5 +113,4 @@ int FontEngineInterfaceDefault::GetVersion(FontFaceHandle handle) return handle_default->GetVersion(); } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h b/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h index 0bf2add7a..ca25023d2 100644 --- a/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h +++ b/Source/Core/FontEngineDefault/FontEngineInterfaceDefault.h @@ -25,13 +25,12 @@ * */ -#ifndef RMLUICOREFONTENGINEINTERFACEDEFAULT_H -#define RMLUICOREFONTENGINEINTERFACEDEFAULT_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTENGINEINTERFACEDEFAULT_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTENGINEINTERFACEDEFAULT_H #include "../../../Include/RmlUi/Core/FontEngineInterface.h" namespace Rml { -namespace Core { class RMLUICORE_API FontEngineInterfaceDefault : public FontEngineInterface { @@ -76,7 +75,5 @@ class RMLUICORE_API FontEngineInterfaceDefault : public FontEngineInterface int GetVersion(FontFaceHandle handle) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontFace.cpp b/Source/Core/FontEngineDefault/FontFace.cpp index cbb42587a..e7c43fb2e 100644 --- a/Source/Core/FontEngineDefault/FontFace.cpp +++ b/Source/Core/FontEngineDefault/FontFace.cpp @@ -32,7 +32,6 @@ #include "FreeTypeInterface.h" namespace Rml { -namespace Core { FontFace::FontFace(FontFaceHandleFreetype _face, Style::FontStyle _style, Style::FontWeight _weight, bool _release_stream) { @@ -94,5 +93,4 @@ FontFaceHandleDefault* FontFace::GetHandle(int size) { } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontFace.h b/Source/Core/FontEngineDefault/FontFace.h index 611f402c9..ddf27cd86 100644 --- a/Source/Core/FontEngineDefault/FontFace.h +++ b/Source/Core/FontEngineDefault/FontFace.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREFONTFACE_H -#define RMLUICOREFONTFACE_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTFACE_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTFACE_H #include "../../../Include/RmlUi/Core/ComputedValues.h" #include "FontTypes.h" namespace Rml { -namespace Core { class FontFaceHandleDefault; @@ -68,7 +67,5 @@ class FontFace FontFaceHandleFreetype face; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp b/Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp index 9499a2f3d..b47bb7081 100644 --- a/Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp +++ b/Source/Core/FontEngineDefault/FontFaceHandleDefault.cpp @@ -35,7 +35,6 @@ #include namespace Rml { -namespace Core { FontFaceHandleDefault::FontFaceHandleDefault() { @@ -451,5 +450,4 @@ bool FontFaceHandleDefault::GenerateLayer(FontFaceLayer* layer) return result; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontFaceHandleDefault.h b/Source/Core/FontEngineDefault/FontFaceHandleDefault.h index fc8d517c9..686cbdb2f 100644 --- a/Source/Core/FontEngineDefault/FontFaceHandleDefault.h +++ b/Source/Core/FontEngineDefault/FontFaceHandleDefault.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREFONTFACEHANDLE_H -#define RMLUICOREFONTFACEHANDLE_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTFACEHANDLE_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTFACEHANDLE_H #include "../../../Include/RmlUi/Core/Traits.h" #include "../../../Include/RmlUi/Core/FontEffect.h" @@ -37,7 +37,6 @@ #include "FontTypes.h" namespace Rml { -namespace Core { class FontFaceLayer; @@ -149,7 +148,5 @@ class FontFaceHandleDefault final : public NonCopyMoveable FontFaceHandleFreetype ft_face; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontFaceLayer.cpp b/Source/Core/FontEngineDefault/FontFaceLayer.cpp index 87b215d7a..c6b51603f 100644 --- a/Source/Core/FontEngineDefault/FontFaceLayer.cpp +++ b/Source/Core/FontEngineDefault/FontFaceLayer.cpp @@ -30,7 +30,6 @@ #include "FontFaceHandleDefault.h" namespace Rml { -namespace Core { FontFaceLayer::FontFaceLayer(const SharedPtr& _effect) : colour(255, 255, 255) { @@ -259,5 +258,4 @@ const Colourb& FontFaceLayer::GetColour() const return colour; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontFaceLayer.h b/Source/Core/FontEngineDefault/FontFaceLayer.h index c0bdc9cbb..9a2d777c3 100644 --- a/Source/Core/FontEngineDefault/FontFaceLayer.h +++ b/Source/Core/FontEngineDefault/FontFaceLayer.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREFONTFACELAYER_H -#define RMLUICOREFONTFACELAYER_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTFACELAYER_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTFACELAYER_H #include "../../../Include/RmlUi/Core/FontGlyph.h" #include "../../../Include/RmlUi/Core/Geometry.h" @@ -36,7 +36,6 @@ #include "../TextureLayout.h" namespace Rml { -namespace Core { class FontEffect; class FontFaceHandleDefault; @@ -143,7 +142,5 @@ class FontFaceLayer Colourb colour; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontFamily.cpp b/Source/Core/FontEngineDefault/FontFamily.cpp index 7cc66dfda..b38fb92ca 100644 --- a/Source/Core/FontEngineDefault/FontFamily.cpp +++ b/Source/Core/FontEngineDefault/FontFamily.cpp @@ -30,7 +30,6 @@ #include "FontFace.h" namespace Rml { -namespace Core { FontFamily::FontFamily(const String& name) : name(name) { @@ -72,5 +71,4 @@ FontFace* FontFamily::AddFace(FontFaceHandleFreetype ft_face, Style::FontStyle s return result; } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontFamily.h b/Source/Core/FontEngineDefault/FontFamily.h index 48c90e9bb..2e3f3c2cb 100644 --- a/Source/Core/FontEngineDefault/FontFamily.h +++ b/Source/Core/FontEngineDefault/FontFamily.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREFONTFAMILY_H -#define RMLUICOREFONTFAMILY_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTFAMILY_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTFAMILY_H #include "FontTypes.h" namespace Rml { -namespace Core { class FontFace; class FontFaceHandleDefault; @@ -69,7 +68,5 @@ class FontFamily FontFaceList font_faces; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontProvider.cpp b/Source/Core/FontEngineDefault/FontProvider.cpp index dff23f305..48c3ebae4 100644 --- a/Source/Core/FontEngineDefault/FontProvider.cpp +++ b/Source/Core/FontEngineDefault/FontProvider.cpp @@ -37,7 +37,6 @@ #include namespace Rml { -namespace Core { static FontProvider* g_font_provider = nullptr; @@ -195,5 +194,4 @@ bool FontProvider::AddFace(FontFaceHandleFreetype face, const String& family, St } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FontProvider.h b/Source/Core/FontEngineDefault/FontProvider.h index b911b7b70..46073e241 100644 --- a/Source/Core/FontEngineDefault/FontProvider.h +++ b/Source/Core/FontEngineDefault/FontProvider.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREFONTPROVIDER_H -#define RMLUICOREFONTPROVIDER_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTPROVIDER_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTPROVIDER_H #include "../../../Include/RmlUi/Core/Types.h" #include "../../../Include/RmlUi/Core/ComputedValues.h" #include "FontTypes.h" namespace Rml { -namespace Core { class FontFace; class FontFamily; @@ -94,7 +93,5 @@ class FontProvider }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FontTypes.h b/Source/Core/FontEngineDefault/FontTypes.h index 159097d63..512851a02 100644 --- a/Source/Core/FontEngineDefault/FontTypes.h +++ b/Source/Core/FontEngineDefault/FontTypes.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICOREFONTTYPES_H -#define RMLUICOREFONTTYPES_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTTYPES_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FONTTYPES_H #include "../../../Include/RmlUi/Core/Types.h" #include "../../../Include/RmlUi/Core/ComputedValues.h" #include "../../../Include/RmlUi/Core/FontGlyph.h" namespace Rml { -namespace Core { - using FontFaceHandleFreetype = uintptr_t; @@ -50,7 +48,5 @@ struct FontMetrics float underline_thickness; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineDefault/FreeTypeInterface.cpp b/Source/Core/FontEngineDefault/FreeTypeInterface.cpp index 606810518..aa6123fec 100644 --- a/Source/Core/FontEngineDefault/FreeTypeInterface.cpp +++ b/Source/Core/FontEngineDefault/FreeTypeInterface.cpp @@ -34,7 +34,6 @@ #include FT_FREETYPE_H namespace Rml { -namespace Core { static FT_Library ft_library = nullptr; @@ -374,5 +373,4 @@ static void GenerateMetrics(FT_Face ft_face, FontMetrics& metrics) } -} -} +} // namespace Rml diff --git a/Source/Core/FontEngineDefault/FreeTypeInterface.h b/Source/Core/FontEngineDefault/FreeTypeInterface.h index ddde2e492..0fc207497 100644 --- a/Source/Core/FontEngineDefault/FreeTypeInterface.h +++ b/Source/Core/FontEngineDefault/FreeTypeInterface.h @@ -26,13 +26,13 @@ * */ -#ifndef RMLUICOREFREETYPEINTERFACE_H -#define RMLUICOREFREETYPEINTERFACE_H +#ifndef RMLUI_CORE_FONTENGINEDEFAULT_FREETYPEINTERFACE_H +#define RMLUI_CORE_FONTENGINEDEFAULT_FREETYPEINTERFACE_H #include "FontTypes.h" namespace Rml { -namespace Core { + namespace FreeType { // Initialize FreeType library. @@ -59,7 +59,5 @@ bool AppendGlyph(FontFaceHandleFreetype face, int font_size, Character character int GetKerning(FontFaceHandleFreetype face, int font_size, Character lhs, Character rhs); } -} -} - +} // namespace Rml #endif diff --git a/Source/Core/FontEngineInterface.cpp b/Source/Core/FontEngineInterface.cpp index 73a2caf16..ef7a94721 100644 --- a/Source/Core/FontEngineInterface.cpp +++ b/Source/Core/FontEngineInterface.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/FontEngineInterface.h" namespace Rml { -namespace Core { FontEngineInterface::FontEngineInterface() { @@ -102,5 +101,4 @@ int FontEngineInterface::GetVersion(FontFaceHandle /*handle*/) return 0; } -} -} +} // namespace Rml diff --git a/Source/Core/Geometry.cpp b/Source/Core/Geometry.cpp index 1b1dbdc26..667b54e6f 100644 --- a/Source/Core/Geometry.cpp +++ b/Source/Core/Geometry.cpp @@ -37,7 +37,6 @@ namespace Rml { -namespace Core { Geometry::Geometry(Element* host_element) : host_element(host_element) { @@ -194,8 +193,7 @@ RenderInterface* Geometry::GetRenderInterface() if (host_context) return host_context->GetRenderInterface(); else - return Rml::Core::GetRenderInterface(); + return ::Rml::GetRenderInterface(); } -} -} +} // namespace Rml diff --git a/Source/Core/GeometryDatabase.cpp b/Source/Core/GeometryDatabase.cpp index a89d50a82..68269309b 100644 --- a/Source/Core/GeometryDatabase.cpp +++ b/Source/Core/GeometryDatabase.cpp @@ -31,7 +31,7 @@ #include namespace Rml { -namespace Core { + namespace GeometryDatabase { class Database { @@ -180,5 +180,4 @@ static class TestGeometryDatabase { #endif } -} -} +} // namespace Rml diff --git a/Source/Core/GeometryDatabase.h b/Source/Core/GeometryDatabase.h index 8fe0fc3ef..35f718d95 100644 --- a/Source/Core/GeometryDatabase.h +++ b/Source/Core/GeometryDatabase.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREGEOMETRYDATABASE_H -#define RMLUICOREGEOMETRYDATABASE_H +#ifndef RMLUI_CORE_GEOMETRYDATABASE_H +#define RMLUI_CORE_GEOMETRYDATABASE_H #include namespace Rml { -namespace Core { class Geometry; using GeometryDatabaseHandle = uint32_t; @@ -55,7 +54,5 @@ namespace GeometryDatabase { } -} -} - +} // namespace Rml #endif diff --git a/Source/Core/GeometryUtilities.cpp b/Source/Core/GeometryUtilities.cpp index 9963a5e14..443963292 100644 --- a/Source/Core/GeometryUtilities.cpp +++ b/Source/Core/GeometryUtilities.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { GeometryUtilities::GeometryUtilities() { @@ -108,5 +107,4 @@ void GeometryUtilities::GenerateLine(FontFaceHandle font_face_handle, Geometry* ); } -} -} +} // namespace Rml diff --git a/Source/Core/IdNameMap.h b/Source/Core/IdNameMap.h index bc252c44e..a3676ea76 100644 --- a/Source/Core/IdNameMap.h +++ b/Source/Core/IdNameMap.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICOREIDNAMEMAP_H -#define RMLUICOREIDNAMEMAP_H +#ifndef RMLUI_CORE_IDNAMEMAP_H +#define RMLUI_CORE_IDNAMEMAP_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Types.h" #include namespace Rml { -namespace Core { template class IdNameMap { @@ -113,7 +112,5 @@ class ShorthandIdNameMap : public IdNameMap { ShorthandIdNameMap(size_t reserve_num_shorthands) : IdNameMap(reserve_num_shorthands) {} }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutBlockBox.cpp b/Source/Core/LayoutBlockBox.cpp index e6c158c3c..f76810758 100644 --- a/Source/Core/LayoutBlockBox.cpp +++ b/Source/Core/LayoutBlockBox.cpp @@ -37,7 +37,6 @@ #include namespace Rml { -namespace Core { // Creates a new block box for rendering a block element. LayoutBlockBox::LayoutBlockBox(LayoutEngine* _layout_engine, LayoutBlockBox* _parent, Element* _element) : position(0, 0) @@ -701,5 +700,4 @@ bool LayoutBlockBox::CatchVerticalOverflow(float cursor) return true; } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutBlockBox.h b/Source/Core/LayoutBlockBox.h index 28ae3a470..8b4f15392 100644 --- a/Source/Core/LayoutBlockBox.h +++ b/Source/Core/LayoutBlockBox.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELAYOUTBLOCKBOX_H -#define RMLUICORELAYOUTBLOCKBOX_H +#ifndef RMLUI_CORE_LAYOUTBLOCKBOX_H +#define RMLUI_CORE_LAYOUTBLOCKBOX_H #include "LayoutLineBox.h" #include "../../Include/RmlUi/Core/Box.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class LayoutBlockBoxSpace; class LayoutEngine; @@ -234,7 +233,5 @@ class LayoutBlockBox ElementList float_elements; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutBlockBoxSpace.cpp b/Source/Core/LayoutBlockBoxSpace.cpp index abec691fb..49421f5fd 100644 --- a/Source/Core/LayoutBlockBoxSpace.cpp +++ b/Source/Core/LayoutBlockBoxSpace.cpp @@ -34,7 +34,6 @@ #include namespace Rml { -namespace Core { LayoutBlockBoxSpace::LayoutBlockBoxSpace(LayoutBlockBox* _parent) : offset(0, 0), dimensions(0, 0) { @@ -286,5 +285,4 @@ LayoutBlockBoxSpace::SpaceBox::SpaceBox(const Vector2f& offset, const Vector2f& { } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutBlockBoxSpace.h b/Source/Core/LayoutBlockBoxSpace.h index 335eaf8f2..589eed79e 100644 --- a/Source/Core/LayoutBlockBoxSpace.h +++ b/Source/Core/LayoutBlockBoxSpace.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORELAYOUTBLOCKBOXSPACE_H -#define RMLUICORELAYOUTBLOCKBOXSPACE_H +#ifndef RMLUI_CORE_LAYOUTBLOCKBOXSPACE_H +#define RMLUI_CORE_LAYOUTBLOCKBOXSPACE_H #include "../../Include/RmlUi/Core/ComputedValues.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class Element; class LayoutBlockBox; @@ -124,7 +123,5 @@ class LayoutBlockBoxSpace Vector2f dimensions; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutEngine.cpp b/Source/Core/LayoutEngine.cpp index f900c1577..1cb96137d 100644 --- a/Source/Core/LayoutEngine.cpp +++ b/Source/Core/LayoutEngine.cpp @@ -41,7 +41,6 @@ #include namespace Rml { -namespace Core { #define MAX(a, b) (a > b ? a : b) @@ -690,5 +689,4 @@ void LayoutEngine::BuildBoxHeight(Box& box, const ComputedValues& computed, floa box.SetContent(content_area); } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutEngine.h b/Source/Core/LayoutEngine.h index 2451bf6da..c01ac8227 100644 --- a/Source/Core/LayoutEngine.h +++ b/Source/Core/LayoutEngine.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORELAYOUTENGINE_H -#define RMLUICORELAYOUTENGINE_H +#ifndef RMLUI_CORE_LAYOUTENGINE_H +#define RMLUI_CORE_LAYOUTENGINE_H #include "LayoutBlockBox.h" namespace Rml { -namespace Core { class Box; @@ -125,7 +124,5 @@ class LayoutEngine LayoutBlockBox* block_context_box; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutInlineBox.cpp b/Source/Core/LayoutInlineBox.cpp index 3bfe2885e..9288b7d3c 100644 --- a/Source/Core/LayoutInlineBox.cpp +++ b/Source/Core/LayoutInlineBox.cpp @@ -36,7 +36,6 @@ #include "../../Include/RmlUi/Core/Property.h" namespace Rml { -namespace Core { // Constructs a new inline box for an element. LayoutInlineBox::LayoutInlineBox(Element* _element, const Box& _box) : position(0, 0), box(_box) @@ -415,5 +414,4 @@ FontFaceHandle LayoutInlineBox::GetParentFont() const return parent->GetElement()->GetFontFaceHandle(); } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutInlineBox.h b/Source/Core/LayoutInlineBox.h index 566e21496..9a06a04d7 100644 --- a/Source/Core/LayoutInlineBox.h +++ b/Source/Core/LayoutInlineBox.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORELAYOUTINLINEBOX_H -#define RMLUICORELAYOUTINLINEBOX_H +#ifndef RMLUI_CORE_LAYOUTINLINEBOX_H +#define RMLUI_CORE_LAYOUTINLINEBOX_H #include "../../Include/RmlUi/Core/Box.h" #include "../../Include/RmlUi/Core/ComputedValues.h" namespace Rml { -namespace Core { class Element; class ElementText; @@ -173,7 +172,5 @@ class LayoutInlineBox bool chained; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutInlineBoxText.cpp b/Source/Core/LayoutInlineBoxText.cpp index 699b30d2d..bdb725e7f 100644 --- a/Source/Core/LayoutInlineBoxText.cpp +++ b/Source/Core/LayoutInlineBoxText.cpp @@ -38,7 +38,6 @@ #include "../../Include/RmlUi/Core/Profiling.h" namespace Rml { -namespace Core { LayoutInlineBoxText::LayoutInlineBoxText(Element* element, int _line_begin) : LayoutInlineBox(element, Box()) { @@ -167,5 +166,4 @@ void LayoutInlineBoxText::BuildWordBox() box.SetContent(content_area); } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutInlineBoxText.h b/Source/Core/LayoutInlineBoxText.h index d4a46a2c4..73114800a 100644 --- a/Source/Core/LayoutInlineBoxText.h +++ b/Source/Core/LayoutInlineBoxText.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORELAYOUTINLINEBOXTEXT_H -#define RMLUICORELAYOUTINLINEBOXTEXT_H +#ifndef RMLUI_CORE_LAYOUTINLINEBOXTEXT_H +#define RMLUI_CORE_LAYOUTINLINEBOXTEXT_H #include "LayoutInlineBox.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -92,7 +91,5 @@ class LayoutInlineBoxText : public LayoutInlineBox bool line_segmented; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/LayoutLineBox.cpp b/Source/Core/LayoutLineBox.cpp index cb40229e0..bf6f06fc6 100644 --- a/Source/Core/LayoutLineBox.cpp +++ b/Source/Core/LayoutLineBox.cpp @@ -37,7 +37,6 @@ #include namespace Rml { -namespace Core { static float GetSpacing(const Box& box, Box::Edge edge) { @@ -389,5 +388,4 @@ void LayoutLineBox::AppendBox(LayoutInlineBox* box) open_inline_box = box; } -} -} +} // namespace Rml diff --git a/Source/Core/LayoutLineBox.h b/Source/Core/LayoutLineBox.h index 9815f92f9..dcb1200a0 100644 --- a/Source/Core/LayoutLineBox.h +++ b/Source/Core/LayoutLineBox.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORELAYOUTLINEBOX_H -#define RMLUICORELAYOUTLINEBOX_H +#ifndef RMLUI_CORE_LAYOUTLINEBOX_H +#define RMLUI_CORE_LAYOUTLINEBOX_H #include "LayoutInlineBox.h" namespace Rml { -namespace Core { class LayoutBlockBox; @@ -120,7 +119,5 @@ class LayoutLineBox LayoutInlineBox* open_inline_box; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Log.cpp b/Source/Core/Log.cpp index c3eee714f..eaef6459c 100644 --- a/Source/Core/Log.cpp +++ b/Source/Core/Log.cpp @@ -37,7 +37,6 @@ #endif namespace Rml { -namespace Core { // Initialises the logging interface. bool Log::Initialise() @@ -95,9 +94,8 @@ void Log::ParseError(const String& filename, int line_number, const char* fmt, . bool Assert(const char* msg, const char* file, int line) { - Rml::Core::String message = CreateString(1024, "%s\n%s:%d", msg, file, line); + String message = CreateString(1024, "%s\n%s:%d", msg, file, line); return GetSystemInterface()->LogMessage(Log::LT_ASSERT, message); } -} -} +} // namespace Rml diff --git a/Source/Core/Lua/Interpreter.cpp b/Source/Core/Lua/Interpreter.cpp deleted file mode 100644 index bfde9f495..000000000 --- a/Source/Core/Lua/Interpreter.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "precompiled.h" -#include -#include -#include -#include -#include -#include "LuaDocumentElementInstancer.h" -#include -#include "LuaEventListenerInstancer.h" -#include "RmlUi.h" -//the types I made -#include "ContextDocumentsProxy.h" -#include "EventParametersProxy.h" -#include "ElementAttributesProxy.h" -#include "Log.h" -#include "Element.h" -#include "ElementStyleProxy.h" -#include "Document.h" -#include "Colourb.h" -#include "Colourf.h" -#include "Vector2f.h" -#include "Vector2i.h" -#include "Context.h" -#include "Event.h" -#include "ElementInstancer.h" -#include "ElementChildNodesProxy.h" -#include "ElementText.h" -#include "GlobalLuaFunctions.h" -#include "RmlUiContextsProxy.h" - -namespace Rml { -namespace Core { -namespace Lua { - -static lua_State* g_L = nullptr; - -//typedefs for nicer Lua names -typedef Rml::Core::ElementDocument Document; - - -void Interpreter::Initialise() -{ - Rml::Core::Lua::Interpreter::Initialise(nullptr); -} - -void Interpreter::Initialise(lua_State* luaStatePointer) -{ - RMLUI_ASSERT(g_L == nullptr); - g_L = luaStatePointer; - Rml::Core::RegisterPlugin(new Interpreter()); -} - -lua_State* Interpreter::GetLuaState() -{ - return g_L; -} - - -void Interpreter::LoadFile(const String& file) -{ - //use the file interface to get the contents of the script - Rml::Core::FileInterface* file_interface = Rml::Core::GetFileInterface(); - Rml::Core::FileHandle handle = file_interface->Open(file); - if(handle == 0) { - lua_pushfstring(g_L, "LoadFile: Unable to open file: %s", file.c_str()); - Report(g_L); - return; - } - - size_t size = file_interface->Length(handle); - if(size == 0) { - lua_pushfstring(g_L, "LoadFile: File is 0 bytes in size: %s", file.c_str()); - Report(g_L); - return; - } - char* file_contents = new char[size]; - file_interface->Read(file_contents,size,handle); - file_interface->Close(handle); - - if(luaL_loadbuffer(g_L,file_contents,size,file.c_str()) != 0) - Report(g_L); - else //if there were no errors loading, then the compiled function is on the top of the stack - { - if(lua_pcall(g_L,0,0,0) != 0) - Report(g_L); - } - - delete[] file_contents; -} - - -void Interpreter::DoString(const Rml::Core::String& code, const Rml::Core::String& name) -{ - if(luaL_loadbuffer(g_L,code.c_str(),code.length(), name.c_str()) != 0) - Report(g_L); - else - { - if(lua_pcall(g_L,0,0,0) != 0) - Report(g_L); - } -} - -void Interpreter::LoadString(const Rml::Core::String& code, const Rml::Core::String& name) -{ - if(luaL_loadbuffer(g_L,code.c_str(),code.length(), name.c_str()) != 0) - Report(g_L); -} - - -void Interpreter::BeginCall(int funRef) -{ - lua_settop(g_L,0); //empty stack - //lua_getref(g_L,funRef); - lua_rawgeti(g_L, LUA_REGISTRYINDEX, (int)funRef); -} - -bool Interpreter::ExecuteCall(int params, int res) -{ - bool ret = true; - int top = lua_gettop(g_L); - if(lua_type(g_L,top-params) != LUA_TFUNCTION) - { - ret = false; - //stack cleanup - if(params > 0) - { - for(int i = top; i >= (top-params); i--) - { - if(!lua_isnone(g_L,i)) - lua_remove(g_L,i); - } - } - } - else - { - if(lua_pcall(g_L,params,res,0) != 0) - { - Report(g_L); - ret = false; - } - } - return ret; -} - -void Interpreter::EndCall(int res) -{ - //stack cleanup - for(int i = res; i > 0; i--) - { - if(!lua_isnone(g_L,res)) - lua_remove(g_L,res); - } -} - - -//From Plugin -int Interpreter::GetEventClasses() -{ - return EVT_BASIC; -} - -void Interpreter::OnInitialise() -{ - if (g_L == nullptr) - { - Log::Message(Log::LT_INFO, "Loading Lua interpreter"); - g_L = luaL_newstate(); - luaL_openlibs(g_L); - owns_lua_state = true; - } - else - { - owns_lua_state = false; - } - RegisterCoreTypes(g_L); - - lua_document_element_instancer = new LuaDocumentElementInstancer(); - lua_event_listener_instancer = new LuaEventListenerInstancer(); - Factory::RegisterElementInstancer("body", lua_document_element_instancer); - Factory::RegisterEventListenerInstancer(lua_event_listener_instancer); -} - -void Interpreter::OnShutdown() -{ - delete lua_document_element_instancer; - delete lua_event_listener_instancer; - lua_document_element_instancer = nullptr; - lua_event_listener_instancer = nullptr; - - if (owns_lua_state) - lua_close(g_L); - - g_L = nullptr; - - delete this; -} - -void Interpreter::RegisterCoreTypes(lua_State* L) -{ - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - //things that inherit from Element - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - //Proxy tables - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - LuaType::Register(L); - OverrideLuaGlobalFunctions(L); - //push the global variable "rmlui" to use the "RmlUi" methods - LuaRmlUiPushrmluiGlobal(L); -} - - - -} -} -} diff --git a/Source/Core/Lua/precompiled.cpp b/Source/Core/Lua/precompiled.cpp deleted file mode 100644 index 3b9b2f47c..000000000 --- a/Source/Core/Lua/precompiled.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "precompiled.h" \ No newline at end of file diff --git a/Source/Core/Lua/precompiled.h b/Source/Core/Lua/precompiled.h deleted file mode 100644 index 64488ae29..000000000 --- a/Source/Core/Lua/precompiled.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICORELUAPRECOMPILED_H -#define RMLUICORELUAPRECOMPILED_H - -#include -#include -#include -#include -#endif diff --git a/Source/Core/Math.cpp b/Source/Core/Math.cpp index 4a1b59038..70593fd99 100644 --- a/Source/Core/Math.cpp +++ b/Source/Core/Math.cpp @@ -32,7 +32,7 @@ #include namespace Rml { -namespace Core { + namespace Math { const float RMLUI_PI = 3.141592653f; @@ -217,5 +217,4 @@ RMLUICORE_API bool RandomBool() } } -} -} +} // namespace Rml diff --git a/Source/Core/Memory.cpp b/Source/Core/Memory.cpp index 7431113c3..407c1c1f2 100644 --- a/Source/Core/Memory.cpp +++ b/Source/Core/Memory.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { namespace Detail { @@ -95,5 +94,4 @@ BasicStackAllocator& GetGlobalBasicStackAllocator() } -} -} +} // namespace Rml diff --git a/Source/Core/Memory.h b/Source/Core/Memory.h index e76c5cd6d..6766ffd89 100644 --- a/Source/Core/Memory.h +++ b/Source/Core/Memory.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICOREMEMORY_H -#define RMLUICOREMEMORY_H +#ifndef RMLUI_CORE_MEMORY_H +#define RMLUI_CORE_MEMORY_H #include "../../Include/RmlUi/Core/Types.h" #include "../../Include/RmlUi/Core/Traits.h" namespace Rml { -namespace Core { - namespace Detail { @@ -137,7 +135,5 @@ class DynamicArray : Alloc, NonCopyMoveable { T* p; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/ObserverPtr.cpp b/Source/Core/ObserverPtr.cpp index eb53ca92e..74af58713 100644 --- a/Source/Core/ObserverPtr.cpp +++ b/Source/Core/ObserverPtr.cpp @@ -30,8 +30,6 @@ #include "Pool.h" namespace Rml { -namespace Core { - static Pool< ObserverPtrBlock >& GetPool() { @@ -56,5 +54,4 @@ ObserverPtrBlock* AllocateObserverPtrBlock() -} -} +} // namespace Rml diff --git a/Source/Core/Plugin.cpp b/Source/Core/Plugin.cpp index ff1486054..9c3e49398 100644 --- a/Source/Core/Plugin.cpp +++ b/Source/Core/Plugin.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/Plugin.h" namespace Rml { -namespace Core { Plugin::~Plugin() { @@ -92,5 +91,4 @@ void Plugin::OnElementDestroy(Element* RMLUI_UNUSED_PARAMETER(element)) RMLUI_UNUSED(element); } -} -} +} // namespace Rml diff --git a/Source/Core/PluginRegistry.cpp b/Source/Core/PluginRegistry.cpp index cb2bd0241..47c4615d4 100644 --- a/Source/Core/PluginRegistry.cpp +++ b/Source/Core/PluginRegistry.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/Plugin.h" namespace Rml { -namespace Core { typedef std::vector< Plugin* > PluginList; static PluginList basic_plugins; @@ -121,5 +120,4 @@ void PluginRegistry::NotifyElementDestroy(Element* element) element_plugins[i]->OnElementDestroy(element); } -} -} +} // namespace Rml diff --git a/Source/Core/PluginRegistry.h b/Source/Core/PluginRegistry.h index 20c6c32d2..4acb17716 100644 --- a/Source/Core/PluginRegistry.h +++ b/Source/Core/PluginRegistry.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREPLUGINREGISTRY_H -#define RMLUICOREPLUGINREGISTRY_H +#ifndef RMLUI_CORE_PLUGINREGISTRY_H +#define RMLUI_CORE_PLUGINREGISTRY_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class Context; class Element; @@ -74,7 +73,5 @@ class PluginRegistry PluginRegistry(); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Pool.h b/Source/Core/Pool.h index 8a79adbdb..992000a55 100644 --- a/Source/Core/Pool.h +++ b/Source/Core/Pool.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREPOOL_H -#define RMLUICOREPOOL_H +#ifndef RMLUI_CORE_POOL_H +#define RMLUI_CORE_POOL_H #include "../../Include/RmlUi/Core/Header.h" #include "../../Include/RmlUi/Core/Debug.h" @@ -35,7 +35,6 @@ #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { template < typename PoolType > class Pool @@ -150,8 +149,7 @@ class Pool int num_allocated_objects; }; -} -} +} // namespace Rml #include "Pool.inl" diff --git a/Source/Core/Pool.inl b/Source/Core/Pool.inl index ff663d857..fc6160738 100644 --- a/Source/Core/Pool.inl +++ b/Source/Core/Pool.inl @@ -29,7 +29,6 @@ namespace Rml { -namespace Core { template < typename PoolType > Pool< PoolType >::Pool(int _chunk_size, bool _grow) @@ -253,5 +252,4 @@ void Pool< PoolType >::CreateChunk() first_free_node = new_chunk->chunk; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertiesIterator.h b/Source/Core/PropertiesIterator.h index bffb2ee2f..52dc5b7b2 100644 --- a/Source/Core/PropertiesIterator.h +++ b/Source/Core/PropertiesIterator.h @@ -25,16 +25,13 @@ * THE SOFTWARE. * */ -#ifndef RMLUICOREPROPERTIESITERATOR_H -#define RMLUICOREPROPERTIESITERATOR_H +#ifndef RMLUI_CORE_PROPERTIESITERATOR_H +#define RMLUI_CORE_PROPERTIESITERATOR_H #include "../../Include/RmlUi/Core/Types.h" #include "../../Include/RmlUi/Core/PropertyIdSet.h" namespace Rml { -namespace Core { - - // An iterator for local properties defined on an element. // Note: Modifying the underlying style invalidates the iterator. @@ -108,7 +105,5 @@ class PropertiesIterator { }; -} -} - +} // namespace Rml #endif \ No newline at end of file diff --git a/Source/Core/PropertiesIteratorView.cpp b/Source/Core/PropertiesIteratorView.cpp index d85a8a733..8353317bc 100644 --- a/Source/Core/PropertiesIteratorView.cpp +++ b/Source/Core/PropertiesIteratorView.cpp @@ -31,9 +31,6 @@ #include "PropertiesIterator.h" namespace Rml { -namespace Core { - - PropertiesIteratorView::PropertiesIteratorView(UniquePtr ptr) : ptr(std::move(ptr)) {} @@ -61,7 +58,7 @@ PropertyId PropertiesIteratorView::GetId() const const String& PropertiesIteratorView::GetName() const { - return Core::StyleSheetSpecification::GetPropertyName(GetId()); + return StyleSheetSpecification::GetPropertyName(GetId()); } const Property& PropertiesIteratorView::GetProperty() const @@ -73,5 +70,4 @@ bool PropertiesIteratorView::AtEnd() const { return ptr->AtEnd(); } -} -} +} // namespace Rml diff --git a/Source/Core/Property.cpp b/Source/Core/Property.cpp index 71531c35b..edcce6c09 100644 --- a/Source/Core/Property.cpp +++ b/Source/Core/Property.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/PropertyDefinition.h" namespace Rml { -namespace Core { Property::Property() : unit(UNKNOWN), specificity(-1) { @@ -48,5 +47,4 @@ String Property::ToString() const return string; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyDefinition.cpp b/Source/Core/PropertyDefinition.cpp index 45485755d..981ff42f4 100644 --- a/Source/Core/PropertyDefinition.cpp +++ b/Source/Core/PropertyDefinition.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/StyleSheetSpecification.h" namespace Rml { -namespace Core { PropertyDefinition::PropertyDefinition(PropertyId id, const String& _default_value, bool _inherited, bool _forces_layout) : id(id), default_value(_default_value, Property::UNKNOWN), relative_target(RelativeTarget::None) @@ -209,5 +208,4 @@ PropertyDefinition & PropertyDefinition::SetRelativeTarget(RelativeTarget relati return *this; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyDictionary.cpp b/Source/Core/PropertyDictionary.cpp index 75e832bd3..f44ad9d07 100644 --- a/Source/Core/PropertyDictionary.cpp +++ b/Source/Core/PropertyDictionary.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ID.h" namespace Rml { -namespace Core { PropertyDictionary::PropertyDictionary() { @@ -99,7 +98,7 @@ void PropertyDictionary::SetSourceOfAllProperties(const SharedPtr namespace Rml { -namespace Core { PropertyParserColour::PropertyParserColour() { @@ -170,5 +169,4 @@ bool PropertyParserColour::ParseValue(Property& property, const String& value, c return true; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyParserColour.h b/Source/Core/PropertyParserColour.h index c82bec59d..fe21ed870 100644 --- a/Source/Core/PropertyParserColour.h +++ b/Source/Core/PropertyParserColour.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPROPERTYPARSERCOLOUR_H -#define RMLUICOREPROPERTYPARSERCOLOUR_H +#ifndef RMLUI_CORE_PROPERTYPARSERCOLOUR_H +#define RMLUI_CORE_PROPERTYPARSERCOLOUR_H #include "../../Include/RmlUi/Core/PropertyParser.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { /** A property parser that parses a colour value. @@ -59,7 +58,5 @@ class PropertyParserColour : public PropertyParser ColourMap html_colours; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertyParserKeyword.cpp b/Source/Core/PropertyParserKeyword.cpp index af9fe1f5b..adac8bc4a 100644 --- a/Source/Core/PropertyParserKeyword.cpp +++ b/Source/Core/PropertyParserKeyword.cpp @@ -29,7 +29,6 @@ #include "PropertyParserKeyword.h" namespace Rml { -namespace Core { PropertyParserKeyword::PropertyParserKeyword() { @@ -52,5 +51,4 @@ bool PropertyParserKeyword::ParseValue(Property& property, const String& value, return true; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyParserKeyword.h b/Source/Core/PropertyParserKeyword.h index 2197037c7..77578ab4c 100644 --- a/Source/Core/PropertyParserKeyword.h +++ b/Source/Core/PropertyParserKeyword.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREPROPERTYPARSERKEYWORD_H -#define RMLUICOREPROPERTYPARSERKEYWORD_H +#ifndef RMLUI_CORE_PROPERTYPARSERKEYWORD_H +#define RMLUI_CORE_PROPERTYPARSERKEYWORD_H #include "../../Include/RmlUi/Core/PropertyParser.h" namespace Rml { -namespace Core { /** A property parser that validates a value is part of a specified list of keywords. @@ -54,7 +53,5 @@ class PropertyParserKeyword : public PropertyParser bool ParseValue(Property& property, const String& value, const ParameterMap& parameters) const override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertyParserNumber.cpp b/Source/Core/PropertyParserNumber.cpp index 48feaa303..ccf0ba3e8 100644 --- a/Source/Core/PropertyParserNumber.cpp +++ b/Source/Core/PropertyParserNumber.cpp @@ -30,7 +30,6 @@ #include namespace Rml { -namespace Core { static const UnorderedMap g_property_unit_string_map = { @@ -115,5 +114,4 @@ bool PropertyParserNumber::ParseValue(Property& property, const String& value, c return false; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyParserNumber.h b/Source/Core/PropertyParserNumber.h index b8356e93a..98f6d02b6 100644 --- a/Source/Core/PropertyParserNumber.h +++ b/Source/Core/PropertyParserNumber.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREPROPERTYPARSERNUMBER_H -#define RMLUICOREPROPERTYPARSERNUMBER_H +#ifndef RMLUI_CORE_PROPERTYPARSERNUMBER_H +#define RMLUI_CORE_PROPERTYPARSERNUMBER_H #include "../../Include/RmlUi/Core/PropertyParser.h" namespace Rml { -namespace Core { /** A property parser that parses a floating-point number with an optional unit. @@ -61,7 +60,5 @@ class PropertyParserNumber : public PropertyParser Property::Unit zero_unit; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertyParserString.cpp b/Source/Core/PropertyParserString.cpp index f1e7f1d55..4cc3223d9 100644 --- a/Source/Core/PropertyParserString.cpp +++ b/Source/Core/PropertyParserString.cpp @@ -29,7 +29,6 @@ #include "PropertyParserString.h" namespace Rml { -namespace Core { PropertyParserString::PropertyParserString() { @@ -50,5 +49,4 @@ bool PropertyParserString::ParseValue(Property& property, const String& value, c return true; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyParserString.h b/Source/Core/PropertyParserString.h index 3a3122635..15c4bb987 100644 --- a/Source/Core/PropertyParserString.h +++ b/Source/Core/PropertyParserString.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREPROPERTYPARSERSTRING_H -#define RMLUICOREPROPERTYPARSERSTRING_H +#ifndef RMLUI_CORE_PROPERTYPARSERSTRING_H +#define RMLUI_CORE_PROPERTYPARSERSTRING_H #include "../../Include/RmlUi/Core/PropertyParser.h" namespace Rml { -namespace Core { /** A passthrough property parser that parses a string. @@ -54,7 +53,5 @@ class PropertyParserString : public PropertyParser bool ParseValue(Property& property, const String& value, const ParameterMap& parameters) const override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertyParserTransform.cpp b/Source/Core/PropertyParserTransform.cpp index c2a9017f0..05a47536f 100644 --- a/Source/Core/PropertyParserTransform.cpp +++ b/Source/Core/PropertyParserTransform.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { PropertyParserTransform::PropertyParserTransform() : number(Property::NUMBER), @@ -291,5 +290,4 @@ bool PropertyParserTransform::Scan(int& out_bytes_read, const char* str, const c return total_bytes_read > 0; } -} -} +} // namespace Rml diff --git a/Source/Core/PropertyParserTransform.h b/Source/Core/PropertyParserTransform.h index 013e4130a..eb29a22ff 100644 --- a/Source/Core/PropertyParserTransform.h +++ b/Source/Core/PropertyParserTransform.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREPROPERTYPARSERTRANSFORM_H -#define RMLUICOREPROPERTYPARSERTRANSFORM_H +#ifndef RMLUI_CORE_PROPERTYPARSERTRANSFORM_H +#define RMLUI_CORE_PROPERTYPARSERTRANSFORM_H #include "../../Include/RmlUi/Core/PropertyParser.h" #include "PropertyParserNumber.h" namespace Rml { -namespace Core { namespace Transforms { struct NumericValue; } @@ -70,7 +69,5 @@ class PropertyParserTransform : public PropertyParser PropertyParserNumber number, length, angle; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertyShorthandDefinition.h b/Source/Core/PropertyShorthandDefinition.h index 4bc8d97d2..486ff2e89 100644 --- a/Source/Core/PropertyShorthandDefinition.h +++ b/Source/Core/PropertyShorthandDefinition.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREPROPERTYSHORTHANDDEFINITION_H -#define RMLUICOREPROPERTYSHORTHANDDEFINITION_H +#ifndef RMLUI_CORE_PROPERTYSHORTHANDDEFINITION_H +#define RMLUI_CORE_PROPERTYSHORTHANDDEFINITION_H #include "../../Include/RmlUi/Core/ID.h" namespace Rml { -namespace Core { enum class ShorthandType; class PropertyDefinition; @@ -68,7 +67,5 @@ struct ShorthandDefinition ShorthandType type; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/PropertySpecification.cpp b/Source/Core/PropertySpecification.cpp index 3ddacfe56..391af32da 100644 --- a/Source/Core/PropertySpecification.cpp +++ b/Source/Core/PropertySpecification.cpp @@ -38,8 +38,6 @@ #include namespace Rml { -namespace Core { - PropertySpecification::PropertySpecification(size_t reserve_num_properties, size_t reserve_num_shorthands) : // Increment reserve numbers by one because the 'invalid' property occupies the first element @@ -571,5 +569,4 @@ bool PropertySpecification::ParsePropertyValues(StringList& values_list, const S return true; } -} -} +} // namespace Rml diff --git a/Source/Core/RenderInterface.cpp b/Source/Core/RenderInterface.cpp index 6c940d656..001d3fe5a 100644 --- a/Source/Core/RenderInterface.cpp +++ b/Source/Core/RenderInterface.cpp @@ -30,7 +30,6 @@ #include "TextureDatabase.h" namespace Rml { -namespace Core { RenderInterface::RenderInterface() { @@ -86,5 +85,4 @@ Context* RenderInterface::GetContext() const return context; } -} -} +} // namespace Rml diff --git a/Source/Core/Spritesheet.cpp b/Source/Core/Spritesheet.cpp index 1051541e1..dd38c2726 100644 --- a/Source/Core/Spritesheet.cpp +++ b/Source/Core/Spritesheet.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/Log.h" namespace Rml { -namespace Core { bool SpritesheetList::AddSpriteSheet(const String& name, const String& image_source, const String& definition_source, int definition_line_number, const SpriteDefinitionList& sprite_definitions) { @@ -153,5 +152,4 @@ String SpritesheetList::ToString() const return result; } -} -} +} // namespace Rml diff --git a/Source/Core/Stream.cpp b/Source/Core/Stream.cpp index f13e8bead..3287ab03d 100644 --- a/Source/Core/Stream.cpp +++ b/Source/Core/Stream.cpp @@ -31,7 +31,6 @@ #include namespace Rml { -namespace Core { const size_t READ_BLOCK_SIZE = 1024; @@ -82,7 +81,7 @@ size_t Stream::Read(Stream* stream, size_t bytes) const size_t total_bytes_read = 0; while (total_bytes_read < bytes) { - size_t bytes_read = this->Read(buffer, Core::Math::Min(READ_BLOCK_SIZE, bytes - total_bytes_read)); + size_t bytes_read = this->Read(buffer, Math::Min(READ_BLOCK_SIZE, bytes - total_bytes_read)); if (bytes_read < 1) return total_bytes_read; stream->Write(buffer, bytes_read); @@ -160,5 +159,4 @@ void Stream::SetStreamDetails(const URL& _url, int _stream_mode) stream_mode = _stream_mode; } -} -} +} // namespace Rml diff --git a/Source/Core/StreamFile.cpp b/Source/Core/StreamFile.cpp index 7a28d93e4..926a8b597 100644 --- a/Source/Core/StreamFile.cpp +++ b/Source/Core/StreamFile.cpp @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/StringUtilities.h" namespace Rml { -namespace Core { StreamFile::StreamFile() { @@ -141,5 +140,4 @@ void StreamFile::GetLength() length = GetFileInterface()->Length(file_handle); } -} -} +} // namespace Rml diff --git a/Source/Core/StreamFile.h b/Source/Core/StreamFile.h index e0fac610a..a2b9ace32 100644 --- a/Source/Core/StreamFile.h +++ b/Source/Core/StreamFile.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORESTREAMFILE_H -#define RMLUICORESTREAMFILE_H +#ifndef RMLUI_CORE_STREAMFILE_H +#define RMLUI_CORE_STREAMFILE_H #include "../../Include/RmlUi/Core/Stream.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { /** @author Peter Curry @@ -82,7 +81,5 @@ class StreamFile : public Stream size_t length; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StreamMemory.cpp b/Source/Core/StreamMemory.cpp index 8f1ec58b0..e53bb8366 100644 --- a/Source/Core/StreamMemory.cpp +++ b/Source/Core/StreamMemory.cpp @@ -31,7 +31,6 @@ #include namespace Rml { -namespace Core { const int DEFAULT_BUFFER_SIZE = 256; const int BUFFER_INCREMENTS = 256; @@ -234,5 +233,4 @@ bool StreamMemory::Reallocate( size_t size ) return true; } -} -} +} // namespace Rml diff --git a/Source/Core/StringUtilities.cpp b/Source/Core/StringUtilities.cpp index 6d24e2948..4c6f6d369 100644 --- a/Source/Core/StringUtilities.cpp +++ b/Source/Core/StringUtilities.cpp @@ -34,8 +34,6 @@ #include namespace Rml { -namespace Core { - static int FormatString(String& string, size_t max_size, const char* format, va_list argument_list) { @@ -606,5 +604,4 @@ inline void StringIteratorU8::SeekForward() { p = StringUtilities::SeekForwardUTF8(p, view.end()); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheet.cpp b/Source/Core/StyleSheet.cpp index 5a2f536c5..e81acaa7d 100644 --- a/Source/Core/StyleSheet.cpp +++ b/Source/Core/StyleSheet.cpp @@ -43,7 +43,6 @@ #include namespace Rml { -namespace Core { // Sorts style nodes based on specificity. inline static bool StyleSheetNodeSort(const StyleSheetNode* lhs, const StyleSheetNode* rhs) @@ -397,5 +396,4 @@ SharedPtr StyleSheet::GetElementDefinition(const Element* ele return new_definition; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetFactory.cpp b/Source/Core/StyleSheetFactory.cpp index 11b9229d8..4b523a31e 100644 --- a/Source/Core/StyleSheetFactory.cpp +++ b/Source/Core/StyleSheetFactory.cpp @@ -44,7 +44,6 @@ #include "../../Include/RmlUi/Core/Log.h" namespace Rml { -namespace Core { static StyleSheetFactory* instance = nullptr; @@ -259,5 +258,4 @@ SharedPtr StyleSheetFactory::LoadStyleSheet(const String& sheet) return new_style_sheet; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetFactory.h b/Source/Core/StyleSheetFactory.h index aaba26c23..b9e86b6b3 100644 --- a/Source/Core/StyleSheetFactory.h +++ b/Source/Core/StyleSheetFactory.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETFACTORY_H -#define RMLUICORESTYLESHEETFACTORY_H +#ifndef RMLUI_CORE_STYLESHEETFACTORY_H +#define RMLUI_CORE_STYLESHEETFACTORY_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class StyleSheet; class StyleSheetNodeSelector; @@ -88,7 +87,5 @@ class StyleSheetFactory SelectorMap selectors; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNode.cpp b/Source/Core/StyleSheetNode.cpp index 1777e6763..7a4a3b905 100644 --- a/Source/Core/StyleSheetNode.cpp +++ b/Source/Core/StyleSheetNode.cpp @@ -34,7 +34,6 @@ #include namespace Rml { -namespace Core { StyleSheetNode::StyleSheetNode() { @@ -330,5 +329,4 @@ void StyleSheetNode::CalculateAndSetSpecificity() specificity += parent->specificity; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNode.h b/Source/Core/StyleSheetNode.h index ca6d0c7b9..10b0a54ad 100644 --- a/Source/Core/StyleSheetNode.h +++ b/Source/Core/StyleSheetNode.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICORESTYLESHEETNODE_H -#define RMLUICORESTYLESHEETNODE_H +#ifndef RMLUI_CORE_STYLESHEETNODE_H +#define RMLUI_CORE_STYLESHEETNODE_H #include "../../Include/RmlUi/Core/PropertyDictionary.h" #include "../../Include/RmlUi/Core/StyleSheet.h" @@ -35,7 +35,6 @@ #include namespace Rml { -namespace Core { class StyleSheetNodeSelector; @@ -130,7 +129,5 @@ class StyleSheetNode StyleSheetNodeList children; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelector.cpp b/Source/Core/StyleSheetNodeSelector.cpp index 2ac90c654..6d87daa23 100644 --- a/Source/Core/StyleSheetNodeSelector.cpp +++ b/Source/Core/StyleSheetNodeSelector.cpp @@ -29,7 +29,6 @@ #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { StyleSheetNodeSelector::StyleSheetNodeSelector() { @@ -50,5 +49,4 @@ bool StyleSheetNodeSelector::IsNth(int a, int b, int count) return (x >= 0 && x * a + b == count); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelector.h b/Source/Core/StyleSheetNodeSelector.h index 58d62ba37..9c9d83a50 100644 --- a/Source/Core/StyleSheetNodeSelector.h +++ b/Source/Core/StyleSheetNodeSelector.h @@ -26,11 +26,10 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTOR_H -#define RMLUICORESTYLESHEETNODESELECTOR_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTOR_H +#define RMLUI_CORE_STYLESHEETNODESELECTOR_H namespace Rml { -namespace Core { class Element; @@ -57,7 +56,5 @@ class StyleSheetNodeSelector bool IsNth(int a, int b, int count); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorEmpty.cpp b/Source/Core/StyleSheetNodeSelectorEmpty.cpp index 775ee2e18..f58cec11c 100644 --- a/Source/Core/StyleSheetNodeSelectorEmpty.cpp +++ b/Source/Core/StyleSheetNodeSelectorEmpty.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorEmpty::StyleSheetNodeSelectorEmpty() { @@ -55,5 +54,4 @@ bool StyleSheetNodeSelectorEmpty::IsApplicable(const Element* element, int RMLUI return true; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorEmpty.h b/Source/Core/StyleSheetNodeSelectorEmpty.h index f038c2f49..dc28e6d9d 100644 --- a/Source/Core/StyleSheetNodeSelectorEmpty.h +++ b/Source/Core/StyleSheetNodeSelectorEmpty.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTOREMPTY_H -#define RMLUICORESTYLESHEETNODESELECTOREMPTY_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTOREMPTY_H +#define RMLUI_CORE_STYLESHEETNODESELECTOREMPTY_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for an empty node. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorEmpty : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorFirstChild.cpp b/Source/Core/StyleSheetNodeSelectorFirstChild.cpp index 5ab84f41d..9c62d92fe 100644 --- a/Source/Core/StyleSheetNodeSelectorFirstChild.cpp +++ b/Source/Core/StyleSheetNodeSelectorFirstChild.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorFirstChild::StyleSheetNodeSelectorFirstChild() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorFirstChild::IsApplicable(const Element* element, int return false; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorFirstChild.h b/Source/Core/StyleSheetNodeSelectorFirstChild.h index 0f187e8cf..ab752248f 100644 --- a/Source/Core/StyleSheetNodeSelectorFirstChild.h +++ b/Source/Core/StyleSheetNodeSelectorFirstChild.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORFIRSTCHILD_H -#define RMLUICORESTYLESHEETNODESELECTORFIRSTCHILD_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORFIRSTCHILD_H +#define RMLUI_CORE_STYLESHEETNODESELECTORFIRSTCHILD_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the first generic child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorFirstChild : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorFirstOfType.cpp b/Source/Core/StyleSheetNodeSelectorFirstOfType.cpp index b0aa6ef45..73dc70cc3 100644 --- a/Source/Core/StyleSheetNodeSelectorFirstOfType.cpp +++ b/Source/Core/StyleSheetNodeSelectorFirstOfType.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorFirstOfType::StyleSheetNodeSelectorFirstOfType() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorFirstOfType::IsApplicable(const Element* element, int return false; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorFirstOfType.h b/Source/Core/StyleSheetNodeSelectorFirstOfType.h index dd987dbcd..eb7af45b4 100644 --- a/Source/Core/StyleSheetNodeSelectorFirstOfType.h +++ b/Source/Core/StyleSheetNodeSelectorFirstOfType.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORFIRSTOFTYPE_H -#define RMLUICORESTYLESHEETNODESELECTORFIRSTOFTYPE_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORFIRSTOFTYPE_H +#define RMLUI_CORE_STYLESHEETNODESELECTORFIRSTOFTYPE_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the first child of its type. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorFirstOfType : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorLastChild.cpp b/Source/Core/StyleSheetNodeSelectorLastChild.cpp index c4ab1a53a..29f436324 100644 --- a/Source/Core/StyleSheetNodeSelectorLastChild.cpp +++ b/Source/Core/StyleSheetNodeSelectorLastChild.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorLastChild::StyleSheetNodeSelectorLastChild() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorLastChild::IsApplicable(const Element* element, int R return false; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorLastChild.h b/Source/Core/StyleSheetNodeSelectorLastChild.h index adf5516b0..06a110560 100644 --- a/Source/Core/StyleSheetNodeSelectorLastChild.h +++ b/Source/Core/StyleSheetNodeSelectorLastChild.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORLASTCHILD_H -#define RMLUICORESTYLESHEETNODESELECTORLASTCHILD_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORLASTCHILD_H +#define RMLUI_CORE_STYLESHEETNODESELECTORLASTCHILD_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the last generic child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorLastChild : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorLastOfType.cpp b/Source/Core/StyleSheetNodeSelectorLastOfType.cpp index e34842a03..0044f63a6 100644 --- a/Source/Core/StyleSheetNodeSelectorLastOfType.cpp +++ b/Source/Core/StyleSheetNodeSelectorLastOfType.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/Element.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorLastOfType::StyleSheetNodeSelectorLastOfType() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorLastOfType::IsApplicable(const Element* element, int return false; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorLastOfType.h b/Source/Core/StyleSheetNodeSelectorLastOfType.h index c393dee6e..3837f3d19 100644 --- a/Source/Core/StyleSheetNodeSelectorLastOfType.h +++ b/Source/Core/StyleSheetNodeSelectorLastOfType.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORLASTOFTYPE_H -#define RMLUICORESTYLESHEETNODESELECTORLASTOFTYPE_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORLASTOFTYPE_H +#define RMLUI_CORE_STYLESHEETNODESELECTORLASTOFTYPE_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the first child of its type. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorLastOfType : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorNthChild.cpp b/Source/Core/StyleSheetNodeSelectorNthChild.cpp index fbb21f5a6..2facbad70 100644 --- a/Source/Core/StyleSheetNodeSelectorNthChild.cpp +++ b/Source/Core/StyleSheetNodeSelectorNthChild.cpp @@ -31,7 +31,6 @@ #include "../../Include/RmlUi/Core/Log.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorNthChild::StyleSheetNodeSelectorNthChild() { @@ -72,5 +71,4 @@ bool StyleSheetNodeSelectorNthChild::IsApplicable(const Element* element, int a, return IsNth(a, b, element_index); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorNthChild.h b/Source/Core/StyleSheetNodeSelectorNthChild.h index 3654c147c..925358fb8 100644 --- a/Source/Core/StyleSheetNodeSelectorNthChild.h +++ b/Source/Core/StyleSheetNodeSelectorNthChild.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORNTHCHILD_H -#define RMLUICORESTYLESHEETNODESELECTORNTHCHILD_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORNTHCHILD_H +#define RMLUI_CORE_STYLESHEETNODESELECTORNTHCHILD_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the nth generic child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorNthChild : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorNthLastChild.cpp b/Source/Core/StyleSheetNodeSelectorNthLastChild.cpp index add8a8504..bb1a8e926 100644 --- a/Source/Core/StyleSheetNodeSelectorNthLastChild.cpp +++ b/Source/Core/StyleSheetNodeSelectorNthLastChild.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorNthLastChild::StyleSheetNodeSelectorNthLastChild() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorNthLastChild::IsApplicable(const Element* element, in return IsNth(a, b, element_index); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorNthLastChild.h b/Source/Core/StyleSheetNodeSelectorNthLastChild.h index 4f472a3ae..f31124c54 100644 --- a/Source/Core/StyleSheetNodeSelectorNthLastChild.h +++ b/Source/Core/StyleSheetNodeSelectorNthLastChild.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORNTHLASTCHILD_H -#define RMLUICORESTYLESHEETNODESELECTORNTHLASTCHILD_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORNTHLASTCHILD_H +#define RMLUI_CORE_STYLESHEETNODESELECTORNTHLASTCHILD_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the nth-last generic child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorNthLastChild : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp b/Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp index c2342ac76..cd8b1a01e 100644 --- a/Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp +++ b/Source/Core/StyleSheetNodeSelectorNthLastOfType.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorNthLastOfType::StyleSheetNodeSelectorNthLastOfType() { @@ -68,5 +67,4 @@ bool StyleSheetNodeSelectorNthLastOfType::IsApplicable(const Element* element, i return IsNth(a, b, element_index); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorNthLastOfType.h b/Source/Core/StyleSheetNodeSelectorNthLastOfType.h index bc559b9b5..88ba28363 100644 --- a/Source/Core/StyleSheetNodeSelectorNthLastOfType.h +++ b/Source/Core/StyleSheetNodeSelectorNthLastOfType.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORNTHLASTOFTYPE_H -#define RMLUICORESTYLESHEETNODESELECTORNTHLASTOFTYPE_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORNTHLASTOFTYPE_H +#define RMLUI_CORE_STYLESHEETNODESELECTORNTHLASTOFTYPE_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the nth-last generic child of its type. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorNthLastOfType : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorNthOfType.cpp b/Source/Core/StyleSheetNodeSelectorNthOfType.cpp index f369ce3b4..dd1ee52f5 100644 --- a/Source/Core/StyleSheetNodeSelectorNthOfType.cpp +++ b/Source/Core/StyleSheetNodeSelectorNthOfType.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorNthOfType::StyleSheetNodeSelectorNthOfType() { @@ -68,5 +67,4 @@ bool StyleSheetNodeSelectorNthOfType::IsApplicable(const Element* element, int a return IsNth(a, b, element_index); } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorNthOfType.h b/Source/Core/StyleSheetNodeSelectorNthOfType.h index 46692b666..93da73b37 100644 --- a/Source/Core/StyleSheetNodeSelectorNthOfType.h +++ b/Source/Core/StyleSheetNodeSelectorNthOfType.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORNTHOFTYPE_H -#define RMLUICORESTYLESHEETNODESELECTORNTHOFTYPE_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORNTHOFTYPE_H +#define RMLUI_CORE_STYLESHEETNODESELECTORNTHOFTYPE_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the nth generic child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorNthOfType : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorOnlyChild.cpp b/Source/Core/StyleSheetNodeSelectorOnlyChild.cpp index f908f9ad2..6e9b42f99 100644 --- a/Source/Core/StyleSheetNodeSelectorOnlyChild.cpp +++ b/Source/Core/StyleSheetNodeSelectorOnlyChild.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorOnlyChild::StyleSheetNodeSelectorOnlyChild() { @@ -69,5 +68,4 @@ bool StyleSheetNodeSelectorOnlyChild::IsApplicable(const Element* element, int R return true; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorOnlyChild.h b/Source/Core/StyleSheetNodeSelectorOnlyChild.h index 23d6eac49..c12f53f66 100644 --- a/Source/Core/StyleSheetNodeSelectorOnlyChild.h +++ b/Source/Core/StyleSheetNodeSelectorOnlyChild.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORONLYCHILD_H -#define RMLUICORESTYLESHEETNODESELECTORONLYCHILD_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORONLYCHILD_H +#define RMLUI_CORE_STYLESHEETNODESELECTORONLYCHILD_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for an only child. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorOnlyChild : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp b/Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp index 629bfabb2..133f30dc2 100644 --- a/Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp +++ b/Source/Core/StyleSheetNodeSelectorOnlyOfType.cpp @@ -30,7 +30,6 @@ #include "../../Include/RmlUi/Core/ElementText.h" namespace Rml { -namespace Core { StyleSheetNodeSelectorOnlyOfType::StyleSheetNodeSelectorOnlyOfType() { @@ -70,5 +69,4 @@ bool StyleSheetNodeSelectorOnlyOfType::IsApplicable(const Element* element, int return true; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetNodeSelectorOnlyOfType.h b/Source/Core/StyleSheetNodeSelectorOnlyOfType.h index 5badcfd5f..fea17e8b6 100644 --- a/Source/Core/StyleSheetNodeSelectorOnlyOfType.h +++ b/Source/Core/StyleSheetNodeSelectorOnlyOfType.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORESTYLESHEETNODESELECTORONLYOFTYPE_H -#define RMLUICORESTYLESHEETNODESELECTORONLYOFTYPE_H +#ifndef RMLUI_CORE_STYLESHEETNODESELECTORONLYOFTYPE_H +#define RMLUI_CORE_STYLESHEETNODESELECTORONLYOFTYPE_H #include "StyleSheetNodeSelector.h" namespace Rml { -namespace Core { /** A node selector for the only child of its type. @@ -50,7 +49,5 @@ class StyleSheetNodeSelectorOnlyOfType : public StyleSheetNodeSelector bool IsApplicable(const Element* element, int a, int b) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetParser.cpp b/Source/Core/StyleSheetParser.cpp index ab0586f00..f1d836571 100644 --- a/Source/Core/StyleSheetParser.cpp +++ b/Source/Core/StyleSheetParser.cpp @@ -43,8 +43,6 @@ #include namespace Rml { -namespace Core { - class AbstractPropertyParser { public: @@ -811,5 +809,4 @@ bool StyleSheetParser::FillBuffer() return read; } -} -} +} // namespace Rml diff --git a/Source/Core/StyleSheetParser.h b/Source/Core/StyleSheetParser.h index 258c322ba..5359b06eb 100644 --- a/Source/Core/StyleSheetParser.h +++ b/Source/Core/StyleSheetParser.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORESTYLESHEETPARSER_H -#define RMLUICORESTYLESHEETPARSER_H +#ifndef RMLUI_CORE_STYLESHEETPARSER_H +#define RMLUI_CORE_STYLESHEETPARSER_H #include "../../Include/RmlUi/Core/StyleSheet.h" #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class PropertyDictionary; class Stream; @@ -113,7 +112,5 @@ class StyleSheetParser bool FillBuffer(); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/StyleSheetSpecification.cpp b/Source/Core/StyleSheetSpecification.cpp index ffdb80e02..a4342ecd2 100644 --- a/Source/Core/StyleSheetSpecification.cpp +++ b/Source/Core/StyleSheetSpecification.cpp @@ -39,8 +39,6 @@ #include "IdNameMap.h" namespace Rml { -namespace Core { - static StyleSheetSpecification* instance = nullptr; @@ -402,5 +400,4 @@ void StyleSheetSpecification::RegisterDefaultProperties() instance->properties.shorthand_map->AssertAllInserted(ShorthandId::NumDefinedIds); } -} -} +} // namespace Rml diff --git a/Source/Core/SystemInterface.cpp b/Source/Core/SystemInterface.cpp index a7a10df09..f91ee5f19 100644 --- a/Source/Core/SystemInterface.cpp +++ b/Source/Core/SystemInterface.cpp @@ -36,7 +36,6 @@ #endif namespace Rml { -namespace Core { static String clipboard_text; @@ -141,5 +140,4 @@ void SystemInterface::DeactivateKeyboard() { } -} -} +} // namespace Rml diff --git a/Source/Core/Template.cpp b/Source/Core/Template.cpp index b67f355cf..c1b132aa9 100644 --- a/Source/Core/Template.cpp +++ b/Source/Core/Template.cpp @@ -33,7 +33,6 @@ #include namespace Rml { -namespace Core { Template::Template() { @@ -136,5 +135,4 @@ const DocumentHeader* Template::GetHeader() return &header; } -} -} +} // namespace Rml diff --git a/Source/Core/Template.h b/Source/Core/Template.h index 33f3e9030..d86741856 100644 --- a/Source/Core/Template.h +++ b/Source/Core/Template.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORETEMPLATE_H -#define RMLUICORETEMPLATE_H +#ifndef RMLUI_CORE_TEMPLATE_H +#define RMLUI_CORE_TEMPLATE_H #include "../../Include/RmlUi/Core/StreamMemory.h" #include "DocumentHeader.h" namespace Rml { -namespace Core { class Element; @@ -70,7 +69,5 @@ class Template UniquePtr body; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TemplateCache.cpp b/Source/Core/TemplateCache.cpp index 0fd4a489e..3455df659 100644 --- a/Source/Core/TemplateCache.cpp +++ b/Source/Core/TemplateCache.cpp @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/Log.h" namespace Rml { -namespace Core { static TemplateCache* instance = nullptr; @@ -122,5 +121,4 @@ void TemplateCache::Clear() instance->template_ids.clear(); } -} -} +} // namespace Rml diff --git a/Source/Core/TemplateCache.h b/Source/Core/TemplateCache.h index c79e68997..bf1124ad9 100644 --- a/Source/Core/TemplateCache.h +++ b/Source/Core/TemplateCache.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORETEMPLATECACHE_H -#define RMLUICORETEMPLATECACHE_H +#ifndef RMLUI_CORE_TEMPLATECACHE_H +#define RMLUI_CORE_TEMPLATECACHE_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class Template; @@ -66,7 +65,5 @@ class TemplateCache Templates template_ids; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Texture.cpp b/Source/Core/Texture.cpp index d3c6aac68..8876d3e5f 100644 --- a/Source/Core/Texture.cpp +++ b/Source/Core/Texture.cpp @@ -31,7 +31,6 @@ #include "TextureResource.h" namespace Rml { -namespace Core { // Attempts to load a texture. void Texture::Set(const String& source, const String& source_path) @@ -83,5 +82,4 @@ Texture::operator bool() const return static_cast(resource); } -} -} +} // namespace Rml diff --git a/Source/Core/TextureDatabase.cpp b/Source/Core/TextureDatabase.cpp index 07c5305ae..05a0cf08a 100644 --- a/Source/Core/TextureDatabase.cpp +++ b/Source/Core/TextureDatabase.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/SystemInterface.h" namespace Rml { -namespace Core { static TextureDatabase* texture_database = nullptr; @@ -106,5 +105,4 @@ void TextureDatabase::ReleaseTextures(RenderInterface* render_interface) } } -} -} +} // namespace Rml diff --git a/Source/Core/TextureDatabase.h b/Source/Core/TextureDatabase.h index 3450156c8..92b0c8d21 100644 --- a/Source/Core/TextureDatabase.h +++ b/Source/Core/TextureDatabase.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICORETEXTUREDATABASE_H -#define RMLUICORETEXTUREDATABASE_H +#ifndef RMLUI_CORE_TEXTUREDATABASE_H +#define RMLUI_CORE_TEXTUREDATABASE_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class RenderInterface; class TextureResource; @@ -73,7 +72,5 @@ class TextureDatabase CallbackTextureMap callback_textures; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TextureLayout.cpp b/Source/Core/TextureLayout.cpp index 528412b4e..d6af24939 100644 --- a/Source/Core/TextureLayout.cpp +++ b/Source/Core/TextureLayout.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { struct RectangleSort { @@ -107,5 +106,4 @@ bool TextureLayout::GenerateLayout(int max_texture_dimensions) return true; } -} -} +} // namespace Rml diff --git a/Source/Core/TextureLayout.h b/Source/Core/TextureLayout.h index 8adc2ad90..2275ced0e 100644 --- a/Source/Core/TextureLayout.h +++ b/Source/Core/TextureLayout.h @@ -33,7 +33,6 @@ #include "TextureLayoutTexture.h" namespace Rml { -namespace Core { /** A texture layout generates and stores a layout of rectangles within a series of textures. It is @@ -83,7 +82,5 @@ class TextureLayout RectangleList rectangles; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TextureLayoutRectangle.cpp b/Source/Core/TextureLayoutRectangle.cpp index e69d7c36e..e9b983224 100644 --- a/Source/Core/TextureLayoutRectangle.cpp +++ b/Source/Core/TextureLayoutRectangle.cpp @@ -29,7 +29,6 @@ #include "TextureLayoutRectangle.h" namespace Rml { -namespace Core { TextureLayoutRectangle::TextureLayoutRectangle(int _id, const Vector2i& dimensions) : dimensions(dimensions), texture_position(0, 0) { @@ -106,5 +105,4 @@ int TextureLayoutRectangle::GetTextureStride() const return texture_stride; } -} -} +} // namespace Rml diff --git a/Source/Core/TextureLayoutRectangle.h b/Source/Core/TextureLayoutRectangle.h index 9accd7dcc..83073b5d7 100644 --- a/Source/Core/TextureLayoutRectangle.h +++ b/Source/Core/TextureLayoutRectangle.h @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { /** A texture layout rectangle is an area positioned with a texture layout. @@ -92,7 +91,5 @@ class TextureLayoutRectangle int texture_stride; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TextureLayoutRow.cpp b/Source/Core/TextureLayoutRow.cpp index 4ad82f2dc..860c92bbc 100644 --- a/Source/Core/TextureLayoutRow.cpp +++ b/Source/Core/TextureLayoutRow.cpp @@ -30,7 +30,6 @@ #include "TextureLayout.h" namespace Rml { -namespace Core { TextureLayoutRow::TextureLayoutRow() { @@ -106,5 +105,4 @@ void TextureLayoutRow::Unplace() rectangles[i]->Unplace(); } -} -} +} // namespace Rml diff --git a/Source/Core/TextureLayoutRow.h b/Source/Core/TextureLayoutRow.h index 5841e46e5..e9d349618 100644 --- a/Source/Core/TextureLayoutRow.h +++ b/Source/Core/TextureLayoutRow.h @@ -32,7 +32,6 @@ #include "TextureLayoutRectangle.h" namespace Rml { -namespace Core { class TextureLayout; @@ -74,7 +73,5 @@ class TextureLayoutRow RectangleList rectangles; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TextureLayoutTexture.cpp b/Source/Core/TextureLayoutTexture.cpp index 177dc320a..07a0b1682 100644 --- a/Source/Core/TextureLayoutTexture.cpp +++ b/Source/Core/TextureLayoutTexture.cpp @@ -31,7 +31,6 @@ #include "TextureLayout.h" namespace Rml { -namespace Core { TextureLayoutTexture::TextureLayoutTexture() : dimensions(0, 0) {} @@ -158,5 +157,4 @@ UniquePtr TextureLayoutTexture::AllocateTexture() return texture_data; } -} -} +} // namespace Rml diff --git a/Source/Core/TextureLayoutTexture.h b/Source/Core/TextureLayoutTexture.h index 4341b9df0..6505d51a6 100644 --- a/Source/Core/TextureLayoutTexture.h +++ b/Source/Core/TextureLayoutTexture.h @@ -33,7 +33,6 @@ #include "TextureLayoutRow.h" namespace Rml { -namespace Core { class TextureLayout; class TextureResource; @@ -73,7 +72,5 @@ class TextureLayoutTexture RowList rows; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/TextureResource.cpp b/Source/Core/TextureResource.cpp index 355f95dda..bdac778d7 100644 --- a/Source/Core/TextureResource.cpp +++ b/Source/Core/TextureResource.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Profiling.h" namespace Rml { -namespace Core { TextureResource::TextureResource() { @@ -182,5 +181,4 @@ bool TextureResource::Load(RenderInterface* render_interface) return true; } -} -} +} // namespace Rml diff --git a/Source/Core/TextureResource.h b/Source/Core/TextureResource.h index 4f9bc0811..550c54614 100644 --- a/Source/Core/TextureResource.h +++ b/Source/Core/TextureResource.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORETEXTURERESOURCE_H -#define RMLUICORETEXTURERESOURCE_H +#ifndef RMLUI_CORE_TEXTURERESOURCE_H +#define RMLUI_CORE_TEXTURERESOURCE_H #include "../../Include/RmlUi/Core/Traits.h" #include "../../Include/RmlUi/Core/Texture.h" namespace Rml { -namespace Core { /** A texture resource stores application-generated texture data (handle and dimensions) for each @@ -82,7 +81,5 @@ class TextureResource : public NonCopyMoveable UniquePtr texture_callback; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Transform.cpp b/Source/Core/Transform.cpp index 47ffb917c..bb26e7a00 100644 --- a/Source/Core/Transform.cpp +++ b/Source/Core/Transform.cpp @@ -32,8 +32,6 @@ #include "../../Include/RmlUi/Core/Transform.h" namespace Rml { -namespace Core { - // Default constructor, initializes an identity transform Transform::Transform() @@ -72,5 +70,4 @@ const Transforms::Primitive & Transform::GetPrimitive(int i) const noexcept return primitives[i]; } -} -} +} // namespace Rml diff --git a/Source/Core/TransformPrimitive.cpp b/Source/Core/TransformPrimitive.cpp index 5f5ca2ade..cfa1901c6 100644 --- a/Source/Core/TransformPrimitive.cpp +++ b/Source/Core/TransformPrimitive.cpp @@ -31,7 +31,7 @@ #include "../../Include/RmlUi/Core/TypeConverter.h" namespace Rml { -namespace Core { + namespace Transforms { static Vector3f Combine(const Vector3f& a, const Vector3f& b, float a_scale, float b_scale) @@ -995,5 +995,4 @@ bool DecomposedMatrix4::Decompose(const Matrix4f & m) } } -} -} +} // namespace Rml diff --git a/Source/Core/TransformState.cpp b/Source/Core/TransformState.cpp index 65a4411c3..8b10cbb60 100644 --- a/Source/Core/TransformState.cpp +++ b/Source/Core/TransformState.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/TransformState.h" namespace Rml { -namespace Core { bool TransformState::SetTransform(const Matrix4f* in_transform) { @@ -92,5 +91,4 @@ const Matrix4f* TransformState::GetInverseTransform() const return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/Tween.cpp b/Source/Core/Tween.cpp index ed7b09f42..412c03d41 100644 --- a/Source/Core/Tween.cpp +++ b/Source/Core/Tween.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { namespace TweenFunctions { @@ -238,5 +237,4 @@ float Tween::in_out(float t) const return 0.5f + out(2.0f * t - 1.0f) * 0.5f; } -} -} +} // namespace Rml diff --git a/Source/Core/TypeConverter.cpp b/Source/Core/TypeConverter.cpp index 90d84dcb9..18a267a06 100644 --- a/Source/Core/TypeConverter.cpp +++ b/Source/Core/TypeConverter.cpp @@ -32,7 +32,6 @@ #include "../../Include/RmlUi/Core/Transform.h" namespace Rml { -namespace Core { bool TypeConverter::Convert(const TransformPtr& src, TransformPtr& dest) { @@ -149,5 +148,4 @@ bool TypeConverter::Convert(const FontEffectsPtr& src, S -} -} +} // namespace Rml diff --git a/Source/Core/URL.cpp b/Source/Core/URL.cpp index 1477b51e2..e0e3bcda3 100644 --- a/Source/Core/URL.cpp +++ b/Source/Core/URL.cpp @@ -32,7 +32,6 @@ #include namespace Rml { -namespace Core { const char* DEFAULT_PROTOCOL = "file"; @@ -623,5 +622,4 @@ bool URL::IsUnreservedChar(const char in) return false; } -} -} +} // namespace Rml diff --git a/Source/Core/Utilities.h b/Source/Core/Utilities.h index 58d2380c8..d9d3aca07 100644 --- a/Source/Core/Utilities.h +++ b/Source/Core/Utilities.h @@ -26,11 +26,11 @@ * */ -#ifndef RMLUICOREUTILITIES_H -#define RMLUICOREUTILITIES_H +#ifndef RMLUI_CORE_UTILITIES_H +#define RMLUI_CORE_UTILITIES_H namespace Rml { -namespace Core { + namespace Utilities { template @@ -41,7 +41,5 @@ inline void HashCombine(std::size_t& seed, const T& v) } } -} -} - +} // namespace Rml #endif diff --git a/Source/Core/Variant.cpp b/Source/Core/Variant.cpp index c978eb4c2..5778f3568 100644 --- a/Source/Core/Variant.cpp +++ b/Source/Core/Variant.cpp @@ -30,7 +30,6 @@ #include namespace Rml { -namespace Core { Variant::Variant() : type(NONE) { @@ -505,5 +504,4 @@ bool Variant::operator==(const Variant & other) const return false; } -} -} +} // namespace Rml diff --git a/Source/Core/Vector3.cpp b/Source/Core/Vector3.cpp index ca2e807f0..57cfe1491 100644 --- a/Source/Core/Vector3.cpp +++ b/Source/Core/Vector3.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { Vector3i operator*(int lhs, const Vector3i& rhs) { @@ -43,5 +42,4 @@ Vector3f operator*(float lhs, const Vector3f& rhs) -} -} +} // namespace Rml diff --git a/Source/Core/Vector4.cpp b/Source/Core/Vector4.cpp index afc13d198..c34605a59 100644 --- a/Source/Core/Vector4.cpp +++ b/Source/Core/Vector4.cpp @@ -29,7 +29,6 @@ #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { Vector4i operator*(int lhs, const Vector4i& rhs) { @@ -51,5 +50,4 @@ Vector4< float > Vector4< float >::Normalise() const return *this / magnitude; } -} -} +} // namespace Rml diff --git a/Source/Core/WidgetSlider.cpp b/Source/Core/WidgetScroll.cpp similarity index 80% rename from Source/Core/WidgetSlider.cpp rename to Source/Core/WidgetScroll.cpp index 6562d44a9..d760f6733 100644 --- a/Source/Core/WidgetSlider.cpp +++ b/Source/Core/WidgetScroll.cpp @@ -26,7 +26,7 @@ * */ -#include "WidgetSlider.h" +#include "WidgetScroll.h" #include "Clock.h" #include "LayoutEngine.h" #include "../../Include/RmlUi/Core/Element.h" @@ -35,12 +35,11 @@ #include "../../Include/RmlUi/Core/Property.h" namespace Rml { -namespace Core { static const float DEFAULT_REPEAT_DELAY = 0.5f; static const float DEFAULT_REPEAT_PERIOD = 0.1f; -WidgetSlider::WidgetSlider(Element* _parent) +WidgetScroll::WidgetScroll(Element* _parent) { parent = _parent; @@ -57,32 +56,36 @@ WidgetSlider::WidgetSlider(Element* _parent) arrow_timers[0] = -1; arrow_timers[1] = -1; last_update_time = 0; + + track_length = 0; + bar_length = 0; + line_height = 12; } -WidgetSlider::~WidgetSlider() +WidgetScroll::~WidgetScroll() { if (bar != nullptr) { - bar->RemoveEventListener(Core::EventId::Drag, this); - bar->RemoveEventListener(Core::EventId::Dragstart, this); + bar->RemoveEventListener(EventId::Drag, this); + bar->RemoveEventListener(EventId::Dragstart, this); } if (track != nullptr) - track->RemoveEventListener(Core::EventId::Click, this); + track->RemoveEventListener(EventId::Click, this); for (int i = 0; i < 2; i++) { if (arrows[i] != nullptr) { - arrows[i]->RemoveEventListener(Core::EventId::Mousedown, this); - arrows[i]->RemoveEventListener(Core::EventId::Mouseup, this); - arrows[i]->RemoveEventListener(Core::EventId::Mouseout, this); + arrows[i]->RemoveEventListener(EventId::Mousedown, this); + arrows[i]->RemoveEventListener(EventId::Mouseup, this); + arrows[i]->RemoveEventListener(EventId::Mouseout, this); } } } // Initialises the slider to a given orientation. -bool WidgetSlider::Initialise(Orientation _orientation) +bool WidgetScroll::Initialise(Orientation _orientation) { // Check that we haven't already been successfully initialised. if (orientation != UNKNOWN) @@ -118,7 +121,7 @@ bool WidgetSlider::Initialise(Orientation _orientation) arrows[0] = parent->AppendChild(std::move(arrow0_element), false); arrows[1] = parent->AppendChild(std::move(arrow1_element), false); - bar->SetProperty(Core::PropertyId::Drag, Core::Property(Core::Style::Drag::Drag)); + bar->SetProperty(PropertyId::Drag, Property(Style::Drag::Drag)); // Attach the listeners as appropriate. bar->AddEventListener(EventId::Drag, this); @@ -137,7 +140,7 @@ bool WidgetSlider::Initialise(Orientation _orientation) } // Updates the key repeats for the increment / decrement arrows. -void WidgetSlider::Update() +void WidgetScroll::Update() { for (int i = 0; i < 2; i++) { @@ -164,7 +167,7 @@ void WidgetSlider::Update() } // Sets the position of the bar. -void WidgetSlider::SetBarPosition(float _bar_position) +void WidgetScroll::SetBarPosition(float _bar_position) { bar_position = Math::Clamp(_bar_position, 0.0f, 1.0f); PositionBar(); @@ -184,19 +187,19 @@ void WidgetSlider::SetBarPosition(float _bar_position) } // Returns the current position of the bar. -float WidgetSlider::GetBarPosition() +float WidgetScroll::GetBarPosition() const { return bar_position; } // Returns the slider's orientation. -WidgetSlider::Orientation WidgetSlider::GetOrientation() const +WidgetScroll::Orientation WidgetScroll::GetOrientation() const { return orientation; } // Sets the dimensions to the size of the slider. -void WidgetSlider::GetDimensions(Vector2f& dimensions) const +void WidgetScroll::GetDimensions(Vector2f& dimensions) const { switch (orientation) { @@ -207,7 +210,7 @@ void WidgetSlider::GetDimensions(Vector2f& dimensions) const } // Lays out and resizes the internal elements. -void WidgetSlider::FormatElements(const Vector2f& containing_block, bool resize_element, float slider_length, float bar_length) +void WidgetScroll::FormatElements(const Vector2f& containing_block, bool resize_element, float slider_length, float bar_length) { int length_axis = orientation == VERTICAL ? 1 : 0; @@ -291,7 +294,7 @@ void WidgetSlider::FormatElements(const Vector2f& containing_block, bool resize_ } // Lays out and positions the bar element. -void WidgetSlider::FormatBar(float bar_length) +void WidgetScroll::FormatBar(float bar_length) { Box bar_box; LayoutEngine::BuildBox(bar_box, parent->GetBox().GetSize(), bar); @@ -364,14 +367,8 @@ void WidgetSlider::FormatBar(float bar_length) PositionBar(); } -// Returns the widget's parent element. -Element* WidgetSlider::GetParent() const -{ - return parent; -} - // Handles events coming through from the slider's components. -void WidgetSlider::ProcessEvent(Event& event) +void WidgetScroll::ProcessEvent(Event& event) { if (event.GetTargetElement() == bar) { @@ -386,7 +383,7 @@ void WidgetSlider::ProcessEvent(Event& event) float new_bar_position = (event.GetParameter< float >("mouse_x", 0) - traversable_track_origin) / traversable_track_length; new_bar_position = Math::Clamp(new_bar_position, 0.0f, 1.0f); - SetBarPosition(OnBarChange(new_bar_position)); + SetBarPosition(new_bar_position); } } else @@ -398,7 +395,7 @@ void WidgetSlider::ProcessEvent(Event& event) float new_bar_position = (event.GetParameter< float >("mouse_y", 0) - traversable_track_origin) / traversable_track_length; new_bar_position = Math::Clamp(new_bar_position, 0.0f, 1.0f); - SetBarPosition(OnBarChange(new_bar_position)); + SetBarPosition(new_bar_position); } } } @@ -419,14 +416,14 @@ void WidgetSlider::ProcessEvent(Event& event) float mouse_position = event.GetParameter< float >("mouse_x", 0); float click_position = (mouse_position - track->GetAbsoluteOffset().x) / track->GetBox().GetSize().x; - SetBarPosition(click_position <= bar_position ? OnPageDecrement(click_position) : OnPageIncrement(click_position)); + SetBarPosition(click_position <= bar_position ? OnPageDecrement() : OnPageIncrement()); } else { float mouse_position = event.GetParameter< float >("mouse_y", 0); float click_position = (mouse_position - track->GetAbsoluteOffset().y) / track->GetBox().GetSize().y; - SetBarPosition(click_position <= bar_position ? OnPageDecrement(click_position) : OnPageIncrement(click_position)); + SetBarPosition(click_position <= bar_position ? OnPageDecrement() : OnPageIncrement()); } } } @@ -456,7 +453,7 @@ void WidgetSlider::ProcessEvent(Event& event) } } -void WidgetSlider::PositionBar() +void WidgetScroll::PositionBar() { const Vector2f& track_dimensions = track->GetBox().GetSize(); const Vector2f& bar_dimensions = bar->GetBox().GetSize(Box::BORDER); @@ -473,5 +470,89 @@ void WidgetSlider::PositionBar() } } + + +// Sets the length of the entire track in some arbitrary unit. +void WidgetScroll::SetTrackLength(float _track_length, bool RMLUI_UNUSED_PARAMETER(force_resize)) +{ + RMLUI_UNUSED(force_resize); + + if (track_length != _track_length) + { + track_length = _track_length; + // GenerateBar(); + } +} + +// Sets the length the bar represents in some arbitrary unit, relative to the track length. +void WidgetScroll::SetBarLength(float _bar_length, bool RMLUI_UNUSED_PARAMETER(force_resize)) +{ + RMLUI_UNUSED(force_resize); + + if (bar_length != _bar_length) + { + bar_length = _bar_length; + // GenerateBar(); + } +} + +// Sets the line height of the parent element; this is used for scrolling speeds. +void WidgetScroll::SetLineHeight(float _line_height) +{ + line_height = _line_height; +} + +// Lays out and resizes the internal elements. +void WidgetScroll::FormatElements(const Vector2f& containing_block, float slider_length) +{ + float relative_bar_length; + + if (track_length <= 0) + relative_bar_length = 1; + else if (bar_length <= 0) + relative_bar_length = 0; + else + relative_bar_length = bar_length / track_length; + + WidgetScroll::FormatElements(containing_block, true, slider_length, relative_bar_length); } + +// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the +// increment arrow. +float WidgetScroll::OnLineIncrement() +{ + return Scroll(line_height); } + +// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the decrement +// arrow. +float WidgetScroll::OnLineDecrement() +{ + return Scroll(-line_height); +} + +// Called when the slider is incremented by one 'page', either by the page-up key or a mouse-click on the track +// below / right of the bar. +float WidgetScroll::OnPageIncrement() +{ + return Scroll(bar_length); +} + +// Called when the slider is incremented by one 'page', either by the page-down key or a mouse-click on the track +// above / left of the bar. +float WidgetScroll::OnPageDecrement() +{ + return Scroll(-bar_length); +} + +// Returns the bar position after scrolling for a number of pixels. +float WidgetScroll::Scroll(float distance) +{ + float traversable_track_length = (track_length - bar_length); + if (traversable_track_length <= 0) + return bar_position; + + return (bar_position * traversable_track_length + distance) / traversable_track_length; +} + +} // namespace Rml diff --git a/Source/Core/WidgetSlider.h b/Source/Core/WidgetScroll.h similarity index 70% rename from Source/Core/WidgetSlider.h rename to Source/Core/WidgetScroll.h index 9c2f03a75..6e1b9e0ab 100644 --- a/Source/Core/WidgetSlider.h +++ b/Source/Core/WidgetScroll.h @@ -26,23 +26,22 @@ * */ -#ifndef RMLUICOREWIDGETSLIDER_H -#define RMLUICOREWIDGETSLIDER_H +#ifndef RMLUI_CORE_WIDGETSCROLL_H +#define RMLUI_CORE_WIDGETSCROLL_H #include "../../Include/RmlUi/Core/EventListener.h" namespace Rml { -namespace Core { class Element; /** - A generic widget for incorporating sliding functionality into an element. + A widget for incorporating scrolling functionality into an element. @author Peter Curry */ -class WidgetSlider : public EventListener +class WidgetScroll final : public EventListener { public: enum Orientation @@ -52,8 +51,8 @@ class WidgetSlider : public EventListener HORIZONTAL }; - WidgetSlider(Element* parent); - virtual ~WidgetSlider(); + WidgetScroll(Element* parent); + virtual ~WidgetScroll(); /// Initialises the slider to a given orientation. bool Initialise(Orientation orientation); @@ -66,7 +65,7 @@ class WidgetSlider : public EventListener void SetBarPosition(float bar_position); /// Returns the current position of the bar. /// @return The current position of the bar (0 representing the start of the track, 1 representing the end). - float GetBarPosition(); + float GetBarPosition() const; /// Returns the slider's orientation. /// @return The orientation of the slider. @@ -76,7 +75,31 @@ class WidgetSlider : public EventListener /// @param[in] dimensions The dimensions to size. void GetDimensions(Vector2f& dimensions) const; -protected: + /// Sets the length of the entire track in scrollable units (usually lines or characters). This affects the + /// length of the bar element and the speed of scrolling using the mouse-wheel or arrows. + /// @param[in] track_length The length of the track. + /// @param[in] force_resize True to resize the bar immediately, false to wait until the next format. + void SetTrackLength(float track_length, bool force_resize = true); + /// Sets the length the bar represents in scrollable units (usually lines or characters), relative to the track + /// length. For example, for a scroll bar, this would represent how big each visible 'page' is compared to the + /// whole document (which would be set as the track length). + /// @param[in] bar_length The length of the slider's bar. + /// @param[in] force_resize True to resize the bar immediately, false to wait until the next format. + void SetBarLength(float bar_length, bool force_resize = true); + + /// Sets the line height of the parent element; this is used for scrolling speeds. + /// @param[in] line_height The line height of the parent element. + void SetLineHeight(float line_height); + + /// Lays out and resizes the internal elements. + /// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties. + /// @param[in] length The total length, in pixels, of the slider widget. + void FormatElements(const Vector2f& containing_block, float slider_length); + +private: + /// Handles events coming through from the slider's components. + void ProcessEvent(Event& event) override; + /// Lays out and resizes the slider's internal elements. /// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties. /// @param[in] resize_element True to resize the parent slider element, false to only resize its components. @@ -87,37 +110,28 @@ class WidgetSlider : public EventListener /// @param[in] bar_length The total length of the bar, as a proportion of the track length. If this is -1, the intrinsic length will be used. void FormatBar(float bar_length = -1); - /// Returns the widget's parent element. - Element* GetParent() const; - - /// Handles events coming through from the slider's components. - void ProcessEvent(Event& event) override; + // Set the offset on 'bar' from its position. + void PositionBar(); - /// Called when the slider's bar position is set or dragged. - /// @param[in] bar_position The new position of the bar (0 representing the start of the track, 1 representing the end). - /// @return The new position of the bar. - virtual float OnBarChange(float bar_position) = 0; /// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the /// increment arrow. /// @return The new position of the bar. - virtual float OnLineIncrement() = 0; + float OnLineIncrement(); /// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the /// decrement arrow. /// @return The new position of the bar. - virtual float OnLineDecrement() = 0; + float OnLineDecrement(); /// Called when the slider is incremented by one 'page', either by the page-up key or a mouse-click on the /// track below / right of the bar. - /// @param[in] click_position The parametric position of the click along the track, or -1 if this was not generated by a mouse click. /// @return The new position of the bar. - virtual float OnPageIncrement(float click_position) = 0; + float OnPageIncrement(); /// Called when the slider is incremented by one 'page', either by the page-down key or a mouse-click on the /// track above / left of the bar. - /// @param[in] click_position The parametric position of the click along the track, or -1 if this was not generated by a mouse click. /// @return The new position of the bar. - virtual float OnPageDecrement(float click_position) = 0; + float OnPageDecrement(); -private: - void PositionBar(); + // Returns the bar position after scrolling for a number of pixels. + float Scroll(float distance); Element* parent; @@ -138,9 +152,11 @@ class WidgetSlider : public EventListener // Set to the auto-repeat timer if either of the arrow buttons have been pressed, -1 if they haven't. float arrow_timers[2]; double last_update_time; -}; -} -} + float track_length; + float bar_length; + float line_height; +}; +} // namespace Rml #endif diff --git a/Source/Core/WidgetSliderScroll.cpp b/Source/Core/WidgetSliderScroll.cpp deleted file mode 100644 index 72a7130cf..000000000 --- a/Source/Core/WidgetSliderScroll.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#include "WidgetSliderScroll.h" - -namespace Rml { -namespace Core { - -WidgetSliderScroll::WidgetSliderScroll(Element* parent) : WidgetSlider(parent) -{ - track_length = 0; - bar_length = 0; - line_height = 12; -} - -WidgetSliderScroll::~WidgetSliderScroll() -{ -} - -// Sets the length of the entire track in some arbitrary unit. -void WidgetSliderScroll::SetTrackLength(float _track_length, bool RMLUI_UNUSED_PARAMETER(force_resize)) -{ - RMLUI_UNUSED(force_resize); - - if (track_length != _track_length) - { - track_length = _track_length; -// GenerateBar(); - } -} - -// Sets the length the bar represents in some arbitrary unit, relative to the track length. -void WidgetSliderScroll::SetBarLength(float _bar_length, bool RMLUI_UNUSED_PARAMETER(force_resize)) -{ - RMLUI_UNUSED(force_resize); - - if (bar_length != _bar_length) - { - bar_length = _bar_length; -// GenerateBar(); - } -} - -// Sets the line height of the parent element; this is used for scrolling speeds. -void WidgetSliderScroll::SetLineHeight(float _line_height) -{ - line_height = _line_height; -} - -// Lays out and resizes the internal elements. -void WidgetSliderScroll::FormatElements(const Vector2f& containing_block, float slider_length) -{ - float relative_bar_length; - - if (track_length <= 0) - relative_bar_length = 1; - else if (bar_length <= 0) - relative_bar_length = 0; - else - relative_bar_length = bar_length / track_length; - - WidgetSlider::FormatElements(containing_block, true, slider_length, relative_bar_length); -} - -// Called when the slider's bar position is set or dragged. -float WidgetSliderScroll::OnBarChange(float bar_position) -{ - return bar_position; -} - -// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the -// increment arrow. -float WidgetSliderScroll::OnLineIncrement() -{ - return Scroll(line_height); -} - -// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the decrement -// arrow. -float WidgetSliderScroll::OnLineDecrement() -{ - return Scroll(-line_height); -} - -// Called when the slider is incremented by one 'page', either by the page-up key or a mouse-click on the track -// below / right of the bar. -float WidgetSliderScroll::OnPageIncrement(float RMLUI_UNUSED_PARAMETER(click_position)) -{ - RMLUI_UNUSED(click_position); - - return Scroll(bar_length); -} - -// Called when the slider is incremented by one 'page', either by the page-down key or a mouse-click on the track -// above / left of the bar. -float WidgetSliderScroll::OnPageDecrement(float RMLUI_UNUSED_PARAMETER(click_position)) -{ - RMLUI_UNUSED(click_position); - - return Scroll(-bar_length); -} - -// Returns the bar position after scrolling for a number of pixels. -float WidgetSliderScroll::Scroll(float distance) -{ - float traversable_track_length = (track_length - bar_length); - if (traversable_track_length <= 0) - return GetBarPosition(); - - return (GetBarPosition() * traversable_track_length + distance) / traversable_track_length; -} - -} -} diff --git a/Source/Core/WidgetSliderScroll.h b/Source/Core/WidgetSliderScroll.h deleted file mode 100644 index 1fbd07834..000000000 --- a/Source/Core/WidgetSliderScroll.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This source file is part of RmlUi, the HTML/CSS Interface Middleware - * - * For the latest information, see http://github.com/mikke89/RmlUi - * - * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd - * Copyright (c) 2019 The RmlUi Team, and contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#ifndef RMLUICOREWIDGETSLIDERSCROLL_H -#define RMLUICOREWIDGETSLIDERSCROLL_H - -#include "WidgetSlider.h" - -namespace Rml { -namespace Core { - -/** - @author Peter Curry - */ - -class WidgetSliderScroll : public WidgetSlider -{ -public: - WidgetSliderScroll(Element* parent); - virtual ~WidgetSliderScroll(); - - /// Sets the length of the entire track in scrollable units (usually lines or characters). This affects the - /// length of the bar element and the speed of scrolling using the mouse-wheel or arrows. - /// @param[in] track_length The length of the track. - /// @param[in] force_resize True to resize the bar immediately, false to wait until the next format. - void SetTrackLength(float track_length, bool force_resize = true); - /// Sets the length the bar represents in scrollable units (usually lines or characters), relative to the track - /// length. For example, for a scroll bar, this would represent how big each visible 'page' is compared to the - /// whole document (which would be set as the track length). - /// @param[in] bar_length The length of the slider's bar. - /// @param[in] force_resize True to resize the bar immediately, false to wait until the next format. - void SetBarLength(float bar_length, bool force_resize = true); - - /// Sets the line height of the parent element; this is used for scrolling speeds. - /// @param[in] line_height The line height of the parent element. - void SetLineHeight(float line_height); - - /// Lays out and resizes the internal elements. - /// @param[in] containing_block The padded box containing the slider. This is used to resolve relative properties. - /// @param[in] length The total length, in pixels, of the slider widget. - void FormatElements(const Vector2f& containing_block, float slider_length); - -protected: - /// Called when the slider's bar position is set or dragged. - /// @param bar_position[in] The new position of the bar (0 representing the start of the track, 1 representing the end). - /// @return The new position of the bar. - float OnBarChange(float bar_position) override; - /// Called when the slider is incremented by one 'line', either by the down / right key or a mouse-click on the - /// increment arrow. - /// @return The new position of the bar. - float OnLineIncrement() override; - /// Called when the slider is decremented by one 'line', either by the up / left key or a mouse-click on the - /// decrement arrow. - /// @return The new position of the bar. - float OnLineDecrement() override; - /// Called when the slider is incremented by one 'page', either by the page-up key or a mouse-click on the - /// track below / right of the bar. - /// @return The new position of the bar. - float OnPageIncrement(float click_position) override; - /// Called when the slider is incremented by one 'page', either by the page-down key or a mouse-click on the - /// track above / left of the bar. - /// @return The new position of the bar. - float OnPageDecrement(float click_position) override; - -private: - // Returns the bar position after scrolling for a number of pixels. - float Scroll(float distance); - - float track_length; - float bar_length; - float line_height; -}; - -} -} - -#endif diff --git a/Source/Core/XMLNodeHandler.cpp b/Source/Core/XMLNodeHandler.cpp index 12cb78463..3b91d86ab 100644 --- a/Source/Core/XMLNodeHandler.cpp +++ b/Source/Core/XMLNodeHandler.cpp @@ -29,11 +29,9 @@ #include "../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Core { XMLNodeHandler::~XMLNodeHandler() { } -} -} +} // namespace Rml diff --git a/Source/Core/XMLNodeHandlerBody.cpp b/Source/Core/XMLNodeHandlerBody.cpp index 68005fe4c..47c79d422 100644 --- a/Source/Core/XMLNodeHandlerBody.cpp +++ b/Source/Core/XMLNodeHandlerBody.cpp @@ -33,7 +33,6 @@ #include "../../Include/RmlUi/Core/Factory.h" namespace Rml { -namespace Core { XMLNodeHandlerBody::XMLNodeHandlerBody() { @@ -82,5 +81,4 @@ bool XMLNodeHandlerBody::ElementData(XMLParser* parser, const String& data, XMLD return Factory::InstanceElementText(parser->GetParseFrame()->element, data); } -} -} +} // namespace Rml diff --git a/Source/Core/XMLNodeHandlerBody.h b/Source/Core/XMLNodeHandlerBody.h index a59d9d54f..dc3f3c83e 100644 --- a/Source/Core/XMLNodeHandlerBody.h +++ b/Source/Core/XMLNodeHandlerBody.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREXMLNODEHANDLERBODY_H -#define RMLUICOREXMLNODEHANDLERBODY_H +#ifndef RMLUI_CORE_XMLNODEHANDLERBODY_H +#define RMLUI_CORE_XMLNODEHANDLERBODY_H #include "../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Core { /** Element Node handler that processes the HEAD tag @@ -54,7 +53,5 @@ class XMLNodeHandlerBody : public XMLNodeHandler bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/XMLNodeHandlerDefault.cpp b/Source/Core/XMLNodeHandlerDefault.cpp index e9af08da1..41f50c201 100644 --- a/Source/Core/XMLNodeHandlerDefault.cpp +++ b/Source/Core/XMLNodeHandlerDefault.cpp @@ -37,7 +37,6 @@ namespace Rml { -namespace Core { XMLNodeHandlerDefault::XMLNodeHandlerDefault() { @@ -96,5 +95,4 @@ bool XMLNodeHandlerDefault::ElementData(XMLParser* parser, const String& data, X } -} -} +} // namespace Rml diff --git a/Source/Core/XMLNodeHandlerDefault.h b/Source/Core/XMLNodeHandlerDefault.h index eae8b1436..200d80c3d 100644 --- a/Source/Core/XMLNodeHandlerDefault.h +++ b/Source/Core/XMLNodeHandlerDefault.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICOREXMLNODEHANDLERDEFAULT_H -#define RMLUICOREXMLNODEHANDLERDEFAULT_H +#ifndef RMLUI_CORE_XMLNODEHANDLERDEFAULT_H +#define RMLUI_CORE_XMLNODEHANDLERDEFAULT_H #include "../../Include/RmlUi/Core/Types.h" #include "../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Core { /** Element Node handler that creates elements @@ -55,7 +54,5 @@ class XMLNodeHandlerDefault : public XMLNodeHandler bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/XMLNodeHandlerHead.cpp b/Source/Core/XMLNodeHandlerHead.cpp index 0231f0e66..c501f7ae4 100644 --- a/Source/Core/XMLNodeHandlerHead.cpp +++ b/Source/Core/XMLNodeHandlerHead.cpp @@ -38,7 +38,6 @@ #include "../../Include/RmlUi/Core/URL.h" namespace Rml { -namespace Core { XMLNodeHandlerHead::XMLNodeHandlerHead() { @@ -147,5 +146,4 @@ bool XMLNodeHandlerHead::ElementData(XMLParser* parser, const String& data, XMLD return true; } -} -} +} // namespace Rml diff --git a/Source/Core/XMLNodeHandlerHead.h b/Source/Core/XMLNodeHandlerHead.h index 3eeee3bcb..efd368fef 100644 --- a/Source/Core/XMLNodeHandlerHead.h +++ b/Source/Core/XMLNodeHandlerHead.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREXMLNODEHANDLERHEAD_H -#define RMLUICOREXMLNODEHANDLERHEAD_H +#ifndef RMLUI_CORE_XMLNODEHANDLERHEAD_H +#define RMLUI_CORE_XMLNODEHANDLERHEAD_H #include "../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Core { /** Element Node handler that processes the HEAD tag @@ -54,7 +53,5 @@ class XMLNodeHandlerHead : public XMLNodeHandler bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/XMLNodeHandlerTemplate.cpp b/Source/Core/XMLNodeHandlerTemplate.cpp index 096f2c402..706dcff89 100644 --- a/Source/Core/XMLNodeHandlerTemplate.cpp +++ b/Source/Core/XMLNodeHandlerTemplate.cpp @@ -35,7 +35,6 @@ #include "../../Include/RmlUi/Core/XMLParser.h" namespace Rml { -namespace Core { XMLNodeHandlerTemplate::XMLNodeHandlerTemplate() { @@ -72,5 +71,4 @@ bool XMLNodeHandlerTemplate::ElementData(XMLParser* parser, const String& data, return Factory::InstanceElementText(parser->GetParseFrame()->element, data); } -} -} +} // namespace Rml diff --git a/Source/Core/XMLNodeHandlerTemplate.h b/Source/Core/XMLNodeHandlerTemplate.h index 8a98df2d0..d41f04970 100644 --- a/Source/Core/XMLNodeHandlerTemplate.h +++ b/Source/Core/XMLNodeHandlerTemplate.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREXMLNODEHANDLERTEMPLATE_H -#define RMLUICOREXMLNODEHANDLERTEMPLATE_H +#ifndef RMLUI_CORE_XMLNODEHANDLERTEMPLATE_H +#define RMLUI_CORE_XMLNODEHANDLERTEMPLATE_H #include "../../Include/RmlUi/Core/XMLNodeHandler.h" namespace Rml { -namespace Core { /** Element Node handler that processes the custom template tags @@ -54,7 +53,5 @@ class XMLNodeHandlerTemplate : public XMLNodeHandler bool ElementData(XMLParser* parser, const String& data, XMLDataType type) override; }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/XMLParseTools.cpp b/Source/Core/XMLParseTools.cpp index 3b5d3d292..d47189854 100644 --- a/Source/Core/XMLParseTools.cpp +++ b/Source/Core/XMLParseTools.cpp @@ -37,7 +37,6 @@ #include namespace Rml { -namespace Core { // Searchs a string for the specified tag // NOTE: tag *MUST* be in lowercase @@ -188,5 +187,4 @@ const char* XMLParseTools::ParseDataBrackets(bool& inside_brackets, char c, char return nullptr; } -} -} +} // namespace Rml diff --git a/Source/Core/XMLParseTools.h b/Source/Core/XMLParseTools.h index 4329921ac..1887658ec 100644 --- a/Source/Core/XMLParseTools.h +++ b/Source/Core/XMLParseTools.h @@ -26,13 +26,12 @@ * */ -#ifndef RMLUICOREXMLPARSETOOLS_H -#define RMLUICOREXMLPARSETOOLS_H +#ifndef RMLUI_CORE_XMLPARSETOOLS_H +#define RMLUI_CORE_XMLPARSETOOLS_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { class Element; @@ -69,7 +68,5 @@ class XMLParseTools static const char* ParseDataBrackets(bool& inside_brackets, char c, char previous); }; -} -} - +} // namespace Rml #endif diff --git a/Source/Core/XMLParser.cpp b/Source/Core/XMLParser.cpp index b5c0c457f..e25517ef8 100644 --- a/Source/Core/XMLParser.cpp +++ b/Source/Core/XMLParser.cpp @@ -37,7 +37,6 @@ #include "../../Include/RmlUi/Core/Factory.h" namespace Rml { -namespace Core { using NodeHandlers = UnorderedMap< String, SharedPtr >; static NodeHandlers node_handlers; @@ -185,5 +184,4 @@ void XMLParser::HandleData(const String& data, XMLDataType type) stack.top().node_handler->ElementData(this, data, type); } -} -} +} // namespace Rml diff --git a/Source/Core/precompiled.h b/Source/Core/precompiled.h index 575ae9201..4a9c96ab4 100644 --- a/Source/Core/precompiled.h +++ b/Source/Core/precompiled.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUICOREPRECOMPILED_H -#define RMLUICOREPRECOMPILED_H +#ifndef RMLUI_CORE_PRECOMPILED_H +#define RMLUI_CORE_PRECOMPILED_H #include "../../Include/RmlUi/Core.h" diff --git a/Source/Debugger/Debugger.cpp b/Source/Debugger/Debugger.cpp index d811a13e1..ed5d4274f 100644 --- a/Source/Debugger/Debugger.cpp +++ b/Source/Debugger/Debugger.cpp @@ -28,39 +28,39 @@ #include "../../Include/RmlUi/Debugger/Debugger.h" #include "../../Include/RmlUi/Core/Core.h" -#include "Plugin.h" +#include "DebuggerPlugin.h" namespace Rml { namespace Debugger { // Initialises the debug plugin. The debugger will be loaded into the given context. -bool Initialise(Core::Context* context) +bool Initialise(Context* context) { - if (Plugin::GetInstance() != nullptr) + if (DebuggerPlugin::GetInstance() != nullptr) { - Core::Log::Message(Core::Log::LT_WARNING, "Unable to initialise debugger plugin, already initialised!"); + Log::Message(Log::LT_WARNING, "Unable to initialise debugger plugin, already initialised!"); return false; } - Plugin* plugin = new Plugin(); + DebuggerPlugin* plugin = new DebuggerPlugin(); if (!plugin->Initialise(context)) { - Core::Log::Message(Core::Log::LT_WARNING, "Unable to initialise debugger plugin."); + Log::Message(Log::LT_WARNING, "Unable to initialise debugger plugin."); delete plugin; return false; } SetContext(context); - Core::RegisterPlugin(plugin); + RegisterPlugin(plugin); return true; } // Sets the context to be debugged. -bool SetContext(Core::Context* context) +bool SetContext(Context* context) { - Plugin* plugin = Plugin::GetInstance(); + DebuggerPlugin* plugin = DebuggerPlugin::GetInstance(); if (plugin == nullptr) return false; @@ -72,7 +72,7 @@ bool SetContext(Core::Context* context) // Sets the visibility of the debugger. void SetVisible(bool visibility) { - Plugin* plugin = Plugin::GetInstance(); + DebuggerPlugin* plugin = DebuggerPlugin::GetInstance(); if (plugin != nullptr) plugin->SetVisible(visibility); } @@ -80,7 +80,7 @@ void SetVisible(bool visibility) // Returns the visibility of the debugger. bool IsVisible() { - Plugin* plugin = Plugin::GetInstance(); + DebuggerPlugin* plugin = DebuggerPlugin::GetInstance(); if (plugin == nullptr) return false; @@ -88,4 +88,4 @@ bool IsVisible() } } -} +} // namespace Rml diff --git a/Source/Debugger/Plugin.cpp b/Source/Debugger/DebuggerPlugin.cpp similarity index 63% rename from Source/Debugger/Plugin.cpp rename to Source/Debugger/DebuggerPlugin.cpp index 571c0920d..b04cfc7c4 100644 --- a/Source/Debugger/Plugin.cpp +++ b/Source/Debugger/DebuggerPlugin.cpp @@ -26,7 +26,7 @@ * */ -#include "Plugin.h" +#include "DebuggerPlugin.h" #include "../../Include/RmlUi/Core/Context.h" #include "../../Include/RmlUi/Core/Core.h" #include "../../Include/RmlUi/Core/ElementInstancer.h" @@ -39,15 +39,15 @@ #include "FontSource.h" #include "Geometry.h" #include "MenuSource.h" -#include "SystemInterface.h" +#include "DebuggerSystemInterface.h" #include namespace Rml { namespace Debugger { -Plugin* Plugin::instance = nullptr; +DebuggerPlugin* DebuggerPlugin::instance = nullptr; -Plugin::Plugin() +DebuggerPlugin::DebuggerPlugin() { RMLUI_ASSERT(instance == nullptr); instance = this; @@ -65,20 +65,20 @@ Plugin::Plugin() application_interface = nullptr; } -Plugin::~Plugin() +DebuggerPlugin::~DebuggerPlugin() { instance = nullptr; } // Initialises the debugging tools into the given context. -bool Plugin::Initialise(Core::Context* context) +bool DebuggerPlugin::Initialise(Context* context) { host_context = context; Geometry::SetContext(context); if (!LoadFont()) { - Core::Log::Message(Core::Log::LT_ERROR, "Failed to initialise debugger, unable to load font."); + Log::Message(Log::LT_ERROR, "Failed to initialise debugger, unable to load font."); return false; } @@ -86,18 +86,18 @@ bool Plugin::Initialise(Core::Context* context) !LoadInfoElement() || !LoadLogElement()) { - Core::Log::Message(Core::Log::LT_ERROR, "Failed to initialise debugger, error while load debugger elements."); + Log::Message(Log::LT_ERROR, "Failed to initialise debugger, error while load debugger elements."); return false; } - hook_element_instancer = std::make_unique< Core::ElementInstancerGeneric >(); - Core::Factory::RegisterElementInstancer("debug-hook", hook_element_instancer.get()); + hook_element_instancer = std::make_unique< ElementInstancerGeneric >(); + Factory::RegisterElementInstancer("debug-hook", hook_element_instancer.get()); return true; } // Sets the context to be debugged. -bool Plugin::SetContext(Core::Context* context) +bool DebuggerPlugin::SetContext(Context* context) { // Remove the debug hook from the old context. if (debug_context && hook_element) @@ -109,7 +109,7 @@ bool Plugin::SetContext(Core::Context* context) // Add the debug hook into the new context. if (context) { - Core::ElementDocument* element = context->CreateDocument("debug-hook"); + ElementDocument* element = context->CreateDocument("debug-hook"); if (!element) return false; @@ -147,49 +147,49 @@ bool Plugin::SetContext(Core::Context* context) } // Sets the visibility of the debugger. -void Plugin::SetVisible(bool visibility) +void DebuggerPlugin::SetVisible(bool visibility) { if (visibility) - menu_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + menu_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); else - menu_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + menu_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); } // Returns the visibility of the debugger. -bool Plugin::IsVisible() +bool DebuggerPlugin::IsVisible() { return menu_element->IsVisible(); } // Renders any debug elements in the debug context. -void Plugin::Render() +void DebuggerPlugin::Render() { // Render the outlines of the debug context's elements. if (render_outlines && debug_context) { for (int i = 0; i < debug_context->GetNumDocuments(); ++i) { - Core::ElementDocument* document = debug_context->GetDocument(i); + ElementDocument* document = debug_context->GetDocument(i); if (document->GetId().find("rmlui-debug-") == 0) continue; - std::stack< Core::Element* > element_stack; + std::stack< Element* > element_stack; element_stack.push(document); while (!element_stack.empty()) { - Core::Element* element = element_stack.top(); + Element* element = element_stack.top(); element_stack.pop(); if (element->IsVisible()) { - Core::ElementUtilities::ApplyTransform(*element); + ElementUtilities::ApplyTransform(*element); for (int j = 0; j < element->GetNumBoxes(); ++j) { - const Core::Box& box = element->GetBox(j); + const Box& box = element->GetBox(j); Geometry::RenderOutline( - element->GetAbsoluteOffset(Core::Box::BORDER) + box.GetPosition(Core::Box::BORDER), - box.GetSize(Core::Box::BORDER), - Core::Colourb(255, 0, 0, 128), + element->GetAbsoluteOffset(Box::BORDER) + box.GetPosition(Box::BORDER), + box.GetSize(Box::BORDER), + Colourb(255, 0, 0, 128), 1 ); } @@ -210,7 +210,7 @@ void Plugin::Render() } // Called when RmlUi shuts down. -void Plugin::OnShutdown() +void DebuggerPlugin::OnShutdown() { // Release the elements before we leak track, this ensures the debugger hook has been cleared // and that we don't try send the messages to the debug log window @@ -222,7 +222,7 @@ void Plugin::OnShutdown() } // Called whenever a RmlUi context is destroyed. -void Plugin::OnContextDestroy(Core::Context* context) +void DebuggerPlugin::OnContextDestroy(Context* context) { if (context == debug_context) { @@ -242,30 +242,30 @@ void Plugin::OnContextDestroy(Core::Context* context) } // Called whenever an element is destroyed. -void Plugin::OnElementDestroy(Core::Element* element) +void DebuggerPlugin::OnElementDestroy(Element* element) { if (info_element) info_element->OnElementDestroy(element); } // Event handler for events from the debugger elements. -void Plugin::ProcessEvent(Core::Event& event) +void DebuggerPlugin::ProcessEvent(Event& event) { - if (event == Core::EventId::Click) + if (event == EventId::Click) { if (event.GetTargetElement()->GetId() == "event-log-button") { if (log_element->IsVisible()) - log_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + log_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); else - log_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + log_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); } else if (event.GetTargetElement()->GetId() == "debug-info-button") { if (info_element->IsVisible()) - info_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + info_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); else - info_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + info_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); } else if (event.GetTargetElement()->GetId() == "outlines-button") { @@ -274,30 +274,30 @@ void Plugin::ProcessEvent(Core::Event& event) } } -Plugin* Plugin::GetInstance() +DebuggerPlugin* DebuggerPlugin::GetInstance() { return instance; } -bool Plugin::LoadFont() +bool DebuggerPlugin::LoadFont() { - const Core::String font_family_name = "rmlui-debugger-font"; + const String font_family_name = "rmlui-debugger-font"; - return (Core::LoadFontFace(courier_prime_code, sizeof(courier_prime_code)/sizeof(courier_prime_code[0]), font_family_name, Core::Style::FontStyle::Normal, Core::Style::FontWeight::Normal) && - Core::LoadFontFace(courier_prime_code_italic, sizeof(courier_prime_code_italic)/sizeof(courier_prime_code_italic[0]), font_family_name, Core::Style::FontStyle::Italic, Core::Style::FontWeight::Normal)); + return (LoadFontFace(courier_prime_code, sizeof(courier_prime_code)/sizeof(courier_prime_code[0]), font_family_name, Style::FontStyle::Normal, Style::FontWeight::Normal) && + LoadFontFace(courier_prime_code_italic, sizeof(courier_prime_code_italic)/sizeof(courier_prime_code_italic[0]), font_family_name, Style::FontStyle::Italic, Style::FontWeight::Normal)); } -bool Plugin::LoadMenuElement() +bool DebuggerPlugin::LoadMenuElement() { menu_element = host_context->CreateDocument(); if (!menu_element) return false; menu_element->SetId("rmlui-debug-menu"); - menu_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + menu_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); menu_element->SetInnerRML(menu_rml); - Core::SharedPtr style_sheet = Core::Factory::InstanceStyleSheetString(menu_rcss); + SharedPtr style_sheet = Factory::InstanceStyleSheetString(menu_rcss); if (!style_sheet) { host_context->UnloadDocument(menu_element); @@ -308,30 +308,30 @@ bool Plugin::LoadMenuElement() menu_element->SetStyleSheet(std::move(style_sheet)); // Set the version info in the menu. - menu_element->GetElementById("version-number")->SetInnerRML("v" + Rml::Core::GetVersion()); + menu_element->GetElementById("version-number")->SetInnerRML("v" + Rml::GetVersion()); // Attach to the buttons. - Core::Element* event_log_button = menu_element->GetElementById("event-log-button"); - event_log_button->AddEventListener(Rml::Core::EventId::Click, this); + Element* event_log_button = menu_element->GetElementById("event-log-button"); + event_log_button->AddEventListener(EventId::Click, this); - Core::Element* element_info_button = menu_element->GetElementById("debug-info-button"); - element_info_button->AddEventListener(Rml::Core::EventId::Click, this); + Element* element_info_button = menu_element->GetElementById("debug-info-button"); + element_info_button->AddEventListener(EventId::Click, this); - Core::Element* outlines_button = menu_element->GetElementById("outlines-button"); - outlines_button->AddEventListener(Rml::Core::EventId::Click, this); + Element* outlines_button = menu_element->GetElementById("outlines-button"); + outlines_button->AddEventListener(EventId::Click, this); return true; } -bool Plugin::LoadInfoElement() +bool DebuggerPlugin::LoadInfoElement() { - info_element_instancer = std::make_unique< Core::ElementInstancerGeneric >(); - Core::Factory::RegisterElementInstancer("debug-info", info_element_instancer.get()); + info_element_instancer = std::make_unique< ElementInstancerGeneric >(); + Factory::RegisterElementInstancer("debug-info", info_element_instancer.get()); info_element = rmlui_dynamic_cast< ElementInfo* >(host_context->CreateDocument("debug-info")); if (!info_element) return false; - info_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + info_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); if (!info_element->Initialise()) { @@ -344,15 +344,15 @@ bool Plugin::LoadInfoElement() return true; } -bool Plugin::LoadLogElement() +bool DebuggerPlugin::LoadLogElement() { - log_element_instancer = std::make_unique< Core::ElementInstancerGeneric >(); - Core::Factory::RegisterElementInstancer("debug-log", log_element_instancer.get()); + log_element_instancer = std::make_unique< ElementInstancerGeneric >(); + Factory::RegisterElementInstancer("debug-log", log_element_instancer.get()); log_element = rmlui_dynamic_cast< ElementLog* >(host_context->CreateDocument("debug-log")); if (!log_element) return false; - log_element->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + log_element->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); if (!log_element->Initialise()) { @@ -363,14 +363,14 @@ bool Plugin::LoadLogElement() } // Make the system interface; this will trap the log messages for us. - application_interface = Core::GetSystemInterface(); - log_interface = std::make_unique(application_interface, log_element); - Core::SetSystemInterface(log_interface.get()); + application_interface = Rml::GetSystemInterface(); + log_interface = std::make_unique(application_interface, log_element); + Rml::SetSystemInterface(log_interface.get()); return true; } -void Plugin::ReleaseElements() +void DebuggerPlugin::ReleaseElements() { if (host_context) { @@ -390,7 +390,7 @@ void Plugin::ReleaseElements() { host_context->UnloadDocument(log_element); log_element = nullptr; - Core::SetSystemInterface(application_interface); + Rml::SetSystemInterface(application_interface); application_interface = nullptr; log_interface.reset(); } diff --git a/Source/Debugger/Plugin.h b/Source/Debugger/DebuggerPlugin.h similarity index 80% rename from Source/Debugger/Plugin.h rename to Source/Debugger/DebuggerPlugin.h index e624cd863..b1e1a20ad 100644 --- a/Source/Debugger/Plugin.h +++ b/Source/Debugger/DebuggerPlugin.h @@ -26,26 +26,23 @@ * */ -#ifndef RMLUIDEBUGGERPLUGIN_H -#define RMLUIDEBUGGERPLUGIN_H +#ifndef RMLUI_DEBUGGER_DEBUGGERPLUGIN_H +#define RMLUI_DEBUGGER_DEBUGGERPLUGIN_H #include "../../Include/RmlUi/Core/EventListener.h" #include "../../Include/RmlUi/Core/Plugin.h" namespace Rml { -namespace Core { class ElementDocument; class SystemInterface; -} - namespace Debugger { class ElementLog; class ElementInfo; class ElementContextHook; -class SystemInterface; +class DebuggerSystemInterface; /** RmlUi plugin interface for the debugger. @@ -53,21 +50,21 @@ class SystemInterface; @author Robert Curry */ -class Plugin : public Core::Plugin, public Core::EventListener +class DebuggerPlugin : public Rml::Plugin, public Rml::EventListener { public: - Plugin(); - ~Plugin(); + DebuggerPlugin(); + ~DebuggerPlugin(); /// Initialises the debugging tools into the given context. /// @param[in] context The context to load the tools into. /// @return True on success, false if an error occured. - bool Initialise(Core::Context* context); + bool Initialise(Context* context); /// Sets the context to be debugged. /// @param[in] context The context to be debugged. /// @return True if the debugger is initialised and the context was switched, false otherwise.. - bool SetContext(Core::Context* context); + bool SetContext(Context* context); /// Sets the visibility of the debugger. /// @param[in] visibility True to show the debugger, false to hide it. @@ -84,19 +81,19 @@ class Plugin : public Core::Plugin, public Core::EventListener /// Called whenever a RmlUi context is destroyed. /// @param[in] context The destroyed context. - void OnContextDestroy(Core::Context* context) override; + void OnContextDestroy(Context* context) override; /// Called whenever an element is destroyed. /// @param[in] element The destroyed element. - void OnElementDestroy(Core::Element* element) override; + void OnElementDestroy(Element* element) override; /// Event handler for events from the debugger elements. /// @param[in] event The event to process. - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; /// Access the singleton instance of the debugger /// @return nullptr or an instance of the plugin - static Plugin* GetInstance(); + static DebuggerPlugin* GetInstance(); private: bool LoadFont(); @@ -108,28 +105,28 @@ class Plugin : public Core::Plugin, public Core::EventListener void ReleaseElements(); // The context hosting the debug documents. - Core::Context* host_context; + Context* host_context; // The context we're debugging. - Core::Context* debug_context; + Context* debug_context; // The debug elements. - Core::ElementDocument* menu_element; + ElementDocument* menu_element; ElementInfo* info_element; ElementLog* log_element; ElementContextHook* hook_element; - Core::SystemInterface* application_interface; - std::unique_ptr log_interface; + Rml::SystemInterface* application_interface; + std::unique_ptr log_interface; - std::unique_ptr hook_element_instancer, info_element_instancer, log_element_instancer; + std::unique_ptr hook_element_instancer, info_element_instancer, log_element_instancer; bool render_outlines; // Singleton instance - static Plugin* instance; + static DebuggerPlugin* instance; }; } -} +} // namespace Rml #endif diff --git a/Source/Debugger/SystemInterface.cpp b/Source/Debugger/DebuggerSystemInterface.cpp similarity index 76% rename from Source/Debugger/SystemInterface.cpp rename to Source/Debugger/DebuggerSystemInterface.cpp index 5825becbd..203c536cd 100644 --- a/Source/Debugger/SystemInterface.cpp +++ b/Source/Debugger/DebuggerSystemInterface.cpp @@ -26,37 +26,37 @@ * */ -#include "SystemInterface.h" +#include "DebuggerSystemInterface.h" #include "ElementLog.h" namespace Rml { namespace Debugger { -SystemInterface::SystemInterface(Core::SystemInterface* _application_interface, ElementLog* _log) +DebuggerSystemInterface::DebuggerSystemInterface(Rml::SystemInterface* _application_interface, ElementLog* _log) { application_interface = _application_interface; log = _log; } -SystemInterface::~SystemInterface() +DebuggerSystemInterface::~DebuggerSystemInterface() { application_interface = nullptr; } // Get the number of seconds elapsed since the start of the application. -double SystemInterface::GetElapsedTime() +double DebuggerSystemInterface::GetElapsedTime() { return application_interface->GetElapsedTime(); } // Translate the input string into the translated string. -int SystemInterface::TranslateString(Core::String& translated, const Core::String& input) +int DebuggerSystemInterface::TranslateString(String& translated, const String& input) { return application_interface->TranslateString(translated, input); } // Log the specified message. -bool SystemInterface::LogMessage(Core::Log::Type type, const Core::String& message) +bool DebuggerSystemInterface::LogMessage(Log::Type type, const String& message) { log->AddLogMessage(type, message); @@ -64,29 +64,29 @@ bool SystemInterface::LogMessage(Core::Log::Type type, const Core::String& messa } // Set mouse cursor. -void SystemInterface::SetMouseCursor(const Core::String& cursor_name) +void DebuggerSystemInterface::SetMouseCursor(const String& cursor_name) { application_interface->SetMouseCursor(cursor_name); } -void SystemInterface::SetClipboardText(const Core::String& text) +void DebuggerSystemInterface::SetClipboardText(const String& text) { application_interface->SetClipboardText(text); } -void SystemInterface::GetClipboardText(Core::String& text) +void DebuggerSystemInterface::GetClipboardText(String& text) { application_interface->GetClipboardText(text); } // Activate keyboard (for touchscreen devices) -void SystemInterface::ActivateKeyboard() +void DebuggerSystemInterface::ActivateKeyboard() { application_interface->ActivateKeyboard(); } // Deactivate keyboard (for touchscreen devices) -void SystemInterface::DeactivateKeyboard() +void DebuggerSystemInterface::DeactivateKeyboard() { application_interface->DeactivateKeyboard(); } diff --git a/Source/Debugger/SystemInterface.h b/Source/Debugger/DebuggerSystemInterface.h similarity index 81% rename from Source/Debugger/SystemInterface.h rename to Source/Debugger/DebuggerSystemInterface.h index 33da4050f..970392348 100644 --- a/Source/Debugger/SystemInterface.h +++ b/Source/Debugger/DebuggerSystemInterface.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGERSYSTEMINTERFACE_H -#define RMLUIDEBUGGERSYSTEMINTERFACE_H +#ifndef RMLUI_DEBUGGER_DEBUGGERSYSTEMINTERFACE_H +#define RMLUI_DEBUGGER_DEBUGGERSYSTEMINTERFACE_H #include "../../Include/RmlUi/Core/SystemInterface.h" @@ -43,13 +43,13 @@ class ElementLog; @author Peter Curry */ -class SystemInterface : public Core::SystemInterface +class DebuggerSystemInterface : public Rml::SystemInterface { public: /// Instances a new debugging log interface. /// @param[in] log The logging element to send messages to. - SystemInterface(Core::SystemInterface* application_interface, ElementLog* log); - virtual ~SystemInterface(); + DebuggerSystemInterface(Rml::SystemInterface* application_interface, ElementLog* log); + virtual ~DebuggerSystemInterface(); /// Get the number of seconds elapsed since the start of the application. /// @return Elapsed time, in seconds. @@ -59,25 +59,25 @@ class SystemInterface : public Core::SystemInterface /// @param[out] translated Translated string ready for display. /// @param[in] input String as received from XML. /// @return Number of translations that occured. - int TranslateString(Core::String& translated, const Core::String& input) override; + int TranslateString(String& translated, const String& input) override; /// Log the specified message. /// @param[in] type Type of log message, ERROR, WARNING, etc. /// @param[in] message Message to log. /// @return True to continue execution, false to break into the debugger. - bool LogMessage(Core::Log::Type type, const Core::String& message) override; + bool LogMessage(Log::Type type, const String& message) override; /// Set mouse cursor. /// @param[in] cursor_name Cursor name to activate. - void SetMouseCursor(const Core::String& cursor_name) override; + void SetMouseCursor(const String& cursor_name) override; /// Set clipboard text. /// @param[in] text Text to apply to clipboard. - void SetClipboardText(const Core::String& text) override; + void SetClipboardText(const String& text) override; /// Get clipboard text. /// @param[out] text Retrieved text from clipboard. - void GetClipboardText(Core::String& text) override; + void GetClipboardText(String& text) override; /// Activate keyboard (for touchscreen devices) void ActivateKeyboard() override; @@ -85,11 +85,11 @@ class SystemInterface : public Core::SystemInterface /// Deactivate keyboard (for touchscreen devices) void DeactivateKeyboard() override; private: - Core::SystemInterface* application_interface; + Rml::SystemInterface* application_interface; ElementLog* log; }; } -} +} // namespace Rml #endif diff --git a/Source/Debugger/ElementContextHook.cpp b/Source/Debugger/ElementContextHook.cpp index 0c8c065eb..a42f2eb5b 100644 --- a/Source/Debugger/ElementContextHook.cpp +++ b/Source/Debugger/ElementContextHook.cpp @@ -27,12 +27,12 @@ */ #include "ElementContextHook.h" -#include "Plugin.h" +#include "DebuggerPlugin.h" namespace Rml { namespace Debugger { -ElementContextHook::ElementContextHook(const Core::String& tag) : Core::ElementDocument(tag) +ElementContextHook::ElementContextHook(const String& tag) : ElementDocument(tag) { debugger = nullptr; } @@ -41,7 +41,7 @@ ElementContextHook::~ElementContextHook() { } -void ElementContextHook::Initialise(Plugin* _debugger) +void ElementContextHook::Initialise(DebuggerPlugin* _debugger) { SetId("rmlui-debug-hook"); debugger = _debugger; diff --git a/Source/Debugger/ElementContextHook.h b/Source/Debugger/ElementContextHook.h index 123938557..1074ae126 100644 --- a/Source/Debugger/ElementContextHook.h +++ b/Source/Debugger/ElementContextHook.h @@ -26,15 +26,15 @@ * */ -#ifndef RMLUIDEBUGGERELEMENTCONTEXTHOOK_H -#define RMLUIDEBUGGERELEMENTCONTEXTHOOK_H +#ifndef RMLUI_DEBUGGER_ELEMENTCONTEXTHOOK_H +#define RMLUI_DEBUGGER_ELEMENTCONTEXTHOOK_H #include "../../Include/RmlUi/Core/ElementDocument.h" namespace Rml { namespace Debugger { -class Plugin; +class DebuggerPlugin; /** An element that the debugger uses to render into a foreign context. @@ -42,23 +42,23 @@ class Plugin; @author Peter Curry */ -class ElementContextHook : public Core::ElementDocument +class ElementContextHook : public ElementDocument { public: - RMLUI_RTTI_DefineWithParent(ElementContextHook, Core::ElementDocument) + RMLUI_RTTI_DefineWithParent(ElementContextHook, ElementDocument) - ElementContextHook(const Core::String& tag); + ElementContextHook(const String& tag); virtual ~ElementContextHook(); - void Initialise(Plugin* debugger); + void Initialise(DebuggerPlugin* debugger); void OnRender() override; private: - Plugin* debugger; + DebuggerPlugin* debugger; }; } -} +} // namespace Rml #endif diff --git a/Source/Debugger/ElementInfo.cpp b/Source/Debugger/ElementInfo.cpp index 82704b163..6a677c294 100644 --- a/Source/Debugger/ElementInfo.cpp +++ b/Source/Debugger/ElementInfo.cpp @@ -44,7 +44,7 @@ namespace Rml { namespace Debugger { -ElementInfo::ElementInfo(const Core::String& tag) : Core::ElementDocument(tag) +ElementInfo::ElementInfo(const String& tag) : ElementDocument(tag) { hover_element = nullptr; source_element = nullptr; @@ -66,11 +66,11 @@ bool ElementInfo::Initialise() SetInnerRML(info_rml); SetId("rmlui-debug-info"); - AddEventListener(Core::EventId::Click, this); - AddEventListener(Core::EventId::Mouseover, this); - AddEventListener(Core::EventId::Mouseout, this); + AddEventListener(EventId::Click, this); + AddEventListener(EventId::Mouseover, this); + AddEventListener(EventId::Mouseout, this); - Core::SharedPtr style_sheet = Core::Factory::InstanceStyleSheetString(Core::String(common_rcss) + Core::String(info_rcss)); + SharedPtr style_sheet = Factory::InstanceStyleSheetString(String(common_rcss) + String(info_rcss)); if (!style_sheet) return false; @@ -92,7 +92,7 @@ void ElementInfo::OnUpdate() { if (source_element && (update_source_element || force_update_once) && IsVisible()) { - const double t = Core::GetSystemInterface()->GetElapsedTime(); + const double t = GetSystemInterface()->GetElapsedTime(); const float dt = (float)(t - previous_update_time); constexpr float update_interval = 0.3f; @@ -120,7 +120,7 @@ void ElementInfo::OnUpdate() } // Called when an element is destroyed. -void ElementInfo::OnElementDestroy(Core::Element* element) +void ElementInfo::OnElementDestroy(Element* element) { if (hover_element == element) hover_element = nullptr; @@ -133,17 +133,17 @@ void ElementInfo::RenderHoverElement() { if (hover_element) { - Core::ElementUtilities::ApplyTransform(*hover_element); + ElementUtilities::ApplyTransform(*hover_element); for (int i = 0; i < hover_element->GetNumBoxes(); i++) { // Render the content area. - const Core::Box element_box = hover_element->GetBox(i); - Core::Vector2f size = element_box.GetSize(Core::Box::BORDER); - size = Core::Vector2f(std::max(size.x, 2.0f), std::max(size.y, 2.0f)); + const Box element_box = hover_element->GetBox(i); + Vector2f size = element_box.GetSize(Box::BORDER); + size = Vector2f(std::max(size.x, 2.0f), std::max(size.y, 2.0f)); Geometry::RenderOutline( - hover_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::BORDER), + hover_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::BORDER), size, - Core::Colourb(255, 0, 0, 255), + Colourb(255, 0, 0, 255), 1 ); } @@ -154,45 +154,45 @@ void ElementInfo::RenderSourceElement() { if (source_element && show_source_element) { - Core::ElementUtilities::ApplyTransform(*source_element); + ElementUtilities::ApplyTransform(*source_element); for (int i = 0; i < source_element->GetNumBoxes(); i++) { - const Core::Box element_box = source_element->GetBox(i); + const Box element_box = source_element->GetBox(i); // Content area: - Geometry::RenderBox(source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::CONTENT), element_box.GetSize(), Core::Colourb(158, 214, 237, 128)); + Geometry::RenderBox(source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::CONTENT), element_box.GetSize(), Colourb(158, 214, 237, 128)); // Padding area: - Geometry::RenderBox(source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::PADDING), element_box.GetSize(Core::Box::PADDING), source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::CONTENT), element_box.GetSize(), Core::Colourb(135, 122, 214, 128)); + Geometry::RenderBox(source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::PADDING), element_box.GetSize(Box::PADDING), source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::CONTENT), element_box.GetSize(), Colourb(135, 122, 214, 128)); // Border area: - Geometry::RenderBox(source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::BORDER), element_box.GetSize(Core::Box::BORDER), source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::PADDING), element_box.GetSize(Core::Box::PADDING), Core::Colourb(133, 133, 133, 128)); + Geometry::RenderBox(source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::BORDER), element_box.GetSize(Box::BORDER), source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::PADDING), element_box.GetSize(Box::PADDING), Colourb(133, 133, 133, 128)); // Border area: - Geometry::RenderBox(source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::MARGIN), element_box.GetSize(Core::Box::MARGIN), source_element->GetAbsoluteOffset(Core::Box::BORDER) + element_box.GetPosition(Core::Box::BORDER), element_box.GetSize(Core::Box::BORDER), Core::Colourb(240, 255, 131, 128)); + Geometry::RenderBox(source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::MARGIN), element_box.GetSize(Box::MARGIN), source_element->GetAbsoluteOffset(Box::BORDER) + element_box.GetPosition(Box::BORDER), element_box.GetSize(Box::BORDER), Colourb(240, 255, 131, 128)); } } } -void ElementInfo::ProcessEvent(Core::Event& event) +void ElementInfo::ProcessEvent(Event& event) { // Only process events if we're visible if (IsVisible()) { - if (event == Core::EventId::Click) + if (event == EventId::Click) { - Core::Element* target_element = event.GetTargetElement(); + Element* target_element = event.GetTargetElement(); // Deal with clicks on our own elements differently. if (target_element->GetOwnerDocument() == this) { - const Core::String& id = event.GetTargetElement()->GetId(); + const String& id = event.GetTargetElement()->GetId(); if (id == "close_button") { if (IsVisible()) - SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); } else if (id == "update_source") { @@ -211,7 +211,7 @@ void ElementInfo::ProcessEvent(Core::Event& event) } else if (target_element->GetTagName() == "pseudo" && source_element) { - const Core::String name = target_element->GetAttribute("name", ""); + const String name = target_element->GetAttribute("name", ""); if (!name.empty()) { @@ -237,7 +237,7 @@ void ElementInfo::ProcessEvent(Core::Event& event) int element_index; if (sscanf(target_element->GetId().c_str(), "a %d", &element_index) == 1) { - Core::Element* new_source_element = source_element; + Element* new_source_element = source_element; for (int i = 0; i < element_index; i++) { if (new_source_element != nullptr) @@ -256,7 +256,7 @@ void ElementInfo::ProcessEvent(Core::Event& event) // Otherwise we just want to focus on the clicked element (unless it's on a debug element) else if (enable_element_select && target_element->GetOwnerDocument() != nullptr && !IsDebuggerElement(target_element)) { - Core::Element* new_source_element = target_element; + Element* new_source_element = target_element; if (new_source_element != source_element) { SetSourceElement(new_source_element); @@ -264,14 +264,14 @@ void ElementInfo::ProcessEvent(Core::Event& event) } } } - else if (event == Core::EventId::Mouseover) + else if (event == EventId::Mouseover) { - Core::Element* target_element = event.GetTargetElement(); - Core::ElementDocument* owner_document = target_element->GetOwnerDocument(); + Element* target_element = event.GetTargetElement(); + ElementDocument* owner_document = target_element->GetOwnerDocument(); if (owner_document == this) { // Check if the id is in the form "a %d" or "c %d" - these are the ancestor or child labels. - const Core::String& id = target_element->GetId(); + const String& id = target_element->GetId(); int element_index; if (sscanf(id.c_str(), "a %d", &element_index) == 1) { @@ -309,13 +309,13 @@ void ElementInfo::ProcessEvent(Core::Event& event) hover_element = target_element; } } - else if (event == Core::EventId::Mouseout) + else if (event == EventId::Mouseout) { - Core::Element* target_element = event.GetTargetElement(); - Core::ElementDocument* owner_document = target_element->GetOwnerDocument(); + Element* target_element = event.GetTargetElement(); + ElementDocument* owner_document = target_element->GetOwnerDocument(); if (owner_document == this) { - const Core::String& id = target_element->GetId(); + const String& id = target_element->GetId(); if (id == "show_source") { // Disable the preview of the source element view @@ -332,7 +332,7 @@ void ElementInfo::ProcessEvent(Core::Event& event) } } -void ElementInfo::SetSourceElement(Core::Element* new_source_element) +void ElementInfo::SetSourceElement(Element* new_source_element) { source_element = new_source_element; force_update_once = true; @@ -340,13 +340,13 @@ void ElementInfo::SetSourceElement(Core::Element* new_source_element) void ElementInfo::UpdateSourceElement() { - previous_update_time = Core::GetSystemInterface()->GetElapsedTime(); + previous_update_time = GetSystemInterface()->GetElapsedTime(); title_dirty = true; // Set the pseudo classes - if (Core::Element* pseudo = GetElementById("pseudo")) + if (Element* pseudo = GetElementById("pseudo")) { - Core::PseudoClassList list; + PseudoClassList list; if (source_element) list = source_element->GetActivePseudoClasses(); @@ -355,7 +355,7 @@ void ElementInfo::UpdateSourceElement() for (int i = 0; i < pseudo->GetNumChildren(); i++) { Element* child = pseudo->GetChild(i); - const Core::String name = child->GetAttribute("name", ""); + const String name = child->GetAttribute("name", ""); if (!name.empty()) { @@ -368,7 +368,7 @@ void ElementInfo::UpdateSourceElement() for (int j = 0; j < child->GetNumChildren(); j++) { Element* grandchild = child->GetChild(j); - const Core::String grandchild_name = grandchild->GetAttribute("name", ""); + const String grandchild_name = grandchild->GetAttribute("name", ""); bool active = (list.erase(grandchild_name) == 1); if(!active) child->RemoveChild(grandchild); @@ -376,7 +376,7 @@ void ElementInfo::UpdateSourceElement() // Finally, create new pseudo buttons for the rest of the active pseudo classes. for (auto& extra_pseudo : list) { - Core::Element* grandchild = child->AppendChild(CreateElement("pseudo")); + Element* grandchild = child->AppendChild(CreateElement("pseudo")); grandchild->SetClass("active", true); grandchild->SetAttribute("name", extra_pseudo); grandchild->SetInnerRML(":" + extra_pseudo); @@ -386,15 +386,15 @@ void ElementInfo::UpdateSourceElement() } // Set the attributes - if (Core::Element* attributes_content = GetElementById("attributes-content")) + if (Element* attributes_content = GetElementById("attributes-content")) { - Core::String attributes; + String attributes; if (source_element != nullptr) { { - Core::String name; - Core::String value; + String name; + String value; // The element's attribute list is not always synchronized with its internal values, fetch // them manually here (see e.g. Element::OnAttributeChange for relevant attributes) @@ -402,13 +402,13 @@ void ElementInfo::UpdateSourceElement() name = "id"; value = source_element->GetId(); if (!value.empty()) - attributes += Core::CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); + attributes += CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); } { name = "class"; value = source_element->GetClassNames(); if (!value.empty()) - attributes += Core::CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); + attributes += CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); } } @@ -416,16 +416,16 @@ void ElementInfo::UpdateSourceElement() { auto& name = pair.first; auto& variant = pair.second; - Core::String value = Core::StringUtilities::EncodeRml(variant.Get()); + String value = StringUtilities::EncodeRml(variant.Get()); if(name != "class" && name != "style" && name != "id") - attributes += Core::CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); + attributes += CreateString(name.size() + value.size() + 32, "%s: %s
", name.c_str(), value.c_str()); } // Text is not an attribute but useful nonetheless - if (auto text_element = rmlui_dynamic_cast(source_element)) + if (auto text_element = rmlui_dynamic_cast(source_element)) { - const Core::String& text_content = text_element->GetText(); - attributes += Core::CreateString(text_content.size() + 32, "Text: %s
", text_content.c_str()); + const String& text_content = text_element->GetText(); + attributes += CreateString(text_content.size() + 32, "Text: %s
", text_content.c_str()); } } @@ -443,9 +443,9 @@ void ElementInfo::UpdateSourceElement() } // Set the properties - if (Core::Element* properties_content = GetElementById("properties-content")) + if (Element* properties_content = GetElementById("properties-content")) { - Core::String properties; + String properties; if (source_element != nullptr) BuildElementPropertiesRML(properties, source_element, source_element); @@ -463,9 +463,9 @@ void ElementInfo::UpdateSourceElement() } // Set the events - if (Core::Element* events_content = GetElementById("events-content")) + if (Element* events_content = GetElementById("events-content")) { - Core::String events; + String events; if (source_element != nullptr) { @@ -486,19 +486,19 @@ void ElementInfo::UpdateSourceElement() } // Set the position - if (Core::Element* position_content = GetElementById("position-content")) + if (Element* position_content = GetElementById("position-content")) { // left, top, width, height. if (source_element != nullptr) { - const Core::Vector2f element_offset = source_element->GetRelativeOffset(Core::Box::BORDER); - const Core::Vector2f element_size = source_element->GetBox().GetSize(Core::Box::BORDER); + const Vector2f element_offset = source_element->GetRelativeOffset(Box::BORDER); + const Vector2f element_size = source_element->GetBox().GetSize(Box::BORDER); - const Core::String positions = - "left: " + Core::ToString(element_offset.x) + "px
" + - "top: " + Core::ToString(element_offset.y) + "px
" + - "width: " + Core::ToString(element_size.x) + "px
" + - "height: " + Core::ToString(element_size.y) + "px
"; + const String positions = + "left: " + ToString(element_offset.x) + "px
" + + "top: " + ToString(element_offset.y) + "px
" + + "width: " + ToString(element_size.x) + "px
" + + "height: " + ToString(element_size.y) + "px
"; position_content->SetInnerRML( positions ); } @@ -510,18 +510,18 @@ void ElementInfo::UpdateSourceElement() } // Set the ancestors - if (Core::Element* ancestors_content = GetElementById("ancestors-content")) + if (Element* ancestors_content = GetElementById("ancestors-content")) { - Core::String ancestors; - Core::Element* element_ancestor = nullptr; + String ancestors; + Element* element_ancestor = nullptr; if (source_element != nullptr) element_ancestor = source_element->GetParentNode(); int ancestor_depth = 1; while (element_ancestor) { - Core::String ancestor_name = element_ancestor->GetAddress(false, false); - ancestors += Core::CreateString(ancestor_name.size() + 32, "

%s

", ancestor_depth, ancestor_name.c_str()); + String ancestor_name = element_ancestor->GetAddress(false, false); + ancestors += CreateString(ancestor_name.size() + 32, "

%s

", ancestor_depth, ancestor_name.c_str()); element_ancestor = element_ancestor->GetParentNode(); ancestor_depth++; } @@ -540,23 +540,23 @@ void ElementInfo::UpdateSourceElement() } // Set the children - if (Core::Element* children_content = GetElementById("children-content")) + if (Element* children_content = GetElementById("children-content")) { - Core::String children; + String children; if (source_element != nullptr) { const int num_dom_children = (source_element->GetNumChildren(false)); for (int i = 0; i < source_element->GetNumChildren(true); i++) { - Core::Element* child = source_element->GetChild(i); + Element* child = source_element->GetChild(i); // If this is a debugger document, do not show it. if (IsDebuggerElement(child)) continue; - Core::String child_name = child->GetTagName(); - const Core::String child_id = child->GetId(); + String child_name = child->GetTagName(); + const String child_id = child->GetId(); if (!child_id.empty()) { child_name += "#"; @@ -564,7 +564,7 @@ void ElementInfo::UpdateSourceElement() } const char* non_dom_string = (i >= num_dom_children ? " class=\"non_dom\"" : ""); - children += Core::CreateString(child_name.size() + 40, "

%s

", i, non_dom_string, child_name.c_str()); + children += CreateString(child_name.size() + 40, "

%s

", i, non_dom_string, child_name.c_str()); } } @@ -582,15 +582,15 @@ void ElementInfo::UpdateSourceElement() } } -void ElementInfo::BuildElementPropertiesRML(Core::String& property_rml, Core::Element* element, Core::Element* primary_element) +void ElementInfo::BuildElementPropertiesRML(String& property_rml, Element* element, Element* primary_element) { NamedPropertyList property_list; for(auto it = element->IterateLocalProperties(); !it.AtEnd(); ++it) { - Core::PropertyId property_id = it.GetId(); - const Core::String& property_name = it.GetName(); - const Core::Property* prop = &it.GetProperty(); + PropertyId property_id = it.GetId(); + const String& property_name = it.GetName(); + const Property* prop = &it.GetProperty(); // Check that this property isn't overridden or just not inherited. if (primary_element->GetProperty(property_id) != prop) @@ -615,7 +615,7 @@ void ElementInfo::BuildElementPropertiesRML(Core::String& property_rml, Core::El property_rml += "

inherited from " + element->GetAddress(false, false) + "

"; } - const Core::PropertySource* previous_source = nullptr; + const PropertySource* previous_source = nullptr; bool first_iteration = true; for (auto& named_property : property_list) @@ -629,8 +629,8 @@ void ElementInfo::BuildElementPropertiesRML(Core::String& property_rml, Core::El // Print the rule name header. if(source) { - Core::String str_line_number; - Core::TypeConverter::Convert(source->line_number, str_line_number); + String str_line_number; + TypeConverter::Convert(source->line_number, str_line_number); property_rml += "

" + source->rule_name + "

"; property_rml += "

" + source->path + " : " + str_line_number + "

"; } @@ -648,9 +648,9 @@ void ElementInfo::BuildElementPropertiesRML(Core::String& property_rml, Core::El BuildElementPropertiesRML(property_rml, element->GetParentNode(), primary_element); } -void ElementInfo::BuildPropertyRML(Core::String& property_rml, const Core::String& name, const Core::Property* property) +void ElementInfo::BuildPropertyRML(String& property_rml, const String& name, const Property* property) { - const Core::String property_value = property->ToString(); + const String property_value = property->ToString(); property_rml += "" + name + ": " + property_value + "
"; } @@ -678,7 +678,7 @@ void ElementInfo::UpdateTitle() } -bool ElementInfo::IsDebuggerElement(Core::Element* element) +bool ElementInfo::IsDebuggerElement(Element* element) { return element->GetOwnerDocument()->GetId().find("rmlui-debug-") == 0; } diff --git a/Source/Debugger/ElementInfo.h b/Source/Debugger/ElementInfo.h index 4b417c638..858b1d620 100644 --- a/Source/Debugger/ElementInfo.h +++ b/Source/Debugger/ElementInfo.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGERELEMENTINFO_H -#define RMLUIDEBUGGERELEMENTINFO_H +#ifndef RMLUI_DEBUGGER_ELEMENTINFO_H +#define RMLUI_DEBUGGER_ELEMENTINFO_H #include "../../Include/RmlUi/Core/ElementDocument.h" #include "../../Include/RmlUi/Core/EventListener.h" @@ -35,19 +35,19 @@ namespace Rml { namespace Debugger { -typedef std::pair< Core::String, const Core::Property* > NamedProperty; +typedef std::pair< String, const Property* > NamedProperty; typedef std::vector< NamedProperty > NamedPropertyList; /** @author Robert Curry */ -class ElementInfo : public Core::ElementDocument, public Core::EventListener +class ElementInfo : public ElementDocument, public EventListener { public: - RMLUI_RTTI_DefineWithParent(ElementInfo, Core::ElementDocument) + RMLUI_RTTI_DefineWithParent(ElementInfo, ElementDocument) - ElementInfo(const Core::String& tag); + ElementInfo(const String& tag); ~ElementInfo(); /// Initialises the info element. @@ -57,30 +57,30 @@ class ElementInfo : public Core::ElementDocument, public Core::EventListener void Reset(); /// Called when an element is destroyed. - void OnElementDestroy(Core::Element* element); + void OnElementDestroy(Element* element); void RenderHoverElement(); void RenderSourceElement(); protected: - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; /// Updates the element info if changed void OnUpdate() override; private: - void SetSourceElement(Core::Element* new_source_element); + void SetSourceElement(Element* new_source_element); void UpdateSourceElement(); - void BuildElementPropertiesRML(Core::String& property_rml, Core::Element* element, Core::Element* primary_element); - void BuildPropertyRML(Core::String& property_rml, const Core::String& name, const Core::Property* property); + void BuildElementPropertiesRML(String& property_rml, Element* element, Element* primary_element); + void BuildPropertyRML(String& property_rml, const String& name, const Property* property); void UpdateTitle(); - bool IsDebuggerElement(Core::Element* element); + bool IsDebuggerElement(Element* element); double previous_update_time; - Core::String attributes_rml, properties_rml, events_rml, ancestors_rml, children_rml; + String attributes_rml, properties_rml, events_rml, ancestors_rml, children_rml; // Enables or disables the selection of elements in user context. bool enable_element_select; @@ -93,11 +93,11 @@ class ElementInfo : public Core::ElementDocument, public Core::EventListener bool title_dirty; - Core::Element* hover_element; - Core::Element* source_element; + Element* hover_element; + Element* source_element; }; } -} +} // namespace Rml #endif diff --git a/Source/Debugger/ElementLog.cpp b/Source/Debugger/ElementLog.cpp index c045d9e99..d7bacd3fa 100644 --- a/Source/Debugger/ElementLog.cpp +++ b/Source/Debugger/ElementLog.cpp @@ -39,43 +39,43 @@ namespace Debugger { const int MAX_LOG_MESSAGES = 50; -ElementLog::ElementLog(const Core::String& tag) : Core::ElementDocument(tag) +ElementLog::ElementLog(const String& tag) : ElementDocument(tag) { dirty_logs = false; beacon = nullptr; - current_beacon_level = Core::Log::LT_MAX; + current_beacon_level = Log::LT_MAX; auto_scroll = true; message_content = nullptr; current_index = 0; // Set up the log type buttons. - log_types[Core::Log::LT_ALWAYS].visible = true; - log_types[Core::Log::LT_ALWAYS].class_name = "error"; - log_types[Core::Log::LT_ALWAYS].alert_contents = "A"; - - log_types[Core::Log::LT_ERROR].visible = true; - log_types[Core::Log::LT_ERROR].class_name = "error"; - log_types[Core::Log::LT_ERROR].alert_contents = "!"; - log_types[Core::Log::LT_ERROR].button_name = "error_button"; - - log_types[Core::Log::LT_ASSERT].visible = true; - log_types[Core::Log::LT_ASSERT].class_name = "error"; - log_types[Core::Log::LT_ASSERT].alert_contents = "!"; - - log_types[Core::Log::LT_WARNING].visible = true; - log_types[Core::Log::LT_WARNING].class_name = "warning"; - log_types[Core::Log::LT_WARNING].alert_contents = "!"; - log_types[Core::Log::LT_WARNING].button_name = "warning_button"; - - log_types[Core::Log::LT_INFO].visible = false; - log_types[Core::Log::LT_INFO].class_name = "info"; - log_types[Core::Log::LT_INFO].alert_contents = "i"; - log_types[Core::Log::LT_INFO].button_name = "info_button"; - - log_types[Core::Log::LT_DEBUG].visible = true; - log_types[Core::Log::LT_DEBUG].class_name = "debug"; - log_types[Core::Log::LT_DEBUG].alert_contents = "?"; - log_types[Core::Log::LT_DEBUG].button_name = "debug_button"; + log_types[Log::LT_ALWAYS].visible = true; + log_types[Log::LT_ALWAYS].class_name = "error"; + log_types[Log::LT_ALWAYS].alert_contents = "A"; + + log_types[Log::LT_ERROR].visible = true; + log_types[Log::LT_ERROR].class_name = "error"; + log_types[Log::LT_ERROR].alert_contents = "!"; + log_types[Log::LT_ERROR].button_name = "error_button"; + + log_types[Log::LT_ASSERT].visible = true; + log_types[Log::LT_ASSERT].class_name = "error"; + log_types[Log::LT_ASSERT].alert_contents = "!"; + + log_types[Log::LT_WARNING].visible = true; + log_types[Log::LT_WARNING].class_name = "warning"; + log_types[Log::LT_WARNING].alert_contents = "!"; + log_types[Log::LT_WARNING].button_name = "warning_button"; + + log_types[Log::LT_INFO].visible = false; + log_types[Log::LT_INFO].class_name = "info"; + log_types[Log::LT_INFO].alert_contents = "i"; + log_types[Log::LT_INFO].button_name = "info_button"; + + log_types[Log::LT_DEBUG].visible = true; + log_types[Log::LT_DEBUG].class_name = "debug"; + log_types[Log::LT_DEBUG].alert_contents = "?"; + log_types[Log::LT_DEBUG].button_name = "debug_button"; } ElementLog::~ElementLog() @@ -91,16 +91,16 @@ bool ElementLog::Initialise() message_content = GetElementById("content"); if (message_content) { - message_content->AddEventListener(Core::EventId::Resize, this); + message_content->AddEventListener(EventId::Resize, this); } - Core::SharedPtr style_sheet = Core::Factory::InstanceStyleSheetString(Core::String(common_rcss) + Core::String(log_rcss)); + SharedPtr style_sheet = Factory::InstanceStyleSheetString(String(common_rcss) + String(log_rcss)); if (!style_sheet) return false; SetStyleSheet(std::move(style_sheet)); - AddEventListener(Core::EventId::Click, this); + AddEventListener(EventId::Click, this); // Create the log beacon. beacon = GetContext()->CreateDocument(); @@ -108,14 +108,14 @@ bool ElementLog::Initialise() return false; beacon->SetId("rmlui-debug-log-beacon"); - beacon->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + beacon->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); beacon->SetInnerRML(beacon_rml); - Core::Element* button = beacon->GetFirstChild(); + Element* button = beacon->GetFirstChild(); if (button) - beacon->GetFirstChild()->AddEventListener(Core::EventId::Click, this); + beacon->GetFirstChild()->AddEventListener(EventId::Click, this); - style_sheet = Core::Factory::InstanceStyleSheetString(Core::String(common_rcss) + Core::String(beacon_rcss)); + style_sheet = Factory::InstanceStyleSheetString(String(common_rcss) + String(beacon_rcss)); if (!style_sheet) { GetContext()->UnloadDocument(beacon); @@ -129,12 +129,12 @@ bool ElementLog::Initialise() } // Adds a log message to the debug log. -void ElementLog::AddLogMessage(Core::Log::Type type, const Core::String& message) +void ElementLog::AddLogMessage(Log::Type type, const String& message) { // Add the message to the list of messages for the specified log type. LogMessage log_message; log_message.index = current_index++; - log_message.message = Core::StringUtilities::EncodeRml(message); + log_message.message = StringUtilities::EncodeRml(message); log_types[type].log_messages.push_back(log_message); if (log_types[type].log_messages.size() >= MAX_LOG_MESSAGES) { @@ -147,7 +147,7 @@ void ElementLog::AddLogMessage(Core::Log::Type type, const Core::String& message { if (!log_types[type].button_name.empty()) { - Rml::Core::Element* button = GetElementById(log_types[type].button_name); + Element* button = GetElementById(log_types[type].button_name); if (button) { button->SetInnerRML("Off*"); @@ -161,10 +161,10 @@ void ElementLog::AddLogMessage(Core::Log::Type type, const Core::String& message { if (type < current_beacon_level) { - beacon->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + beacon->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); current_beacon_level = type; - Rml::Core::Element* beacon_button = beacon->GetFirstChild(); + Element* beacon_button = beacon->GetFirstChild(); if (beacon_button) { beacon_button->SetClassNames(log_types[type].class_name); @@ -180,22 +180,22 @@ void ElementLog::AddLogMessage(Core::Log::Type type, const Core::String& message void ElementLog::OnUpdate() { - Core::ElementDocument::OnUpdate(); + ElementDocument::OnUpdate(); if (dirty_logs) { // Set the log content: - Core::String messages; + String messages; if (message_content) { - unsigned int log_pointers[Core::Log::LT_MAX]; - for (int i = 0; i < Core::Log::LT_MAX; i++) + unsigned int log_pointers[Log::LT_MAX]; + for (int i = 0; i < Log::LT_MAX; i++) log_pointers[i] = 0; int next_type = FindNextEarliestLogType(log_pointers); int num_messages = 0; while (next_type != -1 && num_messages < MAX_LOG_MESSAGES) { - messages += Core::CreateString(128, "
%s

", log_types[next_type].class_name.c_str(), log_types[next_type].alert_contents.c_str()); + messages += CreateString(128, "

%s

", log_types[next_type].class_name.c_str(), log_types[next_type].alert_contents.c_str()); messages += log_types[next_type].log_messages[log_pointers[next_type]].message; messages += "

"; @@ -219,28 +219,28 @@ void ElementLog::OnUpdate() } } -void ElementLog::ProcessEvent(Core::Event& event) +void ElementLog::ProcessEvent(Event& event) { // Only process events if we're visible if (beacon != nullptr) { - if (event == Core::EventId::Click) + if (event == EventId::Click) { if (event.GetTargetElement() == beacon->GetFirstChild()) { if (!IsVisible()) - SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Visible)); + SetProperty(PropertyId::Visibility, Property(Style::Visibility::Visible)); - beacon->SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); - current_beacon_level = Core::Log::LT_MAX; + beacon->SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); + current_beacon_level = Log::LT_MAX; } else if (event.GetTargetElement()->GetId() == "close_button") { - SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden)); + SetProperty(PropertyId::Visibility, Property(Style::Visibility::Hidden)); } else if (event.GetTargetElement()->GetId() == "clear_button") { - for (int i = 0; i < Core::Log::LT_MAX; i++) + for (int i = 0; i < Log::LT_MAX; i++) { log_types[i].log_messages.clear(); if (!log_types[i].visible) @@ -253,7 +253,7 @@ void ElementLog::ProcessEvent(Core::Event& event) } else { - for (int i = 0; i < Core::Log::LT_MAX; i++) + for (int i = 0; i < Log::LT_MAX; i++) { if (!log_types[i].button_name.empty() && event.GetTargetElement()->GetId() == log_types[i].button_name) { @@ -269,7 +269,7 @@ void ElementLog::ProcessEvent(Core::Event& event) } } - if (event == Core::EventId::Resize && auto_scroll) + if (event == EventId::Resize && auto_scroll) { if (message_content != nullptr && message_content->HasChildNodes()) @@ -277,12 +277,12 @@ void ElementLog::ProcessEvent(Core::Event& event) } } -int ElementLog::FindNextEarliestLogType(unsigned int log_pointers[Core::Log::LT_MAX]) +int ElementLog::FindNextEarliestLogType(unsigned int log_pointers[Log::LT_MAX]) { int log_channel = -1; unsigned int index = UINT_MAX; - for (int i = 0; i < Core::Log::LT_MAX; i++) + for (int i = 0; i < Log::LT_MAX; i++) { if (log_types[i].visible) { diff --git a/Source/Debugger/ElementLog.h b/Source/Debugger/ElementLog.h index 5e09edfb6..8a6fc83d2 100644 --- a/Source/Debugger/ElementLog.h +++ b/Source/Debugger/ElementLog.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGERELEMENTLOG_H -#define RMLUIDEBUGGERELEMENTLOG_H +#ifndef RMLUI_DEBUGGER_ELEMENTLOG_H +#define RMLUI_DEBUGGER_ELEMENTLOG_H #include "../../Include/RmlUi/Core/ElementDocument.h" #include "../../Include/RmlUi/Core/EventListener.h" @@ -36,18 +36,18 @@ namespace Rml { namespace Debugger { -class SystemInterface; +class DebuggerSystemInterface; /** @author Robert Curry */ -class ElementLog : public Core::ElementDocument, public Core::EventListener +class ElementLog : public Rml::ElementDocument, public Rml::EventListener { public: - RMLUI_RTTI_DefineWithParent(ElementLog, Core::ElementDocument) + RMLUI_RTTI_DefineWithParent(ElementLog, Rml::ElementDocument) - ElementLog(const Core::String& tag); + ElementLog(const String& tag); ~ElementLog(); /// Initialises the log element. @@ -55,41 +55,41 @@ class ElementLog : public Core::ElementDocument, public Core::EventListener bool Initialise(); /// Adds a log message to the debug log. - void AddLogMessage(Core::Log::Type type, const Core::String& message); + void AddLogMessage(Log::Type type, const String& message); protected: void OnUpdate() override; - void ProcessEvent(Core::Event& event) override; + void ProcessEvent(Event& event) override; private: struct LogMessage { unsigned int index; - Core::String message; + String message; }; typedef std::deque< LogMessage > LogMessageList; struct LogType { bool visible; - Core::String class_name; - Core::String alert_contents; - Core::String button_name; + String class_name; + String alert_contents; + String button_name; LogMessageList log_messages; }; - LogType log_types[Core::Log::LT_MAX]; + LogType log_types[Log::LT_MAX]; - int FindNextEarliestLogType(unsigned int log_pointers[Core::Log::LT_MAX]); + int FindNextEarliestLogType(unsigned int log_pointers[Log::LT_MAX]); unsigned int current_index; bool dirty_logs; bool auto_scroll; - Core::Element* message_content; - Core::ElementDocument* beacon; + Element* message_content; + ElementDocument* beacon; int current_beacon_level; }; } -} +} // namespace Rml #endif diff --git a/Source/Debugger/FontSource.h b/Source/Debugger/FontSource.h index 4c5882ca9..454389177 100644 --- a/Source/Debugger/FontSource.h +++ b/Source/Debugger/FontSource.h @@ -26,8 +26,8 @@ * */ -#ifndef RMLUIDEBUGGERFONTSOURCE_H -#define RMLUIDEBUGGERFONTSOURCE_H +#ifndef RMLUI_DEBUGGER_FONTSOURCE_H +#define RMLUI_DEBUGGER_FONTSOURCE_H /* The fonts 'Courier Prime Code' and 'Courier Prime Code Italic', included diff --git a/Source/Debugger/Geometry.cpp b/Source/Debugger/Geometry.cpp index 954993792..f5c60067f 100644 --- a/Source/Debugger/Geometry.cpp +++ b/Source/Debugger/Geometry.cpp @@ -34,81 +34,81 @@ namespace Rml { namespace Debugger { -static Core::Context* context; +static Context* context; Geometry::Geometry() { } -void Geometry::SetContext(Core::Context* _context) +void Geometry::SetContext(Context* _context) { context = _context; } // Renders a one-pixel rectangular outline. -void Geometry::RenderOutline(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Colourb& colour, float width) +void Geometry::RenderOutline(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour, float width) { if (context == nullptr) return; - Core::RenderInterface* render_interface = context->GetRenderInterface(); + RenderInterface* render_interface = context->GetRenderInterface(); - Core::Vertex vertices[4 * 4]; + Vertex vertices[4 * 4]; int indices[6 * 4]; - Core::GeometryUtilities::GenerateQuad(vertices + 0, indices + 0, Core::Vector2f(0, 0), Core::Vector2f(dimensions.x, width), colour, 0); - Core::GeometryUtilities::GenerateQuad(vertices + 4, indices + 6, Core::Vector2f(0, dimensions.y - width), Core::Vector2f(dimensions.x, width), colour, 4); - Core::GeometryUtilities::GenerateQuad(vertices + 8, indices + 12, Core::Vector2f(0, 0), Core::Vector2f(width, dimensions.y), colour, 8); - Core::GeometryUtilities::GenerateQuad(vertices + 12, indices + 18, Core::Vector2f(dimensions.x - width, 0), Core::Vector2f(width, dimensions.y), colour, 12); + GeometryUtilities::GenerateQuad(vertices + 0, indices + 0, Vector2f(0, 0), Vector2f(dimensions.x, width), colour, 0); + GeometryUtilities::GenerateQuad(vertices + 4, indices + 6, Vector2f(0, dimensions.y - width), Vector2f(dimensions.x, width), colour, 4); + GeometryUtilities::GenerateQuad(vertices + 8, indices + 12, Vector2f(0, 0), Vector2f(width, dimensions.y), colour, 8); + GeometryUtilities::GenerateQuad(vertices + 12, indices + 18, Vector2f(dimensions.x - width, 0), Vector2f(width, dimensions.y), colour, 12); render_interface->RenderGeometry(vertices, 4 * 4, indices, 6 * 4, 0, origin); } // Renders a box. -void Geometry::RenderBox(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Colourb& colour) +void Geometry::RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour) { if (context == nullptr) return; - Core::RenderInterface* render_interface = context->GetRenderInterface(); + RenderInterface* render_interface = context->GetRenderInterface(); - Core::Vertex vertices[4]; + Vertex vertices[4]; int indices[6]; - Core::GeometryUtilities::GenerateQuad(vertices, indices, Core::Vector2f(0, 0), Core::Vector2f(dimensions.x, dimensions.y), colour, 0); + GeometryUtilities::GenerateQuad(vertices, indices, Vector2f(0, 0), Vector2f(dimensions.x, dimensions.y), colour, 0); render_interface->RenderGeometry(vertices, 4, indices, 6, 0, origin); } // Renders a box with a hole in the middle. -void Geometry::RenderBox(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Vector2f& hole_origin, const Core::Vector2f& hole_dimensions, const Core::Colourb& colour) +void Geometry::RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Vector2f& hole_origin, const Vector2f& hole_dimensions, const Colourb& colour) { // Top box. float top_y_dimensions = hole_origin.y - origin.y; if (top_y_dimensions > 0) { - RenderBox(origin, Core::Vector2f(dimensions.x, top_y_dimensions), colour); + RenderBox(origin, Vector2f(dimensions.x, top_y_dimensions), colour); } // Bottom box. float bottom_y_dimensions = (origin.y + dimensions.y) - (hole_origin.y + hole_dimensions.y); if (bottom_y_dimensions > 0) { - RenderBox(Core::Vector2f(origin.x, hole_origin.y + hole_dimensions.y), Core::Vector2f(dimensions.x, bottom_y_dimensions), colour); + RenderBox(Vector2f(origin.x, hole_origin.y + hole_dimensions.y), Vector2f(dimensions.x, bottom_y_dimensions), colour); } // Left box. float left_x_dimensions = hole_origin.x - origin.x; if (left_x_dimensions > 0) { - RenderBox(Core::Vector2f(origin.x, hole_origin.y), Core::Vector2f(left_x_dimensions, hole_dimensions.y), colour); + RenderBox(Vector2f(origin.x, hole_origin.y), Vector2f(left_x_dimensions, hole_dimensions.y), colour); } // Right box. float right_x_dimensions = (origin.x + dimensions.x) - (hole_origin.x + hole_dimensions.x); if (right_x_dimensions > 0) { - RenderBox(Core::Vector2f(hole_origin.x + hole_dimensions.x, hole_origin.y), Core::Vector2f(right_x_dimensions, hole_dimensions.y), colour); + RenderBox(Vector2f(hole_origin.x + hole_dimensions.x, hole_origin.y), Vector2f(right_x_dimensions, hole_dimensions.y), colour); } } diff --git a/Source/Debugger/Geometry.h b/Source/Debugger/Geometry.h index abd79c958..5c6751242 100644 --- a/Source/Debugger/Geometry.h +++ b/Source/Debugger/Geometry.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUIDEBUGGERGEOMETRY_H -#define RMLUIDEBUGGERGEOMETRY_H +#ifndef RMLUI_DEBUGGER_GEOMETRY_H +#define RMLUI_DEBUGGER_GEOMETRY_H #include "../../Include/RmlUi/Core/Types.h" namespace Rml { -namespace Core { - class Context; -} +class Context; namespace Debugger { @@ -49,20 +47,20 @@ class Geometry { public: // Set the context to render through. - static void SetContext(Core::Context* context); + static void SetContext(Context* context); // Renders a one-pixel rectangular outline. - static void RenderOutline(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Colourb& colour, float width); + static void RenderOutline(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour, float width); // Renders a box. - static void RenderBox(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Colourb& colour); + static void RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Colourb& colour); // Renders a box with a hole in the middle. - static void RenderBox(const Core::Vector2f& origin, const Core::Vector2f& dimensions, const Core::Vector2f& hole_origin, const Core::Vector2f& hole_dimensions, const Core::Colourb& colour); + static void RenderBox(const Vector2f& origin, const Vector2f& dimensions, const Vector2f& hole_origin, const Vector2f& hole_dimensions, const Colourb& colour); private: Geometry(); }; } -} +} // namespace Rml #endif diff --git a/Source/Core/Lua/Colourb.cpp b/Source/Lua/Colourb.cpp similarity index 86% rename from Source/Core/Lua/Colourb.cpp rename to Source/Lua/Colourb.cpp index 37598ebcb..cda03f19a 100644 --- a/Source/Core/Lua/Colourb.cpp +++ b/Source/Lua/Colourb.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "Colourb.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -66,9 +64,9 @@ int Colourbnew(lua_State* L) int Colourb__eq(lua_State* L) { Colourb* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Colourb* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0); return 1; @@ -77,9 +75,9 @@ int Colourb__eq(lua_State* L) int Colourb__add(lua_State* L) { Colourb* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Colourb* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); Colourb* res = new Colourb((*lhs) + (*rhs)); @@ -90,7 +88,7 @@ int Colourb__add(lua_State* L) int Colourb__mul(lua_State* L) { Colourb* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); float rhs = (float)luaL_checknumber(L,2); Colourb* res = new Colourb((*lhs) * rhs); @@ -100,12 +98,11 @@ int Colourb__mul(lua_State* L) } - //getters int ColourbGetAttrred(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->red); return 1; } @@ -113,7 +110,7 @@ int ColourbGetAttrred(lua_State* L) int ColourbGetAttrgreen(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->green); return 1; } @@ -121,7 +118,7 @@ int ColourbGetAttrgreen(lua_State* L) int ColourbGetAttrblue(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->blue); return 1; } @@ -129,7 +126,7 @@ int ColourbGetAttrblue(lua_State* L) int ColourbGetAttralpha(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->alpha); return 1; } @@ -137,7 +134,7 @@ int ColourbGetAttralpha(lua_State* L) int ColourbGetAttrrgba(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->red); lua_pushinteger(L,obj->green); lua_pushinteger(L,obj->blue); @@ -150,7 +147,7 @@ int ColourbGetAttrrgba(lua_State* L) int ColourbSetAttrred(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); byte red = (byte)luaL_checkinteger(L,2); obj->red = red; return 0; @@ -159,7 +156,7 @@ int ColourbSetAttrred(lua_State* L) int ColourbSetAttrgreen(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); byte green = (byte)luaL_checkinteger(L,2); obj->green = green; return 0; @@ -168,7 +165,7 @@ int ColourbSetAttrgreen(lua_State* L) int ColourbSetAttrblue(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); byte blue = (byte)luaL_checkinteger(L,2); obj->blue = blue; return 0; @@ -177,7 +174,7 @@ int ColourbSetAttrblue(lua_State* L) int ColourbSetAttralpha(lua_State* L) { Colourb* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); byte alpha = (byte)luaL_checkinteger(L,2); obj->alpha = alpha; return 0; @@ -191,7 +188,7 @@ int ColourbSetAttrrgba(lua_State* L) if(top > 0) { obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); if(top > 1) { if(top > 2) @@ -215,25 +212,24 @@ RegType ColourbMethods[] = luaL_Reg ColourbGetters[] = { - LUAGETTER(Colourb,red) - LUAGETTER(Colourb,green) - LUAGETTER(Colourb,blue) - LUAGETTER(Colourb,alpha) - LUAGETTER(Colourb,rgba) + RMLUI_LUAGETTER(Colourb,red) + RMLUI_LUAGETTER(Colourb,green) + RMLUI_LUAGETTER(Colourb,blue) + RMLUI_LUAGETTER(Colourb,alpha) + RMLUI_LUAGETTER(Colourb,rgba) { nullptr, nullptr }, }; luaL_Reg ColourbSetters[] = { - LUASETTER(Colourb,red) - LUASETTER(Colourb,green) - LUASETTER(Colourb,blue) - LUASETTER(Colourb,alpha) - LUASETTER(Colourb,rgba) + RMLUI_LUASETTER(Colourb,red) + RMLUI_LUASETTER(Colourb,green) + RMLUI_LUASETTER(Colourb,blue) + RMLUI_LUASETTER(Colourb,alpha) + RMLUI_LUASETTER(Colourb,rgba) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Colourb) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(Colourb) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Colourb.h b/Source/Lua/Colourb.h similarity index 90% rename from Source/Core/Lua/Colourb.h rename to Source/Lua/Colourb.h index 5b7b84c16..a2e9fc217 100644 --- a/Source/Core/Lua/Colourb.h +++ b/Source/Lua/Colourb.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICORELUACOLOURB_H -#define RMLUICORELUACOLOURB_H +#ifndef RMLUI_LUA_COLOURB_H +#define RMLUI_LUA_COLOURB_H -#include -#include +#include +#include #include -using Rml::Core::Colourb; namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); int Colourbnew(lua_State* L); @@ -62,8 +60,7 @@ extern RegType ColourbMethods[]; extern luaL_Reg ColourbGetters[]; extern luaL_Reg ColourbSetters[]; -LUACORETYPEDECLARE(Colourb) -} -} -} -#endif \ No newline at end of file +RMLUI_LUATYPE_DECLARE(Colourb) +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Core/Lua/Colourf.cpp b/Source/Lua/Colourf.cpp similarity index 86% rename from Source/Core/Lua/Colourf.cpp rename to Source/Lua/Colourf.cpp index 24a2f0308..ebe1b13b2 100644 --- a/Source/Core/Lua/Colourf.cpp +++ b/Source/Lua/Colourf.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "Colourf.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -62,9 +60,9 @@ int Colourfnew(lua_State* L) int Colourf__eq(lua_State* L) { Colourf* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Colourf* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0); return 1; @@ -75,7 +73,7 @@ int Colourf__eq(lua_State* L) int ColourfGetAttrred(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushnumber(L,obj->red); return 1; } @@ -83,7 +81,7 @@ int ColourfGetAttrred(lua_State* L) int ColourfGetAttrgreen(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushnumber(L,obj->green); return 1; } @@ -91,7 +89,7 @@ int ColourfGetAttrgreen(lua_State* L) int ColourfGetAttrblue(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushnumber(L,obj->blue); return 1; } @@ -99,7 +97,7 @@ int ColourfGetAttrblue(lua_State* L) int ColourfGetAttralpha(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushnumber(L,obj->alpha); return 1; } @@ -107,7 +105,7 @@ int ColourfGetAttralpha(lua_State* L) int ColourfGetAttrrgba(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushnumber(L,obj->red); lua_pushnumber(L,obj->green); lua_pushnumber(L,obj->blue); @@ -120,7 +118,7 @@ int ColourfGetAttrrgba(lua_State* L) int ColourfSetAttrred(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); float red = (float)luaL_checknumber(L,2); obj->red = red; return 0; @@ -129,7 +127,7 @@ int ColourfSetAttrred(lua_State* L) int ColourfSetAttrgreen(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); float green = (float)luaL_checknumber(L,2); obj->green = green; return 0; @@ -138,7 +136,7 @@ int ColourfSetAttrgreen(lua_State* L) int ColourfSetAttrblue(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); float blue = (float)luaL_checknumber(L,2); obj->blue = blue; return 0; @@ -147,7 +145,7 @@ int ColourfSetAttrblue(lua_State* L) int ColourfSetAttralpha(lua_State* L) { Colourf* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); float alpha = (float)luaL_checknumber(L,2); obj->alpha = alpha; return 0; @@ -161,7 +159,7 @@ int ColourfSetAttrrgba(lua_State* L) if(top > 0) { obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); if(top > 1) { if(top > 2) @@ -185,27 +183,26 @@ RegType ColourfMethods[] = luaL_Reg ColourfGetters[] = { - LUAGETTER(Colourf,red) - LUAGETTER(Colourf,green) - LUAGETTER(Colourf,blue) - LUAGETTER(Colourf,alpha) - LUAGETTER(Colourf,rgba) + RMLUI_LUAGETTER(Colourf,red) + RMLUI_LUAGETTER(Colourf,green) + RMLUI_LUAGETTER(Colourf,blue) + RMLUI_LUAGETTER(Colourf,alpha) + RMLUI_LUAGETTER(Colourf,rgba) { nullptr, nullptr }, }; luaL_Reg ColourfSetters[] = { - LUASETTER(Colourf,red) - LUASETTER(Colourf,green) - LUASETTER(Colourf,blue) - LUASETTER(Colourf,alpha) - LUASETTER(Colourf,rgba) + RMLUI_LUASETTER(Colourf,red) + RMLUI_LUASETTER(Colourf,green) + RMLUI_LUASETTER(Colourf,blue) + RMLUI_LUASETTER(Colourf,alpha) + RMLUI_LUASETTER(Colourf,rgba) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Colourf) +RMLUI_LUATYPE_DEFINE(Colourf) -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Colourf.h b/Source/Lua/Colourf.h similarity index 90% rename from Source/Core/Lua/Colourf.h rename to Source/Lua/Colourf.h index ef54c09e5..809ecb2dd 100644 --- a/Source/Core/Lua/Colourf.h +++ b/Source/Lua/Colourf.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICORELUACOLOURF_H -#define RMLUICORELUACOLOURF_H +#ifndef RMLUI_LUA_COLOURF_H +#define RMLUI_LUA_COLOURF_H -#include -#include +#include +#include #include -using Rml::Core::Colourf; namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); //metamethods @@ -60,9 +58,7 @@ extern RegType ColourfMethods[]; extern luaL_Reg ColourfGetters[]; extern luaL_Reg ColourfSetters[]; -LUACORETYPEDECLARE(Colourf) -} -} -} +RMLUI_LUATYPE_DECLARE(Colourf) +} // namespace Lua +} // namespace Rml #endif - diff --git a/Source/Core/Lua/Context.cpp b/Source/Lua/Context.cpp similarity index 86% rename from Source/Core/Lua/Context.cpp rename to Source/Lua/Context.cpp index b387fbeeb..b324d6cfb 100644 --- a/Source/Core/Lua/Context.cpp +++ b/Source/Lua/Context.cpp @@ -26,7 +26,6 @@ * */ -#include "precompiled.h" #include "Context.h" #include #include @@ -35,9 +34,8 @@ #include "ContextDocumentsProxy.h" namespace Rml { -namespace Core { namespace Lua { -typedef Rml::Core::ElementDocument Document; +typedef ElementDocument Document; template<> void ExtraInit(lua_State* /*L*/, int /*metatable_index*/) { return; } //methods @@ -53,7 +51,7 @@ int ContextAddEventListener(lua_State* L, Context* obj) if(!lua_isnoneornil(L,3)) element = LuaType::check(L,3); if(!lua_isnoneornil(L,4)) - capturephase = CHECK_BOOL(L,4); + capturephase = RMLUI_CHECK_BOOL(L,4); } int type = lua_type(L,2); @@ -139,7 +137,7 @@ int ContextGetAttrdimensions(lua_State* L) int ContextGetAttrdocuments(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); ContextDocumentsProxy* cdp = new ContextDocumentsProxy(); cdp->owner = cont; LuaType::push(L,cdp,true); //does get garbage collected (deleted) @@ -149,7 +147,7 @@ int ContextGetAttrdocuments(lua_State* L) int ContextGetAttrfocus_element(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); LuaType::push(L,cont->GetFocusElement()); return 1; } @@ -157,7 +155,7 @@ int ContextGetAttrfocus_element(lua_State* L) int ContextGetAttrhover_element(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); LuaType::push(L,cont->GetHoverElement()); return 1; } @@ -165,7 +163,7 @@ int ContextGetAttrhover_element(lua_State* L) int ContextGetAttrname(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); lua_pushstring(L,cont->GetName().c_str()); return 1; } @@ -173,7 +171,7 @@ int ContextGetAttrname(lua_State* L) int ContextGetAttrroot_element(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); LuaType::push(L,cont->GetRootElement()); return 1; } @@ -183,44 +181,42 @@ int ContextGetAttrroot_element(lua_State* L) int ContextSetAttrdimensions(lua_State* L) { Context* cont = LuaType::check(L,1); - LUACHECKOBJ(cont); + RMLUI_CHECK_OBJ(cont); Vector2i* dim = LuaType::check(L,2); cont->SetDimensions(*dim); return 0; } - RegType ContextMethods[] = { - LUAMETHOD(Context,AddEventListener) - LUAMETHOD(Context,CreateDocument) - LUAMETHOD(Context,LoadDocument) - LUAMETHOD(Context,Render) - LUAMETHOD(Context,UnloadAllDocuments) - LUAMETHOD(Context,UnloadDocument) - LUAMETHOD(Context,Update) + RMLUI_LUAMETHOD(Context,AddEventListener) + RMLUI_LUAMETHOD(Context,CreateDocument) + RMLUI_LUAMETHOD(Context,LoadDocument) + RMLUI_LUAMETHOD(Context,Render) + RMLUI_LUAMETHOD(Context,UnloadAllDocuments) + RMLUI_LUAMETHOD(Context,UnloadDocument) + RMLUI_LUAMETHOD(Context,Update) { nullptr, nullptr }, }; luaL_Reg ContextGetters[] = { - LUAGETTER(Context,dimensions) - LUAGETTER(Context,documents) - LUAGETTER(Context,focus_element) - LUAGETTER(Context,hover_element) - LUAGETTER(Context,name) - LUAGETTER(Context,root_element) + RMLUI_LUAGETTER(Context,dimensions) + RMLUI_LUAGETTER(Context,documents) + RMLUI_LUAGETTER(Context,focus_element) + RMLUI_LUAGETTER(Context,hover_element) + RMLUI_LUAGETTER(Context,name) + RMLUI_LUAGETTER(Context,root_element) { nullptr, nullptr }, }; luaL_Reg ContextSetters[] = { - LUASETTER(Context,dimensions) + RMLUI_LUASETTER(Context,dimensions) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Context) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(Context) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Context.h b/Source/Lua/Context.h similarity index 92% rename from Source/Core/Lua/Context.h rename to Source/Lua/Context.h index 24379cdfb..7ff598971 100644 --- a/Source/Core/Lua/Context.h +++ b/Source/Lua/Context.h @@ -26,16 +26,15 @@ * */ -#ifndef RMLUICORELUACONTEXT_H -#define RMLUICORELUACONTEXT_H +#ifndef RMLUI_LUA_CONTEXT_H +#define RMLUI_LUA_CONTEXT_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); @@ -64,8 +63,7 @@ extern RegType ContextMethods[]; extern luaL_Reg ContextGetters[]; extern luaL_Reg ContextSetters[]; -LUACORETYPEDECLARE(Context) -} -} -} +RMLUI_LUATYPE_DECLARE(Context) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/ContextDocumentsProxy.cpp b/Source/Lua/ContextDocumentsProxy.cpp similarity index 96% rename from Source/Core/Lua/ContextDocumentsProxy.cpp rename to Source/Lua/ContextDocumentsProxy.cpp index 9a78037ba..9ca84f919 100644 --- a/Source/Core/Lua/ContextDocumentsProxy.cpp +++ b/Source/Lua/ContextDocumentsProxy.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "ContextDocumentsProxy.h" #include namespace Rml { -namespace Core { namespace Lua { -typedef Rml::Core::ElementDocument Document; +typedef ElementDocument Document; template<> void ExtraInit(lua_State* L, int metatable_index) { lua_pushcfunction(L,ContextDocumentsProxy__index); @@ -69,7 +67,7 @@ int ContextDocumentsProxy__pairs(lua_State* L) { Document* doc = nullptr; ContextDocumentsProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) *pindex = 0; @@ -103,7 +101,7 @@ int ContextDocumentsProxy__ipairs(lua_State* L) { Document* doc = nullptr; ContextDocumentsProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) *pindex = 0; @@ -148,8 +146,7 @@ luaL_Reg ContextDocumentsProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ContextDocumentsProxy) +RMLUI_LUATYPE_DEFINE(ContextDocumentsProxy) -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ContextDocumentsProxy.h b/Source/Lua/ContextDocumentsProxy.h similarity index 88% rename from Source/Core/Lua/ContextDocumentsProxy.h rename to Source/Lua/ContextDocumentsProxy.h index a77377aec..c5f23962e 100644 --- a/Source/Core/Lua/ContextDocumentsProxy.h +++ b/Source/Lua/ContextDocumentsProxy.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUACONTEXTDOCUMENTSPROXY_H -#define RMLUICORELUACONTEXTDOCUMENTSPROXY_H +#ifndef RMLUI_LUA_CONTEXTDOCUMENTSPROXY_H +#define RMLUI_LUA_CONTEXTDOCUMENTSPROXY_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { //where owner is the context that we should look information from struct ContextDocumentsProxy { Context* owner; }; @@ -48,8 +47,7 @@ extern RegType ContextDocumentsProxyMethods[]; extern luaL_Reg ContextDocumentsProxyGetters[]; extern luaL_Reg ContextDocumentsProxySetters[]; -LUACORETYPEDECLARE(ContextDocumentsProxy) -} -} -} -#endif \ No newline at end of file +RMLUI_LUATYPE_DECLARE(ContextDocumentsProxy) +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Core/Lua/Document.cpp b/Source/Lua/Document.cpp similarity index 89% rename from Source/Core/Lua/Document.cpp rename to Source/Lua/Document.cpp index 0c94df43b..9f3f8da07 100644 --- a/Source/Core/Lua/Document.cpp +++ b/Source/Lua/Document.cpp @@ -26,15 +26,13 @@ * */ -#include "precompiled.h" #include "Document.h" #include #include #include "Element.h" -#include +#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -143,7 +141,7 @@ int DocumentCreateTextNode(lua_State* L, Document* obj) int DocumentGetAttrtitle(lua_State* L) { Document* doc = LuaType::check(L,1); - LUACHECKOBJ(doc); + RMLUI_CHECK_OBJ(doc); lua_pushstring(L,doc->GetTitle().c_str()); return 1; } @@ -151,7 +149,7 @@ int DocumentGetAttrtitle(lua_State* L) int DocumentGetAttrcontext(lua_State* L) { Document* doc = LuaType::check(L,1); - LUACHECKOBJ(doc); + RMLUI_CHECK_OBJ(doc); LuaType::push(L,doc->GetContext(),false); return 1; } @@ -161,7 +159,7 @@ int DocumentGetAttrcontext(lua_State* L) int DocumentSetAttrtitle(lua_State* L) { Document* doc = LuaType::check(L,1); - LUACHECKOBJ(doc); + RMLUI_CHECK_OBJ(doc); const char* title = luaL_checkstring(L,2); doc->SetTitle(title); return 0; @@ -170,30 +168,29 @@ int DocumentSetAttrtitle(lua_State* L) RegType DocumentMethods[] = { - LUAMETHOD(Document,PullToFront) - LUAMETHOD(Document,PushToBack) - LUAMETHOD(Document,Show) - LUAMETHOD(Document,Hide) - LUAMETHOD(Document,Close) - LUAMETHOD(Document,CreateElement) - LUAMETHOD(Document,CreateTextNode) + RMLUI_LUAMETHOD(Document,PullToFront) + RMLUI_LUAMETHOD(Document,PushToBack) + RMLUI_LUAMETHOD(Document,Show) + RMLUI_LUAMETHOD(Document,Hide) + RMLUI_LUAMETHOD(Document,Close) + RMLUI_LUAMETHOD(Document,CreateElement) + RMLUI_LUAMETHOD(Document,CreateTextNode) { nullptr, nullptr }, }; luaL_Reg DocumentGetters[] = { - LUAGETTER(Document,title) - LUAGETTER(Document,context) + RMLUI_LUAGETTER(Document,title) + RMLUI_LUAGETTER(Document,context) { nullptr, nullptr }, }; luaL_Reg DocumentSetters[] = { - LUASETTER(Document,title) + RMLUI_LUASETTER(Document,title) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Document) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(Document) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Document.h b/Source/Lua/Document.h similarity index 91% rename from Source/Core/Lua/Document.h rename to Source/Lua/Document.h index 1cca6e513..a5ccddcee 100644 --- a/Source/Core/Lua/Document.h +++ b/Source/Lua/Document.h @@ -26,16 +26,15 @@ * */ -#ifndef RMLUICORELUADOCUMENT_H -#define RMLUICORELUADOCUMENT_H +#ifndef RMLUI_LUA_DOCUMENT_H +#define RMLUI_LUA_DOCUMENT_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { typedef ElementDocument Document; @@ -61,8 +60,7 @@ extern RegType DocumentMethods[]; extern luaL_Reg DocumentGetters[]; extern luaL_Reg DocumentSetters[]; -LUACORETYPEDECLARE(Document) -} -} -} +RMLUI_LUATYPE_DECLARE(Document) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/Element.cpp b/Source/Lua/Element.cpp similarity index 81% rename from Source/Core/Lua/Element.cpp rename to Source/Lua/Element.cpp index 6d8ec3964..4efa81811 100644 --- a/Source/Core/Lua/Element.cpp +++ b/Source/Lua/Element.cpp @@ -26,17 +26,15 @@ * */ -#include "precompiled.h" #include "Element.h" #include "ElementStyleProxy.h" #include "LuaEventListener.h" #include "ElementAttributesProxy.h" #include "ElementChildNodesProxy.h" -#include +#include namespace Rml { -namespace Core { namespace Lua { typedef ElementDocument Document; @@ -71,7 +69,7 @@ int ElementAddEventListener(lua_State* L, Element* obj) bool capture = false; //default false if they didn't pass it in if (top > 2) - capture = CHECK_BOOL(L,3); + capture = RMLUI_CHECK_BOOL(L,3); const char* event = luaL_checkstring(L,1); @@ -136,7 +134,7 @@ int ElementDispatchEvent(lua_State* L, Element* obj) params[key] = (float)lua_tonumber(L,-1); break; case LUA_TBOOLEAN: - params[key] = CHECK_BOOL(L,-1); + params[key] = RMLUI_CHECK_BOOL(L,-1); break; case LUA_TSTRING: params[key] = luaL_checkstring(L,-1); @@ -248,7 +246,7 @@ int ElementReplaceChild(lua_State* L, Element* obj) int ElementScrollIntoView(lua_State* L, Element* obj) { - bool align = CHECK_BOOL(L,1); + bool align = RMLUI_CHECK_BOOL(L,1); obj->ScrollIntoView(align); return 0; } @@ -264,7 +262,7 @@ int ElementSetAttribute(lua_State* L, Element* obj) int ElementSetClass(lua_State* L, Element* obj) { const char* name = luaL_checkstring(L,1); - bool value = CHECK_BOOL(L,2); + bool value = RMLUI_CHECK_BOOL(L,2); obj->SetClass(name,value); return 0; } @@ -273,7 +271,7 @@ int ElementSetClass(lua_State* L, Element* obj) int ElementGetAttrattributes(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); ElementAttributesProxy* proxy = new ElementAttributesProxy(); proxy->owner = ele; LuaType::push(L,proxy,true); @@ -283,7 +281,7 @@ int ElementGetAttrattributes(lua_State* L) int ElementGetAttrchild_nodes(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); ElementChildNodesProxy* ecnp = new ElementChildNodesProxy(); ecnp->owner = ele; LuaType::push(L,ecnp,true); @@ -293,8 +291,8 @@ int ElementGetAttrchild_nodes(lua_State* L) int ElementGetAttrclass_name(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); - Rml::Core::String classnames = ele->GetClassNames(); + RMLUI_CHECK_OBJ(ele); + String classnames = ele->GetClassNames(); lua_pushstring(L,classnames.c_str()); return 1; } @@ -302,7 +300,7 @@ int ElementGetAttrclass_name(lua_State* L) int ElementGetAttrclient_left(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetClientLeft()); return 1; } @@ -310,7 +308,7 @@ int ElementGetAttrclient_left(lua_State* L) int ElementGetAttrclient_height(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetClientHeight()); return 1; } @@ -318,7 +316,7 @@ int ElementGetAttrclient_height(lua_State* L) int ElementGetAttrclient_top(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetClientTop()); return 1; } @@ -326,7 +324,7 @@ int ElementGetAttrclient_top(lua_State* L) int ElementGetAttrclient_width(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetClientWidth()); return 1; } @@ -334,7 +332,7 @@ int ElementGetAttrclient_width(lua_State* L) int ElementGetAttrfirst_child(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* child = ele->GetFirstChild(); if(child == nullptr) lua_pushnil(L); @@ -346,7 +344,7 @@ int ElementGetAttrfirst_child(lua_State* L) int ElementGetAttrid(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushstring(L,ele->GetId().c_str()); return 1; } @@ -354,7 +352,7 @@ int ElementGetAttrid(lua_State* L) int ElementGetAttrinner_rml(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushstring(L,ele->GetInnerRML().c_str()); return 1; } @@ -362,7 +360,7 @@ int ElementGetAttrinner_rml(lua_State* L) int ElementGetAttrlast_child(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* child = ele->GetLastChild(); if(child == nullptr) lua_pushnil(L); @@ -374,7 +372,7 @@ int ElementGetAttrlast_child(lua_State* L) int ElementGetAttrnext_sibling(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* sibling = ele->GetNextSibling(); if(sibling == nullptr) lua_pushnil(L); @@ -386,7 +384,7 @@ int ElementGetAttrnext_sibling(lua_State* L) int ElementGetAttroffset_height(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetOffsetHeight()); return 1; } @@ -394,7 +392,7 @@ int ElementGetAttroffset_height(lua_State* L) int ElementGetAttroffset_left(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetOffsetLeft()); return 1; } @@ -402,7 +400,7 @@ int ElementGetAttroffset_left(lua_State* L) int ElementGetAttroffset_parent(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* parent = ele->GetOffsetParent(); LuaType::push(L,parent,false); return 1; @@ -411,7 +409,7 @@ int ElementGetAttroffset_parent(lua_State* L) int ElementGetAttroffset_top(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L, ele->GetOffsetTop()); return 1; } @@ -419,7 +417,7 @@ int ElementGetAttroffset_top(lua_State* L) int ElementGetAttroffset_width(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetOffsetWidth()); return 1; } @@ -427,7 +425,7 @@ int ElementGetAttroffset_width(lua_State* L) int ElementGetAttrowner_document(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Document* doc = ele->GetOwnerDocument(); LuaType::push(L,doc,false); return 1; @@ -436,7 +434,7 @@ int ElementGetAttrowner_document(lua_State* L) int ElementGetAttrparent_node(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* parent = ele->GetParentNode(); if(parent == nullptr) lua_pushnil(L); @@ -448,7 +446,7 @@ int ElementGetAttrparent_node(lua_State* L) int ElementGetAttrprevious_sibling(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); Element* sibling = ele->GetPreviousSibling(); if(sibling == nullptr) lua_pushnil(L); @@ -460,7 +458,7 @@ int ElementGetAttrprevious_sibling(lua_State* L) int ElementGetAttrscroll_height(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetScrollHeight()); return 1; } @@ -468,7 +466,7 @@ int ElementGetAttrscroll_height(lua_State* L) int ElementGetAttrscroll_left(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetScrollLeft()); return 1; } @@ -476,7 +474,7 @@ int ElementGetAttrscroll_left(lua_State* L) int ElementGetAttrscroll_top(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetScrollTop()); return 1; } @@ -484,7 +482,7 @@ int ElementGetAttrscroll_top(lua_State* L) int ElementGetAttrscroll_width(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushnumber(L,ele->GetScrollWidth()); return 1; } @@ -492,7 +490,7 @@ int ElementGetAttrscroll_width(lua_State* L) int ElementGetAttrstyle(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); ElementStyleProxy* prox = new ElementStyleProxy(); prox->owner = ele; LuaType::push(L,prox,true); @@ -502,7 +500,7 @@ int ElementGetAttrstyle(lua_State* L) int ElementGetAttrtag_name(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); lua_pushstring(L,ele->GetTagName().c_str()); return 1; } @@ -512,7 +510,7 @@ int ElementGetAttrtag_name(lua_State* L) int ElementSetAttrclass_name(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); const char* name = luaL_checkstring(L,2); ele->SetClassNames(name); return 0; @@ -521,7 +519,7 @@ int ElementSetAttrclass_name(lua_State* L) int ElementSetAttrid(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); const char* id = luaL_checkstring(L,2); ele->SetId(id); return 0; @@ -530,7 +528,7 @@ int ElementSetAttrid(lua_State* L) int ElementSetAttrinner_rml(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); const char* rml = luaL_checkstring(L,2); ele->SetInnerRML(rml); return 0; @@ -539,7 +537,7 @@ int ElementSetAttrinner_rml(lua_State* L) int ElementSetAttrscroll_left(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); float scroll = (float)luaL_checknumber(L,2); ele->SetScrollLeft(scroll); return 0; @@ -548,90 +546,79 @@ int ElementSetAttrscroll_left(lua_State* L) int ElementSetAttrscroll_top(lua_State* L) { Element* ele = LuaType::check(L,1); - LUACHECKOBJ(ele); + RMLUI_CHECK_OBJ(ele); float scroll = (float)luaL_checknumber(L,2); ele->SetScrollTop(scroll); return 0; } - - RegType ElementMethods[] = { - LUAMETHOD(Element,AddEventListener) - LUAMETHOD(Element,AppendChild) - LUAMETHOD(Element,Blur) - LUAMETHOD(Element,Click) - LUAMETHOD(Element,DispatchEvent) - LUAMETHOD(Element,Focus) - LUAMETHOD(Element,GetAttribute) - LUAMETHOD(Element,GetElementById) - LUAMETHOD(Element,GetElementsByTagName) - LUAMETHOD(Element,HasAttribute) - LUAMETHOD(Element,HasChildNodes) - LUAMETHOD(Element,InsertBefore) - LUAMETHOD(Element,IsClassSet) - LUAMETHOD(Element,RemoveAttribute) - LUAMETHOD(Element,RemoveChild) - LUAMETHOD(Element,ReplaceChild) - LUAMETHOD(Element,ScrollIntoView) - LUAMETHOD(Element,SetAttribute) - LUAMETHOD(Element,SetClass) + RMLUI_LUAMETHOD(Element,AddEventListener) + RMLUI_LUAMETHOD(Element,AppendChild) + RMLUI_LUAMETHOD(Element,Blur) + RMLUI_LUAMETHOD(Element,Click) + RMLUI_LUAMETHOD(Element,DispatchEvent) + RMLUI_LUAMETHOD(Element,Focus) + RMLUI_LUAMETHOD(Element,GetAttribute) + RMLUI_LUAMETHOD(Element,GetElementById) + RMLUI_LUAMETHOD(Element,GetElementsByTagName) + RMLUI_LUAMETHOD(Element,HasAttribute) + RMLUI_LUAMETHOD(Element,HasChildNodes) + RMLUI_LUAMETHOD(Element,InsertBefore) + RMLUI_LUAMETHOD(Element,IsClassSet) + RMLUI_LUAMETHOD(Element,RemoveAttribute) + RMLUI_LUAMETHOD(Element,RemoveChild) + RMLUI_LUAMETHOD(Element,ReplaceChild) + RMLUI_LUAMETHOD(Element,ScrollIntoView) + RMLUI_LUAMETHOD(Element,SetAttribute) + RMLUI_LUAMETHOD(Element,SetClass) { nullptr, nullptr }, }; luaL_Reg ElementGetters[] = { - LUAGETTER(Element,attributes) - LUAGETTER(Element,child_nodes) - LUAGETTER(Element,class_name) - LUAGETTER(Element,client_left) - LUAGETTER(Element,client_height) - LUAGETTER(Element,client_top) - LUAGETTER(Element,client_width) - LUAGETTER(Element,first_child) - LUAGETTER(Element,id) - LUAGETTER(Element,inner_rml) - LUAGETTER(Element,last_child) - LUAGETTER(Element,next_sibling) - LUAGETTER(Element,offset_height) - LUAGETTER(Element,offset_left) - LUAGETTER(Element,offset_parent) - LUAGETTER(Element,offset_top) - LUAGETTER(Element,offset_width) - LUAGETTER(Element,owner_document) - LUAGETTER(Element,parent_node) - LUAGETTER(Element,previous_sibling) - LUAGETTER(Element,scroll_height) - LUAGETTER(Element,scroll_left) - LUAGETTER(Element,scroll_top) - LUAGETTER(Element,scroll_width) - LUAGETTER(Element,style) - LUAGETTER(Element,tag_name) + RMLUI_LUAGETTER(Element,attributes) + RMLUI_LUAGETTER(Element,child_nodes) + RMLUI_LUAGETTER(Element,class_name) + RMLUI_LUAGETTER(Element,client_left) + RMLUI_LUAGETTER(Element,client_height) + RMLUI_LUAGETTER(Element,client_top) + RMLUI_LUAGETTER(Element,client_width) + RMLUI_LUAGETTER(Element,first_child) + RMLUI_LUAGETTER(Element,id) + RMLUI_LUAGETTER(Element,inner_rml) + RMLUI_LUAGETTER(Element,last_child) + RMLUI_LUAGETTER(Element,next_sibling) + RMLUI_LUAGETTER(Element,offset_height) + RMLUI_LUAGETTER(Element,offset_left) + RMLUI_LUAGETTER(Element,offset_parent) + RMLUI_LUAGETTER(Element,offset_top) + RMLUI_LUAGETTER(Element,offset_width) + RMLUI_LUAGETTER(Element,owner_document) + RMLUI_LUAGETTER(Element,parent_node) + RMLUI_LUAGETTER(Element,previous_sibling) + RMLUI_LUAGETTER(Element,scroll_height) + RMLUI_LUAGETTER(Element,scroll_left) + RMLUI_LUAGETTER(Element,scroll_top) + RMLUI_LUAGETTER(Element,scroll_width) + RMLUI_LUAGETTER(Element,style) + RMLUI_LUAGETTER(Element,tag_name) { nullptr, nullptr }, }; luaL_Reg ElementSetters[] = { - LUASETTER(Element,class_name) - LUASETTER(Element,id) - LUASETTER(Element,inner_rml) - LUASETTER(Element,scroll_left) - LUASETTER(Element,scroll_top) + RMLUI_LUASETTER(Element,class_name) + RMLUI_LUASETTER(Element,id) + RMLUI_LUASETTER(Element,inner_rml) + RMLUI_LUASETTER(Element,scroll_left) + RMLUI_LUASETTER(Element,scroll_top) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Element) - - - - - - - - - +RMLUI_LUATYPE_DEFINE(Element) template<> void ExtraInit(lua_State* /*L*/, int /*metatable_index*/) @@ -654,10 +641,8 @@ luaL_Reg ElementPtrSetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementPtr) +RMLUI_LUATYPE_DEFINE(ElementPtr) - -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Element.h b/Source/Lua/Element.h similarity index 95% rename from Source/Core/Lua/Element.h rename to Source/Lua/Element.h index 3b3a10cff..711b0e4f9 100644 --- a/Source/Core/Lua/Element.h +++ b/Source/Lua/Element.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUAELEMENT_H -#define RMLUICORELUAELEMENT_H +#ifndef RMLUI_LUA_ELEMENT_H +#define RMLUI_LUA_ELEMENT_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { template<> RMLUILUA_API void ExtraInit(lua_State* L, int metatable_index); @@ -96,12 +95,11 @@ int ElementSetAttrscroll_left(lua_State* L); int ElementSetAttrscroll_top(lua_State* L); - extern RegType ElementMethods[]; extern luaL_Reg ElementGetters[]; extern luaL_Reg ElementSetters[]; -LUACORETYPEDECLARE(Element) +RMLUI_LUATYPE_DECLARE(Element) template<> void ExtraInit(lua_State* L, int metatable_index); @@ -111,9 +109,8 @@ extern RegType ElementPtrMethods[]; extern luaL_Reg ElementPtrGetters[]; extern luaL_Reg ElementPtrSetters[]; -LUACORETYPEDECLARE(ElementPtr) +RMLUI_LUATYPE_DECLARE(ElementPtr) -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/ElementAttributesProxy.cpp b/Source/Lua/ElementAttributesProxy.cpp similarity index 95% rename from Source/Core/Lua/ElementAttributesProxy.cpp rename to Source/Lua/ElementAttributesProxy.cpp index f4c739e3b..c2da5a0e3 100644 --- a/Source/Core/Lua/ElementAttributesProxy.cpp +++ b/Source/Lua/ElementAttributesProxy.cpp @@ -26,13 +26,11 @@ * */ -#include "precompiled.h" #include "ElementAttributesProxy.h" +#include #include -#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) { @@ -51,7 +49,7 @@ int ElementAttributesProxy__index(lua_State* L) if(keytype == LUA_TSTRING) //only valid key types { ElementAttributesProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* key = lua_tostring(L,2); Variant* attr = obj->owner->GetAttribute(key); PushVariant(L,attr); //Utilities.h @@ -65,7 +63,7 @@ int ElementAttributesProxy__index(lua_State* L) int ElementAttributesProxy__pairs(lua_State* L) { ElementAttributesProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int& pindex = *(int*)lua_touserdata(L,3); if ((pindex) == -1) pindex = 0; @@ -111,7 +109,6 @@ luaL_Reg ElementAttributesProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementAttributesProxy) -} -} -} +RMLUI_LUATYPE_DEFINE(ElementAttributesProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ElementAttributesProxy.h b/Source/Lua/ElementAttributesProxy.h similarity index 89% rename from Source/Core/Lua/ElementAttributesProxy.h rename to Source/Lua/ElementAttributesProxy.h index 57b8ad2ae..dd577695b 100644 --- a/Source/Core/Lua/ElementAttributesProxy.h +++ b/Source/Lua/ElementAttributesProxy.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUAELEMENTATTRIBUTESPROXY_H -#define RMLUICORELUAELEMENTATTRIBUTESPROXY_H +#ifndef RMLUI_LUA_ELEMENTATTRIBUTESPROXY_H +#define RMLUI_LUA_ELEMENTATTRIBUTESPROXY_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { //where owner is the Element that we should look up information from struct ElementAttributesProxy { Element* owner; }; @@ -48,8 +47,7 @@ extern RegType ElementAttributesProxyMethods[]; extern luaL_Reg ElementAttributesProxyGetters[]; extern luaL_Reg ElementAttributesProxySetters[]; -LUACORETYPEDECLARE(ElementAttributesProxy) -} -} -} +RMLUI_LUATYPE_DECLARE(ElementAttributesProxy) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/ElementChildNodesProxy.cpp b/Source/Lua/ElementChildNodesProxy.cpp similarity index 96% rename from Source/Core/Lua/ElementChildNodesProxy.cpp rename to Source/Lua/ElementChildNodesProxy.cpp index e206f9606..9d20a396e 100644 --- a/Source/Core/Lua/ElementChildNodesProxy.cpp +++ b/Source/Lua/ElementChildNodesProxy.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "ElementChildNodesProxy.h" #include "Element.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -51,7 +49,7 @@ int ElementChildNodesProxy__index(lua_State* L) if(keytype == LUA_TNUMBER) //only valid key types { ElementChildNodesProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int key = (int)luaL_checkinteger(L,2); Element* child = obj->owner->GetChild(key); LuaType::push(L,child,false); @@ -72,7 +70,7 @@ int ElementChildNodesProxy__pairs(lua_State* L) int ElementChildNodesProxy__ipairs(lua_State* L) { ElementChildNodesProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) //initial value (*pindex) = 0; @@ -104,7 +102,6 @@ luaL_Reg ElementChildNodesProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementChildNodesProxy) -} -} -} +RMLUI_LUATYPE_DEFINE(ElementChildNodesProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ElementChildNodesProxy.h b/Source/Lua/ElementChildNodesProxy.h similarity index 88% rename from Source/Core/Lua/ElementChildNodesProxy.h rename to Source/Lua/ElementChildNodesProxy.h index 6e72c4198..70dbbadd5 100644 --- a/Source/Core/Lua/ElementChildNodesProxy.h +++ b/Source/Lua/ElementChildNodesProxy.h @@ -27,15 +27,14 @@ */ -#ifndef RMLUICORELUAELEMENTCHILDNODESPROXY_H -#define RMLUICORELUAELEMENTCHILDNODESPROXY_H +#ifndef RMLUI_LUA_ELEMENTCHILDNODESPROXY_H +#define RMLUI_LUA_ELEMENTCHILDNODESPROXY_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { //where owner is the Element that we should look up information from struct ElementChildNodesProxy { Element* owner; }; @@ -49,9 +48,7 @@ extern RegType ElementChildNodesProxyMethods[]; extern luaL_Reg ElementChildNodesProxyGetters[]; extern luaL_Reg ElementChildNodesProxySetters[]; -LUACORETYPEDECLARE(ElementChildNodesProxy) -} -} -} - -#endif \ No newline at end of file +RMLUI_LUATYPE_DECLARE(ElementChildNodesProxy) +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Core/Lua/ElementInstancer.cpp b/Source/Lua/ElementInstancer.cpp similarity index 94% rename from Source/Core/Lua/ElementInstancer.cpp rename to Source/Lua/ElementInstancer.cpp index 020b0ce94..642395d9f 100644 --- a/Source/Core/Lua/ElementInstancer.cpp +++ b/Source/Lua/ElementInstancer.cpp @@ -27,12 +27,10 @@ */ -#include "precompiled.h" #include "ElementInstancer.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) { @@ -52,7 +50,7 @@ int ElementInstancernew(lua_State* L) int ElementInstancerSetAttrInstanceElement(lua_State* L) { LuaElementInstancer* lei = (LuaElementInstancer*)LuaType::check(L,1); - LUACHECKOBJ(lei); + RMLUI_CHECK_OBJ(lei); if(lua_type(L,2) != LUA_TFUNCTION) { @@ -78,11 +76,10 @@ luaL_Reg ElementInstancerGetters[] = luaL_Reg ElementInstancerSetters[] = { - LUASETTER(ElementInstancer,InstanceElement) + RMLUI_LUASETTER(ElementInstancer,InstanceElement) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementInstancer) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementInstancer) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ElementInstancer.h b/Source/Lua/ElementInstancer.h similarity index 88% rename from Source/Core/Lua/ElementInstancer.h rename to Source/Lua/ElementInstancer.h index 76a0242be..11fe77eda 100644 --- a/Source/Core/Lua/ElementInstancer.h +++ b/Source/Lua/ElementInstancer.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUAELEMENTINSTANCER_H -#define RMLUICORELUAELEMENTINSTANCER_H +#ifndef RMLUI_LUA_ELEMENTINSTANCER_H +#define RMLUI_LUA_ELEMENTINSTANCER_H -#include -#include +#include +#include #include "LuaElementInstancer.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); //method @@ -46,10 +45,7 @@ extern RegType ElementInstancerMethods[]; extern luaL_Reg ElementInstancerGetters[]; extern luaL_Reg ElementInstancerSetters[]; -LUACORETYPEDECLARE(ElementInstancer) -} -} -} - - -#endif \ No newline at end of file +RMLUI_LUATYPE_DECLARE(ElementInstancer) +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Core/Lua/ElementStyleProxy.cpp b/Source/Lua/ElementStyleProxy.cpp similarity index 91% rename from Source/Core/Lua/ElementStyleProxy.cpp rename to Source/Lua/ElementStyleProxy.cpp index 8c59af808..9f53d93cf 100644 --- a/Source/Core/Lua/ElementStyleProxy.cpp +++ b/Source/Lua/ElementStyleProxy.cpp @@ -26,13 +26,15 @@ * */ -#include "precompiled.h" -#include -#include #include "ElementStyleProxy.h" +#include +#include +#include +#include +#include +#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) { @@ -56,9 +58,9 @@ int ElementStyleProxy__index(lua_State* L) if(keytype == LUA_TSTRING) //if we are trying to access a string, then we will assume that it is a property { ElementStyleProxy* es = LuaType::check(L,1); - LUACHECKOBJ(es); + RMLUI_CHECK_OBJ(es); const Property* prop = es->owner->GetProperty(lua_tostring(L,2)); - LUACHECKOBJ(prop) + RMLUI_CHECK_OBJ(prop) lua_pushstring(L,prop->ToString().c_str()); return 1; } @@ -73,7 +75,7 @@ int ElementStyleProxy__newindex(lua_State* L) { //[1] = obj, [2] = key, [3] = value ElementStyleProxy* es = LuaType::check(L,1); - LUACHECKOBJ(es); + RMLUI_CHECK_OBJ(es); int keytype = lua_type(L,2); int valuetype = lua_type(L,3); if(keytype == LUA_TSTRING ) @@ -103,7 +105,7 @@ int ElementStyleProxy__newindex(lua_State* L) int ElementStyleProxy__pairs(lua_State* L) { ElementStyleProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if ((*pindex) == -1) *pindex = 0; @@ -156,7 +158,6 @@ luaL_Reg ElementStyleProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementStyleProxy) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementStyleProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ElementStyleProxy.h b/Source/Lua/ElementStyleProxy.h similarity index 88% rename from Source/Core/Lua/ElementStyleProxy.h rename to Source/Lua/ElementStyleProxy.h index 1cbf86409..66e585b94 100644 --- a/Source/Core/Lua/ElementStyleProxy.h +++ b/Source/Lua/ElementStyleProxy.h @@ -26,14 +26,15 @@ * */ -#ifndef RMLUICORELUAELEMENTSTYLEPROXY_H -#define RMLUICORELUAELEMENTSTYLEPROXY_H +#ifndef RMLUI_LUA_ELEMENTSTYLEPROXY_H +#define RMLUI_LUA_ELEMENTSTYLEPROXY_H -#include -#include +#include +#include namespace Rml { -namespace Core { +class Element; + namespace Lua { struct ElementStyleProxy { Element* owner; }; @@ -47,8 +48,7 @@ extern RegType ElementStyleProxyMethods[]; extern luaL_Reg ElementStyleProxyGetters[]; extern luaL_Reg ElementStyleProxySetters[]; -LUACORETYPEDECLARE(ElementStyleProxy) -} -} -} +RMLUI_LUATYPE_DECLARE(ElementStyleProxy) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/ElementText.cpp b/Source/Lua/ElementText.cpp similarity index 90% rename from Source/Core/Lua/ElementText.cpp rename to Source/Lua/ElementText.cpp index 9a2dec552..ba9a8b30c 100644 --- a/Source/Core/Lua/ElementText.cpp +++ b/Source/Lua/ElementText.cpp @@ -26,13 +26,11 @@ * */ -#include "precompiled.h" #include "ElementText.h" #include "Element.h" -#include +#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) { @@ -45,7 +43,7 @@ template<> void ExtraInit(lua_State* L, int metatable_index) int ElementTextGetAttrtext(lua_State* L) { ElementText* obj = LuaType::check(L, 1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushstring(L, obj->GetText().c_str()); return 1; } @@ -53,7 +51,7 @@ int ElementTextGetAttrtext(lua_State* L) int ElementTextSetAttrtext(lua_State* L) { ElementText* obj = LuaType::check(L, 1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* text = luaL_checkstring(L,2); obj->SetText(text); return 0; @@ -66,17 +64,16 @@ RegType ElementTextMethods[] = luaL_Reg ElementTextGetters[] = { - LUAGETTER(ElementText,text) + RMLUI_LUAGETTER(ElementText,text) { nullptr, nullptr }, }; luaL_Reg ElementTextSetters[] = { - LUASETTER(ElementText,text) + RMLUI_LUASETTER(ElementText,text) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(ElementText) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementText) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/ElementText.h b/Source/Lua/ElementText.h similarity index 89% rename from Source/Core/Lua/ElementText.h rename to Source/Lua/ElementText.h index 242692f0e..d3c656834 100644 --- a/Source/Core/Lua/ElementText.h +++ b/Source/Lua/ElementText.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUAELEMENTTEXT_H -#define RMLUICORELUAELEMENTTEXT_H +#ifndef RMLUI_LUA_ELEMENTTEXT_H +#define RMLUI_LUA_ELEMENTTEXT_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { //will inherit from Element template<> void ExtraInit(lua_State* L, int metatable_index); @@ -46,8 +45,7 @@ extern RegType ElementTextMethods[]; extern luaL_Reg ElementTextGetters[]; extern luaL_Reg ElementTextSetters[]; -LUACORETYPEDECLARE(ElementText) -} -} -} +RMLUI_LUATYPE_DECLARE(ElementText) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Controls/Lua/As.h b/Source/Lua/Elements/As.h similarity index 81% rename from Source/Controls/Lua/As.h rename to Source/Lua/Elements/As.h index de56a1445..22a9efc8f 100644 --- a/Source/Controls/Lua/As.h +++ b/Source/Lua/Elements/As.h @@ -26,18 +26,17 @@ * */ -#ifndef RMLUICONTROLSLUAAS_H -#define RMLUICONTROLSLUAAS_H +#ifndef RMLUI_LUA_ELEMENTS_AS_H +#define RMLUI_LUA_ELEMENTS_AS_H /* These are helper functions to fill up the Element.As table with types that are able to be casted */ -#include -#include +#include +#include #include namespace Rml { -namespace Controls { namespace Lua { //Helper function for the controls, so that the types don't have to define individual functions themselves @@ -45,9 +44,9 @@ namespace Lua { template int CastFromElementTo(lua_State* L) { - Rml::Core::Element* ele = Rml::Core::Lua::LuaType::check(L,1); - LUACHECKOBJ(ele); - Rml::Core::Lua::LuaType::push(L,(ToType*)ele,false); + Element* ele = LuaType::check(L,1); + RMLUI_CHECK_OBJ(ele); + LuaType::push(L,(ToType*)ele,false); return 1; } @@ -60,14 +59,12 @@ void AddCastFunctionToElementAsTable(lua_State* L) lua_getfield(L,-1,"As"); if(!lua_isnoneornil(L,-1)) { - lua_pushcfunction(L,Rml::Controls::Lua::CastFromElementTo); - lua_setfield(L,-2,Rml::Core::Lua::GetTClassName()); + lua_pushcfunction(L,CastFromElementTo); + lua_setfield(L,-2,GetTClassName()); } lua_settop(L,top); //pop "As" and "Element" } -} -} -} - +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Controls/Lua/DataFormatter.cpp b/Source/Lua/Elements/DataFormatter.cpp similarity index 89% rename from Source/Controls/Lua/DataFormatter.cpp rename to Source/Lua/Elements/DataFormatter.cpp index 912c2c23e..4dee61b37 100644 --- a/Source/Controls/Lua/DataFormatter.cpp +++ b/Source/Lua/Elements/DataFormatter.cpp @@ -26,13 +26,11 @@ * */ -#include "precompiled.h" #include "DataFormatter.h" +#include -using Rml::Core::Log; namespace Rml { -namespace Controls { namespace Lua { //method int DataFormatternew(lua_State* L) @@ -69,7 +67,7 @@ int DataFormatternew(lua_State* L) int DataFormatterSetAttrFormatData(lua_State* L) { DataFormatter* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int ref = LUA_NOREF; if(lua_type(L,2) != LUA_TFUNCTION) { @@ -86,7 +84,7 @@ int DataFormatterSetAttrFormatData(lua_State* L) return 0; } -Rml::Core::Lua::RegType DataFormatterMethods[] = +RegType DataFormatterMethods[] = { { nullptr, nullptr }, }; @@ -98,25 +96,17 @@ luaL_Reg DataFormatterGetters[] = luaL_Reg DataFormatterSetters[] = { - LUASETTER(DataFormatter,FormatData) + RMLUI_LUASETTER(DataFormatter,FormatData) { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -using Rml::Controls::Lua::DataFormatter; template<> void ExtraInit(lua_State* L, int metatable_index) { - lua_pushcfunction(L,Rml::Controls::Lua::DataFormatternew); + lua_pushcfunction(L,DataFormatternew); lua_setfield(L,metatable_index-1,"new"); return; } -LUACONTROLSTYPEDEFINE(DataFormatter) -} -} -} +RMLUI_LUATYPE_DEFINE(DataFormatter) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/DataFormatter.h b/Source/Lua/Elements/DataFormatter.h similarity index 76% rename from Source/Controls/Lua/DataFormatter.h rename to Source/Lua/Elements/DataFormatter.h index bc9fde2bd..debcb72d2 100644 --- a/Source/Controls/Lua/DataFormatter.h +++ b/Source/Lua/Elements/DataFormatter.h @@ -26,17 +26,15 @@ * */ -#ifndef RMLUICONTROLSLUADATAFORMATTER_H -#define RMLUICONTROLSLUADATAFORMATTER_H +#ifndef RMLUI_LUA_ELEMENTS_DATAFORMATTER_H +#define RMLUI_LUA_ELEMENTS_DATAFORMATTER_H -#include -#include +#include +#include #include "LuaDataFormatter.h" -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { typedef LuaDataFormatter DataFormatter; //method @@ -45,15 +43,14 @@ int DataFormatternew(lua_State* L); //setter int DataFormatterSetAttrFormatData(lua_State* L); -extern Rml::Core::Lua::RegType DataFormatterMethods[]; +extern RegType DataFormatterMethods[]; extern luaL_Reg DataFormatterGetters[]; extern luaL_Reg DataFormatterSetters[]; -} -} -} -//for DataFormatter.new -namespace Rml { namespace Core { namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::Lua::DataFormatter) -}}} + + +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(DataFormatter) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/DataSource.cpp b/Source/Lua/Elements/DataSource.cpp similarity index 84% rename from Source/Controls/Lua/DataSource.cpp rename to Source/Lua/Elements/DataSource.cpp index f4d3674aa..9bd9d551a 100644 --- a/Source/Controls/Lua/DataSource.cpp +++ b/Source/Lua/Elements/DataSource.cpp @@ -26,14 +26,10 @@ * */ -#include "precompiled.h" #include "DataSource.h" #include -using Rml::Core::Log; - namespace Rml { -namespace Controls { namespace Lua { typedef LuaDataSource DataSource; @@ -47,7 +43,7 @@ int DataSourcenew(lua_State* L) int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* table_name = luaL_checkstring(L,1); int first_row_added = (int)luaL_checkinteger(L,2); int num_rows_added = (int)luaL_checkinteger(L,3); @@ -57,7 +53,7 @@ int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj) int DataSourceNotifyRowRemove(lua_State* L, DataSource* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* table_name = luaL_checkstring(L,1); int first_row_removed = (int)luaL_checkinteger(L,2); int num_rows_removed = (int)luaL_checkinteger(L,3); @@ -67,7 +63,7 @@ int DataSourceNotifyRowRemove(lua_State* L, DataSource* obj) int DataSourceNotifyRowChange(lua_State* L, DataSource* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* table_name = luaL_checkstring(L,1); if(lua_gettop(L) < 2) { @@ -85,7 +81,7 @@ int DataSourceNotifyRowChange(lua_State* L, DataSource* obj) int DataSourceSetAttrGetNumRows(lua_State* L) { DataSource* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); if(lua_type(L,2) == LUA_TFUNCTION) { lua_pushvalue(L,2); //copy of the function, so it is for sure at the top of the stack @@ -99,7 +95,7 @@ int DataSourceSetAttrGetNumRows(lua_State* L) int DataSourceSetAttrGetRow(lua_State* L) { DataSource* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); if(lua_type(L,2) == LUA_TFUNCTION) { lua_pushvalue(L,2); //copy of the functions, so it is for sure at the top of the stack @@ -111,11 +107,11 @@ int DataSourceSetAttrGetRow(lua_State* L) } -Rml::Core::Lua::RegType DataSourceMethods[] = +RegType DataSourceMethods[] = { - LUAMETHOD(DataSource,NotifyRowAdd) - LUAMETHOD(DataSource,NotifyRowRemove) - LUAMETHOD(DataSource,NotifyRowChange) + RMLUI_LUAMETHOD(DataSource,NotifyRowAdd) + RMLUI_LUAMETHOD(DataSource,NotifyRowRemove) + RMLUI_LUAMETHOD(DataSource,NotifyRowChange) { nullptr, nullptr }, }; @@ -126,27 +122,18 @@ luaL_Reg DataSourceGetters[] = luaL_Reg DataSourceSetters[] = { - LUASETTER(DataSource,GetNumRows) - LUASETTER(DataSource,GetRow) + RMLUI_LUASETTER(DataSource,GetNumRows) + RMLUI_LUASETTER(DataSource,GetRow) { nullptr, nullptr }, }; - -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { - lua_pushcfunction(L,Rml::Controls::Lua::DataSourcenew); + lua_pushcfunction(L,DataSourcenew); lua_setfield(L,metatable_index-1,"new"); return; } -using Rml::Controls::Lua::DataSource; -LUACONTROLSTYPEDEFINE(DataSource) -} -} -} +RMLUI_LUATYPE_DEFINE(DataSource) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/DataSource.h b/Source/Lua/Elements/DataSource.h similarity index 79% rename from Source/Controls/Lua/DataSource.h rename to Source/Lua/Elements/DataSource.h index 927700cd8..a4caf97e5 100644 --- a/Source/Controls/Lua/DataSource.h +++ b/Source/Lua/Elements/DataSource.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUADATASOURCE_H -#define RMLUICONTROLSLUADATASOURCE_H +#ifndef RMLUI_LUA_ELEMENTS_DATASOURCE_H +#define RMLUI_LUA_ELEMENTS_DATASOURCE_H -#include -#include +#include +#include #include "LuaDataSource.h" -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { typedef LuaDataSource DataSource; @@ -48,17 +46,14 @@ int DataSourceNotifyRowChange(lua_State* L, DataSource* obj); int DataSourceSetAttrGetNumRows(lua_State* L); int DataSourceSetAttrGetRow(lua_State* L); -extern Rml::Core::Lua::RegType DataSourceMethods[]; +extern RegType DataSourceMethods[]; extern luaL_Reg DataSourceGetters[]; extern luaL_Reg DataSourceSetters[]; +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(DataSource) +} // namespace Lua +} // namespace Rml -} -} -} -namespace Rml { namespace Core { namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::Lua::DataSource) -}}} #endif diff --git a/Source/Controls/Lua/ElementDataGrid.cpp b/Source/Lua/Elements/ElementDataGrid.cpp similarity index 79% rename from Source/Controls/Lua/ElementDataGrid.cpp rename to Source/Lua/Elements/ElementDataGrid.cpp index a34357f80..62a773a08 100644 --- a/Source/Controls/Lua/ElementDataGrid.cpp +++ b/Source/Lua/Elements/ElementDataGrid.cpp @@ -26,22 +26,20 @@ * */ -#include "precompiled.h" #include "ElementDataGrid.h" #include -#include -#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { //methods int ElementDataGridAddColumn(lua_State* L, ElementDataGrid* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* fields = luaL_checkstring(L,1); const char* formatter = luaL_checkstring(L,2); float width = (float)luaL_checknumber(L,3); @@ -53,7 +51,7 @@ int ElementDataGridAddColumn(lua_State* L, ElementDataGrid* obj) int ElementDataGridSetDataSource(lua_State* L, ElementDataGrid* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* source = luaL_checkstring(L,1); obj->SetDataSource(source); @@ -65,7 +63,7 @@ int ElementDataGridSetDataSource(lua_State* L, ElementDataGrid* obj) int ElementDataGridGetAttrrows(lua_State* L) { ElementDataGrid* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_newtable(L); int tbl = lua_gettop(L); @@ -81,17 +79,16 @@ int ElementDataGridGetAttrrows(lua_State* L) } - -Rml::Core::Lua::RegType ElementDataGridMethods[] = +RegType ElementDataGridMethods[] = { - LUAMETHOD(ElementDataGrid,AddColumn) - LUAMETHOD(ElementDataGrid,SetDataSource) + RMLUI_LUAMETHOD(ElementDataGrid,AddColumn) + RMLUI_LUAMETHOD(ElementDataGrid,SetDataSource) { nullptr, nullptr }, }; luaL_Reg ElementDataGridGetters[] = { - LUAGETTER(ElementDataGrid,rows) + RMLUI_LUAGETTER(ElementDataGrid,rows) { nullptr, nullptr }, }; @@ -101,20 +98,12 @@ luaL_Reg ElementDataGridSetters[] = }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { ExtraInit(L,metatable_index); LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementDataGrid; -LUACONTROLSTYPEDEFINE(ElementDataGrid) -} -} + AddTypeToElementAsTable(L); } +RMLUI_LUATYPE_DEFINE(ElementDataGrid) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementDataGrid.h b/Source/Lua/Elements/ElementDataGrid.h similarity index 76% rename from Source/Controls/Lua/ElementDataGrid.h rename to Source/Lua/Elements/ElementDataGrid.h index 52f195329..e08d0342c 100644 --- a/Source/Controls/Lua/ElementDataGrid.h +++ b/Source/Lua/Elements/ElementDataGrid.h @@ -26,17 +26,15 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTDATAGRID_H -#define RMLUICONTROLSLUAELEMENTDATAGRID_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTDATAGRID_H +#define RMLUI_LUA_ELEMENTS_ELEMENTDATAGRID_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //methods @@ -47,17 +45,15 @@ int ElementDataGridSetDataSource(lua_State* L, ElementDataGrid* obj); int ElementDataGridGetAttrrows(lua_State* L); -extern Rml::Core::Lua::RegType ElementDataGridMethods[]; +extern RegType ElementDataGridMethods[]; extern luaL_Reg ElementDataGridGetters[]; extern luaL_Reg ElementDataGridSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { //this will be used to "inherit" from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementDataGrid) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementDataGrid) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementDataGridRow.cpp b/Source/Lua/Elements/ElementDataGridRow.cpp similarity index 75% rename from Source/Controls/Lua/ElementDataGridRow.cpp rename to Source/Lua/Elements/ElementDataGridRow.cpp index 00a245f7b..49dfffe71 100644 --- a/Source/Controls/Lua/ElementDataGridRow.cpp +++ b/Source/Lua/Elements/ElementDataGridRow.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "ElementDataGridRow.h" -#include -#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { @@ -41,7 +39,7 @@ namespace Lua { int ElementDataGridRowGetAttrrow_expanded(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushboolean(L,obj->IsRowExpanded()); return 1; } @@ -49,7 +47,7 @@ int ElementDataGridRowGetAttrrow_expanded(lua_State* L) int ElementDataGridRowGetAttrparent_relative_index(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetParentRelativeIndex()); return 1; } @@ -57,7 +55,7 @@ int ElementDataGridRowGetAttrparent_relative_index(lua_State* L) int ElementDataGridRowGetAttrtable_relative_index(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetTableRelativeIndex()); return 1; } @@ -65,7 +63,7 @@ int ElementDataGridRowGetAttrtable_relative_index(lua_State* L) int ElementDataGridRowGetAttrparent_row(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); LuaType::push(L,obj->GetParentRow(),false); return 1; } @@ -73,7 +71,7 @@ int ElementDataGridRowGetAttrparent_row(lua_State* L) int ElementDataGridRowGetAttrparent_grid(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); LuaType::push(L,obj->GetParentGrid(),false); return 1; } @@ -83,8 +81,8 @@ int ElementDataGridRowGetAttrparent_grid(lua_State* L) int ElementDataGridRowSetAttrrow_expanded(lua_State* L) { ElementDataGridRow* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); - bool expanded = CHECK_BOOL(L,2); + RMLUI_CHECK_OBJ(obj); + bool expanded = RMLUI_CHECK_BOOL(L,2); if(expanded) obj->ExpandRow(); else @@ -93,42 +91,34 @@ int ElementDataGridRowSetAttrrow_expanded(lua_State* L) } - -Rml::Core::Lua::RegType ElementDataGridRowMethods[] = +RegType ElementDataGridRowMethods[] = { { nullptr, nullptr }, }; luaL_Reg ElementDataGridRowGetters[] = { - LUAGETTER(ElementDataGridRow,row_expanded) - LUAGETTER(ElementDataGridRow,parent_relative_index) - LUAGETTER(ElementDataGridRow,table_relative_index) - LUAGETTER(ElementDataGridRow,parent_row) - LUAGETTER(ElementDataGridRow,parent_grid) + RMLUI_LUAGETTER(ElementDataGridRow,row_expanded) + RMLUI_LUAGETTER(ElementDataGridRow,parent_relative_index) + RMLUI_LUAGETTER(ElementDataGridRow,table_relative_index) + RMLUI_LUAGETTER(ElementDataGridRow,parent_row) + RMLUI_LUAGETTER(ElementDataGridRow,parent_grid) { nullptr, nullptr }, }; luaL_Reg ElementDataGridRowSetters[] = { - LUASETTER(ElementDataGridRow,row_expanded) + RMLUI_LUASETTER(ElementDataGridRow,row_expanded) { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) + +template<> void ExtraInit(lua_State* L, int metatable_index) { ExtraInit(L,metatable_index); LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementDataGridRow; -LUACONTROLSTYPEDEFINE(ElementDataGridRow) -} + AddTypeToElementAsTable(L); } -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementDataGridRow) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementDataGridRow.h b/Source/Lua/Elements/ElementDataGridRow.h similarity index 77% rename from Source/Controls/Lua/ElementDataGridRow.h rename to Source/Lua/Elements/ElementDataGridRow.h index 909c5f5d4..f91ec1471 100644 --- a/Source/Controls/Lua/ElementDataGridRow.h +++ b/Source/Lua/Elements/ElementDataGridRow.h @@ -26,17 +26,15 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTDATAGRIDROW_H -#define RMLUICONTROLSLUAELEMENTDATAGRIDROW_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTDATAGRIDROW_H +#define RMLUI_LUA_ELEMENTS_ELEMENTDATAGRIDROW_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //getters @@ -50,18 +48,15 @@ int ElementDataGridRowGetAttrparent_grid(lua_State* L); int ElementDataGridRowSetAttrrow_expanded(lua_State* L); -extern Rml::Core::Lua::RegType ElementDataGridRowMethods[]; +extern RegType ElementDataGridRowMethods[]; extern luaL_Reg ElementDataGridRowGetters[]; extern luaL_Reg ElementDataGridRowSetters[]; - -} -} -} -namespace Rml { namespace Core { namespace Lua { //this will be used to "inherit" from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementDataGridRow) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementDataGridRow) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementForm.cpp b/Source/Lua/Elements/ElementForm.cpp similarity index 80% rename from Source/Controls/Lua/ElementForm.cpp rename to Source/Lua/Elements/ElementForm.cpp index b74b7bcea..7ce5da23d 100644 --- a/Source/Controls/Lua/ElementForm.cpp +++ b/Source/Lua/Elements/ElementForm.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "ElementForm.h" #include -#include -#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { //method @@ -52,9 +50,9 @@ int ElementFormSubmit(lua_State* L, ElementForm* obj) return 0; } -Rml::Core::Lua::RegType ElementFormMethods[] = +RegType ElementFormMethods[] = { - LUAMETHOD(ElementForm,Submit) + RMLUI_LUAMETHOD(ElementForm,Submit) { nullptr, nullptr }, }; @@ -69,21 +67,13 @@ luaL_Reg ElementFormSetters[] = }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { //inherit from Element ExtraInit(L,metatable_index); LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementForm; -LUACONTROLSTYPEDEFINE(ElementForm) -} -} + AddTypeToElementAsTable(L); } +RMLUI_LUATYPE_DEFINE(ElementForm) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementForm.h b/Source/Lua/Elements/ElementForm.h similarity index 75% rename from Source/Controls/Lua/ElementForm.h rename to Source/Lua/Elements/ElementForm.h index 814c2319f..d35480631 100644 --- a/Source/Controls/Lua/ElementForm.h +++ b/Source/Lua/Elements/ElementForm.h @@ -26,32 +26,28 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORM_H -#define RMLUICONTROLSLUAELEMENTFORM_H - -#include -#include -#include - -using Rml::Core::Lua::LuaType; +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORM_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORM_H +#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { //method int ElementFormSubmit(lua_State* L, ElementForm* obj); -extern Rml::Core::Lua::RegType ElementFormMethods[]; +extern RegType ElementFormMethods[]; extern luaL_Reg ElementFormGetters[]; extern luaL_Reg ElementFormSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { + + //this will be used to "inherit" from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementForm) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementForm) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementFormControl.cpp b/Source/Lua/Elements/ElementFormControl.cpp similarity index 74% rename from Source/Controls/Lua/ElementFormControl.cpp rename to Source/Lua/Elements/ElementFormControl.cpp index e38eb9b5c..f0bae1375 100644 --- a/Source/Controls/Lua/ElementFormControl.cpp +++ b/Source/Lua/Elements/ElementFormControl.cpp @@ -26,23 +26,21 @@ * */ -#include "precompiled.h" +#include "../Element.h" #include "ElementFormControl.h" -#include +#include #include -#include -#include +#include namespace Rml { -namespace Controls { namespace Lua { //getters int ElementFormControlGetAttrdisabled(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); + RMLUI_CHECK_OBJ(efc); lua_pushboolean(L,efc->IsDisabled()); return 1; } @@ -50,7 +48,7 @@ int ElementFormControlGetAttrdisabled(lua_State* L) int ElementFormControlGetAttrname(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); + RMLUI_CHECK_OBJ(efc); lua_pushstring(L,efc->GetName().c_str()); return 1; } @@ -58,7 +56,7 @@ int ElementFormControlGetAttrname(lua_State* L) int ElementFormControlGetAttrvalue(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); + RMLUI_CHECK_OBJ(efc); lua_pushstring(L,efc->GetValue().c_str()); return 1; } @@ -68,15 +66,15 @@ int ElementFormControlGetAttrvalue(lua_State* L) int ElementFormControlSetAttrdisabled(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); - efc->SetDisabled(CHECK_BOOL(L,2)); + RMLUI_CHECK_OBJ(efc); + efc->SetDisabled(RMLUI_CHECK_BOOL(L,2)); return 0; } int ElementFormControlSetAttrname(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); + RMLUI_CHECK_OBJ(efc); const char* name = luaL_checkstring(L,2); efc->SetName(name); return 0; @@ -85,48 +83,41 @@ int ElementFormControlSetAttrname(lua_State* L) int ElementFormControlSetAttrvalue(lua_State* L) { ElementFormControl* efc = LuaType::check(L,1); - LUACHECKOBJ(efc); + RMLUI_CHECK_OBJ(efc); const char* value = luaL_checkstring(L,2); efc->SetValue(value); return 0; } -Rml::Core::Lua::RegType ElementFormControlMethods[] = +RegType ElementFormControlMethods[] = { { nullptr, nullptr }, }; luaL_Reg ElementFormControlGetters[] = { - LUAGETTER(ElementFormControl,disabled) - LUAGETTER(ElementFormControl,name) - LUAGETTER(ElementFormControl,value) + RMLUI_LUAGETTER(ElementFormControl,disabled) + RMLUI_LUAGETTER(ElementFormControl,name) + RMLUI_LUAGETTER(ElementFormControl,value) { nullptr, nullptr }, }; luaL_Reg ElementFormControlSetters[] = { - LUASETTER(ElementFormControl,disabled) - LUASETTER(ElementFormControl,name) - LUASETTER(ElementFormControl,value) + RMLUI_LUASETTER(ElementFormControl,disabled) + RMLUI_LUASETTER(ElementFormControl,name) + RMLUI_LUASETTER(ElementFormControl,value) { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) + +template<> void ExtraInit(lua_State* L, int metatable_index) { ExtraInit(L,metatable_index); LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementFormControl; -LUACONTROLSTYPEDEFINE(ElementFormControl) -} -} + AddTypeToElementAsTable(L); } +RMLUI_LUATYPE_DEFINE(ElementFormControl) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementFormControl.h b/Source/Lua/Elements/ElementFormControl.h similarity index 76% rename from Source/Controls/Lua/ElementFormControl.h rename to Source/Lua/Elements/ElementFormControl.h index 03eaca059..06d7a9b18 100644 --- a/Source/Controls/Lua/ElementFormControl.h +++ b/Source/Lua/Elements/ElementFormControl.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORMCONTROL_H -#define RMLUICONTROLSLUAELEMENTFORMCONTROL_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROL_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROL_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //getters @@ -48,16 +46,14 @@ int ElementFormControlSetAttrdisabled(lua_State* L); int ElementFormControlSetAttrname(lua_State* L); int ElementFormControlSetAttrvalue(lua_State* L); -extern Rml::Core::Lua::RegType ElementFormControlMethods[]; +extern RegType ElementFormControlMethods[]; extern luaL_Reg ElementFormControlGetters[]; extern luaL_Reg ElementFormControlSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementFormControl) -}}} -#endif +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementFormControl) +} // namespace Lua +} // namespace Rml + +#endif diff --git a/Source/Controls/Lua/ElementFormControlDataSelect.cpp b/Source/Lua/Elements/ElementFormControlDataSelect.cpp similarity index 71% rename from Source/Controls/Lua/ElementFormControlDataSelect.cpp rename to Source/Lua/Elements/ElementFormControlDataSelect.cpp index 02ca136d9..8d7cd6926 100644 --- a/Source/Controls/Lua/ElementFormControlDataSelect.cpp +++ b/Source/Lua/Elements/ElementFormControlDataSelect.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "ElementFormControlDataSelect.h" -#include +#include #include "ElementFormControlSelect.h" -#include +#include namespace Rml { -namespace Controls { namespace Lua { //method @@ -44,9 +42,9 @@ int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDa return 0; } -Rml::Core::Lua::RegType ElementFormControlDataSelectMethods[] = +RegType ElementFormControlDataSelectMethods[] = { - LUAMETHOD(ElementFormControlDataSelect,SetDataSource) + RMLUI_LUAMETHOD(ElementFormControlDataSelect,SetDataSource) { nullptr, nullptr }, }; @@ -60,24 +58,17 @@ luaL_Reg ElementFormControlDataSelectSetters[] = { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { //do whatever ElementFormControlSelect did as far as inheritance - ExtraInit(L,metatable_index); + ExtraInit(L,metatable_index); //then inherit from ElementFromControlSelect - LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); + LuaType::_regfunctions(L,metatable_index,metatable_index-1); + AddTypeToElementAsTable(L); } -using Rml::Controls::ElementFormControlDataSelect; -LUACONTROLSTYPEDEFINE(ElementFormControlDataSelect) -} -} -} +RMLUI_LUATYPE_DEFINE(ElementFormControlDataSelect) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementFormControlDataSelect.h b/Source/Lua/Elements/ElementFormControlDataSelect.h similarity index 72% rename from Source/Controls/Lua/ElementFormControlDataSelect.h rename to Source/Lua/Elements/ElementFormControlDataSelect.h index 400f10d69..1d1efefc7 100644 --- a/Source/Controls/Lua/ElementFormControlDataSelect.h +++ b/Source/Lua/Elements/ElementFormControlDataSelect.h @@ -26,31 +26,28 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORMCONTROLDATASELECT_H -#define RMLUICONTROLSLUAELEMENTFORMCONTROLDATASELECT_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLDATASELECT_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLDATASELECT_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //method int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj); -extern Rml::Core::Lua::RegType ElementFormControlDataSelectMethods[]; +extern RegType ElementFormControlDataSelectMethods[]; extern luaL_Reg ElementFormControlDataSelectGetters[]; extern luaL_Reg ElementFormControlDataSelectSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementFormControlDataSelect) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementFormControlDataSelect) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementFormControlInput.cpp b/Source/Lua/Elements/ElementFormControlInput.cpp similarity index 73% rename from Source/Controls/Lua/ElementFormControlInput.cpp rename to Source/Lua/Elements/ElementFormControlInput.cpp index 411f76302..7c40cc3c7 100644 --- a/Source/Controls/Lua/ElementFormControlInput.cpp +++ b/Source/Lua/Elements/ElementFormControlInput.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "ElementFormControlInput.h" -#include +#include #include "ElementFormControl.h" -#include +#include namespace Rml { -namespace Controls { namespace Lua { @@ -41,7 +39,7 @@ namespace Lua { int ElementFormControlInputGetAttrchecked(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushboolean(L,obj->HasAttribute("checked")); return 1; } @@ -49,7 +47,7 @@ int ElementFormControlInputGetAttrchecked(lua_State* L) int ElementFormControlInputGetAttrmaxlength(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetAttribute("maxlength",-1)); return 1; } @@ -57,7 +55,7 @@ int ElementFormControlInputGetAttrmaxlength(lua_State* L) int ElementFormControlInputGetAttrsize(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetAttribute("size",20)); return 1; } @@ -65,7 +63,7 @@ int ElementFormControlInputGetAttrsize(lua_State* L) int ElementFormControlInputGetAttrmax(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetAttribute("max",100)); return 1; } @@ -73,7 +71,7 @@ int ElementFormControlInputGetAttrmax(lua_State* L) int ElementFormControlInputGetAttrmin(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetAttribute("min",0)); return 1; } @@ -81,7 +79,7 @@ int ElementFormControlInputGetAttrmin(lua_State* L) int ElementFormControlInputGetAttrstep(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetAttribute("step",1)); return 1; } @@ -91,8 +89,8 @@ int ElementFormControlInputGetAttrstep(lua_State* L) int ElementFormControlInputSetAttrchecked(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); - bool checked = CHECK_BOOL(L,2); + RMLUI_CHECK_OBJ(obj); + bool checked = RMLUI_CHECK_BOOL(L,2); if(checked) obj->SetAttribute("checked",true); else @@ -103,7 +101,7 @@ int ElementFormControlInputSetAttrchecked(lua_State* L) int ElementFormControlInputSetAttrmaxlength(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int maxlength = (int)luaL_checkinteger(L,2); obj->SetAttribute("maxlength",maxlength); return 0; @@ -112,7 +110,7 @@ int ElementFormControlInputSetAttrmaxlength(lua_State* L) int ElementFormControlInputSetAttrsize(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int size = (int)luaL_checkinteger(L,2); obj->SetAttribute("size",size); return 0; @@ -121,7 +119,7 @@ int ElementFormControlInputSetAttrsize(lua_State* L) int ElementFormControlInputSetAttrmax(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int max = (int)luaL_checkinteger(L,2); obj->SetAttribute("max",max); return 0; @@ -130,7 +128,7 @@ int ElementFormControlInputSetAttrmax(lua_State* L) int ElementFormControlInputSetAttrmin(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int min = (int)luaL_checkinteger(L,2); obj->SetAttribute("min",min); return 0; @@ -139,54 +137,47 @@ int ElementFormControlInputSetAttrmin(lua_State* L) int ElementFormControlInputSetAttrstep(lua_State* L) { ElementFormControlInput* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int step = (int)luaL_checkinteger(L,2); obj->SetAttribute("step",step); return 0; } -Rml::Core::Lua::RegType ElementFormControlInputMethods[] = +RegType ElementFormControlInputMethods[] = { {nullptr,nullptr}, }; luaL_Reg ElementFormControlInputGetters[] = { - LUAGETTER(ElementFormControlInput,checked) - LUAGETTER(ElementFormControlInput,maxlength) - LUAGETTER(ElementFormControlInput,size) - LUAGETTER(ElementFormControlInput,max) - LUAGETTER(ElementFormControlInput,min) - LUAGETTER(ElementFormControlInput,step) + RMLUI_LUAGETTER(ElementFormControlInput,checked) + RMLUI_LUAGETTER(ElementFormControlInput,maxlength) + RMLUI_LUAGETTER(ElementFormControlInput,size) + RMLUI_LUAGETTER(ElementFormControlInput,max) + RMLUI_LUAGETTER(ElementFormControlInput,min) + RMLUI_LUAGETTER(ElementFormControlInput,step) {nullptr,nullptr}, }; luaL_Reg ElementFormControlInputSetters[] = { - LUASETTER(ElementFormControlInput,checked) - LUASETTER(ElementFormControlInput,maxlength) - LUASETTER(ElementFormControlInput,size) - LUASETTER(ElementFormControlInput,max) - LUASETTER(ElementFormControlInput,min) - LUASETTER(ElementFormControlInput,step) + RMLUI_LUASETTER(ElementFormControlInput,checked) + RMLUI_LUASETTER(ElementFormControlInput,maxlength) + RMLUI_LUASETTER(ElementFormControlInput,size) + RMLUI_LUASETTER(ElementFormControlInput,max) + RMLUI_LUASETTER(ElementFormControlInput,min) + RMLUI_LUASETTER(ElementFormControlInput,step) {nullptr,nullptr}, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) + +template<> void ExtraInit(lua_State* L, int metatable_index) { - ExtraInit(L,metatable_index); - LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementFormControlInput; -LUACONTROLSTYPEDEFINE(ElementFormControlInput) -} + ExtraInit(L,metatable_index); + LuaType::_regfunctions(L,metatable_index,metatable_index-1); + AddTypeToElementAsTable(L); } -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementFormControlInput) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementFormControlInput.h b/Source/Lua/Elements/ElementFormControlInput.h similarity index 79% rename from Source/Controls/Lua/ElementFormControlInput.h rename to Source/Lua/Elements/ElementFormControlInput.h index ce38a302e..95699ee20 100644 --- a/Source/Controls/Lua/ElementFormControlInput.h +++ b/Source/Lua/Elements/ElementFormControlInput.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORMCONTROLINPUT_H -#define RMLUICONTROLSLUAELEMENTFORMCONTROLINPUT_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLINPUT_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLINPUT_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //getters @@ -54,16 +52,15 @@ int ElementFormControlInputSetAttrmax(lua_State* L); int ElementFormControlInputSetAttrmin(lua_State* L); int ElementFormControlInputSetAttrstep(lua_State* L); -extern Rml::Core::Lua::RegType ElementFormControlInputMethods[]; +extern RegType ElementFormControlInputMethods[]; extern luaL_Reg ElementFormControlInputGetters[]; extern luaL_Reg ElementFormControlInputSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementFormControlInput) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementFormControlInput) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementFormControlSelect.cpp b/Source/Lua/Elements/ElementFormControlSelect.cpp similarity index 74% rename from Source/Controls/Lua/ElementFormControlSelect.cpp rename to Source/Lua/Elements/ElementFormControlSelect.cpp index 62698fea3..90a8a0b5a 100644 --- a/Source/Controls/Lua/ElementFormControlSelect.cpp +++ b/Source/Lua/Elements/ElementFormControlSelect.cpp @@ -26,18 +26,16 @@ * */ -#include "precompiled.h" #include "ElementFormControlSelect.h" #include "SelectOptionsProxy.h" -#include -#include +#include +#include #include #include "ElementFormControl.h" -#include +#include namespace Rml { -namespace Controls { namespace Lua { //methods @@ -71,7 +69,7 @@ int ElementFormControlSelectRemoveAll(lua_State* /*L*/, ElementFormControlSelect int ElementFormControlSelectGetAttroptions(lua_State* L) { ElementFormControlSelect* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); SelectOptionsProxy* proxy = new SelectOptionsProxy(); proxy->owner = obj; LuaType::push(L,proxy,true); @@ -81,7 +79,7 @@ int ElementFormControlSelectGetAttroptions(lua_State* L) int ElementFormControlSelectGetAttrselection(lua_State* L) { ElementFormControlSelect* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int selection = obj->GetSelection(); lua_pushinteger(L,selection); return 1; @@ -92,51 +90,44 @@ int ElementFormControlSelectGetAttrselection(lua_State* L) int ElementFormControlSelectSetAttrselection(lua_State* L) { ElementFormControlSelect* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int selection = (int)luaL_checkinteger(L,2); obj->SetSelection(selection); return 0; } -Rml::Core::Lua::RegType ElementFormControlSelectMethods[] = +RegType ElementFormControlSelectMethods[] = { - LUAMETHOD(ElementFormControlSelect,Add) - LUAMETHOD(ElementFormControlSelect,Remove) - LUAMETHOD(ElementFormControlSelect,RemoveAll) + RMLUI_LUAMETHOD(ElementFormControlSelect,Add) + RMLUI_LUAMETHOD(ElementFormControlSelect,Remove) + RMLUI_LUAMETHOD(ElementFormControlSelect,RemoveAll) { nullptr, nullptr }, }; luaL_Reg ElementFormControlSelectGetters[] = { - LUAGETTER(ElementFormControlSelect,options) - LUAGETTER(ElementFormControlSelect,selection) + RMLUI_LUAGETTER(ElementFormControlSelect,options) + RMLUI_LUAGETTER(ElementFormControlSelect,selection) { nullptr, nullptr }, }; luaL_Reg ElementFormControlSelectSetters[] = { - LUASETTER(ElementFormControlSelect,selection) + RMLUI_LUASETTER(ElementFormControlSelect,selection) { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { //init whatever elementformcontrol did extra, like inheritance - ExtraInit(L,metatable_index); + ExtraInit(L,metatable_index); //then inherit from elementformcontrol - LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); -} -using Rml::Controls::ElementFormControlSelect; -LUACONTROLSTYPEDEFINE(ElementFormControlSelect) -} + LuaType::_regfunctions(L,metatable_index,metatable_index-1); + AddTypeToElementAsTable(L); } -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementFormControlSelect) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementFormControlSelect.h b/Source/Lua/Elements/ElementFormControlSelect.h similarity index 76% rename from Source/Controls/Lua/ElementFormControlSelect.h rename to Source/Lua/Elements/ElementFormControlSelect.h index 95d78c244..d4e0c48ad 100644 --- a/Source/Controls/Lua/ElementFormControlSelect.h +++ b/Source/Lua/Elements/ElementFormControlSelect.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORMCONTROLSELECT_H -#define RMLUICONTROLSLUAELEMENTFORMCONTROLSELECT_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLSELECT_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLSELECT_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //methods @@ -49,16 +47,15 @@ int ElementFormControlSelectGetAttrselection(lua_State* L); //setter int ElementFormControlSelectSetAttrselection(lua_State* L); -extern Rml::Core::Lua::RegType ElementFormControlSelectMethods[]; +extern RegType ElementFormControlSelectMethods[]; extern luaL_Reg ElementFormControlSelectGetters[]; extern luaL_Reg ElementFormControlSelectSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementFormControlSelect) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementFormControlSelect) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementFormControlTextArea.cpp b/Source/Lua/Elements/ElementFormControlTextArea.cpp similarity index 71% rename from Source/Controls/Lua/ElementFormControlTextArea.cpp rename to Source/Lua/Elements/ElementFormControlTextArea.cpp index efb2a9b18..74accbbdb 100644 --- a/Source/Controls/Lua/ElementFormControlTextArea.cpp +++ b/Source/Lua/Elements/ElementFormControlTextArea.cpp @@ -26,21 +26,19 @@ * */ -#include "precompiled.h" #include "ElementFormControlTextArea.h" -#include +#include #include "ElementFormControl.h" -#include +#include namespace Rml { -namespace Controls { namespace Lua { //getters int ElementFormControlTextAreaGetAttrcols(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetNumColumns()); return 1; } @@ -48,7 +46,7 @@ int ElementFormControlTextAreaGetAttrcols(lua_State* L) int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetMaxLength()); return 1; } @@ -56,7 +54,7 @@ int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L) int ElementFormControlTextAreaGetAttrrows(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushinteger(L,obj->GetNumRows()); return 1; } @@ -64,7 +62,7 @@ int ElementFormControlTextAreaGetAttrrows(lua_State* L) int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); lua_pushboolean(L,obj->GetWordWrap()); return 1; } @@ -74,7 +72,7 @@ int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L) int ElementFormControlTextAreaSetAttrcols(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int cols = (int)luaL_checkinteger(L,2); obj->SetNumColumns(cols); return 0; @@ -83,7 +81,7 @@ int ElementFormControlTextAreaSetAttrcols(lua_State* L) int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int ml = (int)luaL_checkinteger(L,2); obj->SetMaxLength(ml); return 0; @@ -92,7 +90,7 @@ int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L) int ElementFormControlTextAreaSetAttrrows(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int rows = (int)luaL_checkinteger(L,2); obj->SetNumRows(rows); return 0; @@ -101,51 +99,44 @@ int ElementFormControlTextAreaSetAttrrows(lua_State* L) int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L) { ElementFormControlTextArea* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); - bool ww = CHECK_BOOL(L,2); + RMLUI_CHECK_OBJ(obj); + bool ww = RMLUI_CHECK_BOOL(L,2); obj->SetWordWrap(ww); return 0; } -Rml::Core::Lua::RegType ElementFormControlTextAreaMethods[] = +RegType ElementFormControlTextAreaMethods[] = { { nullptr, nullptr }, }; luaL_Reg ElementFormControlTextAreaGetters[] = { - LUAGETTER(ElementFormControlTextArea,cols) - LUAGETTER(ElementFormControlTextArea,maxlength) - LUAGETTER(ElementFormControlTextArea,rows) - LUAGETTER(ElementFormControlTextArea,wordwrap) + RMLUI_LUAGETTER(ElementFormControlTextArea,cols) + RMLUI_LUAGETTER(ElementFormControlTextArea,maxlength) + RMLUI_LUAGETTER(ElementFormControlTextArea,rows) + RMLUI_LUAGETTER(ElementFormControlTextArea,wordwrap) { nullptr, nullptr }, }; luaL_Reg ElementFormControlTextAreaSetters[] = { - LUASETTER(ElementFormControlTextArea,cols) - LUASETTER(ElementFormControlTextArea,maxlength) - LUASETTER(ElementFormControlTextArea,rows) - LUASETTER(ElementFormControlTextArea,wordwrap) + RMLUI_LUASETTER(ElementFormControlTextArea,cols) + RMLUI_LUASETTER(ElementFormControlTextArea,maxlength) + RMLUI_LUASETTER(ElementFormControlTextArea,rows) + RMLUI_LUASETTER(ElementFormControlTextArea,wordwrap) { nullptr, nullptr }, }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) + +template<> void ExtraInit(lua_State* L, int metatable_index) { - ExtraInit(L,metatable_index); - LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); + ExtraInit(L,metatable_index); + LuaType::_regfunctions(L,metatable_index,metatable_index-1); + AddTypeToElementAsTable(L); } -using Rml::Controls::ElementFormControlTextArea; -LUACONTROLSTYPEDEFINE(ElementFormControlTextArea) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementFormControlTextArea) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementFormControlTextArea.h b/Source/Lua/Elements/ElementFormControlTextArea.h similarity index 77% rename from Source/Controls/Lua/ElementFormControlTextArea.h rename to Source/Lua/Elements/ElementFormControlTextArea.h index 26484e1e9..08e97259c 100644 --- a/Source/Controls/Lua/ElementFormControlTextArea.h +++ b/Source/Lua/Elements/ElementFormControlTextArea.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTFORMCONTROLTEXTAREA_H -#define RMLUICONTROLSLUAELEMENTFORMCONTROLTEXTAREA_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLTEXTAREA_H +#define RMLUI_LUA_ELEMENTS_ELEMENTFORMCONTROLTEXTAREA_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //getters @@ -50,16 +48,15 @@ int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L); int ElementFormControlTextAreaSetAttrrows(lua_State* L); int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L); -extern Rml::Core::Lua::RegType ElementFormControlTextAreaMethods[]; +extern RegType ElementFormControlTextAreaMethods[]; extern luaL_Reg ElementFormControlTextAreaGetters[]; extern luaL_Reg ElementFormControlTextAreaSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { + //inherits from ElementFormControl which inherits from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementFormControlTextArea) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementFormControlTextArea) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/ElementTabSet.cpp b/Source/Lua/Elements/ElementTabSet.cpp similarity index 79% rename from Source/Controls/Lua/ElementTabSet.cpp rename to Source/Lua/Elements/ElementTabSet.cpp index abccece6f..b4f5a903f 100644 --- a/Source/Controls/Lua/ElementTabSet.cpp +++ b/Source/Lua/Elements/ElementTabSet.cpp @@ -26,20 +26,18 @@ * */ -#include "precompiled.h" #include "ElementTabSet.h" #include -#include +#include namespace Rml { -namespace Controls { namespace Lua { //methods int ElementTabSetSetPanel(lua_State* L, ElementTabSet* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int index = (int)luaL_checkinteger(L,1); const char* rml = luaL_checkstring(L,2); @@ -49,7 +47,7 @@ int ElementTabSetSetPanel(lua_State* L, ElementTabSet* obj) int ElementTabSetSetTab(lua_State* L, ElementTabSet* obj) { - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int index = (int)luaL_checkinteger(L,1); const char* rml = luaL_checkstring(L,2); @@ -62,7 +60,7 @@ int ElementTabSetSetTab(lua_State* L, ElementTabSet* obj) int ElementTabSetGetAttractive_tab(lua_State* L) { ElementTabSet* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int tab = obj->GetActiveTab(); lua_pushinteger(L,tab); return 1; @@ -71,7 +69,7 @@ int ElementTabSetGetAttractive_tab(lua_State* L) int ElementTabSetGetAttrnum_tabs(lua_State* L) { ElementTabSet* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int num = obj->GetNumTabs(); lua_pushinteger(L,num); return 1; @@ -82,51 +80,42 @@ int ElementTabSetGetAttrnum_tabs(lua_State* L) int ElementTabSetSetAttractive_tab(lua_State* L) { ElementTabSet* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int tab = (int)luaL_checkinteger(L,2); obj->SetActiveTab(tab); return 0; } -Rml::Core::Lua::RegType ElementTabSetMethods[] = +RegType ElementTabSetMethods[] = { - LUAMETHOD(ElementTabSet,SetPanel) - LUAMETHOD(ElementTabSet,SetTab) + RMLUI_LUAMETHOD(ElementTabSet,SetPanel) + RMLUI_LUAMETHOD(ElementTabSet,SetTab) { nullptr, nullptr }, }; luaL_Reg ElementTabSetGetters[] = { - LUAGETTER(ElementTabSet,active_tab) - LUAGETTER(ElementTabSet,num_tabs) + RMLUI_LUAGETTER(ElementTabSet,active_tab) + RMLUI_LUAGETTER(ElementTabSet,num_tabs) { nullptr, nullptr }, }; luaL_Reg ElementTabSetSetters[] = { - LUASETTER(ElementTabSet,active_tab) + RMLUI_LUASETTER(ElementTabSet,active_tab) { nullptr, nullptr }, }; - -} -} -} -namespace Rml { -namespace Core { -namespace Lua { //this will be used to "inherit" from Element -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { ExtraInit(L,metatable_index); LuaType::_regfunctions(L,metatable_index,metatable_index-1); - AddTypeToElementAsTable(L); + AddTypeToElementAsTable(L); } -using Rml::Controls::ElementTabSet; -LUACONTROLSTYPEDEFINE(ElementTabSet) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(ElementTabSet) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/ElementTabSet.h b/Source/Lua/Elements/ElementTabSet.h similarity index 77% rename from Source/Controls/Lua/ElementTabSet.h rename to Source/Lua/Elements/ElementTabSet.h index f58727cc8..15119547e 100644 --- a/Source/Controls/Lua/ElementTabSet.h +++ b/Source/Lua/Elements/ElementTabSet.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICONTROLSLUAELEMENTTABSET_H -#define RMLUICONTROLSLUAELEMENTTABSET_H +#ifndef RMLUI_LUA_ELEMENTS_ELEMENTTABSET_H +#define RMLUI_LUA_ELEMENTS_ELEMENTTABSET_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //methods @@ -49,17 +47,15 @@ int ElementTabSetGetAttrnum_tabs(lua_State* L); //setter int ElementTabSetSetAttractive_tab(lua_State* L); -extern Rml::Core::Lua::RegType ElementTabSetMethods[]; +extern RegType ElementTabSetMethods[]; extern luaL_Reg ElementTabSetGetters[]; extern luaL_Reg ElementTabSetSetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { //this will be used to "inherit" from Element -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::ElementTabSet) -}}} +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(ElementTabSet) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Controls/Lua/LuaDataFormatter.cpp b/Source/Lua/Elements/LuaDataFormatter.cpp similarity index 87% rename from Source/Controls/Lua/LuaDataFormatter.cpp rename to Source/Lua/Elements/LuaDataFormatter.cpp index 9d5890299..05676cd8d 100644 --- a/Source/Controls/Lua/LuaDataFormatter.cpp +++ b/Source/Lua/Elements/LuaDataFormatter.cpp @@ -26,28 +26,21 @@ * */ -#include "precompiled.h" #include "LuaDataFormatter.h" -#include +#include #include -using Rml::Core::Lua::Interpreter; -using Rml::Core::Log; namespace Rml { -namespace Controls { namespace Lua { -LuaDataFormatter::LuaDataFormatter(const Rml::Core::String& name) : Rml::Controls::DataFormatter(name), ref_FormatData(LUA_NOREF) -{ - -} + +LuaDataFormatter::LuaDataFormatter(const String& name) : DataFormatter(name), ref_FormatData(LUA_NOREF) +{} LuaDataFormatter::~LuaDataFormatter() -{ - //empty -} +{} -void LuaDataFormatter::FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) +void LuaDataFormatter::FormatData(String& formatted_data, const StringList& raw_data) { if(ref_FormatData == LUA_NOREF || ref_FormatData == LUA_REFNIL) { @@ -80,7 +73,7 @@ void LuaDataFormatter::FormatData(Rml::Core::String& formatted_data, const Rml:: lua_settop(L,top); return; } - formatted_data = Rml::Core::String(lua_tostring(L,-1)); + formatted_data = String(lua_tostring(L,-1)); lua_settop(L,top); } @@ -96,6 +89,5 @@ void LuaDataFormatter::PushDataFormatterFunctionTable(lua_State* L) } } -} -} -} +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/LuaDataFormatter.h b/Source/Lua/Elements/LuaDataFormatter.h similarity index 80% rename from Source/Controls/Lua/LuaDataFormatter.h rename to Source/Lua/Elements/LuaDataFormatter.h index fe95e415f..c416d7dd2 100644 --- a/Source/Controls/Lua/LuaDataFormatter.h +++ b/Source/Lua/Elements/LuaDataFormatter.h @@ -26,23 +26,22 @@ * */ -#ifndef RMLUICONTROLSLUALUADATAFORMATTER_H -#define RMLUICONTROLSLUALUADATAFORMATTER_H +#ifndef RMLUI_LUA_ELEMENTS_LUADATAFORMATTER_H +#define RMLUI_LUA_ELEMENTS_LUADATAFORMATTER_H -#include -#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { -class LuaDataFormatter : public Rml::Controls::DataFormatter +class LuaDataFormatter : public ::Rml::DataFormatter { public: - LuaDataFormatter(const Rml::Core::String& name = ""); + LuaDataFormatter(const String& name = ""); ~LuaDataFormatter(); - void FormatData(Rml::Core::String& formatted_data, const Rml::Core::StringList& raw_data) override; + void FormatData(String& formatted_data, const StringList& raw_data) override; //Helper function used to push on to the stack the table where the function ref should be stored static void PushDataFormatterFunctionTable(lua_State* L); @@ -50,7 +49,6 @@ class LuaDataFormatter : public Rml::Controls::DataFormatter int ref_FormatData; //the lua reference to the FormatData function }; -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Controls/Lua/LuaDataSource.cpp b/Source/Lua/Elements/LuaDataSource.cpp similarity index 85% rename from Source/Controls/Lua/LuaDataSource.cpp rename to Source/Lua/Elements/LuaDataSource.cpp index 846afb268..06d43ac43 100644 --- a/Source/Controls/Lua/LuaDataSource.cpp +++ b/Source/Lua/Elements/LuaDataSource.cpp @@ -26,28 +26,22 @@ * */ -#include "precompiled.h" #include "LuaDataSource.h" -#include +#include #include -using Rml::Core::Lua::Interpreter; -using Rml::Core::Log; -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { -LuaDataSource::LuaDataSource(const Rml::Core::String& name) : DataSource(name), getRowRef(LUA_NOREF), getNumRowsRef(LUA_NOREF) -{ -} +LuaDataSource::LuaDataSource(const String& name) : DataSource(name), getRowRef(LUA_NOREF), getNumRowsRef(LUA_NOREF) +{} /// Fetches the contents of one row of a table within the data source. /// @param[out] row The list of values in the table. /// @param[in] table The name of the table to query. /// @param[in] row_index The index of the desired row. /// @param[in] columns The list of desired columns within the row. -void LuaDataSource::GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) +void LuaDataSource::GetRow(StringList& row, const String& table, int row_index, const StringList& columns) { if(getRowRef == LUA_NOREF || getRowRef == LUA_REFNIL) return; @@ -58,7 +52,7 @@ void LuaDataSource::GetRow(Rml::Core::StringList& row, const Rml::Core::String& lua_pushinteger(L,row_index); lua_newtable(L); int index = 0; - for(Rml::Core::StringList::const_iterator itr = columns.begin(); itr != columns.end(); ++itr) + for(StringList::const_iterator itr = columns.begin(); itr != columns.end(); ++itr) { lua_pushstring(L,itr->c_str()); lua_rawseti(L,-2,index++); @@ -86,7 +80,7 @@ void LuaDataSource::GetRow(Rml::Core::StringList& row, const Rml::Core::String& /// Fetches the number of rows within one of this data source's tables. /// @param[in] table The name of the table to query. /// @return The number of rows within the specified table. Returns -1 in case of an incorrect Lua function. -int LuaDataSource::GetNumRows(const Rml::Core::String& table) +int LuaDataSource::GetNumRows(const String& table) { if(getNumRowsRef == LUA_NOREF || getNumRowsRef == LUA_REFNIL) return -1; @@ -108,6 +102,5 @@ int LuaDataSource::GetNumRows(const Rml::Core::String& table) } -} -} -} +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/LuaDataSource.h b/Source/Lua/Elements/LuaDataSource.h similarity index 77% rename from Source/Controls/Lua/LuaDataSource.h rename to Source/Lua/Elements/LuaDataSource.h index 5746a903e..7edef0707 100644 --- a/Source/Controls/Lua/LuaDataSource.h +++ b/Source/Lua/Elements/LuaDataSource.h @@ -26,38 +26,37 @@ * */ -#ifndef RMLUICONTROLSLUALUADATASOURCE_H -#define RMLUICONTROLSLUALUADATASOURCE_H +#ifndef RMLUI_LUA_ELEMENTS_LUADATASOURCE_H +#define RMLUI_LUA_ELEMENTS_LUADATASOURCE_H -#include -#include -#include +#include +#include +#include namespace Rml { -namespace Controls { namespace Lua { -class LuaDataSource : public Rml::Controls::DataSource +class LuaDataSource : public ::Rml::DataSource { public: //default initilialize the lua func references to -1 - LuaDataSource(const Rml::Core::String& name = ""); + LuaDataSource(const String& name = ""); /// Fetches the contents of one row of a table within the data source. /// @param[out] row The list of values in the table. /// @param[in] table The name of the table to query. /// @param[in] row_index The index of the desired row. /// @param[in] columns The list of desired columns within the row. - void GetRow(Rml::Core::StringList& row, const Rml::Core::String& table, int row_index, const Rml::Core::StringList& columns) override; + void GetRow(StringList& row, const String& table, int row_index, const StringList& columns) override; /// Fetches the number of rows within one of this data source's tables. /// @param[in] table The name of the table to query. /// @return The number of rows within the specified table. Returns -1 in case of an incorrect Lua function. - int GetNumRows(const Rml::Core::String& table) override; + int GetNumRows(const String& table) override; //make the protected members of DataSource public - using DataSource::NotifyRowAdd; - using DataSource::NotifyRowRemove; - using DataSource::NotifyRowChange; + using DataSource::NotifyRowAdd; + using DataSource::NotifyRowRemove; + using DataSource::NotifyRowChange; //lua reference to DataSource.GetRow int getRowRef; @@ -65,7 +64,6 @@ class LuaDataSource : public Rml::Controls::DataSource int getNumRowsRef; }; -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Controls/Lua/SelectOptionsProxy.cpp b/Source/Lua/Elements/SelectOptionsProxy.cpp similarity index 79% rename from Source/Controls/Lua/SelectOptionsProxy.cpp rename to Source/Lua/Elements/SelectOptionsProxy.cpp index 4a199f190..df84937fe 100644 --- a/Source/Controls/Lua/SelectOptionsProxy.cpp +++ b/Source/Lua/Elements/SelectOptionsProxy.cpp @@ -26,13 +26,11 @@ * */ -#include "precompiled.h" #include "SelectOptionsProxy.h" #include namespace Rml { -namespace Controls { namespace Lua { @@ -43,12 +41,12 @@ int SelectOptionsProxy__index(lua_State* L) if(keytype == LUA_TNUMBER) //only valid key types { SelectOptionsProxy* proxy = LuaType::check(L,1); - LUACHECKOBJ(proxy); + RMLUI_CHECK_OBJ(proxy); int index = (int)luaL_checkinteger(L,2); - Rml::Controls::SelectOption* opt = proxy->owner->GetOption(index); - LUACHECKOBJ(opt); + SelectOption* opt = proxy->owner->GetOption(index); + RMLUI_CHECK_OBJ(opt); lua_newtable(L); - LuaType::push(L,opt->GetElement(),false); + LuaType::push(L,opt->GetElement(),false); lua_setfield(L,-2,"element"); lua_pushstring(L,opt->GetValue().c_str()); lua_setfield(L,-2,"value"); @@ -68,7 +66,7 @@ int SelectOptionsProxy__pairs(lua_State* L) int SelectOptionsProxy__ipairs(lua_State* L) { SelectOptionsProxy* proxy = LuaType::check(L,1); - LUACHECKOBJ(proxy); + RMLUI_CHECK_OBJ(proxy); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) *pindex = 0; @@ -90,7 +88,7 @@ int SelectOptionsProxy__ipairs(lua_State* L) lua_pushinteger(L,(*pindex)-1); //key lua_newtable(L); //value //fill the value - LuaType::push(L,opt->GetElement()); + LuaType::push(L,opt->GetElement()); lua_setfield(L,-2,"element"); lua_pushstring(L,opt->GetValue().c_str()); lua_setfield(L,-2,"value"); @@ -98,7 +96,7 @@ int SelectOptionsProxy__ipairs(lua_State* L) return 2; } -Rml::Core::Lua::RegType SelectOptionsProxyMethods[] = +RegType SelectOptionsProxyMethods[] = { { nullptr, nullptr }, }; @@ -114,24 +112,16 @@ luaL_Reg SelectOptionsProxySetters[] = }; -} -} -} -namespace Rml { -namespace Core { -namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index) +template<> void ExtraInit(lua_State* L, int metatable_index) { - lua_pushcfunction(L,Rml::Controls::Lua::SelectOptionsProxy__index); + lua_pushcfunction(L,SelectOptionsProxy__index); lua_setfield(L,metatable_index,"__index"); - lua_pushcfunction(L,Rml::Controls::Lua::SelectOptionsProxy__pairs); + lua_pushcfunction(L,SelectOptionsProxy__pairs); lua_setfield(L,metatable_index,"__pairs"); - lua_pushcfunction(L,Rml::Controls::Lua::SelectOptionsProxy__ipairs); + lua_pushcfunction(L,SelectOptionsProxy__ipairs); lua_setfield(L,metatable_index,"__ipairs"); } -using Rml::Controls::Lua::SelectOptionsProxy; -LUACONTROLSTYPEDEFINE(SelectOptionsProxy) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(SelectOptionsProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Controls/Lua/SelectOptionsProxy.h b/Source/Lua/Elements/SelectOptionsProxy.h similarity index 72% rename from Source/Controls/Lua/SelectOptionsProxy.h rename to Source/Lua/Elements/SelectOptionsProxy.h index f1c89837f..4e7d3731b 100644 --- a/Source/Controls/Lua/SelectOptionsProxy.h +++ b/Source/Lua/Elements/SelectOptionsProxy.h @@ -26,33 +26,30 @@ * */ -#ifndef RMLUICONTROLSLUASELECTOPTIONSPROXY_H -#define RMLUICONTROLSLUASELECTOPTIONSPROXY_H +#ifndef RMLUI_LUA_ELEMENTS_SELECTOPTIONSPROXY_H +#define RMLUI_LUA_ELEMENTS_SELECTOPTIONSPROXY_H -#include -#include -#include +#include +#include +#include -using Rml::Core::Lua::LuaType; namespace Rml { -namespace Controls { namespace Lua { //where owner is the ElementFormControlSelect that we should look up information from -struct SelectOptionsProxy { Rml::Controls::ElementFormControlSelect* owner; }; +struct SelectOptionsProxy { ElementFormControlSelect* owner; }; int SelectOptionsProxy__index(lua_State* L); int SelectOptionsProxy__pairs(lua_State* L); int SelectOptionsProxy__ipairs(lua_State* L); -extern Rml::Core::Lua::RegType SelectOptionsProxyMethods[]; +extern RegType SelectOptionsProxyMethods[]; extern luaL_Reg SelectOptionsProxyGetters[]; extern luaL_Reg SelectOptionsProxySetters[]; -} -} -} -namespace Rml { namespace Core { namespace Lua { -template<> void ExtraInit(lua_State* L, int metatable_index); -LUACONTROLSTYPEDECLARE(Rml::Controls::Lua::SelectOptionsProxy) -}}} + +template<> void ExtraInit(lua_State* L, int metatable_index); +RMLUI_LUATYPE_DECLARE(SelectOptionsProxy) +} // namespace Lua +} // namespace Rml + #endif diff --git a/Source/Core/Lua/Event.cpp b/Source/Lua/Event.cpp similarity index 86% rename from Source/Core/Lua/Event.cpp rename to Source/Lua/Event.cpp index b94d2983d..762ea13e1 100644 --- a/Source/Core/Lua/Event.cpp +++ b/Source/Lua/Event.cpp @@ -26,9 +26,8 @@ * */ -#include "precompiled.h" -#include -#include +#include +#include #include #include #include @@ -36,7 +35,6 @@ namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* /*L*/, int /*metatable_index*/) { return; } @@ -51,7 +49,7 @@ int EventStopPropagation(lua_State* /*L*/, Event* obj) int EventGetAttrcurrent_element(lua_State* L) { Event* evt = LuaType::check(L,1); - LUACHECKOBJ(evt); + RMLUI_CHECK_OBJ(evt); Element* ele = evt->GetCurrentElement(); LuaType::push(L,ele,false); return 1; @@ -60,7 +58,7 @@ int EventGetAttrcurrent_element(lua_State* L) int EventGetAttrtype(lua_State* L) { Event* evt = LuaType::check(L,1); - LUACHECKOBJ(evt); + RMLUI_CHECK_OBJ(evt); String type = evt->GetType(); lua_pushstring(L,type.c_str()); return 1; @@ -69,7 +67,7 @@ int EventGetAttrtype(lua_State* L) int EventGetAttrtarget_element(lua_State* L) { Event* evt = LuaType::check(L,1); - LUACHECKOBJ(evt); + RMLUI_CHECK_OBJ(evt); Element* target = evt->GetTargetElement(); LuaType::push(L,target,false); return 1; @@ -78,7 +76,7 @@ int EventGetAttrtarget_element(lua_State* L) int EventGetAttrparameters(lua_State* L) { Event* evt = LuaType::check(L,1); - LUACHECKOBJ(evt); + RMLUI_CHECK_OBJ(evt); EventParametersProxy* proxy = new EventParametersProxy(); proxy->owner = evt; LuaType::push(L,proxy,true); @@ -87,16 +85,16 @@ int EventGetAttrparameters(lua_State* L) RegType EventMethods[] = { - LUAMETHOD(Event,StopPropagation) + RMLUI_LUAMETHOD(Event,StopPropagation) { nullptr, nullptr }, }; luaL_Reg EventGetters[] = { - LUAGETTER(Event,current_element) - LUAGETTER(Event,type) - LUAGETTER(Event,target_element) - LUAGETTER(Event,parameters) + RMLUI_LUAGETTER(Event,current_element) + RMLUI_LUAGETTER(Event,type) + RMLUI_LUAGETTER(Event,target_element) + RMLUI_LUAGETTER(Event,parameters) { nullptr, nullptr }, }; @@ -105,7 +103,6 @@ luaL_Reg EventSetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Event) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(Event) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Event.h b/Source/Lua/Event.h similarity index 90% rename from Source/Core/Lua/Event.h rename to Source/Lua/Event.h index 77b205dc6..c61e79023 100644 --- a/Source/Core/Lua/Event.h +++ b/Source/Lua/Event.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORELUAEVENT_H -#define RMLUICORELUAEVENT_H +#ifndef RMLUI_LUA_EVENT_H +#define RMLUI_LUA_EVENT_H -#include -#include +#include +#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); //method @@ -49,8 +48,7 @@ extern RegType EventMethods[]; extern luaL_Reg EventGetters[]; extern luaL_Reg EventSetters[]; -LUACORETYPEDECLARE(Event) -} -} -} +RMLUI_LUATYPE_DECLARE(Event) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/EventParametersProxy.cpp b/Source/Lua/EventParametersProxy.cpp similarity index 95% rename from Source/Core/Lua/EventParametersProxy.cpp rename to Source/Lua/EventParametersProxy.cpp index ef5c54d17..1a2ed10e5 100644 --- a/Source/Core/Lua/EventParametersProxy.cpp +++ b/Source/Lua/EventParametersProxy.cpp @@ -26,15 +26,13 @@ * */ -#include "precompiled.h" #include "EventParametersProxy.h" -#include +#include #include #include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -54,7 +52,7 @@ int EventParametersProxy__index(lua_State* L) if(keytype == LUA_TSTRING) //only valid key types { EventParametersProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); const char* key = lua_tostring(L,2); auto it = obj->owner->GetParameters().find(key); const Variant* param = (it == obj->owner->GetParameters().end() ? nullptr : &it->second); @@ -70,7 +68,7 @@ int EventParametersProxy__index(lua_State* L) int EventParametersProxy__pairs(lua_State* L) { EventParametersProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int& pindex = *(int*)lua_touserdata(L,3); if ((pindex) == -1) pindex = 0; @@ -114,7 +112,6 @@ luaL_Reg EventParametersProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(EventParametersProxy) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(EventParametersProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/EventParametersProxy.h b/Source/Lua/EventParametersProxy.h similarity index 89% rename from Source/Core/Lua/EventParametersProxy.h rename to Source/Lua/EventParametersProxy.h index e63de840e..579b7d4d3 100644 --- a/Source/Core/Lua/EventParametersProxy.h +++ b/Source/Lua/EventParametersProxy.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUAEVENTPARAMETERSPROXY_H -#define RMLUICORELUAEVENTPARAMETERSPROXY_H +#ifndef RMLUI_LUA_EVENTPARAMETERSPROXY_H +#define RMLUI_LUA_EVENTPARAMETERSPROXY_H -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { //where owner is the Element that we should look up information from struct EventParametersProxy { Event* owner; }; @@ -48,8 +47,7 @@ extern RegType EventParametersProxyMethods[]; extern luaL_Reg EventParametersProxyGetters[]; extern luaL_Reg EventParametersProxySetters[]; -LUACORETYPEDECLARE(EventParametersProxy) -} -} -} +RMLUI_LUATYPE_DECLARE(EventParametersProxy) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/GlobalLuaFunctions.cpp b/Source/Lua/GlobalLuaFunctions.cpp similarity index 96% rename from Source/Core/Lua/GlobalLuaFunctions.cpp rename to Source/Lua/GlobalLuaFunctions.cpp index 8d7428702..4a7240116 100644 --- a/Source/Core/Lua/GlobalLuaFunctions.cpp +++ b/Source/Lua/GlobalLuaFunctions.cpp @@ -27,12 +27,14 @@ */ -#include "precompiled.h" #include "GlobalLuaFunctions.h" -#include +#include +#include +#include +#include +#include namespace Rml { -namespace Core { namespace Lua { /* Below here are global functions and their helper functions that help overwrite the Lua global functions @@ -161,6 +163,5 @@ void OverrideLuaGlobalFunctions(lua_State* L) lua_pop(L,1); //pop _G } -} -} -} +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/GlobalLuaFunctions.h b/Source/Lua/GlobalLuaFunctions.h similarity index 90% rename from Source/Core/Lua/GlobalLuaFunctions.h rename to Source/Lua/GlobalLuaFunctions.h index 57ad1cd32..b35e348b5 100644 --- a/Source/Core/Lua/GlobalLuaFunctions.h +++ b/Source/Lua/GlobalLuaFunctions.h @@ -26,18 +26,16 @@ * */ -#ifndef RMLUICORELUAGLOBALLUAFUNCTIONS_H -#define RMLUICORELUAGLOBALLUAFUNCTIONS_H +#ifndef RMLUI_LUA_GLOBALLUAFUNCTIONS_H +#define RMLUI_LUA_GLOBALLUAFUNCTIONS_H + +typedef struct lua_State lua_State; namespace Rml { -namespace Core { namespace Lua { void OverrideLuaGlobalFunctions(lua_State* L); //overrides pairs and ipairs to respect __pairs and __ipairs metamethods //overrdes print to print to the console -} -} -} - - -#endif \ No newline at end of file +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Lua/Interpreter.cpp b/Source/Lua/Interpreter.cpp new file mode 100644 index 000000000..b154504c8 --- /dev/null +++ b/Source/Lua/Interpreter.cpp @@ -0,0 +1,156 @@ +/* + * This source file is part of RmlUi, the HTML/CSS Interface Middleware + * + * For the latest information, see http://github.com/mikke89/RmlUi + * + * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd + * Copyright (c) 2019 The RmlUi Team, and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include +#include "LuaPlugin.h" +#include "LuaDocumentElementInstancer.h" +#include "LuaEventListenerInstancer.h" +#include +#include +#include +#include +#include + +namespace Rml { +namespace Lua { + +lua_State* Interpreter::GetLuaState() +{ + return LuaPlugin::GetLuaState(); +} + +void Interpreter::LoadFile(const String& file) +{ + lua_State* L = GetLuaState(); + + //use the file interface to get the contents of the script + FileInterface* file_interface = GetFileInterface(); + FileHandle handle = file_interface->Open(file); + if (handle == 0) { + lua_pushfstring(L, "LoadFile: Unable to open file: %s", file.c_str()); + Report(L); + return; + } + + size_t size = file_interface->Length(handle); + if (size == 0) { + lua_pushfstring(L, "LoadFile: File is 0 bytes in size: %s", file.c_str()); + Report(L); + return; + } + char* file_contents = new char[size]; + file_interface->Read(file_contents, size, handle); + file_interface->Close(handle); + + if (luaL_loadbuffer(L, file_contents, size, file.c_str()) != 0) + Report(L); + else //if there were no errors loading, then the compiled function is on the top of the stack + { + if (lua_pcall(L, 0, 0, 0) != 0) + Report(L); + } + + delete[] file_contents; +} + + +void Interpreter::DoString(const String& code, const String& name) +{ + lua_State* L = GetLuaState(); + + if (luaL_loadbuffer(L, code.c_str(), code.length(), name.c_str()) != 0) + Report(L); + else + { + if (lua_pcall(L, 0, 0, 0) != 0) + Report(L); + } +} + +void Interpreter::LoadString(const String& code, const String& name) +{ + lua_State* L = GetLuaState(); + + if (luaL_loadbuffer(L, code.c_str(), code.length(), name.c_str()) != 0) + Report(L); +} + + +void Interpreter::BeginCall(int funRef) +{ + lua_State* L = GetLuaState(); + + lua_settop(L, 0); //empty stack + //lua_getref(g_L,funRef); + lua_rawgeti(L, LUA_REGISTRYINDEX, (int)funRef); +} + +bool Interpreter::ExecuteCall(int params, int res) +{ + lua_State* L = GetLuaState(); + + bool ret = true; + int top = lua_gettop(L); + if (lua_type(L, top - params) != LUA_TFUNCTION) + { + ret = false; + //stack cleanup + if (params > 0) + { + for (int i = top; i >= (top - params); i--) + { + if (!lua_isnone(L, i)) + lua_remove(L, i); + } + } + } + else + { + if (lua_pcall(L, params, res, 0) != 0) + { + Report(L); + ret = false; + } + } + return ret; +} + +void Interpreter::EndCall(int res) +{ + lua_State* L = GetLuaState(); + + //stack cleanup + for (int i = res; i > 0; i--) + { + if (!lua_isnone(L, res)) + lua_remove(L, res); + } +} + +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Log.cpp b/Source/Lua/Log.cpp similarity index 93% rename from Source/Core/Lua/Log.cpp rename to Source/Lua/Log.cpp index 06145514e..0a119f6e0 100644 --- a/Source/Core/Lua/Log.cpp +++ b/Source/Lua/Log.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "Log.h" #include #include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -45,7 +43,7 @@ template<> void ExtraInit(lua_State* L, int metatable_index) lua_pushcfunction(L,LogMessage); lua_setfield(L,method_index, "Message"); - //construct the "logtype" table, so that we can use the Rml::Core::Log::Type enum like Log.logtype.always in Lua for Log::LT_ALWAYS + //construct the "logtype" table, so that we can use the Log::Type enum like Log.logtype.always in Lua for Log::LT_ALWAYS lua_newtable(L); int logtype = lua_gettop(L); lua_pushvalue(L,-1); //copy of the new table, so that the logtype index will stay valid @@ -94,7 +92,6 @@ luaL_Reg LogSetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Log) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(Log) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Log.h b/Source/Lua/Log.h similarity index 87% rename from Source/Core/Lua/Log.h rename to Source/Lua/Log.h index 2f5976bf8..2bbc78bab 100644 --- a/Source/Core/Lua/Log.h +++ b/Source/Lua/Log.h @@ -25,12 +25,15 @@ * THE SOFTWARE. * */ - -#include -#include + +#ifndef RMLUI_LUA_LOG_H +#define RMLUI_LUA_LOG_H + +#include +#include +#include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); @@ -40,7 +43,8 @@ extern RegType LogMethods[]; extern luaL_Reg LogGetters[]; extern luaL_Reg LogSetters[]; -LUACORETYPEDECLARE(Log) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DECLARE(Log) +} // namespace Lua +} // namespace Rml + +#endif diff --git a/Source/Core/Lua/LuaElement.h b/Source/Lua/Lua.cpp similarity index 84% rename from Source/Core/Lua/LuaElement.h rename to Source/Lua/Lua.cpp index b931773e4..b190aa33e 100644 --- a/Source/Core/Lua/LuaElement.h +++ b/Source/Lua/Lua.cpp @@ -25,19 +25,23 @@ * THE SOFTWARE. * */ - -#ifndef RMLUICORELUALUAELEMENT_H -#define RMLUICORELUALUAELEMENT_H - -#include + +#include +#include +#include "LuaPlugin.h" namespace Rml { -namespace Core { namespace Lua { -class -} +void Initialise() +{ + ::Rml::Lua::Initialise(nullptr); } + +void Initialise(lua_State* lua_state) +{ + ::Rml::RegisterPlugin(new LuaPlugin(lua_state)); } -#endif +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaDocument.cpp b/Source/Lua/LuaDocument.cpp similarity index 93% rename from Source/Core/Lua/LuaDocument.cpp rename to Source/Lua/LuaDocument.cpp index 3a11e21f5..82a42eee0 100644 --- a/Source/Core/Lua/LuaDocument.cpp +++ b/Source/Lua/LuaDocument.cpp @@ -26,15 +26,13 @@ * */ -#include "precompiled.h" #include "LuaDocument.h" #include -#include -#include +#include +#include namespace Rml { -namespace Core { namespace Lua { LuaDocument::LuaDocument(const String& tag) : ElementDocument(tag) @@ -56,6 +54,5 @@ void LuaDocument::LoadScript(Stream* stream, const String& source_name) } } -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaDocument.h b/Source/Lua/LuaDocument.h similarity index 91% rename from Source/Core/Lua/LuaDocument.h rename to Source/Lua/LuaDocument.h index b2ff96fcf..3497dd771 100644 --- a/Source/Core/Lua/LuaDocument.h +++ b/Source/Lua/LuaDocument.h @@ -26,25 +26,23 @@ * */ -#ifndef RMLUICORELUALUADOCUMENT_H -#define RMLUICORELUALUADOCUMENT_H +#ifndef RMLUI_LUA_LUADOCUMENT_H +#define RMLUI_LUA_LUADOCUMENT_H /* This class is an ElementDocument that overrides the LoadScript function */ #include namespace Rml { -namespace Core { namespace Lua { -class LuaDocument : public ElementDocument +class LuaDocument : public ::Rml::ElementDocument { public: LuaDocument(const String& tag); void LoadScript(Stream* stream, const String& source_name) override; }; -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/LuaDocumentElementInstancer.cpp b/Source/Lua/LuaDocumentElementInstancer.cpp similarity index 97% rename from Source/Core/Lua/LuaDocumentElementInstancer.cpp rename to Source/Lua/LuaDocumentElementInstancer.cpp index 7cd9e8fd6..e8a5441d3 100644 --- a/Source/Core/Lua/LuaDocumentElementInstancer.cpp +++ b/Source/Lua/LuaDocumentElementInstancer.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "LuaDocumentElementInstancer.h" #include "LuaDocument.h" namespace Rml { -namespace Core { namespace Lua { /// Instances an element given the tag name and attributes. @@ -49,6 +47,5 @@ void LuaDocumentElementInstancer::ReleaseElement(Element* element) delete element; } -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaDocumentElementInstancer.h b/Source/Lua/LuaDocumentElementInstancer.h similarity index 90% rename from Source/Core/Lua/LuaDocumentElementInstancer.h rename to Source/Lua/LuaDocumentElementInstancer.h index f3066ca06..586abfc9a 100644 --- a/Source/Core/Lua/LuaDocumentElementInstancer.h +++ b/Source/Lua/LuaDocumentElementInstancer.h @@ -26,16 +26,15 @@ * */ -#ifndef RMLUICORELUALUADOCUMENTELEMENTINSTANCER_H -#define RMLUICORELUALUADOCUMENTELEMENTINSTANCER_H +#ifndef RMLUI_LUA_LUADOCUMENTELEMENTINSTANCER_H +#define RMLUI_LUA_LUADOCUMENTELEMENTINSTANCER_H #include namespace Rml { -namespace Core { namespace Lua { -class LuaDocumentElementInstancer : public ElementInstancer +class LuaDocumentElementInstancer : public ::Rml::ElementInstancer { /// Instances an element given the tag name and attributes. /// @param[in] parent The element the new element is destined to be parented to. @@ -47,7 +46,6 @@ class LuaDocumentElementInstancer : public ElementInstancer void ReleaseElement(Element* element) override; }; -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/LuaElementInstancer.cpp b/Source/Lua/LuaElementInstancer.cpp similarity index 94% rename from Source/Core/Lua/LuaElementInstancer.cpp rename to Source/Lua/LuaElementInstancer.cpp index ba1c9ef89..8734447d3 100644 --- a/Source/Core/Lua/LuaElementInstancer.cpp +++ b/Source/Lua/LuaElementInstancer.cpp @@ -26,17 +26,15 @@ * */ -#include "precompiled.h" #include "LuaElementInstancer.h" #include -#include -#include +#include +#include #include namespace Rml { -namespace Core { namespace Lua { -//This will be called from Rml::Core::Lua::ElementInstancernew +//This will be called from ElementInstancernew LuaElementInstancer::LuaElementInstancer(lua_State* L) : ElementInstancer(), ref_InstanceElement(LUA_NOREF) { if(lua_type(L,1) != LUA_TFUNCTION && !lua_isnoneornil(L,1)) @@ -92,6 +90,5 @@ void LuaElementInstancer::PushFunctionsTable(lua_State* L) } } -} -} -} +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaElementInstancer.h b/Source/Lua/LuaElementInstancer.h similarity index 91% rename from Source/Core/Lua/LuaElementInstancer.h rename to Source/Lua/LuaElementInstancer.h index e10a6a7a1..49185071a 100644 --- a/Source/Core/Lua/LuaElementInstancer.h +++ b/Source/Lua/LuaElementInstancer.h @@ -26,18 +26,17 @@ * */ -#ifndef RMLUICORELUALUAELEMENTINSTANCER_H -#define RMLUICORELUALUAELEMENTINSTANCER_H +#ifndef RMLUI_LUA_LUAELEMENTINSTANCER_H +#define RMLUI_LUA_LUAELEMENTINSTANCER_H #include #include -#include +#include namespace Rml { -namespace Core { namespace Lua { -class LuaElementInstancer : public Rml::Core::ElementInstancer +class LuaElementInstancer : public ::Rml::ElementInstancer { public: LuaElementInstancer(lua_State* L); @@ -56,8 +55,6 @@ class LuaElementInstancer : public Rml::Core::ElementInstancer void PushFunctionsTable(lua_State* L); }; -} -} -} - +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/LuaEventListener.cpp b/Source/Lua/LuaEventListener.cpp similarity index 95% rename from Source/Core/Lua/LuaEventListener.cpp rename to Source/Lua/LuaEventListener.cpp index aaad48fbf..e7adbf6f4 100644 --- a/Source/Core/Lua/LuaEventListener.cpp +++ b/Source/Lua/LuaEventListener.cpp @@ -26,16 +26,15 @@ * */ -#include "precompiled.h" #include "LuaEventListener.h" -#include -#include -#include +#include +#include +#include +#include namespace Rml { -namespace Core { namespace Lua { -typedef Rml::Core::ElementDocument Document; +typedef ElementDocument Document; LuaEventListener::LuaEventListener(const String& code, Element* element) : EventListener() { @@ -146,6 +145,5 @@ void LuaEventListener::ProcessEvent(Event& event) } -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaEventListener.h b/Source/Lua/LuaEventListener.h similarity index 91% rename from Source/Core/Lua/LuaEventListener.h rename to Source/Lua/LuaEventListener.h index cadc5063d..f75846cf0 100644 --- a/Source/Core/Lua/LuaEventListener.h +++ b/Source/Lua/LuaEventListener.h @@ -26,17 +26,19 @@ * */ -#ifndef RMLUICORELUALUAEVENTLISTENER_H -#define RMLUICORELUALUAEVENTLISTENER_H +#ifndef RMLUI_LUA_LUAEVENTLISTENER_H +#define RMLUI_LUA_LUAEVENTLISTENER_H #include -#include +#include namespace Rml { -namespace Core { +class Element; +class ElementDocument; + namespace Lua { -class LuaEventListener : public EventListener +class LuaEventListener : public ::Rml::EventListener { public: //The plan is to wrap the code in an anonymous function so that we can have named parameters to use, @@ -66,7 +68,6 @@ class LuaEventListener : public EventListener String strFunc; //for debugging purposes }; -} -} -} +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/LuaEventListenerInstancer.cpp b/Source/Lua/LuaEventListenerInstancer.cpp similarity index 97% rename from Source/Core/Lua/LuaEventListenerInstancer.cpp rename to Source/Lua/LuaEventListenerInstancer.cpp index 5d8dc44cc..1adb933b8 100644 --- a/Source/Core/Lua/LuaEventListenerInstancer.cpp +++ b/Source/Lua/LuaEventListenerInstancer.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "LuaEventListenerInstancer.h" #include "LuaEventListener.h" namespace Rml { -namespace Core { namespace Lua { /// Instance an event listener object. @@ -42,6 +40,5 @@ EventListener* LuaEventListenerInstancer::InstanceEventListener(const String& va return new LuaEventListener(value,element); } -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/LuaEventListenerInstancer.h b/Source/Lua/LuaEventListenerInstancer.h similarity index 88% rename from Source/Core/Lua/LuaEventListenerInstancer.h rename to Source/Lua/LuaEventListenerInstancer.h index 7b924d807..0bfd86520 100644 --- a/Source/Core/Lua/LuaEventListenerInstancer.h +++ b/Source/Lua/LuaEventListenerInstancer.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUALUAEVENTLISTENERINSTANCER_H -#define RMLUICORELUALUAEVENTLISTENERINSTANCER_H +#ifndef RMLUI_LUA_LUAEVENTLISTENERINSTANCER_H +#define RMLUI_LUA_LUAEVENTLISTENERINSTANCER_H #include namespace Rml { -namespace Core { namespace Lua { -class LuaEventListenerInstancer : public EventListenerInstancer +class LuaEventListenerInstancer : public ::Rml::EventListenerInstancer { public: /// Instance an event listener object. @@ -43,7 +42,6 @@ class LuaEventListenerInstancer : public EventListenerInstancer EventListener* InstanceEventListener(const String& value, Element* element) override; }; -} -} -} -#endif \ No newline at end of file +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Lua/LuaPlugin.cpp b/Source/Lua/LuaPlugin.cpp new file mode 100644 index 000000000..d25bbb3d6 --- /dev/null +++ b/Source/Lua/LuaPlugin.cpp @@ -0,0 +1,186 @@ +/* + * This source file is part of RmlUi, the HTML/CSS Interface Middleware + * + * For the latest information, see http://github.com/mikke89/RmlUi + * + * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd + * Copyright (c) 2019 The RmlUi Team, and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "LuaPlugin.h" +#include +#include +#include +#include +#include +#include "LuaDocumentElementInstancer.h" +#include +#include "LuaEventListenerInstancer.h" +#include "RmlUi.h" +//the types I made +#include "ContextDocumentsProxy.h" +#include "EventParametersProxy.h" +#include "ElementAttributesProxy.h" +#include "Log.h" +#include "Element.h" +#include "ElementStyleProxy.h" +#include "Document.h" +#include "Colourb.h" +#include "Colourf.h" +#include "Vector2f.h" +#include "Vector2i.h" +#include "Context.h" +#include "Event.h" +#include "ElementInstancer.h" +#include "ElementChildNodesProxy.h" +#include "ElementText.h" +#include "GlobalLuaFunctions.h" +#include "RmlUiContextsProxy.h" +// Control types +#include "Elements/SelectOptionsProxy.h" +#include "Elements/DataFormatter.h" +#include "Elements/DataSource.h" +#include "Elements/ElementForm.h" +#include "Elements/ElementFormControl.h" +#include "Elements/ElementFormControlSelect.h" +#include "Elements/ElementFormControlDataSelect.h" +#include "Elements/ElementFormControlInput.h" +#include "Elements/ElementFormControlTextArea.h" +#include "Elements/ElementDataGrid.h" +#include "Elements/ElementDataGridRow.h" +#include "Elements/ElementTabSet.h" + +namespace Rml { +namespace Lua { + +static lua_State* g_L = nullptr; + + +/** This will populate the global Lua table with all of the Lua core types by calling LuaType::Register +@remark This is called automatically by LuaPlugin::OnInitialise(). */ +static void RegisterTypes(); + + +LuaPlugin::LuaPlugin(lua_State* lua_state) +{ + RMLUI_ASSERT(g_L == nullptr); + g_L = lua_state; +} + +int LuaPlugin::GetEventClasses() +{ + return EVT_BASIC; +} + +void LuaPlugin::OnInitialise() +{ + if (g_L == nullptr) + { + Log::Message(Log::LT_INFO, "Loading Lua plugin using a new Lua state."); + g_L = luaL_newstate(); + luaL_openlibs(g_L); + owns_lua_state = true; + } + else + { + Log::Message(Log::LT_INFO, "Loading Lua plugin using the provided Lua state."); + owns_lua_state = false; + } + RegisterTypes(); + + lua_document_element_instancer = new LuaDocumentElementInstancer(); + lua_event_listener_instancer = new LuaEventListenerInstancer(); + Factory::RegisterElementInstancer("body", lua_document_element_instancer); + Factory::RegisterEventListenerInstancer(lua_event_listener_instancer); +} + +void LuaPlugin::OnShutdown() +{ + delete lua_document_element_instancer; + delete lua_event_listener_instancer; + lua_document_element_instancer = nullptr; + lua_event_listener_instancer = nullptr; + + if (owns_lua_state) + lua_close(g_L); + + g_L = nullptr; + + delete this; +} + + +static void RegisterTypes() +{ + RMLUI_ASSERT(g_L); + lua_State* L = g_L; + + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + //things that inherit from Element + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + //Proxy tables + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + OverrideLuaGlobalFunctions(L); + //push the global variable "rmlui" to use the "RmlUi" methods + LuaRmlUiPushrmluiGlobal(L); + + // Control types + LuaType::Register(L); + LuaType::Register(L); + //Inherits from ElementFormControl + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + LuaType::Register(L); + //proxy tables + LuaType::Register(L); +} + + +lua_State* LuaPlugin::GetLuaState() +{ + return g_L; +} + +} // namespace Lua +} // namespace Rml diff --git a/Source/Lua/LuaPlugin.h b/Source/Lua/LuaPlugin.h new file mode 100644 index 000000000..4b693a605 --- /dev/null +++ b/Source/Lua/LuaPlugin.h @@ -0,0 +1,70 @@ +/* + * This source file is part of RmlUi, the HTML/CSS Interface Middleware + * + * For the latest information, see http://github.com/mikke89/RmlUi + * + * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd + * Copyright (c) 2019 The RmlUi Team, and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef RMLUI_LUA_LUAPLUGIN_H +#define RMLUI_LUA_LUAPLUGIN_H + +#include +#include + +typedef struct lua_State lua_State; + +namespace Rml { +namespace Lua { + +class LuaDocumentElementInstancer; +class LuaEventListenerInstancer; + +/** + This initializes the Lua interpreter, and has functions to load the scripts or + call functions that exist in Lua. + + @author Nathan Starkey +*/ +class RMLUILUA_API LuaPlugin : public Plugin +{ +public: + LuaPlugin(lua_State* lua_state); + + static lua_State* GetLuaState(); + +private: + int GetEventClasses() override; + + void OnInitialise() override; + + void OnShutdown() override; + + LuaDocumentElementInstancer* lua_document_element_instancer = nullptr; + LuaEventListenerInstancer* lua_event_listener_instancer = nullptr; + bool owns_lua_state = false; +}; + +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Lua/LuaType.cpp b/Source/Lua/LuaType.cpp new file mode 100644 index 000000000..5fb53f720 --- /dev/null +++ b/Source/Lua/LuaType.cpp @@ -0,0 +1,123 @@ +/* + * This source file is part of RmlUi, the HTML/CSS Interface Middleware + * + * For the latest information, see http://github.com/mikke89/RmlUi + * + * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd + * Copyright (c) 2019 The RmlUi Team, and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include +#include +#include + +namespace Rml { +namespace Lua { + + +int LuaTypeImpl::index(lua_State* L, const char* class_name) +{ + /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/ + lua_getglobal(L, class_name); //stack pos [3] (fairly important, just refered to as [3]) + // string form of the key. + const char* key = luaL_checkstring(L, 2); + if (lua_istable(L, -1)) //[-1 = 3] + { + lua_pushvalue(L, 2); //[2] = key, [4] = copy of key + lua_rawget(L, -2); //[-2 = 3] -> pop top and push the return value to top [4] + //If the key were looking for is not in the table, retrieve its' metatables' index value. + if (lua_isnil(L, -1)) //[-1 = 4] is value from rawget above + { + //try __getters + lua_pop(L, 1); //remove top item (nil) from the stack + lua_pushstring(L, "__getters"); + lua_rawget(L, -2); //[-2 = 3], ._getters -> result to [4] + lua_pushvalue(L, 2); //[2 = key] -> copy to [5] + lua_rawget(L, -2); //[-2 = __getters] -> __getters[key], result to [5] + if (lua_type(L, -1) == LUA_TFUNCTION) //[-1 = 5] + { + lua_pushvalue(L, 1); //push the userdata to the stack [6] + if (lua_pcall(L, 1, 1, 0) != 0) //remove one, result is at [6] + Report(L, String(class_name).append(".__index for ").append(lua_tostring(L, 2)).append(": ")); + } + else + { + lua_settop(L, 4); //forget everything we did above + lua_getmetatable(L, -2); //[-2 = 3] -> metatable from to top [5] + if (lua_istable(L, -1)) //[-1 = 5] = the result of the above + { + lua_getfield(L, -1, "__index"); //[-1 = 5] = check the __index metamethod for the metatable-> push result to [6] + if (lua_isfunction(L, -1)) //[-1 = 6] = __index metamethod + { + lua_pushvalue(L, 1); //[1] = object -> [7] = object + lua_pushvalue(L, 2); //[2] = key -> [8] = key + if (lua_pcall(L, 2, 1, 0) != 0) //call function at top of stack (__index) -> pop top 2 as args; [7] = return value + Report(L, String(class_name).append(".__index for ").append(lua_tostring(L, 2)).append(": ")); + } + else if (lua_istable(L, -1)) + lua_getfield(L, -1, key); //shorthand version of above -> [7] = return value + else + lua_pushnil(L); //[7] = nil + } + else + lua_pushnil(L); //[6] = nil + } + } + else if (lua_istable(L, -1))//[-1 = 4] is value from rawget [3] + { + lua_pushvalue(L, 2); //[2] = key, [5] = key + lua_rawget(L, -2); //[-2 = 3] = table of -> pop top and push the return value to top [5] + } + } + else + lua_pushnil(L); //[4] = nil + + lua_insert(L, 1); //top element to position 1 -> [1] = top element as calculated in the earlier rest of the function + lua_settop(L, 1); // -> [1 = -1], removes the other elements + return 1; +} + +int LuaTypeImpl::newindex(lua_State* L, const char* class_name) +{ + //[1] = obj, [2] = key, [3] = value + //look for it in __setters + lua_getglobal(L, class_name); //[4] = this table + lua_pushstring(L, "__setters"); //[5] + lua_rawget(L, -2); //[-2 = 4] -> .__setters to [5] + lua_pushvalue(L, 2); //[2 = key] -> [6] = copy of key + lua_rawget(L, -2); //[-2 = __setters] -> __setters[key] to [6] + if (lua_type(L, -1) == LUA_TFUNCTION) + { + lua_pushvalue(L, 1); //userdata at [7] + lua_pushvalue(L, 3); //[8] = copy of [3] + if (lua_pcall(L, 2, 0, 0) != 0) //call function, pop 2 off push 0 on + Report(L, String(class_name).append(".__newindex for ").append(lua_tostring(L, 2)).append(": ")); + } + else + lua_pop(L, 1); //not a setter function. + lua_pop(L, 2); //pop __setters and the table + return 0; +} + + +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/RmlUi.cpp b/Source/Lua/RmlUi.cpp similarity index 96% rename from Source/Core/Lua/RmlUi.cpp rename to Source/Lua/RmlUi.cpp index c9fa3fe52..13306e446 100644 --- a/Source/Core/Lua/RmlUi.cpp +++ b/Source/Lua/RmlUi.cpp @@ -26,16 +26,15 @@ * */ -#include "precompiled.h" #include "RmlUi.h" #include +#include #include #include "ElementInstancer.h" #include "LuaElementInstancer.h" #include "RmlUiContextsProxy.h" namespace Rml { -namespace Core { namespace Lua { #define RMLUILUA_INPUTENUM(keyident,tbl) lua_pushinteger(L,Input::KI_##keyident); lua_setfield(L,(tbl),#keyident); #define RMLUILUA_INPUTMODIFIERENUM(keymod,tbl) lua_pushinteger(L,Input::KM_##keymod); lua_setfield(L,(tbl),#keymod); @@ -83,7 +82,7 @@ int LuaRmlUiRegisterTag(lua_State* L, LuaRmlUi* /*obj*/) { const char* tag = luaL_checkstring(L,1); LuaElementInstancer* lei = (LuaElementInstancer*)LuaType::check(L,2); - LUACHECKOBJ(lei); + RMLUI_CHECK_OBJ(lei); Factory::RegisterElementInstancer(tag,lei); return 0; } @@ -306,17 +305,17 @@ void LuaRmlUiEnumkey_modifier(lua_State* L) RegType LuaRmlUiMethods[] = { - LUAMETHOD(LuaRmlUi,CreateContext) - LUAMETHOD(LuaRmlUi,LoadFontFace) - LUAMETHOD(LuaRmlUi,RegisterTag) + RMLUI_LUAMETHOD(LuaRmlUi,CreateContext) + RMLUI_LUAMETHOD(LuaRmlUi,LoadFontFace) + RMLUI_LUAMETHOD(LuaRmlUi,RegisterTag) { nullptr, nullptr }, }; luaL_Reg LuaRmlUiGetters[] = { - LUAGETTER(LuaRmlUi,contexts) - LUAGETTER(LuaRmlUi,key_identifier) - LUAGETTER(LuaRmlUi,key_modifier) + RMLUI_LUAGETTER(LuaRmlUi,contexts) + RMLUI_LUAGETTER(LuaRmlUi,key_identifier) + RMLUI_LUAGETTER(LuaRmlUi,key_modifier) { nullptr, nullptr }, }; @@ -325,7 +324,6 @@ luaL_Reg LuaRmlUiSetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(LuaRmlUi) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(LuaRmlUi) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/RmlUi.h b/Source/Lua/RmlUi.h similarity index 92% rename from Source/Core/Lua/RmlUi.h rename to Source/Lua/RmlUi.h index 7bdb3da8b..04fef5fcb 100644 --- a/Source/Core/Lua/RmlUi.h +++ b/Source/Lua/RmlUi.h @@ -26,14 +26,13 @@ * */ -#ifndef RMLUICORELUARMLUI_H -#define RMLUICORELUARMLUI_H +#ifndef RMLUI_LUA_RMLUI_H +#define RMLUI_LUA_RMLUI_H -#include -#include +#include +#include namespace Rml { -namespace Core { namespace Lua { @@ -64,8 +63,7 @@ extern RegType LuaRmlUiMethods[]; extern luaL_Reg LuaRmlUiGetters[]; extern luaL_Reg LuaRmlUiSetters[]; -LUACORETYPEDECLARE(LuaRmlUi) -} -} -} +RMLUI_LUATYPE_DECLARE(LuaRmlUi) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/RmlUiContextsProxy.cpp b/Source/Lua/RmlUiContextsProxy.cpp similarity index 96% rename from Source/Core/Lua/RmlUiContextsProxy.cpp rename to Source/Lua/RmlUiContextsProxy.cpp index 85185bf03..673199d58 100644 --- a/Source/Core/Lua/RmlUiContextsProxy.cpp +++ b/Source/Lua/RmlUiContextsProxy.cpp @@ -26,14 +26,12 @@ * */ -#include "precompiled.h" #include "RmlUiContextsProxy.h" #include #include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -53,7 +51,7 @@ int RmlUiContextsProxy__index(lua_State* L) if(keytype == LUA_TSTRING || keytype == LUA_TNUMBER) //only valid key types { RmlUiContextsProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); if(keytype == LUA_TSTRING) { const char* key = lua_tostring(L,2); @@ -75,7 +73,7 @@ int RmlUiContextsProxy__index(lua_State* L) int RmlUiContextsProxy__pairs(lua_State* L) { RmlUiContextsProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) *pindex = 0; @@ -101,7 +99,7 @@ int RmlUiContextsProxy__pairs(lua_State* L) int RmlUiContextsProxy__ipairs(lua_State* L) { RmlUiContextsProxy* obj = LuaType::check(L,1); - LUACHECKOBJ(obj); + RMLUI_CHECK_OBJ(obj); int* pindex = (int*)lua_touserdata(L,3); if((*pindex) == -1) *pindex = 0; @@ -136,7 +134,6 @@ luaL_Reg RmlUiContextsProxySetters[] = { nullptr, nullptr }, }; -LUACORETYPEDEFINE(RmlUiContextsProxy) -} -} -} \ No newline at end of file +RMLUI_LUATYPE_DEFINE(RmlUiContextsProxy) +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/RmlUiContextsProxy.h b/Source/Lua/RmlUiContextsProxy.h similarity index 89% rename from Source/Core/Lua/RmlUiContextsProxy.h rename to Source/Lua/RmlUiContextsProxy.h index 721f14822..51f933a0f 100644 --- a/Source/Core/Lua/RmlUiContextsProxy.h +++ b/Source/Lua/RmlUiContextsProxy.h @@ -26,15 +26,14 @@ * */ -#ifndef RMLUICORELUARMLUICONTEXTSPROXY_H -#define RMLUICORELUARMLUICONTEXTSPROXY_H +#ifndef RMLUI_LUA_RMLUICONTEXTSPROXY_H +#define RMLUI_LUA_RMLUICONTEXTSPROXY_H -#include -#include +#include +#include namespace Rml { -namespace Core { namespace Lua { //where owner is the Element that we should look up information from struct RmlUiContextsProxy { void* nothing; }; @@ -48,8 +47,7 @@ extern RegType RmlUiContextsProxyMethods[]; extern luaL_Reg RmlUiContextsProxyGetters[]; extern luaL_Reg RmlUiContextsProxySetters[]; -LUACORETYPEDECLARE(RmlUiContextsProxy) -} -} -} -#endif \ No newline at end of file +RMLUI_LUATYPE_DECLARE(RmlUiContextsProxy) +} // namespace Lua +} // namespace Rml +#endif diff --git a/Source/Core/Lua/Utilities.cpp b/Source/Lua/Utilities.cpp similarity index 94% rename from Source/Core/Lua/Utilities.cpp rename to Source/Lua/Utilities.cpp index f142c993c..c3e2722f3 100644 --- a/Source/Core/Lua/Utilities.cpp +++ b/Source/Lua/Utilities.cpp @@ -26,11 +26,10 @@ * */ -#include "precompiled.h" -#include +#include +#include namespace Rml { -namespace Core { namespace Lua { void PushVariant(lua_State* L, const Variant* var) @@ -74,7 +73,7 @@ void PushVariant(lua_State* L, const Variant* var) } -void Report(lua_State* L, const Rml::Core::String& place) +void Report(lua_State* L, const String& place) { const char * msg= lua_tostring(L,-1); String strmsg; @@ -90,6 +89,5 @@ void Report(lua_State* L, const Rml::Core::String& place) } } -} -} -} +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Vector2f.cpp b/Source/Lua/Vector2f.cpp similarity index 87% rename from Source/Core/Lua/Vector2f.cpp rename to Source/Lua/Vector2f.cpp index 21caa54a2..1cba7a4ec 100644 --- a/Source/Core/Lua/Vector2f.cpp +++ b/Source/Lua/Vector2f.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "Vector2f.h" #include namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) @@ -72,7 +70,7 @@ int Vector2fnew(lua_State* L) int Vector2f__mul(lua_State* L) { Vector2f* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); float rhs = (float)luaL_checknumber(L,2); Vector2f* res = new Vector2f(0.f,0.f); @@ -85,7 +83,7 @@ int Vector2f__mul(lua_State* L) int Vector2f__div(lua_State* L) { Vector2f* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); float rhs = (float)luaL_checknumber(L,2); Vector2f* res = new Vector2f(0.f,0.f); @@ -98,9 +96,9 @@ int Vector2f__div(lua_State* L) int Vector2f__add(lua_State* L) { Vector2f* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2f* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); Vector2f* res = new Vector2f(0.f,0.f); (*res) = (*lhs) + (*rhs); @@ -112,9 +110,9 @@ int Vector2f__add(lua_State* L) int Vector2f__sub(lua_State* L) { Vector2f* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2f* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); Vector2f* res = new Vector2f(0.f,0.f); (*res) = (*lhs) - (*rhs); @@ -126,9 +124,9 @@ int Vector2f__sub(lua_State* L) int Vector2f__eq(lua_State* L) { Vector2f* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2f* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0); return 1; @@ -138,7 +136,7 @@ int Vector2f__eq(lua_State* L) int Vector2fDotProduct(lua_State* L, Vector2f* obj) { Vector2f* rhs = LuaType::check(L,1); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); float res = obj->DotProduct(*rhs); @@ -169,7 +167,7 @@ int Vector2fRotate(lua_State* L, Vector2f* obj) int Vector2fGetAttrx(lua_State*L) { Vector2f* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushnumber(L,self->x); return 1; @@ -178,7 +176,7 @@ int Vector2fGetAttrx(lua_State*L) int Vector2fGetAttry(lua_State*L) { Vector2f* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushnumber(L,self->y); return 1; @@ -187,7 +185,7 @@ int Vector2fGetAttry(lua_State*L) int Vector2fGetAttrmagnitude(lua_State*L) { Vector2f* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushnumber(L,self->Magnitude()); return 1; @@ -196,7 +194,7 @@ int Vector2fGetAttrmagnitude(lua_State*L) int Vector2fSetAttrx(lua_State*L) { Vector2f* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); float value = (float)luaL_checknumber(L,2); self->x = value; @@ -206,7 +204,7 @@ int Vector2fSetAttrx(lua_State*L) int Vector2fSetAttry(lua_State*L) { Vector2f* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); float value = (float)luaL_checknumber(L,2); self->y = value; @@ -214,32 +212,30 @@ int Vector2fSetAttry(lua_State*L) } - RegType Vector2fMethods[] = { - LUAMETHOD(Vector2f,DotProduct) - LUAMETHOD(Vector2f,Normalise) - LUAMETHOD(Vector2f,Rotate) + RMLUI_LUAMETHOD(Vector2f,DotProduct) + RMLUI_LUAMETHOD(Vector2f,Normalise) + RMLUI_LUAMETHOD(Vector2f,Rotate) { nullptr, nullptr }, }; luaL_Reg Vector2fGetters[]= { - LUAGETTER(Vector2f,x) - LUAGETTER(Vector2f,y) - LUAGETTER(Vector2f,magnitude) + RMLUI_LUAGETTER(Vector2f,x) + RMLUI_LUAGETTER(Vector2f,y) + RMLUI_LUAGETTER(Vector2f,magnitude) { nullptr, nullptr }, }; luaL_Reg Vector2fSetters[]= { - LUASETTER(Vector2f,x) - LUASETTER(Vector2f,y) + RMLUI_LUASETTER(Vector2f,x) + RMLUI_LUASETTER(Vector2f,y) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Vector2f) +RMLUI_LUATYPE_DEFINE(Vector2f) -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Vector2f.h b/Source/Lua/Vector2f.h similarity index 91% rename from Source/Core/Lua/Vector2f.h rename to Source/Lua/Vector2f.h index ea90cfde5..bc6ca8a61 100644 --- a/Source/Core/Lua/Vector2f.h +++ b/Source/Lua/Vector2f.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICORELUAVECTOR2F_H -#define RMLUICORELUAVECTOR2F_H +#ifndef RMLUI_LUA_VECTOR2F_H +#define RMLUI_LUA_VECTOR2F_H -#include -#include +#include +#include #include -using Rml::Core::Vector2f; namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); @@ -62,8 +60,7 @@ extern RegType Vector2fMethods[]; extern luaL_Reg Vector2fGetters[]; extern luaL_Reg Vector2fSetters[]; -LUACORETYPEDECLARE(Vector2f) -} -} -} +RMLUI_LUATYPE_DECLARE(Vector2f) +} // namespace Lua +} // namespace Rml #endif diff --git a/Source/Core/Lua/Vector2i.cpp b/Source/Lua/Vector2i.cpp similarity index 88% rename from Source/Core/Lua/Vector2i.cpp rename to Source/Lua/Vector2i.cpp index 052f0a897..ec96548f1 100644 --- a/Source/Core/Lua/Vector2i.cpp +++ b/Source/Lua/Vector2i.cpp @@ -26,12 +26,10 @@ * */ -#include "precompiled.h" #include "Vector2i.h" namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index) { @@ -71,7 +69,7 @@ int Vector2inew(lua_State* L) int Vector2i__mul(lua_State* L) { Vector2i* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); int rhs = (int)luaL_checkinteger(L,2); Vector2i* res = new Vector2i(0,0); @@ -84,7 +82,7 @@ int Vector2i__mul(lua_State* L) int Vector2i__div(lua_State* L) { Vector2i* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); int rhs = (int)luaL_checkinteger(L,2); Vector2i* res = new Vector2i(0,0); @@ -97,9 +95,9 @@ int Vector2i__div(lua_State* L) int Vector2i__add(lua_State* L) { Vector2i* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2i* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); Vector2i* res = new Vector2i(0,0); (*res) = (*lhs) + (*rhs); @@ -111,9 +109,9 @@ int Vector2i__add(lua_State* L) int Vector2i__sub(lua_State* L) { Vector2i* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2i* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); Vector2i* res = new Vector2i(0,0); (*res) = (*lhs) - (*rhs); @@ -125,9 +123,9 @@ int Vector2i__sub(lua_State* L) int Vector2i__eq(lua_State* L) { Vector2i* lhs = LuaType::check(L,1); - LUACHECKOBJ(lhs); + RMLUI_CHECK_OBJ(lhs); Vector2i* rhs = LuaType::check(L,2); - LUACHECKOBJ(rhs); + RMLUI_CHECK_OBJ(rhs); lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0); return 1; @@ -136,7 +134,7 @@ int Vector2i__eq(lua_State* L) int Vector2iGetAttrx(lua_State*L) { Vector2i* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushinteger(L,self->x); return 1; @@ -145,7 +143,7 @@ int Vector2iGetAttrx(lua_State*L) int Vector2iGetAttry(lua_State*L) { Vector2i* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushinteger(L,self->y); return 1; @@ -154,7 +152,7 @@ int Vector2iGetAttry(lua_State*L) int Vector2iGetAttrmagnitude(lua_State*L) { Vector2i* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); lua_pushnumber(L,self->Magnitude()); return 1; @@ -163,7 +161,7 @@ int Vector2iGetAttrmagnitude(lua_State*L) int Vector2iSetAttrx(lua_State*L) { Vector2i* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); int value = (int)luaL_checkinteger(L,2); self->x = value; @@ -173,7 +171,7 @@ int Vector2iSetAttrx(lua_State*L) int Vector2iSetAttry(lua_State*L) { Vector2i* self = LuaType::check(L,1); - LUACHECKOBJ(self); + RMLUI_CHECK_OBJ(self); int value = (int)luaL_checkinteger(L,2); self->y = value; @@ -181,7 +179,6 @@ int Vector2iSetAttry(lua_State*L) } - RegType Vector2iMethods[] = { { nullptr, nullptr }, @@ -189,21 +186,20 @@ RegType Vector2iMethods[] = luaL_Reg Vector2iGetters[]= { - LUAGETTER(Vector2i,x) - LUAGETTER(Vector2i,y) - LUAGETTER(Vector2i,magnitude) + RMLUI_LUAGETTER(Vector2i,x) + RMLUI_LUAGETTER(Vector2i,y) + RMLUI_LUAGETTER(Vector2i,magnitude) { nullptr, nullptr }, }; luaL_Reg Vector2iSetters[]= { - LUASETTER(Vector2i,x) - LUASETTER(Vector2i,y) + RMLUI_LUASETTER(Vector2i,x) + RMLUI_LUASETTER(Vector2i,y) { nullptr, nullptr }, }; -LUACORETYPEDEFINE(Vector2i) +RMLUI_LUATYPE_DEFINE(Vector2i) -} -} -} \ No newline at end of file +} // namespace Lua +} // namespace Rml diff --git a/Source/Core/Lua/Vector2i.h b/Source/Lua/Vector2i.h similarity index 90% rename from Source/Core/Lua/Vector2i.h rename to Source/Lua/Vector2i.h index 2f6575150..acfdc65b7 100644 --- a/Source/Core/Lua/Vector2i.h +++ b/Source/Lua/Vector2i.h @@ -26,16 +26,14 @@ * */ -#ifndef RMLUICORELUAVECTOR2I_H -#define RMLUICORELUAVECTOR2I_H +#ifndef RMLUI_LUA_VECTOR2I_H +#define RMLUI_LUA_VECTOR2I_H -#include -#include +#include +#include #include -using Rml::Core::Vector2i; namespace Rml { -namespace Core { namespace Lua { template<> void ExtraInit(lua_State* L, int metatable_index); int Vector2inew(lua_State* L); @@ -59,9 +57,7 @@ extern RegType Vector2iMethods[]; extern luaL_Reg Vector2iGetters[]; extern luaL_Reg Vector2iSetters[]; -LUACORETYPEDECLARE(Vector2i) -} -} -} +RMLUI_LUATYPE_DECLARE(Vector2i) +} // namespace Lua +} // namespace Rml #endif - diff --git a/changelog.md b/changelog.md index 031153282..5d0049fe6 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,44 @@ ## RmlUi 4.0 (WIP) +### Restructuring RmlUi + +RmlUi has been restructured to simplify its usage. This involves breaking changes but should benefit everyone using the library in the future. See discussion in [#58](https://github.com/mikke89/RmlUi/issues/58). + +- The old `Controls` plugin is now gone. But fear not! It has been merged into the `Core` project . +- The old `Rml::Core` and `Rml::Controls` namespaces are now located directly in the `Rml` namespace. +- The old `Controls` public header files have been moved to ``. +- The old `Controls` source files and private header files have been moved to `Source/Core/Elements/...`. +- The `Debugger` plugin remains as before at the same location and same namespace `Rml::Debugger`. + +The Lua plugins have been changed to reflect the above changes. + +- The old Lua plugins `RmlCoreLua` and `RmlControlsLua` have been merged into a single library `RmlLua`. +- The public header files are now located at ``. +- The Lua plugin is now initialized by calling `Rml::Lua::Initialise()` located in ``. +- Separated the Lua interpreter functions from initialization and the Lua plugin. +- Renamed macros in the Lua plugin, they now start with `RMLUI_`. + +Related changes. + +- Refactored slider widgets to avoid duplicate names in Core and Controls. +- Renamed header guard macros. + +#### Upgrade guide + +- Remove the call to `Rml::Controls::Initialise()`, this is no longer needed. +- Remove all inclusions of ``. In some cases it may be necessary to replace it with `` or individual header files. +- Rename all inclusions of `` to ``. +- Replace all occurrences of `Rml::Core` with `Rml`. +- Replace all occurrences of `Rml::Controls` with `Rml`. +- Remove the linkage to the `RmlControls` library. +- For users of the Lua plugin: + - Replace RmlUi's Lua header files with `` or individual header files in ``. + - Replace the old initialization calls with `Rml::Lua::Initialise()`. Previously this was `Rml::Core::Lua::Interpreter::Initialise()` and `Rml::Controls::Lua::RegisterTypes(...)`. + - Link with the library `RmlLua`, remove `RmlCoreLua` and `RmlControlsLua`. +- Welcome to RmlUi 4.0 :) + + ### Model-view-controller (MVC) implementation RmlUi now supports a model-view-controller (MVC) approach through data bindings. This is a powerful approach for making documents respond to data changes, or in reverse, updating data based on user actions. @@ -18,6 +56,9 @@ For now, this is considered an experimental feature. - See discussion in [#83](https://github.com/mikke89/RmlUi/pull/83) and [#25](https://github.com/mikke89/RmlUi/issues/25). + + + ## RmlUi 3.3 ### Rml `select` element improvements