[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15733] trunk/blender/source/blender: == Grease Pencil - More Tweaks (I) ==

Joshua Leung aligorith at gmail.com
Thu Jul 24 11:23:14 CEST 2008


Revision: 15733
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15733
Author:   aligorith
Date:     2008-07-24 11:23:13 +0200 (Thu, 24 Jul 2008)

Log Message:
-----------
== Grease Pencil - More Tweaks (I) ==

New Stuff:
* Alt-XKEY / Alt-DelKey will now activate the Grease Pencil "Erase" menu. This will only show up when it's relevant (i.e. when there exists Grease Pencil data). It should make it faster to quickly delete the last stroke made. This hotkey has been added to the tooltips of the relevant buttons.
* Finished off colouring of 'active' layers panel so that they are now easily identify-able. This could also be done for Constraints, but the 'active' one isn't that important there.

Bugfixes:
* Fixed bug with drawing gp-data sources in the Action Editor, which resulted in missing icons.
* Fixed buttons in Grease Pencil panel. My hasty attempt last night at making the Action Editor to refresh was causing problems.
* Added a (hopefully temporary) button that will be used to prevent drawing from occurring with Shift-LMB. This is useful when trying to select stuff sometimes, with LMB as select-button, especially when selecting a bunch of closely spaced bones might be interpreted as a new stroke.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/drawgpencil.c
    trunk/blender/source/blender/src/editnode.c
    trunk/blender/source/blender/src/gpencil.c
    trunk/blender/source/blender/src/interface_draw.c
    trunk/blender/source/blender/src/space.c

Modified: trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_gpencil_types.h	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/makesdna/DNA_gpencil_types.h	2008-07-24 09:23:13 UTC (rev 15733)
@@ -127,12 +127,12 @@
 } bGPdata;
 
 /* bGPdata->flag */
-	/* draw this datablock's data (not used) */
-#define GP_DATA_DISP		(1<<0)
+	/* don't allow painting to occur at all */
+#define GP_DATA_LMBPLOCK	(1<<0)
 	/* show debugging info in viewport (i.e. status print) */
 #define GP_DATA_DISPINFO	(1<<1)
 	/* in Action Editor, show as expanded channel */
-#define GP_DATA_EXPAND	(1<<2)
+#define GP_DATA_EXPAND		(1<<2)
 	/* is the block overriding all clicks? */
 #define GP_DATA_EDITPAINT	(1<<3)
 	/* new strokes are added in viewport space */

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/drawaction.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -646,7 +646,7 @@
 						case SPACE_VIEW3D:
 						{
 							/* this shouldn't cause any overflow... */
-							sprintf(name, "3D-View: <%s>", view3d_get_name(sa->spacedata.first));
+							sprintf(name, "3DView: %s", view3d_get_name(sa->spacedata.first));
 							special= ICON_VIEW3D;
 						}
 							break;
@@ -684,8 +684,10 @@
 							break;
 						
 						default:
-							sprintf(name, "GP-Data");
+						{
+							sprintf(name, "<Unknown GP-Data Source>");
 							special= -1;
+						}
 							break;
 					}
 				}
@@ -775,13 +777,19 @@
 				offset += 17;
 			}
 			
