Merge branch 'hotfix-1.5.6' into develop-c++17

This commit is contained in:
Jinhao 2018-01-29 17:19:13 +08:00
commit 211433afdd
10 changed files with 87 additions and 45 deletions

View File

@ -329,6 +329,8 @@ namespace API
void window_size(window, const size&);
size window_outline_size(window);
void window_outline_size(window, const size&);
nana::optional<rectangle> 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);

View File

@ -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

View File

@ -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?
}

View File

@ -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<T>({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);
}

View File

@ -1,7 +1,7 @@
/*
* Window Layout 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
@ -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
@ -386,6 +389,13 @@ namespace nana
nana::rectangle r_of_sigwd(sigwd->pos_root, sigwd->dimension);
for (auto wd : data_sect.effects_bground_windows)
{
//Don't notify the window if both native root windows are not same(e.g. wd and sigwd have
//a some parent). Otherwise, _m_paint_glass_window() recursively paints sigwd to make stack overflow.
//On the other hand, a nested root window is always floating on its parent's child widgets, it's unnecessary to
//notify the wd if they haven't a same native root window.
if (sigwd->root != wd->root)
continue;
if (wd == sigwd || !wd->displayed() ||
(false == overlapped(nana::rectangle{ wd->pos_root, wd->dimension }, r_of_sigwd)))
continue;

View File

@ -821,6 +821,15 @@ namespace API
}
}
nana::optional<rectangle> window_rectangle(window wd)
{
auto iwd = reinterpret_cast<basic_window*>(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<basic_window*>(wd);

View File

@ -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<int>(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<unsigned>(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
);
}
});
}

View File

@ -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
@ -1586,7 +1586,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;
@ -1595,7 +1595,7 @@ namespace nana
pos.item = 0;
for(auto & m : cat.items)
{
if (except != pos)
if (except_abs != pos)
{
if (m.flags.selected != sel)
{
@ -4150,12 +4150,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
}
}
}
@ -4662,12 +4662,12 @@ namespace nana
bool item_proxy::operator==(const std::string& s) const
{
return (text(pos_.item) == s);
return (text(0) == s);
}
bool item_proxy::operator==(const std::wstring& s) const
{
return (text(pos_.item) == to_utf8(s));
return (text(0) == to_utf8(s));
}
item_proxy & item_proxy::operator=(const item_proxy& rhs)
@ -5158,7 +5158,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

View File

@ -1,6 +1,6 @@
/*
* A Progress Indicator Implementation
* 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
@ -96,7 +96,11 @@ namespace nana
{
if (widget_)
{
auto value_px = (widget_->size().width - border_px * 2) * value_ / max_;
auto value_px = (widget_->size().width - border_px * 2);
//avoid overflow
if (value_ < max_)
value_px = static_cast<unsigned>(value_px * (double(value_) / double(max_)));
if (value_px != value_px_)
{

View File

@ -91,7 +91,7 @@ namespace nana
{
::jpeg_create_decompress(&jdstru);
::jpeg_mem_src(&jdstru, const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(data)), bytes);
::jpeg_mem_src(&jdstru, const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(data)), static_cast<unsigned long>(bytes));
_m_read_jpg(jdstru);
jpeg_finish_decompress(&jdstru);