[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22839] branches/blender2.5/blender/source /blender: Grease Pencil: WIP Code Reordering + Context Stuff

Joshua Leung aligorith at gmail.com
Fri Aug 28 14:41:46 CEST 2009


Revision: 22839
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22839
Author:   aligorith
Date:     2009-08-28 14:41:45 +0200 (Fri, 28 Aug 2009)

Log Message:
-----------
Grease Pencil: WIP Code Reordering + Context Stuff

* Shuffled some code around, and renamed some functions used for getting context info
- Split UI-buttons into a separate file from stroke-drawing code
- Removed some obsolete code (i.e. old paint code that used to be in _edit, but which has been moved to _paint). 

* Made drawing in 3D-View default to using the active object as the owner of the Grease Pencil data. For now, the drawing code will therefore only show the GP data for the active object only. More work to come on this.

* Fixed freeing code for Objects/Scenes with GP data.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
    branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_edit.c
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_paint.c
    branches/blender2.5/blender/source/blender/editors/include/ED_gpencil.h
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_object_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_object.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil_buttons.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/object.c	2009-08-28 12:38:59 UTC (rev 22838)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/object.c	2009-08-28 12:41:45 UTC (rev 22839)
@@ -284,6 +284,7 @@
 	if(ob->adt) BKE_free_animdata((ID *)ob);
 	if(ob->poselib) ob->poselib->id.us--;
 	if(ob->dup_group) ob->dup_group->id.us--;
+	if(ob->gpd) ob->gpd->id.us--;
 	if(ob->defbase.first)
 		BLI_freelistN(&ob->defbase);
 	if(ob->pose)

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-08-28 12:38:59 UTC (rev 22838)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2009-08-28 12:41:45 UTC (rev 22839)
@@ -245,6 +245,11 @@
 		base= base->next;
 	}
 	/* do not free objects! */
+	
+	if(sce->gpd) {
+		sce->gpd->id.us--;
+		sce->gpd= NULL;
+	}
 
 	BLI_freelistN(&sce->base);
 	seq_free_editing(sce);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-28 12:38:59 UTC (rev 22838)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-08-28 12:41:45 UTC (rev 22839)
@@ -3449,6 +3449,8 @@
 			}
 			for(a=0; a<ob->totcol; a++) ob->mat[a]= newlibadr_us(fd, ob->id.lib, ob->mat[a]);
 			
+			ob->gpd= newlibadr_us(fd, ob->id.lib, ob->gpd);
+			
 			ob->id.flag -= LIB_NEEDLINK;
 			/* if id.us==0 a new base will be created later on */
 			
@@ -10418,6 +10420,8 @@
 	expand_doit(fd, mainvar, ob->poselib);
 	expand_constraints(fd, mainvar, &ob->constraints);
 	
+	expand_doit(fd, mainvar, ob->gpd);
+	
 // XXX depreceated - old animation system (for version patching only) 
 	expand_doit(fd, mainvar, ob->ipo);
 	expand_doit(fd, mainvar, ob->action);

