From ff7fca93110ebf07dd134d982008fcf9b9092508 Mon Sep 17 00:00:00 2001 From: ErrorFlynn Date: Mon, 3 Feb 2020 02:49:20 -0500 Subject: [PATCH 1/5] fix: submenu option items unresponsive to clicks When the user opens a submenu containing items with the style `menu::checks::option` and clicks an option, the radio button logic doesn't work. This bug was discovered and fixed by nanapro.org forum user "huycan" (I'm just submitting the PR). See this forum post: http://nanapro.org/en-us/forum/index.php?u=/topic/1256/ggleave-a-menu-open As mentioned in more detail in the forum post linked above, my understanding of why this happens is that `menu_builder::checked` fails because the `menu_window` of the submenu is created with the `menu_builder` object used by the parent menu. --- source/gui/widgets/menu.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index 26b21812..750e8422 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -921,7 +921,25 @@ namespace nana } else if (checks::option == item.style) { - get_drawer_trigger().mbuilder().checked(active, true); + if(active > 0) + { + do { + if(menu->items[--active]->flags.splitter) + { + ++active; + break; + } + } while(active > 0); + } + while(active < menu->items.size()) + { + menu_item_type &el = *(menu->items[active++]); + if(el.flags.splitter) + break; + if(checks::option == el.style) + el.flags.checked = false; + } + item.flags.checked = true; } this->_m_close_all(); //means deleting this; From add0af843ee436b6dbd9658a919103fc2607f54e Mon Sep 17 00:00:00 2001 From: besh81 Date: Fri, 7 Feb 2020 13:06:34 +0100 Subject: [PATCH 2/5] added treebox use_entire_line mode Added new interaction/display mode to treebox control. Enabling use_entire_line the entire line of the treebox/child is used for mouse interactions and display purposes. --- include/nana/gui/widgets/treebox.hpp | 8 ++++++++ source/gui/widgets/treebox.cpp | 23 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index d6d67cc8..eaae22e5 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -492,6 +492,14 @@ namespace nana /// Gets the current hovered node. item_proxy hovered(bool exclude_expander) const; + + + /// Enable/disable the interactions (selection, click, ...) on the entire line of the treebox. + /** + * @param enable bool whether to enable. + */ + void use_entire_line(bool enable); + private: std::shared_ptr _m_scroll_operation() override; diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 7e056b1d..0a114471 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -295,7 +295,12 @@ namespace nana if (impl_->data.comp_placer->locate(comp, node_attr_, &attr.area)) { attr.mouse_pointed = node_attr_.mouse_pointed; - attr.area.x += pos_.x; + + if(comp == component_t::bground && impl_->use_entire_line) + attr.area.width = impl_->visible_w_pixels(); + else + attr.area.x += pos_.x; + attr.area.y += pos_.y; return true; } @@ -362,6 +367,9 @@ namespace nana std::size_t scroll_timestamp; nana::timer timer; }adjust; + + bool use_entire_line; + public: implementation() { @@ -386,6 +394,8 @@ namespace nana adjust.offset_x_adjust = 0; adjust.node = nullptr; adjust.scroll_timestamp = 0; + + use_entire_line = false; } void assign_node_attr(node_attribute& ndattr, const node_type* node) const @@ -1675,8 +1685,8 @@ namespace nana nana::rectangle r = node_r; if (!comp_placer->locate(static_cast(comp), node_attr_, &r)) continue; - - if (r.is_hit(logic_pos)) + + if((comp == static_cast(component::bground) && impl_->use_entire_line) || r.is_hit(logic_pos)) { node_ = &node; what_ = static_cast(comp); @@ -2023,6 +2033,7 @@ namespace nana { case component::icon: case component::text: + case component::bground: impl_->set_expanded(node, !node->value.second.expanded); impl_->draw(true, true, false); API::dev::lazy_refresh(); @@ -2448,6 +2459,12 @@ namespace nana return item_proxy(const_cast(dw), dw->impl()->node_state.pointed); } + void treebox::use_entire_line(bool enable) + { + auto dw = &get_drawer_trigger(); + dw->impl()->use_entire_line = enable; + } + std::shared_ptr treebox::_m_scroll_operation() { internal_scope_guard lock; From da295d8c477fecd05bab3c9f6d53e6cd06fb9b1a Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 10 Feb 2020 11:12:30 +0800 Subject: [PATCH 3/5] update the nana version in CMakeLists to 1.7.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0b3e008..e9a9ee48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ # cmake 3.12 have more better modern c++ support cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(nana VERSION 1.7.2 +project(nana VERSION 1.7.3 DESCRIPTION "C++ GUI library" HOMEPAGE_URL http://nanapro.org LANGUAGES CXX ) From f9c0de96981005be9a2a3a7d9848c70cbc790293 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 11 Feb 2020 05:49:56 +0800 Subject: [PATCH 4/5] fix compiler error on VS2015 --- source/filesystem/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 19128e2a..bacd1bef 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -1386,7 +1386,7 @@ namespace std { namespace filesystem { -#if defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)) +#if defined(_MSC_VER) && (_MSC_VER < 1900) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)) path absolute(const path& p) { From cfad078740a3be0d07fffcd8aff588a95834ae71 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 11 Feb 2020 06:13:10 +0800 Subject: [PATCH 5/5] fix compiler error on VS2015 --- source/filesystem/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index bacd1bef..bebc7c8a 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -1386,7 +1386,7 @@ namespace std { namespace filesystem { -#if defined(_MSC_VER) && (_MSC_VER < 1900) && ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703)) +#if defined(_MSC_VER) && ((_MSC_VER < 1900) || ((!defined(_MSVC_LANG)) || (_MSVC_LANG < 201703))) path absolute(const path& p) {