Пример #1
0
 def Prepare_SelectedText_(self):
     self.sr.selected = LabelUnderlay(text='',
                                      parent=self.sr.textclipper,
                                      name='value',
                                      align=uiconst.CENTERLEFT,
                                      left=3,
                                      state=uiconst.UI_DISABLED)
     self.glowLabel = LabelUnderlay(parent=self.sr.textclipper,
                                    state=uiconst.UI_DISABLED,
                                    align=uiconst.CENTERLEFT,
                                    left=3,
                                    opacity=0.0)
     self.glowLabel.renderObject.spriteEffect = trinity.TR2_SFX_BLUR
Пример #2
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.controller = attributes.controller
     self.btnID = attributes.Get('btnID', None)
     self.panel = attributes.Get('panel', None)
     self.colorSelected = attributes.Get('colorSelected',
                                         self.default_colorSelected)
     label = attributes.Get('label', None)
     iconPath = attributes.Get('iconPath', None)
     iconSize = attributes.Get('iconSize', None)
     iconSize = iconSize or self.default_iconSize
     self.hint = attributes.Get('hint', None)
     self.isSelected = False
     self.isDisabled = attributes.Get('isDisabled', False)
     if iconPath:
         self.icon = GlowSprite(parent=self,
                                align=uiconst.CENTER,
                                state=uiconst.UI_DISABLED,
                                width=iconSize,
                                height=iconSize,
                                texturePath=iconPath,
                                iconOpacity=0.75,
                                color=Color.WHITE)
         self.label = None
     else:
         self.label = LabelUnderlay(text=label,
                                    parent=self,
                                    align=uiconst.CENTER,
                                    fontsize=10)
         self.icon = None
     self.selectedBG = RaisedUnderlay(bgParent=self,
                                      color=self.colorSelected,
                                      isGlowEdgeRotated=True)
     if self.isDisabled:
         self.SetDisabled()
Пример #3
0
 def Prepare_(self):
     self.sr.label = LabelUnderlay(
         parent=self,
         align=uiconst.CENTER,
         state=uiconst.UI_DISABLED,
         colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
         opacity=1.0,
         fontsize=10)
     self.glowLabel = LabelUnderlay(name='glowLabel',
                                    parent=self,
                                    align=uiconst.CENTER,
                                    state=uiconst.UI_DISABLED,
                                    opacity=0.0,
                                    color=self.color,
                                    fontsize=10)
     self.glowLabel.renderObject.spriteEffect = trinity.TR2_SFX_BLUR
     if self.iconPath is not None:
         if self.iconSize:
             width = self.iconSize
             height = self.iconSize
         else:
             width = height = min(self.width, self.height)
         self.icon = GlowSprite(parent=self,
                                state=uiconst.UI_DISABLED,
                                align=uiconst.CENTER,
                                pos=(0, 0, width, height),
                                texturePath=self.iconPath,
                                color=self.color,
                                iconOpacity=0.75)
         self.sr.label.state = uiconst.UI_HIDDEN
         self.width = width + 4
         self.height = height + 4
     else:
         self.icon = None
     self.sr.hilite = Fill(bgParent=self,
                           color=(0.7, 0.7, 0.7, 0.5),
                           state=uiconst.UI_HIDDEN)
     self.sr.activeframe = FrameUnderlay(
         parent=self,
         name='activeline',
         state=uiconst.UI_HIDDEN,
         colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
         opacity=0.1)
     self.underlay = RaisedUnderlay(name='backgroundFrame',
                                    bgParent=self,
                                    state=uiconst.UI_DISABLED,
                                    color=self.color)
Пример #4
0
 def Prepare_SelectedText_(self):
     self.sr.selected = Label(text='',
                              fontStyle=self.fontStyle,
                              fontFamily=self.fontFamily,
                              fontPath=self.fontPath,
                              fontsize=self.fontsize,
                              parent=self.sr.textclipper,
                              name='value',
                              align=uiconst.CENTERLEFT,
                              left=6,
                              state=uiconst.UI_DISABLED,
                              color=Color.WHITE)
     self.glowLabel = LabelUnderlay(parent=self.sr.textclipper,
                                    state=uiconst.UI_HIDDEN,
                                    align=uiconst.CENTERLEFT,
                                    left=3,
                                    opacity=0.0)
