UI
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 4 Feb 2009 11:52:16 +0000 (11:52 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 4 Feb 2009 11:52:16 +0000 (11:52 +0000)
* 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.

19 files changed:
source/blender/editors/include/BIF_transform.h
source/blender/editors/include/ED_util.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_utils.c [new file with mode: 0644]
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/undo.c
source/blender/windowmanager/intern/wm_operators.c

index 5039d5e0f7e2b5543369cb49e9d12a6b20033bc4..4375bd027d7cbb7b6fb268c7a0b1708364087fbd 100644 (file)
@@ -37,6 +37,7 @@ struct ListBase;
 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 @@ int BIF_menuselectTransformOrientation(void);
 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);
 
index 6f0c475f39c2af1e7344175c0f82948b5dbede19..7002524be7e27e03d21bfb92fed268c4f6b0c18b 100644 (file)
@@ -44,6 +44,7 @@ void  ED_editors_exit                 (struct bContext *C);
 /* 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);
 
index 8ad4ea2a1e759e9e8fdd0c7cfcc574dc4d8e4003..a81d956f01e16cd61a5a2b6c3763fd1ce1ffda27 100644 (file)
@@ -210,11 +210,12 @@ 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 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 @@ void uiMenuSeparator(uiMenuItem *head);
  * 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,8 +251,10 @@ void uiPupMenuSetActive(int val);
  * 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
  *
@@ -295,7 +297,8 @@ void uiBlockEndAlign(uiBlock *block);
 
 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 @@ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
  * - 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 uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1,
 
 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,
index 939c5b005c297186a1ca044e8e2d8bfca7312367..5012a71a64723f8011ea04dcd3bb343f8fda7084 100644 (file)
@@ -878,6 +878,7 @@ enum {
 /* specific defines per space should have higher define values */
 
 struct bTheme;
+struct PointerRNA;
 
 // THE CODERS API FOR THEMES:
 
@@ -919,6 +920,8 @@ void        UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset);
 // 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;
 
index ce842699ce2b0171b26d3274a91d963832904df7..032aa952c5e8b9038d5eeca850d0920dd5bd1aad 100644 (file)
@@ -304,23 +304,28 @@ void ui_bounds_block(uiBlock *block)
        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,11 +378,22 @@ void uiTextBoundsBlock(uiBlock *block, int addval)
        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)
@@ -594,7 +610,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
        /* 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);
index f2275a18db40009774b6eda4eacfc3db8f0d14cd..ac5e64c80a53de6fae93241239d0b2ebab3bde51 100644 (file)
@@ -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_func(bContext *C, uiBut *but)
 
 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);
+       for(afterf=funcs.first; afterf; afterf=after.next) {
+               after= *afterf; /* copy to avoid memleak on exit() */
+               BLI_freelinkN(&funcs, afterf);
+
+               if(after.func)
+                       after.func(C, after.func_arg1, after.func_arg2);
                
-               if(after->handle_func)
-                       after->handle_func(C, after->handle_func_arg, after->retval);
-               if(after->butm_func)
-                       after->butm_func(C, after->butm_func_arg, after->a2);
+               if(after.handle_func)
+                       after.handle_func(C, after.handle_func_arg, after.retval);
+               if(after.butm_func)
+                       after.butm_func(C, after.butm_func_arg, after.a2);
 
-               if(after->opname)
-                       WM_operator_name_call(C, after->opname, after->opcontext, after->opptr);
-               if(after->opptr) {
-                       WM_operator_properties_free(after->opptr);
-                       MEM_freeN(after->opptr);
+               if(after.opname)
+                       WM_operator_name_call(C, after.opname, after.opcontext, after.opptr);
+               if(after.opptr) {
+                       WM_operator_properties_free(after.opptr);
+                       MEM_freeN(after.opptr);
                }
 
-               if(after->rnapoin.data)
-                       RNA_property_update(C, &after->rnapoin, after->rnaprop);
+               if(after.rnapoin.data)
+                       RNA_property_update(C, &after.rnapoin, after.rnaprop);
        }
-
-       BLI_freelistN(&funcs);
 }
 
 static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -1373,9 +1375,18 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
 
 /* ************* number editing for various types ************* */
 
+static void but_clamped_range(uiBut *but, float *butmin, float *butmax, float *butrange)
+{
+       /* clamp button range to something reasonable in case
+        * we get -inf/inf from RNA properties */
+       *butmin= MAX2(but->min, -1e4f);
+       *butmax= MIN2(but->max, 1e4f);
+       *butrange= *butmax - *butmin;
+}
+
 static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
 {
-       float butrange;
+       float butrange, butmin, butmax;
 
        if(but->type == BUT_CURVE) {
                data->cumap= (CurveMapping*)but->poin;
@@ -1395,8 +1406,9 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
                data->value= data->origvalue;
                but->editval= &data->value;
 
-               butrange= (but->max - but->min);
-               data->dragfstart= (butrange == 0.0)? 0.0f: (data->value - but->min)/butrange;
+               but_clamped_range(but, &butmin, &butmax, &butrange);
+
+               data->dragfstart= (butrange == 0.0)? 0.0f: (data->value - butmin)/butrange;
                data->dragf= data->dragfstart;
        }
 
@@ -1603,7 +1615,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
 
 static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
 {
-       float deler, tempf;
+       float deler, tempf, butmin, butmax, butrange;
        int lvalue, temp, changed= 0;
        
        if(mx == data->draglastx)
@@ -1619,28 +1631,30 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                data->dragstartx= mx;  /* ignore mouse movement within drag-lock */
        }
 
+       but_clamped_range(but, &butmin, &butmax, &butrange);
+
        deler= 500;
        if(!ui_is_but_float(but)) {
-               if((but->max-but->min)<100) deler= 200.0;
-               if((but->max-but->min)<25) deler= 50.0;
+               if((butrange)<100) deler= 200.0;
+               if((butrange)<25) deler= 50.0;
        }
        deler /= fac;
 
-       if(ui_is_but_float(but) && but->max-but->min > 11) {
+       if(ui_is_but_float(but) && butrange > 11) {
                /* non linear change in mouse input- good for high precicsion */
                data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002);
-       } else if (!ui_is_but_float(but) && but->max-but->min > 129) { /* only scale large int buttons */
+       } else if (!ui_is_but_float(but) && butrange > 129) { /* only scale large int buttons */
                /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
                data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004);
        } else {
                /*no scaling */
                data->dragf+= ((float)(mx-data->draglastx))/deler ;
        }
-       
+
        if(data->dragf>1.0) data->dragf= 1.0;
        if(data->dragf<0.0) data->dragf= 0.0;
        data->draglastx= mx;
