Merge branch 'hotfix-1.7.2' into develop

This commit is contained in:
Jinhao
2019-09-11 00:54:47 +08:00
16 changed files with 224 additions and 67 deletions

View File

@@ -2314,7 +2314,8 @@ namespace nana
size_type count_of_exposed(bool with_rest) const
{
auto lister_s = this->content_view->view_area().height;
return (lister_s / item_height()) + (with_rest && (lister_s % item_height()) ? 1 : 0);
return (lister_s / item_height()) + (with_rest &&
listbox_ptr->scroll_operation()->visible(true) && (lister_s % item_height()) ? 1 : 0);
}
void update(bool ignore_auto_draw = false) noexcept
@@ -3338,16 +3339,27 @@ namespace nana
return false;
}
// init ir end to grab a header
void grab(const nana::point& pos, bool is_grab)
{
if(is_grab)
if(is_grab) // init grabbing the header
{
grabs_.start_pos = pos.x;
if(grabs_.splitter != npos) // resize header item, not move it
grabs_.item_width = essence_->header.at(grabs_.splitter).width_px;
if(grabs_.splitter == npos) // No splitter, no resize header, just moving
return;
// splitter grabbed - resize the header: take initial width
grabs_.item_width = essence_->header.at(grabs_.splitter).width_px;
}
else if((grab_terminal_.index != npos) && (grab_terminal_.index != essence_->pointer_where.second))
essence_->header.move(essence_->pointer_where.second, grab_terminal_.index, grab_terminal_.place_front);
else // end to grab the header
if (grabs_.splitter != npos) // some Splitter grab, just resizing, no need to move
return;
else if( (grab_terminal_.index != npos)
&& (grab_terminal_.index != essence_->pointer_where.second) )
// move header to terminal position
essence_->header.move(essence_->pointer_where.second, // from
grab_terminal_.index, // to
grab_terminal_.place_front);
}
//grab_move
@@ -4295,7 +4307,10 @@ namespace nana
auto const good_list_r = essence_->rect_lister(list_r);
auto & ptr_where = essence_->pointer_where;
if((ptr_where.first == parts::header) && (ptr_where.second != npos || (drawer_header_->splitter() != npos)))
if( (ptr_where.first == parts::header) // click on header
&& ( ptr_where.second != npos // in ..
|| (drawer_header_->splitter() != npos))) // or splitter
{
essence_->ptr_state = item_state::pressed;
if(good_head_r)
@@ -4304,7 +4319,8 @@ namespace nana
update = true;
}
}
else if(ptr_where.first == parts::list || ptr_where.first == parts::checker)
else if( ptr_where.first == parts::list // click on list
|| ptr_where.first == parts::checker) // on a checker
{
index_pair item_pos = lister.advance(essence_->first_display(), static_cast<int>(ptr_where.second));
@@ -4477,13 +4493,16 @@ namespace nana
bool need_refresh = false;
//Don't sort the column when the mouse is due to released for stopping resizing column.
if ((drawer_header_->splitter() == npos) && essence_->header.attrib().sortable && essence_->pointer_where.first == parts::header && prev_state == item_state::pressed)
if ( (drawer_header_->splitter() == npos) // no header splitter was selected
&& essence_->header.attrib().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);
}
else if (item_state::grabbed == prev_state)
else if (item_state::grabbed == prev_state) // selected splitter and grabbed
{
nana::point pos = arg.pos;
essence_->widget_to_header(pos);
@@ -6095,7 +6114,15 @@ namespace nana
auto listbox::last_visible() const -> index_pair
{
return _m_ess().lister.advance(_m_ess().first_display(), static_cast<int>(_m_ess().count_of_exposed(true)));
if(!const_cast<listbox*>(this)->scroll_operation()->visible(true))
{
auto last_cat = size_categ()-1;
index_pair ip(last_cat, at(last_cat).size()-1);
if(last_cat == 0 && ip.item == npos) // if the listbox is empty
ip.cat = npos; // return empty index_pair
return ip;
}
return _m_ess().lister.advance(_m_ess().first_display(), static_cast<int>(_m_ess().count_of_exposed(true)-1));
}
auto listbox::visibles() const -> index_pairs

View File

@@ -104,6 +104,7 @@ namespace nana
delete ptr;
cont_.clear();
right_ = npos;
}
@@ -683,6 +684,7 @@ namespace nana
if(m && (m->textout != show))
{
m->textout = show;
m->pixels = 0; //force width calculation
API::refresh_window(this->handle());
}
}