[Bf-blender-cvs] [0570bdc] master: Fix own regression in rB254aa8f3a0fb: Titles and sub-titles in menus were drawn shifted to the right.

Bastien Montagne noreply at git.blender.org
Tue Nov 26 10:44:40 CET 2013


Commit: 0570bdc13d297a80c702a69f72bf28f8d4e2e9b5
Author: Bastien Montagne
Date:   Tue Nov 26 10:29:36 2013 +0100
http://developer.blender.org/rB0570bdc13d297a80c702a69f72bf28f8d4e2e9b5

Fix own regression in rB254aa8f3a0fb: Titles and sub-titles in menus were drawn shifted to the right.

Reported by plasmasolution over IRC, thanks.

Also fixes wrong handling of "sub-titles" with icons in EnumO menus (they were just treated as text-only ones).

Dev notes: in fact, that clean up commit revealed kind of an "hidden bug that happend to work well"
(or at least, a very bad hack): with titles without icon, code used to use uiItemL with ICON_NONE.
However, as the root layout is a menu one, internal ui code would add a dummy blank icon,
and set UI_HAS_ICON flag for the label button. But in the affected menus, code afterward assigned
UI_TEXT_LEFT to but->flag, thus erasing the (internal) UI_HAS_ICON. As UI_TEXT_LEFT was moved to
but->drawflag, the internal flag was no more erased, and the fake icon was drawn, creating that
shift-to-the-right effect. Turns out we do not even have to set UI_TEXT_LEFT in these cases,
just add label buttons without icon is enough!

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

M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_regions.c

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 28055ba..3cd022b 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -908,9 +908,15 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
 						block->flag |= UI_BLOCK_NO_FLIP;
 					}
 
-					uiItemL(column, item->name, ICON_NONE);
-					but = block->buttons.last;
-					but->drawflag = UI_BUT_TEXT_LEFT;
+					if (item->icon) {
+						uiItemL(column, item->name, item->icon);
+						but = block->buttons.last;
+					}
+					else {
+						/* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */
+						but = uiDefBut(block, LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL,
+						               0.0, 0.0, 0, 0, "");
+					}
 					ui_but_tip_from_enum_item(but, item);
 				}
 				else {  /* XXX bug here, colums draw bottom item badly */
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 984904a..b4d99b9 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1791,7 +1791,6 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
 	uiBlock *block = uiLayoutGetBlock(layout);
 	uiPopupBlockHandle *handle = block->handle;
 	uiLayout *split, *column = NULL;
-	uiBut *bt;
 	MenuData *md;
 	MenuEntry *entry;
 	const char *instr = arg_str;
@@ -1800,7 +1799,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
 	int nbr_entries_nosepr = 0;
 
 	uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
-	
+
 	/* compute menu data */
 	md = decompose_menu_string(instr);
 
@@ -1838,9 +1837,8 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
 			uiItemL(layout, md->title, md->titleicon);
 		}
 		else {
-			uiItemL(layout, md->title, ICON_NONE);
-			bt = block->buttons.last;
-			bt->drawflag = UI_BUT_TEXT_LEFT;
+			/* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */
+			uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 		}
 	}
 
@@ -1874,9 +1872,13 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
 
 		if (entry->sepr) {
 			if (entry->str[0]) {
-				uiItemL(column, entry->str, entry->icon);
-				bt = block->buttons.last;
-				bt->drawflag = UI_BUT_TEXT_LEFT;
+				if (entry->icon) {
+					uiItemL(column, entry->str, entry->icon);
+				}
+				else {
+					/* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */
+					uiDefBut(block, LABEL, 0, entry->str, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+				}
 			}
 			else {
 				uiItemS(column);
@@ -1891,7 +1893,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
 			          UI_UNIT_X * 5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, -1, "");
 		}
 	}
-	
+
 	menudata_free(md);
 }




More information about the Bf-blender-cvs mailing list