[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20011] branches/blender2.5/blender/source /blender/editors: 2.5

Ton Roosendaal ton at blender.org
Thu Apr 30 19:27:30 CEST 2009


Revision: 20011
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20011
Author:   ton
Date:     2009-04-30 19:27:30 +0200 (Thu, 30 Apr 2009)

Log Message:
-----------
2.5

Cleanup of conventions for icon placement in menus.

Old code only allowed 1 icon per menu, forcing to pass on the sublevel
menu icon with exception handling.

Now sublevel icons are drawn automatically, allowing to add an icon
before name too. (Check shift+a menu)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-30 16:44:00 UTC (rev 20010)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-04-30 17:27:30 UTC (rev 20011)
@@ -110,7 +110,7 @@
 /* but->flag */
 #define UI_TEXT_LEFT	64
 #define UI_ICON_LEFT	128
-#define UI_ICON_RIGHT	256
+#define UI_ICON_SUBMENU	256
 	/* control for button type block */
 #define UI_MAKE_TOP		512
 #define UI_MAKE_DOWN	1024

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-30 16:44:00 UTC (rev 20010)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-04-30 17:27:30 UTC (rev 20011)
@@ -2741,7 +2741,7 @@
 uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name)
 {
 	int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
-	return uiDefIconTextBlockBut(block, func, NULL, ICON_RIGHTARROW_THIN, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, "");
+	return uiDefIconTextBlockBut(block, func, NULL, ICON_BLANK1, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, "");
 }
 
 uiBut *uiDefMenuTogR(uiBlock *block, PointerRNA *ptr, char *propname, char *propvalue, char *name)
@@ -2991,7 +2991,7 @@
 	but->flag|= UI_HAS_ICON;
 
 	but->flag|= UI_ICON_LEFT;
-	but->flag|= UI_ICON_RIGHT;
+	but->flag|= UI_ICON_SUBMENU;
 
 	but->menu_create_func= func;
 	ui_check_but(but);
@@ -3004,12 +3004,14 @@
 {
 	uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
 	
-	but->icon= (BIFIconID) icon;
+	/* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */
+	if(icon!=ICON_RIGHTARROW_THIN) {
+		but->icon= (BIFIconID) icon;
+		but->flag|= UI_ICON_LEFT;
+	}
 	but->flag|= UI_HAS_ICON;
+	but->flag|= UI_ICON_SUBMENU;
 
-	but->flag|= UI_ICON_LEFT;
-	but->flag|= UI_ICON_RIGHT;
-
 	but->block_create_func= func;
 	ui_check_but(but);
 	
@@ -3025,7 +3027,7 @@
 	but->flag|= UI_HAS_ICON;
 	
 	but->flag|= UI_ICON_LEFT;
-	but->flag|= UI_ICON_RIGHT;
+	but->flag|= UI_ICON_SUBMENU;
 	
 	but->block_create_func= func;
 	ui_check_but(but);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-04-30 16:44:00 UTC (rev 20010)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-04-30 17:27:30 UTC (rev 20011)
@@ -887,9 +887,6 @@
 
 	menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
 
-	if(!icon && layout->type == UI_LAYOUT_MENU)
-		icon= ICON_RIGHTARROW_THIN,
-
 	ui_item_name(&menuitem->item, name);
 	menuitem->item.icon= icon;
 	menuitem->item.type= ITEM_MENU;
@@ -931,8 +928,6 @@
 
 	menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
 
-	if(!icon && layout->type == UI_LAYOUT_MENU)
-		icon= ICON_RIGHTARROW_THIN;
 	if(!name)
 		name= ot->name;
 
@@ -978,8 +973,6 @@
 
 	menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu");
 
-	if(!icon && layout->type == UI_LAYOUT_MENU)
-		icon= ICON_RIGHTARROW_THIN;
 	if(!name)
 		name= (char*)RNA_property_ui_name(prop);
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-04-30 16:44:00 UTC (rev 20010)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-04-30 17:27:30 UTC (rev 20011)
@@ -633,7 +633,7 @@
 	float xs=0, ys=0, aspect, height;
 	
 	/* this icon doesn't need draw... */
-	if(icon==ICON_BLANK1) return;
+	if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return;
 	
 	/* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */
 	aspect= but->block->aspect;
@@ -650,46 +650,50 @@
 	else
 		height= ICON_HEIGHT;
 	
-	if(but->flag & UI_ICON_LEFT) {
-		if (but->type==BUT_TOGDUAL) {
-			if (but->drawstr[0]) {
-				xs= rect->xmin-1.0;
-			} else {
-				xs= (rect->xmin+rect->xmax- height)/2.0;
+	/* calculate blend color */
+	if ELEM3(but->type, TOG, ROW, TOGN) {
+		if(but->flag & UI_SELECT);
+		else if(but->flag & UI_ACTIVE);
+		else blend= -60;
+	}
+	
+	glEnable(GL_BLEND);
+	
+	if(icon && icon!=ICON_BLANK1) {
+		if(but->flag & UI_ICON_LEFT) {
+			if (but->type==BUT_TOGDUAL) {
+				if (but->drawstr[0]) {
+					xs= rect->xmin-1.0;
+				} else {
+					xs= (rect->xmin+rect->xmax- height)/2.0;
+				}
 			}
+			else if (but->block->flag & UI_BLOCK_LOOP) {
+				xs= rect->xmin+1.0;
+			}
+			else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
+				xs= rect->xmin+3.0;
+			}
+			else {
+				xs= rect->xmin+4.0;
+			}
+			ys= (rect->ymin+rect->ymax- height)/2.0;
 		}
-		else if (but->block->flag & UI_BLOCK_LOOP) {
-			xs= rect->xmin+1.0;
-		}
-		else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
-			xs= rect->xmin+3.0;
-		}
 		else {
-			xs= rect->xmin+4.0;
+			xs= (rect->xmin+rect->xmax- height)/2.0;
+			ys= (rect->ymin+rect->ymax- height)/2.0;
 		}
-		ys= (rect->ymin+rect->ymax- height)/2.0;
+	
+		UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
 	}
-	if(but->flag & UI_ICON_RIGHT) {
+	
+	if(but->flag & UI_ICON_SUBMENU) {
 		xs= rect->xmax-17.0;
 		ys= (rect->ymin+rect->ymax- height)/2.0;
+		
+		UI_icon_draw_aspect_blended(xs, ys, ICON_RIGHTARROW_THIN, aspect, blend);
 	}
-	if (!((but->flag & UI_ICON_RIGHT) || (but->flag & UI_ICON_LEFT))) {
-		xs= (rect->xmin+rect->xmax- height)/2.0;
-		ys= (rect->ymin+rect->ymax- height)/2.0;
-	}
 	
-	glEnable(GL_BLEND);
-	
-	/* calculate blend color */
-	if ELEM3(but->type, TOG, ROW, TOGN) {
-		if(but->flag & UI_SELECT);
-		else if(but->flag & UI_ACTIVE);
-		else blend= -60;
-	}
-	if (but->flag & UI_BUT_DISABLED) blend = -100;
-	
-	UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
-	
 	glDisable(GL_BLEND);
 }
 
@@ -843,7 +847,7 @@
 			/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
 			and offset the text label to accomodate it */
 			
-			if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) ) {
+			if (but->flag & UI_HAS_ICON) {
 				widget_draw_icon(but, but->icon, 0, rect);
 				
 				rect->xmin += UI_icon_get_width(but->icon);





More information about the Bf-blender-cvs mailing list