diff options
author | Julian Eisel <julian@blender.org> | 2020-05-26 21:32:21 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-05-26 21:32:21 +0300 |
commit | a2baf50242a315961fc7bc4d202a610442e813ec (patch) | |
tree | 843c01cc39d05b08c2e57fc1feddda31a17b0c23 /source/blender/editors/screen | |
parent | 1f223b9a1fcef8b6eb69af9e2def351e2255a08e (diff) |
Cleanup/refactor: Workspace API, boilerplate code, early exit
* Simplify workspace API a bit
* Comment on behavior of workspace-layout relations where exposed in API
* Remove annoying getters/setters
* Avoid lookups if we can early exit
* A NULL check is removed in `direct_link_workspace()` that I don't see
a need for. Am not 100% sure though, fingers crossed.
In general these changes should improve readability and make things
easier to reason about.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 9 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_layout_edit.c | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 8feef0c675a..3edc51b038b 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -109,9 +109,9 @@ static WorkSpaceLayout *workspace_change_get_new_layout(Main *bmain, layout_new = win->workspace_hook->temp_layout_store; } else { - layout_new = BKE_workspace_hook_layout_for_workspace_get(win->workspace_hook, workspace_new); + layout_new = BKE_workspace_active_layout_for_workspace_get(win->workspace_hook, workspace_new); if (!layout_new) { - layout_new = BKE_workspace_layouts_get(workspace_new)->first; + layout_new = workspace_new->layouts.first; } } screen_new = BKE_workspace_layout_screen_get(layout_new); @@ -163,7 +163,7 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager return false; } - BKE_workspace_hook_layout_for_workspace_set(win->workspace_hook, workspace_new, layout_new); + BKE_workspace_active_layout_set(win->workspace_hook, workspace_new, layout_new); BKE_workspace_active_set(win->workspace_hook, workspace_new); /* update screen *after* changing workspace - which also causes the @@ -188,7 +188,6 @@ bool ED_workspace_change(WorkSpace *workspace_new, bContext *C, wmWindowManager WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindow *win) { WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); - ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); WorkSpace *workspace_new = ED_workspace_add(bmain, workspace_old->id.name + 2); workspace_new->flags = workspace_old->flags; @@ -198,7 +197,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo /* TODO(campbell): tools */ - LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, &workspace_old->layouts) { WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( bmain, workspace_new, layout_old, win); diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c index cf9637788a9..7ce92bc3e4d 100644 --- a/source/blender/editors/screen/workspace_layout_edit.c +++ b/source/blender/editors/screen/workspace_layout_edit.c @@ -140,7 +140,7 @@ bool ED_workspace_layout_delete(WorkSpace *workspace, WorkSpaceLayout *layout_ol const bScreen *screen_old = BKE_workspace_layout_screen_get(layout_old); WorkSpaceLayout *layout_new; - BLI_assert(BLI_findindex(BKE_workspace_layouts_get(workspace), layout_old) != -1); + BLI_assert(BLI_findindex(&workspace->layouts, layout_old) != -1); /* don't allow deleting temp fullscreens for now */ if (BKE_screen_is_fullscreen_area(screen_old)) { |