diff --git a/ChangeLog b/ChangeLog index c6b6cf77..3ded4c96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-10-18 Markus Gans + * Expand or collapse a tree element with a double-click + * FListView::adjustViewport() improved + 2017-10-15 Markus Gans * FObject double free prevention of fc::empty_string diff --git a/src/flistview.cpp b/src/flistview.cpp index 194f1df6..5641c2c8 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -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; } //---------------------------------------------------------------------- diff --git a/src/fterm.cpp b/src/fterm.cpp index 2cc41da4..1a7d0157 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -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);