Blender V4.3
spreadsheet_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "DNA_space_types.h"
6
7#include "ED_screen.hh"
8
9#include "BLI_listbase.h"
10
11#include "MEM_guardedalloc.h"
12
13#include "BKE_context.hh"
14
15#include "RNA_access.hh"
16#include "RNA_define.hh"
17
18#include "WM_api.hh"
19#include "WM_types.hh"
20
21#include "spreadsheet_intern.hh"
23
25
26static int row_filter_add_exec(bContext *C, wmOperator * /*op*/)
27{
29
31 BLI_addtail(&sspreadsheet->row_filters, row_filter);
32
34
35 return OPERATOR_FINISHED;
36}
37
39{
40 ot->name = "Add Row Filter";
41 ot->description = "Add a filter to remove rows from the displayed data";
42 ot->idname = "SPREADSHEET_OT_add_row_filter_rule";
43
46
48}
49
51{
53
55 &sspreadsheet->row_filters, RNA_int_get(op->ptr, "index"));
56 if (row_filter == nullptr) {
57 return OPERATOR_CANCELLED;
58 }
59
60 BLI_remlink(&sspreadsheet->row_filters, row_filter);
62
64
65 return OPERATOR_FINISHED;
66}
67
69{
70 ot->name = "Remove Row Filter";
71 ot->description = "Remove a row filter from the rules";
72 ot->idname = "SPREADSHEET_OT_remove_row_filter_rule";
73
76
78
79 RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX);
80}
81
82static int select_component_domain_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
83{
84 const auto component_type = bke::GeometryComponent::Type(RNA_int_get(op->ptr, "component_type"));
85 bke::AttrDomain domain = bke::AttrDomain(RNA_int_get(op->ptr, "attribute_domain_type"));
86
88 sspreadsheet->geometry_component_type = uint8_t(component_type);
89 sspreadsheet->attribute_domain = uint8_t(domain);
90
91 /* Refresh header and main region. */
93
94 return OPERATOR_FINISHED;
95}
96
98{
99 ot->name = "Change Visible Data Source";
100 ot->description = "Change visible data source in the spreadsheet";
101 ot->idname = "SPREADSHEET_OT_change_spreadsheet_data_source";
102
105
106 RNA_def_int(ot->srna, "component_type", 0, 0, INT16_MAX, "Component Type", "", 0, INT16_MAX);
108 "attribute_domain_type",
109 0,
110 0,
111 INT16_MAX,
112 "Attribute Domain Type",
113 "",
114 0,
115 INT16_MAX);
116
118}
119
126
127} // namespace blender::ed::spreadsheet
SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:130
bool ED_operator_spreadsheet_active(bContext *C)
Read Guarded memory(de)allocation.
@ OPTYPE_INTERNAL
Definition WM_types.hh:182
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
#define ND_SPACE_SPREADSHEET
Definition WM_types.hh:507
#define NC_SPACE
Definition WM_types.hh:359
SpreadsheetRowFilter * spreadsheet_row_filter_new()
static void SPREADSHEET_OT_change_spreadsheet_data_source(wmOperatorType *ot)
static int select_component_domain_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void SPREADSHEET_OT_add_row_filter_rule(wmOperatorType *ot)
static int row_filter_add_exec(bContext *C, wmOperator *)
static int row_filter_remove_exec(bContext *C, wmOperator *op)
void spreadsheet_row_filter_free(SpreadsheetRowFilter *row_filter)
static void SPREADSHEET_OT_remove_row_filter_rule(wmOperatorType *ot)
int RNA_int_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
unsigned char uint8_t
Definition stdint.h:78
#define INT16_MAX
Definition stdint.h:135
uint8_t geometry_component_type
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
StructRNA * srna
Definition WM_types.hh:1080
struct PointerRNA * ptr
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))