Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_api/spacetypes.c
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| #include "ED_space_api.h" | #include "ED_space_api.h" | ||||
| #include "ED_transform.h" | #include "ED_transform.h" | ||||
| #include "ED_userpref.h" | #include "ED_userpref.h" | ||||
| #include "ED_util.h" | #include "ED_util.h" | ||||
| #include "ED_uvedit.h" | #include "ED_uvedit.h" | ||||
| #include "io_ops.h" | #include "io_ops.h" | ||||
| /* only call once on startup, storage is global in BKE kernel listbase */ | /* Only called once on startup. storage is global in BKE kernel listbase. */ | ||||
| void ED_spacetypes_init(void) | void ED_spacetypes_init(void) | ||||
| { | { | ||||
| const ListBase *spacetypes; | /* UI unit is a variable, may be used in some space type inits. */ | ||||
| SpaceType *type; | |||||
| /* UI_UNIT_X is now a variable, is used in some spacetype inits? */ | |||||
| U.widget_unit = 20; | U.widget_unit = 20; | ||||
| /* create space types */ | /* Create space types. */ | ||||
| ED_spacetype_outliner(); | ED_spacetype_outliner(); | ||||
| ED_spacetype_view3d(); | ED_spacetype_view3d(); | ||||
| ED_spacetype_ipo(); | ED_spacetype_ipo(); | ||||
| ED_spacetype_image(); | ED_spacetype_image(); | ||||
| ED_spacetype_node(); | ED_spacetype_node(); | ||||
| ED_spacetype_buttons(); | ED_spacetype_buttons(); | ||||
| ED_spacetype_info(); | ED_spacetype_info(); | ||||
| ED_spacetype_file(); | ED_spacetype_file(); | ||||
| ED_spacetype_action(); | ED_spacetype_action(); | ||||
| ED_spacetype_nla(); | ED_spacetype_nla(); | ||||
| ED_spacetype_script(); | ED_spacetype_script(); | ||||
| ED_spacetype_text(); | ED_spacetype_text(); | ||||
| ED_spacetype_sequencer(); | ED_spacetype_sequencer(); | ||||
| ED_spacetype_console(); | ED_spacetype_console(); | ||||
| ED_spacetype_userpref(); | ED_spacetype_userpref(); | ||||
| ED_spacetype_clip(); | ED_spacetype_clip(); | ||||
| ED_spacetype_statusbar(); | ED_spacetype_statusbar(); | ||||
| ED_spacetype_topbar(); | ED_spacetype_topbar(); | ||||
| // ... | |||||
| /* register operator types for screen and all spaces */ | /* Register operator types for screen and all spaces. */ | ||||
| ED_operatortypes_userpref(); | ED_operatortypes_userpref(); | ||||
| ED_operatortypes_workspace(); | ED_operatortypes_workspace(); | ||||
| ED_operatortypes_scene(); | ED_operatortypes_scene(); | ||||
| ED_operatortypes_screen(); | ED_operatortypes_screen(); | ||||
| ED_operatortypes_anim(); | ED_operatortypes_anim(); | ||||
| ED_operatortypes_animchannels(); | ED_operatortypes_animchannels(); | ||||
| ED_operatortypes_asset(); | ED_operatortypes_asset(); | ||||
| ED_operatortypes_gpencil(); | ED_operatortypes_gpencil(); | ||||
| Show All 15 Lines | void ED_spacetypes_init(void) | ||||
| ED_operatortypes_io(); | ED_operatortypes_io(); | ||||
| ED_operatortypes_edutils(); | ED_operatortypes_edutils(); | ||||
| ED_operatortypes_view2d(); | ED_operatortypes_view2d(); | ||||
| ED_operatortypes_ui(); | ED_operatortypes_ui(); | ||||
| ED_screen_user_menu_register(); | ED_screen_user_menu_register(); | ||||
| /* gizmo types */ | /* Gizmo types. */ | ||||
| ED_gizmotypes_button_2d(); | ED_gizmotypes_button_2d(); | ||||
| ED_gizmotypes_dial_3d(); | ED_gizmotypes_dial_3d(); | ||||
| ED_gizmotypes_move_3d(); | ED_gizmotypes_move_3d(); | ||||
| ED_gizmotypes_arrow_3d(); | ED_gizmotypes_arrow_3d(); | ||||
| ED_gizmotypes_preselect_3d(); | ED_gizmotypes_preselect_3d(); | ||||
| ED_gizmotypes_primitive_3d(); | ED_gizmotypes_primitive_3d(); | ||||
| ED_gizmotypes_blank_3d(); | ED_gizmotypes_blank_3d(); | ||||
| ED_gizmotypes_cage_2d(); | ED_gizmotypes_cage_2d(); | ||||
| ED_gizmotypes_cage_3d(); | ED_gizmotypes_cage_3d(); | ||||
| ED_gizmotypes_snap_3d(); | ED_gizmotypes_snap_3d(); | ||||
| /* register types for operators and gizmos */ | /* Register types for operators and gizmos. */ | ||||
| spacetypes = BKE_spacetypes_list(); | const ListBase *spacetypes = BKE_spacetypes_list(); | ||||
| for (type = spacetypes->first; type; type = type->next) { | LISTBASE_FOREACH (const SpaceType *, type, spacetypes) { | ||||
| /* init gizmo types first, operator-types need them */ | /* Initialize gizmo types first, operator types need them. */ | ||||
| if (type->gizmos) { | if (type->gizmos) { | ||||
| type->gizmos(); | type->gizmos(); | ||||
| } | } | ||||
| if (type->operatortypes) { | if (type->operatortypes) { | ||||
| type->operatortypes(); | type->operatortypes(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void ED_spacemacros_init(void) | void ED_spacemacros_init(void) | ||||
| { | { | ||||
| const ListBase *spacetypes; | /* Macros must go last since they reference other operators. | ||||
| SpaceType *type; | * They need to be registered after python operators too. */ | ||||
| /* Macros's must go last since they reference other operators. | |||||
| * We need to have them go after python operators too */ | |||||
| ED_operatormacros_armature(); | ED_operatormacros_armature(); | ||||
| ED_operatormacros_mesh(); | ED_operatormacros_mesh(); | ||||
| ED_operatormacros_uvedit(); | ED_operatormacros_uvedit(); | ||||
| ED_operatormacros_metaball(); | ED_operatormacros_metaball(); | ||||
| ED_operatormacros_node(); | ED_operatormacros_node(); | ||||
| ED_operatormacros_object(); | ED_operatormacros_object(); | ||||
| ED_operatormacros_file(); | ED_operatormacros_file(); | ||||
| ED_operatormacros_graph(); | ED_operatormacros_graph(); | ||||
| ED_operatormacros_action(); | ED_operatormacros_action(); | ||||
| ED_operatormacros_clip(); | ED_operatormacros_clip(); | ||||
| ED_operatormacros_curve(); | ED_operatormacros_curve(); | ||||
| ED_operatormacros_mask(); | ED_operatormacros_mask(); | ||||
| ED_operatormacros_sequencer(); | ED_operatormacros_sequencer(); | ||||
| ED_operatormacros_paint(); | ED_operatormacros_paint(); | ||||
| ED_operatormacros_gpencil(); | ED_operatormacros_gpencil(); | ||||
| /* register dropboxes (can use macros) */ | /* Register dropboxes (can use macros). */ | ||||
| spacetypes = BKE_spacetypes_list(); | const ListBase *spacetypes = BKE_spacetypes_list(); | ||||
| for (type = spacetypes->first; type; type = type->next) { | LISTBASE_FOREACH (const SpaceType *, type, spacetypes) { | ||||
| if (type->dropboxes) { | if (type->dropboxes) { | ||||
| type->dropboxes(); | type->dropboxes(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* called in wm.c */ | /** | ||||
| /* keymap definitions are registered only once per WM initialize, usually on file read, | * \note Keymap definitions are registered only once per WM initialize, | ||||
| * using the keymap the actual areas/regions add the handlers */ | * usually on file read, using the keymap the actual areas/regions add the handlers. | ||||
| * \note Called in wm.c. */ | |||||
| void ED_spacetypes_keymap(wmKeyConfig *keyconf) | void ED_spacetypes_keymap(wmKeyConfig *keyconf) | ||||
| { | { | ||||
| const ListBase *spacetypes; | |||||
| SpaceType *stype; | |||||
| ARegionType *atype; | |||||
| ED_keymap_screen(keyconf); | ED_keymap_screen(keyconf); | ||||
| ED_keymap_anim(keyconf); | ED_keymap_anim(keyconf); | ||||
| ED_keymap_animchannels(keyconf); | ED_keymap_animchannels(keyconf); | ||||
| ED_keymap_gpencil(keyconf); | ED_keymap_gpencil(keyconf); | ||||
| ED_keymap_object(keyconf); | ED_keymap_object(keyconf); | ||||
| ED_keymap_lattice(keyconf); | ED_keymap_lattice(keyconf); | ||||
| ED_keymap_mesh(keyconf); | ED_keymap_mesh(keyconf); | ||||
| ED_keymap_uvedit(keyconf); | ED_keymap_uvedit(keyconf); | ||||
| ED_keymap_curve(keyconf); | ED_keymap_curve(keyconf); | ||||
| ED_keymap_armature(keyconf); | ED_keymap_armature(keyconf); | ||||
| ED_keymap_physics(keyconf); | ED_keymap_physics(keyconf); | ||||
| ED_keymap_metaball(keyconf); | ED_keymap_metaball(keyconf); | ||||
| ED_keymap_paint(keyconf); | ED_keymap_paint(keyconf); | ||||
| ED_keymap_mask(keyconf); | ED_keymap_mask(keyconf); | ||||
| ED_keymap_marker(keyconf); | ED_keymap_marker(keyconf); | ||||
| ED_keymap_view2d(keyconf); | ED_keymap_view2d(keyconf); | ||||
| ED_keymap_ui(keyconf); | ED_keymap_ui(keyconf); | ||||
| ED_keymap_transform(keyconf); | ED_keymap_transform(keyconf); | ||||
| spacetypes = BKE_spacetypes_list(); | const ListBase *spacetypes = BKE_spacetypes_list(); | ||||
| for (stype = spacetypes->first; stype; stype = stype->next) { | LISTBASE_FOREACH (const SpaceType *, type, spacetypes) { | ||||
| if (stype->keymap) { | if (type->keymap) { | ||||
| stype->keymap(keyconf); | type->keymap(keyconf); | ||||
| } | } | ||||
| for (atype = stype->regiontypes.first; atype; atype = atype->next) { | LISTBASE_FOREACH (ARegionType *, region_type, &type->regiontypes) { | ||||
| if (atype->keymap) { | if (region_type->keymap) { | ||||
| atype->keymap(keyconf); | region_type->keymap(keyconf); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ********************** custom drawcall api ***************** */ | /* ********************** Custom Draw Call API ***************** */ | ||||
| typedef struct RegionDrawCB { | typedef struct RegionDrawCB { | ||||
| struct RegionDrawCB *next, *prev; | struct RegionDrawCB *next, *prev; | ||||
| void (*draw)(const struct bContext *, struct ARegion *, void *); | void (*draw)(const struct bContext *, struct ARegion *, void *); | ||||
| void *customdata; | void *customdata; | ||||
| int type; | int type; | ||||
| Show All 12 Lines | void *ED_region_draw_cb_activate(ARegionType *art, | ||||
| rdc->customdata = customdata; | rdc->customdata = customdata; | ||||
| rdc->type = type; | rdc->type = type; | ||||
| return rdc; | return rdc; | ||||
| } | } | ||||
| void ED_region_draw_cb_exit(ARegionType *art, void *handle) | void ED_region_draw_cb_exit(ARegionType *art, void *handle) | ||||
| { | { | ||||
| RegionDrawCB *rdc; | LISTBASE_FOREACH (RegionDrawCB *, rdc, &art->drawcalls) { | ||||
| for (rdc = art->drawcalls.first; rdc; rdc = rdc->next) { | |||||
| if (rdc == (RegionDrawCB *)handle) { | if (rdc == (RegionDrawCB *)handle) { | ||||
| BLI_remlink(&art->drawcalls, rdc); | BLI_remlink(&art->drawcalls, rdc); | ||||
| MEM_freeN(rdc); | MEM_freeN(rdc); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) | void ED_region_draw_cb_draw(const bContext *C, ARegion *region, int type) | ||||
| { | { | ||||
| RegionDrawCB *rdc; | LISTBASE_FOREACH (RegionDrawCB *, rdc, ®ion->type->drawcalls) { | ||||
| for (rdc = region->type->drawcalls.first; rdc; rdc = rdc->next) { | |||||
| if (rdc->type == type) { | if (rdc->type == type) { | ||||
| rdc->draw(C, region, rdc->customdata); | rdc->draw(C, region, rdc->customdata); | ||||
| /* This is needed until we get rid of BGL which can change the states we are tracking. */ | /* This is needed until we get rid of BGL which can change the states we are tracking. */ | ||||
| GPU_bgl_end(); | GPU_bgl_end(); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||