[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18515] branches/blender2.5/blender/source /blender: UI: various changes

Brecht Van Lommel brecht at blender.org
Thu Jan 15 05:13:59 CET 2009


Revision: 18515
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18515
Author:   blendix
Date:     2009-01-15 05:13:38 +0100 (Thu, 15 Jan 2009)

Log Message:
-----------
UI: various changes

* View2D to region now returns ints instead of shorts.
* Use "Numpad" instead of "Pad" in automatic keymap menu info.
* Menus can now use buttons other than BUTM and SEPR, in
  particular TOG and ROW are now supported instead of flipping
  bits manually.
* Added a simpler uiDefMenu* api for making menus now, and it
  only supports Operator and RNA buttons at the moment, will be
  used in next commit. Not sure how this will evolve .. makes
  menu code look cleaner anyways.
* Ensure that interface code doesn't crash when getting unknown
  Operators and RNA properties, and display their buttons grayed
  out in that case.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/gpencil/gpencil.c
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/windowmanager/WM_api.h
    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/source/blender/editors/gpencil/gpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/gpencil.c	2009-01-15 03:12:21 UTC (rev 18514)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/gpencil.c	2009-01-15 04:13:38 UTC (rev 18515)
@@ -770,7 +770,8 @@
 		VecCopyf(p3d, &pt->x);
 	}
 	else {
-		short mval[2], mx, my;
+		short mval[2];
+		int mx, my;
 		float *fp= give_cursor(NULL, NULL); // XXX should be scene, v3d
 		float dvec[3];
 		
@@ -778,15 +779,13 @@
 		if (gps->flag & GP_STROKE_2DSPACE) {
 			// XXX
 			// View2D *v2d= spacelink_get_view2d(curarea->spacedata.first);
-			// UI_view2d_view_to_region(v2d, pt->x, pt->y, mval, mval+1);
+			// UI_view2d_view_to_region(v2d, pt->x, pt->y, &mx, &my);
 		}
 		else {
 			// XXX
-			// mval[0]= (short)(pt->x / 1000 * curarea->winx);
-			// mval[1]= (short)(pt->y / 1000 * curarea->winy);
+			// mx= (short)(pt->x / 1000 * curarea->winx);
+			// my= (short)(pt->y / 1000 * curarea->winy);
 		}
-		mx= mval[0]; 
-		my= mval[1];
 		
 		/* convert screen coordinate to 3d coordinates 
 		 *	- method taken from editview.c - mouse_cursor() 
@@ -1551,7 +1550,7 @@
 {
 	bGPDspoint *pt1, *pt2;
 	View3D *v3d= NULL;
-	short x0=0, y0=0, x1=0, y1=0;
+	int x0=0, y0=0, x1=0, y1=0;
 	short xyval[2];
 	int i;
 	

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-01-15 03:12:21 UTC (rev 18514)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-01-15 04:13:38 UTC (rev 18515)
@@ -268,7 +268,7 @@
 uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2,  char *tip);
-uiBut *uiDefButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
+uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
 
 uiBut *uiDefIconBut(uiBlock *block, 
 					   int type, int retval, int icon, 
@@ -286,7 +286,7 @@
 uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2,  char *tip);
-uiBut *uiDefIconButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
+uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
 
 uiBut *uiDefIconTextBut(uiBlock *block,
 						int type, int retval, int icon, char *str, 
@@ -304,7 +304,7 @@
 uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2,  char *tip);
 uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2,  char *tip);
-uiBut *uiDefIconTextButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
+uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
 
 typedef void		(*uiIDPoinFuncFP)	(struct bContext *C, char *str, struct ID **idpp);
 uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
@@ -318,6 +318,11 @@
 
 void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
 
+uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
+uiBut *uiDefMenuSep(uiBlock *block);
+uiBut *uiDefMenuSub(uiBlock *block, uiBlockFuncFP func, char *name);
+uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, char *propvalue, char *name);
+
 void uiAutoBlock(struct uiBlock *block, 
 				 float minx, float miny, 
 				 float sizex, float sizey, int flag);

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_resources.h	2009-01-15 03:12:21 UTC (rev 18514)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_resources.h	2009-01-15 04:13:38 UTC (rev 18515)
@@ -875,13 +875,6 @@
 };
 /* XXX WARNING: previous is saved in file, so do not change order! */
 
-/* theme drawtypes */
-#define TH_MINIMAL  	0
-#define TH_ROUNDSHADED	1
-#define TH_ROUNDED  	2
-#define TH_OLDSKOOL 	3
-#define TH_SHADED   	4
-
 /* specific defines per space should have higher define values */
 
 struct bTheme;

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2009-01-15 03:12:21 UTC (rev 18514)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2009-01-15 04:13:38 UTC (rev 18515)
@@ -167,8 +167,8 @@
 
 /* coordinate conversion */
 void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
-void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
-void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
+void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony);
+void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y);
 
 /* utilities */
 struct View2D *UI_view2d_fromcontext(const struct bContext *C);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-01-15 03:12:21 UTC (rev 18514)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-01-15 04:13:38 UTC (rev 18515)
