Skip to content

Commit

Permalink
filter widget
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Dec 16, 2024
1 parent 145e2cb commit 0f74af9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions source/Gui/AlienImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,24 @@ bool AlienImGui::InputText(InputTextParameters const& parameters, std::string& t
return result;
}

bool AlienImGui::InputFilter(std::string& filter)
{
auto result = AlienImGui::InputText(
AlienImGui::InputTextParameters().hint("Filter").textWidth(0).width(
ImGui::GetContentRegionAvail().x - scale(12.0f) - ImGui::GetStyle().WindowPadding.x * 2),
filter);
ImGui::SameLine();

ImGui::BeginDisabled(filter.empty());
if (AlienImGui::Button(ICON_FA_TIMES)) {
filter.clear();
result = true;
}
ImGui::EndDisabled();

return result;
}

void AlienImGui::InputTextMultiline(InputTextMultilineParameters const& parameters, std::string& text)
{
static char buffer[1024*16];
Expand Down
2 changes: 2 additions & 0 deletions source/Gui/AlienImGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class AlienImGui
static bool InputText(InputTextParameters const& parameters, char* buffer, int bufferSize);
static bool InputText(InputTextParameters const& parameters, std::string& text);

static bool InputFilter(std::string& filter);

struct InputTextMultilineParameters
{
MEMBER_DECLARATION(InputTextMultilineParameters, std::string, name, "");
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void BrowserWindow::processWorkspaceSelectionAndFilter()
AlienImGui::VerticalSeparator();

ImGui::TableSetColumnIndex(1);
if (AlienImGui::InputText(AlienImGui::InputTextParameters().hint("Filter").textWidth(0), _filter)) {
if (AlienImGui::InputFilter(_filter)) {
for (NetworkResourceType resourceType = 0; resourceType < NetworkResourceType_Count; ++resourceType) {
for (WorkspaceType workspaceType = 0; workspaceType < WorkspaceType_Count; ++workspaceType) {
createTreeTOs(_workspaces.at(WorkspaceId{resourceType, workspaceType}));
Expand Down

0 comments on commit 0f74af9

Please sign in to comment.