Skip to content

Commit

Permalink
Locator dialog now allows filtering list by substring match. refs #5270
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Oct 9, 2019
1 parent 2703640 commit 2163cfa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/gui/windows/GUIAppEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ enum {
MID_CHOOSER_LIST,
/// @brief Filter selected
MID_CHOOSER_FILTER,
/// @brief Filter list by substring
MID_CHOOSER_FILTER_SUBSTR,

/// @}

Expand Down
19 changes: 19 additions & 0 deletions src/utils/gui/windows/GUIDialog_GLObjChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ FXDEFMAP(GUIDialog_GLObjChooser) GUIDialog_GLObjChooserMap[] = {
FXMAPFUNC(SEL_COMMAND, MID_CHOOSER_TEXT, GUIDialog_GLObjChooser::onCmdText),
FXMAPFUNC(SEL_KEYPRESS, MID_CHOOSER_LIST, GUIDialog_GLObjChooser::onListKeyPress),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSER_FILTER, GUIDialog_GLObjChooser::onCmdFilter),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSER_FILTER_SUBSTR, GUIDialog_GLObjChooser::onCmdFilterSubstr),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSEN_INVERT, GUIDialog_GLObjChooser::onCmdToggleSelection),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSEN_NAME, GUIDialog_GLObjChooser::onCmdLocateByName),
};
Expand Down Expand Up @@ -81,6 +82,7 @@ GUIDialog_GLObjChooser::GUIDialog_GLObjChooser(GUIGlChildWindow* parent, FXIcon*
}
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
new FXButton(layoutRight, "&Hide Unselected\t\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSER_FILTER, GUIDesignChooserButtons);
new FXButton(layoutRight, "&Filter substring\t\t", nullptr, this, MID_CHOOSER_FILTER_SUBSTR, GUIDesignChooserButtons);
new FXButton(layoutRight, "&Select/deselect\tSelect/deselect current object\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSEN_INVERT, GUIDesignChooserButtons);
new FXButton(layoutRight, "By &Name\tLocate item by name\t", nullptr, this, MID_CHOOSEN_NAME, GUIDesignChooserButtons);
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
Expand Down Expand Up @@ -213,6 +215,23 @@ GUIDialog_GLObjChooser::onCmdFilter(FXObject*, FXSelector, void*) {
return 1;
}


long
GUIDialog_GLObjChooser::onCmdFilterSubstr(FXObject*, FXSelector, void*) {
std::vector<GUIGlID> selectedGlIDs;
const int numItems = myList->getNumItems();
FXString t = myTextEntry->getText().lower();
for (int i = 0; i < numItems; i++) {
if (myList->getItemText(i).lower().find(t) >= 0) {
const GUIGlID glID = *static_cast<GUIGlID*>(myList->getItemData(i));
selectedGlIDs.push_back(glID);
}
}
refreshList(selectedGlIDs);
return 1;
}


std::string
GUIDialog_GLObjChooser::getObjectName(GUIGlObject* o) const {
if (myLocateByName) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/gui/windows/GUIDialog_GLObjChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class GUIDialog_GLObjChooser : public FXMainWindow {
/// @brief Callback: Hides unselected items if pressed
long onCmdFilter(FXObject*, FXSelector, void*);

/// @brief Callback: Hides unmatched items if pressed
long onCmdFilterSubstr(FXObject*, FXSelector, void*);

/// @brief Callback: Toggle selection status of current object
long onCmdToggleSelection(FXObject*, FXSelector, void*);

Expand Down

0 comments on commit 2163cfa

Please sign in to comment.