From 3d810fddac0caee17b8fbb3d8b32938776e37d76 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 30 Jun 2018 05:22:34 +0800 Subject: [PATCH 1/4] fix issue of fold expressions test(#320,#321) --- include/nana/gui/msgbox.hpp | 4 ++++ include/nana/internationalization.hpp | 2 +- source/gui/msgbox.cpp | 4 ++-- source/internationalization.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/nana/gui/msgbox.hpp b/include/nana/gui/msgbox.hpp index 02b4fe35..a8a447bf 100644 --- a/include/nana/gui/msgbox.hpp +++ b/include/nana/gui/msgbox.hpp @@ -255,7 +255,11 @@ namespace nana bool show_modal(Args&& ... args) { std::vector contents; +#ifdef __cpp_fold_expressions + (contents.emplace_back(&args), ...); +#else _m_fetch_args(contents, std::forward(args)...); +#endif if (contents.empty()) return false; diff --git a/include/nana/internationalization.hpp b/include/nana/internationalization.hpp index cab02568..cba03bf5 100644 --- a/include/nana/internationalization.hpp +++ b/include/nana/internationalization.hpp @@ -1,7 +1,7 @@ /* * An Implementation of i18n * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2016 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/msgbox.cpp b/source/gui/msgbox.cpp index 36a7c202..caf6380b 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -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 @@ -1294,7 +1294,7 @@ namespace nana min_width_entry_field_pixels_ = pixels; } -#ifndef _nana_cxx_folding_expression +#ifndef __cpp_fold_expressions void inputbox::_m_fetch_args(std::vector&) {} #endif diff --git a/source/internationalization.cpp b/source/internationalization.cpp index 6e4a99d5..d41b775c 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -417,7 +417,7 @@ namespace nana } } -#ifndef _nana_cxx_folding_expression +#ifndef __cpp_fold_expressions void internationalization::_m_fetch_args(std::vector&) {} #endif From 40a6584a757f7adaf0fe4eaaf62d6a7f4d10f747 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 1 Jul 2018 15:06:15 +0800 Subject: [PATCH 2/4] 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 From 5a4edd2fefd0da46cf461e59485572380ddea35b Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 2 Jul 2018 05:42:56 +0800 Subject: [PATCH 3/4] fix bug that widgets may not draw correctly --- source/gui/detail/window_manager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 2a98269e..785f45be 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -950,6 +950,19 @@ namespace detail if (wd->dimension == sz) return false; + std::vector presence; + + if (wd->dimension.width < sz.width || wd->dimension.height < sz.height) + { + auto wd_r = rectangle{ wd->dimension }; + for (auto child : wd->children) + { + auto child_r = rectangle{ child->pos_owner, child->dimension }; + if (!overlapped(wd_r, child_r)) + presence.push_back(child); + } + } + //Before resiz the window, creates the new graphics paint::graphics graph; paint::graphics root_graph; @@ -1010,6 +1023,11 @@ namespace detail } } + for (auto child : presence) + { + refresh_tree(child); + } + arg_resized arg; arg.window_handle = reinterpret_cast(wd); arg.width = sz.width; From 6add8868da61505e1db96fef2279a98c4a03fb1b Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 4 Jul 2018 21:47:47 +0800 Subject: [PATCH 4/4] nana::listbox::scroll not scrolling to correct location(#322) --- source/gui/widgets/listbox.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 3b41311d..e0c67f0a 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2996,11 +2996,11 @@ namespace nana } else { - auto last_off = this->distance(this->first(), this->last()) * ess_->item_height(); - if (last_off - off >= screen_px) + auto const content_px = ess_->content_view->content_size().height; + if (content_px - off >= screen_px) origin.y = static_cast(off); - else if (last_off >= screen_px) - origin.y = static_cast(last_off - screen_px); + else if (content_px >= screen_px) + origin.y = static_cast(content_px - screen_px); } if (ess_->content_view->move_origin(origin - ess_->content_view->origin()))