selectionIndicatorLine.py (3729B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\decorative\selectionIndicatorLine.py 2 import trinity 3 from carbonui import uiconst 4 from carbonui.primitives.line import Line 5 from carbonui.uianimations import animations 6 from carbonui.uicore import uicore 7 from carbonui.util.color import Color 8 from carbonui.util.various_unsorted import GetWindowAbove, IsUnderActiveWindow 9 from eve.client.script.ui import eveThemeColor 10 GLOW_BRIGHTNESS_ACTIVE = 0.75 11 GLOW_BRIGHTNESS_INACTIVE = 0.1 12 COLOR_INACTIVE = Color.HextoRGBA('#B0B0B0') 13 OPACITY_INACTIVE = 0.0 14 15 class SelectionIndicatorLine(Line): 16 default_color = eveThemeColor.THEME_ACCENT 17 default_opacity = 0.0 18 default_weight = 1 19 default_glowBrightness = GLOW_BRIGHTNESS_INACTIVE 20 default_fixedColor = None 21 default_outputMode = trinity.Tr2SpriteTarget.COLOR_AND_GLOW 22 _active = False 23 24 def __init__(self, selected = False, opacity_active = 1.0, **kwargs): 25 self._active_color = kwargs.pop('color', None) or self.default_color 26 self._selected = selected 27 self._opacity_active = opacity_active 28 super(SelectionIndicatorLine, self).__init__(opacity=self._get_opacity(), **kwargs) 29 self._active = IsUnderActiveWindow(self) 30 self._update_glow_brightness(animate=False) 31 self._update_color(animate=False) 32 33 @property 34 def selected(self): 35 return self._selected 36 37 @selected.setter 38 def selected(self, value): 39 if self._selected != value: 40 self._selected = value 41 self._update_opacity() 42 43 def Select(self): 44 self.selected = True 45 46 def Deselect(self): 47 self.selected = False 48 49 def _get_opacity(self): 50 if self.selected: 51 return self._opacity_active 52 else: 53 return OPACITY_INACTIVE 54 55 def _update_opacity(self, animate = True): 56 if animate: 57 duration = uiconst.TIME_ENTRY if self.selected else uiconst.TIME_EXIT 58 animations.FadeTo(self, startVal=self.opacity, endVal=self._get_opacity(), duration=duration) 59 else: 60 self.opacity = self._get_opacity() 61 62 def SetActiveColor(self, color): 63 self._active_color = color 64 self._update_color(animate=False) 65 66 def OnColorThemeChanged(self): 67 super(SelectionIndicatorLine, self).OnColorThemeChanged() 68 self._update_color() 69 70 def OnWindowAboveSetActive(self): 71 super(SelectionIndicatorLine, self).OnWindowAboveSetActive() 72 self._active = True 73 self._update_glow_brightness() 74 self._update_color() 75 76 def OnWindowAboveSetInactive(self): 77 super(SelectionIndicatorLine, self).OnWindowAboveSetInactive() 78 self._active = False 79 self._update_glow_brightness() 80 self._update_color() 81 82 def _get_glow_brightness(self): 83 if self._active: 84 return GLOW_BRIGHTNESS_ACTIVE 85 else: 86 return GLOW_BRIGHTNESS_INACTIVE 87 88 def _update_glow_brightness(self, animate = True): 89 if animate: 90 animations.MorphScalar(self, 'glowBrightness', startVal=self.glowBrightness, endVal=self._get_glow_brightness(), duration=uiconst.TIME_ENTRY if self._active else uiconst.TIME_EXIT) 91 else: 92 self.glowBrightness = self._get_glow_brightness() 93 94 def _get_color(self): 95 if self._active: 96 return self._active_color[:3] 97 else: 98 return COLOR_INACTIVE[:3] 99 100 def _update_color(self, animate = True): 101 if animate: 102 animations.SpColorMorphTo(self, endColor=self._get_color(), duration=uiconst.TIME_ENTRY if self._active else uiconst.TIME_EXIT) 103 else: 104 self.color = self._get_color()