Added Draw.BeginAlign(), Draw.EndAlign()
added align to a few scripts where it looks nice.
This commit is contained in:
@@ -711,12 +711,14 @@ def draw():
|
|||||||
Llisted=0
|
Llisted=0
|
||||||
size[3]=size[3]-18
|
size[3]=size[3]-18
|
||||||
|
|
||||||
|
BeginAlign()
|
||||||
for k in hot:
|
for k in hot:
|
||||||
#hotkeys[k][-1]=Toggle(k, hot.index(k)+10, 4+(20*26)/6*hot.index(k), size[3]-(42), len(k)*8, 20, hotkeys[k][-1].val )
|
#hotkeys[k][-1]=Toggle(k, hot.index(k)+10, 4+(20*26)/6*hot.index(k), size[3]-(42), len(k)*8, 20, hotkeys[k][-1].val )
|
||||||
hotkeys[k][-1]=Toggle(k, hot.index(k)+10, 78*hot.index(k), size[3]-(47), 78, 24, hotkeys[k][-1].val )
|
hotkeys[k][-1]=Toggle(k, hot.index(k)+10, 78*hot.index(k), size[3]-(47), 78, 24, hotkeys[k][-1].val )
|
||||||
l+=len(k)
|
l+=len(k)
|
||||||
if hotkeys[k][-1].val==1.0:
|
if hotkeys[k][-1].val==1.0:
|
||||||
listed=hot.index(k)
|
listed=hot.index(k)
|
||||||
|
EndAlign()
|
||||||
l=0
|
l=0
|
||||||
size[3]=size[3]-4
|
size[3]=size[3]-4
|
||||||
|
|
||||||
@@ -725,8 +727,10 @@ def draw():
|
|||||||
SCROLL=size[3]/21
|
SCROLL=size[3]/21
|
||||||
END=-1
|
END=-1
|
||||||
if SCROLL < len(hotkeys[hot[listed]][:-1]):
|
if SCROLL < len(hotkeys[hot[listed]][:-1]):
|
||||||
|
BeginAlign()
|
||||||
Button('/\\',up,4,size[3]+8,20,14,'Scroll up')
|
Button('/\\',up,4,size[3]+8,20,14,'Scroll up')
|
||||||
Button('\\/',down,4,size[3]-8,20,14,'Scroll down')
|
Button('\\/',down,4,size[3]-8,20,14,'Scroll down')
|
||||||
|
EndAlign()
|
||||||
if (SCROLL+UP)<len(hotkeys[hot[listed]][:-1]):
|
if (SCROLL+UP)<len(hotkeys[hot[listed]][:-1]):
|
||||||
END=(UP+SCROLL)
|
END=(UP+SCROLL)
|
||||||
else:
|
else:
|
||||||
@@ -758,8 +762,10 @@ def draw():
|
|||||||
END=-1
|
END=-1
|
||||||
|
|
||||||
if SCROLL < len(FINDED):
|
if SCROLL < len(FINDED):
|
||||||
|
BeginAlign()
|
||||||
Button('/\\',up,4,size[3]+8,20,14,'Scroll up')
|
Button('/\\',up,4,size[3]+8,20,14,'Scroll up')
|
||||||
Button('\\/',down,4,size[3]-8,20,14,'Scroll down')
|
Button('\\/',down,4,size[3]-8,20,14,'Scroll down')
|
||||||
|
EndAlign()
|
||||||
if (SCROLL+UP)<len(FINDED):
|
if (SCROLL+UP)<len(FINDED):
|
||||||
END=(UP+SCROLL-1)
|
END=(UP+SCROLL-1)
|
||||||
else:
|
else:
|
||||||
@@ -779,18 +785,22 @@ def draw():
|
|||||||
Text(' : '+n[1])
|
Text(' : '+n[1])
|
||||||
l+=1
|
l+=1
|
||||||
else:
|
else:
|
||||||
|
BeginAlign()
|
||||||
for k in hotL:
|
for k in hotL:
|
||||||
pos=hotL.index(k)
|
pos=hotL.index(k)
|
||||||
hotkeys['Letters '][0][k][-1]=Toggle(k,pos+20,hotL.index(k)*21, size[3]-(52+18), 21, 18, hotkeys['Letters '][0][k][-1].val )
|
hotkeys['Letters '][0][k][-1]=Toggle(k,pos+20,hotL.index(k)*21, size[3]-(52+18), 21, 18, hotkeys['Letters '][0][k][-1].val )
|
||||||
if hotkeys['Letters '][0][k][-1].val==1.0:
|
if hotkeys['Letters '][0][k][-1].val==1.0:
|
||||||
Llisted=pos
|
Llisted=pos
|
||||||
|
EndAlign()
|
||||||
size[3]=size[3]-8
|
size[3]=size[3]-8
|
||||||
SCROLL=(size[3]-88)/21
|
SCROLL=(size[3]-88)/21
|
||||||
END=-1
|
END=-1
|
||||||
if SCROLL < len(hotkeys['Letters '][0][hotL[Llisted]]):
|
if SCROLL < len(hotkeys['Letters '][0][hotL[Llisted]]):
|
||||||
LEN=len(hotkeys['Letters '][0][hotL[Llisted]])
|
LEN=len(hotkeys['Letters '][0][hotL[Llisted]])
|
||||||
|
BeginAlign()
|
||||||
Button('/\\',up,4,size[3]+8,20,14,'Scroll up, you can use arrow or page keys too ')
|
Button('/\\',up,4,size[3]+8,20,14,'Scroll up, you can use arrow or page keys too ')
|
||||||
Button('\\/',down,4,size[3]-8,20,14,'Scroll down, you can use arrow or page keys too ')
|
Button('\\/',down,4,size[3]-8,20,14,'Scroll down, you can use arrow or page keys too ')
|
||||||
|
EndAlign()
|
||||||
if (UP+SCROLL)<len(hotkeys['Letters '][0][hotL[Llisted]]):
|
if (UP+SCROLL)<len(hotkeys['Letters '][0][hotL[Llisted]]):
|
||||||
END=(UP+SCROLL)
|
END=(UP+SCROLL)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -904,8 +904,10 @@ def draw():
|
|||||||
glRasterPos2d(60,140)
|
glRasterPos2d(60,140)
|
||||||
rangename = String("Name: ", EVENT_NONE, 5, 170, 200, 18, rangename.val, 50, "Name for Range Object")
|
rangename = String("Name: ", EVENT_NONE, 5, 170, 200, 18, rangename.val, 50, "Name for Range Object")
|
||||||
drawWidget(widmenu.val)
|
drawWidget(widmenu.val)
|
||||||
PushButton("Back", EVENT_BACK, 5, 25, 50, 18)
|
BeginAlign()
|
||||||
PushButton("Finish", EVENT_NEXT, 55, 25, 50, 18)
|
PushButton("Back", EVENT_BACK, 5, 25, 50, 18, "Choose another shape type")
|
||||||
|
PushButton("Finish", EVENT_NEXT, 55, 25, 50, 18, "Add Objects at the cursor location")
|
||||||
|
EndAlign()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,10 +107,12 @@ static PyObject *Method_String( PyObject * self, PyObject * args );
|
|||||||
static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args );
|
static PyObject *Method_GetStringWidth( PyObject * self, PyObject * args );
|
||||||
static PyObject *Method_Text( PyObject * self, PyObject * args );
|
static PyObject *Method_Text( PyObject * self, PyObject * args );
|
||||||
static PyObject *Method_PupMenu( PyObject * self, PyObject * args );
|
static PyObject *Method_PupMenu( PyObject * self, PyObject * args );
|
||||||
/* next three by Campbell: */
|
/* next Five by Campbell: */
|
||||||
static PyObject *Method_PupIntInput( PyObject * self, PyObject * args );
|
static PyObject *Method_PupIntInput( PyObject * self, PyObject * args );
|
||||||
static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args );
|
static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args );
|
||||||
static PyObject *Method_PupStrInput( PyObject * self, PyObject * args );
|
static PyObject *Method_PupStrInput( PyObject * self, PyObject * args );
|
||||||
|
static PyObject *Method_BeginAlign( PyObject * self );
|
||||||
|
static PyObject *Method_EndAlign( PyObject * self );
|
||||||
/* next by Jonathan Merritt (lancelet): */
|
/* next by Jonathan Merritt (lancelet): */
|
||||||
static PyObject *Method_Image( PyObject * self, PyObject * args);
|
static PyObject *Method_Image( PyObject * self, PyObject * args);
|
||||||
/* CLEVER NUMBUT */
|
/* CLEVER NUMBUT */
|
||||||
@@ -158,6 +160,12 @@ static char Method_Button_doc[] =
|
|||||||
[tooltip=] The button's tooltip\n\n\
|
[tooltip=] The button's tooltip\n\n\
|
||||||
This function can be called as Button() or PushButton().";
|
This function can be called as Button() or PushButton().";
|
||||||
|
|
||||||
|
static char Method_BeginAlign_doc[] =
|
||||||
|
"Buttons after this function will draw aligned (button layout only)";
|
||||||
|
|
||||||
|
static char Method_EndAlign_doc[] =
|
||||||
|
"Use after BeginAlign() to stop aligning the buttons (button layout only).";
|
||||||
|
|
||||||
static char Method_Menu_doc[] =
|
static char Method_Menu_doc[] =
|
||||||
"(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \
|
"(name, event, x, y, width, height, default, [tooltip]) - Create a new Menu \
|
||||||
button\n\n\
|
button\n\n\
|
||||||
@@ -348,6 +356,8 @@ static struct PyMethodDef Draw_methods[] = {
|
|||||||
MethodDef( Draw ),
|
MethodDef( Draw ),
|
||||||
MethodDef( Register ),
|
MethodDef( Register ),
|
||||||
{"PushButton", Method_Button, METH_VARARGS, Method_Button_doc},
|
{"PushButton", Method_Button, METH_VARARGS, Method_Button_doc},
|
||||||
|
{"BeginAlign", Method_BeginAlign, METH_NOARGS, Method_BeginAlign_doc},
|
||||||
|
{"EndAlign", Method_EndAlign, METH_NOARGS, Method_EndAlign_doc},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -856,6 +866,28 @@ static PyObject *Method_Button( PyObject * self, PyObject * args )
|
|||||||
return EXPP_incr_ret( Py_None );
|
return EXPP_incr_ret( Py_None );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static PyObject *Method_BeginAlign( PyObject * self )
|
||||||
|
{
|
||||||
|
uiBlock *block = Get_uiBlock( );
|
||||||
|
|
||||||
|
if (block)
|
||||||
|
uiBlockBeginAlign(block);
|
||||||
|
|
||||||
|
return EXPP_incr_ret( Py_None );
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *Method_EndAlign( PyObject * self )
|
||||||
|
{
|
||||||
|
uiBlock *block = Get_uiBlock( );
|
||||||
|
|
||||||
|
if (block)
|
||||||
|
uiBlockEndAlign(block);
|
||||||
|
|
||||||
|
return EXPP_incr_ret( Py_None );
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *Method_Menu( PyObject * self, PyObject * args )
|
static PyObject *Method_Menu( PyObject * self, PyObject * args )
|
||||||
{
|
{
|
||||||
uiBlock *block;
|
uiBlock *block;
|
||||||
|
|||||||
@@ -225,6 +225,16 @@ def Exit():
|
|||||||
Exit the windowing interface.
|
Exit the windowing interface.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def BeginAlign():
|
||||||
|
"""
|
||||||
|
Buttons after this function will draw aligned (button layout only).
|
||||||
|
"""
|
||||||
|
|
||||||
|
def EndAlign():
|
||||||
|
"""
|
||||||
|
Use after BeginAlign() to stop aligning the buttons (button layout only).
|
||||||
|
"""
|
||||||
|
|
||||||
def Register(draw = None, event = None, button = None):
|
def Register(draw = None, event = None, button = None):
|
||||||
"""
|
"""
|
||||||
Register callbacks for windowing.
|
Register callbacks for windowing.
|
||||||
|
|||||||
Reference in New Issue
Block a user