-       tempf= ( but->min + data->dragf*(but->max-but->min));
+       tempf= (butmin + data->dragf*butrange);
        
        if(!ui_is_but_float(but)) {
                
@@ -1667,14 +1681,14 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
                if(snap) {
                        if(snap == 2) {
                                if(tempf==but->min || tempf==but->max);
-                               else if(but->max-but->min < 2.10) tempf= 0.01*floor(100.0*tempf);
-                               else if(but->max-but->min < 21.0) tempf= 0.1*floor(10.0*tempf);
+                               else if(butrange < 2.10) tempf= 0.01*floor(100.0*tempf);
+                               else if(butrange < 21.0) tempf= 0.1*floor(10.0*tempf);
                                else tempf= floor(tempf);
                        }
                        else {
                                if(tempf==but->min || tempf==but->max);
-                               else if(but->max-but->min < 2.10) tempf= 0.1*floor(10*tempf);
-                               else if(but->max-but->min < 21.0) tempf= floor(tempf);
+                               else if(butrange < 2.10) tempf= 0.1*floor(10*tempf);
+                               else if(butrange < 21.0) tempf= floor(tempf);
                                else tempf= 10.0*floor(tempf/10.0);
                        }
                }
@@ -1818,9 +1832,11 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
 
 static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, int ctrl, int mx)
 {
-       float deler, f, tempf;
+       float deler, f, tempf, butmin, butmax, butrange;
        int temp, lvalue, changed= 0;
 
+       but_clamped_range(but, &butmin, &butmax, &butrange);
+
        if(but->type==NUMSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
        else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
        else deler= (but->x2-but->x1- 5.0*but->aspect);
@@ -1831,7 +1847,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
                f= (f-data->dragfstart)/10.0 + data->dragfstart;
 
        CLAMP(f, 0.0, 1.0);
-       tempf= but->min+f*(but->max-but->min);          
+       tempf= butmin + f*butrange;
        temp= floor(tempf+.5);
 
        if(ctrl) {
@@ -1927,11 +1943,13 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
 
        if(click) {
                float f, h;
-               float tempf;
+               float tempf, butmin, butmax, butrange;
                int temp;
                
                button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 
+               but_clamped_range(but, &butmin, &butmax, &butrange);
+
                tempf= data->value;
                temp= (int)data->value;
 
@@ -1940,7 +1958,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1-h);
                else f= (float)(mx- (but->x1+but->x2)/2)/((but->x2-but->x1)/2 - h);
                
-               f= but->min+f*(but->max-but->min);
+               f= butmin + f*butrange;
 
                if(!ui_is_but_float(but)) {
                        if(f<temp) temp--;
@@ -2848,7 +2866,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
                button_tooltip_timer_reset(but);
 
                /* automatic open pulldown block timer */
-               if(ELEM5(but->type, BLOCK, MENU, PULLDOWN, HMENU, ICONTEXTROW)) {
+               if(ELEM4(but->type, BLOCK, PULLDOWN, HMENU, ICONTEXTROW)) {
                        if(!data->autoopentimer) {
                                int time;
 
@@ -3709,19 +3727,11 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
                WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
 
                if(temp.menuretval == UI_RETURN_OK) {
-                       if(temp.popup_func) {
-                               temp.popup_func(C, temp.op_arg, temp.retvalue);
-                       }
-                       else if(temp.op_arg) {
-                               if(temp.propname)
-                                       RNA_enum_set(temp.op_arg->ptr, temp.propname, temp.retvalue);
-                               WM_operator_call(C, temp.op_arg);
-                       }
+                       if(temp.popup_func)
+                               temp.popup_func(C, temp.popup_arg, temp.retvalue);
+                       if(temp.opname)
+                               WM_operator_name_call(C, temp.opname, temp.opcontext, NULL);
                }
-               /* always free operator */
-               else if(temp.op_arg)
-                       WM_operator_free(temp.op_arg);
-               
        }
        else {
                /* re-enable tooltips */
@@ -3757,3 +3767,4 @@ void UI_add_popup_handlers(ListBase *handlers, uiPopupBlockHandle *menu)
 {
        WM_event_add_ui_handler(NULL, handlers, ui_handler_popup, ui_handler_remove_popup, menu);
 }
+
index d66c6e4129e5a8007c30ff168103cd7e1f64d7ca..ce6410765542a15f6a4ed0fa9dd768f446abcd20 100644 (file)
@@ -218,7 +218,7 @@ struct uiBlock {
        char *lockstr;
        
        float xofs, yofs;                               // offset to parent button
-       int bounds, dobounds;                   // for doing delayed
+       int bounds, dobounds, mx, my;   // for doing delayed
        int endblock;                                   // uiEndBlock done?
 
        rctf safety;                            // pulldowns, to detect outside, can differ per case how it is created
@@ -277,9 +277,10 @@ struct uiPopupBlockHandle {
        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;
+
+       /* for operator popups */
+       const char *opname;
+       int opcontext;
        
        /* return values */
        int butretval;
index 09bbbb9ea60d24d88f169d1b018dff0b41fbfe3a..ffd742098de6941ece57f8fa75e8863abe102382 100644 (file)
@@ -1657,13 +1657,14 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
 #define MENU_ITEM_OPNAME                       2
 #define MENU_ITEM_OPNAME_BOOL          3
 #define MENU_ITEM_OPNAME_ENUM          4
-#define MENU_ITEM_OPNAME_FLOAT         5
-#define MENU_ITEM_RNA_BOOL                     6
-#define MENU_ITEM_RNA_ENUM                     7
-#define MENU_ITEM_LEVEL                                8
-#define MENU_ITEM_LEVEL_OPNAME_ENUM    9
-#define MENU_ITEM_LEVEL_RNA_ENUM       10
-#define MENU_ITEM_SEPARATOR                    11
+#define MENU_ITEM_OPNAME_INT           5
+#define MENU_ITEM_OPNAME_FLOAT         6
+#define MENU_ITEM_RNA_BOOL                     7
+#define MENU_ITEM_RNA_ENUM                     8
+#define MENU_ITEM_LEVEL                                9
+#define MENU_ITEM_LEVEL_OPNAME_ENUM    10
+#define MENU_ITEM_LEVEL_RNA_ENUM       11
+#define MENU_ITEM_SEPARATOR                    12
 
 struct uiMenuItem {
        struct uiMenuItem *next, *prev;
@@ -1675,7 +1676,7 @@ struct uiMenuItem {
        char *opname;   /* static string */
        char *propname; /* static string */
        
-       int retval, enumval, boolval;
+       int retval, enumval, boolval, intval;
        float fltval;
        int opcontext;
        uiMenuHandleFunc eventfunc;
@@ -1762,15 +1763,15 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
        block->themecol= TH_MENU_ITEM;
        block->direction= UI_DOWN;
 
-       width= 50; // fixed with, uiPopupBoundsBlock will compute actual width
+       width= 50; // fixed with, uiMenuPopupBoundsBlock will compute actual width
 
        for(item= head->items.first; item; item= item->next) {
                if(0) height+= PUP_LABELH; // XXX sepr line
                else height+= MENU_BUTTON_HEIGHT;
        }
 
-       startx= info->mx;
-       starty= info->my-height+MENU_BUTTON_HEIGHT/2;
+       startx= 0;
+       starty= 0;
        
        /* here we go! */
        if(head->name[0]) {
@@ -1836,6 +1837,12 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
                        
                        y1 -= MENU_BUTTON_HEIGHT;
                }
+               else if(item->type==MENU_ITEM_OPNAME_INT) {
+                       but= uiDefIconTextButO(block, BUTM, item->opname, head->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
+                       RNA_int_set(uiButGetOperatorPtrRNA(but), item->propname, item->intval);
+                       
+                       y1 -= MENU_BUTTON_HEIGHT;
+               }
                else if(item->type==MENU_ITEM_OPNAME_FLOAT) {
                        but= uiDefIconTextButO(block, BUTM, item->opname, item->opcontext, item->icon, item->name, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, "");
                        RNA_float_set(uiButGetOperatorPtrRNA(but), item->propname, item->fltval);
@@ -1890,7 +1897,8 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle,
                uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
                uiBlockSetDirection(block, UI_DOWN);
 
-               uiPopupBoundsBlock(block, 1);
+               /* here we set an offset for the mouse position */
+               uiMenuPopupBoundsBlock(block, 1, 0, -height+MENU_BUTTON_HEIGHT/2);
        }
        else {
                /* for a header menu we set the direction automatic */
@@ -1985,18 +1993,18 @@ void uiMenuItemVal(uiMenuItem *head, const char *name, int icon, int argval)
 }
 
 /* regular operator item */
-void uiMenuItemO(uiMenuItem *head, char *name, int icon)
+void uiMenuItemO(uiMenuItem *head, int icon, char *opname)
 {
-       uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
+       uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
        
-       item->opname= name; // static!
+       item->opname= opname; // static!
        item->type = MENU_ITEM_OPNAME;
 }
 
 /* single operator item with property */
-void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value)
+void uiMenuItemEnumO(uiMenuItem *head, int icon, char *opname, char *propname, int value)
 {
-       uiMenuItem *item= ui_menu_add_item(head, "", 0, 0);
+       uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
        
        item->opname= opname; // static!
        item->propname= propname; // static!
@@ -2005,9 +2013,20 @@ void uiMenuItemEnumO(uiMenuItem *head, char *opname, char *propname, int value)
 }
 
 /* single operator item with property */
-void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *propname, float value)
+void uiMenuItemIntO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, int value)
 {
-       uiMenuItem *item= ui_menu_add_item(head, name, 0, 0);
+       uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
+       
+       item->opname= opname; // static!
+       item->propname= propname; // static!
+       item->intval= value;
+       item->type = MENU_ITEM_OPNAME_INT;
+}
+
+/* single operator item with property */
+void uiMenuItemFloatO(uiMenuItem *head, const char *name, int icon, char *opname, char *propname, float value)
+{
+       uiMenuItem *item= ui_menu_add_item(head, name, icon, 0);
        
        item->opname= opname; // static!
        item->propname= propname; // static!
@@ -2016,9 +2035,9 @@ void uiMenuItemFloatO(uiMenuItem *head, const char *name, char *opname, char *pr
 }
 
 /* single operator item with property */
-void uiMenuItemBooleanO(uiMenuItem *head, char *opname, char *propname, int value)
+void uiMenuItemBooleanO(uiMenuItem *head, int icon, char *opname, char *propname, int value)
 {
-       uiMenuItem *item= ui_menu_add_item(head, "", 0, 0);
+       uiMenuItem *item= ui_menu_add_item(head, "", icon, 0);
        
        item->opname= opname; // static!
        item->propname= propname; // static!
@@ -2046,7 +2065,7 @@ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname)
                RNA_property_enum_items(&ptr, prop, &item, &totitem);
                
                for (i=0; i<totitem; i++)
-                       uiMenuItemEnumO(head, opname, propname, item[i].value);
+                       uiMenuItemEnumO(head, 0, opname, propname, item[i].value);
        }
 }
 
@@ -2142,12 +2161,13 @@ void uiMenuSeparator(uiMenuItem *head)
 /*************************** Popup Menu API **************************/
 
 /* only return handler, and set optional title */
-uiMenuItem *uiPupMenuBegin(const char *title)
+uiMenuItem *uiPupMenuBegin(const char *title, int icon)
 {
        uiMenuItem *item= MEM_callocN(sizeof(uiMenuItem), "menu start");
        
        item->type = MENU_ITEM_TITLE;
        item->opcontext= WM_OP_EXEC_REGION_WIN; 
+       item->icon= icon;
        
        /* NULL is no title */
        if(title)
@@ -2179,32 +2199,6 @@ void uiPupMenuEnd(bContext *C, uiMenuItem *head)
        MEM_freeN(head);
 }
 
-/* This one will set enum propname, call operator and register it, and free the operator itself, 
-   call it in op->invoke with returning OPERATOR_RUNNING_MODAL */
-/* Note: propname has to be static */
-void uiPupMenuOperator(bContext *C, int maxrow, wmOperator *op, const char *propname, char *str)
-{
-       wmWindow *window= CTX_wm_window(C);
-       uiPupMenuInfo info;
-       uiPopupBlockHandle *menu;
-       
-       memset(&info, 0, sizeof(info));
-       info.mx= window->eventstate->x;
-       info.my= window->eventstate->y;
-       info.maxrow= maxrow;
-       info.instr= str;
-       
-       menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info);
-       menu->popup= 1;
-       
-       UI_add_popup_handlers(&window->handlers, menu);
-       WM_event_add_mousemove(C);
-       
-       menu->op_arg= op;
-       menu->propname= propname;
-}
-
-
 /* this one only to be called with operatortype name option */
 void uiPupMenu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...)
 {
@@ -2339,3 +2333,24 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
        BLI_dynstr_free(ds);
 }
 
+/*************************** Popup Block API **************************/
+
+void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext)
+{
+       wmWindow *window= CTX_wm_window(C);
+       uiPopupBlockHandle *handle;
+       
+       handle= ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
+       handle->popup= 1;
+       handle->opname= opname;
+       handle->opcontext= opcontext;
+       
+       UI_add_popup_handlers(&window->handlers, handle);
+       WM_event_add_mousemove(C);
+}
+
+void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg)
+{
+       uiPupBlockO(C, func, arg, NULL, 0);
+}
+
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
new file mode 100644 (file)
index 0000000..3ccd88f
--- /dev/null
@@ -0,0 +1,393 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_context.h"
+#include "BKE_idprop.h"
+#include "BKE_utildefines.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "ED_util.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+/*************************** RNA Utilities ******************************/
+
+int UI_GetIconRNA(PointerRNA *ptr)
+{
+       StructRNA *rnatype= ptr->type;
+
+       if(rnatype == &RNA_Scene)
+               return ICON_SCENE_DEHLT;
+       else if(rnatype == &RNA_World)
+               return ICON_WORLD;
+       else if(rnatype == &RNA_Object)
+               return ICON_OBJECT;
+       else if(rnatype == &RNA_Mesh)
+               return ICON_MESH;
+       else if(rnatype == &RNA_MeshVertex)
+               return ICON_VERTEXSEL;
+       else if(rnatype == &RNA_MeshEdge)
+               return ICON_EDGESEL;
+       else if(rnatype == &RNA_MeshFace)
+               return ICON_FACESEL;
+       else if(rnatype == &RNA_MeshTextureFace)
+               return ICON_FACESEL_HLT;
+       else if(rnatype == &RNA_VertexGroup)
+               return ICON_VGROUP;
+       else if(rnatype == &RNA_VertexGroupElement)
+               return ICON_VGROUP;
+       else if(rnatype == &RNA_Curve)
+               return ICON_CURVE;
+       else if(rnatype == &RNA_MetaBall)
+               return ICON_MBALL;
+       else if(rnatype == &RNA_MetaElement)
+               return ICON_OUTLINER_DATA_META;
+       else if(rnatype == &RNA_Lattice)
+               return ICON_LATTICE;
+       else if(rnatype == &RNA_Armature)
+               return ICON_ARMATURE;
+       else if(rnatype == &RNA_Bone)
+               return ICON_BONE_DEHLT;
+       else if(rnatype == &RNA_Camera)
+               return ICON_CAMERA;
+       else if(rnatype == &RNA_LocalLamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_AreaLamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_SpotLamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_SunLamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_HemiLamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_Lamp)
+               return ICON_LAMP;
+       else if(rnatype == &RNA_Group)
+               return ICON_GROUP;
+       else if(rnatype == &RNA_ParticleSystem)
+               return ICON_PARTICLES;
+       else if(rnatype == &RNA_ParticleSettings)
+               return ICON_PARTICLES;
+       else if(rnatype == &RNA_Material)
+               return ICON_MATERIAL;
+       else if(rnatype == &RNA_Texture)
+               return ICON_TEXTURE;
+       else if(rnatype == &RNA_TextureSlot)
+               return ICON_TEXTURE;
+       else if(rnatype == &RNA_WorldTextureSlot)
+               return ICON_TEXTURE;
+       else if(rnatype == &RNA_MaterialTextureSlot)
+               return ICON_TEXTURE;
+       else if(rnatype == &RNA_Image)
+               return ICON_TEXTURE;
+       else if(rnatype == &RNA_Screen)
+               return ICON_SPLITSCREEN;
+       else if(rnatype == &RNA_NodeTree)
+               return ICON_NODE;
+       else if(rnatype == &RNA_Text)
+               return ICON_TEXT;
+       else if(rnatype == &RNA_Sound)
+               return ICON_SOUND;
+       else if(rnatype == &RNA_Brush)
+               return ICON_TPAINT_HLT;
+       else if(rnatype == &RNA_Library)
+               return ICON_LIBRARY_DEHLT;
+       else if(rnatype == &RNA_Action)
+               return ICON_ACTION;
+       else if(rnatype == &RNA_FCurve)
+               return ICON_IPO_DEHLT;
+       //else if(rnatype == &RNA_Ipo)
+       //      return ICON_IPO_DEHLT;
+       else if(rnatype == &RNA_Key)
+               return ICON_SHAPEKEY;
+       else if(rnatype == &RNA_Main)
+               return ICON_BLENDER;
+       else if(rnatype == &RNA_Struct)
+               return ICON_RNA;
+       else if(rnatype == &RNA_Property)
+               return ICON_RNA;
+       else if(rnatype == &RNA_BooleanProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_IntProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_FloatProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_StringProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_EnumProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_EnumPropertyItem)
+               return ICON_RNA;
+       else if(rnatype == &RNA_PointerProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_CollectionProperty)
+               return ICON_RNA;
+       else if(rnatype == &RNA_GameObjectSettings)
+               return ICON_GAME;
+       else if(rnatype == &RNA_ScriptLink)
+               return ICON_PYTHON;
+       
+       /* modifiers */
+       else if(rnatype == &RNA_SubsurfModifier)
+               return ICON_MOD_SUBSURF;
+       else if(rnatype == &RNA_ArmatureModifier)
+               return ICON_ARMATURE;
+       else if(rnatype == &RNA_LatticeModifier)
+               return ICON_LATTICE;
+       else if(rnatype == &RNA_CurveModifier)
+               return ICON_CURVE;
+       else if(rnatype == &RNA_BuildModifier)
+               return ICON_MOD_BUILD;
+       else if(rnatype == &RNA_MirrorModifier)
+               return ICON_MOD_MIRROR;
+       else if(rnatype == &RNA_DecimateModifier)
+               return ICON_MOD_DECIM;
+       else if(rnatype == &RNA_WaveModifier)
+               return ICON_MOD_WAVE;
+       else if(rnatype == &RNA_HookModifier)
+               return ICON_HOOK;
+       else if(rnatype == &RNA_SoftbodyModifier)
+               return ICON_MOD_SOFT;
+       else if(rnatype == &RNA_BooleanModifier)
+               return ICON_MOD_BOOLEAN;
+       else if(rnatype == &RNA_ParticleInstanceModifier)
+               return ICON_MOD_PARTICLEINSTANCE;
+       else if(rnatype == &RNA_ParticleSystemModifier)
+               return ICON_MOD_PARTICLES;
+       else if(rnatype == &RNA_EdgeSplitModifier)
+               return ICON_MOD_EDGESPLIT;
+       else if(rnatype == &RNA_ArrayModifier)
+               return ICON_MOD_ARRAY;
+       else if(rnatype == &RNA_UVProjectModifier)
+               return ICON_MOD_UVPROJECT;
+       else if(rnatype == &RNA_DisplaceModifier)
+               return ICON_MOD_DISPLACE;
+       else
+               return ICON_DOT;
+}
+
+uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int x1, int y1, int x2, int y2)
+{
+       uiBut *but=NULL;
+       const char *propname= RNA_property_identifier(ptr, prop);
+       int arraylen= RNA_property_array_length(ptr, prop);
+
+       switch(RNA_property_type(ptr, prop)) {
+               case PROP_BOOLEAN: {
+                       int value, length;
+
+                       if(arraylen && index == -1)
+                               return NULL;
+
+                       length= RNA_property_array_length(ptr, prop);
+
+                       if(length)
+                               value= RNA_property_boolean_get_index(ptr, prop, index);
+                       else
+                               value= RNA_property_boolean_get(ptr, prop);
+
+                       if(name && strcmp(name, "") == 0)
+                               name= (value)? "Enabled": "Disabled";
+
+                       but= uiDefButR(block, TOG, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+                       break;
+               }
+               case PROP_INT:
+               case PROP_FLOAT:
+                       if(arraylen && index == -1) {
+                               if(RNA_property_subtype(ptr, prop) == PROP_COLOR)
+                                       but= uiDefButR(block, COL, 0, name, x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL);
+                       }
+                       else
+                               but= uiDefButR(block, NUM, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+                       break;
+               case PROP_ENUM:
+                       but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+                       break;
+               case PROP_STRING:
+                       but= uiDefButR(block, TEX, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
+                       break;
+               case PROP_POINTER: {
+                       PointerRNA pptr;
+                       PropertyRNA *nameprop;
+                       char *text, *descr, textbuf[256];
+                       int icon;
+
+                       pptr= RNA_property_pointer_get(ptr, prop);
+
+                       if(!pptr.data)
+                               return NULL;
+
+                       icon= UI_GetIconRNA(&pptr);
+                       nameprop= RNA_struct_name_property(&pptr);
+
+                       if(nameprop) {
+                               text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
+                               descr= (char*)RNA_property_ui_description(&pptr, prop);
+                               but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
+                               if(text != textbuf)
+                                       MEM_freeN(text);
+                       }
+                       else {
+                               text= (char*)RNA_struct_ui_name(&pptr);
+                               descr= (char*)RNA_property_ui_description(&pptr, prop);
+                               but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
+                       }
+                       break;
+               }
+               case PROP_COLLECTION: {
+                       char text[256];
+                       sprintf(text, "%d items", RNA_property_collection_length(ptr, prop));
+                       but= uiDefBut(block, LABEL, 0, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, NULL);
+                       uiButSetFlag(but, UI_BUT_DISABLED);
+                       break;
+               }
+               default:
+                       but= NULL;
+                       break;
+       }
+
+       return but;
+}
+
+#define RNA_BUT_WIDTH 150
+#define RNA_BUT_HEIGHT 20
+
+int uiDefAutoButsRNA(uiBlock *block, PointerRNA *ptr)
+{
+       CollectionPropertyIterator iter;
+       PropertyRNA *iterprop, *prop;
+       PropertySubType subtype;
+       char *name, namebuf[128];
+       int a, length, x= 0, y= 0;
+
+       x= 0;
+       y= 0;
+
+       /* create buttons */
+       uiSetCurFont(block, UI_HELVB);
+       uiDefBut(block, LABEL, 0, (char*)RNA_struct_ui_name(ptr), x, y, RNA_BUT_WIDTH, RNA_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
+       y -= RNA_BUT_HEIGHT;
+       uiSetCurFont(block, UI_HELV);
+
+       iterprop= RNA_struct_iterator_property(ptr);
+       RNA_property_collection_begin(ptr, iterprop, &iter);
+
+       for(; iter.valid; RNA_property_collection_next(&iter)) {
+               prop= iter.ptr.data;
+
+               if(strcmp(RNA_property_identifier(ptr, prop), "rna_type") == 0)
+                       continue;
+
+               if((length= RNA_property_array_length(ptr, prop))) {
+                       name= (char*)RNA_property_ui_name(ptr, prop);
+                       uiDefBut(block, LABEL, 0, name, x, y, RNA_BUT_WIDTH, RNA_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
+               }
+               else
+                       length= 1;
+
+               subtype= RNA_property_subtype(ptr, prop);
+
+               name= (char*)RNA_property_ui_name(ptr, prop);
+               uiDefBut(block, LABEL, 0, name, x, y, RNA_BUT_WIDTH, RNA_BUT_HEIGHT-1, NULL, 0, 0, 0, 0, "");
+
+               uiBlockBeginAlign(block);
+
+               if(length <= 16 && subtype == PROP_MATRIX) {
+                       /* matrix layout */
+                       int size, row, col, butwidth;
+
+                       size= ceil(sqrt(length));
+                       butwidth= RNA_BUT_WIDTH*2/size;
+                       y -= RNA_BUT_HEIGHT;
+
+                       for(a=0; a<length; a++) {
+                               col= a%size;
+                               row= a/size;
+
+                               uiDefAutoButR(block, ptr, prop, a, "", x+butwidth*col, y-row*RNA_BUT_HEIGHT, butwidth, RNA_BUT_HEIGHT-1);
+                       }
+
+                       y -= RNA_BUT_HEIGHT*(length/size);
+               }
+               else if(length <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
+                       static char *vectoritem[4]= {"X:", "Y:", "Z:", "W:"};
+                       static char *quatitem[4]= {"W:", "X:", "Y:", "Z:"};
+                       static char *coloritem[4]= {"R:", "G:", "B:", "A:"};
+                       int butwidth;
+
+                       butwidth= RNA_BUT_WIDTH*2/length;
+                       y -= RNA_BUT_HEIGHT;
+
+                       for(a=0; a<length; a++) {
+                               if(length == 4 && subtype == PROP_ROTATION)
+                                       name= quatitem[a];
+                               else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION)
+                                       name= vectoritem[a];
+                               else
+                                       name= coloritem[a];
+
+                               uiDefAutoButR(block, ptr, prop, a, name, x+butwidth*a, y, butwidth, RNA_BUT_HEIGHT-1);
+                       }
+                       y -= RNA_BUT_HEIGHT;
+               }
+               else {
+                       if(RNA_property_array_length(ptr, prop)) {
+                               sprintf(namebuf, "%d:", a+1);
+                               name= namebuf;
+                       }
+                       else
+                               name= "";
+
+                       uiDefAutoButR(block, ptr, prop, a, name, x+RNA_BUT_WIDTH, y, RNA_BUT_WIDTH, RNA_BUT_HEIGHT-1);
+                       y -= RNA_BUT_HEIGHT;
+               }
+
+               uiBlockEndAlign(block);
+       }
+
+       RNA_property_collection_end(&iter);
+
+       return -y;
+}
+
+#if 0
+#endif
+
index 805081b6a6ff4e523ab938030ddcf1e2e89a5236..86a4577e269639c7ecc8deb722a0bcb612ac708b 100644 (file)
@@ -6474,39 +6474,29 @@ void MESH_OT_subdivide_smooth(wmOperatorType *ot)
 
 static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       int items;
-       char *menu, *p;
-       
-       items = 4;
-       
-       menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
-       
-       p= menu + sprintf(menu, "%s %%t", "subdiv");
-       p+= sprintf(p, "|%s %%x%d", "simple", 3);
-       p+= sprintf(p, "|%s %%x%d", "multi", 2);
-       p+= sprintf(p, "|%s %%x%d", "fractal", 1);
-       p+= sprintf(p, "|%s %%x%d", "smooth", 0);
-       
-       uiPupMenuOperator(C, 20, op, "index", menu);
-       MEM_freeN(menu);
+       uiMenuItem *head;
+
+       head= uiPupMenuBegin("Subdivision Type", 0);
+       uiMenuItemsEnumO(head, "MESH_OT_subdivs", "type");
+       uiPupMenuEnd(C, head);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 static int subdivs_exec(bContext *C, wmOperator *op)
 {      
-       switch(RNA_int_get(op->ptr, "index"))
+       switch(RNA_int_get(op->ptr, "type"))
        {
-               case 3: // simple
+               case 0: // simple
                        subdivide_exec(C,op);
                        break;
-               case 2: // multi
+               case 1: // multi
                        subdivide_multi_exec(C,op);
                        break;
-               case 1: // fractal;
+               case 2: // fractal;
                        subdivide_multi_fractal_exec(C,op);
                        break;
-               case 0: //smooth
+               case 3: //smooth
                        subdivide_smooth_exec(C,op);
                        break;
        }
@@ -6516,6 +6506,13 @@ static int subdivs_exec(bContext *C, wmOperator *op)
 
 void MESH_OT_subdivs(wmOperatorType *ot)
 {
+       static EnumPropertyItem type_items[]= {
+               {0, "SIMPLE", "Simple", ""},
+               {1, "MULTI", "Multi", ""},
+               {2, "FRACTAL", "Fractal", ""},
+               {3, "SMOOTH", "Smooth", ""},
+               {0, NULL, NULL}};
+
        /* identifiers */
        ot->name= "subdivs";
        ot->idname= "MESH_OT_subdivs";
@@ -6530,7 +6527,7 @@ void MESH_OT_subdivs(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /*props */
-       RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
+       RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
        
        /* this is temp, the ops are different, but they are called from subdivs, so all the possible props should be here as well*/
        RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
index 373bc81b3b1ba1fc62d6fb1d2b8a448e3bee27ed..ca600f0e210ad4ab77603312bde0ab0de77b592f 100644 (file)
@@ -479,17 +479,17 @@ void OBJECT_OT_curve_add(wmOperatorType *ot)
 
 static int object_add_primitive_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       uiMenuItem *head= uiPupMenuBegin("Add Object");
+       uiMenuItem *head= uiPupMenuBegin("Add Object", 0);
        
        uiMenuLevelEnumO(head, "OBJECT_OT_mesh_add", "type");
        uiMenuLevelEnumO(head, "OBJECT_OT_curve_add", "type");
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_SURF);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_MBALL);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_CAMERA);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_LAMP);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_EMPTY);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_ARMATURE);
-       uiMenuItemEnumO(head, "OBJECT_OT_object_add", "type", OB_LATTICE);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_SURF);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_MBALL);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_CAMERA);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LAMP);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_EMPTY);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_ARMATURE);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_object_add", "type", OB_LATTICE);
        
        uiPupMenuEnd(C, head);
        
