[Bf-blender-cvs] [50bdc83cda0] temp-gpencil-bezier-stroke-type: GPencil: Toggle end caps curves operator

Falk David noreply at git.blender.org
Mon Mar 15 00:36:26 CET 2021


Commit: 50bdc83cda0a8343699894dd02cda566176eebed
Author: Falk David
Date:   Sun Mar 14 20:04:43 2021 +0100
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB50bdc83cda0a8343699894dd02cda566176eebed

GPencil: Toggle end caps curves operator

===================================================================

M	source/blender/editors/gpencil/gpencil_edit.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index c7c390b3f4a..223522591df 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3559,6 +3559,7 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
 {
   bGPdata *gpd = ED_gpencil_data_get_active(C);
   Object *ob = CTX_data_active_object(C);
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
   const int type = RNA_enum_get(op->ptr, "type");
 
   /* sanity checks */
@@ -3569,45 +3570,55 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op)
   bool changed = false;
   /* loop all selected strokes */
   CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
-    if (gpl->actframe == NULL) {
-      continue;
-    }
+    bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
 
-    for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
-      MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
+    for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+      if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+        if (gpf == NULL) {
+          continue;
+        }
 
-      /* skip strokes that are not selected or invalid for current view */
-      if (((gps->flag & GP_STROKE_SELECT) == 0) || (ED_gpencil_stroke_can_use(C, gps) == false)) {
-        continue;
-      }
-      /* skip hidden or locked colors */
-      if (!gp_style || (gp_style->flag & GP_MATERIAL_HIDE) ||
-          (gp_style->flag & GP_MATERIAL_LOCKED)) {
-        continue;
-      }
+        LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+          MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
 
-      short prev_first = gps->caps[0];
-      short prev_last = gps->caps[1];
+          /* skip strokes that are not selected or invalid for current view */
+          bool is_stroke_selected = GPENCIL_STROKE_TYPE_BEZIER(gps) ?
+                                        (bool)(gps->editcurve->flag & GP_CURVE_SELECT) :
+                                        (bool)(gps->flag & GP_STROKE_SELECT);
 
-      if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) {
-        ++gps->caps[0];
-        if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
-          gps->caps[0] = GP_STROKE_CAP_ROUND;
-        }
-      }
-      if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) {
-        ++gps->caps[1];
-        if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
-          gps->caps[1] = GP_STROKE_CAP_ROUND;
-        }
-      }
-      if (type == GP_STROKE_CAPS_TOGGLE_DEFAULT) {
-        gps->caps[0] = GP_STROKE_CAP_ROUND;
-        gps->caps[1] = GP_STROKE_CAP_ROUND;
-      }
+          if (!is_stroke_selected) {
+            continue;
+          }
+          /* skip hidden or locked colors */
+          if (!gp_style || (gp_style->flag & GP_MATERIAL_HIDE) ||
+              (gp_style->flag & GP_MATERIAL_LOCKED)) {
+            continue;
+          }
 
-      if (prev_first != gps->caps[0] || prev_last != gps->caps[1]) {
-        changed = true;
+          short prev_first = gps->caps[0];
+          short prev_last = gps->caps[1];
+
+          if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) {
+            ++gps->caps[0];
+            if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
+              gps->caps[0] = GP_STROKE_CAP_ROUND;
+            }
+          }
+          if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) {
+            ++gps->caps[1];
+            if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
+              gps->caps[1] = GP_STROKE_CAP_ROUND;
+            }
+          }
+          if (type == GP_STROKE_CAPS_TOGGLE_DEFAULT) {
+            gps->caps[0] = GP_STROKE_CAP_ROUND;
+            gps->caps[1] = GP_STROKE_CAP_ROUND;
+          }
+
+          if (prev_first != gps->caps[0] || prev_last != gps->caps[1]) {
+            changed = true;
+          }
+        }
       }
     }
   }



More information about the Bf-blender-cvs mailing list