-			/* draw special icon indicating type of ipo-blocktype? 
-			 * 	only for expand widgets for Ipo and Constraint Channels 
-			 */
-			if (special > 0) {
-				offset = (group) ? 29 : 24;
-				BIF_icon_draw(x+offset, yminc, special);
-				offset += 17;
+			/* draw special icon indicating certain data-types */
+			if (special > -1) {
+				if (group == 3) {
+					/* for gpdatablock channels */
+					BIF_icon_draw(x+offset, yminc, special);
+					offset += 17;
+				}
+				else {
+					/* for ipo/constraint channels */
+					offset = (group) ? 29 : 24;
+					BIF_icon_draw(x+offset, yminc, special);
+					offset += 17;
+				}
 			}
 				
 			/* draw name */
@@ -797,13 +805,13 @@
 			offset = 0;
 			
 			/* draw protect 'lock' */
-			if (protect > 0) {
+			if (protect > -1) {
 				offset = 16;
 				BIF_icon_draw(NAMEWIDTH-offset, yminc, protect);
 			}
 			
 			/* draw mute 'eye' */
-			if (mute > 0) {
+			if (mute > -1) {
 				offset += 16;
 				BIF_icon_draw(NAMEWIDTH-offset, yminc, mute);
 			}

Modified: trunk/blender/source/blender/src/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/src/drawgpencil.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/drawgpencil.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -94,7 +94,7 @@
 void gp_ui_activelayer_cb (void *gpd, void *gpl)
 {
 	gpencil_layer_setactive(gpd, gpl);
-	force_draw_plus(SPACE_ACTION, 0);
+	allqueue(REDRAWACTION, 0);
 }
 
 /* rename layer and set active */
@@ -105,21 +105,21 @@
 	
 	BLI_uniquename(&gpd->layers, gpl, "GP_Layer", offsetof(bGPDlayer, info[0]), 128);
 	gpencil_layer_setactive(gpd, gpl);
-	force_draw_plus(SPACE_ACTION, 0);
+	allqueue(REDRAWACTION, 0);
 }
 
 /* add a new layer */
 void gp_ui_addlayer_cb (void *gpd, void *dummy)
 {
 	gpencil_layer_addnew(gpd);
-	force_draw_plus(SPACE_ACTION, 0);
+	allqueue(REDRAWACTION, 0);
 }
 
 /* delete active layer */
 void gp_ui_dellayer_cb (void *gpd, void *dummy)
 {
 	gpencil_layer_delactive(gpd);
-	force_draw_plus(SPACE_ACTION, 0);
+	allqueue(REDRAWACTION, 0);
 }
 
 /* delete last stroke of active layer */
@@ -139,7 +139,7 @@
 	gpencil_layer_setactive(gpd, gpl);
 	gpencil_layer_delframe(gpl, gpf);
 	
-	force_draw_plus(SPACE_ACTION, 0);
+	allqueue(REDRAWACTION, 0);
 }
 
 /* ------- Drawing Code ------- */
@@ -148,6 +148,7 @@
 static void gp_drawui_layer (uiBlock *block, bGPdata *gpd, bGPDlayer *gpl, short *xco, short *yco)
 {
 	uiBut *but;
+	short active= (gpl->flag & GP_LAYER_ACTIVE);
 	short width= 314;
 	short height;
 	int rb_col;
@@ -160,10 +161,10 @@
 		uiBlockSetEmboss(block, UI_EMBOSSN);
 		
 		/* rounded header */
-		//uiBlockSetCol(block, TH_BUT_SETTING1); // FIXME: maybe another color
-			rb_col= (gpl->flag & GP_LAYER_ACTIVE)?50:20;
+		if (active) uiBlockSetCol(block, TH_BUT_ACTION);
+			rb_col= (active)?-20:20;
 			uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15 , rb_col-20, ""); 
-		//uiBlockSetCol(block, TH_AUTO);
+		if (active) uiBlockSetCol(block, TH_AUTO);
 		
 		/* lock toggle */
 		uiDefIconButBitI(block, ICONTOG, GP_LAYER_LOCKED, B_REDR, ICON_UNLOCKED,	*xco-7, *yco-1, 20, 20, &gpl->flag, 0.0, 0.0, 0, 0, "Layer cannot be modified");
@@ -212,9 +213,9 @@
 		}
 		
 		/* draw backdrop */
-		//uiBlockSetCol(block, TH_BUT_SETTING1); // fixme: maybe another color
+		if (active) uiBlockSetCol(block, TH_BUT_ACTION);
 			uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-8, *yco-height, width, height-1, NULL, 5.0, 0.0, 12, rb_col, ""); 
-		//uiBlockSetCol(block, TH_AUTO);
+		if (active) uiBlockSetCol(block, TH_AUTO);
 		
 		/* draw settings */
 		{
@@ -235,12 +236,14 @@
 			uiBlockEndAlign(block);
 			
 			/* options */
-			but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer");
-			uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl);
+			uiBlockBeginAlign(block);
+				but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer (Hotkey = Alt-XKEY/DEL)");
+				uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl);
+				
+				but= uiDefBut(block, BUT, B_REDR, "Del Last Stroke", *xco+160, *yco-95, 140, 20, NULL, 0, 0, 0, 0, "Erases the last stroke from the active frame (Hotkey = Alt-XKEY/DEL)");
+				uiButSetFunc(but, gp_ui_delstroke_cb, gpd, gpl);
+			uiBlockEndAlign(block);
 			
-			but= uiDefBut(block, BUT, B_REDR, "Del Last Stroke", *xco+160, *yco-95, 140, 20, NULL, 0, 0, 0, 0, "Erases the last stroke from the active frame");
-			uiButSetFunc(but, gp_ui_delstroke_cb, gpd, gpl);
-			
 			//uiDefButBitI(block, TOG, GP_LAYER_DRAWDEBUG, B_REDR, "Show Points", *xco+160, *yco-75, 130, 20, &gpl->flag, 0, 0, 0, 0, "Show points which form the strokes");
 		}
 	}
@@ -268,8 +271,14 @@
 		uiButSetFunc(but, gp_ui_addlayer_cb, gpd, NULL);
 		
 		
