From 07de0448f93b9490275141abbaf426d530e79564 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 13 Aug 2015 21:51:34 -0600 Subject: [PATCH] ImGuiTextFilter: default parameter width=0.0f for no override, allow override with negative values --- imgui.cpp | 4 ++-- imgui.h | 2 +- imgui_demo.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 920168b6..943547d1 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1283,10 +1283,10 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) void ImGuiTextFilter::Draw(const char* label, float width) { - if (width > 0.0f) + if (width != 0.0f) ImGui::PushItemWidth(width); ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); - if (width > 0.0f) + if (width != 0.0f) ImGui::PopItemWidth(); Build(); } diff --git a/imgui.h b/imgui.h index 58686dd9..3ef093db 100644 --- a/imgui.h +++ b/imgui.h @@ -850,7 +850,7 @@ struct ImGuiTextFilter ImGuiTextFilter(const char* default_filter = ""); void Clear() { InputBuf[0] = 0; Build(); } - void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f); // Helper calling InputText+Build + void Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build bool PassFilter(const char* text, const char* text_end = NULL) const; bool IsActive() const { return !Filters.empty(); } IMGUI_API void Build(); diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 6e45d2d4..1870171b 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1979,7 +1979,7 @@ struct ExampleAppLog ImGui::SameLine(); bool copy = ImGui::Button("Copy"); ImGui::SameLine(); - Filter.Draw(); + Filter.Draw("Filter", -100.0f); ImGui::Separator(); ImGui::BeginChild("scrolling"); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));