From 7c36c27d4639e08c2014ec605f28b33c878a6fdb Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 11 Oct 2016 02:53:41 +0800 Subject: [PATCH] fix group bgcolor issue --- source/gui/detail/window_manager.cpp | 2 +- source/gui/widgets/group.cpp | 37 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 63e30e48..5cfe1d10 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -1048,7 +1048,7 @@ namespace detail { //The window is still mapped because of edge nimbus effect. //Avoid duplicate copy if action state is not changed and the window is not focused. - if ((wd->flags.action != wd->flags.action_before) || (bedrock::instance().focus() == wd)) + if (wd->flags.action != wd->flags.action_before) this->map(wd, true); } } diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index 91b1bd9a..615bfac2 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -1,7 +1,7 @@ /** * A group widget implementation * Nana C++ Library(http://www.nanaro.org) - * Copyright(C) 2015 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2015-2016 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -36,6 +36,8 @@ namespace nana{ unsigned gap{2}; std::string usr_div_str; + nana::size caption_dimension; + std::vector> options; radio_group * radio_logic{nullptr}; @@ -60,19 +62,18 @@ namespace nana{ void update_div() { - ::nana::size sz = caption.measure(1000); + caption_dimension = caption.measure(1000); - std::stringstream ss; - ss << "vert margin=[0," << gap << "," << gap + 5 << "," << gap << "]" - << " <" << field_title << " weight=" << sz.width + 1 << "> >" - << "<"; + std::string div = "vert margin=[0," + std::to_string(gap) + "," + std::to_string(gap + 5) + "," + std::to_string(gap) + "]"; + div += "<" + field_title + " weight=" + std::to_string(caption_dimension.width + 1) + ">>"; + div += "<"; if (!usr_div_str.empty()) - ss << "<" << usr_div_str << ">>"; + div += "<" + usr_div_str + ">>"; else - ss << ">"; + div += ">"; - place_content.div(ss.str().c_str()); + place_content.div(div.c_str()); if (options.empty()) place_content.field_display(field_options, false); @@ -202,25 +203,23 @@ namespace nana{ outter.collocate(); color pbg = API::bgcolor(this->parent()); - impl_->caption.bgcolor(pbg.blend(colors::black, 0.975)); - color bg = pbg.blend(colors::black, 0.950); - bgcolor(bg); + impl_->caption.bgcolor(pbg.blend(colors::black, 0.975)); + + this->bgcolor(pbg.blend(colors::black, 0.950)); drawing dw(*this); - ::nana::size sz = impl_->caption.measure(1000); - // This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !! - dw.draw([this, sz, bg, pbg](paint::graphics& graph) + dw.draw([this](paint::graphics& graph) { auto gap_px = impl_->gap - 1; - graph.rectangle(true, pbg); - graph.round_rectangle(rectangle(point(gap_px, sz.height / 2), - nana::size(graph.width() - 2 * gap_px, graph.height() - sz.height / 2 - gap_px) + graph.rectangle(true, API::bgcolor(this->parent())); + graph.round_rectangle(rectangle(point(gap_px, impl_->caption_dimension.height / 2), + nana::size(graph.width() - 2 * gap_px, graph.height() - impl_->caption_dimension.height / 2 - gap_px) ), - 3, 3, colors::gray_border, true, bg); + 3, 3, colors::gray_border, true, this->bgcolor()); }); }