Blender  V3.3
spreadsheet_ops.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #include "BKE_screen.h"
3 
4 #include "DNA_space_types.h"
5 
6 #include "ED_screen.h"
7 
8 #include "BLI_listbase.h"
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BKE_context.h"
13 
14 #include "RNA_access.h"
15 #include "RNA_define.h"
16 
17 #include "WM_api.h"
18 #include "WM_types.h"
19 
20 #include "spreadsheet_intern.hh"
22 
23 using namespace blender::ed::spreadsheet;
24 
26 {
28 
30  BLI_addtail(&sspreadsheet->row_filters, row_filter);
31 
33 
34  return OPERATOR_FINISHED;
35 }
36 
38 {
39  ot->name = "Add Row Filter";
40  ot->description = "Add a filter to remove rows from the displayed data";
41  ot->idname = "SPREADSHEET_OT_add_row_filter_rule";
42 
45 
47 }
48 
50 {
52 
54  &sspreadsheet->row_filters, RNA_int_get(op->ptr, "index"));
55  if (row_filter == nullptr) {
56  return OPERATOR_CANCELLED;
57  }
58 
59  BLI_remlink(&sspreadsheet->row_filters, row_filter);
60  spreadsheet_row_filter_free(row_filter);
61 
63 
64  return OPERATOR_FINISHED;
65 }
66 
68 {
69  ot->name = "Remove Row Filter";
70  ot->description = "Remove a row filter from the rules";
71  ot->idname = "SPREADSHEET_OT_remove_row_filter_rule";
72 
75 
77 
78  RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
79 }
80 
82  wmOperator *op,
83  const wmEvent *UNUSED(event))
84 {
85  GeometryComponentType component_type = static_cast<GeometryComponentType>(
86  RNA_int_get(op->ptr, "component_type"));
87  eAttrDomain attribute_domain = static_cast<eAttrDomain>(
88  RNA_int_get(op->ptr, "attribute_domain_type"));
89 
91  sspreadsheet->geometry_component_type = component_type;
92  sspreadsheet->attribute_domain = attribute_domain;
93 
94  /* Refresh header and main region. */
96 
97  return OPERATOR_FINISHED;
98 }
99 
101 {
102  ot->name = "Change Visible Data Source";
103  ot->description = "Change visible data source in the spreadsheet";
104  ot->idname = "SPREADSHEET_OT_change_spreadsheet_data_source";
105 
107 
108  RNA_def_int(ot->srna, "component_type", 0, 0, INT16_MAX, "Component Type", "", 0, INT16_MAX);
110  "attribute_domain_type",
111  0,
112  0,
113  INT16_MAX,
114  "Attribute Domain Type",
115  "",
116  0,
117  INT16_MAX);
118 
120 }
121 
123 {
127 }
eAttrDomain
Definition: BKE_attribute.h:25
struct SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
Definition: context.c:941
GeometryComponentType
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define UNUSED(x)
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
bool ED_operator_spreadsheet_active(struct bContext *C)
Definition: screen_ops.c:292
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
@ OPTYPE_INTERNAL
Definition: WM_types.h:168
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define ND_SPACE_SPREADSHEET
Definition: WM_types.h:484
#define NC_SPACE
Definition: WM_types.h:342
SpreadsheetRowFilter * spreadsheet_row_filter_new()
void spreadsheet_row_filter_free(SpreadsheetRowFilter *row_filter)
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
static void SPREADSHEET_OT_remove_row_filter_rule(wmOperatorType *ot)
static int select_component_domain_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int row_filter_add_exec(bContext *C, wmOperator *UNUSED(op))
void spreadsheet_operatortypes()
static void SPREADSHEET_OT_add_row_filter_rule(wmOperatorType *ot)
static void SPREADSHEET_OT_change_spreadsheet_data_source(wmOperatorType *ot)
static int row_filter_remove_exec(bContext *C, wmOperator *op)
#define INT16_MAX
Definition: stdint.h:135
uint8_t geometry_component_type
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
struct PointerRNA * ptr
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))