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
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2017-06-01 21:41:18 +0300
committerJulian Eisel <eiseljulian@gmail.com>2017-06-01 21:46:18 +0300
commit46fc0bb87ebda166d08b23cbcca799acb2c54158 (patch)
tree1566d535d93c4fb81b962cdbc1346ca8242460f2 /source/blender/blenkernel/intern/workspace.c
parent7f564d74f9edaaa41ce27c6e854869096f70b4da (diff)
Move custom transform orientations to workspace
This commit moves the list of transform orientations from scenes to workspaces. Main reasons for this are: * Transform orientations are UI data and should not be stored in the scene. * Introducion of workspaces caused some (expected) glitches with transform orientations. Mainly when removing one. * Improves code. More technically speaking, this commit does: * Move list of custom transform orientations from Scene to WorkSpace struct. * Store active transform orientation index separate from View3D.twmode (twmode can only be set to preprocessor defined values now). * Display custom transform orientation name in header when transforming in it (used to show "global" which isn't really correct).
Diffstat (limited to 'source/blender/blenkernel/intern/workspace.c')
-rw-r--r--source/blender/blenkernel/intern/workspace.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 8afad317dce..82fface7d06 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -35,6 +35,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_screen.h"
#include "BKE_workspace.h"
#include "DNA_object_types.h"
@@ -150,6 +151,7 @@ void BKE_workspace_free(WorkSpace *workspace)
workspace_relation_remove(&workspace->hook_layout_relations, relation);
}
BLI_freelistN(&workspace->layouts);
+ BLI_freelistN(&workspace->transform_orientations);
}
void BKE_workspace_remove(Main *bmain, WorkSpace *workspace)
@@ -223,6 +225,31 @@ void BKE_workspace_layout_remove(
/* -------------------------------------------------------------------- */
/* General Utils */
+void BKE_workspace_transform_orientation_remove(
+ WorkSpace *workspace, TransformOrientation *orientation)
+{
+ for (WorkSpaceLayout *layout = workspace->layouts.first; layout; layout = layout->next) {
+ BKE_screen_transform_orientation_remove(BKE_workspace_layout_screen_get(layout), workspace, orientation);
+ }
+
+ BLI_freelinkN(&workspace->transform_orientations, orientation);
+}
+
+TransformOrientation *BKE_workspace_transform_orientation_find(
+ const WorkSpace *workspace, const int index)
+{
+ return BLI_findlink(&workspace->transform_orientations, index);
+}
+
+/**
+ * \return the index that \a orientation has within \a workspace's transform-orientation list or -1 if not found.
+ */
+int BKE_workspace_transform_orientation_get_index(
+ const WorkSpace *workspace, const TransformOrientation *orientation)
+{
+ return BLI_findindex(&workspace->transform_orientations, orientation);
+}
+
WorkSpaceLayout *BKE_workspace_layout_find(
const WorkSpace *workspace, const bScreen *screen)
{
@@ -240,6 +267,7 @@ WorkSpaceLayout *BKE_workspace_layout_find(
/**
* Find the layout for \a screen without knowing which workspace to look in.
+ * Can also be used to find the workspace that contains \a screen.
*
* \param r_workspace: Optionally return the workspace that contains the looked up layout (if found).
*/
@@ -353,6 +381,11 @@ void BKE_workspace_object_mode_set(WorkSpace *workspace, const ObjectMode mode)
}
#endif
+ListBase *BKE_workspace_transform_orientations_get(WorkSpace *workspace)
+{
+ return &workspace->transform_orientations;
+}
+
SceneLayer *BKE_workspace_render_layer_get(const WorkSpace *workspace)
{
return workspace->render_layer;