3
Contains the most important mel-layouts wrapped into easy to use python classes
4
These are specialized and thus more powerful than the default wraps
6
__docformat__ = "restructuredtext"
8
import maya.cmds as cmds
9
import mrv.maya.util as mutil
13
class Layout( uibase.SizedControl, uiutil.UIContainerBase ):
14
""" Structural base for all Layouts allowing general queries and name handling
15
Layouts may track their children
17
_properties_ = ( "nch", "numberOfChildren")
19
def __init__( self, *args, **kwargs ):
20
"""Initialize the layout"""
21
super( Layout, self ).__init__( *args, **kwargs )
23
def __getitem__( self, key ):
24
"""Implemented by `UIContainerBase`"""
25
return uiutil.UIContainerBase.__getitem__( self, key )
28
""" :return: children of this layout """
29
childnames = mutil.noneToList( cmds.layout( self, q=1, ca=1 ) )
30
# assure we have long names to ensure uniqueness
31
return uibase.wrapUI( [ "%s|%s" % ( self, c ) for c in childnames ] )
33
def setParentActive( self ):
34
"""Set the parent ( layout ) of this layout active - newly created items
35
will be children of the parent layout
38
:note: can safely be called several times """
39
cmds.setParent(self._parentString())
43
p_ca = property(children)
48
class FormLayout( Layout ):
49
""" Wrapper class for maya form layout """
50
# tuple with side strings - to quickly define your attachments, assign it to letters
51
# like : t,b,l,r = kSides
52
# and use the letters accordingly to save space and make the layout easier to read
53
kSides = ( "top", "bottom", "left", "right" )
55
class FormConstraint( object ):
56
""" defines the way a child is constrained, possibly to other children
58
:todo: proper constraint system, but could be complicated to make it really easy to use"""
60
def setup( self, **kwargs ):
61
"""Apply the given setup to the form layout, specified using kwargs
63
:param kwargs: arguments you would set use to setup the form layout"""
64
self.__melcmd__( self, e=1, **kwargs )
67
class FrameLayout( Layout ):
68
"""Simple wrapper for a frame layout"""
69
_properties_ = ( "bw", "borderVisible",
80
"mh", "marginHeight" )
82
_events_ = ( "cc", "collapseCommand",
83
"ec", "expandCommand",
84
"pcc", "preCollapseCommand",
85
"pec", "preExpandCommand" )
88
class RowLayout( Layout ):
89
"""Wrapper for row column layout"""
90
_properties_ = [ "columnWidth", "cw",
91
"columnAttach", "cat",
94
"adjustableColumn", "adj",
95
"numberOfColumns", "nc" ]
97
for flag in ( "columnWidth", "cw", "columnAttach", "ct", "columnOffset",
98
"co", "columnAlign", "cl", "adjustableColumn", "ad" ):
99
for i in range( 1, 7 ):
100
_properties_.append( flag + str( i ) )
103
class ColumnLayoutBase( Layout ):
104
_properties_ = ( "columnAlign", "cal",
105
"columnAttach", "cat",
106
"columnOffset", "co" ,
110
class RowColumnLayout( ColumnLayoutBase ):
111
"""Wrapper for row column layout"""
112
_properties_ = ( "numberOfColumns", "nc",
113
"numberOfRows", "nr",
119
class ColumnLayout( ColumnLayoutBase ):
120
"""Wrapper class for a simple column layout"""
122
_properties_ = ( "adjustableColumn", "adj" )
124
class ScrollLayout( Layout ):
125
"""Wrapper for a scroll layout"""
126
_properties_ = ( "scrollAreaWIdth", "saw",
127
"scrollAreaHeight", "sah",
128
"scrollAreaValue", "sav",
129
"minChildWidth", "mcw",
131
"scrollByPixel", "sbp" )
133
_event_ = ( "resizeCommand", "rc" )
135
class TabLayout( Layout ):
136
"""Simple wrapper for a tab layout"""
137
_properties_ = ( "tv", "tabsVisible",
139
"sti", "selectTabIndex",
141
"tli", "tabLabelIndex",
143
"hst", "horizontalScrollBarThickness",
144
"vst", "verticalScrollBarThickness",
145
"imw", "innerMarginWidth",
146
"imh", "innerMarginHeight",
148
"iv", "imageVisible",
149
"cr", "childResizable",
150
"mcw", "minChildWidth",
153
_events_ = ( "cc", "changeCommand",
154
"sc", "selectCommand",
155
"psc", "preSelectCommand",
156
"dcc", "doubleClickCommand" )
158
class PaneLayout(Layout):
159
"""Simple wrapper for a pane layout"""
161
"cn", "configuration",
164
"api", "activePaneIndex",
165
"aft", "activeFrameThickness",
166
"st", "separatorThickness",
168
"p1", "p2", "p3", "p4", "pane1", "pane2", "pane3", "pane4",
169
"pup", "paneUnderPointer",
170
"nvp", "numberOfVisiblePanes",
172
"swp", "staticWidthPane",
173
"shp", "staticHeightPane"
175
_events_ = ("smc", "separatorMovedCommand")