@@ -2452,23 +2452,23 @@ static int make_parent_exec(bContext *C, wmOperator *op)
 static int make_parent_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        Object *ob= CTX_data_active_object(C);
-       uiMenuItem *head= uiPupMenuBegin("Make Parent To");
+       uiMenuItem *head= uiPupMenuBegin("Make Parent To", 0);
        
        uiMenuContext(head, WM_OP_EXEC_DEFAULT);
-       uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
+       uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_OBJECT);
        
        /* ob becomes parent, make the associated menus */
        if(ob->type==OB_ARMATURE) {
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_BONE);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_ARMATURE);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_BONE);
        }
        else if(ob->type==OB_CURVE) {
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_CURVE);
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_CURVE);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_FOLLOW);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_PATH_CONST);
        }
        else if(ob->type == OB_LATTICE) {
-               uiMenuItemEnumO(head, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
+               uiMenuItemEnumO(head, 0, "OBJECT_OT_make_parent", "type", PAR_LATTICE);
        }
        
        uiPupMenuEnd(C, head);
index 5473fdf101e94a97c4a072562e4e60fb0af6d5a4..759fc1f2520945264fdf7d5d8230d532dc40a5e9 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
+#include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
@@ -1362,23 +1363,21 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
        wmOperator *lastop;
+       uiMenuItem *head;
        int items, i;
-       char *menu, *p;
        
        items= BLI_countlist(&wm->operators);
        if(items==0)
                return OPERATOR_CANCELLED;
        
-       menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
-       
-       p= menu + sprintf(menu, "%s %%t", op->type->name);
+       head= uiPupMenuBegin(op->type->name, 0);
+
        for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
-               p+= sprintf(p, "|%s %%x%d", lastop->type->name, i);
-       
-       uiPupMenuOperator(C, i/20, op, "index", menu);
-       MEM_freeN(menu);
+               uiMenuItemIntO(head, lastop->type->name, 0, op->type->idname, "index", i);
+
+       uiPupMenuEnd(C, head);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 static int repeat_history_exec(bContext *C, wmOperator *op)
@@ -1412,6 +1411,89 @@ void SCREEN_OT_repeat_history(wmOperatorType *ot)
        RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
 }
 
