Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/screen.c
| Show All 31 Lines | |||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # include "BLI_winstuff.h" | # include "BLI_winstuff.h" | ||||
| #endif | #endif | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_rect.h" | #include "BLI_rect.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| static CLG_LogRef LOG = {"bke.screen"}; | |||||
| /* ************ Spacetype/regiontype handling ************** */ | /* ************ Spacetype/regiontype handling ************** */ | ||||
| /* keep global; this has to be accessible outside of windowmanager */ | /* keep global; this has to be accessible outside of windowmanager */ | ||||
| static ListBase spacetypes = {NULL, NULL}; | static ListBase spacetypes = {NULL, NULL}; | ||||
| /* not SpaceType itself */ | /* not SpaceType itself */ | ||||
| static void spacetype_free(SpaceType *st) | static void spacetype_free(SpaceType *st) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid) | ARegionType *BKE_regiontype_from_id_or_first(SpaceType *st, int regionid) | ||||
| { | { | ||||
| ARegionType *art; | ARegionType *art; | ||||
| for (art = st->regiontypes.first; art; art = art->next) | for (art = st->regiontypes.first; art; art = art->next) | ||||
| if (art->regionid == regionid) | if (art->regionid == regionid) | ||||
| return art; | return art; | ||||
| printf("Error, region type %d missing in - name:\"%s\", id:%d\n", regionid, st->name, st->spaceid); | CLOG_ERROR(&LOG, "region type %d missing in - name:\"%s\", id:%d", regionid, st->name, st->spaceid); | ||||
| return st->regiontypes.first; | return st->regiontypes.first; | ||||
| } | } | ||||
| ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) | ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) | ||||
| { | { | ||||
| ARegionType *art; | ARegionType *art; | ||||
| for (art = st->regiontypes.first; art; art = art->next) { | for (art = st->regiontypes.first; art; art = art->next) { | ||||
| Show All 12 Lines | |||||
| void BKE_spacetype_register(SpaceType *st) | void BKE_spacetype_register(SpaceType *st) | ||||
| { | { | ||||
| SpaceType *stype; | SpaceType *stype; | ||||
| /* sanity check */ | /* sanity check */ | ||||
| stype = BKE_spacetype_from_id(st->spaceid); | stype = BKE_spacetype_from_id(st->spaceid); | ||||
| if (stype) { | if (stype) { | ||||
| printf("error: redefinition of spacetype %s\n", stype->name); | CLOG_ERROR(&LOG, "redefinition of spacetype %s", stype->name); | ||||
| spacetype_free(stype); | spacetype_free(stype); | ||||
| MEM_freeN(stype); | MEM_freeN(stype); | ||||
| } | } | ||||
| BLI_addtail(&spacetypes, st); | BLI_addtail(&spacetypes, st); | ||||
| } | } | ||||
| bool BKE_spacetype_exists(int spaceid) | bool BKE_spacetype_exists(int spaceid) | ||||
| ▲ Show 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | void BKE_area_region_free(SpaceType *st, ARegion *ar) | ||||
| if (st) { | if (st) { | ||||
| ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); | ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); | ||||
| if (art && art->free) | if (art && art->free) | ||||
| art->free(ar); | art->free(ar); | ||||
| if (ar->regiondata) | if (ar->regiondata) | ||||
| printf("regiondata free error\n"); | CLOG_ERROR(&LOG, "regiondata free error"); | ||||
| } | } | ||||
| else if (ar->type && ar->type->free) | else if (ar->type && ar->type->free) | ||||
| ar->type->free(ar); | ar->type->free(ar); | ||||
| if (ar->v2d.tab_offset) { | if (ar->v2d.tab_offset) { | ||||
| MEM_freeN(ar->v2d.tab_offset); | MEM_freeN(ar->v2d.tab_offset); | ||||
| ar->v2d.tab_offset = NULL; | ar->v2d.tab_offset = NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ScrEdge *se, *sen; | ScrEdge *se, *sen; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| int a = 0; | int a = 0; | ||||
| /* sets flags when edge is used in area */ | /* sets flags when edge is used in area */ | ||||
| sa = sc->areabase.first; | sa = sc->areabase.first; | ||||
| while (sa) { | while (sa) { | ||||
| se = BKE_screen_find_edge(sc, sa->v1, sa->v2); | ScrVert *edges[4][2] = { | ||||
| if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a); | { sa->v1, sa->v2 }, | ||||
| else se->flag = 1; | { sa->v2, sa->v3 }, | ||||
| se = BKE_screen_find_edge(sc, sa->v2, sa->v3); | { sa->v3, sa->v4 }, | ||||
| if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a); | { sa->v4, sa->v1 } | ||||
| else se->flag = 1; | }; | ||||
| se = BKE_screen_find_edge(sc, sa->v3, sa->v4); | for (int i = 0; i < 4; i++) { | ||||
| if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a); | ScrVert *v1 = edges[i][0]; | ||||
| else se->flag = 1; | ScrVert *v2 = edges[i][1]; | ||||
| se = BKE_screen_find_edge(sc, sa->v4, sa->v1); | |||||
| if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a); | se = BKE_screen_find_edge(sc, v1, v2); | ||||
| if (se == NULL) { | |||||
| CLOG_ERROR(&LOG, "area %d edge %d doesn't exist", a, i + 1); | |||||
| } | |||||
| else se->flag = 1; | else se->flag = 1; | ||||
| } | |||||
sobakasu: sorry about this random code change, I got bored | |||||
| sa = sa->next; | sa = sa->next; | ||||
| a++; | a++; | ||||
| } | } | ||||
| se = sc->edgebase.first; | se = sc->edgebase.first; | ||||
| while (se) { | while (se) { | ||||
| sen = se->next; | sen = se->next; | ||||
| if (se->flag == 0) { | if (se->flag == 0) { | ||||
| BLI_remlink(&sc->edgebase, se); | BLI_remlink(&sc->edgebase, se); | ||||
| ▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines | |||||
sorry about this random code change, I got bored