diff --git a/include/nana/gui/widgets/detail/tree_cont.hpp b/include/nana/gui/widgets/detail/tree_cont.hpp index 94f9f1c1..ab3e671a 100644 --- a/include/nana/gui/widgets/detail/tree_cont.hpp +++ b/include/nana/gui/widgets/detail/tree_cont.hpp @@ -1,6 +1,6 @@ /* * A Tree Container class implementation - * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2020 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -508,7 +508,7 @@ namespace detail void _m_for_each(const ::std::string& key, Function function) const { //Ignores separaters at the begin of key. - ::std::string::size_type beg = key.find_first_not_of("\\/"); + auto beg = key.find_first_not_of("\\/"); if (key.npos == beg) return; diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index b5d29e40..d6d67cc8 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -1,7 +1,7 @@ /** * A Tree Box Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2020 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at @@ -49,7 +49,7 @@ namespace nana struct node_attribute { - bool has_children; + bool has_children; ///< Determines whether the node has visible children bool expended; checkstate checked; bool selected; diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 990b35c4..ee0ca75c 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -1,7 +1,7 @@ /* * A Treebox Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2010 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -387,7 +387,18 @@ namespace nana void assign_node_attr(node_attribute& ndattr, const node_type* node) const { - ndattr.has_children = (nullptr != node->child); + // Check if there is a visible child that node has. + // This is an improvement based on a new feature that allows treebox node to be hidden(PR#500) + ndattr.has_children = false; + for (auto p = node->child; p; p = p->next) + { + if (!p->value.second.hidden) + { + ndattr.has_children = true; + break; + } + } + ndattr.expended = node->value.second.expanded; ndattr.text = node->value.second.text; ndattr.checked = node->value.second.checked; @@ -1445,7 +1456,7 @@ namespace nana switch(comp) { case component_t::expander: - if(attr.has_children) + if (attr.has_children) { r->width = scheme_.item_offset; return true;