[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15541] trunk/blender/source/blender: == Action Editor - NKEY Properties Panel ==

Joshua Leung aligorith at gmail.com
Sat Jul 12 07:00:37 CEST 2008


Revision: 15541
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15541
Author:   aligorith
Date:     2008-07-12 07:00:37 +0200 (Sat, 12 Jul 2008)

Log Message:
-----------
== Action Editor - NKEY Properties Panel ==

When the NKEY is pressed in the Action Editor while hovering over the keyframes area, a floating properties panel can now be accessed. It shows relevant properties for the active channel, however this is currently only for Action Groups. Action Channel support will come later.

The key benefit of this panel is that it is now possible to edit the colour set used by a group. Also, there is a button for selecting all the channels in that group (which can also be done by simply Ctrl-Shift clicking on any group).

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editaction.h
    trunk/blender/source/blender/include/BIF_resources.h
    trunk/blender/source/blender/include/blendef.h
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/drawaction.c
    trunk/blender/source/blender/src/editaction.c
    trunk/blender/source/blender/src/resources.c

Modified: trunk/blender/source/blender/include/BIF_editaction.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editaction.h	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/include/BIF_editaction.h	2008-07-12 05:00:37 UTC (rev 15541)
@@ -141,6 +141,7 @@
 /* Group/Channel Operations */
 struct bActionGroup *get_active_actiongroup(struct bAction *act);
 void set_active_actiongroup(struct bAction *act, struct bActionGroup *agrp, short select);
+void actionbone_group_copycolors(struct bActionGroup *grp, short init_new);
 void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]);
 void sync_pchan2achan_grouping(void); 
 void action_groups_group(short add_group);
@@ -166,6 +167,7 @@
 void deselect_actionchannels(struct bAction *act, short mode);
 int select_channel(struct bAction *act, struct bActionChannel *achan, int selectmode);
 void select_actionchannel_by_name(struct bAction *act, char *name, int select);
+void select_action_group_channels(struct bAction *act, struct bActionGroup *agrp);
 void selectkeys_leftright (short leftright, short select_mode);
 
 /* Action Markers */

Modified: trunk/blender/source/blender/include/BIF_resources.h
===================================================================
--- trunk/blender/source/blender/include/BIF_resources.h	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/include/BIF_resources.h	2008-07-12 05:00:37 UTC (rev 15541)
@@ -591,7 +591,10 @@
 char 	*BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid);
 char 	*BIF_ThemeColorsPup(int spacetype);
 
+/* only for Bone Color sets */
+char *BIF_ThemeColorSetsPup(short inc_custom);
 
+
 void	BIF_def_color			(BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b);
 
 #endif /*  BIF_ICONS_H */

Modified: trunk/blender/source/blender/include/blendef.h
===================================================================
--- trunk/blender/source/blender/include/blendef.h	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/include/blendef.h	2008-07-12 05:00:37 UTC (rev 15541)
@@ -409,6 +409,12 @@
 #define B_ACTCOPYKEYS		710
 #define B_ACTPASTEKEYS		711
 
+#define B_ACTCUSTCOLORS		712
+#define B_ACTCOLSSELECTOR	713
+#define B_ACTGRP_SELALL		714
+#define B_ACTGRP_ADDTOSELF	715
+#define B_ACTGRP_UNGROUP	716
+
 /* TIME: 751 - 800 */
 #define B_TL_REW		751
 #define B_TL_PLAY		752

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2008-07-12 05:00:37 UTC (rev 15541)
@@ -116,6 +116,7 @@
 
 /* flags for ThemeWireColor */
 #define TH_WIRECOLOR_CONSTCOLS	(1<<0)
+#define TH_WIRECOLOR_TEXTCOLS	(1<<1)
 
 /* A theme */
 typedef struct bTheme {

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/src/buttons_editing.c	2008-07-12 05:00:37 UTC (rev 15541)
@@ -5153,32 +5153,6 @@
 	BLI_uniquename(&pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32);
 }
 
