Minor tree view improvements
This commit is contained in:
parent
2e506a1367
commit
af2caf8fcf
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue