[Bf-blender-cvs] [6b591cd] soc-2016-layer_manager: Add color set from theme as object layer property

Julian Eisel noreply at git.blender.org
Tue Jun 21 22:32:46 CEST 2016


Commit: 6b591cd46b7e33262693a44666d0f6492c3fcbc2
Author: Julian Eisel
Date:   Tue Jun 21 22:14:50 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rB6b591cd46b7e33262693a44666d0f6492c3fcbc2

Add color set from theme as object layer property

We're simply reusing armature color sets, don't want to spend time on adding own color sets for this just now. Note that they don't have any affect yet, just testing if layer properties work (they apparently do :) ).

===================================================================

M	source/blender/blenkernel/intern/layer.c
M	source/blender/editors/include/UI_interface_icons.h
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/space_layers/layers_draw.c
M	source/blender/makesrna/intern/rna_pose.c

===================================================================

diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 905a705..d694d4e 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -45,6 +45,7 @@
 
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 static void layeritem_free(LayerTreeItem *litem);
 
@@ -141,6 +142,8 @@ static void LAYERTYPE_object(LayerType *lt)
 	lt->type = LAYER_ITEMTYPE_LAYER;
 
 	lt->free = BKE_objectlayer_free;
+
+	RNA_def_enum(lt->srna, "color_set", rna_enum_color_sets_items, 0, "Color Set", "Custom color set for this layer");
 }
 
 static void LAYERTYPE_group(LayerType *lt)
diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h
index 945ac1b..f08c46a 100644
--- a/source/blender/editors/include/UI_interface_icons.h
+++ b/source/blender/editors/include/UI_interface_icons.h
@@ -83,5 +83,6 @@ struct PreviewImage *UI_icon_to_preview(int icon_id);
 
 int UI_rnaptr_icon_get(struct bContext *C, struct PointerRNA *ptr, int rnaicon, const bool big);
 int UI_idcode_icon_get(const int idcode);
+int UI_colorset_icon_get(const int set_idx);
 
 #endif /*  __UI_INTERFACE_ICONS_H__ */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 6dc60f1..705fe22 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1587,6 +1587,14 @@ int UI_idcode_icon_get(const int idcode)
 	}
 }
 
+/**
+ * \param set_idx: A value from #rna_enum_color_sets_items.
+ */
+int UI_colorset_icon_get(const int set_idx)
+{
+	return (set_idx < 1) ? ICON_NONE : VICO_COLORSET_01_VEC - 1 + set_idx;
+}
+
 static void icon_draw_at_size(
         float x, float y, int icon_id, float aspect, float alpha,
         enum eIconSizes size, const bool nocreate)
diff --git a/source/blender/editors/space_layers/layers_draw.c b/source/blender/editors/space_layers/layers_draw.c
index e845405..a85da90 100644
--- a/source/blender/editors/space_layers/layers_draw.c
+++ b/source/blender/editors/space_layers/layers_draw.c
@@ -41,7 +41,10 @@
 
 #include "ED_screen.h"
 
+#include "RNA_access.h"
+
 #include "UI_interface.h"
+#include "UI_interface_icons.h"
 #include "UI_view2d.h"
 #include "UI_resources.h"
 
@@ -117,7 +120,7 @@ static float layer_tile_draw(
 	if (expanded) {
 		uiLayout *layout = UI_block_layout(
 		        block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
-		        rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), 0, 0, style);
+		        rect.xmin, rect.ymin, (int)BLI_rctf_size_x(&rect) - 5, 0, 5, style);
 		litem->type->draw_settings(C, litem, layout);
 
 		int size_y = 0;
@@ -263,7 +266,10 @@ void object_layer_draw(const bContext *C, LayerTreeItem *litem, uiLayout *layout
 	uiBlock *block = uiLayoutGetBlock(layout);
 	const bool draw_settingbut = litem->type->draw_settings && tile->flag & (LAYERTILE_SELECTED | LAYERTILE_EXPANDED);
 
-	uiItemL(layout, litem->name, 0);
+	/* name with color set icon */
+	const int col_icon = UI_colorset_icon_get(RNA_enum_get(litem->ptr, "color_set"));
+	uiItemL(layout, litem->name, col_icon);
+
 	if (draw_settingbut) {
 		UI_block_emboss_set(block, UI_EMBOSS_NONE);
 		uiDefIconButBitI(block, UI_BTYPE_TOGGLE, LAYERTILE_EXPANDED, 0,
@@ -273,9 +279,8 @@ void object_layer_draw(const bContext *C, LayerTreeItem *litem, uiLayout *layout
 	}
 }
 
-void object_layer_draw_settings(const bContext *UNUSED(C), LayerTreeItem *UNUSED(litem), uiLayout *layout)
+void object_layer_draw_settings(const bContext *UNUSED(C), LayerTreeItem *litem, uiLayout *layout)
 {
-	/* TODO */
-	uiItemL(layout, "Add stuff here!", 0);
-	uiItemL(layout, "Test", 0);
+	uiLayout *split = uiLayoutSplit(layout, 0.5f, false);
+	uiItemR(split, litem->ptr, "color_set", 0, "Color Set", ICON_NONE);
 }
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 1f34d8f..f08d9ca 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -64,7 +64,10 @@ EnumPropertyItem rna_enum_posebone_rotmode_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
-/* Bone and Group Color Sets */
+/**
+ * Bone and Group Color Sets
+ * \note Take care of #UI_colorset_icon_get when changing.
+ */
 EnumPropertyItem rna_enum_color_sets_items[] = {
 	{0, "DEFAULT", 0, "Default Colors", ""},
 	{1, "THEME01", VICO_COLORSET_01_VEC, "01 - Theme Color Set", ""},




More information about the Bf-blender-cvs mailing list