diff --git a/fragments/filters.cpp b/fragments/filters.cpp index e1c46aa..144ceda 100644 --- a/fragments/filters.cpp +++ b/fragments/filters.cpp @@ -64,7 +64,7 @@ static void render_filter(Filter* filter, std::string* title, bool* request_remo } if (filter->error()) { - ImGui::SameLine(); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::Text("(%s)", filter->error()->c_str()); } @@ -95,8 +95,8 @@ static inline void render_integer_filter(IntegerFilter* filter) { }; ImGui::AlignTextToFramePadding(); - ImGui::Text("%s is%s", head, filter->inverted ? " not" : ""); - ImGui::SameLine(); + ImGui::Text("%s is%s:", head, filter->inverted ? " not" : ""); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); if (ImGui::InputScalar("##int", ImGuiDataType_U64, &filter->other)) { filter->updated(); } @@ -112,46 +112,48 @@ static inline void render_string_filter(StringFilter* filter) { }; ImGui::AlignTextToFramePadding(); - ImGui::Text("%s %s", head, filter->exact_match + ImGui::Text("%s %s:", head, filter->exact_match ? (filter->inverted ? "is not" : "is") : (filter->inverted ? "doesn't have" : "has")); - ImGui::SameLine(); + ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); if (ImGui::InputText("##str", &filter->other)) { filter->updated(); } } static inline void render_buffer_filter(BufferFilter* filter) { - auto update_if_needed = [&](bool updated) { - if (updated) { + auto add_checkbox = [&](const char* name, Buffer buffer) { + if (ImGui::CheckboxFlags(name, &filter->wanted, static_cast(buffer))) { filter->updated(); } }; + ImGui::AlignTextToFramePadding(); - ImGui::TextUnformatted("Buffer is:"); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Unknown", &filter->wanted, static_cast(Buffer::Unknown))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Main", &filter->wanted, static_cast(Buffer::Main))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("System", &filter->wanted, static_cast(Buffer::System))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Radio", &filter->wanted, static_cast(Buffer::Radio))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Events", &filter->wanted, static_cast(Buffer::Events))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Crash", &filter->wanted, static_cast(Buffer::Crash))); + ImGui::TextUnformatted("Buffer is:"); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + add_checkbox("Unknown", Buffer::Unknown); ImGui::SameLine(); + add_checkbox("Main", Buffer::Main); ImGui::SameLine(); + add_checkbox("System", Buffer::System); ImGui::SameLine(); + add_checkbox("Radio", Buffer::Radio); ImGui::SameLine(); + add_checkbox("Events", Buffer::Events); ImGui::SameLine(); + add_checkbox("Crash", Buffer::Crash); } static inline void render_priority_filter(PriorityFilter* filter) { - auto update_if_needed = [&](bool updated) { - if (updated) { + auto add_checkbox = [&](const char* name, Priority priority) { + if (ImGui::CheckboxFlags(name, &filter->wanted, static_cast(priority))) { filter->updated(); } }; + ImGui::AlignTextToFramePadding(); - ImGui::TextUnformatted("Priority is:"); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Unknown", &filter->wanted, static_cast(Priority::Unknown))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Verbose", &filter->wanted, static_cast(Priority::Verbose))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Debug", &filter->wanted, static_cast(Priority::Debug))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Info", &filter->wanted, static_cast(Priority::Info))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Warning", &filter->wanted, static_cast(Priority::Warn))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Error", &filter->wanted, static_cast(Priority::Error))); ImGui::SameLine(); - update_if_needed(ImGui::CheckboxFlags("Fatal", &filter->wanted, static_cast(Priority::Fatal))); + ImGui::TextUnformatted("Priority is:"); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); + add_checkbox("Unknown", Priority::Unknown); ImGui::SameLine(); + add_checkbox("Verbose", Priority::Verbose); ImGui::SameLine(); + add_checkbox("Debug", Priority::Debug); ImGui::SameLine(); + add_checkbox("Info", Priority::Info); ImGui::SameLine(); + add_checkbox("Warning", Priority::Warn); ImGui::SameLine(); + add_checkbox("Error", Priority::Error); ImGui::SameLine(); + add_checkbox("Fatal", Priority::Fatal); } static inline void render_group_filter(GroupFilter* filter) {