Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_toolsystem.c
| Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Tool Reference API | /** \name Tool Reference API | ||||
| * \{ */ | * \{ */ | ||||
| struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) | struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C) | ||||
| { | { | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| const Scene *scene = CTX_data_scene(C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| if ((area == NULL) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { | if ((area == NULL) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = area->spacetype, | .space_type = area->spacetype, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), | ||||
| }; | }; | ||||
| bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | ||||
| /* We could return 'area->runtime.tool' in this case. */ | /* We could return 'area->runtime.tool' in this case. */ | ||||
| if (area->runtime.is_tool_set) { | if (area->runtime.is_tool_set) { | ||||
| BLI_assert(tref == area->runtime.tool); | BLI_assert(tref == area->runtime.tool); | ||||
| } | } | ||||
| return tref; | return tref; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | void WM_toolsystem_refresh_all(struct bContext *C, struct WorkSpace *workspace) | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | ||||
| toolsystem_refresh_ref(C, workspace, tref); | toolsystem_refresh_ref(C, workspace, tref); | ||||
| } | } | ||||
| } | } | ||||
| void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) | void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win) | ||||
| { | { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| const Scene *scene = WM_window_get_active_scene(win); | |||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { | if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | WorkSpace *workspace = WM_window_get_active_workspace(win); | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = area->spacetype, | .space_type = area->spacetype, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), | ||||
| }; | }; | ||||
| bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | ||||
| if (tref) { | if (tref) { | ||||
| if (tref->tag == 0) { | if (tref->tag == 0) { | ||||
| toolsystem_reinit_ref(C, workspace, tref); | toolsystem_reinit_ref(C, workspace, tref); | ||||
| tref->tag = 1; | tref->tag = 1; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToolRef *tref) | ||||
| wmWindowManager *wm = bmain->wm.first; | wmWindowManager *wm = bmain->wm.first; | ||||
| LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| if (workspace != WM_window_get_active_workspace(win)) { | if (workspace != WM_window_get_active_workspace(win)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Scene *scene = WM_window_get_active_scene(win); | Scene *scene = WM_window_get_active_scene(win); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| const ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| BKE_view_layer_synced_ensure(scene, view_layer); | |||||
| const Object *ob = BKE_view_layer_active_object_get(view_layer); | const Object *ob = BKE_view_layer_active_object_get(view_layer); | ||||
| if (ob == NULL) { | if (ob == NULL) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| if ((tref->space_type == SPACE_VIEW3D) && (tref->mode == CTX_MODE_PARTICLE)) { | if ((tref->space_type == SPACE_VIEW3D) && (tref->mode == CTX_MODE_PARTICLE)) { | ||||
| if (ob->mode & OB_MODE_PARTICLE_EDIT) { | if (ob->mode & OB_MODE_PARTICLE_EDIT) { | ||||
| const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items; | const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items; | ||||
| const int i = RNA_enum_from_value(items, ts->particle.brushtype); | const int i = RNA_enum_from_value(items, ts->particle.brushtype); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | switch (tkey->space_type) { | ||||
| case SPACE_NODE: | case SPACE_NODE: | ||||
| return true; | return true; | ||||
| case SPACE_SEQ: | case SPACE_SEQ: | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| int WM_toolsystem_mode_from_spacetype(ViewLayer *view_layer, ScrArea *area, int space_type) | int WM_toolsystem_mode_from_spacetype(const Scene *scene, | ||||
| ViewLayer *view_layer, | |||||
| ScrArea *area, | |||||
| int space_type) | |||||
| { | { | ||||
| int mode = -1; | int mode = -1; | ||||
| switch (space_type) { | switch (space_type) { | ||||
| case SPACE_VIEW3D: { | case SPACE_VIEW3D: { | ||||
| /* 'area' may be NULL in this case. */ | /* 'area' may be NULL in this case. */ | ||||
| BKE_view_layer_synced_ensure(scene, view_layer); | |||||
| Object *obact = BKE_view_layer_active_object_get(view_layer); | Object *obact = BKE_view_layer_active_object_get(view_layer); | ||||
| if (obact != NULL) { | if (obact != NULL) { | ||||
| Object *obedit = OBEDIT_FROM_OBACT(obact); | Object *obedit = OBEDIT_FROM_OBACT(obact); | ||||
| mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode); | mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode); | ||||
| } | } | ||||
| else { | else { | ||||
| mode = CTX_MODE_OBJECT; | mode = CTX_MODE_OBJECT; | ||||
| } | } | ||||
| Show All 12 Lines | case SPACE_SEQ: { | ||||
| SpaceSeq *sseq = area->spacedata.first; | SpaceSeq *sseq = area->spacedata.first; | ||||
| mode = sseq->view; | mode = sseq->view; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return mode; | return mode; | ||||
| } | } | ||||
| bool WM_toolsystem_key_from_context(ViewLayer *view_layer, ScrArea *area, bToolKey *tkey) | bool WM_toolsystem_key_from_context(const Scene *scene, | ||||
| ViewLayer *view_layer, | |||||
| ScrArea *area, | |||||
| bToolKey *tkey) | |||||
| { | { | ||||
| int space_type = SPACE_EMPTY; | int space_type = SPACE_EMPTY; | ||||
| int mode = -1; | int mode = -1; | ||||
| if (area != NULL) { | if (area != NULL) { | ||||
| space_type = area->spacetype; | space_type = area->spacetype; | ||||
| mode = WM_toolsystem_mode_from_spacetype(view_layer, area, space_type); | mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, space_type); | ||||
| } | } | ||||
| if (mode != -1) { | if (mode != -1) { | ||||
| tkey->space_type = space_type; | tkey->space_type = space_type; | ||||
| tkey->mode = mode; | tkey->mode = mode; | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| Show All 9 Lines | struct { | ||||
| ARegion *region; | ARegion *region; | ||||
| bool is_set; | bool is_set; | ||||
| } context_prev = {0}; | } context_prev = {0}; | ||||
| for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | ||||
| LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | WorkSpace *workspace = WM_window_get_active_workspace(win); | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| const Scene *scene = WM_window_get_active_scene(win); | |||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| /* Could skip loop for modes that don't depend on space type. */ | /* Could skip loop for modes that don't depend on space type. */ | ||||
| int space_type_mask_handled = 0; | int space_type_mask_handled = 0; | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| /* Don't change the space type of the active tool, only update its mode. */ | /* Don't change the space type of the active tool, only update its mode. */ | ||||
| const int space_type_mask = (1 << area->spacetype); | const int space_type_mask = (1 << area->spacetype); | ||||
| if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) && | if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) && | ||||
| ((space_type_mask_handled & space_type_mask) == 0)) { | ((space_type_mask_handled & space_type_mask) == 0)) { | ||||
| space_type_mask_handled |= space_type_mask; | space_type_mask_handled |= space_type_mask; | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = area->spacetype, | .space_type = area->spacetype, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), | ||||
| }; | }; | ||||
| bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey); | ||||
| if (tref != area->runtime.tool) { | if (tref != area->runtime.tool) { | ||||
| if (context_prev.is_set == false) { | if (context_prev.is_set == false) { | ||||
| context_prev.win = CTX_wm_window(C); | context_prev.win = CTX_wm_window(C); | ||||
| context_prev.area = CTX_wm_area(C); | context_prev.area = CTX_wm_area(C); | ||||
| context_prev.region = CTX_wm_region(C); | context_prev.region = CTX_wm_region(C); | ||||
| context_prev.is_set = true; | context_prev.is_set = true; | ||||
| Show All 25 Lines | if (workspace->id.tag & LIB_TAG_DOIT) { | ||||
| * needed for the tool (un-initialized paint-slots for eg), see: T64339. */ | * needed for the tool (un-initialized paint-slots for eg), see: T64339. */ | ||||
| LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | ||||
| toolsystem_refresh_ref(C, workspace, tref); | toolsystem_refresh_ref(C, workspace, tref); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_layer, ScrArea *area) | void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, | ||||
| const Scene *scene, | |||||
| ViewLayer *view_layer, | |||||
| ScrArea *area) | |||||
| { | { | ||||
| area->runtime.tool = NULL; | area->runtime.tool = NULL; | ||||
| area->runtime.is_tool_set = true; | area->runtime.is_tool_set = true; | ||||
| const int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); | const int mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype); | ||||
| LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | ||||
| if (tref->space_type == area->spacetype) { | if (tref->space_type == area->spacetype) { | ||||
| if (tref->mode == mode) { | if (tref->mode == mode) { | ||||
| area->runtime.tool = tref; | area->runtime.tool = tref; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void WM_toolsystem_refresh_screen_window(wmWindow *win) | void WM_toolsystem_refresh_screen_window(wmWindow *win) | ||||
| { | { | ||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | WorkSpace *workspace = WM_window_get_active_workspace(win); | ||||
| bool space_type_has_tools[SPACE_TYPE_NUM] = {0}; | bool space_type_has_tools[SPACE_TYPE_NUM] = {0}; | ||||
| LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) { | ||||
| space_type_has_tools[tref->space_type] = true; | space_type_has_tools[tref->space_type] = true; | ||||
| } | } | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| const Scene *scene = WM_window_get_active_scene(win); | |||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| area->runtime.tool = NULL; | area->runtime.tool = NULL; | ||||
| area->runtime.is_tool_set = true; | area->runtime.is_tool_set = true; | ||||
| if (space_type_has_tools[area->spacetype]) { | if (space_type_has_tools[area->spacetype]) { | ||||
| WM_toolsystem_refresh_screen_area(workspace, view_layer, area); | WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void WM_toolsystem_refresh_screen_all(Main *bmain) | void WM_toolsystem_refresh_screen_all(Main *bmain) | ||||
| { | { | ||||
| /* Update all ScrArea's tools */ | /* Update all ScrArea's tools */ | ||||
| for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | ||||
| LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| WM_toolsystem_refresh_screen_window(win); | WM_toolsystem_refresh_screen_window(win); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void toolsystem_refresh_screen_from_active_tool(Main *bmain, | static void toolsystem_refresh_screen_from_active_tool(Main *bmain, | ||||
| WorkSpace *workspace, | WorkSpace *workspace, | ||||
| bToolRef *tref) | bToolRef *tref) | ||||
| { | { | ||||
| /* Update all ScrArea's tools */ | /* Update all ScrArea's tools */ | ||||
| for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { | ||||
| LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| if (workspace == WM_window_get_active_workspace(win)) { | if (workspace == WM_window_get_active_workspace(win)) { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| const Scene *scene = WM_window_get_active_scene(win); | |||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| if (area->spacetype == tref->space_type) { | if (area->spacetype == tref->space_type) { | ||||
| int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype); | int mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype); | ||||
| if (mode == tref->mode) { | if (mode == tref->mode) { | ||||
| area->runtime.tool = tref; | area->runtime.tool = tref; | ||||
| area->runtime.is_tool_set = true; | area->runtime.is_tool_set = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Show All 38 Lines | if (tref) { | ||||
| toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref); | toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref); | ||||
| } | } | ||||
| return (tref && STREQ(tref->idname, name)) ? tref : NULL; | return (tref && STREQ(tref->idname, name)) ? tref : NULL; | ||||
| } | } | ||||
| bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name) | bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name) | ||||
| { | { | ||||
| const Scene *scene = CTX_data_scene(C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| bToolKey tkey; | bToolKey tkey; | ||||
| if (WM_toolsystem_key_from_context(view_layer, area, &tkey)) { | if (WM_toolsystem_key_from_context(scene, view_layer, area, &tkey)) { | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false); | return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false); | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace *workspace, bToolRef *tref) | static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace *workspace, bToolRef *tref) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (WM_toolsystem_ref_ensure(workspace, tkey, &tref)) { | ||||
| STRNCPY(tref->idname, default_tool); | STRNCPY(tref->idname, default_tool); | ||||
| } | } | ||||
| toolsystem_reinit_with_toolref(C, workspace, tref); | toolsystem_reinit_with_toolref(C, workspace, tref); | ||||
| return tref; | return tref; | ||||
| } | } | ||||
| static void wm_toolsystem_update_from_context_view3d_impl(bContext *C, WorkSpace *workspace) | static void wm_toolsystem_update_from_context_view3d_impl(bContext *C, WorkSpace *workspace) | ||||
| { | { | ||||
| const Scene *scene = CTX_data_scene(C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| int space_type = SPACE_VIEW3D; | int space_type = SPACE_VIEW3D; | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = space_type, | .space_type = space_type, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, NULL, space_type), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, NULL, space_type), | ||||
| }; | }; | ||||
| toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); | toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); | ||||
| } | } | ||||
| void WM_toolsystem_update_from_context_view3d(bContext *C) | void WM_toolsystem_update_from_context_view3d(bContext *C) | ||||
| { | { | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | WorkSpace *workspace = CTX_wm_workspace(C); | ||||
| wm_toolsystem_update_from_context_view3d_impl(C, workspace); | wm_toolsystem_update_from_context_view3d_impl(C, workspace); | ||||
| Show All 19 Lines | LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { | ||||
| CTX_wm_area_set(C, area_prev); | CTX_wm_area_set(C, area_prev); | ||||
| CTX_wm_region_set(C, region_prev); | CTX_wm_region_set(C, region_prev); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void WM_toolsystem_update_from_context(bContext *C, | void WM_toolsystem_update_from_context( | ||||
| WorkSpace *workspace, | bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area) | ||||
| ViewLayer *view_layer, | |||||
| ScrArea *area) | |||||
| { | { | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = area->spacetype, | .space_type = area->spacetype, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), | ||||
| }; | }; | ||||
| if (toolsystem_key_ensure_check(&tkey)) { | if (toolsystem_key_ensure_check(&tkey)) { | ||||
| toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); | toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); | ||||
| } | } | ||||
| } | } | ||||
| bool WM_toolsystem_active_tool_is_brush(const bContext *C) | bool WM_toolsystem_active_tool_is_brush(const bContext *C) | ||||
| { | { | ||||
| Show All 13 Lines | do { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| if (BLI_findindex(&screen->areabase, area) != -1) { | if (BLI_findindex(&screen->areabase, area) != -1) { | ||||
| break; | break; | ||||
| } | } | ||||
| } while ((win = win->next)); | } while ((win = win->next)); | ||||
| } | } | ||||
| WorkSpace *workspace = WM_window_get_active_workspace(win); | WorkSpace *workspace = WM_window_get_active_workspace(win); | ||||
| const Scene *scene = WM_window_get_active_scene(win); | |||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ViewLayer *view_layer = WM_window_get_active_view_layer(win); | ||||
| const bToolKey tkey = { | const bToolKey tkey = { | ||||
| .space_type = area->spacetype, | .space_type = area->spacetype, | ||||
| .mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype), | .mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype), | ||||
| }; | }; | ||||
| WM_toolsystem_refresh(C, workspace, &tkey); | WM_toolsystem_refresh(C, workspace, &tkey); | ||||
| WM_toolsystem_refresh_screen_area(workspace, view_layer, area); | WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area); | ||||
| } | } | ||||
| static IDProperty *idprops_ensure_named_group(IDProperty *group, const char *idname) | static IDProperty *idprops_ensure_named_group(IDProperty *group, const char *idname) | ||||
| { | { | ||||
| IDProperty *prop = IDP_GetPropertyFromGroup(group, idname); | IDProperty *prop = IDP_GetPropertyFromGroup(group, idname); | ||||
| if ((prop == NULL) || (prop->type != IDP_GROUP)) { | if ((prop == NULL) || (prop->type != IDP_GROUP)) { | ||||
| IDPropertyTemplate val = {0}; | IDPropertyTemplate val = {0}; | ||||
| prop = IDP_New(IDP_GROUP, &val, __func__); | prop = IDP_New(IDP_GROUP, &val, __func__); | ||||
| ▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines | |||||