Пример #5
0
 def Prepare_(self):
     self.sr.clipper = Container(parent=self,
                                 align=uiconst.TOALL,
                                 padding=(self.labelPadding, 1, 6, 1),
                                 clipChildren=True,
                                 state=uiconst.UI_PICKCHILDREN,
                                 name='labelClipper')
     self.sr.label = LabelUnderlay(
         parent=self.sr.clipper,
         fontStyle=self.fontStyle,
         fontFamily=self.fontFamily,
         fontPath=self.fontPath,
         fontsize=self.fontsize,
         letterspace=1,
         uppercase=1,
         state=uiconst.UI_DISABLED,
         align=uiconst.CENTERLEFT,
         name='tabLabel',
         colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
     self.selectedBG = TabUnderlay(name='underlay',
                                   bgParent=self,
                                   isGlowEdgeRotated=True)
Пример #6
0
 def ApplyAttributes(self, attributes):
     Container.ApplyAttributes(self, attributes)
     self.fontStyle = attributes.get('fontStyle', self.default_fontStyle)
     self.fontFamily = attributes.get('fontFamily', self.default_fontFamily)
     self.fontPath = attributes.get('fontPath', self.default_fontPath)
     self.fontsize = attributes.get('fontsize', self.default_fontsize)
     self.labelPadding = attributes.get('labelPadding',
                                        self.default_labelPadding)
     self.ignoreWndDrag = 1
     self.selecting = 0
     self.sr.icon = None
     self.sr.LoadTabCallback = None
     self.isTabStop = True
     self._detachallowed = False
     self.Prepare_()
     if self.sr.label:
         self.sr.label.Close()
     self.sr.label = LabelUnderlay(parent=self.sr.clipper,
                                   state=uiconst.UI_DISABLED,
                                   align=uiconst.CENTERLEFT,
                                   name='tabLabel',
                                   fontsize=10)
     self.isTabStop = False
Пример #7
0
 def ApplyAttributes(self, attributes):
     ButtonBase.ApplyAttributes(self, attributes)
     if self.btnData.labelAbbrev:
         label = LabelUnderlay(parent=self.iconTransform, align=uiconst.CENTERBOTTOM, text=self.btnData.labelAbbrev, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, fontsize=13, opacity=1.0, top=6, idx=0, bold=True)
Пример #8
0
class Button(ButtonCore):
    """
    Standard UI button
    """
    __guid__ = 'uicontrols.Button'
    default_alwaysLite = False
    default_iconSize = 32
    default_icon = None
    default_color = None

    def ApplyAttributes(self, attributes):
        self.color = attributes.get('color', self.default_color)
        self.iconPath = attributes.get('icon', self.default_icon)
        self.iconSize = attributes.get('iconSize', self.default_iconSize)
        args = attributes.get('args', None)
        ButtonCore.ApplyAttributes(self, attributes)
        if args == 'self':
            self.args = self

    def Prepare_(self):
        self.sr.label = LabelUnderlay(
            parent=self,
            align=uiconst.CENTER,
            state=uiconst.UI_DISABLED,
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
            opacity=1.0,
            fontsize=10)
        self.glowLabel = LabelUnderlay(name='glowLabel',
                                       parent=self,
                                       align=uiconst.CENTER,
                                       state=uiconst.UI_DISABLED,
                                       opacity=0.0,
                                       color=self.color,
                                       fontsize=10)
        self.glowLabel.renderObject.spriteEffect = trinity.TR2_SFX_BLUR
        if self.iconPath is not None:
            if self.iconSize:
                width = self.iconSize
                height = self.iconSize
            else:
                width = height = min(self.width, self.height)
            self.icon = GlowSprite(parent=self,
                                   state=uiconst.UI_DISABLED,
                                   align=uiconst.CENTER,
                                   pos=(0, 0, width, height),
                                   texturePath=self.iconPath,
                                   color=self.color,
                                   iconOpacity=0.75)
            self.sr.label.state = uiconst.UI_HIDDEN
            self.width = width + 4
            self.height = height + 4
        else:
            self.icon = None
        self.sr.hilite = Fill(bgParent=self,
                              color=(0.7, 0.7, 0.7, 0.5),
                              state=uiconst.UI_HIDDEN)
        self.sr.activeframe = FrameUnderlay(
            parent=self,
            name='activeline',
            state=uiconst.UI_HIDDEN,
            colorType=uiconst.COLORTYPE_UIHILIGHTGLOW,
            opacity=0.1)
        self.underlay = RaisedUnderlay(name='backgroundFrame',
                                       bgParent=self,
                                       state=uiconst.UI_DISABLED,
                                       color=self.color)

    def Update_Size_(self):
        if self.iconPath is None:
            self.width = min(
                256, self.fixedwidth or max(40, self.sr.label.width + 20))
            self.height = self.fixedheight or max(
                18, min(32, self.sr.label.textheight + 4))

    def SetLabel_(self, label):
        if not self or self.destroyed:
            return
        text = self.text = label
        self.sr.label.text = text
        self.glowLabel.text = text
        self.Update_Size_()

    def OnSetFocus(self, *args):
        if self.disabled:
            return
        if self and not self.destroyed and self.parent and self.parent.name == 'inlines':
            if self.parent.parent and self.parent.parent.sr.node:
                browser = uiutil.GetBrowser(self)
                if browser:
                    uthread.new(browser.ShowObject, self)
        if self and not self.destroyed and self.sr and self.sr.activeframe:
            self.sr.activeframe.state = uiconst.UI_DISABLED
        btns = self.GetDefaultBtnsInSameWnd()
        if btns:
            self.SetWndDefaultFrameState(btns, 0)

    def OnMouseEnter(self, *args):
        self.Blink(False)
        if not self.disabled:
            self.underlay.OnMouseEnter()
            if self.icon:
                self.icon.OnMouseEnter()
            else:
                uicore.animations.FadeTo(self.glowLabel,
                                         self.glowLabel.opacity,
                                         0.5,
                                         duration=uiconst.TIME_ENTRY)
                uicore.animations.FadeTo(self.sr.label,
                                         self.sr.label.opacity,
                                         1.5,
                                         duration=uiconst.TIME_ENTRY)

    def OnMouseExit(self, *args):
        self.underlay.OnMouseExit()
        if self.icon:
            self.icon.OnMouseExit()
        else:
            uicore.animations.FadeTo(self.glowLabel,
                                     self.glowLabel.opacity,
                                     0.0,
                                     duration=uiconst.TIME_EXIT)
            uicore.animations.FadeTo(self.sr.label,
                                     self.sr.label.opacity,
                                     1.0,
                                     duration=uiconst.TIME_EXIT)

    def OnMouseDown(self, *args):
        if self.disabled:
            return
        if self.mousedownfunc:
            if type(self.args) == tuple:
                self.mousedownfunc(*self.args)
            else:
                self.mousedownfunc(self.args or self)
        self.underlay.OnMouseDown()
        if self.icon:
            self.icon.OnMouseDown()
        else:
            uicore.animations.FadeTo(self.glowLabel,
                                     self.glowLabel.opacity,
                                     1.0,
                                     duration=0.3)
            uicore.animations.FadeTo(self.sr.label,
                                     self.sr.label.opacity,
                                     1.2,
                                     duration=0.3)

    def OnMouseUp(self, *args):
        if self.mouseupfunc:
            if type(self.args) == tuple:
                self.mouseupfunc(*self.args)
            else:
                self.mouseupfunc(self.args or self)
        if not self.disabled:
            self.underlay.OnMouseUp()
            if self.icon:
                self.icon.OnMouseUp()
            else:
                uicore.animations.FadeTo(self.glowLabel,
                                         self.glowLabel.opacity, 1.0)
                uicore.animations.FadeTo(self.sr.label, self.sr.label.opacity,
                                         1.0)

    def Confirm(self, *args):
        ButtonCore.Confirm(self)
        self.underlay.Blink()

    def SetColor(self, color):
        self.glowLabel.SetFixedColor(color)
        self.underlay.SetFixedColor(color)

    def Disable(self):
        ButtonCore.Disable(self)
        self.underlay.SetDisabled()

    def Enable(self):
        ButtonCore.Enable(self)
        self.underlay.SetEnabled()

    def Blink(self, on_off=1, blinks=1000, time=800):
        self.blinking = on_off
        if on_off:
            self.underlay.Blink(blinks)
        else:
            self.underlay.StopBlink()