[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21763] branches/blender2.5/blender: 2. 5 - More work on Bone Groups
Joshua Leung
aligorith at gmail.com
Tue Jul 21 14:38:02 CEST 2009
Revision: 21763
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21763
Author: aligorith
Date: 2009-07-21 14:38:01 +0200 (Tue, 21 Jul 2009)
Log Message:
-----------
2.5 - More work on Bone Groups
* Added a new UI Template for the 3-colour picker used to visualise + select the custom colours for a bone group.
* Finished wrapping the colour properties for Bone Groups in RNA. Although changing the colour-set used will change the displayed/cached colours, changing the colours via the colour wells will not change the colour set to 'custom' (as per 2.4x) yet. This needs a nice solution...
* Fixed context-related bugs with the Assign/Remove operators for bone groups. These were using context-iterators for selected posechannels, but that was only defined/valid for the 3d view (but not for the buttons window), hence a failure in that case.
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/buttons_data_armature.py
branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui_api.c
Modified: branches/blender2.5/blender/release/ui/buttons_data_armature.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_armature.py 2009-07-21 12:19:46 UTC (rev 21762)
+++ branches/blender2.5/blender/release/ui/buttons_data_armature.py 2009-07-21 12:38:01 UTC (rev 21763)
@@ -101,8 +101,13 @@
group = pose.active_bone_group
if group:
- row = layout.row()
- row.itemR(group, "name")
+ col = layout.column()
+ col.itemR(group, "name")
+
+ split = layout.split(0.5)
+ split.itemR(group, "color_set")
+ if group.color_set:
+ split.template_triColorSet(group, "colors")
row = layout.row(align=True)
Modified: branches/blender2.5/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poseobject.c 2009-07-21 12:19:46 UTC (rev 21762)
+++ branches/blender2.5/blender/source/blender/editors/armature/poseobject.c 2009-07-21 12:38:01 UTC (rev 21763)
@@ -1035,7 +1035,7 @@
ob= CTX_data_active_object(C);
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
pose= ob->pose;
@@ -1065,7 +1065,7 @@
else {
/* just use the active group index, and call the exec callback for the calling operator */
RNA_int_set(op->ptr, "type", pose->active_group);
- return op->type->exec;
+ return op->type->exec(C, op);
}
}
@@ -1074,7 +1074,9 @@
{
ScrArea *sa= CTX_wm_area(C);
Object *ob;
+ bArmature *arm;
bPose *pose;
+ bPoseChannel *pchan;
short done= 0;
/* since this call may also be used from the buttons window, we need to check for where to get the object */
@@ -1086,18 +1088,29 @@
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
+ arm= ob->data;
pose= ob->pose;
- /* set the active group number to the one from operator props */
+ /* set the active group number to the one from operator props
+ * - if 0 after this, make a new group...
+ */
pose->active_group= RNA_int_get(op->ptr, "type");
+ if (pose->active_group == 0)
+ pose_add_group(ob);
/* add selected bones to group then */
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
- {
- pchan->agrp_index= pose->active_group;
- done= 1;
+ // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
+ // CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
+ for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+ /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
+ // NOTE: sync this view3d_context() in space_view3d.c
+ if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+ if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) {
+ pchan->agrp_index= pose->active_group;
+ done= 1;
+ }
+ }
}
- CTX_DATA_END;
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1133,7 +1146,9 @@
{
ScrArea *sa= CTX_wm_area(C);
Object *ob;
+ bArmature *arm;
bPose *pose;
+ bPoseChannel *pchan;
short done= 0;
/* since this call may also be used from the buttons window, we need to check for where to get the object */
@@ -1146,16 +1161,23 @@
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
pose= ob->pose;
+ arm= ob->data;
/* add selected bones to ungroup then */
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
- {
- if (pchan->agrp_index) {
- pchan->agrp_index= 0;
- done= 1;
+ // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
+ // CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans)
+ for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+ /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
+ // NOTE: sync this view3d_context() in space_view3d.c
+ if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+ if (pchan->bone->flag & (BONE_SELECTED|BONE_ACTIVE)) {
+ if (pchan->agrp_index) {
+ pchan->agrp_index= 0;
+ done= 1;
+ }
+ }
}
}
- CTX_DATA_END;
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1228,55 +1250,6 @@
ot->flag= OPTYPE_REGISTER;
}
-#if 0
-/* Ctrl-G in 3D-View while in PoseMode */
-void pgroup_operation_with_menu (Scene *scene)
-{
- Object *ob= OBACT;
- bArmature *arm= (ob) ? ob->data : NULL;
- bPose *pose= (ob) ? ob->pose : NULL;
- bPoseChannel *pchan= NULL;
- int mode;
-
- /* sanity checks */
- if (ELEM3(NULL, ob, pose, arm))
- return;
-
- /* check that something is selected */
- for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
- if ((pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer))
- break;
- }
- if (pchan == NULL)
- return;
-
- /* get mode of action */
- if (pchan)
- mode= pupmenu("Bone Groups%t|Add Selected to Active Group%x1|Add Selected to Group%x2|%|Remove Selected From Groups%x3|Remove Active Group%x4");
- else
- mode= pupmenu("Bone Groups%t|Add New Group%x5|Remove Active Group%x4");
-
- /* handle mode */
- switch (mode) {
- case 1:
- pose_assign_to_posegroup(scene, 1);
- break;
- case 2:
- pose_assign_to_posegroup(scene, 0);
- break;
- case 5:
- pose_add_posegroup(scene);
- break;
- case 3:
- pose_remove_from_posegroups(scene);
- break;
- case 4:
- pose_remove_posegroup(scene);
- break;
- }
-}
-#endif
-
/* ********************************************** */
static short pose_select_same_group (Object *ob)
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-07-21 12:19:46 UTC (rev 21762)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-07-21 12:38:01 UTC (rev 21763)
@@ -622,6 +622,7 @@
void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent);
void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
+void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c 2009-07-21 12:19:46 UTC (rev 21762)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c 2009-07-21 12:38:01 UTC (rev 21763)
@@ -1173,7 +1173,7 @@
{
uiLayout *row, *col;
uiBlock *block;
- Material *ma;
+ Material *ma= NULL;
ID *pid, *pparent;
if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
@@ -1265,6 +1265,34 @@
}
}
+/********************* TriColor (ThemeWireColorSet) Template ************************/
+
+void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)
+{
+ uiLayout *row;
+ PropertyRNA *prop;
+ PointerRNA csPtr;
+
+ if (!ptr->data)
+ return;
+
+ prop= RNA_struct_find_property(ptr, propname);
+ if (!prop) {
+ printf("uiTemplateTriColorSet: property not found: %s\n", propname);
+ return;
+ }
+
+ /* we lay out the data in a row as 3 color swatches */
+ row= uiLayoutRow(layout, 1);
+
+ /* nselected, selected, active color swatches */
+ csPtr= RNA_property_pointer_get(ptr, prop);
+
+ uiItemR(row, "", 0, &csPtr, "normal", 0, 0, 0);
+ uiItemR(row, "", 0, &csPtr, "selected", 0, 0, 0);
+ uiItemR(row, "", 0, &csPtr, "active", 0, 0, 0);
+}
+
/********************* Layer Buttons Template ************************/
// TODO:
@@ -1299,7 +1327,10 @@
groups= ((cols / 2) < 5) ? (1) : (cols / 2);
/* layers are laid out going across rows, with the columns being divided into groups */
- uSplit= uiLayoutSplit(layout, (1.0f/(float)groups));
+ if (groups > 1)
+ uSplit= uiLayoutSplit(layout, (1.0f/(float)groups));
+ else
+ uSplit= layout;
for (group= 0; group < groups; group++) {
uCol= uiLayoutColumn(uSplit, 1);
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c 2009-07-21 12:19:46 UTC (rev 21762)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c 2009-07-21 12:38:01 UTC (rev 21763)
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
- * Contributor(s): Blender Foundation (2008), Roland Hess
+ * Contributor(s): Blender Foundation (2008), Roland Hess, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -39,8 +39,12 @@
#ifdef RNA_RUNTIME
+#include <string.h>
+
#include "BLI_arithb.h"
+#include "DNA_userdef_types.h"
+
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
@@ -54,6 +58,41 @@
DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_DATA);
}
+static void rna_BoneGroup_color_set_set(PointerRNA *ptr, int value)
+{
+ bActionGroup *grp= ptr->data;
+
+ /* if valid value, set the new enum value, then copy the relevant colours? */
+ if ((value >= -1) && (value < 21))
+ grp->customCol= value;
+ else
+ return;
+
+ /* only do color copying if using a custom color (i.e. not default colour) */
+ 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 (for custom color set) */
+ if (grp->cs.solid[0] == 0) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list