@@ -71,6 +71,10 @@
 
 #include "interface_intern.h"
 
+#define MENU_WIDTH 			120
+#define MENU_ITEM_HEIGHT	20
+#define MENU_SEP_HEIGHT		6
+
 /* 
  * a full doc with API notes can be found in bf-blender/blender/doc/interface_API.txt
  * 
@@ -475,6 +479,30 @@
 	return found;
 }
 
+static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
+{
+	uiBut *but;
+	char buf[512], *butstr;
+
+	/* XXX bounds? */
+	for(but=block->buttons.first; but; but=but->next) {
+		if(but->opname) {
+			if(WM_key_event_operator_string(C, but->opname, but->opcontext, buf, sizeof(buf))) {
+				butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
+				strcpy(butstr, but->str);
+				strcat(butstr, "|");
+				strcat(butstr, buf);
+
+				but->str= but->strdata;
+				BLI_strncpy(but->str, butstr, sizeof(but->strdata));
+				MEM_freeN(butstr);
+
+				ui_check_but(but);
+			}
+		}
+	}
+}
+
 void uiEndBlock(const bContext *C, uiBlock *block)
 {
 	uiBut *but;
@@ -494,8 +522,9 @@
 
 		block->oldblock= NULL;
 	}
-	
+
 	/* handle pending stuff */
+	if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
 	if(block->autofill) ui_autofill(block);
 	if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0);
 	if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
@@ -1489,6 +1518,7 @@
 
 		block->aspect= 2.0/fabs(getsizex*block->winmat[0][0]);
 		block->auto_open= 2;
+		block->flag |= UI_BLOCK_LOOP; /* tag as menu */
 	}
 
 	uiSetCurFont(block, font);
@@ -1676,7 +1706,7 @@
 	}
 
 	if(but->strwidth==0) but->drawstr[0]= 0;
-	else if(but->type==BUTM || but->type==BLOCK);	// no clip string, uiTextBoundsBlock is used (hack!)
+	else if(but->block->flag & UI_BLOCK_LOOP);	// no clip string, uiTextBoundsBlock is used (hack!)
 	else {
 
 		/* calc but->ofs, to draw the string shorter if too long */
@@ -1714,6 +1744,8 @@
 
 static int ui_auto_themecol(uiBut *but)
 {
+	if(but->block->flag & UI_BLOCK_LOOP)
+		return TH_MENU_ITEM;
 
 	switch(but->type) {
 	case BUT:
@@ -1737,8 +1769,6 @@
 	case BLOCK:
 	case MENU:
 	case BUTM:
-		// (weak!) detect if it is a blockloop
-		if(but->block->dt == UI_EMBOSSP) return TH_MENU_ITEM;
 		return TH_BUT_POPUP;
 	case ROUNDBOX:
 		return TH_PANEL;
@@ -1994,11 +2024,9 @@
 	if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
 	else but->themecol= block->themecol;
 
-	if(but->type != BUTM) {
-		but->func= block->func;
-		but->func_arg1= block->func_arg1;
-		but->func_arg2= block->func_arg2;
-	}
+	but->func= block->func;
+	but->func_arg1= block->func_arg1;
+	but->func_arg2= block->func_arg2;
 	
 	ui_set_embossfunc(but, block->dt);
 	
@@ -2020,7 +2048,7 @@
 		rgb_to_hsv(rgb[0], rgb[1], rgb[2], but->hsv, but->hsv+1, but->hsv+2);
 	}
 
-	if ELEM8(but->type, HSVSLI , NUMSLI, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list