Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-10-22 12:21:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-10-22 12:21:43 +0400
commit688cc11302caa8cde5649e6230c66a1c60cd24a2 (patch)
tree6e0228ff328b2f4a458f9dec1385a9c6810df8b3
parent69c6bd604c36e06d704948bce1eb32134ac8971f (diff)
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.
-rw-r--r--release/scripts/export_fbx.py2
-rw-r--r--release/scripts/export_obj.py2
-rw-r--r--release/scripts/import_obj.py2
-rw-r--r--release/scripts/object_drop.py2
-rw-r--r--source/blender/python/api2_2x/Draw.c15
-rw-r--r--source/blender/python/api2_2x/doc/Draw.py8
6 files changed, 17 insertions, 14 deletions
diff --git a/release/scripts/export_fbx.py b/release/scripts/export_fbx.py
index 696d3d1561a..3f02a71f951 100644
--- a/release/scripts/export_fbx.py
+++ b/release/scripts/export_fbx.py
@@ -2952,7 +2952,7 @@ def write_ui():
#fbx_ui_write('/test.fbx')
break
- Draw.UIBlock(fbx_ui)
+ Draw.UIBlock(fbx_ui, 0)
# GLOBALS.clear()
diff --git a/release/scripts/export_obj.py b/release/scripts/export_obj.py
index 79a224d63c3..9feb02638c3 100644
--- a/release/scripts/export_obj.py
+++ b/release/scripts/export_obj.py
@@ -694,7 +694,7 @@ def write_ui(filename):
# 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
diff --git a/release/scripts/import_obj.py b/release/scripts/import_obj.py
index b7bdd54fe6d..3aad0800cf7 100644
--- a/release/scripts/import_obj.py
+++ b/release/scripts/import_obj.py
@@ -878,7 +878,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False):
# 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
diff --git a/release/scripts/object_drop.py b/release/scripts/object_drop.py
index 63a0bd574fb..f4803e62d98 100644
--- a/release/scripts/object_drop.py
+++ b/release/scripts/object_drop.py
@@ -216,7 +216,7 @@ def main():
# 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()
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index c942657fbd0..e0111f099aa 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -141,7 +141,7 @@ static uiBlock *uiblock=NULL;
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 @@ static char Method_Text_doc[] =
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 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
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 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
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 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
/* Done clearing events */
uiBoundsBlock(uiblock, 5);
- uiDoBlocks(&listb, 0, 1);
+ uiDoBlocks(&listb, 0, mouse_exit);
}
uiFreeBlocks(&listb);
uiblock = NULL;
diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py
index 97e22797902..127f37bfbad 100644
--- a/source/blender/python/api2_2x/doc/Draw.py
+++ b/source/blender/python/api2_2x/doc/Draw.py
@@ -235,19 +235,21 @@ def EndAlign():
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.
"""