diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-06 03:11:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-06 03:12:27 +0300 |
commit | a111204ca968f11dc8c190399047165863080de7 (patch) | |
tree | ca8abae594fe4fd656a5694799e863e73c5a20f0 /source/blender | |
parent | 85b667716aab76e08a5387e03197c7a068ba7a58 (diff) |
WM: match select all behavior for the info space
Adds select invert to the operator.
D4454 by @Poulpator
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_info/info_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_report.c | 58 | ||||
-rw-r--r-- | source/blender/editors/space_info/space_info.c | 2 |
3 files changed, 33 insertions, 29 deletions
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 83a132e6db8..7903a462ce1 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -53,7 +53,7 @@ void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, struct Repo /* info_report.c */ int info_report_mask(struct SpaceInfo *sinfo); void INFO_OT_select_pick(struct wmOperatorType *ot); /* report selection */ -void INFO_OT_select_all_toggle(struct wmOperatorType *ot); +void INFO_OT_select_all(struct wmOperatorType *ot); void INFO_OT_select_box(struct wmOperatorType *ot); void INFO_OT_report_replay(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index c8d21bd3061..4d5e617bd90 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -35,6 +35,7 @@ #include "WM_types.h" #include "ED_screen.h" +#include "ED_select_utils.h" #include "RNA_access.h" #include "RNA_define.h" @@ -154,34 +155,39 @@ void INFO_OT_select_pick(wmOperatorType *ot) RNA_def_int(ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX); } - - -static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op)) +static int report_select_all_exec(bContext *C, wmOperator *op) { SpaceInfo *sinfo = CTX_wm_space_info(C); ReportList *reports = CTX_wm_reports(C); - int report_mask = info_report_mask(sinfo); - int deselect = 0; + const int report_mask = info_report_mask(sinfo); - Report *report; + int action = RNA_enum_get(op->ptr, "action"); - for (report = reports->list.last; report; report = report->prev) { - if ((report->type & report_mask) && (report->flag & SELECT)) { - deselect = 1; - break; + if (action == SEL_TOGGLE) { + for (Report *report = reports->list.last; report; report = report->prev) { + if ((report->type & report_mask) && (report->flag & SELECT)) { + action = SEL_DESELECT; + break; + } } } - - if (deselect) { - for (report = reports->list.last; report; report = report->prev) - if (report->type & report_mask) - report->flag &= ~SELECT; - } - else { - for (report = reports->list.last; report; report = report->prev) - if (report->type & report_mask) - report->flag |= SELECT; + for (Report *report = reports->list.last; report; report = report->prev) { + if (report->type & report_mask) { + switch (action) { + case SEL_SELECT: + report->flag = SELECT; + break; + case SEL_DESELECT: + report->flag = ~SELECT; + break; + case SEL_INVERT: + report->flag ^= SELECT; + break; + default: + BLI_assert(0); + } + } } ED_area_tag_redraw(CTX_wm_area(C)); @@ -189,21 +195,19 @@ static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void INFO_OT_select_all_toggle(wmOperatorType *ot) +void INFO_OT_select_all(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All"; - ot->description = "Select or deselect all reports"; - ot->idname = "INFO_OT_select_all_toggle"; + ot->description = "Change selection of all visible reports"; + ot->idname = "INFO_OT_select_all"; /* api callbacks */ ot->poll = ED_operator_info_active; - ot->exec = report_select_all_toggle_exec; - - /* flags */ - /*ot->flag = OPTYPE_REGISTER;*/ + ot->exec = report_select_all_exec; /* properties */ + WM_operator_properties_select_action(ot, SEL_SELECT); } /* box_select operator */ diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 68554aebbf5..754941a12c0 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -187,7 +187,7 @@ static void info_operatortypes(void) /* info_report.c */ WM_operatortype_append(INFO_OT_select_pick); - WM_operatortype_append(INFO_OT_select_all_toggle); + WM_operatortype_append(INFO_OT_select_all); WM_operatortype_append(INFO_OT_select_box); WM_operatortype_append(INFO_OT_report_replay); |