-static char *build_colorsets_menustr ()
-{
-	DynStr *pupds= BLI_dynstr_new();
-	char *str;
-	char buf[48];
-	int i;
-	
-	/* add title first (and the "default" entry) */
-	BLI_dynstr_append(pupds, "Bone Color Set%t|Default Colors%x0|");
-	
-	/* loop through set indices, adding them */
-	for (i=1; i<21; i++) {
-		sprintf(buf, "%d - Theme Color Set%%x%d|", i, i);
-		BLI_dynstr_append(pupds, buf);
-	}
-	
-	/* add the 'custom' entry */
-	BLI_dynstr_append(pupds, "Custom Set %x-1");
-	
-	/* convert to normal MEM_malloc'd string */
-	str= BLI_dynstr_get_cstring(pupds);
-	BLI_dynstr_free(pupds);
-	
-	return str;
-}
-
 static void editing_panel_links(Object *ob)
 {
 	uiBlock *block;
@@ -5338,32 +5312,14 @@
 			/* color set for 'active' group */
 			if (pose->active_group && grp) {
 				uiBlockBeginAlign(block);
-					menustr= build_colorsets_menustr();
+					menustr= BIF_ThemeColorSetsPup(1);
 					uiDefButI(block, MENU,B_POSEGRP_RECALC, menustr, xco,85,140,19, &grp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme");						
 					MEM_freeN(menustr);
 					
 					/* show color-selection/preview */
 					if (grp->customCol) {
-						if (grp->customCol > 0) {
-							/* copy theme colors on-to group's custom color in case user tries to edit color */
-							bTheme *btheme= U.themes.first;
-							ThemeWireColor *col_set= &btheme->tarm[(grp->customCol - 1)];
-							
-							memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
-						}
-						else {
-							/* init custom colors with a generic multi-color rgb set, if not initialised already */
-							if (grp->cs.solid[0] == 0) {
-								/* define for setting colors in theme below */
-								#define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
-								
-								SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255);
-								SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255);
-								SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
-								
-								#undef SETCOL
-							}
-						}
+						/* do color copying/init (to stay up to date) */
+						actionbone_group_copycolors(grp, 1);
 						
 						/* color changing */
 						uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "",		xco, 65, 30, 19, grp->cs.solid, 0, 0, 0, 0, "Color to use for surface of bones");

Modified: trunk/blender/source/blender/src/drawaction.c
===================================================================
--- trunk/blender/source/blender/src/drawaction.c	2008-07-12 04:02:08 UTC (rev 15540)
+++ trunk/blender/source/blender/src/drawaction.c	2008-07-12 05:00:37 UTC (rev 15541)
@@ -32,6 +32,7 @@
 
 #include <math.h>
 #include <stdlib.h>
+#include <string.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -56,6 +57,7 @@
 #include "DNA_space_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_key_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BKE_action.h"
 #include "BKE_depsgraph.h"
@@ -928,27 +930,124 @@
 void do_actionbuts(unsigned short event)
 {
 	switch(event) {
+		/* general */
 	case REDRAWVIEW3D:
 		allqueue(REDRAWVIEW3D, 0);
 		break;
 	case B_REDR:
 		allqueue(REDRAWACTION, 0);
 		break;
+		
+		/* action-groups */
+	case B_ACTCUSTCOLORS:	/* only when of the color wells is edited */
+	{
+		bActionGroup *agrp= get_active_actiongroup(G.saction->action);
+		
+		if (agrp)
+			agrp->customCol= -1;
+			
+		allqueue(REDRAWACTION, 0);
 	}
+		break;
+	case B_ACTCOLSSELECTOR: /* sync color set after using selector */
+	{
+		bActionGroup *agrp= get_active_actiongroup(G.saction->action);
+		
+		if (agrp) 
+			actionbone_group_copycolors(agrp, 1);
+			
+		allqueue(REDRAWACTION, 0);
+	}
+		break;
+	case B_ACTGRP_SELALL: /* select all grouped channels */
+	{
+		bAction *act= G.saction->action;
+		bActionGroup *agrp= get_active_actiongroup(act);
+		
+		/* select all in group, then reselect/activate group as the previous operation clears that */
+		select_action_group_channels(act, agrp);
+		agrp->flag |= (AGRP_ACTIVE|AGRP_SELECTED);
+		
+		allqueue(REDRAWACTION, 0);
+	}
+		break;
+	case B_ACTGRP_ADDTOSELF: /* add all selected action channels to self */
+		action_groups_group(0);
+		break;
+	case B_ACTGRP_UNGROUP: /* remove channels from active group */
+		// FIXME: todo...
+		printf("FIXME: remove achans from active Action-Group not implemented yet! \n");
+		break;
+	
+	}
 }
 
 // currently not used...
 static void action_panel_properties(short cntrl)	// ACTION_HANDLER_PROPERTIES
 {
 	uiBlock *block;
-
+	void *data;
+	short datatype;
+	
 	block= uiNewBlock(&curarea->uiblocks, "action_panel_properties", UI_EMBOSS, UI_HELV, curarea->win);
 	uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
 	uiSetPanelHandler(ACTION_HANDLER_PROPERTIES);  // for close and esc
-	if (uiNewPanel(curarea, block, "Transform Properties", "Action", 10, 230, 318, 204)==0) 
+	
+	/* get datatype */
+	data= get_action_context(&datatype);
+	//if (data == NULL) return;
+	
+	if (uiNewPanel(curarea, block, "Active Channel Properties", "Action", 10, 230, 318, 204)==0) 
 		return;
-
-	uiDefBut(block, LABEL, 0, "test text",		10,180,300,19, 0, 0, 0, 0, 0, "");
+	
+	/* currently, only show data for actions */
+	if (datatype == ACTCONT_ACTION) {
+		bActionGroup *agrp= get_active_actiongroup(data);
+		//bActionChannel *achan= get_hilighted_action_channel(data);
+		char *menustr;
+		
+		/* only for action-groups */
+		if (agrp) {
+			/* general stuff */
+			uiDefBut(block, LABEL, 1, "Action Group:",					10, 180, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
+			
+			uiDefBut(block, TEX, B_REDR, "Name: ",	10,160,150,20, agrp->name, 0.0, 31.0, 0, 0, "");
+			uiBlockBeginAlign(block);
+				uiDefButBitI(block, TOG, AGRP_EXPANDED, B_REDR, "Expanded", 170, 160, 75, 20, &agrp->flag, 0, 0, 0, 0, "Action Group is expanded");
+				uiDefButBitI(block, TOG, AGRP_PROTECTED, B_REDR, "Protected", 245, 160, 75, 20, &agrp->flag, 0, 0, 0, 0, "Action Group is protected");
+			uiBlockEndAlign(block);
+			
+			/* color stuff */
+			uiDefBut(block, LABEL, 1, "Group Colors:",	10, 107, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
+			uiBlockBeginAlign(block);
+				menustr= BIF_ThemeColorSetsPup(1);
+				uiDefButI(block, MENU,B_ACTCOLSSELECTOR, menustr, 10,85,150,19, &agrp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme");						
+				MEM_freeN(menustr);
+				
+				/* show color-selection/preview */
+				if (agrp->customCol) {
+					/* do color copying/init (to stay up to date) */
+					actionbone_group_copycolors(agrp, 1);
+					
+					/* color changing */
+					uiDefButC(block, COL, B_ACTCUSTCOLORS, "",		10, 65, 50, 19, agrp->cs.active, 0, 0, 0, 0, "Color to use for 'top-level' channels");
+					uiDefButC(block, COL, B_ACTCUSTCOLORS, "",		60, 65, 50, 19, agrp->cs.select, 0, 0, 0, 0, "Color to use for '2nd-level' channels");
+					uiDefButC(block, COL, B_ACTCUSTCOLORS, "",		110, 65, 50, 19, agrp->cs.solid, 0, 0, 0, 0, "Color to use for '3rd-level' channels");
+				}
+			uiBlockEndAlign(block);
+			
+			/* commands for active group */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list