-		/* show override lmb-clicks button */
-		uiDefButBitI(block, TOG, GP_DATA_EDITPAINT, B_REDR, "Draw Mode", 170, 225, 150, 20, &gpd->flag, 0, 0, 0, 0, "Interpret LMB-click as new strokes (same as holding Shift-Key per stroke)");
+		/* show override lmb-clicks button + painting lock */
+		uiBlockBeginAlign(block);
+			uiDefButBitI(block, TOG, GP_DATA_EDITPAINT, B_REDR, "Draw Mode", 170, 225, 130, 20, &gpd->flag, 0, 0, 0, 0, "Interpret LMB-click as new strokes (same as holding Shift-Key per stroke)");
+			
+			uiBlockSetCol(block, TH_BUT_SETTING);
+				uiDefIconButBitI(block, ICONTOG, GP_DATA_LMBPLOCK, B_REDR, ICON_UNLOCKED,	300, 225, 20, 20, &gpd->flag, 0.0, 0.0, 0, 0, "Painting cannot occur with Shift-LMB (when making selections)");
+			uiBlockSetCol(block, TH_AUTO);
+		uiBlockEndAlign(block);
 		
 		/* 'view align' button (naming depends on context) */
 		if (sa->spacetype == SPACE_VIEW3D)

Modified: trunk/blender/source/blender/src/editnode.c
===================================================================
--- trunk/blender/source/blender/src/editnode.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/editnode.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -2568,8 +2568,13 @@
 			break;
 		case DELKEY:
 		case XKEY:
-			if(fromlib) fromlib= -1;
-			else node_delete(snode);
+			if(G.qual==LR_ALTKEY) {
+				gpencil_delete_menu();
+			}
+			else {
+				if(fromlib) fromlib= -1;
+				else node_delete(snode);
+			}
 			break;
 		}
 	}

Modified: trunk/blender/source/blender/src/gpencil.c
===================================================================
--- trunk/blender/source/blender/src/gpencil.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/gpencil.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -616,7 +616,7 @@
  *		 	2 - active frame
  *			3 - active layer
  */
-void gpencil_delete_operation (short mode) // unused
+void gpencil_delete_operation (short mode)
 {
 	bGPdata *gpd;
 	
@@ -642,11 +642,15 @@
 }
 
 /* display a menu for deleting different grease-pencil elements */
-void gpencil_delete_menu (void) // unused
+void gpencil_delete_menu (void)
 {
+	bGPdata *gpd= gpencil_data_getactive(NULL);
 	short mode;
 	
-	mode= pupmenu("Erase...%t|Last Stroke%x1|Active Frame%x2|Active Layer%x3");
+	/* only show menu if it will be relevant */
+	if (gpd == NULL) return;
+	
+	mode= pupmenu("Grease Pencil Erase...%t|Last Stroke%x1|Active Frame%x2|Active Layer%x3");
 	if (mode <= 0) return;
 	
 	gpencil_delete_operation(mode);
@@ -1173,7 +1177,7 @@
 		/* try to paint */
 		retval = gpencil_paint(mousebutton);
 	}
-	else if (G.qual == LR_SHIFTKEY) {
+	else if (!(gpd->flag & GP_DATA_LMBPLOCK) && (G.qual == LR_SHIFTKEY)) {
 		/* try to paint */
 		retval = gpencil_paint(mousebutton);
 	}

Modified: trunk/blender/source/blender/src/interface_draw.c
===================================================================
--- trunk/blender/source/blender/src/interface_draw.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/interface_draw.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -2351,7 +2351,6 @@
 {
 	glEnable(GL_BLEND);
 	
-	//BIF_ThemeColorShadeAlpha(TH_PANEL, but->a2, but->a2);
 	BIF_ThemeColorShadeAlpha(but->themecol, but->a2, but->a2);
 
 	uiSetRoundBox(but->a1);

Modified: trunk/blender/source/blender/src/space.c
===================================================================
--- trunk/blender/source/blender/src/space.c	2008-07-24 08:29:48 UTC (rev 15732)
+++ trunk/blender/source/blender/src/space.c	2008-07-24 09:23:13 UTC (rev 15733)
@@ -2711,6 +2711,8 @@
 			case DELKEY:
 				if(G.qual==0 || G.qual==LR_SHIFTKEY)
 					delete_context_selected();
+				if(G.qual==LR_ALTKEY)
+					gpencil_delete_menu();
 				break;
 			case YKEY:
 				if((G.qual==0) && (G.obedit)) {
@@ -5099,6 +5101,10 @@
 				if((G.qual==0))
 					del_seq();
 			}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list