[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58336] branches/soc-2013-paint/source/ blender/editors/interface/interface_templates.c: * Palette colours get added to toolbar according to toolbar length.

Antony Riakiotakis kalast at gmail.com
Wed Jul 17 13:41:44 CEST 2013


Revision: 58336
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58336
Author:   psy-fi
Date:     2013-07-17 11:41:44 +0000 (Wed, 17 Jul 2013)
Log Message:
-----------
* Palette colours get added to toolbar according to toolbar length.
* Add operator for adding colours.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/interface/interface_templates.c

Modified: branches/soc-2013-paint/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/interface/interface_templates.c	2013-07-17 11:02:51 UTC (rev 58335)
+++ branches/soc-2013-paint/source/blender/editors/interface/interface_templates.c	2013-07-17 11:41:44 UTC (rev 58336)
@@ -2307,10 +2307,10 @@
 	PointerRNA cptr;
 	Palette *palette;
 	PaletteColor *color;
-	uiBlock *block = uiLayoutGetBlock(layout);
+	uiBlock *block;
 	uiLayout *col;
 	int row_cols = 0;
-	int max_palette_cols = 8;
+	int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
 
 	if (!prop) {
 		RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
@@ -2321,6 +2321,8 @@
 	if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette))
 		return;
 
+	block = uiLayoutGetBlock(layout);
+
 	palette = cptr.data;
 	color = palette->colors.first;
 
@@ -2330,17 +2332,21 @@
 	for (; color; color = color->next) {
 		PointerRNA ptr;
 
-		if (row_cols >= max_palette_cols) {
+		if (row_cols >= cols_per_row) {
 			uiLayoutRow(col, TRUE);
 			row_cols = 0;
 		}
 
 		RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr);
-		uiDefButR(block, COLOR, 0, "", 0, 0, 18, 18, &ptr, "color",
-			               -1, 0.0, 1.0, 0.0, 0.0, "");
+		uiDefButR(block, COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color",
+		          -1, 0.0, 1.0, 0.0, 0.0, "");
 
 		row_cols++;
 	}
+
+	col = uiLayoutColumn(layout, TRUE);
+	uiLayoutRow(col, TRUE);
+	uiDefIconButO(block, BUT, "PALETTE_OT_color_add", WM_OP_INVOKE_DEFAULT, ICON_PLUS, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
 }
 
 




More information about the Bf-blender-cvs mailing list