Blender  V2.93
screen.c
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  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 /* Allow using deprecated functionality for .blend file I/O. */
25 #define DNA_DEPRECATED_ALLOW
26 
27 #ifdef WIN32
28 # include "BLI_winstuff.h"
29 #endif
30 
31 #include <math.h>
32 #include <stdio.h>
33 #include <string.h>
34 
35 #include "MEM_guardedalloc.h"
36 
37 #include "DNA_collection_types.h"
38 #include "DNA_defaults.h"
39 #include "DNA_gpencil_types.h"
40 #include "DNA_mask_types.h"
41 #include "DNA_scene_types.h"
42 #include "DNA_screen_types.h"
43 #include "DNA_space_types.h"
44 #include "DNA_text_types.h"
45 #include "DNA_view3d_types.h"
46 #include "DNA_workspace_types.h"
47 
48 #include "BLI_listbase.h"
49 #include "BLI_math_vector.h"
50 #include "BLI_mempool.h"
51 #include "BLI_rect.h"
52 #include "BLI_utildefines.h"
53 
54 #include "BLT_translation.h"
55 
56 #include "BKE_gpencil.h"
57 #include "BKE_icons.h"
58 #include "BKE_idprop.h"
59 #include "BKE_idtype.h"
60 #include "BKE_lib_id.h"
61 #include "BKE_lib_query.h"
62 #include "BKE_node.h"
63 #include "BKE_screen.h"
64 #include "BKE_workspace.h"
65 
66 #include "BLO_read_write.h"
67 
68 #ifdef WITH_PYTHON
69 # include "BPY_extern.h"
70 #endif
71 
72 static void screen_free_data(ID *id)
73 {
74  bScreen *screen = (bScreen *)id;
75 
76  /* No animdata here. */
77 
78  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
79  BKE_area_region_free(NULL, region);
80  }
81 
82  BLI_freelistN(&screen->regionbase);
83 
85 
86  BKE_previewimg_free(&screen->preview);
87 
88  /* Region and timer are freed by the window manager. */
89  MEM_SAFE_FREE(screen->tool_tip);
90 }
91 
93 {
94  if (ads != NULL) {
97  }
98 }
99 
101 {
103 
104  /* TODO this should be moved to a callback in `SpaceType`, defined in each editor's own code.
105  * Will be for a later round of cleanup though... */
106  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
107  switch (sl->spacetype) {
108  case SPACE_VIEW3D: {
109  View3D *v3d = (View3D *)sl;
110 
113 
114  if (v3d->localvd) {
116  }
117  break;
118  }
119  case SPACE_GRAPH: {
120  SpaceGraph *sipo = (SpaceGraph *)sl;
121 
123  break;
124  }
125  case SPACE_PROPERTIES: {
126  SpaceProperties *sbuts = (SpaceProperties *)sl;
127 
129  break;
130  }
131  case SPACE_FILE:
132  break;
133  case SPACE_ACTION: {
134  SpaceAction *saction = (SpaceAction *)sl;
135 
138  break;
139  }
140  case SPACE_IMAGE: {
141  SpaceImage *sima = (SpaceImage *)sl;
142 
146  break;
147  }
148  case SPACE_SEQ: {
149  SpaceSeq *sseq = (SpaceSeq *)sl;
150 
152  break;
153  }
154  case SPACE_NLA: {
155  SpaceNla *snla = (SpaceNla *)sl;
156 
158  break;
159  }
160  case SPACE_TEXT: {
161  SpaceText *st = (SpaceText *)sl;
162 
164  break;
165  }
166  case SPACE_SCRIPT: {
167  SpaceScript *scpt = (SpaceScript *)sl;
168 
170  break;
171  }
172  case SPACE_OUTLINER: {
173  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
174 
176 
177  if (space_outliner->treestore != NULL) {
178  TreeStoreElem *tselem;
179  BLI_mempool_iter iter;
180 
181  BLI_mempool_iternew(space_outliner->treestore, &iter);
182  while ((tselem = BLI_mempool_iterstep(&iter))) {
184  }
185  }
186  break;
187  }
188  case SPACE_NODE: {
189  SpaceNode *snode = (SpaceNode *)sl;
190 
191  const bool is_private_nodetree = snode->id != NULL &&
192  ntreeFromID(snode->id) == snode->nodetree;
193 
196 
198  data, snode->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_USER_ONE);
199 
200  LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
201  if (path == snode->treepath.first) {
202  /* first nodetree in path is same as snode->nodetree */
204  path->nodetree,
205  is_private_nodetree ? IDWALK_CB_EMBEDDED :
207  }
208  else {
210  }
211 
212  if (path->nodetree == NULL) {
213  break;
214  }
215  }
216 
218  break;
219  }
220  case SPACE_CLIP: {
221  SpaceClip *sclip = (SpaceClip *)sl;
222 
225  break;
226  }
227  case SPACE_SPREADSHEET: {
228  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
229 
231  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
234  }
235  }
236  break;
237  }
238  default:
239  break;
240  }
241  }
242 }
243 
245 {
247  bScreen *screen = (bScreen *)id;
248 
249  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
251  }
252  }
253 }
254 
255 static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
256 {
257  bScreen *screen = (bScreen *)id;
258  /* Screens are reference counted, only saved if used by a workspace. */
259  if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
260  /* write LibData */
261  /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
262  BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
263  BKE_id_blend_write(writer, &screen->id);
264 
265  BKE_previewimg_blend_write(writer, screen->preview);
266 
267  /* direct data */
269  }
270 }
271 
272 /* Cannot use IDTypeInfo callback yet, because of the return value. */
274 {
275  bool success = true;
276 
277  screen->regionbase.first = screen->regionbase.last = NULL;
278  screen->context = NULL;
279  screen->active_region = NULL;
280 
281  BLO_read_data_address(reader, &screen->preview);
282  BKE_previewimg_blend_read(reader, screen->preview);
283 
285  printf("Error reading Screen %s... removing it.\n", screen->id.name + 2);
286  success = false;
287  }
288 
289  return success;
290 }
291 
292 /* note: file read without screens option G_FILE_NO_UI;
293  * check lib pointers in call below */
294 static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
295 {
296  bScreen *screen = (bScreen *)id;
297  /* deprecated, but needed for versioning (will be NULL'ed then) */
298  BLO_read_id_address(reader, screen->id.lib, &screen->scene);
299 
300  screen->animtimer = NULL; /* saved in rare cases */
301  screen->tool_tip = NULL;
302  screen->scrubbing = false;
303 
304  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
305  BKE_screen_area_blend_read_lib(reader, &screen->id, area);
306  }
307 }
308 
310  .id_code = ID_SCR,
311  .id_filter = 0,
312  .main_listbase_index = INDEX_ID_SCR,
313  .struct_size = sizeof(bScreen),
314  .name = "Screen",
315  .name_plural = "screens",
316  .translation_context = BLT_I18NCONTEXT_ID_SCREEN,
318 
319  .init_data = NULL,
320  .copy_data = NULL,
321  .free_data = screen_free_data,
322  .make_local = NULL,
323  .foreach_id = screen_foreach_id,
324  .foreach_cache = NULL,
325  .owner_get = NULL,
326 
327  .blend_write = screen_blend_write,
328  /* Cannot be used yet, because #direct_link_screen has a return value. */
329  .blend_read_data = NULL,
330  .blend_read_lib = screen_blend_read_lib,
331  .blend_read_expand = NULL,
332 
333  .blend_read_undo_preserve = NULL,
334 
335  .lib_override_apply_post = NULL,
336 };
337 
338 /* ************ Spacetype/regiontype handling ************** */
339 
340 /* keep global; this has to be accessible outside of windowmanager */
342 
343 /* not SpaceType itself */
344 static void spacetype_free(SpaceType *st)
345 {
346  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
347 #ifdef WITH_PYTHON
349 #endif
350  BLI_freelistN(&art->drawcalls);
351 
352  LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) {
353  if (pt->rna_ext.free) {
354  pt->rna_ext.free(pt->rna_ext.data);
355  }
356 
357  BLI_freelistN(&pt->children);
358  }
359 
360  LISTBASE_FOREACH (HeaderType *, ht, &art->headertypes) {
361  if (ht->rna_ext.free) {
362  ht->rna_ext.free(ht->rna_ext.data);
363  }
364  }
365 
366  BLI_freelistN(&art->paneltypes);
367  BLI_freelistN(&art->headertypes);
368  }
369 
371 }
372 
374 {
376  spacetype_free(st);
377  }
378 
380 }
381 
383 {
385  if (st->spaceid == spaceid) {
386  return st;
387  }
388  }
389  return NULL;
390 }
391 
393 {
394  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
395  if (art->regionid == regionid) {
396  return art;
397  }
398  }
399 
400  printf(
401  "Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid);
402  return st->regiontypes.first;
403 }
404 
406 {
407  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
408  if (art->regionid == regionid) {
409  return art;
410  }
411  }
412  return NULL;
413 }
414 
416 {
417  return &spacetypes;
418 }
419 
421 {
422  /* sanity check */
424  if (stype) {
425  printf("error: redefinition of spacetype %s\n", stype->name);
426  spacetype_free(stype);
427  MEM_freeN(stype);
428  }
429 
430  BLI_addtail(&spacetypes, st);
431 }
432 
433 bool BKE_spacetype_exists(int spaceid)
434 {
435  return BKE_spacetype_from_id(spaceid) != NULL;
436 }
437 
438 /* ***************** Space handling ********************** */
439 
441 {
442  LISTBASE_FOREACH (SpaceLink *, sl, lb) {
443  SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
444 
445  /* free regions for pushed spaces */
446  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
447  BKE_area_region_free(st, region);
448  }
449 
450  BLI_freelistN(&sl->regionbase);
451 
452  if (st && st->free) {
453  st->free(sl);
454  }
455  }
456 
457  BLI_freelistN(lb);
458 }
459 
460 static void panel_list_copy(ListBase *newlb, const ListBase *lb)
461 {
462  BLI_listbase_clear(newlb);
463  BLI_duplicatelist(newlb, lb);
464 
465  /* copy panel pointers */
466  Panel *new_panel = newlb->first;
467  Panel *panel = lb->first;
468  for (; new_panel; new_panel = new_panel->next, panel = panel->next) {
469  new_panel->activedata = NULL;
470  new_panel->runtime.custom_data_ptr = NULL;
471  panel_list_copy(&new_panel->children, &panel->children);
472  }
473 }
474 
475 ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region)
476 {
477  ARegion *newar = MEM_dupallocN(region);
478 
479  newar->prev = newar->next = NULL;
480  BLI_listbase_clear(&newar->handlers);
481  BLI_listbase_clear(&newar->uiblocks);
484  BLI_listbase_clear(&newar->ui_lists);
485  newar->visible = 0;
486  newar->gizmo_map = NULL;
487  newar->regiontimer = NULL;
488  newar->headerstr = NULL;
489  newar->draw_buffer = NULL;
490 
491  /* use optional regiondata callback */
492  if (region->regiondata) {
493  ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);
494 
495  if (art && art->duplicate) {
496  newar->regiondata = art->duplicate(region->regiondata);
497  }
498  else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
499  newar->regiondata = NULL;
500  }
501  else {
502  newar->regiondata = MEM_dupallocN(region->regiondata);
503  }
504  }
505 
506  panel_list_copy(&newar->panels, &region->panels);
507 
509  BLI_duplicatelist(&newar->ui_previews, &region->ui_previews);
510 
511  return newar;
512 }
513 
514 /* from lb2 to lb1, lb1 is supposed to be freed */
515 static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
516 {
517  /* to be sure */
518  BLI_listbase_clear(lb1);
519 
520  LISTBASE_FOREACH (ARegion *, region, lb2) {
521  ARegion *region_new = BKE_area_region_copy(st, region);
522  BLI_addtail(lb1, region_new);
523  }
524 }
525 
526 /* lb1 should be empty */
528 {
529  BLI_listbase_clear(lb1); /* to be sure */
530 
531  LISTBASE_FOREACH (SpaceLink *, sl, lb2) {
532  SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
533 
534  if (st && st->duplicate) {
535  SpaceLink *slnew = st->duplicate(sl);
536 
537  BLI_addtail(lb1, slnew);
538 
539  region_copylist(st, &slnew->regionbase, &sl->regionbase);
540  }
541  }
542 }
543 
544 /* facility to set locks for drawing to survive (render) threads accessing drawing data */
545 /* lock can become bitflag too */
546 /* should be replaced in future by better local data handling for threads */
548 {
550  LISTBASE_FOREACH (ARegionType *, art, &st->regiontypes) {
551  if (set) {
552  art->do_lock = art->lock;
553  }
554  else {
555  art->do_lock = false;
556  }
557  }
558  }
559 }
560 
566  const ScrArea *area,
567  int region_type)
568 {
569  const bool is_slink_active = slink == area->spacedata.first;
570  const ListBase *regionbase = (is_slink_active) ? &area->regionbase : &slink->regionbase;
571  ARegion *region = NULL;
572 
573  BLI_assert(BLI_findindex(&area->spacedata, slink) != -1);
574 
575  LISTBASE_FOREACH (ARegion *, region_iter, regionbase) {
576  if (region_iter->regiontype == region_type) {
577  region = region_iter;
578  break;
579  }
580  }
581 
582  /* Should really unit test this instead. */
583  BLI_assert(!is_slink_active || region == BKE_area_find_region_type(area, region_type));
584 
585  return region;
586 }
587 
588 static void (*spacedata_id_remap_cb)(struct ScrArea *area,
589  struct SpaceLink *sl,
590  ID *old_id,
591  ID *new_id) = NULL;
592 
594 {
595  spacedata_id_remap_cb = func;
596 }
597 
598 /* UNUSED!!! */
599 void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id)
600 {
601  if (spacedata_id_remap_cb) {
602  spacedata_id_remap_cb(area, sl, id, NULL);
603  }
604 }
605 
610 
612 {
614 }
615 
617 {
619  return;
620  }
621 
622  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
623  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
624  if (region->gizmo_map != NULL) {
625  region_refresh_tag_gizmomap_callback(region->gizmo_map);
626  }
627  }
628  }
629 }
630 
634 static void (*region_free_gizmomap_callback)(struct wmGizmoMap *) = NULL;
635 
637 {
639 }
640 
642 {
643  MEM_SAFE_FREE(panel->activedata);
644 
645  LISTBASE_FOREACH_MUTABLE (Panel *, child_panel, &panel->children) {
647  }
648 
649  MEM_freeN(panel);
650 }
651 
653 {
654  LISTBASE_FOREACH_MUTABLE (Panel *, panel, panels) {
655  /* Free custom data just for parent panels to avoid a double free. */
656  MEM_SAFE_FREE(panel->runtime.custom_data_ptr);
658  }
659  BLI_listbase_clear(panels);
660 }
661 
662 /* not region itself */
664 {
665  if (st) {
666  ARegionType *art = BKE_regiontype_from_id(st, region->regiontype);
667 
668  if (art && art->free) {
669  art->free(region);
670  }
671 
672  if (region->regiondata) {
673  printf("regiondata free error\n");
674  }
675  }
676  else if (region->type && region->type->free) {
677  region->type->free(region);
678  }
679 
681 
682  LISTBASE_FOREACH (uiList *, uilst, &region->ui_lists) {
683  if (uilst->dyn_data) {
684  uiListDyn *dyn_data = uilst->dyn_data;
685  if (dyn_data->items_filter_flags) {
686  MEM_freeN(dyn_data->items_filter_flags);
687  }
688  if (dyn_data->items_filter_neworder) {
689  MEM_freeN(dyn_data->items_filter_neworder);
690  }
691  MEM_freeN(dyn_data);
692  }
693  if (uilst->properties) {
694  IDP_FreeProperty(uilst->properties);
695  }
696  }
697 
698  if (region->gizmo_map != NULL) {
700  }
701 
702  BLI_freelistN(&region->ui_lists);
703  BLI_freelistN(&region->ui_previews);
704  BLI_freelistN(&region->panels_category);
706 }
707 
708 /* not area itself */
710 {
711  SpaceType *st = BKE_spacetype_from_id(area->spacetype);
712 
713  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
714  BKE_area_region_free(st, region);
715  }
716 
717  MEM_SAFE_FREE(area->global);
718  BLI_freelistN(&area->regionbase);
719 
720  BKE_spacedata_freelist(&area->spacedata);
721 
722  BLI_freelistN(&area->actionzones);
723 }
724 
726 {
727  LISTBASE_FOREACH_MUTABLE (ScrArea *, area, &area_map->areabase) {
729  }
730 
731  BLI_freelistN(&area_map->vertbase);
732  BLI_freelistN(&area_map->edgebase);
733  BLI_freelistN(&area_map->areabase);
734 }
735 
738 {
739  screen_free_data(&screen->id);
740 }
741 
742 /* ***************** Screen edges & verts ***************** */
743 
745 {
747  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
748  if (se->v1 == v1 && se->v2 == v2) {
749  return se;
750  }
751  }
752 
753  return NULL;
754 }
755 
757 {
758  if (*v1 > *v2) {
759  ScrVert *tmp = *v1;
760  *v1 = *v2;
761  *v2 = tmp;
762  }
763 }
764 
766 {
767  LISTBASE_FOREACH (ScrVert *, verg, &screen->vertbase) {
768  if (verg->newv == NULL) { /* !!! */
769  ScrVert *v1 = verg->next;
770  while (v1) {
771  if (v1->newv == NULL) { /* !?! */
772  if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) {
773  /* printf("doublevert\n"); */
774  v1->newv = verg;
775  }
776  }
777  v1 = v1->next;
778  }
779  }
780  }
781 
782  /* replace pointers in edges and faces */
783  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
784  if (se->v1->newv) {
785  se->v1 = se->v1->newv;
786  }
787  if (se->v2->newv) {
788  se->v2 = se->v2->newv;
789  }
790  /* edges changed: so.... */
791  BKE_screen_sort_scrvert(&(se->v1), &(se->v2));
792  }
793  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
794  if (area->v1->newv) {
795  area->v1 = area->v1->newv;
796  }
797  if (area->v2->newv) {
798  area->v2 = area->v2->newv;
799  }
800  if (area->v3->newv) {
801  area->v3 = area->v3->newv;
802  }
803  if (area->v4->newv) {
804  area->v4 = area->v4->newv;
805  }
806  }
807 
808  /* remove */
809  LISTBASE_FOREACH_MUTABLE (ScrVert *, verg, &screen->vertbase) {
810  if (verg->newv) {
811  BLI_remlink(&screen->vertbase, verg);
812  MEM_freeN(verg);
813  }
814  }
815 }
816 
818 {
819  /* compare */
820  LISTBASE_FOREACH (ScrEdge *, verg, &screen->edgebase) {
821  ScrEdge *se = verg->next;
822  while (se) {
823  ScrEdge *sn = se->next;
824  if (verg->v1 == se->v1 && verg->v2 == se->v2) {
825  BLI_remlink(&screen->edgebase, se);
826  MEM_freeN(se);
827  }
828  se = sn;
829  }
830  }
831 }
832 
834 {
835  /* sets flags when edge is used in area */
836  int a = 0;
837  LISTBASE_FOREACH_INDEX (ScrArea *, area, &screen->areabase, a) {
838  ScrEdge *se = BKE_screen_find_edge(screen, area->v1, area->v2);
839  if (se == NULL) {
840  printf("error: area %d edge 1 doesn't exist\n", a);
841  }
842  else {
843  se->flag = 1;
844  }
845  se = BKE_screen_find_edge(screen, area->v2, area->v3);
846  if (se == NULL) {
847  printf("error: area %d edge 2 doesn't exist\n", a);
848  }
849  else {
850  se->flag = 1;
851  }
852  se = BKE_screen_find_edge(screen, area->v3, area->v4);
853  if (se == NULL) {
854  printf("error: area %d edge 3 doesn't exist\n", a);
855  }
856  else {
857  se->flag = 1;
858  }
859  se = BKE_screen_find_edge(screen, area->v4, area->v1);
860  if (se == NULL) {
861  printf("error: area %d edge 4 doesn't exist\n", a);
862  }
863  else {
864  se->flag = 1;
865  }
866  }
867  LISTBASE_FOREACH_MUTABLE (ScrEdge *, se, &screen->edgebase) {
868  if (se->flag == 0) {
869  BLI_remlink(&screen->edgebase, se);
870  MEM_freeN(se);
871  }
872  else {
873  se->flag = 0;
874  }
875  }
876 }
877 
879 {
880  /* we assume edges are ok */
881  LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
882  se->v1->flag = 1;
883  se->v2->flag = 1;
884  }
885 
886  LISTBASE_FOREACH_MUTABLE (ScrVert *, sv, &screen->vertbase) {
887  if (sv->flag == 0) {
888  BLI_remlink(&screen->vertbase, sv);
889  MEM_freeN(sv);
890  }
891  else {
892  sv->flag = 0;
893  }
894  }
895 }
896 
897 /* ***************** Utilities ********************** */
898 
906 {
907  if (area) {
908  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
909  if (region->regiontype == region_type) {
910  return region;
911  }
912  }
913  }
914 
915  return NULL;
916 }
917 
919 {
920  if (area == NULL) {
921  return NULL;
922  }
923 
924  ARegion *region = BLI_findlink(&area->regionbase, area->region_active_win);
925  if (region && (region->regiontype == RGN_TYPE_WINDOW)) {
926  return region;
927  }
928 
929  /* fallback to any */
931 }
932 
933 ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int y)
934 {
935  if (area == NULL) {
936  return NULL;
937  }
938 
939  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
940  if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
941  if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
942  return region;
943  }
944  }
945  }
946  return NULL;
947 }
948 
952 ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y)
953 {
954  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
955  if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) {
956  if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
957  return region;
958  }
959  }
960  }
961  return NULL;
962 }
963 
969 {
970  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
971  if (BLI_findindex(&area->spacedata, sl) != -1) {
972  return area;
973  }
974  }
975 
976  return NULL;
977 }
978 
983 ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min)
984 {
985  ScrArea *big = NULL;
986  int maxsize = 0;
987 
988  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
989  if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
990  if (min <= area->winx && min <= area->winy) {
991  int size = area->winx * area->winy;
992  if (size > maxsize) {
993  maxsize = size;
994  big = area;
995  }
996  }
997  }
998  }
999 
1000  return big;
1001 }
1002 
1004  const int spacetype,
1005  int x,
1006  int y)
1007 {
1008  LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) {
1009  if (BLI_rcti_isect_pt(&area->totrct, x, y)) {
1010  if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) {
1011  return area;
1012  }
1013  break;
1014  }
1015  }
1016  return NULL;
1017 }
1018 ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, int x, int y)
1019 {
1020  return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, x, y);
1021 }
1022 
1024 {
1025  if (v3d->scenelock && v3d->localvd == NULL) {
1026  v3d->camera = scene->camera;
1027 
1028  if (v3d->camera == NULL) {
1029  LISTBASE_FOREACH (ARegion *, region, &v3d->regionbase) {
1030  if (region->regiontype == RGN_TYPE_WINDOW) {
1031  RegionView3D *rv3d = region->regiondata;
1032  if (rv3d->persp == RV3D_CAMOB) {
1033  rv3d->persp = RV3D_PERSP;
1034  }
1035  }
1036  }
1037  }
1038  }
1039 }
1040 
1042 {
1043  /* are there cameras in the views that are not in the scene? */
1044  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1045  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1046  if (sl->spacetype == SPACE_VIEW3D) {
1047  View3D *v3d = (View3D *)sl;
1049  }
1050  }
1051  }
1052 }
1053 
1055 {
1056  const View3DShading *shading_default = DNA_struct_default_get(View3DShading);
1057  memcpy(shading, shading_default, sizeof(*shading));
1058 }
1059 
1061  const int space_type,
1062  const int x,
1063  const int y)
1064 {
1065  ScrArea *area = BKE_screen_find_area_xy(screen, space_type, x, y);
1066  if (!area) {
1067  return NULL;
1068  }
1070 }
1071 
1072 /* magic zoom calculation, no idea what
1073  * it signifies, if you find out, tell me! -zr
1074  */
1075 
1076 /* simple, its magic dude!
1077  * well, to be honest, this gives a natural feeling zooming
1078  * with multiple keypad presses (ton)
1079  */
1080 float BKE_screen_view3d_zoom_to_fac(float camzoom)
1081 {
1082  return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f;
1083 }
1084 
1086 {
1087  return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
1088 }
1089 
1091 {
1092  return ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL);
1093 }
1094 
1095 bool BKE_screen_is_used(const bScreen *screen)
1096 {
1097  return (screen->winid != 0);
1098 }
1099 
1101 {
1102  int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
1103  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1104  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1105  if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
1107  region->alignment = RGN_ALIGN_TOP;
1108  continue;
1109  }
1110  region->alignment = alignment;
1111  }
1112  if (region->regiontype == RGN_TYPE_FOOTER) {
1114  region->alignment = RGN_ALIGN_BOTTOM;
1115  continue;
1116  }
1117  region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
1118  }
1119  }
1120  }
1121  screen->do_refresh = true;
1122 }
1123 
1125 {
1126  if (shading->prop) {
1127  IDP_BlendWrite(writer, shading->prop);
1128  }
1129 }
1130 
1132 {
1133  if (shading->prop) {
1134  BLO_read_data_address(reader, &shading->prop);
1135  IDP_BlendDataRead(reader, &shading->prop);
1136  }
1137 }
1138 
1139 static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
1140 {
1141  BLO_write_struct(writer, ARegion, region);
1142 
1143  if (region->regiondata) {
1144  if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
1145  return;
1146  }
1147 
1148  switch (spacetype) {
1149  case SPACE_VIEW3D:
1150  if (region->regiontype == RGN_TYPE_WINDOW) {
1151  RegionView3D *rv3d = region->regiondata;
1152  BLO_write_struct(writer, RegionView3D, rv3d);
1153 
1154  if (rv3d->localvd) {
1155  BLO_write_struct(writer, RegionView3D, rv3d->localvd);
1156  }
1157  if (rv3d->clipbb) {
1158  BLO_write_struct(writer, BoundBox, rv3d->clipbb);
1159  }
1160  }
1161  else {
1162  printf("regiondata write missing!\n");
1163  }
1164  break;
1165  default:
1166  printf("regiondata write missing!\n");
1167  }
1168  }
1169 }
1170 
1171 static void write_uilist(BlendWriter *writer, uiList *ui_list)
1172 {
1173  BLO_write_struct(writer, uiList, ui_list);
1174 
1175  if (ui_list->properties) {
1176  IDP_BlendWrite(writer, ui_list->properties);
1177  }
1178 }
1179 
1180 static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
1181 {
1182  BLI_mempool *ts = space_outliner->treestore;
1183 
1184  if (ts) {
1185  SpaceOutliner space_outliner_flat = *space_outliner;
1186 
1187  int elems = BLI_mempool_len(ts);
1188  /* linearize mempool to array */
1189  TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL;
1190 
1191  if (data) {
1192  /* In this block we use the memory location of the treestore
1193  * but _not_ its data, the addresses in this case are UUID's,
1194  * since we can't rely on malloc giving us different values each time.
1195  */
1196  TreeStore ts_flat = {0};
1197 
1198  /* we know the treestore is at least as big as a pointer,
1199  * so offsetting works to give us a UUID. */
1200  void *data_addr = (void *)POINTER_OFFSET(ts, sizeof(void *));
1201 
1202  ts_flat.usedelem = elems;
1203  ts_flat.totelem = elems;
1204  ts_flat.data = data_addr;
1205 
1206  BLO_write_struct(writer, SpaceOutliner, space_outliner);
1207 
1208  BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat);
1209  BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data);
1210 
1211  MEM_freeN(data);
1212  }
1213  else {
1214  space_outliner_flat.treestore = NULL;
1215  BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat);
1216  }
1217  }
1218  else {
1219  BLO_write_struct(writer, SpaceOutliner, space_outliner);
1220  }
1221 }
1222 
1223 static void write_panel_list(BlendWriter *writer, ListBase *lb)
1224 {
1225  LISTBASE_FOREACH (Panel *, panel, lb) {
1226  BLO_write_struct(writer, Panel, panel);
1227  write_panel_list(writer, &panel->children);
1228  }
1229 }
1230 
1231 static void write_area(BlendWriter *writer, ScrArea *area)
1232 {
1233  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1234  write_region(writer, region, area->spacetype);
1235  write_panel_list(writer, &region->panels);
1236 
1237  LISTBASE_FOREACH (PanelCategoryStack *, pc_act, &region->panels_category_active) {
1238  BLO_write_struct(writer, PanelCategoryStack, pc_act);
1239  }
1240 
1241  LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
1242  write_uilist(writer, ui_list);
1243  }
1244 
1245  LISTBASE_FOREACH (uiPreview *, ui_preview, &region->ui_previews) {
1246  BLO_write_struct(writer, uiPreview, ui_preview);
1247  }
1248  }
1249 
1250  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1251  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
1252  write_region(writer, region, sl->spacetype);
1253  }
1254 
1255  if (sl->spacetype == SPACE_VIEW3D) {
1256  View3D *v3d = (View3D *)sl;
1257  BLO_write_struct(writer, View3D, v3d);
1258 
1259  if (v3d->localvd) {
1260  BLO_write_struct(writer, View3D, v3d->localvd);
1261  }
1262 
1264  }
1265  else if (sl->spacetype == SPACE_GRAPH) {
1266  SpaceGraph *sipo = (SpaceGraph *)sl;
1267  ListBase tmpGhosts = sipo->runtime.ghost_curves;
1268 
1269  /* temporarily disable ghost curves when saving */
1271 
1272  BLO_write_struct(writer, SpaceGraph, sl);
1273  if (sipo->ads) {
1274  BLO_write_struct(writer, bDopeSheet, sipo->ads);
1275  }
1276 
1277  /* reenable ghost curves */
1278  sipo->runtime.ghost_curves = tmpGhosts;
1279  }
1280  else if (sl->spacetype == SPACE_PROPERTIES) {
1281  BLO_write_struct(writer, SpaceProperties, sl);
1282  }
1283  else if (sl->spacetype == SPACE_FILE) {
1284  SpaceFile *sfile = (SpaceFile *)sl;
1285 
1286  BLO_write_struct(writer, SpaceFile, sl);
1287  if (sfile->params) {
1288  BLO_write_struct(writer, FileSelectParams, sfile->params);
1289  }
1290  if (sfile->asset_params) {
1292  }
1293  }
1294  else if (sl->spacetype == SPACE_SEQ) {
1295  BLO_write_struct(writer, SpaceSeq, sl);
1296  }
1297  else if (sl->spacetype == SPACE_OUTLINER) {
1298  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1299  write_space_outliner(writer, space_outliner);
1300  }
1301  else if (sl->spacetype == SPACE_IMAGE) {
1302  BLO_write_struct(writer, SpaceImage, sl);
1303  }
1304  else if (sl->spacetype == SPACE_TEXT) {
1305  BLO_write_struct(writer, SpaceText, sl);
1306  }
1307  else if (sl->spacetype == SPACE_SCRIPT) {
1308  SpaceScript *scr = (SpaceScript *)sl;
1309  scr->but_refs = NULL;
1310  BLO_write_struct(writer, SpaceScript, sl);
1311  }
1312  else if (sl->spacetype == SPACE_ACTION) {
1313  BLO_write_struct(writer, SpaceAction, sl);
1314  }
1315  else if (sl->spacetype == SPACE_NLA) {
1316  SpaceNla *snla = (SpaceNla *)sl;
1317 
1318  BLO_write_struct(writer, SpaceNla, snla);
1319  if (snla->ads) {
1320  BLO_write_struct(writer, bDopeSheet, snla->ads);
1321  }
1322  }
1323  else if (sl->spacetype == SPACE_NODE) {
1324  SpaceNode *snode = (SpaceNode *)sl;
1325  BLO_write_struct(writer, SpaceNode, snode);
1326 
1327  LISTBASE_FOREACH (bNodeTreePath *, path, &snode->treepath) {
1328  BLO_write_struct(writer, bNodeTreePath, path);
1329  }
1330  }
1331  else if (sl->spacetype == SPACE_CONSOLE) {
1332  SpaceConsole *con = (SpaceConsole *)sl;
1333 
1334  LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
1335  /* 'len_alloc' is invalid on write, set from 'len' on read */
1336  BLO_write_struct(writer, ConsoleLine, cl);
1337  BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
1338  }
1339  BLO_write_struct(writer, SpaceConsole, sl);
1340  }
1341  else if (sl->spacetype == SPACE_TOPBAR) {
1342  BLO_write_struct(writer, SpaceTopBar, sl);
1343  }
1344  else if (sl->spacetype == SPACE_STATUSBAR) {
1345  BLO_write_struct(writer, SpaceStatusBar, sl);
1346  }
1347  else if (sl->spacetype == SPACE_USERPREF) {
1348  BLO_write_struct(writer, SpaceUserPref, sl);
1349  }
1350  else if (sl->spacetype == SPACE_CLIP) {
1351  BLO_write_struct(writer, SpaceClip, sl);
1352  }
1353  else if (sl->spacetype == SPACE_INFO) {
1354  BLO_write_struct(writer, SpaceInfo, sl);
1355  }
1356  else if (sl->spacetype == SPACE_SPREADSHEET) {
1357  BLO_write_struct(writer, SpaceSpreadsheet, sl);
1358 
1359  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1360  LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
1361  BLO_write_struct(writer, SpreadsheetColumn, column);
1362  BLO_write_struct(writer, SpreadsheetColumnID, column->id);
1363  BLO_write_string(writer, column->id->name);
1364  }
1366  switch (context->type) {
1369  BLO_write_struct(writer, SpreadsheetContextObject, object_context);
1370  break;
1371  }
1374  BLO_write_struct(writer, SpreadsheetContextModifier, modifier_context);
1375  BLO_write_string(writer, modifier_context->modifier_name);
1376  break;
1377  }
1378  case SPREADSHEET_CONTEXT_NODE: {
1381  BLO_write_string(writer, node_context->node_name);
1382  break;
1383  }
1384  }
1385  }
1386  }
1387  }
1388 }
1389 
1391 {
1392  BLO_write_struct_list(writer, ScrVert, &area_map->vertbase);
1393  BLO_write_struct_list(writer, ScrEdge, &area_map->edgebase);
1394  LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
1395  area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
1396 
1397  BLO_write_struct(writer, ScrArea, area);
1398 
1399  BLO_write_struct(writer, ScrGlobalAreaData, area->global);
1400 
1401  write_area(writer, area);
1402 
1403  area->butspacetype = SPACE_EMPTY; /* Unset again, was changed above. */
1404  }
1405 }
1406 
1408 {
1409  BLO_read_list(reader, lb);
1410 
1411  LISTBASE_FOREACH (Panel *, panel, lb) {
1412  panel->runtime_flag = 0;
1413  panel->activedata = NULL;
1414  panel->type = NULL;
1415  panel->runtime.custom_data_ptr = NULL;
1416  direct_link_panel_list(reader, &panel->children);
1417  }
1418 }
1419 
1420 static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
1421 {
1422  direct_link_panel_list(reader, &region->panels);
1423 
1424  BLO_read_list(reader, &region->panels_category_active);
1425 
1426  BLO_read_list(reader, &region->ui_lists);
1427 
1428  /* The area's search filter is runtime only, so we need to clear the active flag on read. */
1429  region->flag &= ~RGN_FLAG_SEARCH_FILTER_ACTIVE;
1430 
1431  LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
1432  ui_list->type = NULL;
1433  ui_list->dyn_data = NULL;
1434  BLO_read_data_address(reader, &ui_list->properties);
1435  IDP_BlendDataRead(reader, &ui_list->properties);
1436  }
1437 
1438  BLO_read_list(reader, &region->ui_previews);
1439 
1440  if (spacetype == SPACE_EMPTY) {
1441  /* unknown space type, don't leak regiondata */
1442  region->regiondata = NULL;
1443  }
1444  else if (region->flag & RGN_FLAG_TEMP_REGIONDATA) {
1445  /* Runtime data, don't use. */
1446  region->regiondata = NULL;
1447  }
1448  else {
1449  BLO_read_data_address(reader, &region->regiondata);
1450  if (region->regiondata) {
1451  if (spacetype == SPACE_VIEW3D) {
1452  RegionView3D *rv3d = region->regiondata;
1453 
1454  BLO_read_data_address(reader, &rv3d->localvd);
1455  BLO_read_data_address(reader, &rv3d->clipbb);
1456 
1457  rv3d->depths = NULL;
1458  rv3d->render_engine = NULL;
1459  rv3d->sms = NULL;
1460  rv3d->smooth_timer = NULL;
1461 
1462  rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
1463  rv3d->runtime_viewlock = 0;
1464  }
1465  }
1466  }
1467 
1468  region->v2d.sms = NULL;
1469  region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */
1471  BLI_listbase_clear(&region->handlers);
1472  BLI_listbase_clear(&region->uiblocks);
1473  region->headerstr = NULL;
1474  region->visible = 0;
1475  region->type = NULL;
1476  region->do_draw = 0;
1477  region->gizmo_map = NULL;
1478  region->regiontimer = NULL;
1479  region->draw_buffer = NULL;
1480  memset(&region->drawrct, 0, sizeof(region->drawrct));
1481 }
1482 
1483 /* for the saved 2.50 files without regiondata */
1484 /* and as patch for 2.48 and older */
1486 {
1487  LISTBASE_FOREACH (ARegion *, region, regions) {
1488  if (region->regiontype == RGN_TYPE_WINDOW && region->regiondata == NULL) {
1489  RegionView3D *rv3d;
1490 
1491  rv3d = region->regiondata = MEM_callocN(sizeof(RegionView3D), "region v3d patch");
1492  rv3d->persp = (char)v3d->persp;
1493  rv3d->view = (char)v3d->view;
1494  rv3d->dist = v3d->dist;
1495  copy_v3_v3(rv3d->ofs, v3d->ofs);
1496  copy_qt_qt(rv3d->viewquat, v3d->viewquat);
1497  }
1498  }
1499 
1500  /* this was not initialized correct always */
1501  if (v3d->gridsubdiv == 0) {
1502  v3d->gridsubdiv = 10;
1503  }
1504 }
1505 
1507 {
1508  BLO_read_list(reader, &(area->spacedata));
1509  BLO_read_list(reader, &(area->regionbase));
1510 
1511  BLI_listbase_clear(&area->handlers);
1512  area->type = NULL; /* spacetype callbacks */
1513 
1514  /* Should always be unset so that rna_Area_type_get works correctly. */
1515  area->butspacetype = SPACE_EMPTY;
1516 
1517  area->region_active_win = -1;
1518 
1520 
1521  BLO_read_data_address(reader, &area->global);
1522 
1523  /* if we do not have the spacetype registered we cannot
1524  * free it, so don't allocate any new memory for such spacetypes. */
1525  if (!BKE_spacetype_exists(area->spacetype)) {
1526  /* Hint for versioning code to replace deprecated space types. */
1527  area->butspacetype = area->spacetype;
1528 
1529  area->spacetype = SPACE_EMPTY;
1530  }
1531 
1532  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1533  direct_link_region(reader, region, area->spacetype);
1534  }
1535 
1536  /* accident can happen when read/save new file with older version */
1537  /* 2.50: we now always add spacedata for info */
1538  if (area->spacedata.first == NULL) {
1539  SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
1540  area->spacetype = sinfo->spacetype = SPACE_INFO;
1541  BLI_addtail(&area->spacedata, sinfo);
1542  }
1543  /* add local view3d too */
1544  else if (area->spacetype == SPACE_VIEW3D) {
1545  BKE_screen_view3d_do_versions_250(area->spacedata.first, &area->regionbase);
1546  }
1547 
1548  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1549  BLO_read_list(reader, &(sl->regionbase));
1550 
1551  /* if we do not have the spacetype registered we cannot
1552  * free it, so don't allocate any new memory for such spacetypes. */
1553  if (!BKE_spacetype_exists(sl->spacetype)) {
1554  sl->spacetype = SPACE_EMPTY;
1555  }
1556 
1557  LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
1558  direct_link_region(reader, region, sl->spacetype);
1559  }
1560 
1561  if (sl->spacetype == SPACE_VIEW3D) {
1562  View3D *v3d = (View3D *)sl;
1563  if (v3d->gpd) {
1564  BLO_read_data_address(reader, &v3d->gpd);
1565  BKE_gpencil_blend_read_data(reader, v3d->gpd);
1566  }
1567  BLO_read_data_address(reader, &v3d->localvd);
1568 
1569  /* Runtime data */
1571  v3d->runtime.flag = 0;
1572 
1573  /* render can be quite heavy, set to solid on load */
1574  if (v3d->shading.type == OB_RENDER) {
1575  v3d->shading.type = OB_SOLID;
1576  }
1577  v3d->shading.prev_type = OB_SOLID;
1578 
1580 
1582  }
1583  else if (sl->spacetype == SPACE_GRAPH) {
1584  SpaceGraph *sipo = (SpaceGraph *)sl;
1585 
1586  BLO_read_data_address(reader, &sipo->ads);
1588  }
1589  else if (sl->spacetype == SPACE_NLA) {
1590  SpaceNla *snla = (SpaceNla *)sl;
1591 
1592  BLO_read_data_address(reader, &snla->ads);
1593  }
1594  else if (sl->spacetype == SPACE_OUTLINER) {
1595  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1596 
1597  /* use #BLO_read_get_new_data_address_no_us and do not free old memory avoiding double
1598  * frees and use of freed memory. this could happen because of a
1599  * bug fixed in revision 58959 where the treestore memory address
1600  * was not unique */
1601  TreeStore *ts = BLO_read_get_new_data_address_no_us(reader, space_outliner->treestore);
1602  space_outliner->treestore = NULL;
1603  if (ts) {
1605 
1606  space_outliner->treestore = BLI_mempool_create(
1607  sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER);
1608  if (ts->usedelem && elems) {
1609  for (int i = 0; i < ts->usedelem; i++) {
1610  TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore);
1611  *new_elem = elems[i];
1612  }
1613  }
1614  /* we only saved what was used */
1615  space_outliner->storeflag |= SO_TREESTORE_CLEANUP; /* at first draw */
1616  }
1617  space_outliner->tree.first = space_outliner->tree.last = NULL;
1618  space_outliner->runtime = NULL;
1619  }
1620  else if (sl->spacetype == SPACE_IMAGE) {
1621  SpaceImage *sima = (SpaceImage *)sl;
1622 
1623  sima->iuser.scene = NULL;
1624  sima->iuser.ok = 1;
1625  sima->scopes.waveform_1 = NULL;
1626  sima->scopes.waveform_2 = NULL;
1627  sima->scopes.waveform_3 = NULL;
1628  sima->scopes.vecscope = NULL;
1629  sima->scopes.ok = 0;
1630 
1631  /* WARNING: gpencil data is no longer stored directly in sima after 2.5
1632  * so sacrifice a few old files for now to avoid crashes with new files!
1633  * committed: r28002 */
1634 #if 0
1635  sima->gpd = newdataadr(fd, sima->gpd);
1636  if (sima->gpd) {
1637  BKE_gpencil_blend_read_data(fd, sima->gpd);
1638  }
1639 #endif
1640  }
1641  else if (sl->spacetype == SPACE_NODE) {
1642  SpaceNode *snode = (SpaceNode *)sl;
1643 
1644  if (snode->gpd) {
1645  BLO_read_data_address(reader, &snode->gpd);
1646  BKE_gpencil_blend_read_data(reader, snode->gpd);
1647  }
1648 
1649  BLO_read_list(reader, &snode->treepath);
1650  snode->edittree = NULL;
1651  snode->runtime = NULL;
1652  }
1653  else if (sl->spacetype == SPACE_TEXT) {
1654  SpaceText *st = (SpaceText *)sl;
1655  memset(&st->runtime, 0, sizeof(st->runtime));
1656  }
1657  else if (sl->spacetype == SPACE_SEQ) {
1658  SpaceSeq *sseq = (SpaceSeq *)sl;
1659 
1660  /* grease pencil data is not a direct data and can't be linked from direct_link*
1661  * functions, it should be linked from lib_link* functions instead
1662  *
1663  * otherwise it'll lead to lost grease data on open because it'll likely be
1664  * read from file after all other users of grease pencil and newdataadr would
1665  * simple return NULL here (sergey)
1666  */
1667 #if 0
1668  if (sseq->gpd) {
1669  sseq->gpd = newdataadr(fd, sseq->gpd);
1670  BKE_gpencil_blend_read_data(fd, sseq->gpd);
1671  }
1672 #endif
1673  sseq->scopes.reference_ibuf = NULL;
1674  sseq->scopes.zebra_ibuf = NULL;
1675  sseq->scopes.waveform_ibuf = NULL;
1676  sseq->scopes.sep_waveform_ibuf = NULL;
1677  sseq->scopes.vector_ibuf = NULL;
1678  sseq->scopes.histogram_ibuf = NULL;
1679  }
1680  else if (sl->spacetype == SPACE_PROPERTIES) {
1681  SpaceProperties *sbuts = (SpaceProperties *)sl;
1682 
1683  sbuts->path = NULL;
1684  sbuts->texuser = NULL;
1685  sbuts->mainbo = sbuts->mainb;
1686  sbuts->mainbuser = sbuts->mainb;
1687  sbuts->runtime = NULL;
1688  }
1689  else if (sl->spacetype == SPACE_CONSOLE) {
1690  SpaceConsole *sconsole = (SpaceConsole *)sl;
1691 
1692  BLO_read_list(reader, &sconsole->scrollback);
1693  BLO_read_list(reader, &sconsole->history);
1694 
1695  /* comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
1696  * from left to right. the right-most expression sets the result of the comma
1697  * expression as a whole*/
1698  LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
1699  BLO_read_data_address(reader, &cl->line);
1700  if (cl->line) {
1701  /* the allocted length is not written, so reset here */
1702  cl->len_alloc = cl->len + 1;
1703  }
1704  else {
1705  BLI_remlink(&sconsole->history, cl);
1706  MEM_freeN(cl);
1707  }
1708  }
1709  }
1710  else if (sl->spacetype == SPACE_FILE) {
1711  SpaceFile *sfile = (SpaceFile *)sl;
1712 
1713  /* this sort of info is probably irrelevant for reloading...
1714  * plus, it isn't saved to files yet!
1715  */
1716  sfile->folders_prev = sfile->folders_next = NULL;
1718  sfile->files = NULL;
1719  sfile->layout = NULL;
1720  sfile->op = NULL;
1721  sfile->previews_timer = NULL;
1722  sfile->tags = 0;
1723  sfile->runtime = NULL;
1724  BLO_read_data_address(reader, &sfile->params);
1725  BLO_read_data_address(reader, &sfile->asset_params);
1726  }
1727  else if (sl->spacetype == SPACE_CLIP) {
1728  SpaceClip *sclip = (SpaceClip *)sl;
1729 
1730  sclip->scopes.track_search = NULL;
1731  sclip->scopes.track_preview = NULL;
1732  sclip->scopes.ok = 0;
1733  }
1734  else if (sl->spacetype == SPACE_SPREADSHEET) {
1735  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1736 
1737  sspreadsheet->runtime = NULL;
1738 
1739  BLO_read_list(reader, &sspreadsheet->columns);
1740  LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
1741  BLO_read_data_address(reader, &column->id);
1742  BLO_read_data_address(reader, &column->id->name);
1743  }
1744 
1745  BLO_read_list(reader, &sspreadsheet->context_path);
1747  switch (context->type) {
1748  case SPREADSHEET_CONTEXT_NODE: {
1750  BLO_read_data_address(reader, &node_context->node_name);
1751  break;
1752  }
1755  BLO_read_data_address(reader, &modifier_context->modifier_name);
1756  break;
1757  }
1759  break;
1760  }
1761  }
1762  }
1763  }
1764  }
1765 
1766  BLI_listbase_clear(&area->actionzones);
1767 
1768  BLO_read_data_address(reader, &area->v1);
1769  BLO_read_data_address(reader, &area->v2);
1770  BLO_read_data_address(reader, &area->v3);
1771  BLO_read_data_address(reader, &area->v4);
1772 }
1773 
1778 {
1779  BLO_read_list(reader, &area_map->vertbase);
1780  BLO_read_list(reader, &area_map->edgebase);
1781  BLO_read_list(reader, &area_map->areabase);
1782  LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
1783  direct_link_area(reader, area);
1784  }
1785 
1786  /* edges */
1787  LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
1788  BLO_read_data_address(reader, &se->v1);
1789  BLO_read_data_address(reader, &se->v2);
1790  BKE_screen_sort_scrvert(&se->v1, &se->v2);
1791 
1792  if (se->v1 == NULL) {
1793  BLI_remlink(&area_map->edgebase, se);
1794 
1795  return false;
1796  }
1797  }
1798 
1799  return true;
1800 }
1801 
1803 {
1804  BLO_read_id_address(reader, parent_id->lib, &area->full);
1805 
1806  memset(&area->runtime, 0x0, sizeof(area->runtime));
1807 
1808  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1809  switch (sl->spacetype) {
1810  case SPACE_VIEW3D: {
1811  View3D *v3d = (View3D *)sl;
1812 
1813  BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
1814  BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
1815 
1816  if (v3d->localvd) {
1817  BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
1818  }
1819  break;
1820  }
1821  case SPACE_GRAPH: {
1822  SpaceGraph *sipo = (SpaceGraph *)sl;
1823  bDopeSheet *ads = sipo->ads;
1824 
1825  if (ads) {
1826  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1827  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1828  }
1829  break;
1830  }
1831  case SPACE_PROPERTIES: {
1832  SpaceProperties *sbuts = (SpaceProperties *)sl;
1833  BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
1834  if (sbuts->pinid == NULL) {
1835  sbuts->flag &= ~SB_PIN_CONTEXT;
1836  }
1837  break;
1838  }
1839  case SPACE_FILE: {
1840  SpaceFile *sfile = (SpaceFile *)sl;
1842  break;
1843  }
1844  case SPACE_ACTION: {
1845  SpaceAction *saction = (SpaceAction *)sl;
1846  bDopeSheet *ads = &saction->ads;
1847 
1848  if (ads) {
1849  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1850  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1851  }
1852 
1853  BLO_read_id_address(reader, parent_id->lib, &saction->action);
1854  break;
1855  }
1856  case SPACE_IMAGE: {
1857  SpaceImage *sima = (SpaceImage *)sl;
1858 
1859  BLO_read_id_address(reader, parent_id->lib, &sima->image);
1860  BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
1861 
1862  /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
1863  * so fingers crossed this works fine!
1864  */
1865  BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
1866  break;
1867  }
1868  case SPACE_SEQ: {
1869  SpaceSeq *sseq = (SpaceSeq *)sl;
1870 
1871  /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
1872  * so fingers crossed this works fine!
1873  */
1874  BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
1875  break;
1876  }
1877  case SPACE_NLA: {
1878  SpaceNla *snla = (SpaceNla *)sl;
1879  bDopeSheet *ads = snla->ads;
1880 
1881  if (ads) {
1882  BLO_read_id_address(reader, parent_id->lib, &ads->source);
1883  BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
1884  }
1885  break;
1886  }
1887  case SPACE_TEXT: {
1888  SpaceText *st = (SpaceText *)sl;
1889 
1890  BLO_read_id_address(reader, parent_id->lib, &st->text);
1891  break;
1892  }
1893  case SPACE_SCRIPT: {
1894  SpaceScript *scpt = (SpaceScript *)sl;
1895  /*scpt->script = NULL; - 2.45 set to null, better re-run the script */
1896  if (scpt->script) {
1897  BLO_read_id_address(reader, parent_id->lib, &scpt->script);
1898  if (scpt->script) {
1899  SCRIPT_SET_NULL(scpt->script);
1900  }
1901  }
1902  break;
1903  }
1904  case SPACE_OUTLINER: {
1905  SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
1906  BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id);
1907 
1908  if (space_outliner->treestore) {
1909  TreeStoreElem *tselem;
1910  BLI_mempool_iter iter;
1911 
1912  BLI_mempool_iternew(space_outliner->treestore, &iter);
1913  while ((tselem = BLI_mempool_iterstep(&iter))) {
1914  BLO_read_id_address(reader, NULL, &tselem->id);
1915  }
1916  /* rebuild hash table, because it depends on ids too */
1917  space_outliner->storeflag |= SO_TREESTORE_REBUILD;
1918  }
1919  break;
1920  }
1921  case SPACE_NODE: {
1922  SpaceNode *snode = (SpaceNode *)sl;
1923 
1924  /* node tree can be stored locally in id too, link this first */
1925  BLO_read_id_address(reader, parent_id->lib, &snode->id);
1926  BLO_read_id_address(reader, parent_id->lib, &snode->from);
1927 
1928  bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
1929  if (ntree) {
1930  snode->nodetree = ntree;
1931  }
1932  else {
1933  BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
1934  }
1935 
1936  bNodeTreePath *path;
1937  for (path = snode->treepath.first; path; path = path->next) {
1938  if (path == snode->treepath.first) {
1939  /* first nodetree in path is same as snode->nodetree */
1940  path->nodetree = snode->nodetree;
1941  }
1942  else {
1943  BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
1944  }
1945 
1946  if (!path->nodetree) {
1947  break;
1948  }
1949  }
1950 
1951  /* remaining path entries are invalid, remove */
1952  bNodeTreePath *path_next;
1953  for (; path; path = path_next) {
1954  path_next = path->next;
1955 
1956  BLI_remlink(&snode->treepath, path);
1957  MEM_freeN(path);
1958  }
1959 
1960  /* edittree is just the last in the path,
1961  * set this directly since the path may have been shortened above */
1962  if (snode->treepath.last) {
1963  path = snode->treepath.last;
1964  snode->edittree = path->nodetree;
1965  }
1966  else {
1967  snode->edittree = NULL;
1968  }
1969  break;
1970  }
1971  case SPACE_CLIP: {
1972  SpaceClip *sclip = (SpaceClip *)sl;
1973  BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
1974  BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
1975  break;
1976  }
1977  case SPACE_SPREADSHEET: {
1978  SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
1980  if (context->type == SPREADSHEET_CONTEXT_OBJECT) {
1982  reader, parent_id->lib, &((SpreadsheetContextObject *)context)->object);
1983  }
1984  }
1985  break;
1986  }
1987  default:
1988  break;
1989  }
1990  }
1991 }
void BKE_gpencil_blend_read_data(struct BlendDataReader *reader, struct bGPdata *gpd)
Definition: gpencil.c:196
void BKE_previewimg_free(struct PreviewImage **prv)
Definition: icons.cc:295
void BKE_previewimg_blend_read(struct BlendDataReader *reader, struct PreviewImage *prv)
Definition: icons.cc:651
void BKE_previewimg_blend_write(struct BlendWriter *writer, const struct PreviewImage *prv)
void IDP_BlendWrite(struct BlendWriter *writer, const struct IDProperty *prop)
#define IDP_BlendDataRead(reader, prop)
Definition: BKE_idprop.h:208
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1040
@ IDTYPE_FLAGS_NO_MAKELOCAL
Definition: BKE_idtype.h:49
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition: BKE_idtype.h:51
@ IDTYPE_FLAGS_NO_COPY
Definition: BKE_idtype.h:45
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2395
@ IDWALK_INCLUDE_UI
#define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag)
int BKE_lib_query_foreachid_process_flags_get(struct LibraryForeachIDData *data)
Definition: lib_query.c:123
@ IDWALK_CB_USER_ONE
Definition: BKE_lib_query.h:93
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:87
@ IDWALK_CB_EMBEDDED
Definition: BKE_lib_query.h:62
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:47
#define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag)
struct bNodeTree * ntreeFromID(struct ID *id)
Definition: node.cc:3147
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
#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
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
Definition: BLI_listbase.h:180
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
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
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define M_SQRT2
Definition: BLI_math_base.h:47
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:52
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
Definition: BLI_mempool.c:537
@ BLI_MEMPOOL_ALLOW_ITER
Definition: BLI_mempool.h:85
void * BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_mempool.c:645
void void void void * BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int totelem, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_mempool.c:268
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: BLI_mempool.c:334
int BLI_mempool_len(BLI_mempool *pool) ATTR_NONNULL(1)
Definition: BLI_mempool.c:454
bool BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y)
#define ELEM(...)
#define POINTER_OFFSET(v, ofs)
Compatibility-like things for windows.
#define BLO_read_data_address(reader, ptr_p)
void * BLO_read_get_new_data_address_no_us(BlendDataReader *reader, const void *old_address)
Definition: readfile.c:5605
#define BLO_write_struct_array_at_address(writer, struct_name, array_size, address, data_ptr)
#define BLO_write_struct_at_address_with_filecode(writer, filecode, struct_name, address, data_ptr)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_list(BlendDataReader *reader, struct ListBase *list)
Definition: readfile.c:5654
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
Definition: writefile.c:1401
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_write_struct_list(writer, struct_name, list_ptr)
void BLO_write_raw(BlendWriter *writer, size_t size_in_bytes, const void *data_ptr)
Definition: writefile.c:1286
bool BLO_write_is_undo(BlendWriter *writer)
Definition: writefile.c:1412
#define BLO_write_struct_at_address(writer, struct_name, address, data_ptr)
#define BLT_I18NCONTEXT_ID_SCREEN
void BPY_callback_screen_free(struct ARegionType *art)
@ INDEX_ID_SCR
Definition: DNA_ID.h:853
@ ID_SCR
Definition: DNA_ID_enums.h:72
#define ID_SCRN
Definition: DNA_ID_enums.h:103
Object groups, one object can be in many groups at once.
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:44
@ OB_SOLID
@ OB_RENDER
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_TOP
#define AREAMAP_FROM_SCREEN(screen)
@ SCREENFULL
@ SCREENMAXIMIZED
@ AREA_FLAG_ACTIVE_TOOL_UPDATE
struct bScreen bScreen
#define RGN_TYPE_ANY
@ RGN_FLAG_TEMP_REGIONDATA
@ RGN_FLAG_SEARCH_FILTER_ACTIVE
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_WINDOW
@ RGN_TYPE_FOOTER
@ RGN_TYPE_HEADER
@ SPREADSHEET_CONTEXT_OBJECT
@ SPREADSHEET_CONTEXT_MODIFIER
@ SPREADSHEET_CONTEXT_NODE
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_CONSOLE
@ SPACE_OUTLINER
@ SPACE_STATUSBAR
@ SPACE_TOPBAR
@ SPACE_NODE
@ SPACE_SPREADSHEET
@ SPACE_USERPREF
@ SPACE_FILE
@ SPACE_PROPERTIES
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_SCRIPT
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SPACE_INFO
#define SCRIPT_SET_NULL(_script)
@ FILE_TAG_REBUILD_MAIN_FILES
@ SB_PIN_CONTEXT
@ SO_TREESTORE_CLEANUP
@ SO_TREESTORE_REBUILD
#define SPACE_TYPE_ANY
@ USER_HEADER_BOTTOM
#define RV3D_CAMOB
#define RV3D_PAINTING
#define RV3D_PERSP
#define RV3D_NAVIGATING
_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 y
_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 GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static void init_data(ModifierData *md)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
Scene scene
DEGForeachIDComponentCallback callback
bNodeTree * ntree
#define powf(x, y)
#define sqrtf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
static void * newdataadr(FileData *fd, const void *adr)
Definition: readfile.c:1806
void BKE_spacetype_register(SpaceType *st)
Definition: screen.c:420
ScrArea * BKE_screen_find_area_from_space(struct bScreen *screen, SpaceLink *sl)
Definition: screen.c:968
ScrArea * BKE_screen_find_area_xy(bScreen *screen, const int spacetype, int x, int y)
Definition: screen.c:1018
static void area_region_panels_free_recursive(Panel *panel)
Definition: screen.c:641
void BKE_screen_remove_unused_scrverts(bScreen *screen)
Definition: screen.c:878
void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading)
Definition: screen.c:1131
void BKE_spacedata_id_unref(struct ScrArea *area, struct SpaceLink *sl, struct ID *id)
Definition: screen.c:599
static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner)
Definition: screen.c:1180
bool BKE_screen_is_used(const bScreen *screen)
Definition: screen.c:1095
void BKE_region_callback_refresh_tag_gizmomap_set(void(*callback)(struct wmGizmoMap *))
Definition: screen.c:611
void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
Definition: screen.c:1023
void BKE_screen_area_map_blend_write(BlendWriter *writer, ScrAreaMap *area_map)
Definition: screen.c:1390
ARegionType * BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid)
Definition: screen.c:392
void BKE_spacedata_draw_locks(bool set)
Definition: screen.c:547
void BKE_screen_remove_unused_scredges(bScreen *screen)
Definition: screen.c:833
static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: screen.c:255
ScrEdge * BKE_screen_find_edge(const bScreen *screen, ScrVert *v1, ScrVert *v2)
Definition: screen.c:744
static void screen_foreach_id_dopesheet(LibraryForeachIDData *data, bDopeSheet *ads)
Definition: screen.c:92
static void spacetype_free(SpaceType *st)
Definition: screen.c:344
float BKE_screen_view3d_zoom_from_fac(float zoomfac)
Definition: screen.c:1085
void BKE_spacedata_callback_id_remap_set(void(*func)(ScrArea *area, SpaceLink *sl, ID *, ID *))
Definition: screen.c:593
static ListBase spacetypes
Definition: screen.c:341
void BKE_screen_remove_double_scrverts(bScreen *screen)
Definition: screen.c:765
bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
Definition: screen.c:273
void BKE_spacetypes_free(void)
Definition: screen.c:373
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
Definition: screen.c:527
ARegion * BKE_spacedata_find_region_type(const SpaceLink *slink, const ScrArea *area, int region_type)
Definition: screen.c:565
void BKE_spacedata_freelist(ListBase *lb)
Definition: screen.c:440
ARegionType * BKE_regiontype_from_id(const SpaceType *st, int regionid)
Definition: screen.c:405
static void write_area(BlendWriter *writer, ScrArea *area)
Definition: screen.c:1231
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition: screen.c:382
void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading)
Definition: screen.c:1124
static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: screen.c:294
void BKE_screen_sort_scrvert(ScrVert **v1, ScrVert **v2)
Definition: screen.c:756
static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
Definition: screen.c:1407
void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrArea *area)
Definition: screen.c:1802
static void write_region(BlendWriter *writer, ARegion *region, int spacetype)
Definition: screen.c:1139
void BKE_screen_area_free(ScrArea *area)
Definition: screen.c:709
static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
Definition: screen.c:515
bool BKE_spacetype_exists(int spaceid)
Definition: screen.c:433
void BKE_screen_gizmo_tag_refresh(struct bScreen *screen)
Definition: screen.c:616
static void write_panel_list(BlendWriter *writer, ListBase *lb)
Definition: screen.c:1223
void BKE_screen_header_alignment_reset(bScreen *screen)
Definition: screen.c:1100
const ListBase * BKE_spacetypes_list(void)
Definition: screen.c:415
void BKE_screen_area_map_free(ScrAreaMap *area_map)
Definition: screen.c:725
void BKE_area_region_free(SpaceType *st, ARegion *region)
Definition: screen.c:663
void BKE_screen_free(bScreen *screen)
Definition: screen.c:737
void BKE_region_callback_free_gizmomap_set(void(*callback)(struct wmGizmoMap *))
Definition: screen.c:636
ARegion * BKE_area_find_region_active_win(ScrArea *area)
Definition: screen.c:918
ARegion * BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int y)
Definition: screen.c:933
bool BKE_screen_is_fullscreen_area(const bScreen *screen)
Definition: screen.c:1090
bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *area_map)
Definition: screen.c:1777
static void(* region_free_gizmomap_callback)(struct wmGizmoMap *)
Definition: screen.c:634
void BKE_screen_view3d_scene_sync(bScreen *screen, Scene *scene)
Definition: screen.c:1041
ARegion * BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y)
Definition: screen.c:952
static void(* region_refresh_tag_gizmomap_callback)(struct wmGizmoMap *)
Definition: screen.c:609
void BKE_screen_remove_double_scredges(bScreen *screen)
Definition: screen.c:817
float BKE_screen_view3d_zoom_to_fac(float camzoom)
Definition: screen.c:1080
ScrArea * BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min)
Definition: screen.c:983
IDTypeInfo IDType_ID_SCR
Definition: screen.c:309
void BKE_screen_view3d_shading_init(View3DShading *shading)
Definition: screen.c:1054
ARegion * BKE_screen_find_main_region_at_xy(bScreen *screen, const int space_type, const int x, const int y)
Definition: screen.c:1060
static void(* spacedata_id_remap_cb)(struct ScrArea *area, struct SpaceLink *sl, ID *old_id, ID *new_id)
Definition: screen.c:588
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition: screen.c:905
static void direct_link_area(BlendDataReader *reader, ScrArea *area)
Definition: screen.c:1506
static void write_uilist(BlendWriter *writer, uiList *ui_list)
Definition: screen.c:1171
void BKE_area_region_panels_free(ListBase *panels)
Definition: screen.c:652
static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: screen.c:244
ScrArea * BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, const int spacetype, int x, int y)
Definition: screen.c:1003
void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
Definition: screen.c:1485
static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype)
Definition: screen.c:1420
ARegion * BKE_area_region_copy(const SpaceType *st, const ARegion *region)
Definition: screen.c:475
void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area)
Definition: screen.c:100
static void panel_list_copy(ListBase *newlb, const ListBase *lb)
Definition: screen.c:460
static void screen_free_data(ID *id)
Definition: screen.c:72
struct SELECTID_Context context
Definition: select_engine.c:47
#define min(a, b)
Definition: sort.c:51
static int node_context(const bContext *C, const char *member, bContextDataResult *result)
Definition: space_node.c:872
void(* free)(struct ARegion *)
Definition: BKE_screen.h:187
void *(* duplicate)(void *poin)
Definition: BKE_screen.h:190
struct wmTimer * regiontimer
void * regiondata
struct ARegion * prev
ListBase panels_category_active
ListBase ui_previews
char * headerstr
struct ARegion * next
ListBase panels_category
ListBase panels
ListBase ui_lists
ListBase handlers
struct wmDrawBuffer * draw_buffer
short regiontype
struct wmGizmoMap * gizmo_map
struct ARegionType * type
ListBase uiblocks
short id_code
Definition: BKE_idtype.h:120
Definition: DNA_ID.h:273
struct Library * lib
Definition: DNA_ID.h:277
int us
Definition: DNA_ID.h:293
char name[66]
Definition: DNA_ID.h:283
struct Scene * scene
void * last
Definition: DNA_listBase.h:47
void * first
Definition: DNA_listBase.h:47
struct Mask * mask
struct ImBuf * track_preview
struct ImBuf * track_search
struct PointerRNA * custom_data_ptr
Panel_Runtime runtime
void * activedata
struct Panel * next
ListBase children
struct RenderEngine * render_engine
struct SmoothView3DStore * sms
float viewquat[4]
struct RegionView3D * localvd
struct ViewDepths * depths
struct wmTimer * smooth_timer
struct BoundBox * clipbb
struct Object * camera
float * waveform_3
float * waveform_2
float * waveform_1
float * vecscope
ListBase vertbase
ListBase edgebase
ListBase areabase
ScrVert * v1
struct ScrEdge * next
ScrVert * v2
struct ImBuf * reference_ibuf
struct ImBuf * waveform_ibuf
struct ImBuf * sep_waveform_ibuf
struct ImBuf * zebra_ibuf
struct ImBuf * histogram_ibuf
struct ImBuf * vector_ibuf
bAction * action
bDopeSheet ads
struct MovieClipScopes scopes
struct MovieClip * clip
MaskSpaceInfo mask_info
ListBase scrollback
struct FileLayout * layout
struct wmOperator * op
ListBase * folders_prev
struct FileList * files
FileSelectParams * params
struct wmTimer * previews_timer
FileAssetSelectParams * asset_params
ListBase * folders_next
ListBase folder_histories
SpaceFile_Runtime * runtime
struct bDopeSheet * ads
SpaceGraph_Runtime runtime
struct Scopes scopes
MaskSpaceInfo mask_info
struct ImageUser iuser
struct bGPdata * gpd
struct Image * image
struct bDopeSheet * ads
SpaceNode_Runtime * runtime
struct ID * from
struct bGPdata * gpd
ListBase treepath
struct bNodeTree * edittree
struct ID * id
struct bNodeTree * nodetree
struct TreeStoreElem search_tse
SpaceOutliner_Runtime * runtime
struct BLI_mempool * treestore
struct SpaceProperties_Runtime * runtime
struct Script * script
struct SequencerScopes scopes
struct bGPdata * gpd
SpaceSpreadsheet_Runtime * runtime
SpaceText_Runtime runtime
struct Text * text
struct SpaceLink *(* duplicate)(struct SpaceLink *sl)
Definition: BKE_screen.h:104
ListBase regiontypes
Definition: BKE_screen.h:130
void(* free)(struct SpaceLink *sl)
Definition: BKE_screen.h:88
int spaceid
Definition: BKE_screen.h:81
char name[BKE_ST_MAXNAME]
Definition: BKE_screen.h:80
TreeStoreElem * data
char alpha_vert
struct SmoothView2DStore * sms
char alpha_hor
struct IDProperty * prop
View3D_Runtime runtime
struct Object * camera
short gridsubdiv
struct View3D * localvd
short scenelock
struct Object * ob_center
ListBase regionbase
View3DShading shading
struct Collection * filter_grp
struct bNodeTree * nodetree
struct bNodeTreePath * next
char do_refresh
ListBase edgebase
void * context
PreviewImage * preview
ListBase regionbase
struct wmTooltipState * tool_tip
ListBase vertbase
struct wmTimer * animtimer
char scrubbing
ListBase areabase
struct ARegion * active_region
int * items_filter_neworder
int * items_filter_flags
IDProperty * properties