eveWindowUnderlay.py (9953B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\eveWindowUnderlay.py 2 import carbonui.const as uiconst 3 import trinity 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.fill import Fill 6 from carbonui.uianimations import animations 7 from carbonui.uicore import uicore 8 from eve.client.script.ui import eveThemeColor 9 from eve.client.script.ui.control.themeColored import FrameThemeColored, FillThemeColored 10 11 class RaisedUnderlay(Container): 12 default_fixedColor = None 13 default_colorType = uiconst.COLORTYPE_UIHILIGHT 14 default_clipChildren = True 15 default_hideFrame = False 16 OPACITY_DISABLED = 0.2 17 OPACITY_IDLE = 0.4 18 OPACITY_HOVER = 0.7 19 OPACITY_SELECTED = 1.0 20 OPACITY_MOUSEDOWN = 1.1 21 22 def ApplyAttributes(self, attributes): 23 Container.ApplyAttributes(self, attributes) 24 self.fixedColor = attributes.Get('color', self.default_fixedColor) 25 self._colorType = attributes.Get('colorType', self.default_colorType) 26 self.isSelected = False 27 self.isDisabled = False 28 self.ConstructLayout() 29 30 @property 31 def colorType(self): 32 return self._colorType 33 34 @colorType.setter 35 def colorType(self, colorType): 36 if colorType == self.colorType: 37 return 38 self._colorType = colorType 39 self._UpdateColorType() 40 41 def ConstructLayout(self): 42 self.frame = FrameThemeColored(name='frame', bgParent=self, colorType=self.colorType, color=self.fixedColor, blendMode=trinity.TR2_SBM_ADD, texturePath='res:/UI/Texture/Classes/Button/frame.png', opacity=0.2) 43 self.innerGlow = FrameThemeColored(name='innerGlow', bgParent=self, cornerSize=10, texturePath='res:/UI/Texture/Classes/Button/innerGlow.png', colorType=self.colorType, color=self.fixedColor, opacity=0.2) 44 self.hoverFill = FillThemeColored(name='hoverFill', bgParent=self, colorType=self.colorType, opacity=self.OPACITY_IDLE, color=self.fixedColor) 45 FillThemeColored(name='backgroundColorFill', bgParent=self, opacity=0.45) 46 47 def HideFrame(self): 48 self.frame.Hide() 49 50 def SetFixedColor(self, fixedColor): 51 self.fixedColor = fixedColor 52 self.frame.SetFixedColor(fixedColor) 53 self.innerGlow.SetFixedColor(fixedColor) 54 self.hoverFill.SetFixedColor(fixedColor) 55 56 def OnMouseEnter(self, *args): 57 self.ShowHilite() 58 59 def OnMouseExit(self, *args): 60 self.HideHilite() 61 62 def GetColor(self): 63 return self.fixedColor or sm.GetService('uiColor').GetUIColor(self.colorType) 64 65 def ShowHilite(self, animate = True): 66 if self.isSelected or self.isDisabled: 67 return 68 color = self.GetColor()[:3] 69 if animate: 70 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, self.OPACITY_HOVER, duration=uiconst.TIME_ENTRY) 71 uicore.animations.SpColorMorphTo(self.frame, endColor=color, duration=uiconst.TIME_ENTRY) 72 else: 73 self.hoverFill.opacity = self.OPACITY_HOVER 74 color = color + (self.frame.opacity,) 75 self.frame.SetRGBA(*color) 76 77 def HideHilite(self, animate = True): 78 if self.isSelected or self.isDisabled: 79 return 80 color = self.GetColor()[:3] 81 if animate: 82 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, self.OPACITY_IDLE, duration=uiconst.TIME_EXIT) 83 uicore.animations.SpColorMorphTo(self.frame, endColor=color, duration=uiconst.TIME_ENTRY) 84 else: 85 self.hoverFill.opacity = self.OPACITY_IDLE 86 color = color + (self.frame.opacity,) 87 self.frame.SetRGBA(*color) 88 89 def OnMouseDown(self, *args): 90 if self.isSelected or self.isDisabled: 91 return 92 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, self.OPACITY_MOUSEDOWN, duration=0.1) 93 94 def OnMouseUp(self, *args): 95 if self.isSelected or self.isDisabled: 96 return 97 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, self.OPACITY_HOVER, duration=0.3) 98 99 def Blink(self, loops = 1): 100 opacity = self.OPACITY_DISABLED if self.isDisabled else self.OPACITY_IDLE 101 uicore.animations.FadeTo(self.hoverFill, self.OPACITY_MOUSEDOWN, opacity, curveType=uiconst.ANIM_WAVE, duration=0.6, loops=loops) 102 103 def StopBlink(self): 104 opacity = self.OPACITY_DISABLED if self.isDisabled else self.OPACITY_IDLE 105 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, opacity, duration=0.3) 106 107 def Select(self, animate = True): 108 if self.isSelected: 109 return 110 self.innerGlow.StopAnimations() 111 if self.fixedColor: 112 self.innerGlow.SetFixedColor(self.fixedColor) 113 else: 114 self.innerGlow.SetColorType(uiconst.COLORTYPE_UIHILIGHT) 115 if animate: 116 uicore.animations.FadeTo(self.hoverFill, self.hoverFill.opacity, self.OPACITY_SELECTED, duration=0.15) 117 else: 118 self.hoverFill.opacity = self.OPACITY_SELECTED 119 self.isSelected = True 120 121 def Deselect(self, animate = True): 122 if not self.isSelected: 123 return 124 self.isSelected = False 125 self.HideHilite(animate=animate) 126 127 def SetDisabled(self): 128 self.isDisabled = True 129 self.hoverFill.StopAnimations() 130 self.hoverFill.opacity = self.OPACITY_DISABLED 131 132 def SetEnabled(self): 133 self.isDisabled = False 134 self.hoverFill.StopAnimations() 135 self.hoverFill.opacity = self.OPACITY_IDLE 136 137 def _UpdateColorType(self): 138 self.frame.SetColorType(self._colorType) 139 self.innerGlow.SetColorType(self._colorType) 140 self.hoverFill.SetColorType(self._colorType) 141 142 def Expand(self, *args): 143 pass 144 145 def Collapse(self): 146 pass 147 148 149 class ListEntryUnderlay(Fill): 150 COLOR = eveThemeColor.THEME_FOCUSDARK 151 OPACITY_IDLE = 0.0 152 OPACITY_HOVER = 0.2 153 OPACITY_SELECTED = 0.4 154 GLOW_BRIGHTNESS_IDLE = 0.0 155 GLOW_BRIGHTNESS_HOVERED = 0.3 156 default_name = 'ListEntryUnderlay' 157 default_padBottom = 1 158 159 def __init__(self, color_override = None, hovered = False, selected = False, **kwargs): 160 if 'color' in kwargs: 161 color_override = kwargs.pop('color') 162 self._color_override = color_override 163 self._hovered = hovered 164 self._selected = selected 165 super(ListEntryUnderlay, self).__init__(color=self._get_color(), opacity=self._get_opacity(), outputMode=uiconst.OUTPUT_COLOR_AND_GLOW, glowBrightness=self._get_glow_brightness(), **kwargs) 166 167 @property 168 def color_override(self): 169 return self._color_override 170 171 @color_override.setter 172 def color_override(self, value): 173 self.set_color_override(value) 174 175 @property 176 def hovered(self): 177 return self._hovered 178 179 @hovered.setter 180 def hovered(self, value): 181 self.set_hovered(value) 182 183 @property 184 def selected(self): 185 return self._selected 186 187 @selected.setter 188 def selected(self, value): 189 self.set_selected(value) 190 191 def set_color_override(self, value, animate = True): 192 if self._color_override != value: 193 self._color_override = value 194 self._update_color(animate) 195 self._update_opacity(animate) 196 197 def set_hovered(self, value, animate = True): 198 if self._hovered != value: 199 self._hovered = value 200 self._update_opacity(animate) 201 self._update_glow_brightness(animate) 202 203 def set_selected(self, value, animate = True): 204 if self._selected != value: 205 self._selected = value 206 self._update_color(animate) 207 self._update_opacity(animate) 208 209 def select(self, animate = True): 210 self.set_selected(True, animate) 211 212 def deselect(self, animate = True): 213 self.set_selected(False, animate) 214 215 def _get_color(self): 216 if self._selected: 217 return self.COLOR 218 elif self._color_override is not None: 219 return self._color_override 220 else: 221 return self.COLOR 222 223 def _update_color(self, animate = True): 224 if animate: 225 animations.SpColorMorphTo(self, startColor=self.color.GetRGB(), endColor=self._get_color()[:3], duration=0.3) 226 else: 227 self.color = self._get_color()[:3] 228 229 def _get_opacity(self): 230 if self._selected: 231 return self.OPACITY_SELECTED 232 elif self._color_override is not None: 233 return self.OPACITY_SELECTED 234 elif self._hovered: 235 return self.OPACITY_HOVER 236 else: 237 return self.OPACITY_IDLE 238 239 def _update_opacity(self, animate = True): 240 if animate: 241 animations.FadeTo(self, startVal=self.opacity, endVal=self._get_opacity(), duration=0.3) 242 else: 243 self.opacity = self._get_opacity() 244 245 def _get_glow_brightness(self): 246 if self._hovered: 247 return self.GLOW_BRIGHTNESS_HOVERED 248 else: 249 return self.GLOW_BRIGHTNESS_IDLE 250 251 def _update_glow_brightness(self, animate = True): 252 if animate: 253 if self._hovered: 254 duration = 0.1 255 else: 256 duration = 0.3 257 animations.MorphScalar(self, 'glowBrightness', endVal=self._get_glow_brightness(), duration=duration) 258 else: 259 self.glowBrightness = self._get_glow_brightness() 260 261 def OnColorThemeChanged(self): 262 self._update_color(animate=False) 263 264 def OnMouseEnter(self, *args): 265 self.hovered = True 266 267 def OnMouseExit(self, *args): 268 self.hovered = False 269 270 def ShowHilite(self, animate = True): 271 self.set_hovered(True, animate) 272 273 def HideHilite(self, animate = True): 274 self.set_hovered(False, animate) 275 276 def Select(self, animate = True): 277 self.select(animate) 278 279 def Deselect(self, animate = True): 280 self.deselect(animate)