+/* ********************** redo operator ***************************** */
+
+static int redo_last_exec(bContext *C, wmOperator *op)
+{
+#if 0
+       /* XXX context is not correct after popup menu */
+       wmOperator *lastop= CTX_wm_manager(C)->operators.last;
+       
+       if(lastop) {
+               ED_undo_pop(C);
+               WM_operator_repeat(C, lastop);
+       }
+#endif
+       
+       return OPERATOR_CANCELLED;
+}
+
+static void redo_last_cb(bContext *C, void *arg1, void *arg2)
+{
+#if 0
+       /* XXX context here is not correct .. we get the popup block region
+        * context but should actually have where ever the last operator was
+        * executed. */
+       WM_operator_name_call(C, "SCREEN_OT_redo_last", WM_OP_EXEC_DEFAULT, NULL);
+#endif
+}
+
+static uiBlock *ui_block_create_redo_last(bContext *C, ARegion *ar, void *arg_op)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       wmOperator *op= arg_op;
+       PointerRNA ptr;
+       uiBlock *block;
+       int height;
+       
+       block= uiBeginBlock(C, ar, "redo_last_popup", UI_EMBOSS, UI_HELV);
+       uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
+       uiBlockSetFunc(block, redo_last_cb, NULL, NULL);
+
+       if(!op->properties) {
+               IDPropertyTemplate val = {0};
+               op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
+       }
+
+       RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+       height= uiDefAutoButsRNA(block, &ptr);
+
+       uiPopupBoundsBlock(block, 4.0f, 0, 0);
+       uiEndBlock(C, block);
+
+       return block;
+}
+
+static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       wmOperator *lastop= wm->operators.last;
+
+       if(!lastop)
+               return OPERATOR_CANCELLED;
+
+       /* only for operators that are registered and did an undo push */
+       if(!(lastop->type->flag & OPTYPE_REGISTER) || !(lastop->type->flag & OPTYPE_UNDO))
+               return OPERATOR_CANCELLED;
+
+       uiPupBlockO(C, ui_block_create_redo_last, lastop, op->type->idname, WM_OP_EXEC_DEFAULT);
+
+       return OPERATOR_CANCELLED;
+}
+
+void SCREEN_OT_redo_last(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Redo Last";
+       ot->idname= "SCREEN_OT_redo_last";
+       
+       /* api callbacks */
+       ot->invoke= redo_last_invoke;
+       ot->exec= redo_last_exec;
+       
+       ot->poll= ED_operator_screenactive;
+}
+
 /* ************** region split operator ***************************** */
 
 /* insert a region in the area region list */
