[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18747] branches/blender2.5/blender/source /blender: 2.5: UI & Menus

Brecht Van Lommel brecht at blender.org
Fri Jan 30 13:18:11 CET 2009


Revision: 18747
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18747
Author:   blendix
Date:     2009-01-30 13:18:08 +0100 (Fri, 30 Jan 2009)

Log Message:
-----------
2.5: UI & Menus

* Cleaned up UI_interface.h a bit, and added some comments to
  organize things a bit and indicate what should be used when.

* uiMenu* functions can now be used to create menus for headers
  too, this is done with a uiDefMenuBut, which takes a pointer
  to a uiMenuCreateFunc, that will then call uiMenu* functions.

* Renamed uiMenuBegin/End to uiPupMenuBegin/End, as these are
  specific to making popup menus. Will convert the other
  conformation popup menu functions to use this too so we can
  remove some code.

* Extended uiMenu functions, now there is is also:
  BooleanO, FloatO, BooleanR, EnumR, LevelEnumR, Separator.

* Converted image window headers to use uiMenu functions, simplifies
  menu code further here. Did not remove the uiDefMenu functions as
  they are used in sequencer/view3d in some places now (will fix).

* Also tried to simplify and fix bounds computation a bit better
  for popup menus. It tried to find out in advance what the size
  of the menu was but this is difficult with keymap strings in
  there, now uiPopupBoundsBlock can figure this out afterwards and
  ensure the popup is within the window bounds. Will convert some
  other functions to use this too.

Modified Paths:
--------------
    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/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_draw.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_panel.c
    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_action/action_header.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_header.c
    branches/blender2.5/blender/source/blender/editors/space_file/file_header.c
    branches/blender2.5/blender/source/blender/editors/space_image/image_header.c
    branches/blender2.5/blender/source/blender/editors/space_info/info_header.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/ipo_header.c
    branches/blender2.5/blender/source/blender/editors/space_nla/nla_header.c
    branches/blender2.5/blender/source/blender/editors/space_node/node_draw.c
    branches/blender2.5/blender/source/blender/editors/space_node/node_header.c
    branches/blender2.5/blender/source/blender/editors/space_outliner/outliner_header.c
    branches/blender2.5/blender/source/blender/editors/space_script/script_header.c
    branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_header.c
    branches/blender2.5/blender/source/blender/editors/space_sound/sound_header.c
    branches/blender2.5/blender/source/blender/editors/space_text/text_header.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_header.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/util/editmode_undo.c
    branches/blender2.5/blender/source/blender/render/intern/source/occlusion.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.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-01-30 10:08:58 UTC (rev 18746)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_util.h	2009-01-30 12:18:08 UTC (rev 18747)
@@ -30,7 +30,7 @@
 
 struct Object;
 struct bContext;
-struct uiMenuBlockHandle;
+struct ARegion;
 struct uiBlock;
 struct wmOperatorType;
 
@@ -55,7 +55,7 @@
 
 						
 void	*undo_editmode_get_prev		(struct Object *ob);
-struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg_unused);
+struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct ARegion *ar, void *arg_unused);
 void	undo_editmode_menu			(struct bContext *C);
 void	undo_editmode_clear			(void);
 void	undo_editmode_step			(struct bContext *C, int step);

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-30 10:08:58 UTC (rev 18746)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-01-30 12:18:08 UTC (rev 18747)
@@ -30,6 +30,8 @@
 #ifndef UI_INTERFACE_H
 #define UI_INTERFACE_H
 
+/* Struct Declarations */
+
 struct ID;
 struct ListBase;
 struct ARegion;
@@ -42,6 +44,12 @@
 struct PropertyRNA;
 struct ReportList;
 
+typedef struct uiBut uiBut;
+typedef struct uiBlock uiBlock;
+typedef struct uiPopupBlockHandle uiPopupBlockHandle;
+
+/* Defines */
+
 /* uiBlock->dt */
 #define UI_EMBOSS		0	/* use one of the themes for drawing */
 #define UI_EMBOSSN		1	/* Nothing */
@@ -76,7 +84,7 @@
 #define UI_BLOCK_MOVEMOUSE_QUIT	128
 #define UI_BLOCK_KEEP_OPEN		256
 
-/* uiMenuBlockHandle->menuretval */
+/* uiPopupBlockHandle->menuretval */
 #define UI_RETURN_CANCEL	1       /* cancel all menus cascading */
 #define UI_RETURN_OK        2       /* choice made */
 #define UI_RETURN_OUT       4       /* left the menu */
@@ -169,13 +177,14 @@
 #define ICONTOGN (34<<9)
 #define FTPREVIEW (35<<9)
 #define NUMABS	(36<<9)
+#define HMENU	(37<<9)
 #define BUTTYPE	(63<<9)
 
-typedef struct uiBut uiBut;
-typedef struct uiBlock uiBlock;
+/* Drawing
+ *
+ * Functions to draw various shapes, taking theme settings into account.
+ * Used for code that draws its own UI style elements. */
 
-/* Common Drawing Functions */
-
 void uiEmboss(float x1, float y1, float x2, float y2, int sel);
 void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
 void uiSetRoundBox(int type);
@@ -183,92 +192,138 @@
 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
 
-/* Popup Menu's */
+/* Menus
+ *
+ * These functions are used by popup menus, toolbox and header menus. They
+ * assume uiMenuItem head is already created, which is done by uiMenuButton
+ * for header menus, or can be done with uiPupMenuBegin for popups. These
+ * functions do not use uiDefBut functions in order to simplify creating
+ * them, and to permit other types of menus (radial, ..) in the future. */
 
