[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23110] branches/blender2.5/blender: UI:

Brecht Van Lommel brecht at blender.org
Thu Sep 10 16:20:21 CEST 2009


Revision: 23110
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23110
Author:   blendix
Date:     2009-09-10 16:20:21 +0200 (Thu, 10 Sep 2009)

Log Message:
-----------
UI:

* layout.itemR now has icon_only option to show only icon
  in e.g. enums buttons, for uv editor header.
* Automatic key shortcuts in menus now show the shortcut even if
  operator properties don't match. Not sure this will work well
  everywhere, but seems to be working ok for now.
* Open recent now show shorter filenames instead of the whole
  file path.
* Tweak object Duplicate menu item.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_image.py
    branches/blender2.5/blender/release/ui/space_view3d.py
    branches/blender2.5/blender/source/blender/blenlib/BLI_fileops.h
    branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
    branches/blender2.5/blender/source/blender/editors/object/object_add.c
    branches/blender2.5/blender/source/blender/editors/object/object_ops.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_keymap.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/blender2.5/blender/release/ui/space_image.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_image.py	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/release/ui/space_image.py	2009-09-10 14:20:21 UTC (rev 23110)
@@ -126,9 +126,9 @@
 	def draw(self, context):
 		layout = self.layout
 
-		layout.item_enumO("tfm.transform", "mode", 'TRANSLATION')
-		layout.item_enumO("tfm.transform", "mode", 'ROTATION')
-		layout.item_enumO("tfm.transform", "mode", 'RESIZE')
+		layout.itemO("tfm.translate")
+		layout.itemO("tfm.rotate")
+		layout.itemO("tfm.resize")
 
 class IMAGE_MT_uvs_mirror(bpy.types.Menu):
 	__space_type__ = 'IMAGE_EDITOR'
@@ -136,10 +136,14 @@
 
 	def draw(self, context):
 		layout = self.layout
+		layout.operator_context = "EXEC_REGION_WIN"
 
-		layout.item_enumO("uv.mirror", "axis", 'MIRROR_X') # "X Axis", M, 
-		layout.item_enumO("uv.mirror", "axis", 'MIRROR_Y') # "Y Axis", M, 
+		props= layout.itemO("tfm.mirror", text="X Axis", properties=True)
+		props.constraint_axis[0]= True
 
+		props= layout.itemO("tfm.mirror", text="Y Axis", properties=True)
+		props.constraint_axis[1]= True
+
 class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
 	__space_type__ = 'IMAGE_EDITOR'
 	__label__ = "Weld/Align"
@@ -233,14 +237,14 @@
 		if show_uvedit:
 			uvedit = sima.uv_editor
 
-			layout.itemR(uvedit, "pivot", text="")
+			layout.itemR(uvedit, "pivot", text="", icon_only=True)
 			layout.itemR(settings, "uv_sync_selection", text="")
 
 			if settings.uv_sync_selection:
 				layout.itemR(settings, "mesh_selection_mode", text="", expand=True)
 			else:
 				layout.itemR(settings, "uv_selection_mode", text="", expand=True)
-				layout.itemR(uvedit, "sticky_selection_mode", text="")
+				layout.itemR(uvedit, "sticky_selection_mode", text="", icon_only=True)
 			pass
 
 			row = layout.row(align=True)

Modified: branches/blender2.5/blender/release/ui/space_view3d.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d.py	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/release/ui/space_view3d.py	2009-09-10 14:20:21 UTC (rev 23110)
@@ -410,7 +410,7 @@
 		
 		layout.itemS()
 		
-		layout.itemO("object.duplicate")
+		layout.itemO("object.duplicate_move")
 		layout.item_booleanO("object.duplicate", "linked", True, text="Duplicate Linked")
 		layout.itemO("object.delete", text="Delete...")
 		layout.itemO("object.proxy_make", text="Make Proxy...")

Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_fileops.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_fileops.h	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_fileops.h	2009-09-10 14:20:21 UTC (rev 23110)
@@ -54,6 +54,7 @@
 int	  BLI_add_slash(char *string);
 void  BLI_del_slash(char *string);
 char *first_slash(char *string);
+const char *BLI_short_filename(const char *string);
 
 /* only for the sane unix world: direct calls to system functions :( */
 #ifndef WIN32

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/fileops.c	2009-09-10 14:20:21 UTC (rev 23110)
@@ -84,6 +84,31 @@
 	else return lfslash;
 }
 
