From 813911b215626171e61cd2b285f23d46df9997b3 Mon Sep 17 00:00:00 2001 From: Gammasoft Date: Thu, 18 Apr 2024 15:38:47 +0200 Subject: [PATCH] Add XTD_KEEP_CLONED_CONTROLS option and set by default to false --- CMakeLists.txt | 8 +++++++- src/xtd.forms/include/xtd/forms/application.h | 4 ++-- src/xtd.forms/src/xtd/forms/application.cpp | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95e1d58df2ea..3c5adfc0bfbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,10 @@ option(XTD_ENABLE_RUN_DEVELOPPER_REFERENCE_GUIDE "Add run Developper Reference G option(XTD_ENABLE_RUN_REFERENCE_GUIDE "Add run Reference Guide generator command" ON) option(XTD_INSTALL_EXAMPLES "Install examples" ON) option(XTD_INSTALL_RESOURCES "Install resources" ON) +option(XTD_KEEP_CLONED_CONTROLS "Keep cloned controls by default (Only for debugging)" OFF) option(XTD_SET_COMPILER_OPTION_WARNINGS_TO_ALL "Enable compiler option warnings to all" ON) option(XTD_SET_COMPILER_OPTION_WARNINGS_AS_ERRORS "Enable compiler option warnings as errors" OFF) -option(XTD_USE_SYSTEM_CONTROLS "Use by default system controls instead standard controls" OFF) +option(XTD_USE_SYSTEM_CONTROLS "Use by default system controls instead standard controls (Only for debugging)" OFF) add_definitions(-D__XTD_INSTALL_PATH__="${CMAKE_INSTALL_PREFIX}") add_definitions(-D__XTD_LOCALE_PATH__="${CMAKE_INSTALL_PREFIX}/share/xtd/locale") add_definitions(-D__XTD_REFERENCE_GUIDE_PATH__="${CMAKE_INSTALL_PREFIX}/share/xtd/reference_guide") @@ -44,6 +45,11 @@ if (XTD_BUILD_WITH_CONTINUOUS_INTEGRATION_SYSTEM) add_definitions(-D__XTD_BUILD_WITH_CONTINUOUS_INTEGRATION_SYSTEM__) endif () +if (XTD_KEEP_CLONED_CONTROLS) + message(WARNING "The XTD_KEEP_CLONED_CONTROLS option can only be used for debugging.\nUse xtd::application::keep_cloned_controls() instead.\nSee https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1forms_1_1application.html#a28ad4db693e3bf228e5f0902fdf5882a for more information") + add_definitions(-D__ XTD_KEEP_CLONED_CONTROLS__) +endif () + if (XTD_USE_SYSTEM_CONTROLS) message(WARNING "The XTD_USE_SYSTEM_CONTROLS option can only be used for debugging.\nUse xtd::application::enable_system_controls() instead.\nSee https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1forms_1_1application.html#a28ad4db693e3bf228e5f0902fdf5882a for more information") add_definitions(-D__XTD_USE_SYSTEM_CONTROLS__) diff --git a/src/xtd.forms/include/xtd/forms/application.h b/src/xtd.forms/include/xtd/forms/application.h index 325b54e21744..650a3f2d3b6e 100644 --- a/src/xtd.forms/include/xtd/forms/application.h +++ b/src/xtd.forms/include/xtd/forms/application.h @@ -140,13 +140,13 @@ namespace xtd { /// @brief Gets a value indicating whether the xtd framework keep cloned control is enabled. /// @return true if xtd framework keep cloned control is enabled; otherwise false. - /// @remarks By default the value is true. + /// @remarks By default the value is false. static bool keep_cloned_controls() noexcept; /// @brief Sets a value indicating whether the xtd framework keep cloned control is enabled. /// @param value true if xtd framework keep cloned control is enabled; otherwise false. /// @exception xtd::invalid_operation_exception If this method is called after xtd::forms::application::run. - /// @remarks By default the value is true. + /// @remarks By default the value is false. static void keep_cloned_controls(bool value); /// @brief Gets a value indicating whether light mode is enabled for the application. diff --git a/src/xtd.forms/src/xtd/forms/application.cpp b/src/xtd.forms/src/xtd/forms/application.cpp index c98bd7b9ce78..98d3271e2a7d 100644 --- a/src/xtd.forms/src/xtd/forms/application.cpp +++ b/src/xtd.forms/src/xtd/forms/application.cpp @@ -76,7 +76,11 @@ namespace { xtd::forms::application_context application::internal_context_; xtd::forms::application_context* application::context_ = &application::internal_context_; bool application::button_images_ = true; +#if defined(__XTD_KEEP_CLONED_CONTROLS__) bool application::keep_cloned_controls_ = true; +#else +bool application::keep_cloned_controls_ = false; +#endif bool application::font_size_correction_ = true; bool application::light_mode_ = false; bool application::menu_images_ = true;