Revision: 17171
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17171
Author:   campbellbarton
Date:     2008-10-22 10:21:43 +0200 (Wed, 22 Oct 2008)

Log Message:
-----------
added an option for python Draw.UIBlock(func, mouse_exit) so moving the mouse 
outside the popup wont close it.
Stops FBX Export and OBJ I/O from flickering a lot.

Modified Paths:
--------------
    trunk/blender/release/scripts/export_fbx.py
    trunk/blender/release/scripts/export_obj.py
    trunk/blender/release/scripts/import_obj.py
    trunk/blender/release/scripts/object_drop.py
    trunk/blender/source/blender/python/api2_2x/Draw.c
    trunk/blender/source/blender/python/api2_2x/doc/Draw.py

Modified: trunk/blender/release/scripts/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/export_fbx.py 2008-10-22 07:09:15 UTC (rev 
17170)
+++ trunk/blender/release/scripts/export_fbx.py 2008-10-22 08:21:43 UTC (rev 
17171)
@@ -2952,7 +2952,7 @@
                        #fbx_ui_write('/test.fbx')
                        break
                
-               Draw.UIBlock(fbx_ui)
+               Draw.UIBlock(fbx_ui, 0)
        
        
        # GLOBALS.clear()

Modified: trunk/blender/release/scripts/export_obj.py
===================================================================
--- trunk/blender/release/scripts/export_obj.py 2008-10-22 07:09:15 UTC (rev 
17170)
+++ trunk/blender/release/scripts/export_obj.py 2008-10-22 08:21:43 UTC (rev 
17171)
@@ -694,7 +694,7 @@
                
                # hack so the toggle buttons redraw. this is not nice at all
                while GLOBALS['EVENT'] not in (EVENT_EXIT, EVENT_EXPORT):
-                       Draw.UIBlock(obj_ui)
+                       Draw.UIBlock(obj_ui, 0)
                
                if GLOBALS['EVENT'] != EVENT_EXPORT:
                        return

Modified: trunk/blender/release/scripts/import_obj.py
===================================================================
--- trunk/blender/release/scripts/import_obj.py 2008-10-22 07:09:15 UTC (rev 
17170)
+++ trunk/blender/release/scripts/import_obj.py 2008-10-22 08:21:43 UTC (rev 
17171)
@@ -878,7 +878,7 @@
                
                # hack so the toggle buttons redraw. this is not nice at all
                while GLOBALS['EVENT'] not in (EVENT_EXIT, EVENT_IMPORT):
-                       Draw.UIBlock(obj_ui)
+                       Draw.UIBlock(obj_ui, 0)
                
                if GLOBALS['EVENT'] != EVENT_IMPORT:
                        return

Modified: trunk/blender/release/scripts/object_drop.py
===================================================================
--- trunk/blender/release/scripts/object_drop.py        2008-10-22 07:09:15 UTC 
(rev 17170)
+++ trunk/blender/release/scripts/object_drop.py        2008-10-22 08:21:43 UTC 
(rev 17171)
@@ -216,7 +216,7 @@
        
        # hack so the toggle buttons redraw. this is not nice at all
        while GLOBALS['EVENT'] == EVENT_REDRAW:
-               Draw.UIBlock(terain_clamp_ui)
+               Draw.UIBlock(terain_clamp_ui, 0)
        
 if __name__ == '__main__':
        main()

Modified: trunk/blender/source/blender/python/api2_2x/Draw.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Draw.c  2008-10-22 07:09:15 UTC 
(rev 17170)
+++ trunk/blender/source/blender/python/api2_2x/Draw.c  2008-10-22 08:21:43 UTC 
(rev 17171)
@@ -141,7 +141,7 @@
 
 static char Draw_doc[] = "The Blender.Draw submodule";
 
