[Bf-blender-cvs] [86749a5] GPencil_EditStrokes: Tweaks for Delete Active Frame in GPencil UI

Joshua Leung noreply at git.blender.org
Thu Oct 23 08:36:09 CEST 2014


Commit: 86749a5f7c4749302a2bc9e2a2a29cf61bea7a8e
Author: Joshua Leung
Date:   Thu Oct 23 19:30:41 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rB86749a5f7c4749302a2bc9e2a2a29cf61bea7a8e

Tweaks for Delete Active Frame in GPencil UI

* Expose "delete active frame" directly in GP UI (alongside frame locking)
  instead of hiding in a submenu
* Deleting the active frame immediately makes the one before it active

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index e46f785..5ca2300 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -307,8 +307,8 @@ class GreasePencilDataPanel():
 
         layout.separator()
 
-        # Full-Row - Frame Locking
-        row = layout.row()
+        # Full-Row - Frame Locking (and Delete Frame)
+        row = layout.row(align=True)
         row.active = not gpl.lock
 
         if gpl.active_frame:
@@ -317,6 +317,7 @@ class GreasePencilDataPanel():
         else:
             lock_label = "Lock Frame"
         row.prop(gpl, "lock_frame", text=lock_label, icon='UNLOCKED')
+        row.operator("gpencil.active_frame_delete", text="", icon='X')
 
         layout.separator()
 
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index fc09400..b1234cb 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -493,16 +493,23 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
 bool gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
 {
 	bool changed = false;
-
+	
 	/* error checking */
 	if (ELEM(NULL, gpl, gpf))
 		return false;
-		
+	
+	/* if this frame was active, make the previous frame active instead 
+	 * since it's tricky to set active frame otherwise
+	 */
+	if (gpl->actframe == gpf)
+		gpl->actframe = gpf->prev;
+	else
+		gpl->actframe = NULL;
+	
 	/* free the frame and its data */
 	changed = free_gpencil_strokes(gpf);
 	BLI_freelinkN(&gpl->frames, gpf);
-	gpl->actframe = NULL;
-
+	
 	return changed;
 }




More information about the Bf-blender-cvs mailing list