[Bf-blender-cvs] [1237e50c9ba] blender2.8: GP: Reorganize origin popover and top area

Antonioya noreply at git.blender.org
Thu Nov 1 17:05:32 CET 2018


Commit: 1237e50c9ba9a023ddb118ed9d1eedc1e5d7c08e
Author: Antonioya
Date:   Thu Nov 1 16:42:34 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB1237e50c9ba9a023ddb118ed9d1eedc1e5d7c08e

GP: Reorganize origin popover and top area

- Draw on back buttons moves near mode
- zDepth offset moved from View Panel to Popover
- Target for Stroke mode moved to popover
- New First point snap mode

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 3499411f632..1ca3d9adc2b 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -357,7 +357,6 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
 
         layout.prop(gpd, "use_force_fill_recalc", text="Force Fill Update")
         layout.prop(gpd, "use_adaptative_uv", text="Adaptative UVs")
-        layout.prop(gpd, "zdepth_offset", text="Surface Offset")
 
 
 class DATA_PT_gpencil_canvas(DataButtonsPanel, Panel):
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index d5a3c2a542b..1f931529800 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -210,13 +210,6 @@ class TOPBAR_HT_lower_bar(Header):
                     panel="TOPBAR_PT_gpencil_layers",
                     text=text,
                 )
-                if tool_mode == 'GPENCIL_PAINT':
-                    tool_settings = context.tool_settings
-                    layout.prop(tool_settings, "use_gpencil_draw_onback", text="", icon='MOD_OPACITY')
-                    layout.prop(tool_settings, "use_gpencil_weight_data_add", text="", icon='WPAINT_HLT')
-                    layout.prop(tool_settings, "use_gpencil_additive_drawing", text="", icon='FREEZE')
-                    if tool_settings.gpencil_stroke_placement_view3d == 'STROKE':
-                        layout.prop(tool_settings, "use_gpencil_stroke_endpoints", text="", icon='CURVE_DATA')
         elif tool_space_type == 'IMAGE_EDITOR':
             if tool_mode == 'PAINT':
                 layout.popover_group(space_type='PROPERTIES', region_type='WINDOW', context=".imagepaint_2d", category="")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 5188f565719..f18c49930e7 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -65,7 +65,12 @@ class VIEW3D_HT_header(Header):
             gpd = context.gpencil_data
 
             if gpd.is_stroke_paint_mode:
-                row = layout.row(align=True)
+                row = layout.row()
+                sub = row.row(align=True)
+                sub.prop(tool_settings, "use_gpencil_draw_onback", text="", icon='MOD_OPACITY')
+                sub.prop(tool_settings, "use_gpencil_weight_data_add", text="", icon='WPAINT_HLT')
+                sub.prop(tool_settings, "use_gpencil_additive_drawing", text="", icon='FREEZE')
+
                 row.popover(
                     panel="VIEW3D_PT_tools_grease_pencil_shapes",
                     text="Shapes"
@@ -4888,11 +4893,26 @@ class VIEW3D_PT_gpencil_origin(Panel):
 
     def draw(self, context):
         layout = self.layout
+        ts = context.tool_settings
+        gpd = context.gpencil_data
+
         layout.label(text="Stroke Placement")
 
         row = layout.row()
         col = row.column()
-        col.prop(context.tool_settings, "gpencil_stroke_placement_view3d", expand=True)
+        col.prop(ts, "gpencil_stroke_placement_view3d", expand=True)
+
+        if ts.gpencil_stroke_placement_view3d == 'SURFACE':
+            row = layout.row()
+            row.label(text="Offset")
+            row = layout.row()
+            row.prop(gpd, "zdepth_offset", text="")
+
+        if ts.gpencil_stroke_placement_view3d == 'STROKE':
+            row = layout.row()
+            row.label(text="Target")
+            row = layout.row()
+            row.prop(ts, "gpencil_stroke_snap_mode", expand=True)
 
 
 class VIEW3D_PT_gpencil_lock(Panel):
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 837b18d1e52..44d47d1354b 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1040,7 +1040,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 					depth_arr[i] = 0.9999f;
 			}
 			else {
-				if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
+				if ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) ||
+					(ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST))
+				{
 					int first_valid = 0;
 					int last_valid = 0;
 
@@ -1052,12 +1054,16 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 					first_valid = i;
 
 					/* find last valid contact point */
-					for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
-						if (depth_arr[i] != FLT_MAX)
-							break;
+					if (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_FIRST) {
+						last_valid = first_valid;
+					}
+					else {
+						for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
+							if (depth_arr[i] != FLT_MAX)
+								break;
+						}
+						last_valid = i;
 					}
-					last_valid = i;
-
 					/* invalidate any point other point, to interpolate between
 					 * first and last contact in an imaginary line between them */
 					for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index ebdce500d31..7d71f1250e3 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -2122,6 +2122,7 @@ typedef enum eGPencil_Placement_Flags {
 	/* "Use Endpoints" */
 	GP_PROJECT_DEPTH_STROKE_ENDPOINTS = (1 << 4),
 	GP_PROJECT_CURSOR = (1 << 5),
+	GP_PROJECT_DEPTH_STROKE_FIRST = (1 << 6),
 } eGPencil_Placement_Flags;
 
 /* ToolSettings.gpencil_selectmode */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index f505e446b2f..e5efdbc2054 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2229,6 +2229,13 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 		{0, NULL, 0, NULL, NULL}
 	};
 
+	static const EnumPropertyItem gpencil_stroke_snap_items[] = {
+		{0, "NONE", 0, "All points", "No snap"},
+		{GP_PROJECT_DEPTH_STROKE_ENDPOINTS, "ENDS", 0, "End points", "Snap to first and last points and interpolate" },
+		{GP_PROJECT_DEPTH_STROKE_FIRST, "FIRST", 0, "First point", "Snap to first point" },
+		{0, NULL, 0, NULL, NULL}
+	};
+	
 	static const EnumPropertyItem gpencil_selectmode_items[] = {
 		{GP_SELECTMODE_POINT, "POINT", ICON_GP_SELECT_POINTS, "Point", "Select only points"},
 		{GP_SELECTMODE_STROKE, "STROKE", ICON_GP_SELECT_STROKES, "Stroke", "Select all stroke points" },
@@ -2522,6 +2529,12 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 	RNA_def_property_ui_text(prop, "Stroke Placement (3D View)", "");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+	prop = RNA_def_property(srna, "gpencil_stroke_snap_mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v3d_align");
+	RNA_def_property_enum_items(prop, gpencil_stroke_snap_items);
+	RNA_def_property_ui_text(prop, "Stroke Snap", "");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
 	prop = RNA_def_property(srna, "use_gpencil_stroke_endpoints", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "gpencil_v3d_align", GP_PROJECT_DEPTH_STROKE_ENDPOINTS);
 	RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping");



More information about the Bf-blender-cvs mailing list