Minor tree view improvements

This commit is contained in:
Markus Gans 2017-10-15 15:27:36 +02:00
parent 2e506a1367
commit af2caf8fcf
3 changed files with 18 additions and 17 deletions

View File

@ -82,7 +82,7 @@ struct Treeview::TreeItem
{ return &name; }
const char* const* end() const
{ return &density + 1; }
{ return reinterpret_cast<const char* const*>(&child_element); }
// Data Members
const char* name;

View File

@ -318,6 +318,7 @@ class FListView : public FWidget
FObjectIterator appendItem (FListViewItem*);
void processClick();
void processChanged();
void setRelativePosition (int);
void stepForward();
void stepBackward();
void stepForward (int);

View File

@ -912,10 +912,7 @@ void FListView::onMouseDown (FMouseEvent* ev)
int new_pos = first_visible_line.getPosition() + mouse_y - 2;
if ( new_pos < int(getCount()) )
{
current_iter = first_visible_line;
current_iter += mouse_y - 2;
}
setRelativePosition (mouse_y - 2);
if ( isVisible() )
drawList();
@ -977,10 +974,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
int new_pos = first_visible_line.getPosition() + mouse_y - 2;
if ( new_pos < int(getCount()) )
{
current_iter = first_visible_line;
current_iter += mouse_y - 2;
}
setRelativePosition (mouse_y - 2);
if ( isVisible() )
drawList();
@ -1158,13 +1152,13 @@ void FListView::onWheel (FWheelEvent* ev)
}
else
{
// Save relative position from the top line
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from top
int difference = first_visible_line.getPosition();
first_visible_line -= difference;
last_visible_line -= difference;
current_iter = first_visible_line;
current_iter += ry;
setRelativePosition(ry);
}
break;
@ -1181,13 +1175,13 @@ void FListView::onWheel (FWheelEvent* ev)
}
else
{
// Save relative position from the top line
// Save relative position from the first line
int ry = current_iter.getPosition() - first_visible_line.getPosition();
// Save difference from bottom
int differenz = element_count - last_visible_line.getPosition() - 1;
first_visible_line += differenz;
last_visible_line += differenz;
current_iter = first_visible_line;
current_iter += ry;
setRelativePosition(ry);
}
break;
@ -1753,6 +1747,13 @@ void FListView::processChanged()
emitCallback("row-changed");
}
//----------------------------------------------------------------------
void FListView::setRelativePosition (int ry)
{
current_iter = first_visible_line;
current_iter += ry;
}
//----------------------------------------------------------------------
void FListView::stepForward()
{
@ -1883,8 +1884,7 @@ void FListView::scrollToY (int y)
{
first_visible_line = itemlist.begin();
first_visible_line += y;
current_iter = first_visible_line;
current_iter += ry;
setRelativePosition (ry);
last_visible_line = first_visible_line;
last_visible_line += pagesize;
}