Expand or collapse a tree element with a double-click
This commit is contained in:
parent
1cb6a5f73d
commit
b11e37a921
|
@ -1,3 +1,7 @@
|
|||
2017-10-18 Markus Gans <guru.mail@muenster.de>
|
||||
* Expand or collapse a tree element with a double-click
|
||||
* FListView::adjustViewport() improved
|
||||
|
||||
2017-10-15 Markus Gans <guru.mail@muenster.de>
|
||||
* FObject double free prevention of fc::empty_string
|
||||
|
||||
|
|
|
@ -1065,6 +1065,21 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
|
|||
if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) )
|
||||
return;
|
||||
|
||||
FListViewItem* item = getCurrentItem();
|
||||
|
||||
if ( item->isExpandable() )
|
||||
{
|
||||
if ( item->isExpand() )
|
||||
item->collapse();
|
||||
else
|
||||
item->expand();
|
||||
|
||||
adjustSize();
|
||||
|
||||
if ( isVisible() )
|
||||
draw();
|
||||
}
|
||||
|
||||
processClick();
|
||||
}
|
||||
}
|
||||
|
@ -1231,29 +1246,22 @@ void FListView::onFocusOut (FFocusEvent*)
|
|||
void FListView::adjustViewport()
|
||||
{
|
||||
int element_count = int(getCount());
|
||||
int height = getClientHeight();
|
||||
|
||||
if ( element_count == 0 || getClientHeight() <= 0 )
|
||||
if ( element_count == 0 || height <= 0 )
|
||||
return;
|
||||
|
||||
if ( element_count < getClientHeight() )
|
||||
if ( element_count < height )
|
||||
{
|
||||
first_visible_line = itemlist.begin();
|
||||
last_visible_line = first_visible_line;
|
||||
last_visible_line += element_count - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( yoffset > element_count - getClientHeight() )
|
||||
yoffset = element_count - getClientHeight();
|
||||
|
||||
if ( yoffset < 0 )
|
||||
yoffset = 0;*/
|
||||
|
||||
//setTermXY(1,1); ::printf("(%d > %d)", first_visible_line.getPosition(),element_count - getClientHeight() - 1); fflush(stdout); sleep(1);
|
||||
|
||||
if ( first_visible_line.getPosition() > element_count - getClientHeight() )
|
||||
if ( first_visible_line.getPosition() > element_count - height )
|
||||
{
|
||||
int difference = first_visible_line.getPosition() - (element_count - getClientHeight());
|
||||
int difference = first_visible_line.getPosition()
|
||||
- (element_count - height);
|
||||
|
||||
if ( first_visible_line.getPosition() - difference + 1 > 0 )
|
||||
{
|
||||
|
@ -1262,15 +1270,17 @@ void FListView::adjustViewport()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ( current_iter.getPosition() < first_visible_line.getPosition() )
|
||||
current_iter = first_visible_line;
|
||||
int max_last_visible_line = first_visible_line.getPosition()
|
||||
+ height - 1;
|
||||
|
||||
if ( first_visible_line.getPosition() < current_iter.getPosition() - getClientHeight() )
|
||||
if ( last_visible_line.getPosition() > max_last_visible_line )
|
||||
{
|
||||
first_visible_line = current_iter;
|
||||
first_visible_line -= getClientHeight();
|
||||
}*/
|
||||
last_visible_line = first_visible_line;
|
||||
last_visible_line += height - 1;
|
||||
}
|
||||
|
||||
if ( current_iter.getPosition() > last_visible_line.getPosition() )
|
||||
current_iter = last_visible_line;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -4060,7 +4060,7 @@ void FTerm::init()
|
|||
setPalette (fc::DarkGray, 0x50, 0x50, 0x50);
|
||||
setPalette (fc::LightBlue, 0x80, 0xa4, 0xec);
|
||||
setPalette (fc::LightGreen, 0x54, 0xff, 0x54);
|
||||
setPalette (fc::LightCyan, 0x49, 0xc9, 0xe3);
|
||||
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (fc::LightRed, 0xff, 0x54, 0x54);
|
||||
setPalette (fc::LightMagenta, 0xff, 0x54, 0xff);
|
||||
setPalette (fc::Yellow, 0xff, 0xff, 0x54);
|
||||
|
|
Loading…
Reference in New Issue