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

Brecht Van Lommel brecht at blender.org
Wed Feb 4 12:52:23 CET 2009


Revision: 18809
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18809
Author:   blendix
Date:     2009-02-04 12:52:16 +0100 (Wed, 04 Feb 2009)

Log Message:
-----------
UI
* Changed uiPupMenuOperator usage to uiPupMenuBegin/End (simpler,
  no need to build a string). Also made transform orientation and
  subdiv type enums instead of ints for this.
* Added an icon argument to many of the uiMenu calls, and added a
  uiMenuItemIntO.
* Move auto rna button creation out of outliner code, now is
  uiDefAutoButR for individual buttons and uiDefAutoButsRNA for a
  whole block.
* Implemented uiPupBlock(O). Pressing F6 gives a menu with the
  properties of the last operator to test. I tried to make a redo
  last operator out of this but couldn't get the context correct
  for the operator to repeat in. Further the popup block also has
  some issues getting closed while editing buttons.
* Fix uiAfterFunc memory leak on Ctrl+Q quit.
* Fix handling of RNA number button dragging and sliding for RNA
  buttons with range -inf/inf.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h
    branches/blender2.5/blender/source/blender/editors/include/ED_util.h
    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/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_header.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_orientations.c
    branches/blender2.5/blender/source/blender/editors/util/undo.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c

Modified: branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_transform.h	2009-02-04 11:52:16 UTC (rev 18809)
@@ -37,6 +37,7 @@
 struct wmEvent;
 struct bContext;
 struct Object;
+struct uiMenuItem;
 
 void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid);
 void transform_operatortypes(void);
@@ -113,6 +114,7 @@
 void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
 void BIF_selectTransformOrientationValue(struct bContext *C, int orientation);
 
+void BIF_menuTransformOrientation(struct bContext *C, struct uiMenuItem *head, void *arg);
 char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
 int BIF_countTransformOrientation(const struct bContext *C);
 

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_util.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_util.h	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_util.h	2009-02-04 11:52:16 UTC (rev 18809)
@@ -44,6 +44,7 @@
 /* undo.c */
 void	ED_undo_push			(struct bContext *C, char *str);
 void	ED_undo_push_op			(struct bContext *C, struct wmOperator *op);
+void	ED_undo_pop				(struct bContext *C);
 void	ED_OT_undo				(struct wmOperatorType *ot);
 void	ED_OT_redo				(struct wmOperatorType *ot);
 

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-02-04 11:52:16 UTC (rev 18809)
@@ -210,11 +210,12 @@
 
 void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval);
 
-void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value);
-void uiMenuItemBooleanO(uiMenuItem *head, char *opname, char *propname, int value);
+void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value);
+void uiMenuItemBooleanO(uiMenuItem *head, int icon, char *opname, char *propname, int value);
 void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname);
-void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *propname, float value);
-void uiMenuItemO(uiMenuItem *head, char *name, int icon);
+void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value);
+void uiMenuItemFloatO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, float value);
+void uiMenuItemO(uiMenuItem *head, int icon, char *opname);
 
 void uiMenuItemBooleanR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
 void uiMenuItemEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname, int value);
@@ -233,11 +234,10 @@
  * the uiMenu functions inbetween. If it is a simple confirmation menu
  * or similar, popups can be created with a single function call. */
 
-uiMenuItem *uiPupMenuBegin(const char *title);
+uiMenuItem *uiPupMenuBegin(const char *title, int icon);
 void uiPupMenuEnd(struct bContext *C, struct uiMenuItem *head);
 
 void uiPupMenu(struct bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...);
-void uiPupMenuOperator(struct bContext *C, int maxrow, struct  wmOperator *op, const char *propname, char *str);
 void uiPupMenuOkee(struct bContext *C, char *opname, char *str, ...);
 void uiPupMenuSaveOver(struct bContext *C, char *opname, char *filename, ...);
 void uiPupMenuNotice(struct bContext *C, char *str, ...);
@@ -251,9 +251,11 @@
  * Functions used to create popup blocks. These are like popup menus
  * but allow using all button types and creating an own layout. */
 
-uiBlock *uiPupBlockBegin(struct bContext *C, const char *title);
-void uiPupBlockEnd(struct bContext *C, uiBlock *block);
+typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
 