@@ -1585,14 +1667,14 @@ static void newlevel1(bContext *C, uiMenuItem *head, void *arg)
 
 static int testing123(bContext *C, wmOperator *op, wmEvent *event)
 {
-       uiMenuItem *head= uiPupMenuBegin("Hello world");
+       uiMenuItem *head= uiPupMenuBegin("Hello world", 0);
        
        uiMenuContext(head, WM_OP_EXEC_DEFAULT);
-       uiMenuItemO(head, "SCREEN_OT_region_flip", ICON_PROP_ON);
-       uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_PROP_CON);
-       uiMenuItemO(head, "SCREEN_OT_region_foursplit", ICON_SMOOTHCURVE);
+       uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_region_flip");
+       uiMenuItemO(head, ICON_PROP_CON, "SCREEN_OT_screen_full_area");
+       uiMenuItemO(head, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit");
        uiMenuLevel(head, "Submenu", newlevel1);
-       uiMenuItemO(head, "SCREEN_OT_area_rip", ICON_PROP_ON);
+       uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_area_rip");
        
        uiPupMenuEnd(C, head);
        
@@ -1724,6 +1806,7 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_actionzone);
        WM_operatortype_append(SCREEN_OT_repeat_last);
        WM_operatortype_append(SCREEN_OT_repeat_history);
+       WM_operatortype_append(SCREEN_OT_redo_last);
        
        /* screen tools */
        WM_operatortype_append(SCREEN_OT_area_move);
@@ -1774,6 +1857,7 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
 
        /* files */
        WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
index 59bc98eac936df5f1e99eaef4b625fcc97bc66d2..38f9883bdc7e5bcb62ae63ee0be2df848642958a 100644 (file)
@@ -87,8 +87,8 @@ static void image_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unus
 {
        int a;
        
-       uiMenuItemO(head, "IMAGE_OT_view_zoom_in", ICON_BLANK1);
-       uiMenuItemO(head, "IMAGE_OT_view_zoom_out", ICON_BLANK1);
+       uiMenuItemO(head, 0, "IMAGE_OT_view_zoom_in");
+       uiMenuItemO(head, 0, "IMAGE_OT_view_zoom_out");
 
        uiMenuSeparator(head);
 
@@ -97,7 +97,7 @@ static void image_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unus
                char namestr[128];
 
                sprintf(namestr, "Zoom %d:%d", ratios[a][0], ratios[a][1]);
-               uiMenuItemFloatO(head, namestr, "IMAGE_OT_view_zoom_ratio", "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
+               uiMenuItemFloatO(head, namestr, 0, "IMAGE_OT_view_zoom_ratio", "ratio", (float)ratios[a][0]/(float)ratios[a][1]);
        }
 }
 
@@ -137,13 +137,13 @@ static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
        show_uvedit= get_space_image_show_uvedit(sima, CTX_data_edit_object(C));
        
        /* create menu */
-       uiMenuItemO(head, "IMAGE_OT_toggle_view_properties_panel", ICON_MENU_PANEL); // View Properties...
-       uiMenuItemO(head, "IMAGE_OT_toggle_image_properties_panel", ICON_MENU_PANEL); // Image Properties...|N
-       uiMenuItemO(head, "IMAGE_OT_toggle_realtime_properties_panel", ICON_MENU_PANEL); // Real-time properties...
-       if(show_paint) uiMenuItemO(head, "IMAGE_OT_toggle_paint_panel", ICON_MENU_PANEL); // Paint Tool...|C
-       uiMenuItemO(head, "IMAGE_OT_toggle_curves_panel", ICON_MENU_PANEL); // Curves Tool...
-       if(show_render) uiMenuItemO(head, "IMAGE_OT_toggle_compositing_preview_panel", ICON_MENU_PANEL); // Compositing Preview...|Shift P
-       uiMenuItemO(head, "IMAGE_OT_toggle_grease_pencil_panel", ICON_MENU_PANEL); // Grease Pencil...
+       uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_view_properties_panel"); // View Properties...
+       uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_image_properties_panel"); // Image Properties...|N
+       uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_realtime_properties_panel"); // Real-time properties...
+       if(show_paint) uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_paint_panel"); // Paint Tool...|C
+       uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_curves_panel"); // Curves Tool...
+       if(show_render) uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_compositing_preview_panel"); // Compositing Preview...|Shift P
+       uiMenuItemO(head, ICON_MENU_PANEL, "IMAGE_OT_toggle_grease_pencil_panel"); // Grease Pencil...
 
        uiMenuSeparator(head);
 
@@ -153,11 +153,11 @@ static void image_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
        uiMenuSeparator(head);
 
        uiMenuLevel(head, "View Navigation", image_view_viewnavmenu);
-       if(show_uvedit) uiMenuItemO(head, "IMAGE_OT_view_selected", ICON_BLANK1);
-       uiMenuItemO(head, "IMAGE_OT_view_all", ICON_BLANK1);
+       if(show_uvedit) uiMenuItemO(head, 0, "IMAGE_OT_view_selected");
+       uiMenuItemO(head, 0, "IMAGE_OT_view_all");
 
-       if(sa->full) uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Tile Window", Ctrl UpArrow
-       else uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Maximize Window", Ctr DownArrow
+       if(sa->full) uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
+       else uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
 }
 
 #if 0
@@ -180,19 +180,19 @@ static void do_selectmenu(bContext *C, void *arg, int event)
 
 static void image_selectmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-       uiMenuItemO(head, "UV_OT_border_select", ICON_BLANK1); // Border Select|B
-       uiMenuItemO(head, "UV_OT_border_select_pinned", ICON_BLANK1); // Border Select Pinned|Shift B
+       uiMenuItemO(head, 0, "UV_OT_border_select"); // Border Select|B
+       uiMenuItemO(head, 0, "UV_OT_border_select_pinned"); // Border Select Pinned|Shift B
 
        uiMenuSeparator(head);
        
-       uiMenuItemO(head, "UV_OT_de_select_all", ICON_BLANK1);
-       uiMenuItemO(head, "UV_OT_select_invert", ICON_BLANK1);
-       uiMenuItemO(head, "UV_OT_unlink_selection", ICON_BLANK1); // Unlink Selection|Alt L
+       uiMenuItemO(head, 0, "UV_OT_de_select_all");
+       uiMenuItemO(head, 0, "UV_OT_select_invert");
+       uiMenuItemO(head, 0, "UV_OT_unlink_selection"); // Unlink Selection|Alt L
        
        uiMenuSeparator(head);
 
-       uiMenuItemO(head, "UV_OT_select_pinned", ICON_BLANK1); // Select Pinned|Shift P
-       uiMenuItemO(head, "UV_OT_select_linked", ICON_BLANK1); // Select Linked|Ctrl L
+       uiMenuItemO(head, 0, "UV_OT_select_pinned"); // Select Pinned|Shift P
+       uiMenuItemO(head, 0, "UV_OT_select_linked"); // Select Linked|Ctrl L
 }
 
 #if 0
@@ -277,27 +277,27 @@ static void image_imagemenu(bContext *C, uiMenuItem *head, void *arg_unused)
        RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &spaceptr);
 
        /* create menu */
-       uiMenuItemO(head, "IMAGE_OT_new", ICON_BLANK1); // New...|Alt N
-       uiMenuItemO(head, "IMAGE_OT_open", ICON_BLANK1); // Open...|Alt O
+       uiMenuItemO(head, 0, "IMAGE_OT_new"); // New...|Alt N
+       uiMenuItemO(head, 0, "IMAGE_OT_open"); // Open...|Alt O
 
        if(ima) {
-               uiMenuItemO(head, "IMAGE_OT_replace", ICON_BLANK1); // Replace...
-               uiMenuItemO(head, "IMAGE_OT_reload", ICON_BLANK1); // Reload...|Alt R
-               uiMenuItemO(head, "IMAGE_OT_save", ICON_BLANK1); // Save|Alt S
-               uiMenuItemO(head, "IMAGE_OT_save_as", ICON_BLANK1); // Save As...
+               uiMenuItemO(head, 0, "IMAGE_OT_replace"); // Replace...
+               uiMenuItemO(head, 0, "IMAGE_OT_reload"); // Reload...|Alt R
+               uiMenuItemO(head, 0, "IMAGE_OT_save"); // Save|Alt S
+               uiMenuItemO(head, 0, "IMAGE_OT_save_as"); // Save As...
                if(ima->source == IMA_SRC_SEQUENCE)
-                       uiMenuItemO(head, "IMAGE_OT_save_changed", ICON_BLANK1); // Save Changed Images
+                       uiMenuItemO(head, 0, "IMAGE_OT_save_changed"); // Save Changed Images
 
                if(!show_render) {
                        uiMenuSeparator(head);
 
-                       if(ima->packedfile) uiMenuItemO(head, "IMAGE_OT_unpack", ICON_BLANK1); // Unpack Image...
-                       else uiMenuItemO(head, "IMAGE_OT_pack", ICON_BLANK1); // Pack Image
+                       if(ima->packedfile) uiMenuItemO(head, 0, "IMAGE_OT_unpack"); // Unpack Image...
+                       else uiMenuItemO(head, 0, "IMAGE_OT_pack"); // Pack Image
 
                        /* only for dirty && specific image types : XXX poll? */
                        if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
                                if(ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_GENERATED) && ima->type != IMA_TYPE_MULTILAYER)
-                                       uiMenuItemO(head, "IMAGE_OT_pack_as_png", ICON_BLANK1); // Pack Image As PNG
+                                       uiMenuItemO(head, 0, "IMAGE_OT_pack_as_png"); // Pack Image As PNG
 
                        uiMenuSeparator(head);
 
@@ -344,9 +344,9 @@ static void do_image_uvs_showhidemenu(void *arg, int event)
 
 static void image_uvs_showhidemenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-       uiMenuItemO(head, "UV_OT_show_hidden_faces", ICON_BLANK1); // Show Hidden Faces|Alt H
-       uiMenuItemO(head, "UV_OT_hide_selected_faces", ICON_BLANK1); // Hide Selected Faces|H
-       uiMenuItemO(head, "UV_OT_hide_deselected_faces", ICON_BLANK1); // Hide Deselected Faces|Shift H
+       uiMenuItemO(head, 0, "UV_OT_show_hidden_faces"); // Show Hidden Faces|Alt H
+       uiMenuItemO(head, 0, "UV_OT_hide_selected_faces"); // Hide Selected Faces|H
+       uiMenuItemO(head, 0, "UV_OT_hide_deselected_faces"); // Hide Deselected Faces|Shift H
 }
 
 #if 0
