diff -Nru mygui-3.4.2+dfsg/ChangeLog.md mygui-3.4.3+dfsg/ChangeLog.md --- mygui-3.4.2+dfsg/ChangeLog.md 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/ChangeLog.md 2023-08-06 21:45:08.000000000 +0000 @@ -1,3 +1,30 @@ +## MyGUI v3.4.3 + +### Core +- Allow passing lambdas into MyGUI::newDelegate without explicitly wrapping them into std::function + +### Widgets +- Add missing eventClipboardChanged when trying to cut/copy with no text selected +- Fixed rare crash when changing widget style after it was clicked in the same frame +- Fixed TabItem left disabled when rapidly switching between tabs +- Improve performance of the TabControl tabs switching +- Fixed ignoring "FontHeight" property when "FontName" is also set +- Move MyGUI::DEFAULT to deprecated, add TabControl::DEFAULT_WIDTH instead + +### Platforms +- Fix build with Ogre 14 + +### Tools +- Minor fixes for macOS +- Use macOS Command key in tools + +### Other +- Switch to C++17 +- Use string_view, unique_ptr and some other stuff +- Various code improvements, including range base for migration and some other minor stuff +- Add some missing MYGUI_DONT_USE_OBSOLETE checks for deprecated stuff +- Remove MYGUI_DEBUG_MODE from headers to avoid issues with mixed debug/release builds + ## MyGUI v3.4.2 ### Core - Add missing MYGUI_EXPORT for ControllerRepeatClick (was not linking in non-static builds) diff -Nru mygui-3.4.2+dfsg/.clang-format mygui-3.4.3+dfsg/.clang-format --- mygui-3.4.2+dfsg/.clang-format 1970-01-01 00:00:00.000000000 +0000 +++ mygui-3.4.3+dfsg/.clang-format 2023-08-06 21:45:08.000000000 +0000 @@ -0,0 +1,85 @@ +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: None +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Inline +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeConceptDeclarations: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +BreakStringLiterals: true +ColumnLimit: 120 +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +EmptyLineBeforeAccessModifier: LogicalBlock +FixNamespaceComments: false +IncludeBlocks: Preserve +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: NoIndent +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +IndentRequires: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +PackConstructorInitializers: Never +PenaltyIndentedWhitespace: 1 +PenaltyReturnTypeOnItsOwnLine: 1000 +PointerAlignment: Left +ReflowComments: false +SortIncludes: Never +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Latest +TabWidth: 4 +UseTab: Always diff -Nru mygui-3.4.2+dfsg/.clang-tidy mygui-3.4.3+dfsg/.clang-tidy --- mygui-3.4.2+dfsg/.clang-tidy 1970-01-01 00:00:00.000000000 +0000 +++ mygui-3.4.3+dfsg/.clang-tidy 2023-08-06 21:45:08.000000000 +0000 @@ -0,0 +1,87 @@ +Checks: '\ + -*,\ # definitely good checks + modernize-*,\ + performance-*,\ + readability-*,\ + cppcoreguidelines-*,\ + hicpp-*,\ + google-*,\ + bugprone-*,\ + \ # intentionally disabled checks (sorted alphabetically) + -bugprone-branch-clone,\ + -bugprone-easily-swappable-parameters,\ + -bugprone-exception-escape,\ # TODO? + -bugprone-implicit-widening-of-multiplication-result,\ # TODO? + -bugprone-macro-parentheses,\ + -bugprone-misplaced-widening-cast,\ + -bugprone-narrowing-conversions,\ + -bugprone-reserved-identifier,\ + -bugprone-signed-char-misuse,\ # TODO? + -cppcoreguidelines-avoid-c-arrays,\ + -cppcoreguidelines-avoid-const-or-ref-data-members,\ + -cppcoreguidelines-avoid-do-while,\ + -cppcoreguidelines-avoid-magic-numbers,\ + -cppcoreguidelines-avoid-non-const-global-variables,\ + -cppcoreguidelines-c-copy-assignment-signature,\ + -cppcoreguidelines-init-variables,\ + -cppcoreguidelines-macro-usage,\ + -cppcoreguidelines-narrowing-conversions,\ + -cppcoreguidelines-non-private-member-variables-in-classes,\ + -cppcoreguidelines-owning-memory,\ # TODO + -cppcoreguidelines-prefer-member-initializer,\ + -cppcoreguidelines-pro-bounds-constant-array-index,\ + -cppcoreguidelines-pro-bounds-array-to-pointer-decay,\ # false positive? + -cppcoreguidelines-pro-bounds-pointer-arithmetic,\ + -cppcoreguidelines-pro-type-const-cast,\ + -cppcoreguidelines-pro-type-cstyle-cast,\ + -cppcoreguidelines-pro-type-member-init,\ + -cppcoreguidelines-pro-type-reinterpret-cast,\ + -cppcoreguidelines-pro-type-static-cast-downcast,\ + -cppcoreguidelines-pro-type-union-access,\ + -cppcoreguidelines-pro-type-vararg,\ + -cppcoreguidelines-special-member-functions,\ # TODO (mostly fixed) + -cppcoreguidelines-virtual-class-destructor,\ + -google-explicit-constructor,\ + -google-readability-braces-around-statements,\ + -google-readability-casting,\ + -google-readability-namespace-comments,\ + -google-readability-todo,\ + -google-runtime-int,\ # TODO + -google-default-arguments,\ + -hicpp-special-member-functions,\ + -hicpp-braces-around-statements,\ + -hicpp-explicit-conversions,\ + -hicpp-use-auto,\ + -hicpp-uppercase-literal-suffix,\ + -hicpp-avoid-c-arrays,\ + -hicpp-member-init,-hicpp-vararg,\ + -hicpp-no-array-decay,\ + -hicpp-signed-bitwise,\ + -modernize-pass-by-value,\ + -modernize-use-auto,\ + -modernize-use-nodiscard,\ + -modernize-use-trailing-return-type,\ + -performance-unnecessary-value-param,\ + -readability-braces-around-statements,\ + -readability-convert-member-functions-to-static,\ + -readability-function-cognitive-complexity,\ + -readability-identifier-length,\ + -readability-implicit-bool-conversion,\ + -readability-magic-numbers,\ + -readability-redundant-access-specifiers,\ + -readability-suspicious-call-argument,\ + -readability-uppercase-literal-suffix,\ + \ # TODO + -modernize-avoid-c-arrays,\ + -readability-use-anyofallof,\ + ' + +WarningsAsErrors: "*" +HeaderFilterRegex: '.*' +FormatStyle: file +UseColor: true +CheckOptions: + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: 1 + - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted + value: 1 diff -Nru mygui-3.4.2+dfsg/.clang-tidy-ignore mygui-3.4.3+dfsg/.clang-tidy-ignore --- mygui-3.4.2+dfsg/.clang-tidy-ignore 1970-01-01 00:00:00.000000000 +0000 +++ mygui-3.4.3+dfsg/.clang-tidy-ignore 2023-08-06 21:45:08.000000000 +0000 @@ -0,0 +1,2 @@ +*/include/GL/* +*/pugixml.* diff -Nru mygui-3.4.2+dfsg/CMake/ConfigureBuild.cmake mygui-3.4.3+dfsg/CMake/ConfigureBuild.cmake --- mygui-3.4.2+dfsg/CMake/ConfigureBuild.cmake 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMake/ConfigureBuild.cmake 2023-08-06 21:45:08.000000000 +0000 @@ -54,7 +54,3 @@ # configure additional packages endif () - -if (MYGUI_STANDALONE_BUILD) - set(CMAKE_SUPPRESS_REGENERATION true) -endif() diff -Nru mygui-3.4.2+dfsg/CMake/Packages/FindDirectX11.cmake mygui-3.4.3+dfsg/CMake/Packages/FindDirectX11.cmake --- mygui-3.4.2+dfsg/CMake/Packages/FindDirectX11.cmake 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMake/Packages/FindDirectX11.cmake 2023-08-06 21:45:08.000000000 +0000 @@ -5,37 +5,32 @@ # DirectX_INCLUDE_DIR # DirectX_LIBRARY -if (MYGUI_STANDALONE_BUILD) - SET(DirectX11_LIBRARIES "d3d11.lib d3dx11.lib DxErr.lib dxguid.lib dxgi.lib d3dcompiler.lib" CACHE STRING "") - SET(DirectX11_FOUND TRUE) -else() - if(WIN32) # The only platform it makes sense to check for DirectX11 SDK - include(FindPkgMacros) - include(FindDirectX) - findpkg_begin(DirectX11) +if(WIN32) # The only platform it makes sense to check for DirectX11 SDK + include(FindPkgMacros) + include(FindDirectX) + findpkg_begin(DirectX11) - if(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x64") - else(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x86") - endif(CMAKE_CL_64) + if(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x64") + else(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x86") + endif(CMAKE_CL_64) - find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXERR_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_COMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXERR_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_COMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - findpkg_finish(DirectX11) - set(DirectX11_LIBRARIES ${DirectX11_LIBRARIES} - ${DirectX11_D3D11_LIBRARY} - ${DirectX11_D3DX11_LIBRARY} - ${DirectX11_DXGI_LIBRARY} - ${DirectX11_DXGUID_LIBRARY} - ${DirectX11_DXERR_LIBRARY} - ${DirectX11_COMPILER_LIBRARY} - ) + findpkg_finish(DirectX11) + set(DirectX11_LIBRARIES ${DirectX11_LIBRARIES} + ${DirectX11_D3D11_LIBRARY} + ${DirectX11_D3DX11_LIBRARY} + ${DirectX11_DXGI_LIBRARY} + ${DirectX11_DXGUID_LIBRARY} + ${DirectX11_DXERR_LIBRARY} + ${DirectX11_COMPILER_LIBRARY} + ) - endif(WIN32) -endif () +endif(WIN32) diff -Nru mygui-3.4.2+dfsg/CMake/Packages/FindDirectX.cmake mygui-3.4.3+dfsg/CMake/Packages/FindDirectX.cmake --- mygui-3.4.2+dfsg/CMake/Packages/FindDirectX.cmake 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMake/Packages/FindDirectX.cmake 2023-08-06 21:45:08.000000000 +0000 @@ -5,130 +5,119 @@ # DirectX_INCLUDE_DIR # DirectX_LIBRARY -if (MYGUI_STANDALONE_BUILD) - SET(DirectX_INCLUDE_DIR "C:/MYGUIHACK DXSDK_DIR MYGUIBRACKETHACK/include" CACHE STRING "") - SET(DirectX_LIBRARIES "d3d9.lib d3dx9.lib DxErr.lib dxguid.lib" CACHE STRING "") - SET(DIRECTX_LIB_DIR "C:/MYGUIHACK DXSDK_DIR MYGUIBRACKETHACK/lib/x86" CACHE STRING "") - SET(DirectX_FOUND TRUE) - SET(DirectX11_INCLUDE_DIR "C:/MYGUIHACK DXSDK_DIR MYGUIBRACKETHACK/include" CACHE STRING "") - SET(DirectX11_LIBRARIES "d3d11.lib d3dx11.lib DxErr.lib dxguid.lib dxgi.lib d3dcompiler.lib" CACHE STRING "") - SET(DIRECTX11_LIB_DIR "C:/MYGUIHACK DXSDK_DIR MYGUIBRACKETHACK/lib/x86" CACHE STRING "") - SET(DirectX11_FOUND TRUE) -else() - IF (NOT DIRECTX_DIR) - set(DIRECTX_DIR "" CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)") - ENDIF () - - if(WIN32) # The only platform it makes sense to check for DirectX SDK - include(FindPkgMacros) - findpkg_begin(DirectX) - - # Get path, convert backslashes as ${ENV_DXSDK_DIR} - getenv_path(DXSDK_DIR) - - # construct search paths - set(DirectX_PREFIX_PATH - "${DIRECTX_DIR}" - "${DXSDK_DIR}" - "${ENV_DXSDK_DIR}" - "C:/apps_x86/Microsoft DirectX SDK*" - "C:/Program Files (x86)/Microsoft DirectX SDK*" - "C:/apps/Microsoft DirectX SDK*" - "C:/Program Files/Microsoft DirectX SDK*" - "$ENV{ProgramFiles}/Microsoft DirectX SDK*" - ) - create_search_paths(DirectX) - # redo search if prefix path changed - clear_if_changed(DirectX_PREFIX_PATH - DirectX_LIBRARY - DirectX_INCLUDE_DIR - ) - - find_path(DirectX_INCLUDE_DIR NAMES d3d9.h HINTS ${DirectX_INC_SEARCH_PATH}) - # dlls are in DIRECTX_DIR/Developer Runtime/x64|x86 - # lib files are in DIRECTX_DIR/Lib/x64|x86 - if(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x64") - else(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x86") - endif(CMAKE_CL_64) - find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX_DXERR9_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - - if(DirectX_INCLUDE_DIR) - if (NOT DIRECTX_DIR) - set(DIRECTX_DIR ${DirectX_INCLUDE_DIR}/.. CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)" FORCE) - endif () - endif(DirectX_INCLUDE_DIR) - - - findpkg_finish(DirectX) - set(DirectX_LIBRARIES ${DirectX_LIBRARIES} - ${DirectX_D3DX9_LIBRARY} - ${DirectX_DXERR9_LIBRARY} - ${DirectX_DXGUID_LIBRARY} - ) - - endif(WIN32) - - - if(WIN32) # The only platform it makes sense to check for DirectX11 SDK - include(FindPkgMacros) - findpkg_begin(DirectX11) - - # Get path, convert backslashes as ${ENV_DXSDK_DIR} - getenv_path(DXSDK_DIR) - - # construct search paths - set(DirectX_PREFIX_PATH - "${DIRECTX_DIR}" - "${DXSDK_DIR}" - "${ENV_DXSDK_DIR}" - "C:/apps_x86/Microsoft DirectX SDK*" - "C:/Program Files (x86)/Microsoft DirectX SDK*" - "C:/apps/Microsoft DirectX SDK*" - "C:/Program Files/Microsoft DirectX SDK*" - "$ENV{ProgramFiles}/Microsoft DirectX SDK*" - ) - create_search_paths(DirectX) - # redo search if prefix path changed - clear_if_changed(DirectX_PREFIX_PATH - DirectX11_LIBRARY - DirectX11_INCLUDE_DIR - ) - - find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS ${DirectX_INC_SEARCH_PATH}) - # dlls are in DIRECTX_DIR/Developer Runtime/x64|x86 - # lib files are in DIRECTX_DIR/Lib/x64|x86 - if(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x64") - else(CMAKE_CL_64) - set(DirectX_LIBPATH_SUFFIX "x86") - endif(CMAKE_CL_64) - find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_DXERR_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - find_library(DirectX11_COMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) - - if(DirectX11_INCLUDE_DIR) - if (NOT DIRECTX_DIR) - set(DIRECTX_DIR ${DirectX11_INCLUDE_DIR}/.. CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)" FORCE) - endif () - endif(DirectX11_INCLUDE_DIR) - - findpkg_finish(DirectX11) - set(DirectX11_LIBRARIES ${DirectX11_LIBRARIES} - ${DirectX11_D3D11_LIBRARY} - ${DirectX11_D3DX11_LIBRARY} - ${DirectX11_DXGI_LIBRARY} - ${DirectX11_DXGUID_LIBRARY} - ${DirectX11_DXERR_LIBRARY} - ${DirectX11_COMPILER_LIBRARY} - ) +IF (NOT DIRECTX_DIR) + set(DIRECTX_DIR "" CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)") +ENDIF () + +if(WIN32) # The only platform it makes sense to check for DirectX SDK + include(FindPkgMacros) + findpkg_begin(DirectX) + + # Get path, convert backslashes as ${ENV_DXSDK_DIR} + getenv_path(DXSDK_DIR) + + # construct search paths + set(DirectX_PREFIX_PATH + "${DIRECTX_DIR}" + "${DXSDK_DIR}" + "${ENV_DXSDK_DIR}" + "C:/apps_x86/Microsoft DirectX SDK*" + "C:/Program Files (x86)/Microsoft DirectX SDK*" + "C:/apps/Microsoft DirectX SDK*" + "C:/Program Files/Microsoft DirectX SDK*" + "$ENV{ProgramFiles}/Microsoft DirectX SDK*" + ) + create_search_paths(DirectX) + # redo search if prefix path changed + clear_if_changed(DirectX_PREFIX_PATH + DirectX_LIBRARY + DirectX_INCLUDE_DIR + ) + + find_path(DirectX_INCLUDE_DIR NAMES d3d9.h HINTS ${DirectX_INC_SEARCH_PATH}) + # dlls are in DIRECTX_DIR/Developer Runtime/x64|x86 + # lib files are in DIRECTX_DIR/Lib/x64|x86 + if(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x64") + else(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x86") + endif(CMAKE_CL_64) + find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX_DXERR9_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + + if(DirectX_INCLUDE_DIR) + if (NOT DIRECTX_DIR) + set(DIRECTX_DIR ${DirectX_INCLUDE_DIR}/.. CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)" FORCE) + endif () + endif(DirectX_INCLUDE_DIR) + + + findpkg_finish(DirectX) + set(DirectX_LIBRARIES ${DirectX_LIBRARIES} + ${DirectX_D3DX9_LIBRARY} + ${DirectX_DXERR9_LIBRARY} + ${DirectX_DXGUID_LIBRARY} + ) + +endif(WIN32) + + +if(WIN32) # The only platform it makes sense to check for DirectX11 SDK + include(FindPkgMacros) + findpkg_begin(DirectX11) + + # Get path, convert backslashes as ${ENV_DXSDK_DIR} + getenv_path(DXSDK_DIR) + + # construct search paths + set(DirectX_PREFIX_PATH + "${DIRECTX_DIR}" + "${DXSDK_DIR}" + "${ENV_DXSDK_DIR}" + "C:/apps_x86/Microsoft DirectX SDK*" + "C:/Program Files (x86)/Microsoft DirectX SDK*" + "C:/apps/Microsoft DirectX SDK*" + "C:/Program Files/Microsoft DirectX SDK*" + "$ENV{ProgramFiles}/Microsoft DirectX SDK*" + ) + create_search_paths(DirectX) + # redo search if prefix path changed + clear_if_changed(DirectX_PREFIX_PATH + DirectX11_LIBRARY + DirectX11_INCLUDE_DIR + ) + + find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS ${DirectX_INC_SEARCH_PATH}) + # dlls are in DIRECTX_DIR/Developer Runtime/x64|x86 + # lib files are in DIRECTX_DIR/Lib/x64|x86 + if(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x64") + else(CMAKE_CL_64) + set(DirectX_LIBPATH_SUFFIX "x86") + endif(CMAKE_CL_64) + find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_DXERR_LIBRARY NAMES dxerr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + find_library(DirectX11_COMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX}) + + if(DirectX11_INCLUDE_DIR) + if (NOT DIRECTX_DIR) + set(DIRECTX_DIR ${DirectX11_INCLUDE_DIR}/.. CACHE PATH "Path to DirectX SDK (set it if you don't have DIrectX SDK properly installed or CMake can't find path to it)" FORCE) + endif () + endif(DirectX11_INCLUDE_DIR) + + findpkg_finish(DirectX11) + set(DirectX11_LIBRARIES ${DirectX11_LIBRARIES} + ${DirectX11_D3D11_LIBRARY} + ${DirectX11_D3DX11_LIBRARY} + ${DirectX11_DXGI_LIBRARY} + ${DirectX11_DXGUID_LIBRARY} + ${DirectX11_DXERR_LIBRARY} + ${DirectX11_COMPILER_LIBRARY} + ) - endif(WIN32) -endif () \ No newline at end of file +endif(WIN32) diff -Nru mygui-3.4.2+dfsg/CMake/Packages/FindOGRE_Old.cmake mygui-3.4.3+dfsg/CMake/Packages/FindOGRE_Old.cmake --- mygui-3.4.2+dfsg/CMake/Packages/FindOGRE_Old.cmake 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMake/Packages/FindOGRE_Old.cmake 2023-08-06 21:45:08.000000000 +0000 @@ -11,143 +11,133 @@ if (NOT OGRE_FOUND) # Then try everything else - if (MYGUI_STANDALONE_BUILD) - CMAKE_POLICY(PUSH) - SET(OGRE_INCLUDE_DIR "C:/MYGUIHACK OGRE_HOME MYGUIBRACKETHACK/include" "C:/MYGUIHACK OGRE_SRC MYGUIBRACKETHACK/OgreMain/include" "C:/MYGUIHACK OGRE_HOME MYGUIBRACKETHACK/include/OGRE" "C:/MYGUIHACK OGRE_HOME MYGUIBRACKETHACK/boost_1_42" CACHE STRING "") - SET(OGRE_LIBRARIES "debug;OgreMain_d;optimized;OgreMain" CACHE STRING "") - SET(OGRE_LIB_DIR "C:/MYGUIHACK OGRE_HOME MYGUIBRACKETHACK/lib" "C:/MYGUIHACK OGRE_SRC MYGUIBRACKETHACK/lib" "C:/MYGUIHACK OGRE_HOME MYGUIBRACKETHACK/boost_1_42/lib" CACHE STRING "") - SET(OGRE_FOUND TRUE) - CMAKE_POLICY(POP) - else() + IF (NOT OGRE_SOURCE_DIR) + set(OGRE_SOURCE_DIR "" CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") + ENDIF () + + if (NOT OGRE_BUILD) + set(OGRE_BUILD ${OGRE_SOURCE_DIR} CACHE PATH "Path to Ogre build directory (same as OGRE_SOURCE_DIR by default)") + endif () - IF (NOT OGRE_SOURCE_DIR) - set(OGRE_SOURCE_DIR "" CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") - ENDIF () - - if (NOT OGRE_BUILD) - set(OGRE_BUILD ${OGRE_SOURCE_DIR} CACHE PATH "Path to Ogre build directory (same as OGRE_SOURCE_DIR by default)") - endif () + if (NOT ${OGRE_SOURCE_DIR} STREQUAL "") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OGRE_SOURCE_DIR}/CMake ${OGRE_SOURCE_DIR}/CMake/Packages) + endif() - if (NOT ${OGRE_SOURCE_DIR} STREQUAL "") - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OGRE_SOURCE_DIR}/CMake ${OGRE_SOURCE_DIR}/CMake/Packages) - endif() + if (NOT (WIN32 OR APPLE)) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /usr/lib/OGRE/cmake/ /usr/local/lib/OGRE/cmake /usr/share/OGRE/cmake/modules /usr/local/share/OGRE/cmake/modules) + endif() - if (NOT (WIN32 OR APPLE)) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /usr/lib/OGRE/cmake/ /usr/local/lib/OGRE/cmake /usr/share/OGRE/cmake/modules /usr/local/share/OGRE/cmake/modules) - endif() + if (EXISTS ${OGRE_SOURCE_DIR}/CMake) + MESSAGE(STATUS "Original FindOGRE.cmake found in OGRE_SOURCE_DIR, trying to use it") + set (OGRE_HOME ${OGRE_SOURCE_DIR}) + FIND_PACKAGE(OGRE) + else() + FIND_PACKAGE(OGRE) + endif() - if (EXISTS ${OGRE_SOURCE_DIR}/CMake) - MESSAGE(STATUS "Original FindOGRE.cmake found in OGRE_SOURCE_DIR, trying to use it") - set (OGRE_HOME ${OGRE_SOURCE_DIR}) - FIND_PACKAGE(OGRE) + if (OGRE_FOUND) + MESSAGE(STATUS "Ogre was found with it's own CMake script") + + set(BOOST_ROOT ${BOOST_ROOT} CACHE PATH "Path to Boost (required if Ogre was built with boost)") + FIND_PACKAGE(Boost) + + if (Boost_FOUND) + set (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) + set (OGRE_LIB_DIR ${OGRE_LIB_DIR} ${Boost_LIBRARY_DIRS} ${BOOST_LIBRARYDIR}) else() - FIND_PACKAGE(OGRE) + # trying to get boost from OGRE_SOURCE_DIR + set (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} ${OGRE_SOURCE_DIR}/boost) + set (OGRE_LIB_DIR ${OGRE_LIB_DIR} ${OGRE_SOURCE_DIR}/boost/lib) endif() - if (OGRE_FOUND) - MESSAGE(STATUS "Ogre was found with it's own CMake script") - - set(BOOST_ROOT ${BOOST_ROOT} CACHE PATH "Path to Boost (required if Ogre was built with boost)") - FIND_PACKAGE(Boost) - - if (Boost_FOUND) - set (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) - set (OGRE_LIB_DIR ${OGRE_LIB_DIR} ${Boost_LIBRARY_DIRS} ${BOOST_LIBRARYDIR}) - else() - # trying to get boost from OGRE_SOURCE_DIR - set (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} ${OGRE_SOURCE_DIR}/boost) - set (OGRE_LIB_DIR ${OGRE_LIB_DIR} ${OGRE_SOURCE_DIR}/boost/lib) - endif() - - #add_definitions("-DBOOST_ALL_NO_LIB") - - return() - endif () - - # now trying to find it by our script - CMAKE_POLICY(PUSH) - - IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) - SET(OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent - ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) - - IF (WIN32) #Windows - MESSAGE(STATUS "Looking for OGRE") - SET(OGRESDK $ENV{OGRE_HOME}) - SET(OGRESOURCE $ENV{OGRE_SRC}) - IF (OGRE_SOURCE_DIR) - MESSAGE(STATUS "Using OGRE built from source (from specified path)") - SET(OGRE_INCLUDE_DIR ${OGRE_SOURCE_DIR}/OgreMain/include ${OGRE_SOURCE_DIR}/include) - SET(OGRE_LIB_DIR ${OGRE_SOURCE_DIR}/lib) - ELSEIF (OGRESDK) - MESSAGE(STATUS "Using OGRE SDK") - STRING(REGEX REPLACE "[\\]" "/" OGRESDK "${OGRESDK}") - SET(OGRE_INCLUDE_DIR ${OGRESDK}/include/OGRE ${OGRESDK}/include) - SET(OGRE_LIB_DIR ${OGRESDK}/lib) - IF (NOT OGRE_SOURCE_DIR) - set(OGRE_SOURCE_DIR $ENV{OGRE_HOME} CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") - ENDIF () - ELSEIF (OGRESOURCE) - MESSAGE(STATUS "Using OGRE built from source") - SET(OGRE_INCLUDE_DIR $ENV{OGRE_SRC}/OgreMain/include ${OGRE_SOURCE_DIR}/include) - SET(OGRE_LIB_DIR $ENV{OGRE_SRC}/lib) - IF (NOT OGRE_SOURCE_DIR) - set(OGRE_SOURCE_DIR $ENV{OGRE_SRC} CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") - ENDIF () - ENDIF () + #add_definitions("-DBOOST_ALL_NO_LIB") - IF (OGRESDK OR OGRESOURCE OR OGRE_SOURCE_DIR) - SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain) + return() + endif () - SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "") - SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "") - SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "") + # now trying to find it by our script + CMAKE_POLICY(PUSH) + + IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) + SET(OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent + ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR) + + IF (WIN32) #Windows + MESSAGE(STATUS "Looking for OGRE") + SET(OGRESDK $ENV{OGRE_HOME}) + SET(OGRESOURCE $ENV{OGRE_SRC}) + IF (OGRE_SOURCE_DIR) + MESSAGE(STATUS "Using OGRE built from source (from specified path)") + SET(OGRE_INCLUDE_DIR ${OGRE_SOURCE_DIR}/OgreMain/include ${OGRE_SOURCE_DIR}/include) + SET(OGRE_LIB_DIR ${OGRE_SOURCE_DIR}/lib) + ELSEIF (OGRESDK) + MESSAGE(STATUS "Using OGRE SDK") + STRING(REGEX REPLACE "[\\]" "/" OGRESDK "${OGRESDK}") + SET(OGRE_INCLUDE_DIR ${OGRESDK}/include/OGRE ${OGRESDK}/include) + SET(OGRE_LIB_DIR ${OGRESDK}/lib) + IF (NOT OGRE_SOURCE_DIR) + set(OGRE_SOURCE_DIR $ENV{OGRE_HOME} CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") ENDIF () - ELSE (WIN32) #Unix - IF (OGRE_SOURCE_DIR) - MESSAGE(STATUS "Using OGRE built from source (from specified path)") - SET(OGRE_INCLUDE_DIR ${OGRE_SOURCE_DIR}/OgreMain/include) - SET(OGRE_LIB_DIR ${OGRE_SOURCE_DIR}/lib) - ELSE () - CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) - FIND_PACKAGE(PkgConfig) - PKG_SEARCH_MODULE(OGRE OGRE) - SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS}) - SET(OGRE_LIB_DIR ${OGRE_LIBDIR}) + ELSEIF (OGRESOURCE) + MESSAGE(STATUS "Using OGRE built from source") + SET(OGRE_INCLUDE_DIR $ENV{OGRE_SRC}/OgreMain/include ${OGRE_SOURCE_DIR}/include) + SET(OGRE_LIB_DIR $ENV{OGRE_SRC}/lib) + IF (NOT OGRE_SOURCE_DIR) + set(OGRE_SOURCE_DIR $ENV{OGRE_SRC} CACHE PATH "Path to Ogre sources (set it if you don't have OGRE_HOME or OGRE_SRC environment variables)") ENDIF () + ENDIF () + + IF (OGRESDK OR OGRESOURCE OR OGRE_SOURCE_DIR) + SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain) SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "") SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "") SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "") - ENDIF (WIN32) + ENDIF () + ELSE (WIN32) #Unix + IF (OGRE_SOURCE_DIR) + MESSAGE(STATUS "Using OGRE built from source (from specified path)") + SET(OGRE_INCLUDE_DIR ${OGRE_SOURCE_DIR}/OgreMain/include) + SET(OGRE_LIB_DIR ${OGRE_SOURCE_DIR}/lib) + ELSE () + CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) + FIND_PACKAGE(PkgConfig) + PKG_SEARCH_MODULE(OGRE OGRE) + SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS}) + SET(OGRE_LIB_DIR ${OGRE_LIBDIR}) + ENDIF () - # compatibility with CMakeConfig script - SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} ${OGRE_LIBRARY_DIRS}) + SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "") + SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "") + SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "") + ENDIF (WIN32) - IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES) - SET(OGRE_FOUND TRUE) - ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES) - - IF (OGRE_FOUND) - # compatibility with CMakeConfig script - IF(NOT OGRE_CONFIG_DIR) - IF(WIN32) - SET(OGRE_CONFIG_DIR "${OGRE_MEDIA_DIR}/../bin/") - ELSE() - SET(OGRE_CONFIG_DIR "${OGRE_MEDIA_DIR}/../") - ENDIF() + # compatibility with CMakeConfig script + SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} ${OGRE_LIBRARY_DIRS}) + + IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES) + SET(OGRE_FOUND TRUE) + ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES) + + IF (OGRE_FOUND) + # compatibility with CMakeConfig script + IF(NOT OGRE_CONFIG_DIR) + IF(WIN32) + SET(OGRE_CONFIG_DIR "${OGRE_MEDIA_DIR}/../bin/") + ELSE() + SET(OGRE_CONFIG_DIR "${OGRE_MEDIA_DIR}/../") ENDIF() + ENDIF() - IF (NOT OGRE_FIND_QUIETLY) - MESSAGE(STATUS " libraries : ${OGRE_LIBRARIES} from ${OGRE_LIB_DIR}") - MESSAGE(STATUS " includes : ${OGRE_INCLUDE_DIR}") - ENDIF (NOT OGRE_FIND_QUIETLY) - ELSE (OGRE_FOUND) - IF (OGRE_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find OGRE") - ENDIF (OGRE_FIND_REQUIRED) - ENDIF (OGRE_FOUND) - CMAKE_POLICY(POP) - endif() + IF (NOT OGRE_FIND_QUIETLY) + MESSAGE(STATUS " libraries : ${OGRE_LIBRARIES} from ${OGRE_LIB_DIR}") + MESSAGE(STATUS " includes : ${OGRE_INCLUDE_DIR}") + ENDIF (NOT OGRE_FIND_QUIETLY) + ELSE (OGRE_FOUND) + IF (OGRE_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find OGRE") + ENDIF (OGRE_FIND_REQUIRED) + ENDIF (OGRE_FOUND) + CMAKE_POLICY(POP) endif() diff -Nru mygui-3.4.2+dfsg/CMake/Utils/MyGUIConfigTargets.cmake mygui-3.4.3+dfsg/CMake/Utils/MyGUIConfigTargets.cmake --- mygui-3.4.2+dfsg/CMake/Utils/MyGUIConfigTargets.cmake 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMake/Utils/MyGUIConfigTargets.cmake 2023-08-06 21:45:08.000000000 +0000 @@ -335,7 +335,11 @@ include_directories(${MYGUI_SOURCE_DIR}/Tools/EditorFramework) if (${CMAKE_VERSION} VERSION_EQUAL "3.16" OR ${CMAKE_VERSION} VERSION_GREATER "3.16") - target_precompile_headers(${PROJECTNAME} PRIVATE "../../Common/Precompiled.h") + if (NOT MYGUI_CLANG_TIDY_BUILD) + target_precompile_headers(${PROJECTNAME} PRIVATE "../../Common/Precompiled.h") + else () + target_compile_options(${PROJECTNAME} PRIVATE -include "${CMAKE_CURRENT_LIST_DIR}/../../Common/Precompiled.h") + endif () endif () target_link_libraries(${PROJECTNAME} @@ -353,7 +357,11 @@ mygui_dll(${PROJECTNAME} Tools) if (${CMAKE_VERSION} VERSION_EQUAL "3.16" OR ${CMAKE_VERSION} VERSION_GREATER "3.16") - target_precompile_headers(${PROJECTNAME} PRIVATE "../../Common/Precompiled.h") + if (NOT MYGUI_CLANG_TIDY_BUILD) + target_precompile_headers(${PROJECTNAME} PRIVATE "../../Common/Precompiled.h") + else () + target_compile_options(${PROJECTNAME} PRIVATE -include "${CMAKE_CURRENT_LIST_DIR}/../../Common/Precompiled.h") + endif () endif () endfunction(mygui_tool_dll) @@ -399,12 +407,6 @@ install(FILES ${HEADER_FILES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MYGUI" ) - - if (MYGUI_HIGH_LEVEL_WARNINGS) - if (NOT MSVC) - target_compile_options(${PROJECTNAME} PRIVATE -Wno-missing-prototypes) - endif () - endif () endfunction(mygui_plugin) @@ -417,7 +419,8 @@ else (MYGUI_STATIC) if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") # add GCC visibility flags to shared library build - set_target_properties(${PROJECTNAME} PROPERTIES COMPILE_FLAGS "${MYGUI_GCC_VISIBILITY_FLAGS}") + target_compile_options(${PROJECTNAME} PRIVATE ${MYGUI_GCC_VISIBILITY_OPTIONS}) + target_compile_definitions(${PROJECTNAME} PRIVATE ${MYGUI_GCC_VISIBILITY_DEFINITIONS}) if (APPLE) # deal with Mac OS X's framework system set_target_properties(${PROJECTNAME} PROPERTIES FRAMEWORK TRUE) diff -Nru mygui-3.4.2+dfsg/CMakeLists.txt mygui-3.4.3+dfsg/CMakeLists.txt --- mygui-3.4.2+dfsg/CMakeLists.txt 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/CMakeLists.txt 2023-08-06 21:45:08.000000000 +0000 @@ -5,7 +5,7 @@ # and provide build configuration options. ###################################################################### -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.8) if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif() @@ -35,7 +35,7 @@ include(GNUInstallDirs) set(MYGUI_TEMPLATES_DIR "${MYGUI_SOURCE_DIR}/CMake/Templates") -SET(CMAKE_CXX_STANDARD 11) +SET(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS True) # Prevent CMake from adding "#pragma clang system_header" to the precompiled headers (otherwise all warnings are suppressed) set(CMAKE_PCH_PROLOGUE "") @@ -65,23 +65,9 @@ include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fvisibility=hidden MYGUI_GCC_VISIBILITY) if (MYGUI_GCC_VISIBILITY) - # determine gcc version - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE MYGUI_GCC_VERSION) - message(STATUS "Detected g++ ${MYGUI_GCC_VERSION}") - message(STATUS "Enabling GCC visibility flags") - set(MYGUI_GCC_VISIBILITY_FLAGS "-DMYGUI_GCC_VISIBILITY -fvisibility=hidden") - - # check if we can safely add -fvisibility-inlines-hidden - string(TOLOWER "${CMAKE_BUILD_TYPE}" MYGUI_BUILD_TYPE) - if (MYGUI_BUILD_TYPE STREQUAL "debug") - if(MYGUI_GCC_VERSION VERSION_LESS "4.2") - message(STATUS "Skipping -fvisibility-inlines-hidden due to possible bug in g++ < 4.2") - else() # double if because of bug in CMake 2.6 - set(MYGUI_GCC_VISIBILITY_FLAGS "${MYGUI_GCC_VISIBILITY_FLAGS} -fvisibility-inlines-hidden") - endif() - else () - set(MYGUI_GCC_VISIBILITY_FLAGS "${MYGUI_GCC_VISIBILITY_FLAGS} -fvisibility-inlines-hidden") - endif () + message(STATUS "Enabling visibility flags") + set(MYGUI_GCC_VISIBILITY_DEFINITIONS "MYGUI_GCC_VISIBILITY") + set(MYGUI_GCC_VISIBILITY_OPTIONS "-fvisibility-inlines-hidden;-fvisibility=hidden") endif (MYGUI_GCC_VISIBILITY) # Fix x64 issues on Linux @@ -163,8 +149,6 @@ cmake_dependent_option(MYGUI_INSTALL_TOOLS "Install MyGUI tools." FALSE "MYGUI_BUILD_TOOLS" FALSE) option(MYGUI_INSTALL_DOCS "Install documentation." FALSE) cmake_dependent_option(MYGUI_INSTALL_PDB "Install debug pdb files" FALSE "MSVC;NOT MYGUI_STATIC" FALSE) -option(MYGUI_STANDALONE_BUILD "Generate build files that do not reference CMake (should be used only from Scripts/prepareRelease.py)" FALSE) -MARK_AS_ADVANCED(MYGUI_STANDALONE_BUILD) option(MYGUI_GENERATE_LIST_FILES_FROM_VSPROJECT "Generate .list files from visual studio project files" FALSE) MARK_AS_ADVANCED(MYGUI_GENERATE_LIST_FILES_FROM_VSPROJECT) @@ -204,6 +188,7 @@ ) # not useful add_compile_options( + -Wno-unsafe-buffer-usage -Wno-unknown-warning-option -Wno-documentation -Wno-documentation-unknown-command @@ -221,40 +206,38 @@ -Wno-global-constructors ) else () - # TODO: the warnings below have'nt been checked for a while add_compile_options( -Wno-deprecated -Wall - -Wno-reorder -Winit-self - -Woverloaded-virtual -Wcast-qual -Wwrite-strings -Wextra -pedantic + -Wshadow ) + add_compile_options("$<$:-Wno-reorder;-Woverloaded-virtual;-Wsuggest-override>") if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_compile_definitions(-Wctor-dtor-privacy) - add_compile_definitions(-fdiagnostics-show-option) + add_compile_options(-fdiagnostics-show-option) endif () # disable some - add_compile_definitions( + add_compile_options( -Wno-unused-parameter ) - - # MyGUI_UString.h ignored from warnings because of this - add_compile_definitions(-Wshadow) endif () endif () endif () +option(MYGUI_CLANG_TIDY_BUILD "Hack some things for clang-tidy runs, f.e. disable PCH" FALSE) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # usage: # UBSAN_OPTIONS=print_stacktrace=1,suppressions=sanitizers/UBSanitizer.supp option(MYGUI_UB_SANITIZER "Compile with undefined behaviour sanitizer" FALSE) if (MYGUI_UB_SANITIZER) - add_compile_definitions(-fno-omit-frame-pointer -fno-optimize-sibling-calls) - add_compile_definitions(-fsanitize=undefined -fno-sanitize-recover=undefined) + add_compile_options("-fno-omit-frame-pointer" "-fno-optimize-sibling-calls") + add_compile_options("-fsanitize=undefined" "-fno-sanitize-recover=undefined") + link_libraries("-fsanitize=undefined") endif() # usage: @@ -262,8 +245,9 @@ # alloc_dealloc_mismatch is here due to issues with Ogre and no clear way to suppress the issue option(MYGUI_ADDRESS_SANITIZER "Compile with address sanitizer" FALSE) if (MYGUI_ADDRESS_SANITIZER) - add_compile_definitions(-fno-omit-frame-pointer -fno-optimize-sibling-calls) - add_compile_definitions(-fsanitize=address -fsanitize-address-use-after-scope) + add_compile_options("-fno-omit-frame-pointer" "-fno-optimize-sibling-calls") + add_compile_options("-fsanitize=address" "-fsanitize-address-use-after-scope") + link_libraries("-fsanitize=address") endif() endif () diff -Nru mygui-3.4.2+dfsg/Common/Base/BaseDemoManager.h mygui-3.4.3+dfsg/Common/Base/BaseDemoManager.h --- mygui-3.4.2+dfsg/Common/Base/BaseDemoManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/BaseDemoManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -14,16 +14,9 @@ namespace base { - class BaseDemoManager : - public BaseManager + class BaseDemoManager : public BaseManager { public: - BaseDemoManager() : - mInfo(nullptr), - mFocusInfo(nullptr) - { - } - diagnostic::StatisticInfo* getStatisticInfo() { return mInfo; @@ -61,24 +54,20 @@ mInfo = new diagnostic::StatisticInfo(); mFocusInfo = new diagnostic::InputFocusInfo(); - MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &BaseDemoManager::notifyFrameStartUpdateStatistic); + MyGUI::Gui::getInstance().eventFrameStart += + MyGUI::newDelegate(this, &BaseDemoManager::notifyFrameStartUpdateStatistic); } void destroyGui() override { - MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &BaseDemoManager::notifyFrameStartUpdateStatistic); + MyGUI::Gui::getInstance().eventFrameStart -= + MyGUI::newDelegate(this, &BaseDemoManager::notifyFrameStartUpdateStatistic); - if (mInfo) - { - delete mInfo; - mInfo = nullptr; - } + delete mInfo; + mInfo = nullptr; - if (mFocusInfo) - { - delete mFocusInfo; - mFocusInfo = nullptr; - } + delete mFocusInfo; + mFocusInfo = nullptr; BaseManager::destroyGui(); } @@ -95,7 +84,7 @@ time -= 1; MyGUI::MapString statistic = getStatistic(); - for (MyGUI::MapString::const_iterator info = statistic.begin(); info != statistic.end(); info ++) + for (MyGUI::MapString::const_iterator info = statistic.begin(); info != statistic.end(); info++) mInfo->change((*info).first, (*info).second); mInfo->update(); } @@ -103,8 +92,8 @@ } private: - diagnostic::StatisticInfo* mInfo; - diagnostic::InputFocusInfo* mFocusInfo; + diagnostic::StatisticInfo* mInfo{nullptr}; + diagnostic::InputFocusInfo* mFocusInfo{nullptr}; }; } diff -Nru mygui-3.4.2+dfsg/Common/Base/DirectX/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/DirectX/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/DirectX/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/DirectX/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -20,9 +20,9 @@ memset(&mD3dpp, 0, sizeof(mD3dpp)); mD3dpp.AutoDepthStencilFormat = D3DFMT_D16; mD3dpp.EnableAutoDepthStencil = TRUE; - mD3dpp.BackBufferCount = 1; + mD3dpp.BackBufferCount = 1; mD3dpp.BackBufferFormat = d3ddm.Format; - mD3dpp.BackBufferWidth = _width; + mD3dpp.BackBufferWidth = _width; mD3dpp.BackBufferHeight = _height; mD3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; mD3dpp.Windowed = _windowed; @@ -33,8 +33,12 @@ mD3dpp.hDeviceWindow = sysWMInfo.info.win.window; if (FAILED(mD3d->CreateDevice( - D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mD3dpp.hDeviceWindow, - D3DCREATE_HARDWARE_VERTEXPROCESSING, &mD3dpp, &mDevice))) + D3DADAPTER_DEFAULT, + D3DDEVTYPE_HAL, + mD3dpp.hDeviceWindow, + D3DCREATE_HARDWARE_VERTEXPROCESSING, + &mD3dpp, + &mDevice))) { return false; } @@ -76,7 +80,7 @@ { if (mIsDeviceLost) { - Sleep( 100 ); + Sleep(100); HRESULT hr; if (FAILED(hr = mDevice->TestCooperativeLevel())) @@ -89,7 +93,7 @@ if (mPlatform != nullptr) mPlatform->getRenderManagerPtr()->deviceLost(); - hr = mDevice->Reset( &mD3dpp ); + hr = mDevice->Reset(&mD3dpp); if (FAILED(hr)) return; diff -Nru mygui-3.4.2+dfsg/Common/Base/DirectX/BaseManager.h mygui-3.4.3+dfsg/Common/Base/DirectX/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/DirectX/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/DirectX/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -18,11 +18,13 @@ namespace base { - class BaseManager : - public SdlBaseManager + class BaseManager : public SdlBaseManager { public: - BaseManager() : SdlBaseManager(false) { } + BaseManager() : + SdlBaseManager(false) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; diff -Nru mygui-3.4.2+dfsg/Common/Base/DirectX11/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/DirectX11/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/DirectX11/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/DirectX11/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -12,22 +12,20 @@ { bool BaseManager::createRender(int _width, int _height, bool _windowed) { - D3D_FEATURE_LEVEL featureLevels[] = - { + D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1 - }; + D3D_FEATURE_LEVEL_9_1}; static const int numFeatureLevels = 6; D3D_FEATURE_LEVEL selectedFeatureLevel = D3D_FEATURE_LEVEL_11_0; DXGI_SWAP_CHAIN_DESC swapChainDesc; - ZeroMemory( &swapChainDesc, sizeof(swapChainDesc) ); + ZeroMemory(&swapChainDesc, sizeof(swapChainDesc)); swapChainDesc.BufferCount = 1; swapChainDesc.BufferDesc.Width = _width; swapChainDesc.BufferDesc.Height = _height; @@ -46,28 +44,29 @@ HRESULT hr = S_OK; - if (FAILED(hr = D3D11CreateDeviceAndSwapChain( - nullptr, - D3D_DRIVER_TYPE_HARDWARE, - nullptr, - 0, - featureLevels, - numFeatureLevels, - D3D11_SDK_VERSION, - &swapChainDesc, - &mSwapChain, - &mDevice, - &selectedFeatureLevel, - &mDeviceContext))) + if (FAILED( + hr = D3D11CreateDeviceAndSwapChain( + nullptr, + D3D_DRIVER_TYPE_HARDWARE, + nullptr, + 0, + featureLevels, + numFeatureLevels, + D3D11_SDK_VERSION, + &swapChainDesc, + &mSwapChain, + &mDevice, + &selectedFeatureLevel, + &mDeviceContext))) { return false; } - hr = mSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&mBackBuffer); + hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mBackBuffer); - mDevice->CreateRenderTargetView(mBackBuffer, nullptr, &mRenderTarget ); + mDevice->CreateRenderTargetView(mBackBuffer, nullptr, &mRenderTarget); - mDeviceContext->OMSetRenderTargets( 1, &mRenderTarget, nullptr ); + mDeviceContext->OMSetRenderTargets(1, &mRenderTarget, nullptr); D3D11_VIEWPORT vp; vp.Width = (float)_width; @@ -76,7 +75,7 @@ vp.MaxDepth = 1.0f; vp.TopLeftX = 0.0f; vp.TopLeftY = 0.0f; - mDeviceContext->RSSetViewports( 1, &vp ); + mDeviceContext->RSSetViewports(1, &vp); return true; } @@ -87,7 +86,8 @@ mRenderTarget->Release(); mRenderTarget = nullptr; } - if (mBackBuffer) { + if (mBackBuffer) + { mBackBuffer->Release(); mBackBuffer = nullptr; } @@ -127,7 +127,7 @@ void BaseManager::drawOneFrame() { - const float clearColor[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + const float clearColor[] = {0.0f, 0.0f, 0.0f, 1.0f}; mDeviceContext->ClearRenderTargetView(mRenderTarget, clearColor); mPlatform->getRenderManagerPtr()->drawOneFrame(); mSwapChain->Present(0, 0); @@ -144,7 +144,8 @@ mRenderTarget->Release(); mRenderTarget = nullptr; } - if (mBackBuffer) { + if (mBackBuffer) + { mBackBuffer->Release(); mBackBuffer = nullptr; } @@ -168,7 +169,7 @@ vp.MaxDepth = 1.0f; vp.TopLeftX = 0.0f; vp.TopLeftY = 0.0f; - mDeviceContext->RSSetViewports( 1, &vp ); + mDeviceContext->RSSetViewports(1, &vp); } } diff -Nru mygui-3.4.2+dfsg/Common/Base/DirectX11/BaseManager.h mygui-3.4.3+dfsg/Common/Base/DirectX11/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/DirectX11/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/DirectX11/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -21,11 +21,13 @@ namespace base { - class BaseManager : - public SdlBaseManager + class BaseManager : public SdlBaseManager { public: - BaseManager() : SdlBaseManager(false) { } + BaseManager() : + SdlBaseManager(false) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; diff -Nru mygui-3.4.2+dfsg/Common/Base/Dummy/BaseManager.h mygui-3.4.3+dfsg/Common/Base/Dummy/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/Dummy/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/Dummy/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,11 +7,13 @@ namespace base { - class BaseManager : - public SdlBaseManager + class BaseManager : public SdlBaseManager { public: - BaseManager() : SdlBaseManager(false) { } + BaseManager() : + SdlBaseManager(false) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; diff -Nru mygui-3.4.2+dfsg/Common/Base/InputFocusInfo.h mygui-3.4.3+dfsg/Common/Base/InputFocusInfo.h --- mygui-3.4.2+dfsg/Common/Base/InputFocusInfo.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/InputFocusInfo.h 2023-08-06 21:45:08.000000000 +0000 @@ -16,24 +16,21 @@ class InputFocusInfo { public: - InputFocusInfo() : - mFocusVisible(false), - mMouseHelper(nullptr), - mKeyHelper(nullptr), - mWidgetMouseFocus(nullptr), - mWidgetKeyFocus(nullptr), - mOldMouseFocus(nullptr), - mOldKeyFocus(nullptr) + InputFocusInfo() { - MyGUI::InputManager::getInstance().eventChangeMouseFocus += MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeMouseFocus); - MyGUI::InputManager::getInstance().eventChangeKeyFocus += MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeKeyFocus); + MyGUI::InputManager::getInstance().eventChangeMouseFocus += + MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeMouseFocus); + MyGUI::InputManager::getInstance().eventChangeKeyFocus += + MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeKeyFocus); MyGUI::Gui::getInstance().eventFrameStart += MyGUI::newDelegate(this, &InputFocusInfo::notifyFrameStart); } ~InputFocusInfo() { - MyGUI::InputManager::getInstance().eventChangeMouseFocus -= MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeMouseFocus); - MyGUI::InputManager::getInstance().eventChangeKeyFocus -= MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeKeyFocus); + MyGUI::InputManager::getInstance().eventChangeMouseFocus -= + MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeMouseFocus); + MyGUI::InputManager::getInstance().eventChangeKeyFocus -= + MyGUI::newDelegate(this, &InputFocusInfo::notifyChangeKeyFocus); MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &InputFocusInfo::notifyFrameStart); if (mKeyHelper != nullptr) @@ -86,22 +83,27 @@ void updateFocusWidgetHelpers(bool _updateinfo = true) { - const std::string layer = "Statistic"; - const std::string skin_mouse = "RectGreen"; - const std::string skin_key = "RectBlue"; - - if ((mWidgetMouseFocus != mOldMouseFocus) - || ((mWidgetMouseFocus != nullptr) - && (mMouseHelper != nullptr) - && mWidgetMouseFocus->getAbsoluteCoord() != mMouseHelper->getAbsoluteCoord())) + const std::string_view layer = "Statistic"; + const std::string_view skin_mouse = "RectGreen"; + const std::string_view skin_key = "RectBlue"; + + if ((mWidgetMouseFocus != mOldMouseFocus) || + ((mWidgetMouseFocus != nullptr) && (mMouseHelper != nullptr) && + mWidgetMouseFocus->getAbsoluteCoord() != mMouseHelper->getAbsoluteCoord())) { mOldMouseFocus = mWidgetMouseFocus; if (mMouseHelper == nullptr) { - if (!MyGUI::LayerManager::getInstance().isExist(layer)) return; - if (!MyGUI::SkinManager::getInstance().isExist(skin_mouse)) return; - mMouseHelper = MyGUI::Gui::getInstance().createWidget(skin_mouse, MyGUI::IntCoord(), MyGUI::Align::Default, layer); + if (!MyGUI::LayerManager::getInstance().isExist(layer)) + return; + if (!MyGUI::SkinManager::getInstance().isExist(skin_mouse)) + return; + mMouseHelper = MyGUI::Gui::getInstance().createWidget( + skin_mouse, + MyGUI::IntCoord(), + MyGUI::Align::Default, + layer); mMouseHelper->setNeedMouseFocus(false); } @@ -120,18 +122,23 @@ } } - if ((mWidgetKeyFocus != mOldKeyFocus) - || ((mWidgetKeyFocus != nullptr) - && (mKeyHelper != nullptr) - && mWidgetKeyFocus->getAbsoluteCoord() != mKeyHelper->getAbsoluteCoord())) + if ((mWidgetKeyFocus != mOldKeyFocus) || + ((mWidgetKeyFocus != nullptr) && (mKeyHelper != nullptr) && + mWidgetKeyFocus->getAbsoluteCoord() != mKeyHelper->getAbsoluteCoord())) { mOldKeyFocus = mWidgetKeyFocus; if (mKeyHelper == nullptr) { - if (!MyGUI::LayerManager::getInstance().isExist(layer)) return; - if (!MyGUI::SkinManager::getInstance().isExist(skin_key)) return; - mKeyHelper = MyGUI::Gui::getInstance().createWidget(skin_key, MyGUI::IntCoord(), MyGUI::Align::Default, layer); + if (!MyGUI::LayerManager::getInstance().isExist(layer)) + return; + if (!MyGUI::SkinManager::getInstance().isExist(skin_key)) + return; + mKeyHelper = MyGUI::Gui::getInstance().createWidget( + skin_key, + MyGUI::IntCoord(), + MyGUI::Align::Default, + layer); mKeyHelper->setNeedMouseFocus(false); } if (mWidgetKeyFocus) @@ -151,15 +158,14 @@ } private: - bool mFocusVisible; - MyGUI::Widget* mMouseHelper; - MyGUI::Widget* mKeyHelper; - - MyGUI::Widget* mWidgetMouseFocus; - MyGUI::Widget* mWidgetKeyFocus; - MyGUI::Widget* mOldMouseFocus; - MyGUI::Widget* mOldKeyFocus; - + bool mFocusVisible{false}; + MyGUI::Widget* mMouseHelper{nullptr}; + MyGUI::Widget* mKeyHelper{nullptr}; + + MyGUI::Widget* mWidgetMouseFocus{nullptr}; + MyGUI::Widget* mWidgetKeyFocus{nullptr}; + MyGUI::Widget* mOldMouseFocus{nullptr}; + MyGUI::Widget* mOldKeyFocus{nullptr}; }; } // namespace diagnostic diff -Nru mygui-3.4.2+dfsg/Common/Base/Main.h mygui-3.4.3+dfsg/Common/Base/Main.h --- mygui-3.4.2+dfsg/Common/Base/Main.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/Main.h 2023-08-06 21:45:08.000000000 +0000 @@ -11,28 +11,36 @@ #include "Precompiled.h" #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#include + #define WIN32_LEAN_AND_MEAN + #include + #include #endif #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 -# define MYGUI_APP(cls) INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT argc) { return startApp(); } + #define MYGUI_APP(cls) \ + INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT argc) \ + { \ + return startApp(); \ + } #else -# define MYGUI_APP(cls) int main(int argc, char **argv) { return startApp(); } + #define MYGUI_APP(cls) \ + int main(int argc, char** argv) \ + { \ + return startApp(); \ + } #endif #ifdef EMSCRIPTEN -#include + #include -template +template void run(void* arg) { reinterpret_cast(arg)->run(); } #endif -template +template int startApp() { try @@ -41,9 +49,9 @@ // set working directory to exe location LPSTR fileName = new CHAR[256]; GetModuleFileName(nullptr, fileName, 256); - std::string path = fileName; + std::string_view path = fileName; size_t path_directory_index = path.find_last_of('\\'); - std::string exedir = path.substr(0, path_directory_index + 1); + std::string exedir{path.substr(0, path_directory_index + 1)}; _chdir(exedir.c_str()); #endif @@ -64,9 +72,14 @@ catch (MyGUI::Exception& _e) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 - MessageBoxA( nullptr, _e.getFullDescription().c_str(), "An exception has occured", MB_OK | MB_ICONERROR | MB_TASKMODAL); + MessageBoxA( + nullptr, + _e.getFullDescription().c_str(), + "An exception has occured", + MB_OK | MB_ICONERROR | MB_TASKMODAL); #else - std::cerr << "An exception has occured" << " : " << _e.getFullDescription().c_str(); + std::cerr << "An exception has occured" + << " : " << _e.getFullDescription().c_str(); #endif throw; } diff -Nru mygui-3.4.2+dfsg/Common/Base/Ogre/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/Ogre/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/Ogre/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/Ogre/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -29,7 +29,10 @@ SDL_VERSION(&wmInfo.version) if (SDL_GetWindowWMInfo(mSdlWindow, &wmInfo) == SDL_FALSE) { - OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Couldn't get WM Info! (SDL2)", "BaseManager::createRender"); + OGRE_EXCEPT( + Ogre::Exception::ERR_INTERNAL_ERROR, + "Couldn't get WM Info! (SDL2)", + "BaseManager::createRender"); } Ogre::NameValuePairList params; @@ -131,7 +134,8 @@ void BaseManager::addResourceLocation(const std::string& _name, bool _recursive) { - Ogre::ResourceGroupManager::getSingleton().addResourceLocation(_name, "FileSystem", MyGuiResourceGroup, _recursive); + Ogre::ResourceGroupManager::getSingleton() + .addResourceLocation(_name, "FileSystem", MyGuiResourceGroup, _recursive); } void BaseManager::makeScreenShot() @@ -150,8 +154,7 @@ } file = MyGUI::utility::toString("screenshot_", ++num, ".png"); stream.open(file.c_str()); - } - while (stream.is_open()); + } while (stream.is_open()); mWindow->writeContentsToFile(file); } @@ -195,7 +198,8 @@ { mCamera->setPolygonMode(Ogre::PM_POINTS); } -#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0 +#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_VERSION < MYGUI_DEFINE_VERSION(14, 0, 0) && \ + OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0 else if (_key == MyGUI::KeyCode::F1) { mWindow->getViewport(0)->setOrientationMode(Ogre::OR_DEGREE_0, false); diff -Nru mygui-3.4.2+dfsg/Common/Base/Ogre/BaseManager.h mygui-3.4.3+dfsg/Common/Base/Ogre/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/Ogre/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/Ogre/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,11 +7,13 @@ namespace base { - class BaseManager : - public SdlBaseManager + class BaseManager : public SdlBaseManager { public: - BaseManager() : SdlBaseManager(false) { } + BaseManager() : + SdlBaseManager(false) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; @@ -25,17 +27,18 @@ MyGUI::MapString getStatistic() override; void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) override; - /*internal:*/ + /*internal:*/ Ogre::SceneManager* getSceneManager() const; Ogre::Camera* getCamera() const; Ogre::SceneNode* getCameraNode() const; static const std::string MyGuiResourceGroup; + private: MyGUI::OgrePlatform* mPlatform = nullptr; Ogre::Root* mRoot; - Ogre::Camera* mCamera; + Ogre::Camera* mCamera; Ogre::SceneNode* mCameraNode; Ogre::SceneManager* mSceneManager; Ogre::RenderWindow* mWindow; diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGL/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/OpenGL/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/OpenGL/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGL/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -71,8 +71,8 @@ { std::string fullname = MyGUI::OpenGLDataManager::getInstance().getDataPath(_filename); void* result = nullptr; - SDL_Surface *image = nullptr; - SDL_Surface *cvtImage = nullptr; // converted surface with RGBA/RGB pixel format + SDL_Surface* image = nullptr; + SDL_Surface* cvtImage = nullptr; // converted surface with RGBA/RGB pixel format image = IMG_Load(fullname.c_str()); MYGUI_ASSERT(image != nullptr, "Failed to load image: " + fullname); @@ -96,7 +96,12 @@ return result; } - void BaseManager::saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) + void BaseManager::saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) { SDL_Surface* surface = SDL_CreateRGBSurface(0, _width, _height, _format.getBytesPerPixel() * 8, 0, 0, 0, 0); std::memcpy(surface->pixels, _texture, _width * _height * _format.getBytesPerPixel()); diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGL/BaseManager.h mygui-3.4.3+dfsg/Common/Base/OpenGL/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/OpenGL/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGL/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,12 +7,13 @@ namespace base { - class BaseManager : - public SdlBaseManager, - public MyGUI::OpenGLImageLoader + class BaseManager : public SdlBaseManager, public MyGUI::OpenGLImageLoader { public: - BaseManager() : SdlBaseManager(true) { } + BaseManager() : + SdlBaseManager(true) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; @@ -21,9 +22,14 @@ void createGuiPlatform() override; void destroyGuiPlatform() override; -// /*internal:*/ + // /*internal:*/ void* loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename) override; - void saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) override; + void saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) override; private: MyGUI::OpenGLPlatform* mPlatform = nullptr; diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGL3/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/OpenGL3/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/OpenGL3/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGL3/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -71,8 +71,8 @@ { std::string fullname = MyGUI::OpenGL3DataManager::getInstance().getDataPath(_filename); void* result = nullptr; - SDL_Surface *image = nullptr; - SDL_Surface *cvtImage = nullptr; // converted surface with RGBA/RGB pixel format + SDL_Surface* image = nullptr; + SDL_Surface* cvtImage = nullptr; // converted surface with RGBA/RGB pixel format image = IMG_Load(fullname.c_str()); MYGUI_ASSERT(image != nullptr, "Failed to load image: " + fullname); @@ -96,7 +96,12 @@ return result; } - void BaseManager::saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) + void BaseManager::saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) { SDL_Surface* surface = SDL_CreateRGBSurface(0, _width, _height, _format.getBytesPerPixel() * 8, 0, 0, 0, 0); std::memcpy(surface->pixels, _texture, _width * _height * _format.getBytesPerPixel()); diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGL3/BaseManager.h mygui-3.4.3+dfsg/Common/Base/OpenGL3/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/OpenGL3/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGL3/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,12 +7,13 @@ namespace base { - class BaseManager : - public SdlBaseManager, - public MyGUI::OpenGL3ImageLoader + class BaseManager : public SdlBaseManager, public MyGUI::OpenGL3ImageLoader { public: - BaseManager() : SdlBaseManager(true) { } + BaseManager() : + SdlBaseManager(true) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; @@ -21,9 +22,14 @@ void createGuiPlatform() override; void destroyGuiPlatform() override; -// /*internal:*/ + // /*internal:*/ void* loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename) override; - void saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) override; + void saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) override; private: MyGUI::OpenGL3Platform* mPlatform = nullptr; diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGLES/BaseManager.cpp mygui-3.4.3+dfsg/Common/Base/OpenGLES/BaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/OpenGLES/BaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGLES/BaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -79,8 +79,8 @@ { std::string fullname = MyGUI::OpenGLESDataManager::getInstance().getDataPath(_filename); void* result = nullptr; - SDL_Surface *image = nullptr; - SDL_Surface *cvtImage = nullptr; // converted surface with RGBA/RGB pixel format + SDL_Surface* image = nullptr; + SDL_Surface* cvtImage = nullptr; // converted surface with RGBA/RGB pixel format image = IMG_Load(fullname.c_str()); MYGUI_ASSERT(image != nullptr, "Failed to load image: " + fullname); @@ -104,7 +104,12 @@ return result; } - void BaseManager::saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) + void BaseManager::saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) { SDL_Surface* surface = SDL_CreateRGBSurface(0, _width, _height, _format.getBytesPerPixel() * 8, 0, 0, 0, 0); std::memcpy(surface->pixels, _texture, _width * _height * _format.getBytesPerPixel()); diff -Nru mygui-3.4.2+dfsg/Common/Base/OpenGLES/BaseManager.h mygui-3.4.3+dfsg/Common/Base/OpenGLES/BaseManager.h --- mygui-3.4.2+dfsg/Common/Base/OpenGLES/BaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/OpenGLES/BaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,12 +7,13 @@ namespace base { - class BaseManager : - public SdlBaseManager, - public MyGUI::OpenGLESImageLoader + class BaseManager : public SdlBaseManager, public MyGUI::OpenGLESImageLoader { public: - BaseManager() : SdlBaseManager(true) { } + BaseManager() : + SdlBaseManager(true) + { + } bool createRender(int _width, int _height, bool _windowed) override; void destroyRender() override; void drawOneFrame() override; @@ -21,9 +22,14 @@ void createGuiPlatform() override; void destroyGuiPlatform() override; -// /*internal:*/ + // /*internal:*/ void* loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename) override; - void saveImage(int _width, int _height, MyGUI::PixelFormat _format, void* _texture, const std::string& _filename) override; + void saveImage( + int _width, + int _height, + MyGUI::PixelFormat _format, + void* _texture, + const std::string& _filename) override; private: MyGUI::OpenGLESPlatform* mPlatform = nullptr; diff -Nru mygui-3.4.2+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.cpp mygui-3.4.3+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.cpp --- mygui-3.4.2+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -6,7 +6,7 @@ namespace base { SdlBaseManager::SdlBaseManager(bool _isOpenGlWindow) : - mIsOpenGlWindow(_isOpenGlWindow) + mIsOpenGlWindow(_isOpenGlWindow) { } @@ -43,7 +43,13 @@ int left = (currDisp.w - width) / 2; int top = (currDisp.h - height) / 2; - mSdlWindow = SDL_CreateWindow("MyGUI Render Window", left, top, width, height, (mIsOpenGlWindow ? SDL_WINDOW_OPENGL : 0) | SDL_WINDOW_RESIZABLE); + mSdlWindow = SDL_CreateWindow( + "MyGUI Render Window", + left, + top, + width, + height, + (mIsOpenGlWindow ? SDL_WINDOW_OPENGL : 0) | SDL_WINDOW_RESIZABLE); if (mSdlWindow == nullptr) { std::cerr << "Failed to create SDL window."; @@ -65,8 +71,10 @@ char buf[MAX_PATH]; ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH); HINSTANCE instance = ::GetModuleHandleA(buf); - HICON hIconSmall = static_cast(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE)); - HICON hIconBig = static_cast(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 256, 256, LR_DEFAULTSIZE)); + HICON hIconSmall = + static_cast(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE)); + HICON hIconBig = + static_cast(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 256, 256, LR_DEFAULTSIZE)); if (hIconSmall) ::SendMessageA((HWND)handle, WM_SETICON, 0, (LPARAM)hIconSmall); if (hIconBig) @@ -120,15 +128,9 @@ keyReleased(mEvent.key); break; // mouse events - case SDL_MOUSEMOTION: - mouseMoved(mEvent.motion); - break; - case SDL_MOUSEBUTTONDOWN: - mousePressed(mEvent.button); - break; - case SDL_MOUSEBUTTONUP: - mouseReleased(mEvent.button); - break; + case SDL_MOUSEMOTION: mouseMoved(mEvent.motion); break; + case SDL_MOUSEBUTTONDOWN: mousePressed(mEvent.button); break; + case SDL_MOUSEBUTTONUP: mouseReleased(mEvent.button); break; case SDL_MOUSEWHEEL: mouseWheelMoved(mEvent.wheel); break; @@ -139,24 +141,14 @@ case SDL_WINDOWEVENT: switch (mEvent.window.event) { - case SDL_WINDOWEVENT_CLOSE: - mExit = true; - break; - case SDL_WINDOWEVENT_RESIZED: - _windowResized(mEvent.window.data1, mEvent.window.data2); - break; - case SDL_WINDOWEVENT_FOCUS_GAINED: - mWindowOn = true; - break; - case SDL_WINDOWEVENT_FOCUS_LOST: - mWindowOn = false; - break; - default: - break; + case SDL_WINDOWEVENT_CLOSE: mExit = true; break; + case SDL_WINDOWEVENT_RESIZED: _windowResized(mEvent.window.data1, mEvent.window.data2); break; + case SDL_WINDOWEVENT_FOCUS_GAINED: mWindowOn = true; break; + case SDL_WINDOWEVENT_FOCUS_LOST: mWindowOn = false; break; + default: break; } break; - default: - break; + default: break; } } @@ -187,7 +179,7 @@ MyGUI::xml::Document doc; if (!doc.open(std::string("resources.xml"))) - doc.getLastError(); + MYGUI_LOG(Warning, "Failed to load resources.xml: " << doc.getLastError()); MyGUI::xml::ElementPtr root = doc.getRoot(); if (root == nullptr || root->getName() != "Paths") @@ -198,7 +190,7 @@ { if (node->getName() == "Path") { - if (node->findAttribute("root") != "") + if (!node->findAttribute("root").empty()) { bool rootAttribute = MyGUI::utility::parseBool(node->findAttribute("root")); if (rootAttribute) @@ -266,10 +258,13 @@ MyGUI::IntCoord SdlBaseManager::getWindowCoord() const { - int left, top, width, height; + int left; + int top; + int width; + int height; SDL_GetWindowPosition(mSdlWindow, &left, &top); SDL_GetWindowSize(mSdlWindow, &width, &height); - return MyGUI::IntCoord(left, top, width, height); + return {left, top, width, height}; } void SdlBaseManager::setWindowCaption(const std::wstring& _text) @@ -312,7 +307,7 @@ mExit = true; return; } - else if (_key == MyGUI::KeyCode::SysRq) + if (_key == MyGUI::KeyCode::SysRq) { makeScreenShot(); return; @@ -329,30 +324,22 @@ MyGUI::InputManager::getInstance().injectKeyRelease(_key); } - void* SdlBaseManager::convertPixelData(SDL_Surface *_image, MyGUI::PixelFormat& _myGuiPixelFormat) + void* SdlBaseManager::convertPixelData(SDL_Surface* _image, MyGUI::PixelFormat& _myGuiPixelFormat) { void* ret = nullptr; - SDL_PixelFormat *format = _image->format; + SDL_PixelFormat* format = _image->format; unsigned int bpp = format->BytesPerPixel; - switch (bpp) { - case 1: - _myGuiPixelFormat = MyGUI::PixelFormat::L8; - break; - case 2: - _myGuiPixelFormat = MyGUI::PixelFormat::L8A8; - break; - case 3: - _myGuiPixelFormat = MyGUI::PixelFormat::R8G8B8; - break; - case 4: - _myGuiPixelFormat = MyGUI::PixelFormat::R8G8B8A8; - break; - default: - break; + switch (bpp) + { + case 1: _myGuiPixelFormat = MyGUI::PixelFormat::L8; break; + case 2: _myGuiPixelFormat = MyGUI::PixelFormat::L8A8; break; + case 3: _myGuiPixelFormat = MyGUI::PixelFormat::R8G8B8; break; + case 4: _myGuiPixelFormat = MyGUI::PixelFormat::R8G8B8A8; break; + default: break; } SDL_LockSurface(_image); - int pitchSrc = _image->pitch; //the length of a row of pixels in bytes + int pitchSrc = _image->pitch; //the length of a row of pixels in bytes size_t size = _image->h * pitchSrc; ret = new unsigned char[size]; unsigned char* ptr_source = (unsigned char*)_image->pixels; @@ -386,7 +373,7 @@ return mRootMedia; } - void SdlBaseManager::setResourceFilename(const std::string& _flename) + void SdlBaseManager::setResourceFilename(std::string_view _flename) { mResourceFileName = _flename; } diff -Nru mygui-3.4.2+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.h mygui-3.4.3+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.h --- mygui-3.4.2+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/PlatformBaseManager/SdlBaseManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -10,14 +10,12 @@ namespace base { - class SdlBaseManager : - public input::InputManager, - public input::PointerManager + class SdlBaseManager : public input::InputManager, public input::PointerManager { public: - SdlBaseManager(bool _isOpenGlWindow); + SdlBaseManager(bool _isOpenGlWindow); - // Block of virtual functions for specific platform implementations + // Block of virtual functions for specific platform implementations virtual bool createRender(int _width, int _height, bool _windowed) = 0; virtual void destroyRender() = 0; virtual void createGuiPlatform() = 0; @@ -25,7 +23,10 @@ virtual void drawOneFrame() = 0; virtual void resizeRender(int _width, int _height) = 0; virtual void addResourceLocation(const std::string& _name, bool _recursive = false) = 0; - virtual void makeScreenShot() { MYGUI_LOG(Warning, "makeScreenShot not implemented"); } + virtual void makeScreenShot() + { + MYGUI_LOG(Warning, "makeScreenShot not implemented"); + } bool create(int _width = 1024, int _height = 768); void destroy(); @@ -35,16 +36,23 @@ void setWindowCaption(const std::wstring& _text); const std::string& getRootMedia() const; - void setResourceFilename(const std::string& _flename); + void setResourceFilename(std::string_view _flename); - /*internal:*/ + /*internal:*/ void _windowResized(int w, int h); - virtual void prepare() { } + virtual void prepare() + { + } virtual MyGUI::MapString getStatistic(); + protected: - virtual void createScene() { } - virtual void destroyScene() { } + virtual void createScene() + { + } + virtual void destroyScene() + { + } virtual void setupResources(); @@ -63,7 +71,7 @@ virtual void setWindowCoord(const MyGUI::IntCoord& _value); virtual MyGUI::IntCoord getWindowCoord() const; - void* convertPixelData(SDL_Surface *_image, MyGUI::PixelFormat& _myGuiPixelFormat); + void* convertPixelData(SDL_Surface* _image, MyGUI::PixelFormat& _myGuiPixelFormat); protected: SDL_Window* mSdlWindow = nullptr; @@ -79,7 +87,7 @@ std::string mRootMedia; std::string mResourceFileName = "MyGUI_Core.xml"; bool mWindowOn = false; - SDL_Keycode mKeyCode; + SDL_Keycode mKeyCode; int mFpsCounter = 0; }; diff -Nru mygui-3.4.2+dfsg/Common/Base/StatisticInfo.h mygui-3.4.3+dfsg/Common/Base/StatisticInfo.h --- mygui-3.4.2+dfsg/Common/Base/StatisticInfo.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Base/StatisticInfo.h 2023-08-06 21:45:08.000000000 +0000 @@ -16,16 +16,14 @@ class StatisticInfo { public: - - StatisticInfo() : - mInfo(nullptr), - mOffset(20, 20) + StatisticInfo() { - const std::string layer = "Statistic"; + std::string_view layer = "Statistic"; if (!MyGUI::LayerManager::getInstance().isExist(layer)) return; - mInfo = MyGUI::Gui::getInstance().createWidget("TextBox", MyGUI::IntCoord(), MyGUI::Align::Default, layer); + mInfo = MyGUI::Gui::getInstance() + .createWidget("TextBox", MyGUI::IntCoord(), MyGUI::Align::Default, layer); mInfo->setTextColour(MyGUI::Colour::White); mInfo->setTextShadow(true); } @@ -39,21 +37,21 @@ } } - template - void change(const std::string& _key, const T& _value) + template + void change(std::string_view _key, const T& _value) { - for (MyGUI::VectorStringPairs::iterator iter = mParams.begin(); iter != mParams.end(); ++iter) + for (auto& param : mParams) { - if (iter->first == _key) + if (param.first == _key) { - iter->second = MyGUI::utility::toString(_value); + param.second = MyGUI::utility::toString(_value); return; } } - mParams.push_back(std::make_pair(_key, MyGUI::utility::toString(_value))); + mParams.emplace_back(_key, MyGUI::utility::toString(_value)); } - void remove(const std::string& _key) + void remove(std::string_view _key) { for (MyGUI::VectorStringPairs::iterator iter = mParams.begin(); iter != mParams.end(); ++iter) { @@ -72,7 +70,8 @@ std::ostringstream stream; for (MyGUI::VectorStringPairs::iterator iter = mParams.begin(); iter != mParams.end(); ++iter) { - if (iter != mParams.begin()) stream << "\n"; + if (iter != mParams.begin()) + stream << "\n"; stream << iter->first << " : " << iter->second; } @@ -81,9 +80,13 @@ MyGUI::ISubWidgetText* text = mInfo->getSubWidgetText(); if (text != nullptr) { - const MyGUI::IntSize& size = text->getTextSize() + mInfo->getSize() - text->getSize(); + MyGUI::IntSize size = text->getTextSize() + mInfo->getSize() - text->getSize(); const MyGUI::IntSize& size_view = MyGUI::RenderManager::getInstance().getViewSize(); - MyGUI::IntCoord coord(size_view.width - size.width - mOffset.left, size_view.height - size.height - mOffset.top, size.width, size.height); + MyGUI::IntCoord coord( + size_view.width - size.width - mOffset.left, + size_view.height - size.height - mOffset.top, + size.width, + size.height); if (coord != mInfo->getCoord()) mInfo->setCoord(coord); } @@ -95,7 +98,7 @@ mParams.clear(); } - void clear(const std::string& _key) + void clear(std::string_view _key) { for (MyGUI::VectorStringPairs::iterator iter = mParams.begin(); iter != mParams.end(); ++iter) { @@ -126,9 +129,9 @@ } private: - MyGUI::TextBox* mInfo; + MyGUI::TextBox* mInfo{nullptr}; MyGUI::VectorStringPairs mParams; - MyGUI::IntPoint mOffset; + MyGUI::IntPoint mOffset{20, 20}; }; } // namespace diagnostic diff -Nru mygui-3.4.2+dfsg/Common/BaseLayout/Attribute.h mygui-3.4.3+dfsg/Common/BaseLayout/Attribute.h --- mygui-3.4.2+dfsg/Common/BaseLayout/Attribute.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/BaseLayout/Attribute.h 2023-08-06 21:45:08.000000000 +0000 @@ -12,7 +12,7 @@ { // класс обертка для удаления данных из статического вектора - template + template struct DataHolder { ~DataHolder() @@ -25,41 +25,44 @@ }; // интерфейс для обертки поля - template + template struct Field { - virtual ~Field() { } + virtual ~Field() = default; virtual bool set(OwnerType* _target, typename SetterType::BaseValueType* _value) = 0; - virtual const std::string& getFieldTypeName() const = 0; + virtual std::string_view getFieldTypeName() const = 0; }; // шаблон для обертки поля - template + template struct FieldHolder : public Field { - FieldHolder(FieldType* OwnerType::* offset) : m_offset(offset) { } - FieldType* OwnerType::* const m_offset; + FieldHolder(FieldType* OwnerType::*offset) : + m_offset(offset) + { + } + FieldType* OwnerType::*const m_offset; bool set(OwnerType* _target, typename SetterType::BaseValueType* _value) override { _target->*m_offset = SetterType::template convert(_value); return _target->*m_offset != nullptr; } - const std::string& getFieldTypeName() const override + std::string_view getFieldTypeName() const override { return FieldType::getClassTypeName(); } }; // шаблон для атрибута поля - template + template struct AttributeField { - typedef std::pair*, ValueType> BindPair; - typedef std::vector VectorBindPair; + using BindPair = std::pair*, ValueType>; + using VectorBindPair = std::vector; - template - AttributeField(FieldType* OwnerType::* _offset, const ValueType& _value) + template + AttributeField(FieldType* OwnerType::*_offset, const ValueType& _value) { getData().push_back(BindPair(new FieldHolder(_offset), _value)); } @@ -72,12 +75,14 @@ // макрос для инстансирования атрибута поля #define DECLARE_ATTRIBUTE_FIELD(_name, _type, _setter) \ - template \ + template \ struct _name : public attribute::AttributeField \ { \ - template \ - _name(FieldType* OwnerType::* _offset, const ValueType& _value) : \ - AttributeField(_offset, _value) { } \ + template \ + _name(FieldType* OwnerType::*_offset, const ValueType& _value) : \ + AttributeField(_offset, _value) \ + { \ + } \ } // макрос для инстансирования экземпляра атрибута @@ -92,7 +97,7 @@ // шаблон для атрибута класса - template + template struct ClassAttribute { ClassAttribute(const ValueType& _value) @@ -108,11 +113,13 @@ // макрос для инстансирования атрибута класса #define DECLARE_ATTRIBUTE_CLASS(_name, _type) \ - template \ + template \ struct _name : public attribute::ClassAttribute<_name, ValueType> \ { \ _name(const ValueType& _value) : \ - ClassAttribute<_name, ValueType>(_value) { } \ + ClassAttribute<_name, ValueType>(_value) \ + { \ + } \ } // макрос для инстансирования экземпляра класса diff -Nru mygui-3.4.2+dfsg/Common/BaseLayout/BaseLayout.h mygui-3.4.3+dfsg/Common/BaseLayout/BaseLayout.h --- mygui-3.4.2+dfsg/Common/BaseLayout/BaseLayout.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/BaseLayout/BaseLayout.h 2023-08-06 21:45:08.000000000 +0000 @@ -22,19 +22,19 @@ { } - BaseLayout(const std::string& _layout, MyGUI::Widget* _parent = nullptr) : + BaseLayout(std::string_view _layout, MyGUI::Widget* _parent = nullptr) : mMainWidget(nullptr) { initialise(_layout, _parent); } - template - void assignWidget(T * & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) + template + void assignWidget(T*& _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) { _widget = nullptr; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) + for (const auto& iter : mListWindowRoot) { - MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); + MyGUI::Widget* find = iter->findWidget(mPrefix + _name); if (nullptr != find) { T* cast = find->castType(false); @@ -44,9 +44,14 @@ } else { - MYGUI_LOG(Warning, "Widget with name '" << _name << "' have wrong type ('" << - find->getTypeName() << "instead of '" << T::getClassTypeName() << "'). [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); + MYGUI_LOG( + Warning, + "Widget with name '" + << _name << "' have wrong type ('" << find->getTypeName() << "instead of '" + << T::getClassTypeName() << "'). [" << mLayoutName << "]"); + MYGUI_ASSERT( + !_throw, + "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) _widget = _createFakeWidget(mMainWidget); } @@ -55,18 +60,18 @@ } } MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); + MYGUI_ASSERT(!_throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) _widget = _createFakeWidget(mMainWidget); } - template - void assignBase(T * & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) + template + void assignBase(T*& _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) { _widget = nullptr; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) + for (const auto& iter : mListWindowRoot) { - MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); + MyGUI::Widget* find = iter->findWidget(mPrefix + _name); if (nullptr != find) { _widget = new T(find); @@ -76,7 +81,7 @@ } MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign base widget with name '" << _name << "'. [" << mLayoutName << "]"); + MYGUI_ASSERT(!_throw, "Can't assign base widget with name '" << _name << "'. [" << mLayoutName << "]"); if (_createFakeWidgets) { _widget = new T(_createFakeWidget(mMainWidget)); @@ -84,10 +89,12 @@ } } - void initialise(const std::string& _layout, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) + void initialise( + std::string_view _layout, + MyGUI::Widget* _parent = nullptr, + bool _throw = true, + bool _createFakeWidgets = true) { - const std::string MAIN_WINDOW1 = "_Main"; - const std::string MAIN_WINDOW2 = "Root"; mLayoutName = _layout; // оборачиваем @@ -106,13 +113,15 @@ mPrefix = MyGUI::utility::toString(this, "_"); mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent); + const std::string MAIN_WINDOW1 = "_Main"; + const std::string MAIN_WINDOW2 = "Root"; const std::string mainName1 = mPrefix + MAIN_WINDOW1; const std::string mainName2 = mPrefix + MAIN_WINDOW2; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) + for (const auto& iter : mListWindowRoot) { - if ((*iter)->getName() == mainName1 || (*iter)->getName() == mainName2) + if (iter->getName() == mainName1 || iter->getName() == mainName2) { - mMainWidget = (*iter); + mMainWidget = iter; snapToParent(mMainWidget); @@ -122,7 +131,10 @@ if (mMainWidget == nullptr) { - MYGUI_LOG(Warning, "Root widget with name '" << MAIN_WINDOW1 << "' or '" << MAIN_WINDOW2 << "' not found. [" << mLayoutName << "]"); + MYGUI_LOG( + Warning, + "Root widget with name '" + << MAIN_WINDOW1 << "' or '" << MAIN_WINDOW2 << "' not found. [" << mLayoutName << "]"); MYGUI_ASSERT(!_throw, "No root widget. ['" << mLayoutName << "]"); if (_createFakeWidgets) mMainWidget = _createFakeWidget(_parent); @@ -145,13 +157,20 @@ mListWindowRoot.clear(); } - template - void initialiseByAttributes(Type* _owner, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) + template + void initialiseByAttributes( + Type* _owner, + MyGUI::Widget* _parent = nullptr, + bool _throw = true, + bool _createFakeWidgets = true) { initialise(attribute::AttributeLayout::getData(), _parent, _throw, _createFakeWidgets); - typename attribute::AttributeFieldWidgetName::VectorBindPair& data = attribute::AttributeFieldWidgetName::getData(); - for (typename attribute::AttributeFieldWidgetName::VectorBindPair::iterator item = data.begin(); item != data.end(); ++item) + typename attribute::AttributeFieldWidgetName::VectorBindPair& data = + attribute::AttributeFieldWidgetName::getData(); + for (typename attribute::AttributeFieldWidgetName::VectorBindPair::iterator item = data.begin(); + item != data.end(); + ++item) { MyGUI::Widget* value = nullptr; assignWidget(value, item->second, _throw, false); @@ -169,13 +188,13 @@ private: std::string FindParentPrefix(MyGUI::Widget* _parent) { - std::string prefix = _parent->getUserString("BaseLayoutPrefix"); + std::string prefix{_parent->getUserString("BaseLayoutPrefix")}; if (!prefix.empty()) return prefix; if (_parent->getParent() != nullptr) return FindParentPrefix(_parent->getParent()); - return ""; + return prefix; } void snapToParent(MyGUI::Widget* _child) @@ -227,18 +246,27 @@ } } - template + template T* _createFakeWidget(MyGUI::Widget* _parent) { return static_cast(_createFakeWidgetT(T::getClassTypeName(), _parent)); } - MyGUI::Widget* _createFakeWidgetT(const std::string& _typeName, MyGUI::Widget* _parent) + MyGUI::Widget* _createFakeWidgetT(std::string_view _typeName, MyGUI::Widget* _parent) { if (_parent) - return _parent->createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default); - - return MyGUI::Gui::getInstance().createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default, ""); + return _parent->createWidgetT( + _typeName, + MyGUI::SkinManager::getInstance().getDefaultSkin(), + MyGUI::IntCoord(), + MyGUI::Align::Default); + + return MyGUI::Gui::getInstance().createWidgetT( + _typeName, + MyGUI::SkinManager::getInstance().getDefaultSkin(), + MyGUI::IntCoord(), + MyGUI::Align::Default, + std::string_view{}); } public: @@ -254,7 +282,7 @@ std::string mPrefix; std::string mLayoutName; MyGUI::VectorWidgetPtr mListWindowRoot; - typedef std::vector VectorBasePtr; + using VectorBasePtr = std::vector; VectorBasePtr mListBase; }; diff -Nru mygui-3.4.2+dfsg/Common/BaseLayout/WrapsAttribute.h mygui-3.4.3+dfsg/Common/BaseLayout/WrapsAttribute.h --- mygui-3.4.2+dfsg/Common/BaseLayout/WrapsAttribute.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/BaseLayout/WrapsAttribute.h 2023-08-06 21:45:08.000000000 +0000 @@ -16,9 +16,9 @@ struct FieldSetterWidget { - typedef MyGUI::Widget BaseValueType; + using BaseValueType = MyGUI::Widget; - template + template static Type* convert(BaseValueType* _value) { return _value == nullptr ? nullptr : _value->castType(false); @@ -33,8 +33,7 @@ DECLARE_ATTRIBUTE_CLASS(AttributeLayout, std::string); -#define ATTRIBUTE_CLASS_LAYOUT(_class, _value) \ - ATTRIBUTE_CLASS(AttributeLayout, _class, _value) +#define ATTRIBUTE_CLASS_LAYOUT(_class, _value) ATTRIBUTE_CLASS(AttributeLayout, _class, _value) } diff -Nru mygui-3.4.2+dfsg/Common/CMakeLists.txt mygui-3.4.3+dfsg/Common/CMakeLists.txt --- mygui-3.4.2+dfsg/Common/CMakeLists.txt 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/CMakeLists.txt 2023-08-06 21:45:08.000000000 +0000 @@ -83,16 +83,20 @@ set (HEADER_FILES ${HEADER_FILES} Input/SDL/InputManager.h Input/SDL/PointerManager.h - ) + Input/SDL/ResourceSDLPointer.h +) set (SOURCE_FILES ${SOURCE_FILES} Input/SDL/InputManager.cpp Input/SDL/PointerManager.cpp - ) + Input/SDL/ResourceSDLPointer.cpp +) SOURCE_GROUP("Base" FILES Input/SDL/InputManager.h Input/SDL/InputManager.cpp Input/SDL/PointerManager.h Input/SDL/PointerManager.cpp + Input/SDL/ResourceSDLPointer.h + Input/SDL/ResourceSDLPointer.cpp ) add_library(${PROJECTNAME} ${HEADER_FILES} ${SOURCE_FILES}) diff -Nru mygui-3.4.2+dfsg/Common/FileSystemInfo/FileSystemInfo.h mygui-3.4.3+dfsg/Common/FileSystemInfo/FileSystemInfo.h --- mygui-3.4.2+dfsg/Common/FileSystemInfo/FileSystemInfo.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/FileSystemInfo/FileSystemInfo.h 2023-08-06 21:45:08.000000000 +0000 @@ -9,15 +9,14 @@ #include #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 -#include -#include + #include + #include #else -#include -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include #endif #include @@ -29,18 +28,22 @@ struct FileInfo { - FileInfo(const std::wstring& _name, bool _folder) : name(_name), folder(_folder) { } + FileInfo(const std::wstring& _name, bool _folder) : + name(_name), + folder(_folder) + { + } std::wstring name; bool folder; }; - typedef std::vector VectorFileInfo; + using VectorFileInfo = std::vector; inline std::wstring toLower(const std::wstring& _input) { std::wstring result; result.resize(_input.size()); static std::locale sLocale(""); - for (unsigned int i=0; i<_input.size(); ++i) + for (unsigned int i = 0; i < _input.size(); ++i) result[i] = std::tolower(_input[i], sLocale); return result; } @@ -57,10 +60,10 @@ inline bool isAbsolutePath(const wchar_t* path) { - #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 +#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 if (IsCharAlphaW(path[0]) && path[1] == ':') return true; - #endif +#endif return path[0] == '/' || path[0] == '\\'; } @@ -70,7 +73,7 @@ if (_source.size() < count) return false; size_t offset = _source.size() - count; - for (size_t index = 0; index < count; ++ index) + for (size_t index = 0; index < count; ++index) { if (_source[index + offset] != _value[index]) return false; @@ -84,32 +87,34 @@ { return _name; } - else - { - if (endWith(_base, L"\\") || endWith(_base, L"/")) - return _base + _name; + + if (endWith(_base, L"\\") || endWith(_base, L"/")) + return _base + _name; #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 - return _base + L'\\' + _name; + return _base + L'\\' + _name; #else - return _base + L'/' + _name; + return _base + L'/' + _name; #endif - } } - inline bool isReservedDir (const wchar_t* _fn) + inline bool isReservedDir(const wchar_t* _fn) { // if "." - return (_fn [0] == '.' && _fn [1] == 0); + return (_fn[0] == '.' && _fn[1] == 0); } - inline bool isParentDir (const wchar_t* _fn) + inline bool isParentDir(const wchar_t* _fn) { // if ".." - return (_fn [0] == '.' && _fn [1] == '.' && _fn [2] == 0); + return (_fn[0] == '.' && _fn[1] == '.' && _fn[2] == 0); } - inline void getSystemFileList(VectorFileInfo& _result, const std::wstring& _folder, const std::wstring& _mask, bool _sorted = true) + inline void getSystemFileList( + VectorFileInfo& _result, + const std::wstring& _folder, + const std::wstring& _mask, + bool _sorted = true) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 //FIXME add optional parameter? @@ -123,7 +128,7 @@ size_t pos = _mask.find_last_of(L"/\\"); std::wstring directory; if (pos != _mask.npos) - directory = _mask.substr (0, pos); + directory = _mask.substr(0, pos); std::wstring full_mask = concatenatePath(_folder, _mask); @@ -131,37 +136,40 @@ res = 0; while (lHandle != -1 && res != -1) { - if (( !ms_IgnoreHidden || (tagData.attrib & _A_HIDDEN) == 0 ) && - !isReservedDir(tagData.name)) + if ((!ms_IgnoreHidden || (tagData.attrib & _A_HIDDEN) == 0) && !isReservedDir(tagData.name)) { - _result.push_back(FileInfo(concatenatePath(directory, tagData.name), (tagData.attrib & _A_SUBDIR) != 0)); + _result.push_back( + FileInfo(concatenatePath(directory, tagData.name), (tagData.attrib & _A_SUBDIR) != 0)); } - res = _wfindnext( lHandle, &tagData ); + res = _wfindnext(lHandle, &tagData); } // Close if we found any files if (lHandle != -1) _findclose(lHandle); #else - DIR* dir = opendir(MyGUI::UString(_folder).asUTF8_c_str()); + std::string folder = MyGUI::UString(_folder).asUTF8(); + DIR* dir = opendir(folder.c_str()); struct dirent* dp; if (dir == nullptr) { /* opendir() failed */ - MYGUI_LOG(Error, (std::string("Can't open ") + MyGUI::UString(_folder).asUTF8_c_str())); + MYGUI_LOG(Error, "Can't open " + folder); return; } - rewinddir (dir); + rewinddir(dir); - while ((dp = readdir (dir)) != nullptr) + while ((dp = readdir(dir)) != nullptr) { - if ((fnmatch(MyGUI::UString(_mask).asUTF8_c_str(), dp->d_name, 0) == 0) && !isReservedDir(MyGUI::UString(dp->d_name).asWStr_c_str())) + if ((fnmatch(MyGUI::UString(_mask).asUTF8_c_str(), dp->d_name, 0) == 0) && + !isReservedDir(MyGUI::UString(dp->d_name).asWStr_c_str())) { struct stat fInfo; - std::string path = MyGUI::UString(_folder).asUTF8() + "/" + dp->d_name; - if (stat(path.c_str(), &fInfo) == -1)perror("stat"); - _result.push_back(FileInfo(MyGUI::UString(dp->d_name).asWStr(), (S_ISDIR(fInfo.st_mode)))); + std::string path = folder + "/" + dp->d_name; + if (stat(path.c_str(), &fInfo) == -1) + perror("stat"); + _result.emplace_back(MyGUI::UString(dp->d_name).asWStr_c_str(), (S_ISDIR(fInfo.st_mode))); } } @@ -176,49 +184,54 @@ inline std::wstring getSystemCurrentFolder() { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 - wchar_t buff[MAX_PATH+1]; + wchar_t buff[MAX_PATH + 1]; ::GetCurrentDirectoryW(MAX_PATH, buff); return buff; #else -# ifndef PATH_MAX -# define PATH_MAX 256 -# endif - char buff[PATH_MAX+1]; - return getcwd(buff, PATH_MAX) ? MyGUI::UString(buff).asWStr() : std::wstring(); + #ifndef PATH_MAX + #define PATH_MAX 256 + #endif + char buff[PATH_MAX + 1]; + return getcwd(buff, PATH_MAX) ? MyGUI::UString(buff).asWStr_c_str() : std::wstring(); #endif } - typedef std::vector VectorWString; - inline void scanFolder(VectorWString& _result, const std::wstring& _folder, bool _recursive, const std::wstring& _mask, bool _fullpath) + using VectorWString = std::vector; + inline void scanFolder( + VectorWString& _result, + const std::wstring& _folder, + bool _recursive, + const std::wstring& _mask, + bool _fullpath) { std::wstring folder = _folder; - if (!folder.empty() && *folder.rbegin() != '/' && *folder.rbegin() != '\\') folder += L"/"; + if (!folder.empty() && *folder.rbegin() != '/' && *folder.rbegin() != '\\') + folder += L"/"; VectorFileInfo result; getSystemFileList(result, folder, _mask); - for (VectorFileInfo::const_iterator item = result.begin(); item != result.end(); ++item) + for (const auto& item : result) { - if (item->folder) continue; + if (item.folder) + continue; if (_fullpath) - _result.push_back(folder + item->name); + _result.push_back(folder + item.name); else - _result.push_back(item->name); + _result.push_back(item.name); } if (_recursive) { getSystemFileList(result, folder, L"*"); - for (VectorFileInfo::const_iterator item = result.begin(); item != result.end(); ++item) + for (const auto& item : result) { - if (!item->folder - || item->name == L".." - || item->name == L".") continue; - scanFolder(_result, folder + item->name, _recursive, _mask, _fullpath); + if (!item.folder || item.name == L".." || item.name == L".") + continue; + scanFolder(_result, folder + item.name, _recursive, _mask, _fullpath); } - } } diff -Nru mygui-3.4.2+dfsg/Common/Input/InputConverter.h mygui-3.4.3+dfsg/Common/Input/InputConverter.h --- mygui-3.4.2+dfsg/Common/Input/InputConverter.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/InputConverter.h 2023-08-06 21:45:08.000000000 +0000 @@ -10,20 +10,20 @@ #include #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 -#include -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif + #include + #ifdef max + #undef max + #endif + #ifdef min + #undef min + #endif #endif //#define INPUT_KEY_NAME #ifdef INPUT_KEY_NAME -#include -#include + #include + #include #endif namespace input @@ -335,9 +335,9 @@ SC_8 = 0x09, SC_9 = 0x0A, SC_0 = 0x0B, - SC_MINUS = 0x0C, // - on main keyboard + SC_MINUS = 0x0C, // - on main keyboard SC_EQUALS = 0x0D, - SC_BACK = 0x0E, // backspace + SC_BACK = 0x0E, // backspace SC_TAB = 0x0F, SC_Q = 0x10, SC_W = 0x11, @@ -351,7 +351,7 @@ SC_P = 0x19, SC_LBRACKET = 0x1A, SC_RBRACKET = 0x1B, - SC_RETURN = 0x1C, // Enter on main keyboard + SC_RETURN = 0x1C, // Enter on main keyboard SC_LCONTROL = 0x1D, SC_A = 0x1E, SC_S = 0x1F, @@ -364,7 +364,7 @@ SC_L = 0x26, SC_SEMICOLON = 0x27, SC_APOSTROPHE = 0x28, - SC_GRAVE = 0x29, // accent + SC_GRAVE = 0x29, // accent SC_LSHIFT = 0x2A, SC_BACKSLASH = 0x2B, SC_Z = 0x2C, @@ -375,11 +375,11 @@ SC_N = 0x31, SC_M = 0x32, SC_COMMA = 0x33, - SC_PERIOD = 0x34, // . on main keyboard - SC_SLASH = 0x35, // / on main keyboard + SC_PERIOD = 0x34, // . on main keyboard + SC_SLASH = 0x35, // / on main keyboard SC_RSHIFT = 0x36, - SC_MULTIPLY = 0x37, // * on numeric keypad - SC_LMENU = 0x38, // left Alt + SC_MULTIPLY = 0x37, // * on numeric keypad + SC_LMENU = 0x38, // left Alt SC_SPACE = 0x39, SC_CAPITAL = 0x3A, SC_F1 = 0x3B, @@ -393,81 +393,81 @@ SC_F9 = 0x43, SC_F10 = 0x44, SC_NUMLOCK = 0x45, - SC_SCROLL = 0x46, // Scroll Lock + SC_SCROLL = 0x46, // Scroll Lock SC_NUMPAD7 = 0x47, SC_NUMPAD8 = 0x48, SC_NUMPAD9 = 0x49, - SC_SUBTRACT = 0x4A, // - on numeric keypad + SC_SUBTRACT = 0x4A, // - on numeric keypad SC_NUMPAD4 = 0x4B, SC_NUMPAD5 = 0x4C, SC_NUMPAD6 = 0x4D, - SC_ADD = 0x4E, // + on numeric keypad + SC_ADD = 0x4E, // + on numeric keypad SC_NUMPAD1 = 0x4F, SC_NUMPAD2 = 0x50, SC_NUMPAD3 = 0x51, SC_NUMPAD0 = 0x52, - SC_DECIMAL = 0x53, // . on numeric keypad - SC_OEM_102 = 0x56, // < > | on UK/Germany keyboards + SC_DECIMAL = 0x53, // . on numeric keypad + SC_OEM_102 = 0x56, // < > | on UK/Germany keyboards SC_F11 = 0x57, SC_F12 = 0x58, - SC_F13 = 0x64, // (NEC PC98) - SC_F14 = 0x65, // (NEC PC98) - SC_F15 = 0x66, // (NEC PC98) - SC_KANA = 0x70, // (Japanese keyboard) - SC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards - SC_CONVERT = 0x79, // (Japanese keyboard) - SC_NOCONVERT = 0x7B, // (Japanese keyboard) - SC_YEN = 0x7D, // (Japanese keyboard) - SC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards - SC_NUMPADEQUALS = 0x8D, // = on numeric keypad (NEC PC98) - SC_PREVTRACK = 0x90, // Previous Track (SC_CIRCUMFLEX on Japanese keyboard) - SC_AT = 0x91, // (NEC PC98) - SC_COLON = 0x92, // (NEC PC98) - SC_UNDERLINE = 0x93, // (NEC PC98) - SC_KANJI = 0x94, // (Japanese keyboard) - SC_STOP = 0x95, // (NEC PC98) - SC_AX = 0x96, // (Japan AX) - SC_UNLABELED = 0x97, // (J3100) - SC_NEXTTRACK = 0x99, // Next Track - SC_NUMPADENTER = 0x9C, // Enter on numeric keypad + SC_F13 = 0x64, // (NEC PC98) + SC_F14 = 0x65, // (NEC PC98) + SC_F15 = 0x66, // (NEC PC98) + SC_KANA = 0x70, // (Japanese keyboard) + SC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards + SC_CONVERT = 0x79, // (Japanese keyboard) + SC_NOCONVERT = 0x7B, // (Japanese keyboard) + SC_YEN = 0x7D, // (Japanese keyboard) + SC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards + SC_NUMPADEQUALS = 0x8D, // = on numeric keypad (NEC PC98) + SC_PREVTRACK = 0x90, // Previous Track (SC_CIRCUMFLEX on Japanese keyboard) + SC_AT = 0x91, // (NEC PC98) + SC_COLON = 0x92, // (NEC PC98) + SC_UNDERLINE = 0x93, // (NEC PC98) + SC_KANJI = 0x94, // (Japanese keyboard) + SC_STOP = 0x95, // (NEC PC98) + SC_AX = 0x96, // (Japan AX) + SC_UNLABELED = 0x97, // (J3100) + SC_NEXTTRACK = 0x99, // Next Track + SC_NUMPADENTER = 0x9C, // Enter on numeric keypad SC_RCONTROL = 0x9D, - SC_MUTE = 0xA0, // Mute - SC_CALCULATOR = 0xA1, // Calculator - SC_PLAYPAUSE = 0xA2, // Play / Pause - SC_MEDIASTOP = 0xA4, // Media Stop - SC_VOLUMEDOWN = 0xAE, // Volume - - SC_VOLUMEUP = 0xB0, // Volume + - SC_WEBHOME = 0xB2, // Web home - SC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98) - SC_DIVIDE = 0xB5, // / on numeric keypad + SC_MUTE = 0xA0, // Mute + SC_CALCULATOR = 0xA1, // Calculator + SC_PLAYPAUSE = 0xA2, // Play / Pause + SC_MEDIASTOP = 0xA4, // Media Stop + SC_VOLUMEDOWN = 0xAE, // Volume - + SC_VOLUMEUP = 0xB0, // Volume + + SC_WEBHOME = 0xB2, // Web home + SC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98) + SC_DIVIDE = 0xB5, // / on numeric keypad SC_SYSRQ = 0xB7, - SC_RMENU = 0xB8, // right Alt - SC_PAUSE = 0xC5, // Pause - SC_HOME = 0xC7, // Home on arrow keypad - SC_UP = 0xC8, // UpArrow on arrow keypad - SC_PGUP = 0xC9, // PgUp on arrow keypad - SC_LEFT = 0xCB, // LeftArrow on arrow keypad - SC_RIGHT = 0xCD, // RightArrow on arrow keypad - SC_END = 0xCF, // End on arrow keypad - SC_DOWN = 0xD0, // DownArrow on arrow keypad - SC_PGDOWN = 0xD1, // PgDn on arrow keypad - SC_INSERT = 0xD2, // Insert on arrow keypad - SC_DELETE = 0xD3, // Delete on arrow keypad - SC_LWIN = 0xDB, // Left Windows key - SC_RWIN = 0xDC, // Right Windows key - SC_APPS = 0xDD, // AppMenu key - SC_POWER = 0xDE, // System Power - SC_SLEEP = 0xDF, // System Sleep - SC_WAKE = 0xE3, // System Wake - SC_WEBSEARCH = 0xE5, // Web Search - SC_WEBFAVORITES = 0xE6, // Web Favorites - SC_WEBREFRESH = 0xE7, // Web Refresh - SC_WEBSTOP = 0xE8, // Web Stop - SC_WEBFORWARD = 0xE9, // Web Forward - SC_WEBBACK = 0xEA, // Web Back - SC_MYCOMPUTER = 0xEB, // My Computer - SC_MAIL = 0xEC, // Mail - SC_MEDIASELECT = 0xED, // Media Select + SC_RMENU = 0xB8, // right Alt + SC_PAUSE = 0xC5, // Pause + SC_HOME = 0xC7, // Home on arrow keypad + SC_UP = 0xC8, // UpArrow on arrow keypad + SC_PGUP = 0xC9, // PgUp on arrow keypad + SC_LEFT = 0xCB, // LeftArrow on arrow keypad + SC_RIGHT = 0xCD, // RightArrow on arrow keypad + SC_END = 0xCF, // End on arrow keypad + SC_DOWN = 0xD0, // DownArrow on arrow keypad + SC_PGDOWN = 0xD1, // PgDn on arrow keypad + SC_INSERT = 0xD2, // Insert on arrow keypad + SC_DELETE = 0xD3, // Delete on arrow keypad + SC_LWIN = 0xDB, // Left Windows key + SC_RWIN = 0xDC, // Right Windows key + SC_APPS = 0xDD, // AppMenu key + SC_POWER = 0xDE, // System Power + SC_SLEEP = 0xDF, // System Sleep + SC_WAKE = 0xE3, // System Wake + SC_WEBSEARCH = 0xE5, // Web Search + SC_WEBFAVORITES = 0xE6, // Web Favorites + SC_WEBREFRESH = 0xE7, // Web Refresh + SC_WEBSTOP = 0xE8, // Web Stop + SC_WEBFORWARD = 0xE9, // Web Forward + SC_WEBBACK = 0xEA, // Web Back + SC_MYCOMPUTER = 0xEB, // My Computer + SC_MAIL = 0xEC, // Mail + SC_MEDIASELECT = 0xED, // Media Select SC_MAX }; @@ -479,7 +479,7 @@ #ifdef INPUT_KEY_NAME mVirtualKeyToName.resize(VLK_MAX); - #define DECLARE_VIRTUAL_KEY(_key) mVirtualKeyToName[_key] = #_key; + #define DECLARE_VIRTUAL_KEY(_key) mVirtualKeyToName[_key] = #_key; DECLARE_VIRTUAL_KEY(VLK_LBUTTON) DECLARE_VIRTUAL_KEY(VLK_RBUTTON) @@ -704,11 +704,11 @@ DECLARE_VIRTUAL_KEY(VLK_PA1) DECLARE_VIRTUAL_KEY(VLK_OEM_CLEAR) - #undef DECLARE_VIRTUAL_KEY + #undef DECLARE_VIRTUAL_KEY mScanCodeToName.resize(SC_MAX); - #define DECLARE_SCAN_CODE(_code) mScanCodeToName[_code] = #_code; + #define DECLARE_SCAN_CODE(_code) mScanCodeToName[_code] = #_code; DECLARE_SCAN_CODE(SC_ESCAPE) DECLARE_SCAN_CODE(SC_1) @@ -855,18 +855,18 @@ DECLARE_SCAN_CODE(SC_MAIL) DECLARE_SCAN_CODE(SC_MEDIASELECT) - #undef DECLARE_SCAN_CODE + #undef DECLARE_SCAN_CODE #endif memset(mVirtualKeyToScanCode, 0, VLK_MAX); memset(mScanCodeToVirtualKey, 0, SC_MAX); - #define ADD_MAP(_keyName) \ - mVirtualKeyToScanCode[VLK_##_keyName] = SC_##_keyName; \ - mScanCodeToVirtualKey[SC_##_keyName] = VLK_##_keyName; - #define ADD_MAP2(_virtualKey, _scanCode) \ - mVirtualKeyToScanCode[VLK_##_virtualKey] = SC_##_scanCode; \ - mScanCodeToVirtualKey[SC_##_scanCode] = VLK_##_virtualKey; +#define ADD_MAP(_keyName) \ + mVirtualKeyToScanCode[VLK_##_keyName] = SC_##_keyName; \ + mScanCodeToVirtualKey[SC_##_keyName] = VLK_##_keyName; +#define ADD_MAP2(_virtualKey, _scanCode) \ + mVirtualKeyToScanCode[VLK_##_virtualKey] = SC_##_scanCode; \ + mScanCodeToVirtualKey[SC_##_scanCode] = VLK_##_virtualKey; ADD_MAP(0) ADD_MAP(1) @@ -991,8 +991,8 @@ ADD_MAP(NUMPAD9) - #undef ADD_MAP - #undef ADD_MAP2 +#undef ADD_MAP +#undef ADD_MAP2 } int VirtualKeyToScanCode(WPARAM _virtualKey) const @@ -1010,18 +1010,18 @@ } #ifdef INPUT_KEY_NAME - const std::string VirtualKeyToName(WPARAM _virtualKey) const + std::string_view VirtualKeyToName(WPARAM _virtualKey) const { if (_virtualKey < VLK_MAX) return mVirtualKeyToName[_virtualKey]; - return ""; + return {}; } - const std::string ScanCodeToName(int _scanCode) const + std::string_view ScanCodeToName(int _scanCode) const { if (_scanCode < SC_MAX) return mScanCodeToName[_scanCode]; - return ""; + return {}; } #endif @@ -1056,13 +1056,13 @@ #ifdef INPUT_KEY_NAME - std::string VirtualKeyToName(WPARAM _virtualKey) + std::string_view VirtualKeyToName(WPARAM _virtualKey) { const Table& table = getTable(); return table.VirtualKeyToName(_virtualKey); } - std::string ScanCodeToName(int _scanCode) + std::string_view ScanCodeToName(int _scanCode) { const Table& table = getTable(); return table.ScanCodeToName(_scanCode); @@ -1077,17 +1077,17 @@ static WCHAR deadKey = 0; BYTE keyState[256]; - HKL layout = GetKeyboardLayout(0); + HKL layout = GetKeyboardLayout(0); if (GetKeyboardState(keyState) == 0) return 0; - WCHAR buff[3] = { 0, 0, 0 }; + WCHAR buff[3] = {0, 0, 0}; int ascii = ToUnicodeEx((UINT)_virtualKey, 0, keyState, buff, 3, 0, layout); - if (ascii == 1 && deadKey != '\0' ) + if (ascii == 1 && deadKey != '\0') { // A dead key is stored and we have just converted a character key // Combine the two into a single character - WCHAR wcBuff[3] = { buff[0], deadKey, '\0' }; + WCHAR wcBuff[3] = {buff[0], deadKey, '\0'}; WCHAR out[3]; deadKey = '\0'; @@ -1122,9 +1122,7 @@ case 0xB8: // Cedilla: з deadKey = 0x327; break; - default: - deadKey = buff[0]; - break; + default: deadKey = buff[0]; break; } } return 0; @@ -1132,7 +1130,7 @@ int ScanCodeToText(int _scanCode) { - HKL layout = GetKeyboardLayout(0); + HKL layout = GetKeyboardLayout(0); unsigned int vk = MapVirtualKeyEx((UINT)_scanCode, 3 /*MAPVK_VSC_TO_VK_EX*/, layout); if (vk == 0) return 0; diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/InputManager.cpp mygui-3.4.3+dfsg/Common/Input/SDL/InputManager.cpp --- mygui-3.4.2+dfsg/Common/Input/SDL/InputManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/InputManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -4,13 +4,7 @@ namespace input { - InputManager::InputManager() : - mMouseX(0), - mMouseY(0), - mMouseZ(0), - mMouseMove(false), - mWidth(0), - mHeight(0) + InputManager::InputManager() { // build the virtual key map and mouse button between SDL and MyGUI buildVKeyMap(); @@ -22,8 +16,7 @@ int sdlKey; MyGUI::KeyCode myguiKey; }; - static KeyMapItem mapItems[] = - { + static KeyMapItem mapItems[] = { {0, MyGUI::KeyCode::None}, {SDLK_UNKNOWN, MyGUI::KeyCode::None}, {SDLK_ESCAPE, MyGUI::KeyCode::Escape}, @@ -158,14 +151,13 @@ {SDLK_LGUI, MyGUI::KeyCode::LeftWindows}, //{, MyGUI::KeyCode::RightWindow}, {SDLK_RGUI, MyGUI::KeyCode::RightWindows}, - {SDLK_APPLICATION, MyGUI::KeyCode::AppMenu} - }; + {SDLK_APPLICATION, MyGUI::KeyCode::AppMenu}}; void InputManager::buildVKeyMap() { mSDLVKeyMap.clear(); - for (size_t i = 0; i < sizeof(mapItems) / sizeof(KeyMapItem); ++i) - mSDLVKeyMap.insert(std::pair(mapItems[i].sdlKey, mapItems[i].myguiKey)); + for (const auto& mapItem : mapItems) + mSDLVKeyMap.insert(std::pair(mapItem.sdlKey, mapItem.myguiKey)); } void InputManager::buildMouseButtonMap() @@ -184,14 +176,18 @@ MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear(); // Set the cross-platform SDL system clipboard handler - MyGUI::ClipboardManager::getInstance().eventClipboardChanged += MyGUI::newDelegate(this, &InputManager::onClipboardChanged); - MyGUI::ClipboardManager::getInstance().eventClipboardRequested += MyGUI::newDelegate(this, &InputManager::onClipboardRequested); + MyGUI::ClipboardManager::getInstance().eventClipboardChanged += + MyGUI::newDelegate(this, &InputManager::onClipboardChanged); + MyGUI::ClipboardManager::getInstance().eventClipboardRequested += + MyGUI::newDelegate(this, &InputManager::onClipboardRequested); } void InputManager::destroyInput() { - MyGUI::ClipboardManager::getInstance().eventClipboardChanged -= MyGUI::newDelegate(this, &InputManager::onClipboardChanged); - MyGUI::ClipboardManager::getInstance().eventClipboardRequested -= MyGUI::newDelegate(this, &InputManager::onClipboardRequested); + MyGUI::ClipboardManager::getInstance().eventClipboardChanged -= + MyGUI::newDelegate(this, &InputManager::onClipboardChanged); + MyGUI::ClipboardManager::getInstance().eventClipboardRequested -= + MyGUI::newDelegate(this, &InputManager::onClipboardRequested); } void InputManager::updateCursorPosition() @@ -212,7 +208,7 @@ } } - bool InputManager::mouseMoved(const SDL_MouseMotionEvent &evt) + bool InputManager::mouseMoved(const SDL_MouseMotionEvent& evt) { mMouseX = evt.x; mMouseY = evt.y; @@ -220,14 +216,14 @@ return true; } - bool InputManager::mousePressed(const SDL_MouseButtonEvent &evt) + bool InputManager::mousePressed(const SDL_MouseButtonEvent& evt) { computeMouseMove(); injectMousePress(mMouseX, mMouseY, mSDLMouseMap[evt.button]); return true; } - bool InputManager::mouseReleased(const SDL_MouseButtonEvent &evt ) + bool InputManager::mouseReleased(const SDL_MouseButtonEvent& evt) { computeMouseMove(); injectMouseRelease(mMouseX, mMouseY, mSDLMouseMap[evt.button]); @@ -236,35 +232,38 @@ bool InputManager::keyPressed(SDL_Keycode key, const SDL_TextInputEvent* evt) { - if (mSDLVKeyMap.count(key) == 0) { + if (mSDLVKeyMap.count(key) == 0) + { return false; } MyGUI::KeyCode myGuiKeyCode = mSDLVKeyMap[key]; - if (evt == nullptr) { + if (evt == nullptr) + { injectKeyPress(myGuiKeyCode, 0); } else { MyGUI::UString ustring(evt->text); MyGUI::UString::utf32string utf32string = ustring.asUTF32(); - for (MyGUI::UString::utf32string::const_iterator it = utf32string.begin(); it != utf32string.end(); ++it) + for (unsigned int it : utf32string) { - injectKeyPress(myGuiKeyCode, *it); + injectKeyPress(myGuiKeyCode, it); } } return true; } - bool InputManager::keyReleased(const SDL_KeyboardEvent &key) + bool InputManager::keyReleased(const SDL_KeyboardEvent& key) { - if (mSDLVKeyMap.count(key.keysym.sym) == 0) { + if (mSDLVKeyMap.count(key.keysym.sym) == 0) + { return false; } injectKeyRelease(mSDLVKeyMap[key.keysym.sym]); return true; } - bool InputManager::mouseWheelMoved(const SDL_MouseWheelEvent &evt) + bool InputManager::mouseWheelMoved(const SDL_MouseWheelEvent& evt) { mMouseZ += evt.y; mMouseMove = true; @@ -272,8 +271,8 @@ } void InputManager::captureInput() - { - } + { + } void InputManager::setInputViewSize(int _width, int _height) { @@ -303,13 +302,13 @@ mMouseY = mHeight - 1; } - void InputManager::onClipboardChanged(const std::string &_type, const std::string &_data) + void InputManager::onClipboardChanged(std::string_view _type, std::string_view _data) { if (_type == "Text") SDL_SetClipboardText(MyGUI::TextIterator::getOnlyText(MyGUI::UString(_data)).asUTF8().c_str()); } - void InputManager::onClipboardRequested(const std::string &_type, std::string &_data) + void InputManager::onClipboardRequested(std::string_view _type, std::string& _data) { if (_type != "Text") return; diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/InputManager.h mygui-3.4.3+dfsg/Common/Input/SDL/InputManager.h --- mygui-3.4.2+dfsg/Common/Input/SDL/InputManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/InputManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -24,14 +24,29 @@ void setInputViewSize(int _width, int _height); // following five methods are to be implemented in BaseManager class - virtual void injectMouseMove(int _absx, int _absy, int _absz){} - virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id){} - virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id){} - virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text){} - virtual void injectKeyRelease(MyGUI::KeyCode _key){} - - virtual void onFileDrop(const std::wstring& _filename) { } - virtual bool onWindowClose(size_t _handle) { return true; } + virtual void injectMouseMove(int _absx, int _absy, int _absz) + { + } + virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id) + { + } + virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id) + { + } + virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) + { + } + virtual void injectKeyRelease(MyGUI::KeyCode _key) + { + } + + virtual void onFileDrop(const std::wstring& _filename) + { + } + virtual bool onWindowClose(size_t _handle) + { + return true; + } void setMousePosition(int _x, int _y); void updateCursorPosition(); @@ -40,27 +55,28 @@ void frameEvent(float _time); void computeMouseMove(); - void onClipboardChanged(const std::string& _type, const std::string& _data); - void onClipboardRequested(const std::string& _type, std::string& _data); + void onClipboardChanged(std::string_view _type, std::string_view _data); + void onClipboardRequested(std::string_view _type, std::string& _data); - virtual bool mouseMoved(const SDL_MouseMotionEvent &evt); - virtual bool mousePressed(const SDL_MouseButtonEvent &evt); - virtual bool mouseReleased(const SDL_MouseButtonEvent &evt); + virtual bool mouseMoved(const SDL_MouseMotionEvent& evt); + virtual bool mousePressed(const SDL_MouseButtonEvent& evt); + virtual bool mouseReleased(const SDL_MouseButtonEvent& evt); virtual bool keyPressed(SDL_Keycode key, const SDL_TextInputEvent* evt); - virtual bool keyReleased(const SDL_KeyboardEvent &key); - virtual bool mouseWheelMoved(const SDL_MouseWheelEvent &evt); + virtual bool keyReleased(const SDL_KeyboardEvent& key); + virtual bool mouseWheelMoved(const SDL_MouseWheelEvent& evt); void checkPosition(); void buildVKeyMap(); void buildMouseButtonMap(); + private: - int mMouseX; - int mMouseY; - int mMouseZ; - bool mMouseMove; - int mWidth; - int mHeight; + int mMouseX{0}; + int mMouseY{0}; + int mMouseZ{0}; + bool mMouseMove{false}; + int mWidth{0}; + int mHeight{0}; std::map mSDLVKeyMap; std::map mSDLMouseMap; }; diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/PointerManager.cpp mygui-3.4.3+dfsg/Common/Input/SDL/PointerManager.cpp --- mygui-3.4.2+dfsg/Common/Input/SDL/PointerManager.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/PointerManager.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -8,17 +8,11 @@ #include "PointerManager.h" #include -#include "ResourceSDLPointer.cpp" +#include "ResourceSDLPointer.h" namespace input { - PointerManager::PointerManager() : - mManagerPointer(true), - mCursor(nullptr) - { - } - PointerManager::~PointerManager() { SDL_FreeCursor(mCursor); @@ -30,13 +24,13 @@ manager.setVisible(false); manager.eventChangeMousePointer += MyGUI::newDelegate(this, &PointerManager::notifyChangeMousePointer); - std::string resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); + const std::string& resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); MyGUI::FactoryManager::getInstance().registerFactory(resourceCategory); } void PointerManager::destroyPointerManager() { - std::string resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); + const std::string& resourceCategory = MyGUI::ResourceManager::getInstance().getCategoryName(); MyGUI::FactoryManager::getInstance().unregisterFactory(resourceCategory); MyGUI::PointerManager& manager = MyGUI::PointerManager::getInstance(); @@ -48,7 +42,7 @@ SDL_ShowCursor(static_cast(_value)); } - void PointerManager::notifyChangeMousePointer(const std::string& _name) + void PointerManager::notifyChangeMousePointer(std::string_view _name) { if (mManagerPointer) { @@ -56,7 +50,7 @@ } } - void PointerManager::setPointerName(const std::string& _name) + void PointerManager::setPointerName(std::string_view _name) { mManagerPointer = false; setPointer(_name); @@ -69,7 +63,7 @@ SDL_SetCursor(mCursor); } - void PointerManager::setPointer(const std::string& _name) + void PointerManager::setPointer(std::string_view _name) { MapPointer::iterator iter = mMapPointer.find(_name); if (iter != mMapPointer.end()) @@ -84,7 +78,7 @@ ResourceSDLPointer* resource = resource_generic->castType(false); if (resource != nullptr) { - mMapPointer[_name] = resource->getPointerType(); + mMapPointer.emplace(_name, resource->getPointerType()); updateSDLPointer(resource->getPointerType()); } } diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/PointerManager.h mygui-3.4.3+dfsg/Common/Input/SDL/PointerManager.h --- mygui-3.4.2+dfsg/Common/Input/SDL/PointerManager.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/PointerManager.h 2023-08-06 21:45:08.000000000 +0000 @@ -7,7 +7,9 @@ #ifndef POINTER_MANAGER_H_ #define POINTER_MANAGER_H_ +#include #include +#include #include namespace input @@ -16,28 +18,27 @@ class PointerManager { public: - PointerManager(); virtual ~PointerManager(); void createPointerManager(); void destroyPointerManager(); void setPointerVisible(bool _value); - void setPointerName(const std::string& _name); + void setPointerName(std::string_view _name); void loadPointerResources(); private: - void notifyChangeMousePointer(const std::string& _name); + void notifyChangeMousePointer(std::string_view _name); void updateSDLPointer(SDL_SystemCursor _newCursor); bool isMouseInClient(); - void setPointer(const std::string& _name); + void setPointer(std::string_view _name); private: - typedef std::map MapPointer; + using MapPointer = std::map>; MapPointer mMapPointer; - bool mManagerPointer; - SDL_Cursor* mCursor; + bool mManagerPointer{true}; + SDL_Cursor* mCursor{nullptr}; }; } // namespace input diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/ResourceSDLPointer.cpp mygui-3.4.3+dfsg/Common/Input/SDL/ResourceSDLPointer.cpp --- mygui-3.4.2+dfsg/Common/Input/SDL/ResourceSDLPointer.cpp 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/ResourceSDLPointer.cpp 2023-08-06 21:45:08.000000000 +0000 @@ -10,11 +10,6 @@ namespace input { - ResourceSDLPointer::ResourceSDLPointer() : - mCursorType(SDL_NUM_SYSTEM_CURSORS) - { - } - void ResourceSDLPointer::deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) { Base::deserialization(_node, _version); @@ -24,7 +19,7 @@ { if (info->getName() == "Property") { - const std::string& key = info->findAttribute("key"); + std::string_view key = info->findAttribute("key"); if (key == "SourceFile") { @@ -33,7 +28,7 @@ } else if (key == "SourceSystem") { - std::string value = info->getContent(); + const std::string& value = info->getContent(); if (value == "SDL_SYSTEM_CURSOR_ARROW") mCursorType = SDL_SYSTEM_CURSOR_ARROW; else if (value == "SDL_SYSTEM_CURSOR_IBEAM") diff -Nru mygui-3.4.2+dfsg/Common/Input/SDL/ResourceSDLPointer.h mygui-3.4.3+dfsg/Common/Input/SDL/ResourceSDLPointer.h --- mygui-3.4.2+dfsg/Common/Input/SDL/ResourceSDLPointer.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/Input/SDL/ResourceSDLPointer.h 2023-08-06 21:45:08.000000000 +0000 @@ -16,14 +16,11 @@ namespace input { - class ResourceSDLPointer : - public MyGUI::IResource + class ResourceSDLPointer : public MyGUI::IResource { - MYGUI_RTTI_DERIVED( ResourceSDLPointer ) + MYGUI_RTTI_DERIVED(ResourceSDLPointer) public: - ResourceSDLPointer(); - void deserialization(MyGUI::xml::ElementPtr _node, MyGUI::Version _version) override; SDL_SystemCursor getPointerType() @@ -32,7 +29,7 @@ } private: - SDL_SystemCursor mCursorType; + SDL_SystemCursor mCursorType{SDL_NUM_SYSTEM_CURSORS}; }; } diff -Nru mygui-3.4.2+dfsg/Common/ItemBox/BaseCellView.h mygui-3.4.3+dfsg/Common/ItemBox/BaseCellView.h --- mygui-3.4.2+dfsg/Common/ItemBox/BaseCellView.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/ItemBox/BaseCellView.h 2023-08-06 21:45:08.000000000 +0000 @@ -14,14 +14,13 @@ namespace wraps { template - class BaseCellView : - public BaseLayout + class BaseCellView : public BaseLayout { public: - typedef DataType Type; + using Type = DataType; protected: - BaseCellView(const std::string& _layout, MyGUI::Widget* _parent) : + BaseCellView(std::string_view _layout, MyGUI::Widget* _parent) : BaseLayout(_layout, _parent) { } diff -Nru mygui-3.4.2+dfsg/Common/ItemBox/BaseItemBox.h mygui-3.4.3+dfsg/Common/ItemBox/BaseItemBox.h --- mygui-3.4.2+dfsg/Common/ItemBox/BaseItemBox.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/ItemBox/BaseItemBox.h 2023-08-06 21:45:08.000000000 +0000 @@ -15,15 +15,14 @@ namespace wraps { template - class BaseItemBox : - public BaseLayout + class BaseItemBox : public BaseLayout { public: - typedef typename CellType::Type DataType; + using DataType = typename CellType::Type; public: BaseItemBox(MyGUI::Widget* _parent) : - BaseLayout("", _parent) + BaseLayout(std::string_view{}, _parent) { mBoxItems = mMainWidget->castType(); mBoxItems->setUserData(static_cast(this)); @@ -82,7 +81,7 @@ mBoxItems->setItemDataAt(_index, _data); } - template + template ValueType* getItemDataAt(size_t _index, bool _throw = true) { return mBoxItems->getItemDataAt(_index, _throw); @@ -141,13 +140,13 @@ } public: - MyGUI::delegates::CDelegate3 eventStartDrag; - MyGUI::delegates::CDelegate3 eventRequestDrop; - MyGUI::delegates::CDelegate3 eventDropResult; - MyGUI::delegates::CDelegate2 eventChangeDDState; - MyGUI::delegates::CDelegate2 eventNotifyItem; + MyGUI::delegates::Delegate eventStartDrag; + MyGUI::delegates::Delegate eventRequestDrop; + MyGUI::delegates::Delegate eventDropResult; + MyGUI::delegates::Delegate eventChangeDDState; + MyGUI::delegates::Delegate eventNotifyItem; - MyGUI::delegates::CDelegate3 eventToolTip; + MyGUI::delegates::Delegate eventToolTip; MyGUI::ItemBox* getItemBox() const { @@ -155,7 +154,7 @@ } private: - typedef std::vector VectorCellView; + using VectorCellView = std::vector; VectorCellView mListCellView; MyGUI::ItemBox* mBoxItems; }; diff -Nru mygui-3.4.2+dfsg/Common/MessageBox/MessageBox.h mygui-3.4.3+dfsg/Common/MessageBox/MessageBox.h --- mygui-3.4.2+dfsg/Common/MessageBox/MessageBox.h 2023-05-09 09:46:12.000000000 +0000 +++ mygui-3.4.3+dfsg/Common/MessageBox/MessageBox.h 2023-08-06 21:45:08.000000000 +0000 @@ -14,10 +14,9 @@ { class Message; - typedef delegates::CMultiDelegate2 EventHandle_MessageBoxPtrMessageStyle; + using EventHandle_MessageBoxPtrMessageStyle = delegates::MultiDelegate; - class Message : - public wraps::BaseLayout + class Message : public wraps::BaseLayout { public: Message() : @@ -33,7 +32,7 @@ initialise(); } - Message(const std::string& _layoutName) : + Message(std::string_view _layoutName) : wraps::BaseLayout(_layoutName), mWidgetText(nullptr), mInfoOk(MessageBoxStyle::None), @@ -69,20 +68,22 @@ /** Create button with specific name*/ MessageBoxStyle addButtonName(const UString& _name) { - if (mVectorButton.size() >= MessageBoxStyle::_CountUserButtons) + if (mVectorButton.size() >= MessageBoxStyle::_countUserButtons) { MYGUI_LOG(Warning, "Too many buttons in message box, ignored"); return MessageBoxStyle::None; } // бит, номер кнопки + смещение до Button1 - MessageBoxStyle info = MessageBoxStyle(MessageBoxStyle::Enum(MYGUI_FLAG(mVectorButton.size() + MessageBoxStyle::_IndexUserButton1))); + MessageBoxStyle info = MessageBoxStyle( + MessageBoxStyle::Enum(MYGUI_FLAG(mVectorButton.size() + MessageBoxStyle::_indexUserButton1))); // запоминаем кнопки для отмены и подтверждения if (mVectorButton.empty()) mInfoOk = info; mInfoCancel = info; - Widget* widget = mMainWidget->createWidgetT(mButtonType, mButtonSkin, IntCoord(), Align::Left | Align::Bottom); + Widget* widget = + mMainWidget->createWidgetT(mButtonType, mButtonSkin, IntCoord(), Align::Left | Align::Bottom); Button* button = widget->castType