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>2006-12-27 14:58:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2006-12-27 14:58:03 +0300
commit4d74f07043572aff350050b567a2772dec88b52f (patch)
treedc0c70cf8f586fd5eb978c200e5e4af8c6abaf5a /source/blender/python/api2_2x/Draw.c
parent38f168c3d3b7a7e979ec33e574ad69e9966c47bb (diff)
added Draw.Normal() for the normal rotating sphere button, mostly the same as the ColorPicker in code and syntax.
Diffstat (limited to 'source/blender/python/api2_2x/Draw.c')
-rw-r--r--source/blender/python/api2_2x/Draw.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 173d971e7b8..fb70cf88199 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -102,6 +102,7 @@ static PyObject *Method_Toggle( PyObject * self, PyObject * args );
static PyObject *Method_Slider( PyObject * self, PyObject * args );
static PyObject *Method_Scrollbar( PyObject * self, PyObject * args );
static PyObject *Method_ColorPicker( PyObject * self, PyObject * args );
+static PyObject *Method_Normal( PyObject * self, PyObject * args );
static PyObject *Method_Number( PyObject * self, PyObject * args );
static PyObject *Method_String( PyObject * self, PyObject * args );
static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args );
@@ -228,6 +229,15 @@ Color picker button\n\n\
(initial) 3-Float tuple of the color (values between 0 and 1)\
[tooltip=] The button's tooltip";
+static char Method_Normal_doc[] =
+ "(event, x, y, width, height, initial, [tooltip]) - Create a new Button \
+Normal button (a sphere that you can roll to change the normal)\n\n\
+(event) The event number to pass to the button event function when the color changes\n\
+(x, y) The lower left coordinate of the button\n\
+(width, height) The button width and height - non square will gave odd results\n\
+(initial) 3-Float tuple of the normal vector (values between -1 and 1)\
+[tooltip=] The button's tooltip";
+
static char Method_Number_doc[] =
"(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \
new Number button\n\n\
@@ -341,6 +351,7 @@ static struct PyMethodDef Draw_methods[] = {
MethodDef( Slider ),
MethodDef( Scrollbar ),
MethodDef( ColorPicker ),
+ MethodDef( Normal ),
MethodDef( Number ),
MethodDef( String ),
MethodDef( GetStringWidth ),
@@ -1161,6 +1172,49 @@ static PyObject *Method_ColorPicker( PyObject * self, PyObject * args )
}
+
+static PyObject *Method_Normal( PyObject * self, PyObject * args )
+{
+ char USAGE_ERROR[] = "expected a 3-float tuple of values between -1 and 1";
+ Button *but;
+ PyObject *inio;
+ uiBlock *block;
+ char *tip = NULL;
+ float nor[3];
+ int event;
+ short x, y, w, h;
+
+ if( !PyArg_ParseTuple( args, "ihhhhO!|s", &event,
+ &x, &y, &w, &h, &PyTuple_Type, &inio, &tip ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected five ints, one tuple and optionally a string as arguments." );
+
+ if (check_button_event(&event) == -1)
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "button event argument must be in the range [0, 16382]");
+
+ if ( !PyArg_ParseTuple( inio, "fff", nor, nor+1, nor+2 ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
+
+ if ( EXPP_check_sequence_consistency( inio, &PyFloat_Type ) != 1 )
+ return EXPP_ReturnPyObjError( PyExc_ValueError, USAGE_ERROR);
+
+ but = newbutton();
+
+ but->type = BVECTOR_TYPE;
+ but->val.asvec[0] = nor[0];
+ but->val.asvec[1] = nor[1];
+ but->val.asvec[2] = nor[2];
+
+ block = Get_uiBlock( );
+ if( block ) {
+ uiBut *ubut;
+ ubut = uiDefButF( block, BUT_NORMAL, event, "", x, y, w, h, but->val.asvec, 0.0f, 1.0f, 0, 0, tip);
+ }
+
+ return ( PyObject * ) but;
+}
+
static PyObject *Method_Number( PyObject * self, PyObject * args )
{
uiBlock *block;