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:
authorAntonio Vazquez <antoniov>2019-10-10 09:11:47 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-10-10 09:13:32 +0300
commitea1174bde9edff7639b1b3de4989084987a29f1e (patch)
treea10a6fd93460bc278f071db5000a3b920fe60518 /source/blender/editors/space_view3d
parent7e020e70d9ce5e970ff12313f5565e13545058bb (diff)
Annotations: Use flag to determine if the layer is a Ruler
Proposed fix for T70141. Before, the ruler was using the name of the layer as key, but this is very weak because if the layer name changes, the layer gets an annotation layer. Now, the layer is marked using a flag and now it's possible to rename it. Reviewed By: dfelinto Differential Revision: https://developer.blender.org/D6028
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index 5625333d837..a5b7fac624d 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -407,6 +407,17 @@ static bool view3d_ruler_item_mousemove(RulerInfo *ruler_info,
/** \name Ruler/Grease Pencil Conversion
* \{ */
+/* Helper: Find the layer created as ruler. */
+static bGPDlayer *view3d_ruler_layer_get(bGPdata *gpd)
+{
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ if (gpl->flag & GP_LAYER_IS_RULER) {
+ return gpl;
+ }
+ }
+ return NULL;
+}
+
#define RULER_ID "RulerData3D"
static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup)
{
@@ -427,12 +438,12 @@ static bool view3d_ruler_to_gpencil(bContext *C, wmGizmoGroup *gzgroup)
}
gpd = scene->gpd;
- gpl = BLI_findstring(&gpd->layers, ruler_name, offsetof(bGPDlayer, info));
+ gpl = view3d_ruler_layer_get(gpd);
if (gpl == NULL) {
gpl = BKE_gpencil_layer_addnew(gpd, ruler_name, false);
copy_v4_v4(gpl->color, U.gpencil_new_layer_col);
gpl->thickness = 1;
- gpl->flag |= GP_LAYER_HIDE;
+ gpl->flag |= GP_LAYER_HIDE | GP_LAYER_IS_RULER;
}
gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW);
@@ -485,8 +496,7 @@ static bool view3d_ruler_from_gpencil(const bContext *C, wmGizmoGroup *gzgroup)
if (scene->gpd) {
bGPDlayer *gpl;
- const char *ruler_name = RULER_ID;
- gpl = BLI_findstring(&scene->gpd->layers, ruler_name, offsetof(bGPDlayer, info));
+ gpl = view3d_ruler_layer_get(scene->gpd);
if (gpl) {
bGPDframe *gpf;
gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);