From 40a6584a757f7adaf0fe4eaaf62d6a7f4d10f747 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 1 Jul 2018 15:06:15 +0800 Subject: [PATCH] fix bug that group draws gradual rectangle for caption at wrong position --- include/nana/gui/msgbox.hpp | 2 +- source/gui/widgets/group.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/nana/gui/msgbox.hpp b/include/nana/gui/msgbox.hpp index a8a447bf..a004fd21 100644 --- a/include/nana/gui/msgbox.hpp +++ b/include/nana/gui/msgbox.hpp @@ -1,7 +1,7 @@ /* * A Message Box Class * Nana C++ Library(http://www.nanapro.org) -* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) +* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index e9ece21a..21a9ffe0 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -264,15 +264,22 @@ namespace nana{ drawing dw(*this); + //When the group is resized, the drawing is called before moving the caption, but + //the drawing of group requires the lastest position of caption for gradual rectangle. + //For the requirement, a move event handler is required for listning the change of caption's position. + impl_->caption.events().move([this](const arg_move& arg){ + if (align::left != impl_->caption_align) + API::refresh_window(*this); + }); + // This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !! dw.draw([this](paint::graphics& graph) { auto gap_px = impl_->gap - 1; - graph.rectangle(true, API::bgcolor(this->parent())); - auto const top_round_line = static_cast(impl_->caption_dimension.height) / 2; + graph.rectangle(true, API::bgcolor(this->parent())); graph.round_rectangle(rectangle(point(gap_px, top_round_line), nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px) ), @@ -281,11 +288,10 @@ namespace nana{ auto opt_r = API::window_rectangle(impl_->caption); if (opt_r) { - rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width, static_cast(top_round_line - opt_r->y) } }; + rectangle grad_r{ opt_r->position(), nana::size{ opt_r->width + 4, static_cast(top_round_line - opt_r->y) } }; grad_r.y += top_round_line*2 / 3; grad_r.x -= 2; - grad_r.width += 4; graph.gradual_rectangle(grad_r, API::bgcolor(this->parent()), this->bgcolor(), true