Ajout des sélection sur le composant FListView

This commit is contained in:
Nicolas H 2021-07-13 08:15:38 +00:00
parent ea7f53be41
commit 79d4f6f7a9
2 changed files with 29 additions and 7 deletions

View File

@ -1428,33 +1428,46 @@ inline void FListView::mapKeyFunctions()
key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
}
//----------------------------------------------------------------------
std::vector<int> FListView::getmultimark()
{
return multi;
}
//----------------------------------------------------------------------
void FListView::setmultimark(std::vector<int> mark)
{
multi=mark;
}
//----------------------------------------------------------------------
void FListView::setindex(int index)
{
if (index==-666)
if (index<0)
current_iter=getNullIterator();
else
{
current_iter=itemlist.begin();
current_iter+=index;
scrollToY(index);
}
draw();
}
//----------------------------------------------------------------------
void FListView::setmark(int index)
{
if (index==-666)
if (index<0)
current_iter=getNullIterator();
else
{
mark_iter=itemlist.begin();
mark_iter+=index;
scrollToY(index);
}
draw();
}
//----------------------------------------------------------------------
int FListView::getmark()
{
return mark_iter.getPosition();
}
//----------------------------------------------------------------------
int FListView::getindex()
{
return current_iter.getPosition();
@ -1641,7 +1654,13 @@ void FListView::drawList()
{
const bool is_current_line( iter == current_iter );
const bool is_current_mark( iter == mark_iter );
const bool is_current_selected=false;
bool is_current_selected=false;
for(int item: multi)
if (item==current_iter.getPosition())
{
is_current_selected=true;
break;
}
const auto& item = static_cast<FListViewItem*>(*iter);
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
const int checkbox_offset = item->isCheckable() ? 1 : 0;
@ -1825,7 +1844,7 @@ inline void FListView::setLineAttributes ( bool is_current
unsetBold();
}
if ( is_selected )
setColor ( FColor::White , FColor::Black );
setColor ( FColor::White , FColor::Green );
if ( is_mark )
setColor ( FColor::White, FColor::Red );
}

View File

@ -342,7 +342,10 @@ class FListView : public FWidget
// Methods
int getindex();
void setindex(int);
int getmark();
void setmark(int);
std::vector<int> getmultimark();
void setmultimark(std::vector<int> mark);
virtual int addColumn (const FString&, int = USE_MAX_SIZE);
void hide() override;
iterator insert (FListViewItem*);
@ -527,7 +530,7 @@ class FListView : public FWidget
bool tree_view{false};
bool hide_sort_indicator{false};
bool has_checkable_items{false};
std::vector<int> multi;
// Function Pointer
bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr};
bool (*user_defined_descending) (const FObject*, const FObject*){nullptr};