Package mrv :: Package maya :: Package ui :: Module layout
[hide private]
[frames] | no frames]

Source Code for Module mrv.maya.ui.layout

  1  # -*- coding: utf-8 -*- 
  2  """ 
  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 
  5  """ 
  6  __docformat__ = "restructuredtext" 
  7  import base as uibase 
  8  import maya.cmds as cmds 
  9  import mrv.maya.util as mutil 
 10  import util as uiutil 
 11   
 12   
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 16 """ 17 _properties_ = ( "nch", "numberOfChildren") 18
19 - def __init__( self, *args, **kwargs ):
20 """Initialize the layout""" 21 super( Layout, self ).__init__( *args, **kwargs )
22
23 - def __getitem__( self, key ):
24 """Implemented by `UIContainerBase`""" 25 return uiutil.UIContainerBase.__getitem__( self, key )
26
27 - def children( self ):
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 ] )
32
33 - def setParentActive( self ):
34 """Set the parent ( layout ) of this layout active - newly created items 35 will be children of the parent layout 36 37 :return: self 38 :note: can safely be called several times """ 39 cmds.setParent(self._parentString()) 40 return self
41 42 #{ Properties 43 p_ca = property(children) 44 p_childArray = p_ca
45 #} End Properties 46 47
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" ) 54
55 - class FormConstraint( object ):
56 """ defines the way a child is constrained, possibly to other children 57 58 :todo: proper constraint system, but could be complicated to make it really easy to use"""
59
60 - def setup( self, **kwargs ):
61 """Apply the given setup to the form layout, specified using kwargs 62 63 :param kwargs: arguments you would set use to setup the form layout""" 64 self.__melcmd__( self, e=1, **kwargs )
65 66
67 -class FrameLayout( Layout ):
68 """Simple wrapper for a frame layout""" 69 _properties_ = ( "bw", "borderVisible", 70 "bs", "borderStyle", 71 "cl", "collapse", 72 "cll", "collapsable", 73 "l", "label", 74 "lw", "labelWidth", 75 "lv", "labelVisible", 76 "la", "labelAlign", 77 "li", "labelIndent", 78 "fn", "font", 79 "mw", "marginWidth", 80 "mh", "marginHeight" ) 81 82 _events_ = ( "cc", "collapseCommand", 83 "ec", "expandCommand", 84 "pcc", "preCollapseCommand", 85 "pec", "preExpandCommand" )
86 87
88 -class RowLayout( Layout ):
89 """Wrapper for row column layout""" 90 _properties_ = [ "columnWidth", "cw", 91 "columnAttach", "cat", 92 "rowAttach", "rat", 93 "columnAlign", "cal", 94 "adjustableColumn", "adj", 95 "numberOfColumns", "nc" ] 96 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 ) )
101 102
103 -class ColumnLayoutBase( Layout ):
104 _properties_ = ( "columnAlign", "cal", 105 "columnAttach", "cat", 106 "columnOffset", "co" , 107 "columnWidth", "cw", 108 "rowSpacing", "rs" )
109
110 -class RowColumnLayout( ColumnLayoutBase ):
111 """Wrapper for row column layout""" 112 _properties_ = ( "numberOfColumns", "nc", 113 "numberOfRows", "nr", 114 "rowHeight", "rh", 115 "rowOffset", "ro", 116 "rowSpacing", "rs" )
117 118
119 -class ColumnLayout( ColumnLayoutBase ):
120 """Wrapper class for a simple column layout""" 121 122 _properties_ = ( "adjustableColumn", "adj" )
123
124 -class ScrollLayout( Layout ):
125 """Wrapper for a scroll layout""" 126 _properties_ = ( "scrollAreaWIdth", "saw", 127 "scrollAreaHeight", "sah", 128 "scrollAreaValue", "sav", 129 "minChildWidth", "mcw", 130 "scrollPage", "sp", 131 "scrollByPixel", "sbp" ) 132 133 _event_ = ( "resizeCommand", "rc" )
134
135 -class TabLayout( Layout ):
136 """Simple wrapper for a tab layout""" 137 _properties_ = ( "tv", "tabsVisible", 138 "st", "selectTab", 139 "sti", "selectTabIndex", 140 "tl", "tabLabel", 141 "tli", "tabLabelIndex", 142 "scr", "scrollable", 143 "hst", "horizontalScrollBarThickness", 144 "vst", "verticalScrollBarThickness", 145 "imw", "innerMarginWidth", 146 "imh", "innerMarginHeight", 147 "i", "image", 148 "iv", "imageVisible", 149 "cr", "childResizable", 150 "mcw", "minChildWidth", 151 "mt", "moveTab" ) 152 153 _events_ = ( "cc", "changeCommand", 154 "sc", "selectCommand", 155 "psc", "preSelectCommand", 156 "dcc", "doubleClickCommand" )
157
158 -class PaneLayout(Layout):
159 """Simple wrapper for a pane layout""" 160 _properties_ = ( 161 "cn", "configuration", 162 "sp", "setPane", 163 "ap", "activePane", 164 "api", "activePaneIndex", 165 "aft", "activeFrameThickness", 166 "st", "separatorThickness", 167 "ps", "paneSize", 168 "p1", "p2", "p3", "p4", "pane1", "pane2", "pane3", "pane4", 169 "pup", "paneUnderPointer", 170 "nvp", "numberOfVisiblePanes", 171 # maya >= 2011 172 "swp", "staticWidthPane", 173 "shp", "staticHeightPane" 174 ) 175 _events_ = ("smc", "separatorMovedCommand")
176