def _CreateUI(self): self._dictImages = { 'CORNER': { 'LEFTTOP': ImageBox(), 'RIGHTTOP': ImageBox(), 'LEFTBOTTOM': ImageBox(), 'RIGHTBOTTOM': ImageBox() }, 'BAR': { 'LEFT': ExpandedImageBox(), 'TOP': ExpandedImageBox(), 'RIGHT': ExpandedImageBox(), 'BOTTOM': ExpandedImageBox() }, 'FILL': ExpandedImageBox() } for imageDictKey in (['CORNER', 'BAR']): for position, image in self._dictImages[imageDictKey].iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/%s%s_%s.tga" % (self.BASE_PATH, self.FILE_NAME_POSTFIX, imageDictKey.lower(), position.lower())) image.Show() self._dictImages['FILL'].SetParent(self) self._dictImages['FILL'].AddFlag("not_pick") self._dictImages['FILL'].LoadImage( "%s/%sfill.tga" % (self.BASE_PATH, self.FILE_NAME_POSTFIX)) self._dictImages['FILL'].Show()
def AddCloseButton(self): self.__imgCloseButtonDecoration = ImageBox() self.__imgCloseButtonDecoration.SetParent(self) self.__imgCloseButtonDecoration.AddFlag("not_pick") self.__imgCloseButtonDecoration.LoadImage("%s/decoration_right.tga" % TitleBar.BASE_PATH) self.__imgCloseButtonDecoration.SetHorizontalAlign( wndMgr.HORIZONTAL_ALIGN_RIGHT) self.__imgCloseButtonDecoration.Show() self.__btnClose = SimpleButton() self.__btnClose.SetParent(self) self.__btnClose.SetUpVisual( "%s/controls/common/button/board_close_01_normal.tga" % illumina.BASE_PATH) self.__btnClose.SetOverVisual( "%s/controls/common/button/board_close_02_hover.tga" % illumina.BASE_PATH) self.__btnClose.SetDownVisual( "%s/controls/common/button/board_close_03_active.tga" % illumina.BASE_PATH) self.__btnClose.SetHorizontalAlign(wndMgr.HORIZONTAL_ALIGN_RIGHT) self.__btnClose.Show() self.UpdateGeneralUIPosition() self.UpdateTitlePosition() self.UpdateCloseButtonAndDecorationPosition()
def __CreateUI(self): self.__dictImages = { 'LEFT' : ImageBox(), 'CENTER' : ExpandedImageBox(), 'RIGHT' : ImageBox() } for position, image in self.__dictImages.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/bg_%s.tga" % (self.BASE_PATH, position.lower())) image.Show() self.__imgRange = ExpandedImageBox() self.__imgRange.SetParent(self) self.__imgRange.SetPosition(4, self.GetHeight() / 2 - 1) self.__imgRange.LoadImage("%s/bg_range.tga" % Slider.BASE_PATH) self.__imgRange.Hide() self.__btnSlider = SimpleDragButton() self.__btnSlider.SetParent(self) self.__btnSlider.AddFlag("movable") self.__btnSlider.AddFlag("restrict_y") self.__btnSlider.SetPosition(0, 0) self.__btnSlider.SetUpVisual("%s/btn_01_normal.tga" % Slider.BASE_PATH) self.__btnSlider.SetOverVisual("%s/btn_02_hover.tga" % Slider.BASE_PATH) self.__btnSlider.SetDownVisual("%s/btn_01_normal.tga" % Slider.BASE_PATH) self.__btnSlider.Show() self.__dictImages['LEFT'].SetPosition(0, 6) self.__dictImages['CENTER'].SetPosition(3, 6) self.__btnSlider.AddEventListener(SimpleDragButton.Events.ON_MOVE, self.__OnMove)
def __init__(self,screen,score=Score()): self.pos=(10,5) self.dx=60 self.dy=15 self.dyline=5 self.dxline=5 self.size=(2*self.dx+self.dxline,5*self.dy+self.dyline+15) self.fgcolor=COLORS['yellow'] self.font=FONTS[14] ImageBox.__init__(self,self.pos,self.size,COLORS['tabledark'],self.fgcolor,self.font) self.draw(screen,score)
def __CreateUI(self): self.__dictImages = { 'LEFT': { _ButtonState.NORMAL: ImageBox(), _ButtonState.HOVER: ImageBox(), _ButtonState.ACTIVE: ImageBox(), _ButtonState.DISABLED: ImageBox() }, 'CENTER': { _ButtonState.NORMAL: ExpandedImageBox(), _ButtonState.HOVER: ExpandedImageBox(), _ButtonState.ACTIVE: ExpandedImageBox(), _ButtonState.DISABLED: ExpandedImageBox() }, 'RIGHT': { _ButtonState.NORMAL: ImageBox(), _ButtonState.HOVER: ImageBox(), _ButtonState.ACTIVE: ImageBox(), _ButtonState.DISABLED: ImageBox() } } self.__txtText = None for position, imageDictByState in self.__dictImages.iteritems(): for state, image in imageDictByState.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage(self.IMAGES[position][state]) image.Hide()
def _CreateUI(self): if self.__hasShadow: self.__CreateShadow() else: self.__wndShadow = None self.__imgDecoration = ImageBox() self.__imgDecoration.SetParent(self) self.__imgDecoration.LoadImage("%s/decoration_leftbottom.tga" % self.BASE_PATH) self.__imgDecoration.SetVerticalAlign(wndMgr.VERTICAL_ALIGN_BOTTOM) self.__imgDecoration.Show() _BoardBase._CreateUI(self) self.__wndTitleBar = None
def __CreateUI(self): self.__dictImages = { 'LEFT' : ImageBox(), 'CENTER' : ExpandedImageBox(), 'RIGHT' : ImageBox() } for position, image in self.__dictImages.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/%s_%s.tga" % (self.BASE_PATH, self.FILE_NAME_PREFIX, position.lower())) image.Show() self.__dictImages['CENTER'].SetPosition(self.__dictImages['LEFT'].GetWidth(), 0) self.__txtInput = None self.__textAlign = _BaseInput.TextAlign.LEFT
def __CreateUI(self): self.__dictImages = { 'LEFT': ImageBox(), 'CENTER': ExpandedImageBox(), 'RIGHT': ImageBox() } for position, image in self.__dictImages.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/bg_%s.tga" % (self.BASE_PATH, position.lower())) image.Show() self.__imgRange = ExpandedImageBox() self.__imgRange.SetParent(self) self.__imgRange.AddFlag("not_pick") self.__imgRange.LoadImage("%s/bg_range.tga" % self.BASE_PATH) self.__imgRange.Show() self.__liRangeSlider = [SimpleDragButton() for obj in xrange(2)] for rangeSlider in self.__liRangeSlider: rangeSlider.SetParent(self) rangeSlider.AddFlag("movable") rangeSlider.AddFlag("restrict_y") rangeSlider.SetPosition(0, 0) rangeSlider.SetUpVisual("%s/btn_01_normal.tga" % RangeSlider.BASE_PATH) rangeSlider.SetOverVisual("%s/btn_02_hover.tga" % RangeSlider.BASE_PATH) rangeSlider.SetDownVisual("%s/btn_01_normal.tga" % RangeSlider.BASE_PATH) rangeSlider.Show() self.__curValues.append(0) self.__rangeSliderWidth = rangeSlider.GetWidth() self.__liRangeSlider[0].AddEventListener( SimpleDragButton.Events.ON_MOVE, lambda: self.__OnMove(self.__liRangeSlider[0], 0)) self.__liRangeSlider[1].AddEventListener( SimpleDragButton.Events.ON_MOVE, lambda: self.__OnMove(self.__liRangeSlider[1], 1)) self.__dictImages['LEFT'].SetPosition(0, 6) self.__dictImages['CENTER'].SetPosition(3, 6)
def __CreateUI(self): self.__dictImages = { 'LEFT': ImageBox(), 'CENTER': ExpandedImageBox(), 'RIGHT': ImageBox() } self.__imgCloseButtonDecoration = None self.__btnClose = None self.__txtTitle = None for image in self.__dictImages.itervalues(): image.SetParent(self) image.AddFlag("not_pick") image.Show() self.__dictImages['LEFT'].LoadImage("%s/left.tga" % TitleBar.BASE_PATH) self.__dictImages['CENTER'].LoadImage("%s/center.tga" % TitleBar.BASE_PATH) self.__dictImages['RIGHT'].LoadImage("%s/right.tga" % TitleBar.BASE_PATH)
def __CreateUI(self): self.__dictImages = { 'LEFT': ImageBox(), 'CENTER': ExpandedImageBox(), 'RIGHT': ImageBox() } for image in self.__dictImages.itervalues(): image.SetParent(self) image.Show() self.__dictImages['LEFT'].LoadImage("%s/horizontal_left.tga" % HorizontalSeparator.BASE_PATH) self.__dictImages['CENTER'].LoadImage("%s/horizontal_center.tga" % HorizontalSeparator.BASE_PATH) self.__dictImages['RIGHT'].LoadImage("%s/horizontal_right.tga" % HorizontalSeparator.BASE_PATH) self.__dictImages['LEFT'].SetPosition(0, 0) self.__dictImages['CENTER'].SetPosition( HorizontalSeparator.WIDTHS['LEFT'], 0)
def __CreateUI(self): self.__dictImages = { 'TOP': ImageBox(), 'CENTER': ExpandedImageBox(), 'BOTTOM': ImageBox() } for image in self.__dictImages.itervalues(): image.SetParent(self) image.Show() self.__dictImages['TOP'].LoadImage("%s/vertical_top.tga" % VerticalSeparator.BASE_PATH) self.__dictImages['CENTER'].LoadImage("%s/vertical_center.tga" % VerticalSeparator.BASE_PATH) self.__dictImages['BOTTOM'].LoadImage("%s/vertical_bottom.tga" % VerticalSeparator.BASE_PATH) self.__dictImages['TOP'].SetPosition(0, 0) self.__dictImages['CENTER'].SetPosition( 0, VerticalSeparator.HEIGHTS['TOP'])
def __CreateUI(self): self.__dictImages = { 'LEFT' : { ExpanderState.EXPANDED : ImageBox(), ExpanderState.COLLAPSED : ImageBox() }, 'CENTER' : { ExpanderState.EXPANDED : ExpandedImageBox(), ExpanderState.COLLAPSED : ExpandedImageBox() }, 'RIGHT' : { ExpanderState.EXPANDED : ImageBox(), ExpanderState.COLLAPSED : ImageBox() } } self.__txtText = None for position, imageDictByState in self.__dictImages.iteritems(): for state, image in imageDictByState.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/%s" % (Expander.BASE_PATH, Expander.IMAGES[position][state])) image.Hide() self.__imgArrowBackground = ImageBox() self.__imgArrowBackground.SetParent(self) self.__imgArrowBackground.AddFlag("not_pick") self.__imgArrowBackground.SetPosition(0, 0) self.__imgArrowBackground.LoadImage("%s/arrow_bg.tga" % Expander.BASE_PATH) self.__imgArrowBackground.Show() self.__imgArrow = ExpandedImageBox() self.__imgArrow.SetParent(self.__imgArrowBackground) self.__imgArrow.AddFlag("not_pick") self.__imgArrow.SetPosition(0, 0) self.__imgArrow.LoadImage("%s/arrow.tga" % Expander.BASE_PATH) self.__imgArrow.SetHorizontalAlign(wndMgr.HORIZONTAL_ALIGN_CENTER) self.__imgArrow.SetVerticalAlign(wndMgr.VERTICAL_ALIGN_CENTER) self.__imgArrow.Show()
def __del__(self): ImageBox.__del__(self)
class Board(_BoardBase): class _Shadow(_BoardBase): BASE_PATH = "%s/controls/common/board/" % illumina.BASE_PATH FILE_NAME_POSTFIX = "shadow_" DIMENSIONS = { 'CORNER': { 'WIDTH': 73, 'HEIGHT': 73 }, 'BAR_VERTICAL': { 'WIDTH': 1, 'HEIGHT': 73 }, 'BAR_HORIZONTAL': { 'WIDTH': 73, 'HEIGHT': 1 }, 'FILL': { 'WIDTH': 1, 'HEIGHT': 1 } } MIN_WIDTH = 55 * 2 MIN_HEIGHT = 55 * 2 def SetOpacity(self, opacity): for imageDictKey in (['CORNER', 'BAR']): for position, image in self._dictImages[ imageDictKey].iteritems(): image.SetDiffuseColor(1.0, 1.0, 1.0, opacity) self._dictImages['FILL'].SetDiffuseColor(1.0, 1.0, 1.0, opacity) BASE_PATH = "%s/controls/common/board/" % illumina.BASE_PATH DIMENSIONS = { 'CORNER': { 'WIDTH': 55, 'HEIGHT': 55 }, 'BAR_VERTICAL': { 'WIDTH': 128, 'HEIGHT': 55 }, 'BAR_HORIZONTAL': { 'WIDTH': 55, 'HEIGHT': 128 }, 'FILL': { 'WIDTH': 128, 'HEIGHT': 128 } } MIN_WIDTH = 55 * 2 MIN_HEIGHT = 55 * 2 def __init__(self, shadowSize=-1, layer="UI"): self.__hasShadow = shadowSize != -1 self.__shadowSize = shadowSize _BoardBase.__init__(self, layer) def __del__(self): _BoardBase.__del__(self) def _CreateUI(self): if self.__hasShadow: self.__CreateShadow() else: self.__wndShadow = None self.__imgDecoration = ImageBox() self.__imgDecoration.SetParent(self) self.__imgDecoration.LoadImage("%s/decoration_leftbottom.tga" % self.BASE_PATH) self.__imgDecoration.SetVerticalAlign(wndMgr.VERTICAL_ALIGN_BOTTOM) self.__imgDecoration.Show() _BoardBase._CreateUI(self) self.__wndTitleBar = None def SetSize(self, width, height): _BoardBase.SetSize(self, width, height) self.__imgDecoration.SetPosition(-5, 52) self.UpdateTitleBar() if self.__hasShadow: self.UpdateShadow() ## TitleBar def AddTitleBar(self): self.__wndTitleBar = TitleBar() self.__wndTitleBar.SetParent(self) self.__wndTitleBar.SetPosition(9, 11) self.__wndTitleBar.Show() self.UpdateTitleBar() def GetTitleBar(self): return self.__wndTitleBar def UpdateTitleBar(self): if not self.__wndTitleBar: return self.__wndTitleBar.SetWidth(self.GetWidth() - 18) ## Shadow def __CreateShadow(self): self.__wndShadow = Board._Shadow() self.__wndShadow.SetParent(self) self.__wndShadow.SetPosition(-self.__shadowSize, -self.__shadowSize) self.__wndShadow.Show() self.__wndShadow.SetOpacity(0.0) def UpdateShadow(self): self.__wndShadow.SetSize(self.GetWidth() + self.__shadowSize * 2, self.GetHeight() + self.__shadowSize * 2) def GetShadow(self): return self.__wndShadow
class TitleBar(Window): BASE_PATH = "%s/controls/common/titlebar/" % illumina.BASE_PATH HEIGHT = 28 MIN_WIDTH = 70 def __init__(self, layer="UI"): Window.__init__(self, layer) self.__CreateUI() self.SetWidth(0) def __del__(self): Window.__del__(self) def __CreateUI(self): self.__dictImages = { 'LEFT': ImageBox(), 'CENTER': ExpandedImageBox(), 'RIGHT': ImageBox() } self.__imgCloseButtonDecoration = None self.__btnClose = None self.__txtTitle = None for image in self.__dictImages.itervalues(): image.SetParent(self) image.AddFlag("not_pick") image.Show() self.__dictImages['LEFT'].LoadImage("%s/left.tga" % TitleBar.BASE_PATH) self.__dictImages['CENTER'].LoadImage("%s/center.tga" % TitleBar.BASE_PATH) self.__dictImages['RIGHT'].LoadImage("%s/right.tga" % TitleBar.BASE_PATH) def UpdateGeneralUIPosition(self): self.__dictImages['LEFT'].SetPosition( 0, TitleBar.HEIGHT - self.__dictImages['LEFT'].GetHeight()) self.__dictImages['CENTER'].SetPosition( self.__dictImages['LEFT'].GetWidth(), TitleBar.HEIGHT - self.__dictImages['CENTER'].GetHeight()) self.__dictImages['RIGHT'].SetPosition( self.GetWidth() - self.__dictImages['RIGHT'].GetWidth(), TitleBar.HEIGHT - self.__dictImages['RIGHT'].GetHeight()) self.__dictImages['CENTER'].SetScale( float(self.GetWidth() - (self.__dictImages['LEFT'].GetWidth() + self.__dictImages['RIGHT'].GetWidth())) / float(self.__dictImages['CENTER'].GetWidth()), 1.0) def SetWidth(self, width): width = max(TitleBar.MIN_WIDTH, width) self.SetSize(width, TitleBar.HEIGHT) self.UpdateGeneralUIPosition() self.UpdateTitlePosition() self.UpdateCloseButtonAndDecorationPosition() ## TITLE def SetTitle(self, title): if not self.__txtTitle: self.__txtTitle = TextLine() self.__txtTitle.SetParent(self) self.__txtTitle.SetPackedFontColor(0xFFE6D0A2) self.__txtTitle.SetHorizontalAlignCenter() self.__txtTitle.SetVerticalAlignBottom() self.__txtTitle.Show() self.__txtTitle.SetText(title) self.UpdateTitlePosition() def UpdateTitlePosition(self): if not self.__txtTitle: return self.__txtTitle.SetPosition(self.GetWidth() / 2, 17) ## CLOSE BUTTON def AddCloseButton(self): self.__imgCloseButtonDecoration = ImageBox() self.__imgCloseButtonDecoration.SetParent(self) self.__imgCloseButtonDecoration.AddFlag("not_pick") self.__imgCloseButtonDecoration.LoadImage("%s/decoration_right.tga" % TitleBar.BASE_PATH) self.__imgCloseButtonDecoration.SetHorizontalAlign( wndMgr.HORIZONTAL_ALIGN_RIGHT) self.__imgCloseButtonDecoration.Show() self.__btnClose = SimpleButton() self.__btnClose.SetParent(self) self.__btnClose.SetUpVisual( "%s/controls/common/button/board_close_01_normal.tga" % illumina.BASE_PATH) self.__btnClose.SetOverVisual( "%s/controls/common/button/board_close_02_hover.tga" % illumina.BASE_PATH) self.__btnClose.SetDownVisual( "%s/controls/common/button/board_close_03_active.tga" % illumina.BASE_PATH) self.__btnClose.SetHorizontalAlign(wndMgr.HORIZONTAL_ALIGN_RIGHT) self.__btnClose.Show() self.UpdateGeneralUIPosition() self.UpdateTitlePosition() self.UpdateCloseButtonAndDecorationPosition() def GetCloseButton(self): return self.__btnClose def HasCloseButton(self): return (self.__imgCloseButtonDecoration and self.__btnClose) def UpdateCloseButtonAndDecorationPosition(self): if not self.HasCloseButton(): return self.__imgCloseButtonDecoration.SetPosition( self.__imgCloseButtonDecoration.GetWidth() - 13, -18) self.__btnClose.SetPosition(self.__btnClose.GetWidth() - 1, 0)
def __init__(self, layer="UI"): ImageBox.__init__(self, layer)
class Expander(Window): BASE_PATH = "%s/controls/common/expander/" % illumina.BASE_PATH IMAGES = { 'LEFT' : { ExpanderState.COLLAPSED : "left_01_normal.tga", ExpanderState.EXPANDED : "left_02_hover.tga" }, 'CENTER' : { ExpanderState.COLLAPSED : "center_01_normal.tga", ExpanderState.EXPANDED : "center_02_hover.tga" }, 'RIGHT' : { ExpanderState.COLLAPSED : "right_01_normal.tga", ExpanderState.EXPANDED : "right_02_hover.tga" } } MIN_WIDTH = 30 HEIGHT = 30 def __init__(self, layer = "UI"): Window.__init__(self, layer) self.__state = ExpanderState.COLLAPSED self.__arrowRotation = 0.0 self.__CreateUI() self.__SetEventListeners() self.SetWidth(0) self.SetState(ExpanderState.COLLAPSED) def __del__(self): Window.__del__(self) def __CreateUI(self): self.__dictImages = { 'LEFT' : { ExpanderState.EXPANDED : ImageBox(), ExpanderState.COLLAPSED : ImageBox() }, 'CENTER' : { ExpanderState.EXPANDED : ExpandedImageBox(), ExpanderState.COLLAPSED : ExpandedImageBox() }, 'RIGHT' : { ExpanderState.EXPANDED : ImageBox(), ExpanderState.COLLAPSED : ImageBox() } } self.__txtText = None for position, imageDictByState in self.__dictImages.iteritems(): for state, image in imageDictByState.iteritems(): image.SetParent(self) image.AddFlag("not_pick") image.LoadImage("%s/%s" % (Expander.BASE_PATH, Expander.IMAGES[position][state])) image.Hide() self.__imgArrowBackground = ImageBox() self.__imgArrowBackground.SetParent(self) self.__imgArrowBackground.AddFlag("not_pick") self.__imgArrowBackground.SetPosition(0, 0) self.__imgArrowBackground.LoadImage("%s/arrow_bg.tga" % Expander.BASE_PATH) self.__imgArrowBackground.Show() self.__imgArrow = ExpandedImageBox() self.__imgArrow.SetParent(self.__imgArrowBackground) self.__imgArrow.AddFlag("not_pick") self.__imgArrow.SetPosition(0, 0) self.__imgArrow.LoadImage("%s/arrow.tga" % Expander.BASE_PATH) self.__imgArrow.SetHorizontalAlign(wndMgr.HORIZONTAL_ALIGN_CENTER) self.__imgArrow.SetVerticalAlign(wndMgr.VERTICAL_ALIGN_CENTER) self.__imgArrow.Show() def __SetEventListeners(self): self.AddEventListener(Expander.Events.ON_MOUSE_OVER_IN, lambda : self.__RefreshButton(ExpanderState.EXPANDED)) self.AddEventListener(Expander.Events.ON_MOUSE_OVER_OUT, lambda : self.__RefreshButton(ExpanderState.COLLAPSED)) self.AddEventListener(Expander.Events.ON_MOUSE_LEFT_BUTTON_UP, lambda : self.SetState(ExpanderState.EXPANDED if self.GetState() == ExpanderState.COLLAPSED else ExpanderState.COLLAPSED)) def __RefreshButton(self, expandingState): for position, imageDictByState in self.__dictImages.iteritems(): for state, image in imageDictByState.iteritems(): if state != expandingState: image.Hide() else: image.Show() if self.GetState() == ExpanderState.COLLAPSED: self.__imgArrow.SetRotation(self.__arrowRotation) else: self.__imgArrow.SetRotation(180.0 + self.__arrowRotation) def GetState(self): return self.__state def SetState(self, state): self.__state = state self.__RefreshButton(self.__state) def SetWidth(self, width): width = max(Expander.MIN_WIDTH, width) self.SetSize(width, Expander.HEIGHT) for image in self.__dictImages['CENTER'].itervalues(): image.SetPosition(5, 0) image.SetScale(float(width - 10), 1.0) for image in self.__dictImages['RIGHT'].itervalues(): image.SetPosition(width - 5, 0) self.UpdateText() def SetArrowRotation(self, rotation): self.__arrowRotation = rotation self.__imgArrow.SetRotation(rotation) ## Text def SetText(self, text): if not self.__txtText: self.__txtText = TextLine() self.__txtText.SetParent(self) self.__txtText.AddFlag("not_pick") self.__txtText.SetVerticalAlignCenter() self.__txtText.SetPackedFontColor(0xFFE6D0A2) self.__txtText.Show() self.UpdateText() self.__txtText.SetText(text) def GetText(self): if not self.__txtText: return "" return self.__txtText.GetText() def UpdateText(self): if not self.__txtText: return self.__txtText.SetPosition(35, self.GetHeight() / 2 - 2) ################################################## ## EVENTS class Events(Window.Events): ON_EXPAND = EventEnum() ON_COLLAPSE = EventEnum()
def __init__(self, layer = "UI"): ImageBox.__init__(self, layer)