+static const char *last_slash_len(const char *string, int len) {
+	int a;
+
+	for(a=len-1; a>=0; a--)
+		if(string[a] == '/' || string[a] == '\\')
+			return &string[a];
+	
+	return NULL;
+}
+
+const char *BLI_short_filename(const char *string) {
+	const char *ls, *lls;
+	
+	ls= last_slash_len(string, strlen(string));
+	if(!ls)
+		return string;
+	
+	lls= last_slash_len(string, ls-string);
+
+	if(lls)
+		return lls+1;
+	else
+		return ls+1;
+}
+
 /* adds a slash if there isnt one there alredy */
 int BLI_add_slash(char *string) {
 	int len = strlen(string);

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-09-10 14:20:21 UTC (rev 23110)
@@ -589,6 +589,7 @@
 #define UI_ITEM_R_EXPAND		2
 #define UI_ITEM_R_SLIDER		4
 #define UI_ITEM_R_TOGGLE		8
+#define UI_ITEM_R_ICON_ONLY		16
 
 uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
 void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-09-10 11:50:50 UTC (rev 23109)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c	2009-09-10 14:20:21 UTC (rev 23110)
@@ -443,7 +443,7 @@
 	uiBlockSetCurLayout(block, layout);
 }
 
-static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h)
+static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h, int icon_only)
 {
 	EnumPropertyItem *item;
 	const char *identifier;
@@ -463,7 +463,7 @@
 		value= item[a].value;
 		itemw= ui_text_icon_width(block->curlayout, name, icon, 0);
 
-		if(icon && strcmp(name, "") != 0)
+		if(icon && strcmp(name, "") != 0 && !icon_only)
 			uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
 		else if(icon)
 			uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
@@ -477,7 +477,7 @@
 }
 
 /* create label + button for RNA property */
-static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h)
+static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int icon_only)
 {
 	uiLayout *sub;
 	uiBut *but;
@@ -506,7 +506,7 @@
 		but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, "Browse for file or directory.");
 	}
 	else
-		but= uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w, h);
+		but= uiDefAutoButR(block, ptr, prop, index, (icon_only)? "": NULL, icon, x, y, w, h);
 
 	uiBlockSetCurLayout(block, layout);
 	return but;
@@ -788,7 +788,7 @@
 
 /* RNA property items */
 
-static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int *r_w, int *r_h)
+static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int icon_only, int *r_w, int *r_h)
 {
 	PropertyType type;
 	PropertySubType subtype;
@@ -799,9 +799,9 @@
 	subtype= RNA_property_subtype(prop);
 	len= RNA_property_array_length(ptr, prop);
 
-	if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0])
+	if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0] && !icon_only)
 		name= "non-empty text";
-	else if(type == PROP_BOOLEAN && !name[0])
+	else if(type == PROP_BOOLEAN && !name[0] && !icon_only)
 		icon= ICON_DOT;
 
 	w= ui_text_icon_width(layout, name, icon, 0);
@@ -823,7 +823,7 @@
 		if(type == PROP_BOOLEAN && strcmp(name, "") != 0)
 			w += UI_UNIT_X/5;
 		else if(type == PROP_ENUM)
-			w += UI_UNIT_X/2;
+			w += UI_UNIT_X/4;
 		else if(type == PROP_FLOAT || type == PROP_INT)
 			w += UI_UNIT_X*3;
 	}
@@ -838,7 +838,7 @@
 	uiBut *but;
 	PropertyType type;
 	char namestr[UI_MAX_NAME_STR];
-	int len, w, h, slider, toggle, expand;
+	int len, w, h, slider, toggle, expand, icon_only;
 
 	if(!ptr->data || !prop)
 		return;
@@ -872,9 +872,10 @@
 	slider= (flag & UI_ITEM_R_SLIDER);
 	toggle= (flag & UI_ITEM_R_TOGGLE);
 	expand= (flag & UI_ITEM_R_EXPAND);
+	icon_only= (flag & UI_ITEM_R_ICON_ONLY);
 
 	/* get size */
-	ui_item_rna_size(layout, name, icon, ptr, prop, index, &w, &h);
+	ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
 
 	/* array property */
 	if(index == RNA_NO_INDEX && len > 0)
@@ -883,7 +884,7 @@
 	else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) {
 		char *identifier= (char*)RNA_property_identifier(prop);
 
-		if(icon && strcmp(name, "") != 0)
+		if(icon && strcmp(name, "") != 0 && !icon_only)
 			uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
 		else if(icon)
 			uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
@@ -892,10 +893,10 @@
 	}
 	/* expanded enum */
 	else if(type == PROP_ENUM && expand)
-		ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h);
+		ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h, icon_only);
 	/* property with separate label */
 	else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
-		but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h);
+		but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, icon_only);
 		ui_but_add_search(but, ptr, prop, NULL, NULL);
 	}
 	/* single button */
@@ -1160,8 +1161,8 @@
 	/* create button */
 	block= uiLayoutGetBlock(layout);
 
-	ui_item_rna_size(layout, name, icon, ptr, prop, 0, &w, &h);
-	but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h);
+	ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, &w, &h);
+	but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
 
 	ui_but_add_search(but, ptr, prop, searchptr, searchprop);
 }

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c	2009-09-10 11:50:50 UTC (rev 23109)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list