Modified: branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c	2009-08-28 12:38:59 UTC (rev 22838)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c	2009-08-28 12:41:45 UTC (rev 22839)
@@ -885,7 +885,7 @@
 		for (sa= sc->areabase.first; sa; sa= sa->next) {
 			/* try to get gp data */
 			// XXX need to put back grease pencil api...
-			gpd= gpencil_data_getactive(sa);
+			gpd= gpencil_data_get_active(sa);
 			if (gpd == NULL) continue;
 			
 			/* add gpd as channel too (if for drawing, and it has layers) */

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-28 12:38:59 UTC (rev 22838)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-28 12:41:45 UTC (rev 22839)
@@ -67,279 +67,12 @@
 #include "ED_sequencer.h"
 #include "ED_util.h"
 
-#include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
 #include "gpencil_intern.h"
 
 /* ************************************************** */
-/* GREASE PENCIL PANEL-UI DRAWING */
-
-/* Every space which implements Grease-Pencil functionality should have a panel
- * for the settings. All of the space-dependent parts should be coded in the panel
- * code for that space, but the rest is all handled by generic panel here.
- */
-
-/* ------- Callbacks ----------- */
-/* These are just 'dummy wrappers' around gpencil api calls */
-
-#if 0
-// XXX
-/* make layer active one after being clicked on */
-void gp_ui_activelayer_cb (void *gpd, void *gpl)
-{
-	gpencil_layer_setactive(gpd, gpl);
-	
-	scrarea_queue_winredraw(curarea);
-	allqueue(REDRAWACTION, 0);
-}
-
-/* rename layer and set active */
-void gp_ui_renamelayer_cb (void *gpd_arg, void *gpl_arg)
-{
-	bGPdata *gpd= (bGPdata *)gpd_arg;
-	bGPDlayer *gpl= (bGPDlayer *)gpl_arg;
-	
-	BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), 128);
-	gpencil_layer_setactive(gpd, gpl);
-	
-	scrarea_queue_winredraw(curarea);
-	allqueue(REDRAWACTION, 0);
-}
-
-/* add a new layer */
-void gp_ui_addlayer_cb (void *gpd, void *dummy)
-{
-	gpencil_layer_addnew(gpd);
-	
-	scrarea_queue_winredraw(curarea);
-	allqueue(REDRAWACTION, 0);
-}
-
-/* delete active layer */
-void gp_ui_dellayer_cb (void *gpd, void *dummy)
-{
-	gpencil_layer_delactive(gpd);
-	
-	scrarea_queue_winredraw(curarea);
-	allqueue(REDRAWACTION, 0);
-}
-
-/* delete last stroke of active layer */
-void gp_ui_delstroke_cb (void *gpd, void *gpl)
-{
-	bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
-	
-	if (gpf) {
-		if (gpf->framenum != CFRA) return;
-
-		gpencil_layer_setactive(gpd, gpl);
-		gpencil_frame_delete_laststroke(gpl, gpf);
-		
-		scrarea_queue_winredraw(curarea);
-	}
-}
-
-/* delete active frame of active layer */
-void gp_ui_delframe_cb (void *gpd, void *gpl)
-{
-	bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
-	
-	gpencil_layer_setactive(gpd, gpl);
-	gpencil_layer_delframe(gpl, gpf);
-	
-	scrarea_queue_winredraw(curarea);
-	allqueue(REDRAWACTION, 0);
-}
-
-/* convert the active layer to geometry */
-void gp_ui_convertlayer_cb (void *gpd, void *gpl)
-{
-	gpencil_layer_setactive(gpd, gpl);
-	gpencil_convert_menu();
-	
-	scrarea_queue_winredraw(curarea);
-}
-#endif
-
-/* ------- Drawing Code ------- */
-
-#if 0
-/* XXX */
-/* draw the controls for a given layer */
-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;
-	
-	/* unless button has own callback, it adds this callback to button */
-	uiBlockSetFunc(block, gp_ui_activelayer_cb, gpd, gpl);
-	
-	/* draw header */
-	{
-		uiBlockSetEmboss(block, UI_EMBOSSN);
-		
-		/* rounded header */
-		if (active) uiBlockSetCol(block, TH_BUT_ACTION);
-			rb_col= (active)?-20:20;
-			uiDefBut(block, ROUNDBOX, B_REDR, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15.0, (float)(rb_col-20), ""); 
-		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");
-	}
-	
-	/* when layer is locked or hidden, only draw header */
-	if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) {
-		char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */
-		
-		height= 0;
-		
-		/* visibility button (only if hidden but not locked!) */
-		if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED))
-			uiDefIconButBitI(block, ICONTOG, GP_LAYER_HIDE, B_REDR, ICON_RESTRICT_VIEW_OFF,	*xco+12, *yco-1, 20, 20, &gpl->flag, 0.0, 0.0, 0, 0, "Visibility of layer");
-		
-		/* name */
-		if (gpl->flag & GP_LAYER_HIDE)
-			sprintf(name, "%s (Hidden)", gpl->info);
-		else
-			sprintf(name, "%s (Locked)", gpl->info);
-		uiDefBut(block, LABEL, 1, name,	*xco+35, *yco, 240, 20, NULL, 0.0, 0.0, 0, 0, "Short description of what this layer is for (optional)");
-			
-		/* delete button (only if hidden but not locked!) */
-		if ((gpl->flag & GP_LAYER_HIDE) & !(gpl->flag & GP_LAYER_LOCKED)) {
-			but= uiDefIconBut(block, BUT, B_REDR, ICON_X, *xco+(width-30), *yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Delete layer");
-			uiButSetFunc(but, gp_ui_dellayer_cb, gpd, NULL);
-		}	
-		uiBlockSetEmboss(block, UI_EMBOSS);
-	}
-	else {
-		height= 97;
-		
-		/* draw rest of header */
-		{
-			/* visibility button */
-			uiDefIconButBitI(block, ICONTOG, GP_LAYER_HIDE, B_REDR, ICON_RESTRICT_VIEW_OFF,	*xco+12, *yco-1, 20, 20, &gpl->flag, 0.0, 0.0, 0, 0, "Visibility of layer");
-			
-			uiBlockSetEmboss(block, UI_EMBOSS);
-			
-			/* name */
-			but= uiDefButC(block, TEX, B_REDR, "Info:",	*xco+36, *yco, 240, 19, gpl->info, 0, 127, 0, 0, "Short description of what this layer is for (optional)");
-			uiButSetFunc(but, gp_ui_renamelayer_cb, gpd, gpl);
-			
-			/* delete 'button' */
-			uiBlockSetEmboss(block, UI_EMBOSSN);
-			
-			but= uiDefIconBut(block, BUT, B_REDR, ICON_X, *xco+(width-30), *yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Delete layer");
-			uiButSetFunc(but, gp_ui_dellayer_cb, gpd, NULL);
-			
-			uiBlockSetEmboss(block, UI_EMBOSS);
-		}
-		
-		/* draw backdrop */
-		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.0, (float)rb_col, ""); 
-		if (active) uiBlockSetCol(block, TH_AUTO);
-		
-		/* draw settings */
-		{
-			/* color */
-			uiBlockBeginAlign(block);
-				uiDefButF(block, COL, B_REDR, "",		*xco, *yco-26, 150, 19, gpl->color, 0, 0, 0, 0, "Color to use for all strokes on this Grease Pencil Layer");
-				uiDefButF(block, NUMSLI, B_REDR, "Opacity: ",		*xco,*yco-45,150,19, &gpl->color[3], 0.3f, 1.0f, 0, 0, "Visibility of stroke (0.3 to 1.0)");
-			uiBlockEndAlign(block);
-			
-			/* stroke thickness */
-			uiDefButS(block, NUMSLI, B_REDR, "Thickness:",	*xco, *yco-75, 150, 20, &gpl->thickness, 1, 10, 0, 0, "Thickness of strokes (in pixels)");
-			
-			/* debugging options */
-			if (G.f & G_DEBUG) {
-				uiDefButBitI(block, TOG, GP_LAYER_DRAWDEBUG, B_REDR, "Show Points", *xco, *yco-95, 150, 20, &gpl->flag, 0, 0, 0, 0, "Show points which form the strokes");
-			}
-			
-			/* onion-skinning */
-			uiBlockBeginAlign(block);
-				uiDefButBitI(block, TOG, GP_LAYER_ONIONSKIN, B_REDR, "Onion-Skin", *xco+160, *yco-26, 140, 20, &gpl->flag, 0, 0, 0, 0, "Ghost frames on either side of frame");
-				uiDefButS(block, NUMSLI, B_REDR, "GStep:",	*xco+160, *yco-46, 140, 20, &gpl->gstep, 0, 120, 0, 0, "Max number of frames on either side of active frame to show (0 = just 'first' available sketch on either side)");
-			uiBlockEndAlign(block);
-			
-			/* options */
-			uiBlockBeginAlign(block);
-				if (curarea->spacetype == SPACE_VIEW3D) {
-					but= uiDefBut(block, BUT, B_REDR, "Convert to...", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Converts this layer's strokes to geometry (Hotkey = Alt-Shift-C)");
-					uiButSetFunc(but, gp_ui_convertlayer_cb, gpd, gpl);
-				}
-				else {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list