diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 02ce947f..cb795e5f 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -301,6 +301,8 @@ namespace API void window_size(window, const size&); size window_outline_size(window); void window_outline_size(window, const size&); + + nana::optional window_rectangle(window); bool get_window_rectangle(window, rectangle&); bool track_window_size(window, const size&, bool true_for_max); ///< Sets the minimum or maximum tracking size of a window. void window_enabled(window, bool); diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index be3d571f..a2fa3542 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -1,7 +1,7 @@ /** * A List Box Implementation * 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/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index c4e39981..0603c308 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -398,7 +398,7 @@ namespace nana /// \brief The construct that creates a widget. /// @param wd A handle to the parent window of the widget being created. /// @param visible specify the visibility after creation. - scroll(window wd, bool visible) + scroll(window wd, bool visible = true) { this->create(wd, rectangle(), visible); // add a widget scheme? and take some colors from these wd? } diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 0e2e2e9c..a24cce4a 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -1,7 +1,7 @@ /** * A Tabbar implementation * 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 @@ -42,9 +42,8 @@ namespace nana : arg_tabbar({wdg, v}) {} - bool remove = true; ///< determines whether to remove the item - bool close_attach_window = true; ///< determines whether to close the attached window. It is ignored if remove is false - + mutable bool remove = true; ///< determines whether to remove the item + mutable bool close_attach_window = true; ///< determines whether to close the attached window. It is ignored if remove is false }; namespace drawerbase @@ -293,7 +292,7 @@ namespace nana if (pos > length()) throw std::out_of_range("tabbar::insert invalid position"); - this->get_drawer_trigger().insert(pos, to_nstring(text), std::move(value)); + this->get_drawer_trigger().insert(pos, to_nstring(std::move(text)), std::move(value)); API::update_window(*this); } diff --git a/source/gui/detail/window_layout.cpp b/source/gui/detail/window_layout.cpp index 4add7b03..45764b81 100644 --- a/source/gui/detail/window_layout.cpp +++ b/source/gui/detail/window_layout.cpp @@ -106,43 +106,46 @@ namespace nana visual = rectangle{ wd->pos_root, wd->dimension }; - if (wd->root_widget != wd) + if (category::flags::root != wd->other.category) { //Test if the root widget is overlapped the specified widget //the pos of root widget is (0, 0) if (overlapped(visual, rectangle{ wd->root_widget->pos_owner, wd->root_widget->dimension }) == false) return false; - } - for (auto parent = wd->parent; parent; parent = parent->parent) - { - if (category::flags::root == parent->other.category) + for (auto parent = wd->parent; parent; parent = parent->parent) { - //visual rectangle of wd's parent - rectangle vrt_parent{parent->pos_root, parent->dimension}; - - point pos_root; - while (parent->parent) + if (category::flags::root == parent->other.category) { - pos_root -= native_interface::window_position(parent->root); - - if (!overlap(rectangle{ pos_root, parent->parent->root_widget->dimension }, vrt_parent, vrt_parent)) - return false; - - parent = parent->parent->root_widget; + wd = parent; + break; } - if (!overlap(vrt_parent, visual, visual)) + if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual)) return false; - - return true; } - - if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual)) - return false; } - return true; + //Now, wd actually is the root widget of original parameter wd + if (nullptr == wd->parent) + return true; + + auto parent_rw = wd->parent->root_widget; + //visual rectangle of wd's parent + rectangle vrt_parent{ parent_rw->pos_root, parent_rw->dimension }; + + point pos_root; + while (parent_rw->parent) + { + pos_root -= native_interface::window_position(parent_rw->root); + + if (!overlap(rectangle{ pos_root, parent_rw->parent->root_widget->dimension }, vrt_parent, vrt_parent)) + return false; + + parent_rw = parent_rw->parent->root_widget; + } + + return overlap(vrt_parent, visual, visual); } //read_overlaps diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 0d8986f8..9ddf5842 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -823,6 +823,15 @@ namespace API } } + nana::optional window_rectangle(window wd) + { + auto iwd = reinterpret_cast(wd); + internal_scope_guard lock; + if (restrict::wd_manager().available(iwd)) + return rectangle(iwd->pos_owner, iwd->dimension); + return{}; + } + bool get_window_rectangle(window wd, rectangle& r) { auto iwd = reinterpret_cast(wd); diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index ab8e9e73..87d2ebc6 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -208,8 +208,8 @@ namespace nana{ outter[field_title] << impl_->caption; outter.collocate(); + impl_->caption.transparent(true); color pbg = API::bgcolor(this->parent()); - impl_->caption.bgcolor(pbg.blend(colors::black, 0.025)); this->bgcolor(pbg.blend(colors::black, 0.05)); @@ -222,10 +222,27 @@ namespace nana{ auto gap_px = impl_->gap - 1; 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) + + auto const top_round_line = static_cast(impl_->caption_dimension.height) / 2; + + graph.round_rectangle(rectangle(point(gap_px, top_round_line), + nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px) ), 3, 3, colors::gray_border, true, this->bgcolor()); + + 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) } }; + + 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 + ); + } }); } diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 5561c604..e97b0cab 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1,7 +1,7 @@ /* * A List Box Implementation * 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 @@ -1595,7 +1595,7 @@ namespace nana return pairs; } - bool select_for_all(bool sel, const index_pair& except = index_pair{npos, npos}) + bool select_for_all(bool sel, const index_pair& except_abs = index_pair{npos, npos}) { bool changed = false; index_pair pos; @@ -1604,7 +1604,7 @@ namespace nana pos.item = 0; for(auto & m : cat.items) { - if (except != pos) + if (except_abs != pos) { if (m.flags.selected != sel) { @@ -4223,12 +4223,12 @@ namespace nana //Unselects all selected items if the current item is not selected before selecting. auto selected = lister.pick_items(true); if (selected.cend() == std::find(selected.cbegin(), selected.cend(), item_pos)) - lister.select_for_all(false, item_pos); + lister.select_for_all(false, abs_item_pos); } else { //Unselects all selected items except current item if right button clicked. - lister.select_for_all(false, item_pos); //cancel all selections + lister.select_for_all(false, abs_item_pos); //cancel all selections } } } @@ -5231,7 +5231,8 @@ namespace nana cat_->make_sort_order(); ess_->lister.sort(); - ess_->update(true); + //Don't ignore the auto-draw flag for performance enhancement. + ess_->update(); } } //end class cat_proxy diff --git a/source/paint/detail/image_jpeg.hpp b/source/paint/detail/image_jpeg.hpp index 1f19373b..d63a2c1d 100644 --- a/source/paint/detail/image_jpeg.hpp +++ b/source/paint/detail/image_jpeg.hpp @@ -91,7 +91,7 @@ namespace nana { ::jpeg_create_decompress(&jdstru); - ::jpeg_mem_src(&jdstru, const_cast(reinterpret_cast(data)), bytes); + ::jpeg_mem_src(&jdstru, const_cast(reinterpret_cast(data)), static_cast(bytes)); _m_read_jpg(jdstru); jpeg_finish_decompress(&jdstru);