Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-02 10:02:05 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-02 10:02:05 +0300
commit6fb51ece54b6b439c70f3a9010e7a52aaf1a806d (patch)
tree5d63b6fec4752d2954530301019e3e9a64affa31 /source
parent38e34a12ac5932aa175088d28fbe9664350c1e4c (diff)
Workspace: remove global active tool
This was needed for a global top-bar to show a single tool, no longer needed now the top-bar is per-space.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_icons.c21
-rw-r--r--source/blender/makesdna/DNA_workspace_types.h5
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c35
3 files changed, 20 insertions, 41 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 4b66461e186..7e295f83390 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1826,15 +1826,14 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
ui_id_icon_render(C, id, true);
}
else {
- WorkSpace *workspace = CTX_wm_workspace(C);
Object *ob = CTX_data_active_object(C);
const EnumPropertyItem *items = NULL;
ePaintMode paint_mode = PAINT_MODE_INVALID;
ScrArea *sa = CTX_wm_area(C);
char space_type = sa->spacetype;
- /* When in an unsupported space. */
- if (!ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE)) {
- space_type = workspace->tools_space_type;
+ /* Fallback to 3D view. */
+ if (space_type == SPACE_PROPERTIES) {
+ space_type = SPACE_VIEW3D;
}
/* XXX: this is not nice, should probably make brushes
@@ -1856,17 +1855,11 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
}
else if (space_type == SPACE_IMAGE) {
- int sima_mode;
if (sa->spacetype == space_type) {
- SpaceImage *sima = sa->spacedata.first;
- sima_mode = sima->mode;
- }
- else {
- sima_mode = workspace->tools_mode;
- }
-
- if (sima_mode == SI_MODE_PAINT) {
- paint_mode = PAINT_MODE_TEXTURE_2D;
+ const SpaceImage *sima = sa->spacedata.first;
+ if (sima->mode == SI_MODE_PAINT) {
+ paint_mode = PAINT_MODE_TEXTURE_2D;
+ }
}
}
diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h
index 49c709b972c..1fd5e6a952a 100644
--- a/source/blender/makesdna/DNA_workspace_types.h
+++ b/source/blender/makesdna/DNA_workspace_types.h
@@ -122,10 +122,7 @@ typedef struct WorkSpace {
/**
* BAD DESIGN WARNING:
* This is a workaround for the topbar not knowing which tools spec. */
- char tools_space_type;
- /** Type is different for each space-type. */
- char tools_mode;
- char _pad[2];
+ char _pad[4];
int object_mode;
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index dc0f02f22dd..f429415bee9 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -362,10 +362,6 @@ void WM_toolsystem_ref_set_from_runtime(struct bContext *C,
STRNCPY(tref->idname, idname);
- /* BAD DESIGN WARNING: used for topbar. */
- workspace->tools_space_type = tref->space_type;
- workspace->tools_mode = tref->mode;
-
if (tref->runtime == NULL) {
tref->runtime = MEM_callocN(sizeof(*tref->runtime), __func__);
}
@@ -558,31 +554,24 @@ void WM_toolsystem_refresh_active(bContext *C)
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- int mode_other = 0;
- enum { UNSET = -1, CHANGE = 0, MATCH = 1 } mode_match = UNSET;
/* Could skip loop for modes that don't depend on space type. */
+ int space_type_mask_handled = 0;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
/* Don't change the space type of the active tool, only update it's mode. */
- if (sa->spacetype == workspace->tools_space_type) {
- const int mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype);
- if (workspace->tools_mode == mode) {
- mode_match = MATCH;
- break;
- }
- else if (mode_match == -1) {
- mode_match = CHANGE;
- mode_other = mode;
+ const int space_type_mask = (1 << sa->spacetype);
+ if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) &&
+ ((space_type_mask_handled & space_type_mask) == 0)) {
+ space_type_mask_handled |= space_type_mask;
+ const bToolKey tkey = {
+ .space_type = sa->spacetype,
+ .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
+ };
+ bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
+ if (tref != sa->runtime.tool) {
+ toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
}
}
}
-
- if (mode_match == CHANGE) {
- const bToolKey tkey = {
- .space_type = workspace->tools_space_type,
- .mode = mode_other,
- };
- toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
- }
}
}
}