Blender  V2.93
space_spreadsheet.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include <cstring>
18 
19 #include "BLI_listbase.h"
20 
21 #include "BKE_screen.h"
22 
23 #include "ED_screen.h"
24 #include "ED_space_api.h"
25 #include "ED_spreadsheet.h"
26 
27 #include "DNA_scene_types.h"
28 #include "DNA_screen_types.h"
29 #include "DNA_space_types.h"
30 
31 #include "MEM_guardedalloc.h"
32 
33 #include "UI_interface.h"
34 #include "UI_resources.h"
35 #include "UI_view2d.h"
36 
37 #include "DEG_depsgraph_query.h"
38 
39 #include "RNA_access.h"
40 
41 #include "WM_api.h"
42 #include "WM_types.h"
43 
44 #include "BLF_api.h"
45 
46 #include "spreadsheet_intern.hh"
47 
48 #include "spreadsheet_context.hh"
50 #include "spreadsheet_intern.hh"
51 #include "spreadsheet_layout.hh"
52 
53 using namespace blender;
54 using namespace blender::ed::spreadsheet;
55 
57 {
58  SpaceSpreadsheet *spreadsheet_space = (SpaceSpreadsheet *)MEM_callocN(sizeof(SpaceSpreadsheet),
59  "spreadsheet space");
60  spreadsheet_space->spacetype = SPACE_SPREADSHEET;
61 
62  {
63  /* Header. */
64  ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet header");
65  BLI_addtail(&spreadsheet_space->regionbase, region);
66  region->regiontype = RGN_TYPE_HEADER;
68  }
69 
70  {
71  /* Footer. */
72  ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet footer region");
73  BLI_addtail(&spreadsheet_space->regionbase, region);
74  region->regiontype = RGN_TYPE_FOOTER;
76  }
77 
78  {
79  /* Main window. */
80  ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet main region");
81  BLI_addtail(&spreadsheet_space->regionbase, region);
82  region->regiontype = RGN_TYPE_WINDOW;
83  }
84 
85  return (SpaceLink *)spreadsheet_space;
86 }
87 
88 static void spreadsheet_free(SpaceLink *sl)
89 {
90  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
91  MEM_SAFE_FREE(sspreadsheet->runtime);
92 
93  LISTBASE_FOREACH_MUTABLE (SpreadsheetColumn *, column, &sspreadsheet->columns) {
95  }
98  }
99 }
100 
102 {
103  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)area->spacedata.first;
104  if (sspreadsheet->runtime == nullptr) {
105  sspreadsheet->runtime = (SpaceSpreadsheet_Runtime *)MEM_callocN(
106  sizeof(SpaceSpreadsheet_Runtime), __func__);
107  }
108 }
109 
111 {
112  const SpaceSpreadsheet *sspreadsheet_old = (SpaceSpreadsheet *)sl;
113  SpaceSpreadsheet *sspreadsheet_new = (SpaceSpreadsheet *)MEM_dupallocN(sspreadsheet_old);
114  sspreadsheet_new->runtime = (SpaceSpreadsheet_Runtime *)MEM_dupallocN(sspreadsheet_old->runtime);
115 
116  BLI_listbase_clear(&sspreadsheet_new->columns);
117  LISTBASE_FOREACH (SpreadsheetColumn *, src_column, &sspreadsheet_old->columns) {
118  SpreadsheetColumn *new_column = spreadsheet_column_copy(src_column);
119  BLI_addtail(&sspreadsheet_new->columns, new_column);
120  }
121 
122  BLI_listbase_clear(&sspreadsheet_new->context_path);
123  LISTBASE_FOREACH_MUTABLE (SpreadsheetContext *, src_context, &sspreadsheet_old->context_path) {
124  SpreadsheetContext *new_context = spreadsheet_context_copy(src_context);
125  BLI_addtail(&sspreadsheet_new->context_path, new_context);
126  }
127 
128  return (SpaceLink *)sspreadsheet_new;
129 }
130 
131 static void spreadsheet_keymap(wmKeyConfig *UNUSED(keyconf))
132 {
133 }
134 
135 static void spreadsheet_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
136 {
137  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)slink;
139  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
141  if ((ID *)object_context->object == old_id) {
142  if (new_id && GS(new_id->name) == ID_OB) {
143  object_context->object = (Object *)new_id;
144  }
145  else {
146  object_context->object = nullptr;
147  }
148  }
149  }
150  }
151 }
152 
154 {
158  region->v2d.keeptot = V2D_KEEPTOT_STRICT;
159  region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
160 
161  UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
162 
163  wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
164  WM_event_add_keymap_handler(&region->handlers, keymap);
165 }
166 
168 {
169  if (BLI_listbase_is_empty(&sspreadsheet->context_path)) {
170  return nullptr;
171  }
172  SpreadsheetContext *root_context = (SpreadsheetContext *)sspreadsheet->context_path.first;
173  if (root_context->type != SPREADSHEET_CONTEXT_OBJECT) {
174  return nullptr;
175  }
176  SpreadsheetContextObject *object_context = (SpreadsheetContextObject *)root_context;
177  return (ID *)object_context->object;
178 }
179 
180 /* Check if the pinned context still exists. If it doesn't try to find a new context. */
182 {
184 
185  /* Currently, this only checks if the object has been deleted. In the future we can have a more
186  * sophisticated check for the entire context (including modifier and nodes). */
188  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
190  if (object_context->object == nullptr) {
191  ED_spreadsheet_context_path_clear(sspreadsheet);
192  break;
193  }
194  }
195  }
196  if (BLI_listbase_is_empty(&sspreadsheet->context_path)) {
197  Object *active_object = CTX_data_active_object(C);
198  if (active_object != nullptr) {
200  ((SpreadsheetContextObject *)new_context)->object = active_object;
201  BLI_addtail(&sspreadsheet->context_path, new_context);
202  }
203  }
204 
205  if (BLI_listbase_is_empty(&sspreadsheet->context_path)) {
206  /* Don't pin empty context_path, that could be annoying. */
207  sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED;
208  }
209 }
210 
212 {
214  Object *active_object = CTX_data_active_object(C);
215  if (active_object == nullptr) {
216  ED_spreadsheet_context_path_clear(sspreadsheet);
217  return;
218  }
219  if (!BLI_listbase_is_empty(&sspreadsheet->context_path)) {
220  SpreadsheetContext *root_context = (SpreadsheetContext *)sspreadsheet->context_path.first;
221  if (root_context->type == SPREADSHEET_CONTEXT_OBJECT) {
222  SpreadsheetContextObject *object_context = (SpreadsheetContextObject *)root_context;
223  if (object_context->object != active_object) {
224  ED_spreadsheet_context_path_clear(sspreadsheet);
225  }
226  }
227  }
228  if (BLI_listbase_is_empty(&sspreadsheet->context_path)) {
230  ((SpreadsheetContextObject *)new_context)->object = active_object;
231  BLI_addtail(&sspreadsheet->context_path, new_context);
232  }
233 }
234 
235 static void update_context_path(const bContext *C)
236 {
238  if (sspreadsheet->flag & SPREADSHEET_FLAG_PINNED) {
240  }
241  else {
243  }
244 }
245 
246 static std::unique_ptr<DataSource> get_data_source(const bContext *C)
247 {
250  ID *used_id = ED_spreadsheet_get_current_id(sspreadsheet);
251  if (used_id == nullptr) {
252  return {};
253  }
254  const ID_Type id_type = GS(used_id->name);
255  if (id_type != ID_OB) {
256  return {};
257  }
258  Object *object_orig = (Object *)used_id;
259  if (!ELEM(object_orig->type, OB_MESH, OB_POINTCLOUD)) {
260  return {};
261  }
262  Object *object_eval = DEG_get_evaluated_object(depsgraph, object_orig);
263  if (object_eval == nullptr) {
264  return {};
265  }
266 
267  return data_source_from_geometry(C, object_eval);
268 }
269 
270 static float get_column_width(const ColumnValues &values)
271 {
272  if (values.default_width > 0) {
273  return values.default_width;
274  }
275  const int fontid = UI_style_get()->widget.uifont_id;
276  BLF_size(fontid, UI_DEFAULT_TEXT_POINTS, U.dpi);
277  const StringRefNull name = values.name();
278  const float name_width = BLF_width(fontid, name.data(), name.size());
279  return std::max<float>(name_width / UI_UNIT_X + 1.0f, 3.0f);
280 }
281 
282 static float get_column_width_in_pixels(const ColumnValues &values)
283 {
284  return get_column_width(values) * SPREADSHEET_WIDTH_UNIT;
285 }
286 
287 static int get_index_column_width(const int tot_rows)
288 {
289  const int fontid = UI_style_get()->widget.uifont_id;
290  BLF_size(fontid, UI_style_get_dpi()->widget.points * U.pixelsize, U.dpi);
291  return std::to_string(std::max(0, tot_rows - 1)).size() * BLF_width(fontid, "0", 1) +
292  UI_UNIT_X * 0.75;
293 }
294 
295 static void update_visible_columns(ListBase &columns, DataSource &data_source)
296 {
297  Set<SpreadsheetColumnID> used_ids;
298  LISTBASE_FOREACH_MUTABLE (SpreadsheetColumn *, column, &columns) {
299  std::unique_ptr<ColumnValues> values = data_source.get_column_values(*column->id);
300  /* Remove columns that don't exist anymore. */
301  if (!values) {
302  BLI_remlink(&columns, column);
303  spreadsheet_column_free(column);
304  continue;
305  }
306 
307  if (!used_ids.add(*column->id)) {
308  /* Remove duplicate columns for now. */
309  BLI_remlink(&columns, column);
310  spreadsheet_column_free(column);
311  continue;
312  }
313  }
314 
315  data_source.foreach_default_column_ids([&](const SpreadsheetColumnID &column_id) {
316  std::unique_ptr<ColumnValues> values = data_source.get_column_values(column_id);
317  if (values) {
318  if (used_ids.add(column_id)) {
319  SpreadsheetColumnID *new_id = spreadsheet_column_id_copy(&column_id);
320  SpreadsheetColumn *new_column = spreadsheet_column_new(new_id);
321  BLI_addtail(&columns, new_column);
322  }
323  }
324  });
325 }
326 
327 static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
328 {
331 
332  std::unique_ptr<DataSource> data_source = get_data_source(C);
333  if (!data_source) {
334  data_source = std::make_unique<DataSource>();
335  }
336 
337  update_visible_columns(sspreadsheet->columns, *data_source);
338 
339  SpreadsheetLayout spreadsheet_layout;
340  ResourceScope scope;
341 
342  LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
343  std::unique_ptr<ColumnValues> values_ptr = data_source->get_column_values(*column->id);
344  /* Should have been removed before if it does not exist anymore. */
345  BLI_assert(values_ptr);
346  const ColumnValues *values = scope.add(std::move(values_ptr), __func__);
347  const int width = get_column_width_in_pixels(*values);
348  spreadsheet_layout.columns.append({values, width});
349  }
350 
351  const int tot_rows = data_source->tot_rows();
352  spreadsheet_layout.index_column_width = get_index_column_width(tot_rows);
353  spreadsheet_layout.row_indices = IndexRange(tot_rows).as_span();
354 
355  if (const GeometryDataSource *geometry_data_source = dynamic_cast<const GeometryDataSource *>(
356  data_source.get())) {
357  Object *object_eval = geometry_data_source->object_eval();
358  Object *object_orig = DEG_get_original_object(object_eval);
359  if (object_orig->type == OB_MESH) {
360  if (object_orig->mode == OB_MODE_EDIT) {
361  if (sspreadsheet->filter_flag & SPREADSHEET_FILTER_SELECTED_ONLY) {
362  spreadsheet_layout.row_indices = geometry_data_source->get_selected_element_indices();
363  }
364  }
365  }
366  }
367 
368  sspreadsheet->runtime->tot_columns = spreadsheet_layout.columns.size();
369  sspreadsheet->runtime->tot_rows = tot_rows;
370  sspreadsheet->runtime->visible_rows = spreadsheet_layout.row_indices.size();
371 
372  std::unique_ptr<SpreadsheetDrawer> drawer = spreadsheet_drawer_from_layout(spreadsheet_layout);
373  draw_spreadsheet_in_region(C, region, *drawer);
374 
375  /* Tag footer for redraw, because the main region updates data for the footer. */
377  ED_region_tag_redraw(footer);
378 }
379 
381 {
382  ARegion *region = params->region;
383  wmNotifier *wmn = params->notifier;
384 
385  switch (wmn->category) {
386  case NC_SCENE: {
387  switch (wmn->data) {
388  case ND_MODE:
389  case ND_FRAME:
390  case ND_OB_ACTIVE: {
391  ED_region_tag_redraw(region);
392  break;
393  }
394  }
395  break;
396  }
397  case NC_OBJECT: {
398  ED_region_tag_redraw(region);
399  break;
400  }
401  case NC_SPACE: {
402  if (wmn->data == ND_SPACE_SPREADSHEET) {
403  ED_region_tag_redraw(region);
404  }
405  break;
406  }
407  case NC_TEXTURE:
408  case NC_GEOM: {
409  ED_region_tag_redraw(region);
410  break;
411  }
412  }
413 }
414 
416 {
417  ED_region_header_init(region);
418 }
419 
420 static void spreadsheet_header_region_draw(const bContext *C, ARegion *region)
421 {
423  ED_region_header(C, region);
424 }
425 
427 {
428 }
429 
431 {
432  ARegion *region = params->region;
433  wmNotifier *wmn = params->notifier;
434 
435  switch (wmn->category) {
436  case NC_SCENE: {
437  switch (wmn->data) {
438  case ND_MODE:
439  case ND_OB_ACTIVE: {
440  ED_region_tag_redraw(region);
441  break;
442  }
443  }
444  break;
445  }
446  case NC_OBJECT: {
447  ED_region_tag_redraw(region);
448  break;
449  }
450  case NC_SPACE: {
451  if (wmn->data == ND_SPACE_SPREADSHEET) {
452  ED_region_tag_redraw(region);
453  }
454  break;
455  }
456  case NC_GEOM: {
457  ED_region_tag_redraw(region);
458  break;
459  }
460  }
461 }
462 
464 {
465  ED_region_header_init(region);
466 }
467 
468 static void spreadsheet_footer_region_draw(const bContext *C, ARegion *region)
469 {
471  SpaceSpreadsheet_Runtime *runtime = sspreadsheet->runtime;
472  std::stringstream ss;
473  ss << "Rows: ";
474  if (runtime->visible_rows != runtime->tot_rows) {
475  char visible_rows_str[16];
476  BLI_str_format_int_grouped(visible_rows_str, runtime->visible_rows);
477  ss << visible_rows_str << " / ";
478  }
479  char tot_rows_str[16];
480  BLI_str_format_int_grouped(tot_rows_str, runtime->tot_rows);
481  ss << tot_rows_str << " | Columns: " << runtime->tot_columns;
482  std::string stats_str = ss.str();
483 
485 
486  uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
487  const uiStyle *style = UI_style_get_dpi();
488  uiLayout *layout = UI_block_layout(block,
492  region->winy - (region->winy - UI_UNIT_Y) / 2.0f,
493  region->sizex,
494  1,
495  0,
496  style);
497  uiItemSpacer(layout);
499  uiItemL(layout, stats_str.c_str(), ICON_NONE);
500  UI_block_layout_resolve(block, nullptr, nullptr);
501  UI_block_align_end(block);
502  UI_block_end(C, block);
503  UI_block_draw(C, block);
504 }
505 
507 {
508 }
509 
511 {
512 }
513 
515 {
516  SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype spreadsheet");
517  ARegionType *art;
518 
520  strncpy(st->name, "Spreadsheet", BKE_ST_MAXNAME);
521 
523  st->free = spreadsheet_free;
524  st->init = spreadsheet_init;
529 
530  /* regions: main window */
531  art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet region");
532  art->regionid = RGN_TYPE_WINDOW;
534 
538  BLI_addhead(&st->regiontypes, art);
539 
540  /* regions: header */
541  art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet header region");
542  art->regionid = RGN_TYPE_HEADER;
543  art->prefsizey = HEADERY;
544  art->keymapflag = 0;
546 
551  BLI_addhead(&st->regiontypes, art);
552 
553  /* regions: footer */
554  art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet footer region");
555  art->regionid = RGN_TYPE_FOOTER;
556  art->prefsizey = HEADERY;
557  art->keymapflag = 0;
559 
564  BLI_addhead(&st->regiontypes, art);
565 
567 }
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
Definition: context.c:917
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
#define BKE_ST_MAXNAME
Definition: BKE_screen.h:68
void BKE_spacetype_register(struct SpaceType *st)
Definition: screen.c:420
float BLF_width(int fontid, const char *str, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: blf.c:723
void BLF_size(int fontid, int size, int dpi)
Definition: blf.c:367
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:87
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:188
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL()
Definition: string.c:1170
#define UNUSED(x)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct Object * DEG_get_original_object(struct Object *object)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
ID_Type
Definition: DNA_ID_enums.h:56
@ ID_OB
Definition: DNA_ID_enums.h:59
@ OB_MODE_EDIT
@ OB_MESH
@ OB_POINTCLOUD
#define HEADERY
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_TOP
@ RGN_TYPE_WINDOW
@ RGN_TYPE_FOOTER
@ RGN_TYPE_HEADER
@ SPREADSHEET_CONTEXT_OBJECT
@ SPACE_SPREADSHEET
@ SPREADSHEET_FILTER_SELECTED_ONLY
#define SPREADSHEET_WIDTH_UNIT
@ SPREADSHEET_FLAG_PINNED
@ USER_HEADER_BOTTOM
@ V2D_KEEPTOT_STRICT
@ V2D_SCROLL_RIGHT
@ V2D_SCROLL_BOTTOM
@ V2D_ALIGN_NO_NEG_X
@ V2D_ALIGN_NO_POS_Y
@ V2D_LIMITZOOM
@ V2D_LOCKZOOM_X
@ V2D_KEEPASPECT
@ V2D_LOCKZOOM_Y
void ED_region_header(const struct bContext *C, struct ARegion *region)
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
void ED_region_header_init(struct ARegion *region)
Definition: area.c:3358
@ ED_KEYMAP_UI
Definition: ED_screen.h:440
@ ED_KEYMAP_HEADER
Definition: ED_screen.h:446
@ ED_KEYMAP_VIEW2D
Definition: ED_screen.h:443
void ED_spreadsheet_context_path_clear(struct SpaceSpreadsheet *sspreadsheet)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
#define C
Definition: RandGen.cpp:39
#define UI_UNIT_Y
@ UI_EMBOSS
Definition: UI_interface.h:107
const struct uiStyle * UI_style_get_dpi(void)
@ UI_LAYOUT_HEADER
void uiItemL(uiLayout *layout, const char *name, int icon)
const struct uiStyle * UI_style_get(void)
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
#define UI_HEADER_OFFSET
@ UI_LAYOUT_ALIGN_RIGHT
void UI_block_end(const struct bContext *C, uiBlock *block)
void uiItemSpacer(uiLayout *layout)
void UI_block_draw(const struct bContext *C, struct uiBlock *block)
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const struct uiStyle *style)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
#define UI_DEFAULT_TEXT_POINTS
Definition: UI_interface.h:238
#define UI_UNIT_X
@ UI_LAYOUT_HORIZONTAL
void UI_block_align_end(uiBlock *block)
Definition: interface.c:3834
@ TH_BACK
Definition: UI_resources.h:55
void UI_ThemeClearColor(int colorid)
Definition: resources.c:1478
void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy)
Definition: view2d.c:240
@ V2D_COMMONVIEW_LIST
Definition: UI_view2d.h:53
#define NC_GEOM
Definition: WM_types.h:294
#define ND_OB_ACTIVE
Definition: WM_types.h:340
#define ND_MODE
Definition: WM_types.h:345
#define NC_SCENE
Definition: WM_types.h:279
#define ND_FRAME
Definition: WM_types.h:334
#define NC_TEXTURE
Definition: WM_types.h:282
#define ND_SPACE_SPREADSHEET
Definition: WM_types.h:435
#define NC_OBJECT
Definition: WM_types.h:280
#define NC_SPACE
Definition: WM_types.h:293
unsigned int U
Definition: btGjkEpa3.h:78
Span< int64_t > as_span() const
T * add(std::unique_ptr< T > resource, const char *name)
bool add(const Key &key)
Definition: BLI_set.hh:267
constexpr int64_t size() const
Definition: BLI_span.hh:254
constexpr const char * data() const
constexpr int64_t size() const
virtual void foreach_default_column_ids(FunctionRef< void(const SpreadsheetColumnID &)> fn) const
virtual std::unique_ptr< ColumnValues > get_column_values(const SpreadsheetColumnID &column_id) const
Scene scene
const Depsgraph * depsgraph
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define GS(x)
Definition: iris.c:241
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void area(int d1, int d2, int e1, int e2, float weights[2])
SpreadsheetContext * spreadsheet_context_copy(const SpreadsheetContext *old_context)
void spreadsheet_context_free(SpreadsheetContext *context)
void draw_spreadsheet_in_region(const bContext *C, ARegion *region, const SpreadsheetDrawer &drawer)
std::unique_ptr< DataSource > data_source_from_geometry(const bContext *C, Object *object_eval)
void spreadsheet_column_free(SpreadsheetColumn *column)
std::unique_ptr< SpreadsheetDrawer > spreadsheet_drawer_from_layout(const SpreadsheetLayout &spreadsheet_layout)
SpreadsheetContext * spreadsheet_context_new(eSpaceSpreadsheet_ContextType type)
SpreadsheetColumn * spreadsheet_column_copy(const SpreadsheetColumn *src_column)
std::string to_string(const T &n)
struct SELECTID_Context context
Definition: select_engine.c:47
static std::unique_ptr< DataSource > get_data_source(const bContext *C)
static void spreadsheet_free(SpaceLink *sl)
static void spreadsheet_init(wmWindowManager *UNUSED(wm), ScrArea *area)
static int get_index_column_width(const int tot_rows)
static void spreadsheet_footer_region_listener(const wmRegionListenerParams *UNUSED(params))
static void spreadsheet_header_region_listener(const wmRegionListenerParams *params)
static void spreadsheet_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
ID * ED_spreadsheet_get_current_id(struct SpaceSpreadsheet *sspreadsheet)
static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
static void spreadsheet_footer_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
void ED_spacetype_spreadsheet(void)
static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
static void spreadsheet_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id, ID *new_id)
static void spreadsheet_footer_region_free(ARegion *UNUSED(region))
static void update_context_path(const bContext *C)
static SpaceLink * spreadsheet_duplicate(SpaceLink *sl)
static float get_column_width_in_pixels(const ColumnValues &values)
static float get_column_width(const ColumnValues &values)
static SpaceLink * spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static void spreadsheet_footer_region_draw(const bContext *C, ARegion *region)
static void update_context_path_from_context(const bContext *C)
static void spreadsheet_header_region_draw(const bContext *C, ARegion *region)
static void spreadsheet_header_region_free(ARegion *UNUSED(region))
static void spreadsheet_main_region_listener(const wmRegionListenerParams *params)
static void update_visible_columns(ListBase &columns, DataSource &data_source)
static void spreadsheet_keymap(wmKeyConfig *UNUSED(keyconf))
static void update_pinned_context_path_if_outdated(const bContext *C)
void spreadsheet_operatortypes(void)
void(* draw)(const struct bContext *C, struct ARegion *region)
Definition: BKE_screen.h:169
void(* listener)(const wmRegionListenerParams *params)
Definition: BKE_screen.h:183
int keymapflag
Definition: BKE_screen.h:226
void(* free)(struct ARegion *)
Definition: BKE_screen.h:187
void(* init)(struct wmWindowManager *wm, struct ARegion *region)
Definition: BKE_screen.h:165
ListBase handlers
short alignment
short regiontype
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
SpaceSpreadsheet_Runtime * runtime
struct SpaceLink *(* duplicate)(struct SpaceLink *sl)
Definition: BKE_screen.h:104
ListBase regiontypes
Definition: BKE_screen.h:130
void(* keymap)(struct wmKeyConfig *keyconf)
Definition: BKE_screen.h:109
void(* operatortypes)(void)
Definition: BKE_screen.h:107
void(* free)(struct SpaceLink *sl)
Definition: BKE_screen.h:88
struct SpaceLink *(* create)(const struct ScrArea *area, const struct Scene *scene)
Definition: BKE_screen.h:86
void(* init)(struct wmWindowManager *wm, struct ScrArea *area)
Definition: BKE_screen.h:91
int spaceid
Definition: BKE_screen.h:81
void(* id_remap)(struct ScrArea *area, struct SpaceLink *sl, struct ID *old_id, struct ID *new_id)
Definition: BKE_screen.h:120
char name[BKE_ST_MAXNAME]
Definition: BKE_screen.h:80
float minzoom
short align
short keeptot
short keepzoom
short scroll
float maxzoom
uiFontStyle widget
unsigned int data
Definition: WM_types.h:260
unsigned int category
Definition: WM_types.h:260
struct wmKeyConfig * defaultconf
float max
wmEventHandler_Keymap * WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852