Page Menu
Home
Search
Configure Global Search
Log In
Files
F2397
patch-2676.c
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 1:04 PM
Size
7 KB
Subscribers
None
patch-2676.c
View Options
Index
:
source
/
blender
/
python
/
api2_2x
/
Draw
.
c
===================================================================
RCS
file
:
/
cvsroot
/
bf
-
blender
/
blender
/
source
/
blender
/
python
/
api2_2x
/
Draw
.
c
,
v
retrieving
revision
1.37
diff
-
u
-
r1
.37
Draw
.
c
---
source
/
blender
/
python
/
api2_2x
/
Draw
.
c
25
May
2005
04
:
52
:
52
-0000
1.37
+++
source
/
blender
/
python
/
api2_2x
/
Draw
.
c
9
Jun
2005
20
:
30
:
05
-0000
@@
-70
,
6
+
70
,
9
@@
#include
"interface.h"
#include
"mydevice.h"
/*@ for all the event constants */
+
#
define
EVENT_OFFSET
16
/* lets us distinguish user event from
+ internal Blender events */
+
/* pointer to main dictionary defined in Blender.c */
extern
PyObject
*
g_blenderdict
;
@@
-510
,
18
+
513
,
6
@@
void
BPY_spacescript_do_pywin_event
(
SpaceScript
*
sc
,
unsigned
short
event
,
short
val
,
char
ascii
)
{
-
static
int
menu_hack
=
0
;
-
-
/* about menu_hack above: when a menu returns after an entry is chosen,
- * two events are generated, the second one with val = 4. We don't want
- * this second one to be passed to Python, because it can be confused with
- * some event with same number defined by the script.
- * What we do is set menu_hack to 1 if a button event occurs.
- * Then if the next one is also a button event, w/ val = 4, we discard it. */
-
-
if
(
event
!=
UI_BUT_EVENT
||
!
val
)
-
menu_hack
=
0
;
-
if
(
event
==
QKEY
&&
G
.
qual
&
(
LR_ALTKEY
|
LR_CTRLKEY
)
)
{
/* finish script: user pressed ALT+Q or CONTROL+Q */
Script
*
script
=
sc
->
script
;
@@
-537
,
20
+
528
,
11
@@
if
(
uiDoBlocks
(
&
curarea
->
uiblocks
,
event
)
!=
UI_NOTHING
)
event
=
0
;
-
if
(
event
==
UI_BUT_EVENT
)
{
-
if
(
menu_hack
&&
val
==
UI_RETURN_OK
)
{
/* "false" event? */
-
if
(
menu_hack
==
2
)
/* was last event UI_RETURN_OUT? */
-
spacescript_do_pywin_buttons
(
sc
,
UI_RETURN_OUT
);
/* if so, send */
-
menu_hack
=
0
;
/* clear menu_hack */
-
}
-
else
if
(
val
==
UI_RETURN_OUT
)
/* possible cancel */
-
menu_hack
=
2
;
-
else
{
-
menu_hack
=
1
;
-
spacescript_do_pywin_buttons
(
sc
,
val
);
-
}
+
/* if a button event and value indicates a user-defined event,
+ * pass it back (with adjustment) */
-
}
+
if
(
event
==
UI_BUT_EVENT
&&
(
unsigned
short
)
val
>=
EVENT_OFFSET
)
+
spacescript_do_pywin_buttons
(
sc
,
val
-
EVENT_OFFSET
);
}
/* Using the "event" main module var, used by scriptlinks, to pass the ascii
@@ -568,7 +550,6 @@
PyDict_SetItemString(g_blenderdict, "event", PyString_FromString(""));
}
}
-
static PyObject *Method_Exit( PyObject * self, PyObject * args )
{
SpaceScript *sc;
@@ -760,14 +741,20 @@
{
uiBlock *block;
char *name, *tip = NULL;
- int event;
+ unsigned short event;
int x, y, w, h;
- if( !PyArg_ParseTuple( args, "siiiii|s", &name, &event,
+ if( !PyArg_ParseTuple( args, "sHiiii|s", &name, &event,
&x, &y, &w, &h, &tip ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string, five ints and optionally another string as arguments" );
+ /* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
block
=
Get_uiBlock
(
);
if
(
block
)
@@
-781
,
15
+
768
,
21
@@
{
uiBlock
*
block
;
char
*
name
,
*
tip
=
NULL
;
-
int
event
,
def
;
-
int
x
,
y
,
w
,
h
;
+
unsigned
short
event
;
+
int
def
,
x
,
y
,
w
,
h
;
Button
*
but
;
-
if
(
!
PyArg_ParseTuple
(
args
,
"siiiiii|s"
,
&
name
,
&
event
,
+
if
(
!
PyArg_ParseTuple
(
args
,
"sHiiiii|s"
,
&
name
,
&
event
,
&
x
,
&
y
,
&
w
,
&
h
,
&
def
,
&
tip
)
)
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
"expected a string, six ints and optionally another string as arguments"
);
+
/* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
but
=
newbutton
(
);
but
->
type
=
1
;
but
->
val
.
asint
=
def
;
@@
-806
,
15
+
799
,
21
@@
{
uiBlock
*
block
;
char
*
name
,
*
tip
=
NULL
;
-
int
event
;
+
unsigned
short
event
;
int
x
,
y
,
w
,
h
,
def
;
Button
*
but
;
-
if
(
!
PyArg_ParseTuple
(
args
,
"siiiiii|s"
,
&
name
,
&
event
,
+
if
(
!
PyArg_ParseTuple
(
args
,
"sHiiiii|s"
,
&
name
,
&
event
,
&
x
,
&
y
,
&
w
,
&
h
,
&
def
,
&
tip
)
)
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
"expected a string, six ints and optionally another string as arguments"
);
+
/* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
but
=
newbutton
(
);
but
->
type
=
1
;
but
->
val
.
asint
=
def
;
@@
-837
,
6
+
836
,
7
@@
static
void
py_slider_update
(
void
*
butv
,
void
*
data2_unused
)
{
uiBut
*
but
=
butv
;
+
PyObject
*
ref
=
Py_BuildValue
(
"(i)"
,
SPACE_VIEW3D
);
EXPP_disable_force_draw
=
1
;
/*@ Disable forced drawing, otherwise the button object which
@@ -848,9 +848,14 @@
disable_where_script( 1 );
spacescript_do_pywin_buttons( curarea->spacedata.first,
- uiButGetRetVal( but ) );
+ uiButGetRetVal( but ) - EVENT_OFFSET );
+
/* XXX useless right now: */
-
M_Window_Redraw
(
0
,
Py_BuildValue
(
"(i)"
,
SPACE_VIEW3D
)
);
+
/* if this is "useless", should it be removed? */
+
M_Window_Redraw
(
0
,
ref
);
+
+
Py_DECREF
(
Py_None
);
/* M_Window_Redraw() returns new Py_None ref */
+
Py_DECREF
(
ref
);
disable_where_script
(
0
);
@@
-861
,
18
+
866
,
24
@@
{
uiBlock
*
block
;
char
*
name
,
*
tip
=
NULL
;
-
int
event
;
+
unsigned
short
event
;
int
x
,
y
,
w
,
h
,
realtime
=
1
;
Button
*
but
;
PyObject
*
mino
,
*
maxo
,
*
inio
;
-
if
(
!
PyArg_ParseTuple
(
args
,
"siiiiiOOO|is"
,
&
name
,
&
event
,
+
if
(
!
PyArg_ParseTuple
(
args
,
"sHiiiiOOO|is"
,
&
name
,
&
event
,
&
x
,
&
y
,
&
w
,
&
h
,
&
inio
,
&
mino
,
&
maxo
,
&
realtime
,
&
tip
)
)
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
"expected a string, five ints, three PyObjects
\n
\
and optionally another int and string as arguments"
);
+
/* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
but
=
newbutton
(
);
if
(
PyFloat_Check
(
inio
)
)
{
@@
-940
,
6
+
951
,
12
@@
return
EXPP_ReturnPyObjError
(
PyExc_AttributeError
,
"expected numbers for initial, min, and max"
);
+
/* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
but
=
newbutton
(
);
if
(
PyFloat_Check
(
inio
)
)
@@
-984
,
17
+
1001
,
23
@@
{
uiBlock
*
block
;
char
*
name
,
*
tip
=
NULL
;
-
int
event
;
+
unsigned
short
event
;
int
x
,
y
,
w
,
h
;
Button
*
but
;
PyObject
*
mino
,
*
maxo
,
*
inio
;
-
if
(
!
PyArg_ParseTuple
(
args
,
"siiiiiOOO|s"
,
&
name
,
&
event
,
+
if
(
!
PyArg_ParseTuple
(
args
,
"sHiiiiOOO|s"
,
&
name
,
&
event
,
&
x
,
&
y
,
&
w
,
&
h
,
&
inio
,
&
mino
,
&
maxo
,
&
tip
)
)
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
"expected a string, five ints, three PyObjects and
\n
\
optionally another string as arguments"
);
+
/* adjust event number, check for overflow */
+
if
(
event
>
USHRT_MAX
-
EVENT_OFFSET
)
+
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
+
"event value out of range"
);
+
event
+=
EVENT_OFFSET
;
+
but
=
newbutton
(
);
if
(
PyFloat_Check
(
inio
)
)
{
@@
-1035
,
11
+
1058
,
11
@@
uiBlock
*
block
;
char
*
info_arg
=
NULL
,
*
tip
=
NULL
,
*
newstr
=
NULL
;
char
*
info_str
=
NULL
,
*
info_str0
=
" "
;
-
int
event
;
+
unsigned
short
event
;
int
x
,
y
,
w
,
h
,
len
,
real_len
=
0
;
Button
*
but
;
-
if
(
!
PyArg_ParseTuple
(
args
,
"siiiiisi|s"
,
&
info_arg
,
&
event
,
+
if
(
!
PyArg_ParseTuple
(
args
,
"sHiiiisi|s"
,
&
info_arg
,
&
event
,
&
x
,
&
y
,
&
w
,
&
h
,
&
newstr
,
&
len
,
&
tip
)
)
return
EXPP_ReturnPyObjError
(
PyExc_TypeError
,
"expected a string, five ints, a string, an int and
\n
\
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f3/73/6120d5b74115bc1e3e4d47f1c62f
Event Timeline
Log In to Comment