From 2c04ba7bf33b2f413e12bf2f27c6e4caec77d5eb Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 03:17:49 +0100 Subject: [PATCH] all demos added because exec() don't need main form to exit_all --- .travis.yml | 49 +++++++++++++++++++++++++++++--------- CMakeLists.txt | 13 ++++------ include/nana/config.hpp | 8 ++----- include/nana/gui/wvl.hpp | 5 ++-- source/gui/wvl.cpp | 51 +++++++++++++++++----------------------- 5 files changed, 68 insertions(+), 58 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a0e87e7..3b573ebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,7 @@ script: - ./animate-bmp - ./audio_player - ./background-effects - #- ./calculator ? + - ./calculator - ./categ - ./clicked - ./decore @@ -94,18 +94,45 @@ script: - ./drag-button - ./draw - ./file_explorer - #- ./example_menu + - ./example_menu - ./example_listbox - #- ./example_combox + - ./example_combox - ./example.button + - ./folder_tree_nana + - ./folder_tree_std + - ./framework_design_1 + - ./framework_design_2 + - ./framework_design_3 + - ./group - ./HelloWord - #- ./MontiHall - #- ./helloworld_demo - #- ./notepad - #- ./loader_2 - #- ./widget_show2 - #- ./widget_show - - + - ./helloword_quit + - ./inputbox + - ./label_listener + - ./lambda_event.cpp11 + - ./listbox_inline_widget + - ./listbox_Resolver + - ./loader_1 + - ./loader_2 + - ./mbox + - ./menu_debug + - ./MontiHall + - ./helloworld_demo + - ./notepad + - ./loader_2 + - ./mbox + - ./menu_debug + - ./menu_popuper + - ./modal_form + - ./widget_show2 + - ./widget_show + - ./place_login + - ./png + - ./screen + - ./stretch_image + - ./threading + - ./thread-pool + - ./various_events + - ./window-dragger + - ./windows-subclassing diff --git a/CMakeLists.txt b/CMakeLists.txt index 95da4a64..7b622422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,6 @@ option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the option(NANA_CMAKE_BUILD_DEMOS "Build all the demos form the nana_demo repository." OFF) option(NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS "" ON) option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF) -option(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING "Add defoult automatic GUI test?" OFF) option(NANA_CMAKE_BUILD_FreeMe "Build FreeMe (currently broken)?" OFF) @@ -177,10 +176,6 @@ if(NANA_CMAKE_ENABLE_AUDIO) endif(UNIX) endif(NANA_CMAKE_ENABLE_AUDIO) -if (NANA_CMAKE_BUILD_FreeMe) - add_definitions(-DBUILD_FreeMe) -endif (NANA_CMAKE_BUILD_FreeMe) - if(NANA_CMAKE_VERBOSE_PREPROCESSOR) add_definitions(-DVERBOSE_PREPROCESSOR) endif(NANA_CMAKE_VERBOSE_PREPROCESSOR) @@ -249,10 +244,6 @@ if (NANA_CMAKE_BUILD_DEMOS) enable_testing () endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING) - if(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING) - add_definitions(-DNANA_ADD_DEF_AUTOMATIC_GUI_TESTING) - endif(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING) - set (demos calculator file_explorer helloworld_demo notepad ) foreach ( demo ${demos}) @@ -270,6 +261,10 @@ if (NANA_CMAKE_BUILD_DEMOS) set (demos widget_show widget_show2 ) +if (NANA_CMAKE_BUILD_FreeMe) + add_definitions(-DBUILD_FreeMe) +endif (NANA_CMAKE_BUILD_FreeMe) + if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) list(APPEND demos FreeMe) # ?? endif (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 99d73d31..4e1eb6ac 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -96,15 +96,11 @@ /////////////////// // Support for NANA_AUTOMATIC_GUI_TESTING -// Will cause the program to self-test the GUI. -// If NANA_ADD_DEF_AUTOMATIC_GUI_TESTING is also defined a default automatic GUI test +// Will cause the program to self-test the GUI. A default automatic GUI test // will be added to all programs which don't have yet one defined. This default test will simple // wait 10 sec. (time to construct, show and execute the GUI) and then exit normally. // -//#define NANA_AUTOMATIC_GUI_TESTING -//#if defined(NANA_AUTOMATIC_GUI_TESTING) - //#define NANA_ADD_DEF_AUTOMATIC_GUI_TESTING -//#endif +#define NANA_AUTOMATIC_GUI_TESTING diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index 176af43d..4da60f25 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -66,9 +66,8 @@ namespace nana /// from the underlying OS, interpreting and sending it with suitable arguments /// to the nana widgets that registered a response in the corresponding event. /// It also accept arguments to be used in case of automatic GUI testing. - /// Other Way the arguments are ignored. It seems that only works in simple - /// programs with only one active form ?? - void exec(form *main_form = nullptr, ///< used to close the program + /// Other Way the arguments are ignored. + void exec( unsigned wait = 1, ///< for the GUI to be constructed, in seconds unsigned wait_end = 1, ///< for the GUI to be destructed, in seconds std::function = {} ///< emit events to mimics user actions and may asert results diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 24e58ee0..1b475c80 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -49,46 +49,39 @@ namespace nana } - void exec(form *main_form, //= nullptr, ///< used to close the program + void exec( unsigned wait, // = 1, ///< for the GUI to be constructed, in seconds unsigned wait_end, // = 1, ///< for the GUI to be destructed, in seconds std::functionf // = {} ///< emit events to mimics user actions and may asert results ) { #ifdef NANA_AUTOMATIC_GUI_TESTING - //if (!wait) - // wait = 1; - //if (!main_form && !f) - // f = []() {API::exit_all(); }; std::cout << "Will wait " << wait << " sec...\n"; - std::thread t([wait, &f, wait_end, main_form]() - { if (wait) - { - Wait( wait ); - std::cout << "running... \n" ; - if (f) - { - f(); - std::cout << "\nCongratulations, this was not trivial !" << std::endl; - }else - { - std::cout << "\nJust a trivial test." << std::endl; - } - std::cout << "Done... \n"; - std::cout << "Now again "; - Wait(wait_end); - std::cout << "Done... Now closing the main form...\n"; - /*if (main_form) - main_form->close();*/ - std::cout << "Closed... Now API::exit ...\n"; - API::exit_all(); // why not works? - std::cout << "Done... Upps - this had not to appear !! \n"; - } - }); + + std::thread t([wait, &f, wait_end]() + { + Wait( wait ); + std::cout << "running... \n" ; + if (f) + { + f(); + std::cout << "\nCongratulations, this was not trivial !" << std::endl; + }else + { + std::cout << "\nJust a trivial test." << std::endl; + } + std::cout << "Done... \n"; + std::cout << "Now again "; + Wait(wait_end); + std::cout << "Done... Now API::exit all ...\n"; + API::exit_all(); + }); + pump(); if (t.joinable()) t.join(); + #else pump(); #endif