pointerOverlay.py (4348B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\pointerTool\pointerOverlay.py 2 from carbonui.primitives.container import Container 3 from carbonui.uicore import uicore 4 import carbonui.const as uiconst 5 from carbonui.control.window import Window 6 from eve.client.script.ui.shared.pointerTool.pointerFrame import PointerFill 7 from eve.client.script.ui.shared.pointerTool.pointerToolFraming import RemoveOldFrames, RemoveAllFrames, CreateBinding 8 from eve.client.script.ui.shared.pointerTool.pointerToolFunctions import GetScreenElementsByUniqueName 9 import log 10 11 class PointerOverlay(object): 12 13 def __init__(self): 14 self.fillDict = {} 15 self.pythonBindings = {} 16 self.fillCurveSet = uicore.animations.CreateCurveSet(useRealTime=True) 17 self.fillCont = Container(name='pointerFillCont', parent=uicore.desktop, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN, idx=0) 18 self.isActive = False 19 20 def ShowOverlay(self): 21 log.LogInfo('UI Pointer overlay:ShowOverlay') 22 self._RemoveAllFills() 23 try: 24 self.isActive = True 25 self.FrameAllUiElements() 26 except: 27 self.HideOverlay() 28 raise 29 30 def HideOverlay(self): 31 log.LogInfo('UI Pointer overlay:HideOverlay') 32 self.isActive = False 33 self._RemoveAllFills() 34 if self.fillCont: 35 self.fillCont.Flush() 36 37 def _RemoveAllFills(self): 38 log.LogInfo('UI Pointer overlay:_RemoveAllFills') 39 RemoveAllFrames(self.pythonBindings, self.fillDict, self.fillCurveSet) 40 self.ForceCleanupAllFills() 41 42 def FrameAllUiElements(self): 43 log.LogInfo('UI Pointer overlay:FrameAllUiElements') 44 RemoveOldFrames(self.fillDict, self.pythonBindings, self.fillCurveSet) 45 allPointers = sm.GetService('helpPointer').GetAllPointersByElementName() 46 allUiElementNames = allPointers.keys() 47 dictOfElementsToFrame = GetScreenElementsByUniqueName(allUiElementNames) 48 self._FrameElements(dictOfElementsToFrame) 49 50 def _FrameElements(self, elementsToFrame): 51 for key, eachElement in elementsToFrame.iteritems(): 52 if not self.isActive: 53 return 54 if eachElement is None or eachElement.destroyed or not eachElement.display: 55 continue 56 f, _ = self.fillDict.get(key, (None, None)) 57 if f and not f.destroyed: 58 pass 59 else: 60 try: 61 if isinstance(eachElement, Window) and eachElement.sr.underlay: 62 parent = eachElement 63 else: 64 parent = eachElement 65 f = PointerFill(parent=parent, idx=0, state=uiconst.UI_NORMAL, colorRGB=(0.2, 0.6, 1), uiElementName=key) 66 except Exception as e: 67 elementPos = eachElement.GetAbsolute() 68 f = PointerFill(parent=self.fillCont, align=uiconst.ABSOLUTE, colorRGB=(0.2, 0.6, 1), idx=0, state=uiconst.UI_NORMAL, pos=elementPos, uiElementName=key) 69 self._CreateBinding(key, eachElement, f) 70 71 if f: 72 self.fillDict[key] = (f, eachElement) 73 uicore.animations.FadeTo(f, 0.4, 0.6, duration=1.5, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_BOUNCE) 74 75 if not self.isActive: 76 self._RemoveAllFills() 77 78 def _CreateBinding(self, key, element, elementFrame): 79 CreateBinding(key, element, elementFrame, self.pythonBindings, self.fillCurveSet) 80 81 def ForceCleanupAllFills(self): 82 toClose = [] 83 self.FindDeepPointerFill(uicore.desktop, toClose) 84 for eachElement in toClose: 85 if eachElement and not eachElement.destroyed: 86 eachElement.Close() 87 88 if toClose: 89 log.LogTraceback('Pointer Overlay: had to manually remove fills') 90 91 def FindDeepPointerFill(self, element, fillsToClose): 92 if isinstance(element, PointerFill): 93 fillsToClose.append(element) 94 children = getattr(element, 'children', None) 95 if not children: 96 return 97 for child in children: 98 results = self.FindDeepPointerFill(child, fillsToClose) 99 if results is not None: 100 return results