@@ -371,9 +371,9 @@ static void do_image_uvs_transformmenu(void *arg, int event)
 
 static void image_uvs_transformmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-       uiMenuItemO(head, "UV_OT_grab", ICON_BLANK1); // Grab/Move|G
-       uiMenuItemO(head, "UV_OT_rotate", ICON_BLANK1); // Rotate|R
-       uiMenuItemO(head, "UV_OT_scale", ICON_BLANK1); // Scale|S
+       uiMenuItemO(head, 0, "UV_OT_grab"); // Grab/Move|G
+       uiMenuItemO(head, 0, "UV_OT_rotate"); // Rotate|R
+       uiMenuItemO(head, 0, "UV_OT_scale"); // Scale|S
 }
 
 #if 0
@@ -402,8 +402,8 @@ static void do_image_uvs_mirrormenu(void *arg, int event)
 
 static void image_uvs_mirrormenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-       uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
-       uiMenuItemEnumO(head, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
+       uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'x'); // "X Axis", M, 1
+       uiMenuItemEnumO(head, 0, "UV_OT_mirror", "axis", 'y'); // "Y Axis", M, 2
 }
 
 #if 0
@@ -431,7 +431,7 @@ static void do_image_uvs_weldalignmenu(void *arg, int event)
 
 static void image_uvs_weldalignmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-       uiMenuItemO(head, "UV_OT_weld", ICON_BLANK1); // W, 1
+       uiMenuItemO(head, 0, "UV_OT_weld"); // W, 1
        uiMenuItemsEnumO(head, "UV_OT_align", "axis"); // W, 2/3/4
 }
 
@@ -536,16 +536,16 @@ static void image_uvsmenu(bContext *C, uiMenuItem *head, void *arg_unused)
        uiMenuSeparator(head);
 
        uiMenuItemBooleanR(head, &uvptr, "live_unwrap");
-       uiMenuItemO(head, "UV_OT_unwrap", ICON_BLANK1); // Unwrap|E
-       uiMenuItemO(head, "UV_OT_unpin", ICON_BLANK1); // Unpin|Alt P
-       uiMenuItemO(head, "UV_OT_pin", ICON_BLANK1); // Pin|P
+       uiMenuItemO(head, 0, "UV_OT_unwrap"); // Unwrap|E
+       uiMenuItemO(head, 0, "UV_OT_unpin"); // Unpin|Alt P
+       uiMenuItemO(head, 0, "UV_OT_pin"); // Pin|P
 
        uiMenuSeparator(head);
 
-       uiMenuItemO(head, "UV_OT_pack_islands", ICON_BLANK1); // Pack Islands|Ctr P
-       uiMenuItemO(head, "UV_OT_average_islands", ICON_BLANK1); // Average Islands Scale|Ctrl A
-       uiMenuItemO(head, "UV_OT_minimize_stretch", ICON_BLANK1); // Minimize Stretch...|Ctrl V
-       uiMenuItemO(head, "UV_OT_stitch", ICON_BLANK1);
+       uiMenuItemO(head, 0, "UV_OT_pack_islands"); // Pack Islands|Ctr P
+       uiMenuItemO(head, 0, "UV_OT_average_islands"); // Average Islands Scale|Ctrl A
+       uiMenuItemO(head, 0, "UV_OT_minimize_stretch"); // Minimize Stretch...|Ctrl V
+       uiMenuItemO(head, 0, "UV_OT_stitch");
 
        uiMenuSeparator(head);
 
@@ -1128,7 +1128,7 @@ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        show_uvedit= get_space_image_show_uvedit(sima, obedit);
 
-       head= uiPupMenuBegin("Toolbox");
+       head= uiPupMenuBegin("Toolbox", 0);
 
        uiMenuLevel(head, "View", image_viewmenu);
        if(show_uvedit) uiMenuLevel(head, "Select", image_selectmenu);
index ef5b59e905b35d77d80def358454c609079a0624..5e54a57f48dc339a4651b4e8a0a72da15cba8169 100644 (file)
@@ -3092,161 +3092,6 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
 
 /* ***************** DRAW *************** */
 
-static int tselem_rna_icon(PointerRNA *ptr)
-{
-       StructRNA *rnatype= ptr->type;
-
-       if(rnatype == &RNA_Scene)
-               return ICON_SCENE_DEHLT;
-       else if(rnatype == &RNA_World)
-               return ICON_WORLD;
-       else if(rnatype == &RNA_Object)
-               return ICON_OBJECT;
-       else if(rnatype == &RNA_Mesh)
-               return ICON_MESH;
-       else if(rnatype == &RNA_MeshVertex)
-               return ICON_VERTEXSEL;
-       else if(rnatype == &RNA_MeshEdge)
-               return ICON_EDGESEL;
-       else if(rnatype == &RNA_MeshFace)
-               return ICON_FACESEL;
-       else if(rnatype == &RNA_MeshTextureFace)
-               return ICON_FACESEL_HLT;
-       else if(rnatype == &RNA_VertexGroup)
-               return ICON_VGROUP;
-       else if(rnatype == &RNA_VertexGroupElement)
-               return ICON_VGROUP;
-       else if(rnatype == &RNA_Curve)
-               return ICON_CURVE;
-       else if(rnatype == &RNA_MetaBall)
-               return ICON_MBALL;
-       else if(rnatype == &RNA_MetaElement)
-               return ICON_OUTLINER_DATA_META;
-       else if(rnatype == &RNA_Lattice)
-               return ICON_LATTICE;
-       else if(rnatype == &RNA_Armature)
-               return ICON_ARMATURE;
-       else if(rnatype == &RNA_Bone)
-               return ICON_BONE_DEHLT;
-       else if(rnatype == &RNA_Camera)
-               return ICON_CAMERA;
-       else if(rnatype == &RNA_LocalLamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_AreaLamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_SpotLamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_SunLamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_HemiLamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_Lamp)
-               return ICON_LAMP;
-       else if(rnatype == &RNA_Group)
-               return ICON_GROUP;
-       else if(rnatype == &RNA_ParticleSystem)
-               return ICON_PARTICLES;
-       else if(rnatype == &RNA_ParticleSettings)
-               return ICON_PARTICLES;
-       else if(rnatype == &RNA_Material)
-               return ICON_MATERIAL;
-       else if(rnatype == &RNA_Texture)
-               return ICON_TEXTURE;
-       else if(rnatype == &RNA_TextureSlot)
-               return ICON_TEXTURE;
-       else if(rnatype == &RNA_WorldTextureSlot)
-               return ICON_TEXTURE;
-       else if(rnatype == &RNA_MaterialTextureSlot)
-               return ICON_TEXTURE;
-       else if(rnatype == &RNA_Image)
-               return ICON_TEXTURE;
-       else if(rnatype == &RNA_Screen)
-               return ICON_SPLITSCREEN;
-       else if(rnatype == &RNA_NodeTree)
-               return ICON_NODE;
-       else if(rnatype == &RNA_Text)
-               return ICON_TEXT;
-       else if(rnatype == &RNA_Sound)
-               return ICON_SOUND;
-       else if(rnatype == &RNA_Brush)
-               return ICON_TPAINT_HLT;
-       else if(rnatype == &RNA_Library)
-               return ICON_LIBRARY_DEHLT;
-       else if(rnatype == &RNA_Action)
-               return ICON_ACTION;
-       else if(rnatype == &RNA_FCurve)
-               return ICON_IPO_DEHLT;
-       //else if(rnatype == &RNA_Ipo)
-       //      return ICON_IPO_DEHLT;
-       else if(rnatype == &RNA_Key)
-               return ICON_SHAPEKEY;
-       else if(rnatype == &RNA_Main)
-               return ICON_BLENDER;
-       else if(rnatype == &RNA_Struct)
-               return ICON_RNA;
-       else if(rnatype == &RNA_Property)
-               return ICON_RNA;
-       else if(rnatype == &RNA_BooleanProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_IntProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_FloatProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_StringProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_EnumProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_EnumPropertyItem)
-               return ICON_RNA;
-       else if(rnatype == &RNA_PointerProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_CollectionProperty)
-               return ICON_RNA;
-       else if(rnatype == &RNA_GameObjectSettings)
-               return ICON_GAME;
-       else if(rnatype == &RNA_ScriptLink)
-               return ICON_PYTHON;
-       
-       /* modifiers */
-       else if(rnatype == &RNA_SubsurfModifier)
-               return ICON_MOD_SUBSURF;
-       else if(rnatype == &RNA_ArmatureModifier)
-               return ICON_ARMATURE;
-       else if(rnatype == &RNA_LatticeModifier)
-               return ICON_LATTICE;
-       else if(rnatype == &RNA_CurveModifier)
-               return ICON_CURVE;
-       else if(rnatype == &RNA_BuildModifier)
-               return ICON_MOD_BUILD;
-       else if(rnatype == &RNA_MirrorModifier)
-               return ICON_MOD_MIRROR;
-       else if(rnatype == &RNA_DecimateModifier)
-               return ICON_MOD_DECIM;
-       else if(rnatype == &RNA_WaveModifier)
-               return ICON_MOD_WAVE;
-       else if(rnatype == &RNA_HookModifier)
-               return ICON_HOOK;
-       else if(rnatype == &RNA_SoftbodyModifier)
-               return ICON_MOD_SOFT;
-       else if(rnatype == &RNA_BooleanModifier)
-               return ICON_MOD_BOOLEAN;
-       else if(rnatype == &RNA_ParticleInstanceModifier)
-               return ICON_MOD_PARTICLEINSTANCE;
-       else if(rnatype == &RNA_ParticleSystemModifier)
-               return ICON_MOD_PARTICLES;
-       else if(rnatype == &RNA_EdgeSplitModifier)
-               return ICON_MOD_EDGESPLIT;
-       else if(rnatype == &RNA_ArrayModifier)
-               return ICON_MOD_ARRAY;
-       else if(rnatype == &RNA_UVProjectModifier)
-               return ICON_MOD_UVPROJECT;
-       else if(rnatype == &RNA_DisplaceModifier)
-               return ICON_MOD_DISPLACE;
-       
-       else
-               return ICON_DOT;
-}
-
 static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElement *te)
 {
        if(tselem->type) {
@@ -3353,7 +3198,7 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                                UI_icon_draw(x, y, ICON_OBJECT);
                                break;
                        case TSE_RNA_STRUCT:
-                               UI_icon_draw(x, y, tselem_rna_icon(&te->rnaptr));
+                               UI_icon_draw(x, y, UI_GetIconRNA(&te->rnaptr));
                                break;
                        default:
                                UI_icon_draw(x, y, ICON_DOT); break;
@@ -4084,79 +3929,6 @@ static void outliner_draw_rnacols(ARegion *ar, SpaceOops *soops, int sizex)
                v2d->cur.ymin);
 }
 
