underlay.py (3060B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\window\underlay.py 2 from carbonui import uiconst 3 from carbonui.decorative.selectionIndicatorLine import SelectionIndicatorLine 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.frame import Frame 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.uianimations import animations 8 from carbonui.decorative.blurredSceneUnderlay import BlurredSceneUnderlay 9 10 class BaseWindowUnderlay(Container): 11 12 def EnableLightBackground(self): 13 pass 14 15 def DisableLightBackground(self): 16 pass 17 18 def AnimEntry(self): 19 pass 20 21 def AnimExit(self): 22 pass 23 24 25 DURATION_ENTRY = 0.4 26 DURATION_EXIT = 0.6 27 28 class WindowUnderlay(BaseWindowUnderlay): 29 default_name = 'underlay' 30 default_state = uiconst.UI_DISABLED 31 default_hasBlurredUnderlay = True 32 ACCENT_LINE_THICKNESS = 1 33 __notifyevents__ = ['OnCameraDragStart', 'OnCameraDragEnd'] 34 35 def ApplyAttributes(self, attributes): 36 self.hasBlurredUnderlay = attributes.get('hasBlurredUnderlay', self.default_hasBlurredUnderlay) 37 super(WindowUnderlay, self).ApplyAttributes(attributes) 38 sm.RegisterNotify(self) 39 self.isCameraDragging = False 40 self.blurredUnderlay = None 41 self.ConstructLayout() 42 43 def ConstructLayout(self): 44 self.ConstructAccentLine() 45 Frame(parent=self, align=uiconst.TOALL, opacity=0.1) 46 self.dotBG = Sprite(name='dotBG', bgParent=self, texturePath='res:/UI/Texture/Shared/dot_bg.png', opacity=0.0, tileX=True, tileY=True, translationPrimary=(-0.61, -0.61)) 47 self.ConstructBlurredUnderlay() 48 49 def ConstructAccentLine(self): 50 self.headerAccentLine = SelectionIndicatorLine(parent=self, align=uiconst.TOTOP_NOPUSH, weight=self.ACCENT_LINE_THICKNESS, opacity_active=0.5) 51 52 def ConstructBlurredUnderlay(self): 53 if self.hasBlurredUnderlay: 54 self.blurredUnderlay = BlurredSceneUnderlay(bgParent=self, effectOpacity=0.5, saturation=0.5) 55 56 def AnimEntry(self): 57 self.headerAccentLine.Select() 58 animations.FadeTo(self.dotBG, self.dotBG.opacity, 0.05, duration=DURATION_ENTRY, curveType=uiconst.ANIM_OVERSHOT3) 59 60 def AnimExit(self): 61 self.headerAccentLine.Deselect() 62 animations.FadeTo(self.dotBG, self.dotBG.opacity, 0.0, duration=DURATION_EXIT) 63 64 def OnCameraDragStart(self): 65 if not self.blurredUnderlay: 66 return 67 self.blurredUnderlay.isCameraDragging = True 68 self.blurredUnderlay.UpdateState() 69 70 def OnCameraDragEnd(self): 71 if not self.blurredUnderlay: 72 return 73 self.blurredUnderlay.isCameraDragging = False 74 self.blurredUnderlay.UpdateState() 75 76 def EnableLightBackground(self): 77 if not self.blurredUnderlay: 78 return 79 self.blurredUnderlay.EnableLightBackground() 80 81 def DisableLightBackground(self): 82 if not self.blurredUnderlay: 83 return 84 self.blurredUnderlay.DisableLightBackground()