Fix/Cleanup: I18N: Bad usage of IFACE_ instead of TIP_.
[blender.git] / source / blender / editors / gpencil / gpencil_primitive.c
index f178d2323765877c38750085db43fbf825b76cd3..b10801fc87f271f67e9a4d71ff6415b9e24e42fb 100644 (file)
@@ -129,8 +129,9 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
   gpd->runtime.sbuffer_sflag = 0;
   gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
 
-  if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE))
+  if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE)) {
     gpd->runtime.sbuffer_sflag |= GP_STROKE_CYCLIC;
+  }
 }
 
 static void gp_init_colors(tGPDprimitive *p)
@@ -174,16 +175,20 @@ static void gpencil_primitive_to_square(tGPDprimitive *tgpi, const float x, cons
   float w = fabsf(x);
   float h = fabsf(y);
   if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
-    if (w > h)
+    if (w > h) {
       tgpi->end[1] = tgpi->origin[1] + x;
-    else
+    }
+    else {
       tgpi->end[0] = tgpi->origin[0] + y;
+    }
   }
   else {
-    if (w > h)
+    if (w > h) {
       tgpi->end[1] = tgpi->origin[1] - x;
-    else
+    }
+    else {
       tgpi->end[0] = tgpi->origin[0] - y;
+    }
   }
 }
 
@@ -289,8 +294,9 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
   tgpi->point_count += (tgpi->type == GP_STROKE_BOX) ? (MAX_EDGES * 4 + 1) : (MAX_EDGES + 1);
   bGPDstroke *gpsf = tgpi->gpf->strokes.first;
   gpsf->points = MEM_reallocN(gpsf->points, sizeof(bGPDspoint) * tgpi->point_count);
-  if (gpsf->dvert != NULL)
+  if (gpsf->dvert != NULL) {
     gpsf->dvert = MEM_reallocN(gpsf->dvert, sizeof(MDeformVert) * tgpi->point_count);
+  }
   tgpi->points = MEM_reallocN(tgpi->points, sizeof(tGPspoint) * tgpi->point_count);
 }
 
@@ -299,21 +305,11 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
 /* Helper: Create internal strokes primitives data */
 static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
 {
-  ToolSettings *ts = CTX_data_tool_settings(C);
   Depsgraph *depsgraph = CTX_data_depsgraph(C);
   int cfra_eval = (int)DEG_get_ctime(depsgraph);
 
   bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
 
-  /* if brush doesn't exist, create a new one */
-  Paint *paint = &ts->gp_paint->paint;
-  /* if not exist, create a new one */
-  if (paint->brush == NULL) {
-    /* create new brushes */
-    BKE_brush_gpencil_presets(C);
-  }
-  tgpi->brush = paint->brush;
-
   /* if layer doesn't exist, create a new one */
   if (gpl == NULL) {
     gpl = BKE_gpencil_layer_addnew(tgpi->gpd, DATA_("Primitives"), true);
@@ -404,32 +400,32 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
 
   if (tgpi->type == GP_STROKE_LINE) {
     BLI_strncpy(msg_str,
-                IFACE_("Line: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to "
-                       "adjust subdivision number, Shift to align, Alt to center, E: extrude"),
+                TIP_("Line: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- to "
+                     "adjust subdivision number, Shift to align, Alt to center, E: extrude"),
                 UI_MAX_DRAW_STR);
   }
   else if (tgpi->type == GP_STROKE_BOX) {
     BLI_strncpy(msg_str,
-                IFACE_("Rectangle: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- "
-                       "to adjust subdivision number, Shift to square, Alt to center"),
+                TIP_("Rectangle: ESC to cancel, LMB set origin, Enter/MMB to confirm, WHEEL/+- "
+                     "to adjust subdivision number, Shift to square, Alt to center"),
                 UI_MAX_DRAW_STR);
   }
   else if (tgpi->type == GP_STROKE_CIRCLE) {
     BLI_strncpy(msg_str,
-                IFACE_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
-                       "number, Shift to square, Alt to center"),
+                TIP_("Circle: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
+                     "number, Shift to square, Alt to center"),
                 UI_MAX_DRAW_STR);
   }
   else if (tgpi->type == GP_STROKE_ARC) {
     BLI_strncpy(msg_str,
-                IFACE_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, "
-                       "Shift to square, Alt to center, M: Flip, E: extrude"),
+                TIP_("Arc: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge number, "
+                     "Shift to square, Alt to center, M: Flip, E: extrude"),
                 UI_MAX_DRAW_STR);
   }
   else if (tgpi->type == GP_STROKE_CURVE) {
     BLI_strncpy(msg_str,
-                IFACE_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
-                       "number, Shift to square, Alt to center, E: extrude"),
+                TIP_("Curve: ESC to cancel, Enter/MMB to confirm, WHEEL/+- to adjust edge "
+                     "number, Shift to square, Alt to center, E: extrude"),
                 UI_MAX_DRAW_STR);
   }
 