-typedef struct uiMenuBlockHandle {
-	/* internal */
-	struct ARegion *region;
-	int towardsx, towardsy;
-	double towardstime;
-	int dotowards;
-
-	int popup;
-	void (*popup_func)(struct bContext *C, void *arg, int event);
-	void *popup_arg;
-	/* for operator menus */
-	struct wmOperator *op_arg;
-	const char *propname;
-	
-	/* return values */
-	int butretval;
-	int menuretval;
-	float retvalue;
-	float retvec[3];
-} uiMenuBlockHandle;
-
-typedef uiBlock* (*uiBlockFuncFP)(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg1);
-typedef void (*uiPupmenuFunc)(struct bContext *C, void *arg, int event);
-
-void uiPupmenuSetActive(int val);
-
-void uiPupmenuOperator(struct bContext *C, int maxrow, struct  wmOperator *op, const char *propname, char *str);
-void uiPupmenu(struct bContext *C, int maxrow, uiPupmenuFunc func, void *arg, 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, ...);
-void uiPupmenuError(struct bContext *C, char *str, ...);
-void uiPupmenuReports(struct bContext *C, struct ReportList *reports);
-
-/* Custom popup menus and toolbox */
 typedef struct uiMenuItem uiMenuItem;
 
-uiMenuItem *uiMenuBegin(const char *title);
+typedef void (*uiMenuCreateFunc)(struct bContext *C, uiMenuItem *head, void *arg1);
+typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event);
 
-void uiMenuFunc(uiMenuItem *head, void (*eventfunc)(struct bContext *, void *, int), void *argv);
+void uiMenuFunc(uiMenuItem *head, uiMenuHandleFunc handlefunc, void *argv);
 void uiMenuContext(uiMenuItem *head, int opcontext);
 
 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 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 uiMenuLevel(uiMenuItem *head, const char *name, void (*newlevel)(uiMenuItem *));
+
+void uiMenuItemBooleanR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
+void uiMenuItemEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname, int value);
+void uiMenuItemsEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
+
+void uiMenuLevel(uiMenuItem *head, const char *name, uiMenuCreateFunc newlevel);
 void uiMenuLevelEnumO(uiMenuItem *head, char *opname, char *propname);
+void uiMenuLevelEnumR(uiMenuItem *head, struct PointerRNA *ptr, char *propname);
 
-void uiMenuEnd(struct bContext *C, struct uiMenuItem *head);
+void uiMenuSeparator(uiMenuItem *head);
 
-/* Block */
+/* Popup Menus
+ *
+ * Functions used to create popup menus. For more extended menus the
+ * uiPupMenuBegin/End functions can be used to define own items with
+ * 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);
+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, ...);
+void uiPupMenuError(struct bContext *C, char *str, ...);
+void uiPupMenuReports(struct bContext *C, struct ReportList *reports);
+
+void uiPupMenuSetActive(int val);
+
+/* Popup Blocks
+ *
+ * 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);
+
+/* Blocks
+ *
+ * Functions for creating, drawing and freeing blocks. A Block is a
+ * container of buttons and used for various purposes.
+ * 
+ * Begin/Define Buttons/End/Draw is the typical order in which these
+ * function should be called, though for popup blocks Draw is left out.
+ * Freeing blocks is done by the screen/ module automatically.
+ *
+ * */
+
 uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, char *name, short dt, short font);
 void uiEndBlock(const struct bContext *C, uiBlock *block);
 void uiDrawBlock(const struct bContext *C, struct uiBlock *block);
+
 uiBlock *uiGetBlock(char *name, struct ARegion *ar);
+
 void uiFreeBlock(const struct bContext *C, uiBlock *block);
 void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
 void uiFreeInactiveBlocks(const struct bContext *C, struct ListBase *lb);
 
-void uiBoundsBlock(struct uiBlock *block, int addval);
-void uiTextBoundsBlock(uiBlock *block, int addval);
-
 void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
 void uiBlockClearButLock(uiBlock *block);
 
+/* Appearance/Cruft
+ *
+ * These functions should mostly dissappear ideally, or become internal.
+ * Font handling could move to blenfont/, and appearance could be dictated
+ * better by high level information instead of spread out all over. */
+
+void uiSetCurFont(uiBlock *block, int index);
+void *uiSetCurFont_ext(float aspect);
+void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
+void *uiBlockGetCurFont	(uiBlock *block);
+
 /* automatic aligning, horiz or verical */
 void uiBlockBeginAlign(uiBlock *block);
 void uiBlockEndAlign(uiBlock *block);
 
-/* Misc */
+void uiBoundsBlock(struct uiBlock *block, int addval);
+void uiTextBoundsBlock(uiBlock *block, int addval);
+void uiPopupBoundsBlock(uiBlock *block, int addval);
 
-void uiSetCurFont(uiBlock *block, int index);
-void *uiSetCurFont_ext(float aspect);
-void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
+int		uiBlocksGetYMin		(ListBase *lb);
+int		uiBlockGetCol		(uiBlock *block);
 
-void uiComposeLinks(uiBlock *block);
-uiBut *uiFindInlink(uiBlock *block, void *poin);
+void	uiBlockSetCol		(uiBlock *block, int col);
+void	uiBlockSetEmboss	(uiBlock *block, int emboss);
+void	uiBlockSetDirection	(uiBlock *block, int direction);
+void 	uiBlockFlipOrder	(uiBlock *block);
+void	uiBlockSetFlag		(uiBlock *block, int flag);
+void	uiBlockSetXOfs		(uiBlock *block, int xofs);
 
-void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
+int		uiButGetRetVal		(uiBut *but);
 
-/* Defining Buttons */
+void	uiButSetFlag		(uiBut *but, int flag);
+void	uiButClearFlag		(uiBut *but, int flag);
 
+void	uiAutoBlock(uiBlock *block, float minx, float miny, float sizex, float sizey, int flag);
+
+/* Buttons
+ *

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list