+void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
+void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
+
 /* Blocks
  *
  * Functions for creating, drawing and freeing blocks. A Block is a
@@ -295,7 +297,8 @@
 
 void uiBoundsBlock(struct uiBlock *block, int addval);
 void uiTextBoundsBlock(uiBlock *block, int addval);
-void uiPopupBoundsBlock(uiBlock *block, int addval);
+void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my);
+void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my);
 
 int		uiBlocksGetYMin		(ListBase *lb);
 int		uiBlockGetCol		(uiBlock *block);
@@ -389,9 +392,9 @@
  * - PulldownBut: like MenuBut, but creating a uiBlock (for compatibility).
  * - BlockBut: buttons that popup a block with more buttons.
  * - KeyevtBut: buttons that can be used to turn key events into values.
- * - PickerButtons: buttons like the color picker (for code sharing). */
+ * - PickerButtons: buttons like the color picker (for code sharing).
+ * - AutoButR: RNA property button with type automatically defined. */
 
-typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, void *arg1);
 typedef void     (*uiIDPoinFuncFP)(struct bContext *C, char *str, struct ID **idpp);
 
 uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
@@ -409,6 +412,9 @@
 
 void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
 
+uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2);
+int uiDefAutoButsRNA(uiBlock *block, struct PointerRNA *ptr);
+
 /* Links
  *
  * Game engine logic brick links. Non-functional currently in 2.5,

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_resources.h	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_resources.h	2009-02-04 11:52:16 UTC (rev 18809)
@@ -878,6 +878,7 @@
 /* specific defines per space should have higher define values */
 
 struct bTheme;
+struct PointerRNA;
 
 // THE CODERS API FOR THEMES:
 
@@ -919,6 +920,8 @@
 // get a 3 byte color, blended and shaded between two other char color pointers
 void	UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset);
 
+// get pointer from RNA pointer
+int		UI_GetIconRNA(struct PointerRNA *ptr);
 
 struct ScrArea;
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-02-04 11:52:16 UTC (rev 18809)
@@ -304,23 +304,28 @@
 	block->safety.ymax= block->maxy+xof;
 }
 
-static void ui_popup_bounds_block(const bContext *C, uiBlock *block)
+static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int menu)
 {
+	wmWindow *window= CTX_wm_window(C);
 	int startx, starty, endx, endy, width, height;
 	int oldbounds, mx, my, xmax, ymax;
 
 	oldbounds= block->bounds;
 
-	/* compute bounds */
+	/* compute mouse position with user defined offset */
 	ui_bounds_block(block);
-	mx= block->minx;
-	my= block->miny;
+	mx= window->eventstate->x + block->minx + block->mx;
+	my= window->eventstate->y + block->miny + block->my;
 
-	wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
+	wm_window_get_size(window, &xmax, &ymax);
 
 	/* first we ensure wide enough text bounds */
-	block->bounds= 50;
-	ui_text_bounds_block(block, block->minx);
+	if(menu) {
+		if(block->flag & UI_BLOCK_LOOP) {
+			block->bounds= 50;
+			ui_text_bounds_block(block, block->minx);
+		}
+	}
 
 	/* next we recompute bounds */
 	block->bounds= oldbounds;
@@ -373,13 +378,24 @@
 	block->dobounds= 2;
 }
 
-/* used for menu popups */
-void uiPopupBoundsBlock(uiBlock *block, int addval)
+/* used for block popups */
+void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
 {
 	block->bounds= addval;
 	block->dobounds= 3;
+	block->mx= mx;
+	block->my= my;
 }
 
+/* used for menu popups */
+void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
+{
+	block->bounds= addval;
+	block->dobounds= 4;
+	block->mx= mx;
+	block->my= my;
+}
+
 void ui_autofill(uiBlock *block)
 {
 	uiBut *but;
@@ -594,7 +610,7 @@
 	/* after keymaps! */
 	if(block->dobounds == 1) ui_bounds_block(block);
 	else if(block->dobounds == 2) ui_text_bounds_block(block, 0.0f);
-	else if(block->dobounds == 3) ui_popup_bounds_block(C, block);
+	else if(block->dobounds) ui_popup_bounds_block(C, block, (block->dobounds == 4));
 
 	if(block->autofill) ui_autofill(block);
 	if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2009-02-04 11:47:05 UTC (rev 18808)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2009-02-04 11:52:16 UTC (rev 18809)
@@ -23,6 +23,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <float.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -250,34 +251,35 @@
 
 static void ui_apply_but_funcs_after(bContext *C)
 {
-	uiAfterFunc *after;
+	uiAfterFunc *afterf, after;
 	ListBase funcs;
 
 	/* copy to avoid recursive calls */
 	funcs= UIAfterFuncs;
 	UIAfterFuncs.first= UIAfterFuncs.last= NULL;
 
-	for(after=funcs.first; after; after=after->next) {
-		if(after->func)
-			after->func(C, after->func_arg1, after->func_arg2);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list