NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

floatingToggleButtonGroup.py (3759B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\floatingToggleButtonGroup.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui import TextColor, uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.fill import Fill
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.uianimations import animations
      8 from eve.client.script.ui import eveThemeColor
      9 from eve.client.script.ui.control.eveLabel import EveLabelLarge
     10 from eve.client.script.ui.control.toggleButtonGroup import ToggleButtonGroup
     11 from eve.client.script.ui.control.toggleButtonGroupButton import BaseToggleButtonGroupButton
     12 OPACITY_LABEL_IDLE = TextColor.NORMAL.opacity
     13 OPACITY_LABEL_HOVER = TextColor.HIGHLIGHT.opacity
     14 OPACITY_LABEL_SELECTED = TextColor.HIGHLIGHT.opacity
     15 OPACITY_GLOW_IDLE = 0.0
     16 OPACITY_GLOW_HOVER = 0.5
     17 OPACITY_GLOW_SELECTED = 0.8
     18 OPACITY_LINE_IDLE = 0.2
     19 OPACITY_LINE_HOVER = 0.3
     20 OPACITY_LINE_SELECTED = 1.0
     21 
     22 class FloatingToggleButtonGroupButton(BaseToggleButtonGroupButton):
     23     default_padRight = 4
     24     default_iconSize = 16
     25 
     26     def ApplyAttributes(self, attributes):
     27         super(FloatingToggleButtonGroupButton, self).ApplyAttributes(attributes)
     28         label = attributes.label
     29         labelLeft = 10
     30         if self.iconPath:
     31             self.icon = Sprite(parent=self, texturePath=self.iconPath, align=uiconst.TOPLEFT, pos=(labelLeft,
     32              0,
     33              self.iconSize,
     34              self.iconSize), state=uiconst.UI_DISABLED)
     35             labelLeft += self.iconSize + 6
     36         self.label = EveLabelLarge(text=label, parent=self, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, left=labelLeft, opacity=OPACITY_LABEL_IDLE, autoFadeSides=True)
     37         lineCont = Container(parent=self, align=uiconst.TOBOTTOM, height=4)
     38         self.line = Fill(parent=lineCont, align=uiconst.TOALL, state=uiconst.UI_DISABLED, color=eveThemeColor.THEME_ACCENT, opacity=OPACITY_LINE_IDLE, outputMode=uiconst.OUTPUT_COLOR_AND_GLOW, glowBrightness=OPACITY_GLOW_IDLE)
     39 
     40     def OnColorThemeChanged(self):
     41         self.line.rgb = eveThemeColor.THEME_ACCENT.rgb
     42 
     43     def OnMouseEnter(self, *args):
     44         PlaySound(uiconst.SOUND_BUTTON_HOVER)
     45         animations.FadeTo(self.label, self.label.opacity, OPACITY_LABEL_HOVER, duration=0.1)
     46         if not self.isSelected:
     47             animations.MorphScalar(self.line, 'glowBrightness', self.line.glowBrightness, OPACITY_GLOW_HOVER, duration=0.1)
     48 
     49     def OnMouseExit(self, *args):
     50         if not self.isSelected:
     51             animations.FadeTo(self.label, self.label.opacity, OPACITY_LABEL_IDLE, duration=0.1)
     52             animations.MorphScalar(self.line, 'glowBrightness', self.line.glowBrightness, OPACITY_LINE_HOVER, duration=0.1)
     53 
     54     def SetSelected(self, animate = True):
     55         super(FloatingToggleButtonGroupButton, self).SetSelected(animate)
     56         animations.FadeTo(self.label, self.label.opacity, OPACITY_LABEL_SELECTED, duration=0.1)
     57         animations.MorphScalar(self.line, 'glowBrightness', self.line.glowBrightness, OPACITY_GLOW_SELECTED, duration=0.1)
     58         animations.FadeTo(self.line, self.line.opacity, OPACITY_GLOW_SELECTED, duration=0.1)
     59 
     60     def SetDeselected(self, animate = True):
     61         super(FloatingToggleButtonGroupButton, self).SetDeselected(animate)
     62         animations.FadeTo(self.label, self.label.opacity, OPACITY_LABEL_IDLE, duration=0.1)
     63         animations.MorphScalar(self.line, 'glowBrightness', self.line.glowBrightness, OPACITY_GLOW_IDLE, duration=0.1)
     64         animations.FadeTo(self.line, self.line.opacity, OPACITY_LINE_IDLE, duration=0.1)
     65 
     66 
     67 class FloatingToggleButtonGroup(ToggleButtonGroup):
     68     default_btnClass = FloatingToggleButtonGroupButton
     69     default_height = 32