Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-21 16:38:01 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-21 16:38:01 +0400
commit7284eb6d9119f70766242f490a0dc841e01cc585 (patch)
treef7684fd649276dd967fc900f05da4bad33a808ae /source/blender/makesrna/intern/rna_pose.c
parente18164dbab59ae5c9f0f1dd1ba12d1a97538919b (diff)
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.
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c91
1 files changed, 83 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index e15310a02bf..0963f2483f3 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -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 @@ static void rna_Pose_update(bContext *C, PointerRNA *ptr)
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) {
+ /* 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
+ }
+ }
+ }
+}
+
IDProperty *rna_PoseChannel_idproperties(PointerRNA *ptr, int create)
{
bPoseChannel *pchan= ptr->data;
@@ -189,23 +228,60 @@ void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *result,
static void rna_def_bone_group(BlenderRNA *brna)
{
+ static EnumPropertyItem prop_colorSets_items[] = {
+ {0, "DEFAULT", 0, "Default Colors", ""},
+ {1, "THEME01", 0, "01 - Theme Color Set", ""},
+ {2, "THEME02", 0, "02 - Theme Color Set", ""},
+ {3, "THEME03", 0, "03 - Theme Color Set", ""},
+ {4, "THEME04", 0, "04 - Theme Color Set", ""},
+ {5, "THEME05", 0, "05 - Theme Color Set", ""},
+ {6, "THEME06", 0, "06 - Theme Color Set", ""},
+ {7, "THEME07", 0, "07 - Theme Color Set", ""},
+ {8, "THEME08", 0, "08 - Theme Color Set", ""},
+ {9, "THEME09", 0, "09 - Theme Color Set", ""},
+ {10, "THEME10", 0, "10 - Theme Color Set", ""},
+ {11, "THEME11", 0, "11 - Theme Color Set", ""},
+ {12, "THEME12", 0, "12 - Theme Color Set", ""},
+ {13, "THEME13", 0, "13 - Theme Color Set", ""},
+ {14, "THEME14", 0, "14 - Theme Color Set", ""},
+ {15, "THEME15", 0, "15 - Theme Color Set", ""},
+ {16, "THEME16", 0, "16 - Theme Color Set", ""},
+ {17, "THEME17", 0, "17 - Theme Color Set", ""},
+ {18, "THEME18", 0, "18 - Theme Color Set", ""},
+ {19, "THEME19", 0, "19 - Theme Color Set", ""},
+ {20, "THEME20", 0, "20 - Theme Color Set", ""},
+ {-1, "CUSTOM", 0, "Custom Color Set", ""},
+ {0, NULL, 0, NULL, NULL}};
+
StructRNA *srna;
PropertyRNA *prop;
-
+
+ /* struct */
srna= RNA_def_struct(brna, "BoneGroup", NULL);
RNA_def_struct_sdna(srna, "bActionGroup");
RNA_def_struct_ui_text(srna, "Bone Group", "Groups of Pose Channels (Bones).");
-
+
+ /* name */
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
// TODO: add some runtime-collections stuff to access grouped bones
- // FIXME: this needs more work - probably a custom template?
- prop= RNA_def_property(srna, "custom_color", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "customCol");
- RNA_def_property_ui_text(prop, "Custom Color", "Index of custom color set.");
+ /* color set + colors */
+ prop= RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "customCol");
+ RNA_def_property_enum_items(prop, prop_colorSets_items);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_BoneGroup_color_set_set", NULL);
+ RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
+
+ // TODO: editing the colors for this should result in changes to the color type...
+ prop= RNA_def_property(srna, "colors", PROP_POINTER, PROP_NEVER_NULL);
+ RNA_def_property_struct_type(prop, "ThemeBoneColorSet");
+ RNA_def_property_pointer_sdna(prop, NULL, "cs"); /* NOTE: the DNA data is not really a pointer, but this code works :) */
+ RNA_def_property_ui_text(prop, "Colors", "Copy of the colors associated with the group's color set.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_POSE, "rna_Pose_update");
}
static void rna_def_pose_channel(BlenderRNA *brna)
@@ -272,7 +348,6 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "selectflag", BONE_SELECTED);
RNA_def_property_ui_text(prop, "Selected", "");
- /* XXX note: bone groups are stored internally as bActionGroups :) - Aligorith */
prop= RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "agrp_index");
RNA_def_property_ui_text(prop, "Bone Group Index", "Bone Group this pose channel belongs to (0=no group).");