@@ -675,13 +671,16 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
   const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) &&
                          (tgpi->rv3d->persp == RV3D_CAMOB) && (!is_depth);
 
-  if (tgpi->type == GP_STROKE_BOX)
+  if (tgpi->type == GP_STROKE_BOX) {
     gps->totpoints = (tgpi->tot_edges * 4 + tgpi->tot_stored_edges);
-  else
+  }
+  else {
     gps->totpoints = (tgpi->tot_edges + tgpi->tot_stored_edges);
+  }
 
-  if (tgpi->tot_stored_edges)
+  if (tgpi->tot_stored_edges) {
     gps->totpoints--;
+  }
 
   tgpi->gpd->runtime.tot_cp_points = 0;
 
@@ -778,8 +777,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
 
           /* find first valid contact point */
           for (i = 0; i < gps->totpoints; i++) {
-            if (depth_arr[i] != FLT_MAX)
+            if (depth_arr[i] != FLT_MAX) {
               break;
+            }
           }
           first_valid = i;
 
@@ -789,8 +789,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
           }
           else {
             for (i = gps->totpoints - 1; i >= 0; i--) {
-              if (depth_arr[i] != FLT_MAX)
+              if (depth_arr[i] != FLT_MAX) {
                 break;
+              }
             }
             last_valid = i;
           }
@@ -1095,6 +1096,8 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
   Depsgraph *depsgraph = CTX_data_depsgraph(C);
+  Paint *paint = &ts->gp_paint->paint;
+
   int cfra_eval = (int)DEG_get_ctime(depsgraph);
 
   /* create temporary operator data */
@@ -1125,6 +1128,12 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
   /* region where paint was originated */
   tgpi->gpd->runtime.ar = tgpi->ar;
 
+  /* if brush doesn't exist, create a new set (fix damaged files from old versions) */
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
+    BKE_brush_gpencil_presets(C);
+  }
+  tgpi->brush = paint->brush;
+
   /* control points */
   tgpi->gpd->runtime.cp_points = MEM_callocN(sizeof(bGPDcontrolpoint) * MAX_CP,
                                              "gp primitive cpoint");
@@ -1325,16 +1334,18 @@ static void gpencil_primitive_edit_event_handling(
           float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
           tgpi->cp1[0] += dx;
           tgpi->cp1[1] += dy;
-          if (event->shift)
+          if (event->shift) {
             copy_v2_v2(tgpi->cp2, tgpi->cp1);
+          }
         }
         else if (tgpi->sel_cp == SELECT_CP2) {
           float dx = (tgpi->mval[0] - tgpi->mvalo[0]);
           float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
           tgpi->cp2[0] += dx;
           tgpi->cp2[1] += dy;
-          if (event->shift)
+          if (event->shift) {
             copy_v2_v2(tgpi->cp1, tgpi->cp2);
+          }
         }
         /* update screen */
         gpencil_primitive_update(C, op, tgpi);
@@ -1344,12 +1355,15 @@ static void gpencil_primitive_edit_event_handling(
     case LEFTMOUSE: {
       if ((event->val == KM_PRESS)) {
         /* find nearest cp based on stroke end points */
-        if (move == MOVE_ENDS)
+        if (move == MOVE_ENDS) {
           tgpi->sel_cp = (a < b) ? SELECT_START : SELECT_END;
-        else if (move == MOVE_CP)
+        }
+        else if (move == MOVE_CP) {
           tgpi->sel_cp = (c < d) ? SELECT_CP1 : SELECT_CP2;
-        else
+        }
+        else {
           tgpi->sel_cp = SELECT_NONE;
+        }
         break;
       }
       else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {