47 ot->name =
"Add Row Filter";
48 ot->description =
"Add a filter to remove rows from the displayed data";
49 ot->idname =
"SPREADSHEET_OT_add_row_filter_rule";
63 if (row_filter ==
nullptr) {
77 ot->name =
"Remove Row Filter";
78 ot->description =
"Remove a row filter from the rules";
79 ot->idname =
"SPREADSHEET_OT_remove_row_filter_rule";
86 RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, INT_MAX);
108 ot->name =
"Change Visible Data Source";
109 ot->description =
"Change visible data source in the spreadsheet";
110 ot->idname =
"SPREADSHEET_OT_change_spreadsheet_data_source";
117 "attribute_domain_type",
121 "Attribute Domain Type",
143 auto cancel = [&]() {
149 auto finish = [&]() {
156 const int2 cursor_re{
event->mval[0],
event->mval[1]};
158 switch (event->
type) {
167 const int offset = cursor_re.x -
data.initial_cursor_re.x;
169 data.initial_width_px + offset);
182 const int2 &cursor_re)
186 cursor_re.y <= region_height;
191 const int2 &cursor_re)
211 const int2 &cursor_re)
222 if (cursor_x_view > column->runtime->left_x && cursor_x_view <= column->runtime->right_x) {
231 const int2 &cursor_re)
241 const int2 &cursor_re)
254 const int2 cursor_re{
event->mval[0],
event->mval[1]};
256 sspreadsheet, region, cursor_re);
257 if (!column_to_resize) {
262 data->column = column_to_resize;
263 data->initial_cursor_re = cursor_re;
273 ot->name =
"Resize Column";
274 ot->description =
"Resize a spreadsheet column";
275 ot->idname =
"SPREADSHEET_OT_resize_column";
292 const int2 cursor_re{
event->mval[0],
event->mval[1]};
298 std::unique_ptr<ColumnValues> values = data_source->get_column_values(*column->
id);
306 const float width_px = values->fit_column_width_px();
315 ot->name =
"Fit Column";
316 ot->description =
"Resize a spreadsheet column to the width of the data";
317 ot->idname =
"SPREADSHEET_OT_fit_column";
355 const int2 cursor_re{
event->mval[0],
event->mval[1]};
362 if (!column_to_move) {
372 data->column = column_to_move;
378 visualization_data.
old_index = old_index;
379 visualization_data.
new_index = old_index;
398 const int2 cursor_re{
event->mval[0],
event->mval[1]};
408 if (hovered_column) {
420 auto cleanup_on_finish = [&]() {
427 switch (event->
type) {
435 if (old_index != new_index) {
447 visualization_data.
new_index = new_index;
450 data.initial_cursor_x_view;
470 ot->name =
"Reorder Columns";
471 ot->description =
"Change the order of columns";
472 ot->idname =
"SPREADSHEET_OT_reorder_columns";
wmWindow * CTX_wm_window(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
bool BLI_rcti_isect_pt_v(const struct rcti *rect, const int xy[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
@ SPREADSHEET_COLUMN_FLAG_UNAVAILABLE
#define SPREADSHEET_WIDTH_UNIT
@ SPREADSHEET_TABLE_FLAG_MANUALLY_EDITED
bool ED_operator_spreadsheet_active(bContext *C)
void ED_region_tag_redraw(ARegion *region)
void UI_view2d_edge_pan_cancel(bContext *C, View2DEdgePanData *vpd)
void UI_view2d_edge_pan_init(bContext *C, View2DEdgePanData *vpd, float inside_pad, float outside_pad, float speed_ramp, float max_speed, float delay, float zoom_influence)
void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[2]) ATTR_NONNULL(1
float UI_view2d_region_to_view_x(const View2D *v2d, float x)
#define ND_SPACE_SPREADSHEET
BMesh const char void * data
constexpr int64_t first_index(const T &search_value) const
void move_index(T *items, const int items_num, const int from_index, const int to_index)
void spreadsheet_operatortypes()
SpreadsheetRowFilter * spreadsheet_row_filter_new()
static void SPREADSHEET_OT_resize_column(wmOperatorType *ot)
static void SPREADSHEET_OT_change_spreadsheet_data_source(wmOperatorType *ot)
SpreadsheetColumn * find_hovered_column_edge(SpaceSpreadsheet &sspreadsheet, ARegion ®ion, const int2 &cursor_re)
SpreadsheetColumn * find_hovered_column(SpaceSpreadsheet &sspreadsheet, ARegion ®ion, const int2 &cursor_re)
static wmOperatorStatus resize_column_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus reorder_columns_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus reorder_columns_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static std::optional< int > find_first_available_column_index(const SpreadsheetTable &table)
static void SPREADSHEET_OT_fit_column(wmOperatorType *ot)
std::unique_ptr< DataSource > get_data_source(const bContext &C)
static void SPREADSHEET_OT_reorder_columns(wmOperatorType *ot)
static void SPREADSHEET_OT_add_row_filter_rule(wmOperatorType *ot)
static bool is_hovering_header_row(const SpaceSpreadsheet &sspreadsheet, const ARegion ®ion, const int2 &cursor_re)
SpreadsheetColumn * find_hovered_column_header(SpaceSpreadsheet &sspreadsheet, ARegion ®ion, const int2 &cursor_re)
static wmOperatorStatus resize_column_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus row_filter_remove_exec(bContext *C, wmOperator *op)
static wmOperatorStatus row_filter_add_exec(bContext *C, wmOperator *)
void spreadsheet_row_filter_free(SpreadsheetRowFilter *row_filter)
SpreadsheetColumn * find_hovered_column_header_edge(SpaceSpreadsheet &sspreadsheet, ARegion ®ion, const int2 &cursor_re)
SpreadsheetTable * get_active_table(SpaceSpreadsheet &sspreadsheet)
static std::optional< int > find_last_available_column_index(const SpreadsheetTable &table)
static void SPREADSHEET_OT_remove_row_filter_rule(wmOperatorType *ot)
static wmOperatorStatus select_component_domain_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus fit_column_invoke(bContext *C, wmOperator *, const wmEvent *event)
VecBase< int32_t, 2 > int2
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)
#define SPREADSHEET_EDGE_ACTION_ZONE
SpreadsheetTableIDGeometry geometry_id
SpaceSpreadsheet_Runtime * runtime
uint8_t geometry_component_type
SpreadsheetColumn ** columns
int initial_cursor_x_view
SpreadsheetColumn * column
View2DEdgePanData pan_data
SpreadsheetColumn * column
std::optional< ReorderColumnVisualizationData > reorder_column_visualization_data
void WM_cursor_set(wmWindow *win, int curs)
void WM_main_add_notifier(uint type, void *reference)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))