From add0af843ee436b6dbd9658a919103fc2607f54e Mon Sep 17 00:00:00 2001 From: besh81 Date: Fri, 7 Feb 2020 13:06:34 +0100 Subject: [PATCH] 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;