Merge branch 'hotfix-1.6.1' into develop

This commit is contained in:
Jinhao
2018-08-19 15:24:05 +08:00
42 changed files with 1148 additions and 230 deletions

View File

@@ -2934,9 +2934,9 @@ namespace nana
cat_proxy(ess_, pos.cat).at(pos.item).select(true);
}
void hovered(index_type /*pos*/) override
void hovered(index_type pos) override
{
auto offset = ess_->content_view->origin().y / ess_->item_height();
auto offset = ess_->lister.distance(ess_->first_display(), ess_->lister.index_cast(pos, false));
if (ess_->pointer_where.first != parts::list || ess_->pointer_where.second != offset)
{
@@ -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<int>(off);
else if (last_off >= screen_px)
origin.y = static_cast<int>(last_off - screen_px);
else if (content_px >= screen_px)
origin.y = static_cast<int>(content_px - screen_px);
}
if (ess_->content_view->move_origin(origin - ess_->content_view->origin()))
@@ -4378,9 +4378,11 @@ namespace nana
essence_->ptr_state = item_state::highlighted;
bool need_refresh = false;
//Do sort
if (essence_->header.sortable() && essence_->pointer_where.first == parts::header && prev_state == item_state::pressed)
//Don't sort the column when the mouse is due to released for stopping resizing column.
if ((drawer_header_->splitter() == npos) && essence_->header.sortable() && essence_->pointer_where.first == parts::header && prev_state == item_state::pressed)
{
//Try to sort the column
if(essence_->pointer_where.second < essence_->header.cont().size())
need_refresh = essence_->lister.sort_column(essence_->pointer_where.second, nullptr);
}
@@ -4475,14 +4477,11 @@ namespace nana
if (list.first().empty())
return;
bool upward = false;
switch(arg.key)
{
case keyboard::os_arrow_up:
upward = true;
case keyboard::os_arrow_down:
list.move_select(upward, !arg.shift, true);
list.move_select((keyboard::os_arrow_up == arg.key), !arg.shift, true);
break;
case L' ':
{
@@ -4494,9 +4493,9 @@ namespace nana
}
break;
case keyboard::os_pageup :
upward = true;
case keyboard::os_pagedown:
{
auto const upward = (keyboard::os_pageup == arg.key);
auto const item_px = essence_->item_height();
auto picked_items = list.pick_items(true, true);
index_pair init_idx = (picked_items.empty() ? list.first() : picked_items[0]);
@@ -5390,6 +5389,7 @@ namespace nana
void listbox::auto_draw(bool enabled) noexcept
{
internal_scope_guard lock;
auto & ess = _m_ess();
if (ess.auto_draw != enabled)
{
@@ -5400,6 +5400,7 @@ namespace nana
void listbox::scroll(bool to_bottom, size_type cat_pos)
{
internal_scope_guard lock;
auto & ess = _m_ess();
auto cats = this->size_categ();
@@ -5498,6 +5499,7 @@ namespace nana
rectangle listbox::content_area() const
{
internal_scope_guard lock;
auto & ess = _m_ess();
auto carea = ess.content_area();
carea.x += ess.header.margin();
@@ -5544,29 +5546,34 @@ namespace nana
listbox::cat_proxy listbox::at(size_type pos)
{
internal_scope_guard lock;
check_range(pos, size_categ());
return{ &_m_ess(), pos };
}
const listbox::cat_proxy listbox::at(size_type pos) const
{
internal_scope_guard lock;
check_range(pos, size_categ());
return{ &_m_ess(), pos };
}
listbox::item_proxy listbox::at(const index_pair& abs_pos)
{
internal_scope_guard lock;
return at(abs_pos.cat).at(abs_pos.item);
}
const listbox::item_proxy listbox::at(const index_pair& pos_abs) const
{
internal_scope_guard lock;
return at(pos_abs.cat).at(pos_abs.item);
}
// Contributed by leobackes(pr#97)
listbox::index_pair listbox::cast( const point& pos ) const
{
internal_scope_guard lock;
auto & ess=_m_ess();
auto _where = ess.where(pos);
@@ -5578,27 +5585,32 @@ namespace nana
auto listbox::column_at(size_type pos, bool disp_order) -> column_interface&
{
internal_scope_guard lock;
return _m_ess().header.at(pos, disp_order);
}
auto listbox::column_at(size_type pos, bool disp_order) const -> const column_interface&
{
internal_scope_guard lock;
return _m_ess().header.at(pos, disp_order);
}
auto listbox::column_size() const ->size_type
{
internal_scope_guard lock;
return _m_ess().header.cont().size();
}
//Contributed by leobackes(pr#97)
listbox::size_type listbox::column_from_pos ( const point& pos ) const
{
internal_scope_guard lock;
return _m_ess().column_from_pos(pos.x);
}
void listbox::checkable(bool chkable)
{
internal_scope_guard lock;
auto & ess = _m_ess();
if(ess.checkable != chkable)
{
@@ -5609,11 +5621,13 @@ namespace nana
auto listbox::checked() const -> index_pairs
{
internal_scope_guard lock;
return _m_ess().lister.pick_items(false);
}
void listbox::clear(size_type cat)
{
internal_scope_guard lock;
auto & ess = _m_ess();
auto origin = ess.content_view->origin();
@@ -5637,6 +5651,7 @@ namespace nana
void listbox::clear()
{
internal_scope_guard lock;
auto & ess = _m_ess();
ess.lister.clear();
@@ -5651,6 +5666,7 @@ namespace nana
void listbox::erase(size_type cat)
{
internal_scope_guard lock;
auto & ess = _m_ess();
auto origin = ess.content_view->origin();
@@ -5675,6 +5691,7 @@ namespace nana
void listbox::erase()
{
internal_scope_guard lock;
auto & ess = _m_ess();
ess.lister.erase();
ess.calc_content_size();
@@ -5683,6 +5700,8 @@ namespace nana
void listbox::erase(index_pairs indexes)
{
internal_scope_guard lock;
std::sort(indexes.begin(), indexes.end(), [](const index_pair& pos1, const index_pair& pos2)
{
return (pos1 > pos2);
@@ -5732,6 +5751,7 @@ namespace nana
if(ip.empty())
return ip;
internal_scope_guard lock;
auto * ess = ip._m_ess();
auto _where = ip.pos();
@@ -5754,48 +5774,57 @@ namespace nana
bool listbox::sortable() const
{
internal_scope_guard lock;
return _m_ess().header.sortable();
}
void listbox::sortable(bool enable)
{
internal_scope_guard lock;
_m_ess().header.sortable(enable);
}
void listbox::set_sort_compare(size_type col, std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> strick_ordering)
{
internal_scope_guard lock;
_m_ess().header.at(col).weak_ordering = std::move(strick_ordering);
}
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
void listbox::sort_col(size_type col, bool reverse)
{
internal_scope_guard lock;
_m_ess().lister.sort_column(col, &reverse);
}
auto listbox::sort_col() const -> size_type
{
internal_scope_guard lock;
return _m_ess().lister.sort_attrs().column;
}
/// potencially ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
void listbox::unsort()
{
internal_scope_guard lock;
this->sort_col(npos, false);
}
bool listbox::freeze_sort(bool freeze)
{
internal_scope_guard lock;
return !_m_ess().lister.active_sort(!freeze);
}
auto listbox::selected() const -> index_pairs
{
internal_scope_guard lock;
return _m_ess().lister.pick_items(true); // absolute positions, no relative to display
}
void listbox::show_header(bool sh)
{
internal_scope_guard lock;
_m_ess().header.visible(sh);
_m_ess().update();
}
@@ -5807,6 +5836,7 @@ namespace nana
void listbox::move_select(bool upwards) ///<Selects an item besides the current selected item in the display.
{
internal_scope_guard lock;
_m_ess().lister.move_select(upwards, true, true);
_m_ess().update();
}
@@ -5839,6 +5869,7 @@ namespace nana
listbox& listbox::category_icon(std::function<void(paint::graphics& graph, const rectangle& rt_icon, bool expanded)> icon_renderer)
{
internal_scope_guard lock;
_m_ess().ctg_icon_renderer.swap(icon_renderer);
_m_ess().update();
return *this;
@@ -5846,6 +5877,7 @@ namespace nana
listbox& listbox::category_icon(const paint::image& img_expanded, const paint::image&& img_collapsed)
{
internal_scope_guard lock;
_m_ess().ctg_icon_renderer = [img_expanded, img_collapsed](paint::graphics& graph, const rectangle& rt_icon, bool expanded)
{
if (expanded)