-static uiBut *outliner_draw_rnabut(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, int x1, int y1, int x2, int y2)
-{
-       uiBut *but=NULL;
-       const char *propname= RNA_property_identifier(ptr, prop);
-       int arraylen= RNA_property_array_length(ptr, prop);
-
-       switch(RNA_property_type(ptr, prop)) {
-               case PROP_BOOLEAN: {
-                       int value, length;
-
-                       if(arraylen && index == -1)
-                               return NULL;
-
-                       length= RNA_property_array_length(ptr, prop);
-
-                       if(length)
-                               value= RNA_property_boolean_get_index(ptr, prop, index);
-                       else
-                               value= RNA_property_boolean_get(ptr, prop);
-
-                       but= uiDefButR(block, TOG, 0, (value)? "True": "False", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
-                       break;
-               }
-               case PROP_INT:
-               case PROP_FLOAT:
-                       if(arraylen && index == -1) {
-                               if(RNA_property_subtype(ptr, prop) == PROP_COLOR)
-                                       but= uiDefButR(block, COL, 0, "", x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL);
-                       }
-                       else
-                               but= uiDefButR(block, NUM, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
-                       break;
-               case PROP_ENUM:
-                       but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
-                       break;
-               case PROP_STRING:
-                       but= uiDefButR(block, TEX, 0, "", x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL);
-                       break;
-               case PROP_POINTER: {
-                       PointerRNA pptr;
-                       PropertyRNA *nameprop;
-                       char *text, *descr, textbuf[256];
-                       int icon;
-
-                       pptr= RNA_property_pointer_get(ptr, prop);
-
-                       if(!pptr.data)
-                               return NULL;
-
-                       icon= tselem_rna_icon(&pptr);
-                       nameprop= RNA_struct_name_property(&pptr);
-
-                       if(nameprop) {
-                               text= RNA_property_string_get_alloc(&pptr, nameprop, textbuf, sizeof(textbuf));
-                               descr= (char*)RNA_property_ui_description(&pptr, prop);
-                               but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
-                               if(text != textbuf)
-                                       MEM_freeN(text);
-                       }
-                       else {
-                               text= (char*)RNA_struct_ui_name(&pptr);
-                               descr= (char*)RNA_property_ui_description(&pptr, prop);
-                               but= uiDefIconTextBut(block, LABEL, 0, icon, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, descr);
-                       }
-               }
-               default:
-                       but= NULL;
-                       break;
-       }
-
-       return but;
-}
-
 static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb)
 {      
        TreeElement *te;
@@ -4174,13 +3946,13 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                                prop= te->directdata;
 
                                if(!(RNA_property_type(ptr, prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
-                                       outliner_draw_rnabut(block, ptr, prop, -1, sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                                       uiDefAutoButR(block, ptr, prop, -1, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
                        }
                        else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
                                ptr= &te->rnaptr;
                                prop= te->directdata;
 
-                               outliner_draw_rnabut(block, ptr, prop, te->index, sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
+                               uiDefAutoButR(block, ptr, prop, te->index, "", sizex, te->ys, OL_RNA_COL_SIZEX, OL_H-1);
                        }
                }
                
index dfa0f66c8c299bff0b4fbd2ca9080b0618792ccb..0259f7b008daa3c338811ff1a5d5206e77e65393 100644 (file)
@@ -555,7 +555,7 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event)
 
 static void view3d_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
-//     uiMenuItemO(head, "VIEW3D_OT_view_fly_mode", ICON_BLANK1);
+//     uiMenuItemO(head, 0, "VIEW3D_OT_view_fly_mode");
        
 //     uiMenuSeparator(head);
        
@@ -567,8 +567,8 @@ static void view3d_view_viewnavmenu(bContext *C, uiMenuItem *head, void *arg_unu
        
        uiMenuSeparator(head);
        
-       uiMenuItemFloatO(head, "Zoom in", "VIEW3D_OT_viewzoom", "delta", 1.0f);
-       uiMenuItemFloatO(head, "Zoom out", "VIEW3D_OT_viewzoom", "delta", -1.0f);
+       uiMenuItemFloatO(head, "Zoom in", 0, "VIEW3D_OT_viewzoom", "delta", 1.0f);
+       uiMenuItemFloatO(head, "Zoom out", 0, "VIEW3D_OT_viewzoom", "delta", -1.0f);
        
 }
 static void view3d_view_alignviewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
@@ -583,33 +583,33 @@ static void view3d_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 {
        ScrArea *sa= CTX_wm_area(C);
        
-//     uiMenuItemO(head, "VIEW3D_OT_toggle_transform_orientations_panel", ICON_MENU_PANEL); // Transform Orientations...
-//     uiMenuItemO(head, "VIEW3D_OT_toggle_render_preview_panel", ICON_MENU_PANEL); // render preview...
-//     uiMenuItemO(head, "VIEW3D_OT_toggle_view_properties_panel", ICON_MENU_PANEL); // View Properties....
-//     uiMenuItemO(head, "VIEW3D_OT_toggle_background_image_panel", ICON_MENU_PANEL); // Background Image....
-//     uiMenuItemO(head, "VIEW3D_OT_toggle_grease_pencil_panel", ICON_MENU_PANEL); // Grease Pencil....
+//     uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_transform_orientations_panel"); // Transform Orientations...
+//     uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_render_preview_panel"); // render preview...
+//     uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_view_properties_panel"); // View Properties....
+//     uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_background_image_panel"); // Background Image....
+//     uiMenuItemO(head, ICON_MENU_PANEL, "VIEW3D_OT_toggle_grease_pencil_panel"); // Grease Pencil....
        
 //     uiMenuSeparator(head);
        
-       uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
-       uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
-       uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
-       uiMenuItemEnumO(head, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
+       uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_CAMERA);
+       uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_TOP);
+       uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_FRONT);
+       uiMenuItemEnumO(head, 0, "VIEW3D_OT_viewnumpad", "type", V3D_VIEW_RIGHT);
        
        //uiMenuLevel(head, "Cameras", view3d_view_camerasmenu);
        
        uiMenuSeparator(head);
 
-       uiMenuItemO(head, "VIEW3D_OT_view_persportho", ICON_BLANK1);
+       uiMenuItemO(head, 0, "VIEW3D_OT_view_persportho");
        
        uiMenuSeparator(head);
        
-//     uiMenuItemO(head, "VIEW3D_OT_view_show_all_layers", ICON_BLANK1);       
+//     uiMenuItemO(head, 0, "VIEW3D_OT_view_show_all_layers"); 
        
 //     uiMenuSeparator(head);
        
-//     uiMenuItemO(head, "VIEW3D_OT_view_local_view", ICON_BLANK1);
-//     uiMenuItemO(head, "VIEW3D_OT_view_global_view", ICON_BLANK1);
+//     uiMenuItemO(head, 0, "VIEW3D_OT_view_local_view");
+//     uiMenuItemO(head, 0, "VIEW3D_OT_view_global_view");
        
 //     uiMenuSeparator(head);
        
@@ -620,18 +620,18 @@ static void view3d_viewmenu(bContext *C, uiMenuItem *head, void *arg_unused)
 
        uiMenuContext(head, WM_OP_INVOKE_REGION_WIN);   
 
-       uiMenuItemO(head, "VIEW3D_OT_clipping", ICON_BLANK1);
-       uiMenuItemO(head, "VIEW3D_OT_border_zoom", ICON_BLANK1);
+       uiMenuItemO(head, 0, "VIEW3D_OT_clipping");
+       uiMenuItemO(head, 0, "VIEW3D_OT_border_zoom");
        
        uiMenuSeparator(head);
        
-       uiMenuItemO(head, "VIEW3D_OT_viewcenter", ICON_BLANK1);
-       uiMenuItemO(head, "VIEW3D_OT_viewhome", ICON_BLANK1);
+       uiMenuItemO(head, 0, "VIEW3D_OT_viewcenter");
+       uiMenuItemO(head, 0, "VIEW3D_OT_viewhome");
        
        uiMenuSeparator(head);
        
-       if(sa->full) uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Tile Window", Ctrl UpArrow
-       else uiMenuItemO(head, "SCREEN_OT_screen_full_area", ICON_BLANK1); // "Maximize Window", Ctr DownArrow
+       if(sa->full) uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow
+       else uiMenuItemO(head, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctr DownArrow
 }
 #if 0
 static uiBlock *view3d_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
@@ -6052,15 +6052,15 @@ static int editmesh_face_toolbox_invoke(bContext *C, wmOperator *op, wmEvent *ev
 {
        uiMenuItem *head;
 
-       head= uiPupMenuBegin("Edit Faces");
+       head= uiPupMenuBegin("Edit Faces", 0);
 
-       uiMenuItemO(head, "MESH_OT_fill", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_beauty_fill", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_convert_quads_to_tris", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_convert_tris_to_quads", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_edge_flip", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_faces_shade_smooth", ICON_BLANK1);
-       uiMenuItemO(head, "MESH_OT_faces_shade_solid", ICON_BLANK1);
+       uiMenuItemO(head, 0, "MESH_OT_fill");
+       uiMenuItemO(head, 0, "MESH_OT_beauty_fill");
+       uiMenuItemO(head, 0, "MESH_OT_convert_quads_to_tris");
+       uiMenuItemO(head, 0, "MESH_OT_convert_tris_to_quads");
+       uiMenuItemO(head, 0, "MESH_OT_edge_flip");
+       uiMenuItemO(head, 0, "MESH_OT_faces_shade_smooth");
+       uiMenuItemO(head, 0, "MESH_OT_faces_shade_solid");
        uiPupMenuEnd(C, head);
 
        return OPERATOR_CANCELLED;
index 3bad537948479663a9ba0150516d8564f6373147..1e7c67c7cd32da1e08f3ab24c174f225313e2a8d 100644 (file)
 
 #include "transform.h"
 
-
 static int select_orientation_exec(bContext *C, wmOperator *op)
 {
-       int orientation = RNA_int_get(op->ptr, "orientation");
+       int orientation = RNA_enum_get(op->ptr, "orientation");
+       int custom_index= RNA_int_get(op->ptr, "custom_index");;
+
+       if(orientation == V3D_MANIP_CUSTOM)
+               orientation += custom_index;
        
-       if (orientation > -1)
-       {
-               BIF_selectTransformOrientationValue(C, orientation);
-               return OPERATOR_FINISHED;
-       }
-       else
-       {
-               return OPERATOR_CANCELLED;
-       }
+       BIF_selectTransformOrientationValue(C, orientation);
+
+       return OPERATOR_FINISHED;
 }
 
 static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       char *string = BIF_menustringTransformOrientation(C, "Orientation");
-       
-       op->customdata = string;
+       uiMenuItem *head;
        
-       uiPupMenuOperator(C, 0, op, "orientation", string);
+       head= uiPupMenuBegin("Orientation", 0);
+       BIF_menuTransformOrientation(C, head, NULL);
+       uiPupMenuEnd(C, head);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
        
 void TFM_OT_select_orientation(struct wmOperatorType *ot)
 {
+       static EnumPropertyItem orientation_items[]= {
+               {V3D_MANIP_GLOBAL, "GLOBAL", "Global", ""},
+               {V3D_MANIP_NORMAL, "NORMAL", "Normal", ""},
+               {V3D_MANIP_LOCAL, "LOCAL", "Local", ""},
+               {V3D_MANIP_VIEW, "VIEW", "View", ""},
+               {V3D_MANIP_CUSTOM, "CUSTOM", "Custom", ""},
+               {0, NULL, NULL, NULL}};
+
        /* identifiers */
        ot->name   = "Select Orientation";
        ot->idname = "TFM_OT_select_orientation";
@@ -82,7 +87,8 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
        ot->exec   = select_orientation_exec;
        ot->poll   = ED_operator_areaactive;
 
-       RNA_def_int(ot->srna, "orientation", -1, INT_MIN, INT_MAX, "Orientation", "DOC_BROKEN", INT_MIN, INT_MAX);
+       RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_CUSTOM, "Orientation", "DOC_BROKEN");
+       RNA_def_int(ot->srna, "custom_index", 0, 0, INT_MAX, "Custom Index", "", 0, INT_MAX);
 }
 
 static void transformops_exit(bContext *C, wmOperator *op)
@@ -208,7 +214,7 @@ void TFM_OT_transform(struct wmOperatorType *ot)
        /* identifiers */
        ot->name   = "Transform";
        ot->idname = "TFM_OT_transform";
-       ot->flag= OPTYPE_REGISTER;
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* api callbacks */
        ot->invoke = transform_invoke;
index 3cd24a31111fbd0b16aa1cfb57318bfc8fa6ab4c..35d7cb3634368250cb477b998a79d4ed5577c371 100644 (file)
@@ -57,6 +57,8 @@
 #include "ED_mesh.h"
 #include "ED_util.h"
 
+#include "UI_interface.h"
+
 #include "transform.h"
 
 /* *********************** TransSpace ************************** */
@@ -352,6 +354,22 @@ void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
        v3d->twmode = orientation;
 }
 
+void BIF_menuTransformOrientation(bContext *C, uiMenuItem *head, void *arg)
+{
+       char menu[] = "%t|Global%x0|Local%x1|Normal%x2|View%x3";
+       ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
+       TransformOrientation *ts;
+       int i= V3D_MANIP_CUSTOM;
+
+       uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
+       uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
+       uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
+       uiMenuItemEnumO(head, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
+
+       for(ts = transform_spaces->first; ts; ts = ts->next)
+               uiMenuItemIntO(head, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++);
+}
+
 char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
        char menu[] = "%t|Global%x0|Local%x1|Normal%x2|View%x3";
        ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
index 1a31373ef3123ead9ab29f43765525dc71c734a4..5d7ed72127e8b3990185fa56e3cf16ec18c9411f 100644 (file)
@@ -113,7 +113,7 @@ void ED_undo_push_op(bContext *C, wmOperator *op)
        ED_undo_push(C, op->type->name);
 }
 
-static int ed_undo_step(bContext *C, wmOperator *op, int step)
+static int ed_undo_step(bContext *C, int step)
 {      
        Object *obedit= CTX_data_edit_object(C);
        ScrArea *sa= CTX_wm_area(C);
@@ -161,13 +161,18 @@ static int ed_undo_step(bContext *C, wmOperator *op, int step)
        return OPERATOR_FINISHED;
 }
 
+void ED_undo_pop(bContext *C)
+{
+       ed_undo_step(C, 1);
+}
+
 static int ed_undo_exec(bContext *C, wmOperator *op)
 {
-       return ed_undo_step(C, op, 1);
+       return ed_undo_step(C, 1);
 }
 static int ed_redo_exec(bContext *C, wmOperator *op)
 {
-       return ed_undo_step(C, op, -1);
+       return ed_undo_step(C, -1);
 }
 
 void ED_undo_menu(bContext *C)
index 5c286e06324d29f8963fd77bc246e362ffc868f3..f5e9520c702646f8dac5596a2a8c8b4a88c5ac39 100644 (file)
@@ -201,9 +201,7 @@ void WM_operator_properties_free(PointerRNA *ptr)
 int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type");
-       const EnumPropertyItem *item;
-       int totitem, i, len= strlen(op->type->name) + 8;
-       char *menu, *p;
+       uiMenuItem *head;
 
        if(prop==NULL) {
                printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname);
@@ -212,34 +210,24 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
                printf("WM_menu_invoke: %s \"type\" is not an enum property\n", op->type->idname);
        }
        else {
-               RNA_property_enum_items(op->ptr, prop, &item, &totitem);
-               
-               for (i=0; i<totitem; i++)
-                       len+= strlen(item[i].name) + 8;
-               
-               menu= MEM_callocN(len, "string");
-               
-               p= menu + sprintf(menu, "%s %%t", op->type->name);
-               for (i=0; i<totitem; i++)
-                       p+= sprintf(p, "|%s %%x%d", item[i].name, item[i].value);
-               
-               uiPupMenuOperator(C, totitem/30, op, "type", menu);
-               MEM_freeN(menu);
-               
-               return OPERATOR_RUNNING_MODAL;
+               head= uiPupMenuBegin(op->type->name, 0);
+               uiMenuItemsEnumO(head, op->type->idname, "type");
+               uiPupMenuEnd(C, head);
        }
+
        return OPERATOR_CANCELLED;
 }
 
 /* op->invoke */
 int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
 {
-       char buf[512];
-       
-       sprintf(buf, "OK? %%i%d%%t|%s", ICON_HELP, op->type->name);
-       uiPupMenuOperator(C, 0, op, NULL, buf);
+       uiMenuItem *head;
+
+       head= uiPupMenuBegin("OK?", ICON_HELP);
+       uiMenuItemO(head, 0, op->type->idname);
+       uiPupMenuEnd(C, head);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 /* op->invoke, opens fileselect if filename property not set, otherwise executes */
@@ -293,26 +281,6 @@ static void WM_OT_save_homefile(wmOperatorType *ot)
 
 /* ********* recent file *********** */
 
-static void recent_filelist(char *pup)
-{
-       struct RecentFile *recent;
-       int i, ofs= 0;
-       char *p;
-       
-       p= pup + sprintf(pup, "Open Recent%%t");
-       
-       if (G.sce[0]) {
-               p+= sprintf(p, "|%s %%x%d", G.sce, 1);
-               ofs = 1;
-       }
-       
-       for (recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
-               if (strcmp(recent->filename, G.sce)) {
-                       p+= sprintf(p, "|%s %%x%d", recent->filename, i+ofs+1);
-               }
-       }
-}
-
 static int recentfile_exec(bContext *C, wmOperator *op)
 {
        int event= RNA_enum_get(op->ptr, "nr");
@@ -338,12 +306,24 @@ static int recentfile_exec(bContext *C, wmOperator *op)
 
 static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       char pup[2048];
+       struct RecentFile *recent;
+       uiMenuItem *head;
+       int i, ofs= 0;
+
+       head= uiPupMenuBegin("Open Recent", 0);
+
+       if(G.sce[0]) {
+               uiMenuItemIntO(head, G.sce, 0, op->type->idname, "nr", 1);
+               ofs = 1;
+       }
        
-       recent_filelist(pup);
-       uiPupMenuOperator(C, 0, op, "nr", pup);
+       for(recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++)
+               if(strcmp(recent->filename, G.sce))
+                       uiMenuItemIntO(head, recent->filename, 0, op->type->idname, "nr", i+ofs+1);
+
+       uiPupMenuEnd(C, head);
        
-       return OPERATOR_RUNNING_MODAL;
+       return OPERATOR_CANCELLED;
 }
 
 static void WM_OT_open_recentfile(wmOperatorType *ot)