[Bf-blender-cvs] [d6f2a3a1e68] soc-2020-info-editor: Info Editor: Add text search
Mateusz GrzeliÅski
noreply at git.blender.org
Tue Jun 30 17:24:57 CEST 2020
Commit: d6f2a3a1e684a8a7344c86b31c5bf90035a8c276
Author: Mateusz Grzeliński
Date: Wed Jun 24 16:14:08 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rBd6f2a3a1e684a8a7344c86b31c5bf90035a8c276
Info Editor: Add text search
Differential Revision: https://developer.blender.org/D8105
===================================================================
M release/scripts/startup/bl_ui/space_info.py
M source/blender/editors/space_info/info_draw.c
M source/blender/editors/space_info/info_intern.h
M source/blender/editors/space_info/info_report.c
M source/blender/makesdna/DNA_space_types.h
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index cd65980fc0d..eeef4170818 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -26,8 +26,12 @@ class INFO_HT_header(Header):
def draw(self, context):
layout = self.layout
layout.template_header()
+ sinfo = context.space_data
INFO_MT_editor_menus.draw_collapsible(context, layout)
+ row = layout.row(align=True)
+ row.prop(sinfo, "filter_text", text="")
+ layout.separator_spacer()
class INFO_MT_editor_menus(Menu):
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 3685e5de852..327aaa1347d 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -131,7 +131,8 @@ static int report_textview_skip__internal(TextViewContext *tvc)
{
const SpaceInfo *sinfo = tvc->arg1;
const int report_mask = info_report_mask(sinfo);
- while (tvc->iter && (((const Report *)tvc->iter)->type & report_mask) == 0) {
+ while (tvc->iter &&
+ !IS_REPORT_VISIBLE((const Report *)tvc->iter, report_mask, sinfo->search_string)) {
tvc->iter = (void *)((Link *)tvc->iter)->prev;
}
return (tvc->iter != NULL);
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h
index 79bfb1fa047..9eef804aaea 100644
--- a/source/blender/editors/space_info/info_intern.h
+++ b/source/blender/editors/space_info/info_intern.h
@@ -58,6 +58,7 @@ void info_textview_main(const struct SpaceInfo *sinfo,
/* info_report.c */
int info_report_mask(const struct SpaceInfo *sinfo);
+bool info_filter_text(const Report *report, const char *search_string);
void INFO_OT_select_pick(struct wmOperatorType *ot); /* report selection */
void INFO_OT_select_all(struct wmOperatorType *ot);
void INFO_OT_select_box(struct wmOperatorType *ot);
@@ -66,4 +67,7 @@ void INFO_OT_report_replay(struct wmOperatorType *ot);
void INFO_OT_report_delete(struct wmOperatorType *ot);
void INFO_OT_report_copy(struct wmOperatorType *ot);
+#define IS_REPORT_VISIBLE(report, report_mask, search_string) \
+ (info_filter_text(report, search_string) && ((report)->type & report_mask))
+
#endif /* __INFO_INTERN_H__ */
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index adc6391a0f6..8b6b5234ec0 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -18,6 +18,7 @@
* \ingroup spinfo
*/
+#include <fnmatch.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@@ -41,12 +42,21 @@
#include "info_intern.h"
-static void reports_select_all(ReportList *reports, int report_mask, int action)
+/* return true if substring is found */
+bool info_filter_text(const Report *report, const char *search_string)
+{
+ return strstr(report->message, search_string) != NULL;
+}
+
+static void reports_select_all(ReportList *reports,
+ int report_mask,
+ const char *search_string,
+ int action)
{
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
for (Report *report = reports->list.last; report; report = report->prev) {
- if ((report->type & report_mask) && (report->flag & SELECT)) {
+ if (IS_REPORT_VISIBLE(report, report_mask, search_string) && (report->flag & SELECT)) {
action = SEL_DESELECT;
break;
}
@@ -54,7 +64,7 @@ static void reports_select_all(ReportList *reports, int report_mask, int action)
}
for (Report *report = reports->list.last; report; report = report->prev) {
- if (report->type & report_mask) {
+ if (IS_REPORT_VISIBLE(report, report_mask, search_string)) {
switch (action) {
case SEL_SELECT:
report->flag = SELECT;
@@ -160,7 +170,7 @@ static int select_report_pick_exec(bContext *C, wmOperator *op)
}
if (!extend) {
- reports_select_all(reports, report_mask, SEL_DESELECT);
+ reports_select_all(reports, report_mask, sinfo->search_string, SEL_DESELECT);
}
report->flag ^= SELECT; /* toggle */
@@ -213,7 +223,7 @@ static int report_select_all_exec(bContext *C, wmOperator *op)
const int report_mask = info_report_mask(sinfo);
int action = RNA_enum_get(op->ptr, "action");
- reports_select_all(reports, report_mask, action);
+ reports_select_all(reports, report_mask, sinfo->search_string, action);
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 1cb42b333c7..198372dfc5a 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -113,6 +113,7 @@ typedef struct SpaceInfo {
char rpt_mask;
char _pad[7];
+ char search_string[64];
} SpaceInfo;
/* SpaceInfo.rpt_mask */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 49a21799d5b..d5b3d69afe9 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -6088,6 +6088,13 @@ static void rna_def_space_info(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_ERR);
RNA_def_property_ui_text(prop, "Show Error", "Display error text");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
+
+ prop = RNA_def_property(srna, "filter_text", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "search_string");
+ RNA_def_property_ui_text(prop, "Log Filter", "Live filtering string");
+ RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
+ RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, NULL);
}
static void rna_def_space_userpref(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list