-static char Method_UIBlock_doc[] = "(drawfunc, x,y) - Popup dialog where 
buttons can be drawn (expemental)";
+static char Method_UIBlock_doc[] = "(drawfunc, mouse_exit) - Popup dialog 
where buttons can be drawn (expemental)";
 
 static char Method_Register_doc[] =
        "(draw, event, button) - Register callbacks for windowing\n\n\
@@ -290,9 +290,9 @@
 This function returns the width of the drawn string.";
 
 static char Method_Label_doc[] =
-       "(text, x, y) - Draw a text label onscreen\n\n\
+       "(text, x, y, w, h, tip, callback) - Draw a text label onscreen\n\n\
 (text) The text to draw\n\
-(x, y) The lower left coordinate of the lable";
+(x, y, w, h) The lower left coordinate of the lable, width and height";
 
 static char Method_PupMenu_doc[] =
        "(string, maxrow = None) - Display a pop-up menu at the screen.\n\
@@ -1101,15 +1101,16 @@
        PyObject *val = NULL;
        PyObject *result = NULL;
        ListBase listb= {NULL, NULL};
+       int mouse_exit = 1;
 
        if (G.background) {
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                              "Can't run Draw.UIBlock() in 
background mode." );
        }
        
-       if ( !PyArg_ParseTuple( args, "O", &val ) || !PyCallable_Check( val ) ) 
+       if ( !PyArg_ParseTuple( args, "O|i", &val, &mouse_exit ) || 
!PyCallable_Check( val ) ) 
                return EXPP_ReturnPyObjError( PyExc_AttributeError,
-                                             "expected 1 python function and 2 
ints" );
+                                             "expected 1 python function and 
an optional int" );
 
        if (uiblock)
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -1121,7 +1122,7 @@
        uiblock= uiNewBlock(&listb, "numbuts", UI_EMBOSS, UI_HELV, 
G.curscreen->mainwin);
        
        uiBlockSetFlag(uiblock, UI_BLOCK_LOOP|UI_BLOCK_REDRAW);
-       result = PyObject_CallObject( val, Py_BuildValue( "()" ) );
+       result = PyObject_CallObject( val, NULL );
        
        if (!result) {
                PyErr_Print(  );
@@ -1146,7 +1147,7 @@
                /* Done clearing events */
                
                uiBoundsBlock(uiblock, 5);
-               uiDoBlocks(&listb, 0, 1);
+               uiDoBlocks(&listb, 0, mouse_exit);
        }
        uiFreeBlocks(&listb);
        uiblock = NULL;

Modified: trunk/blender/source/blender/python/api2_2x/doc/Draw.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Draw.py     2008-10-22 
07:09:15 UTC (rev 17170)
+++ trunk/blender/source/blender/python/api2_2x/doc/Draw.py     2008-10-22 
08:21:43 UTC (rev 17171)
@@ -235,19 +235,21 @@
        Use after BeginAlign() to stop aligning the buttons (button layout 
only).
        """
 
-def UIBlock(draw):
+def UIBlock(draw, mouse_exit=1):
        """
        This function creates a popup area where buttons, labels, sliders etc 
can be drawn.
        
+       @type mouse_exit: int
+       @param mouse_exit: When zero the popup wont close when the mouse moves 
away from the popup.
        @type draw: function
        @param draw: A function to draw to the popup area, taking no arguments: 
draw().
        
        @note: The size of the popup will expand to fit the bounds of the 
buttons created in the draw function.
-       @note: Be sure to use the mouse coordinates to position the buttons 
under the mouse,
+       @note: If mouse_exit is nonzero be sure to use the mouse coordinates if 
to position the buttons under the mouse,
                so the popup dosn't exit as soon as it opens.
                The coordinates for buttons start 0,0 at the bottom left hand 
side of the screen.
        @note: Within this popup, Redraw events and the registered button 
callback will not work.
-               For buttons to run events, use per button callbacks.
+               For buttons to run events, use per button callbacks instead.
        @note: OpenGL drawing functions wont work within this popup, for text 
use L{Label} rather then L{Text}
        @warning: L{Menu} will not work properly within a UIBlock, this is a 
limitation with blenders user interface internals.
        """


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to