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

sidePanelsLayer.py (3395B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\sidePanelsLayer.py
      2 from carbonui import uiconst
      3 from carbonui.control.layer import LayerCore
      4 from carbonui.uicore import uicore
      5 from carbonui.window.snap import SNAP_DISTANCE
      6 
      7 class SidePanels(LayerCore):
      8     __notifyevents__ = ['OnHideUI', 'OnShowUI']
      9 
     10     def ApplyAttributes(self, attributes):
     11         LayerCore.ApplyAttributes(self, attributes)
     12         self.inactivePanels = ['sidePanel']
     13         self.leftPush = 0
     14         self.rightPush = 0
     15         sm.RegisterNotify(self)
     16 
     17     def OnShowUI(self):
     18         for each in self.children:
     19             if each.align != uiconst.TOALL:
     20                 each.display = True
     21 
     22     def OnHideUI(self):
     23         for each in self.children:
     24             if each.align != uiconst.TOALL:
     25                 each.display = False
     26 
     27     def OnOpenView(self, **kwargs):
     28         sm.GetService('neocom').CreateNeocom()
     29         sm.GetService('notificationUIService').Show()
     30 
     31     def OnCloseView(self):
     32         sm.GetService('notificationUIService').Hide()
     33 
     34     def UpdateAlignment(self, *args, **kw):
     35         needsUpdate = False
     36         for c in self.children:
     37             if c._alignmentDirty:
     38                 needsUpdate = True
     39                 break
     40 
     41         ret = LayerCore.UpdateAlignment(self, *args, **kw)
     42         if needsUpdate:
     43             self.UpdateWindowPositions()
     44         return ret
     45 
     46     def UpdateWindowPositions(self):
     47         dockedLeft = []
     48         dockedLeftGap = []
     49         dockedRight = []
     50         dockedRightGap = []
     51         for wnd in uicore.registry.GetValidWindows():
     52             if wnd.name == 'mapbrowser':
     53                 continue
     54             if wnd.align != uiconst.TOPLEFT:
     55                 continue
     56             if wnd.left == self.leftPush:
     57                 dockedLeft.append(wnd)
     58             elif wnd.left == self.leftPush + SNAP_DISTANCE:
     59                 dockedLeftGap.append(wnd)
     60             elif wnd.left + wnd.width == uicore.desktop.width - self.rightPush:
     61                 dockedRight.append(wnd)
     62             elif wnd.left + wnd.width == uicore.desktop.width - self.rightPush - SNAP_DISTANCE:
     63                 dockedRightGap.append(wnd)
     64 
     65         self.leftPush, self.rightPush = self.GetSideOffset()
     66         for wnd in dockedLeft:
     67             wnd.left = self.leftPush
     68 
     69         for wnd in dockedLeftGap:
     70             wnd.left = self.leftPush + SNAP_DISTANCE
     71 
     72         for wnd in dockedRight:
     73             wnd.left = uicore.desktop.width - self.rightPush - wnd.width
     74 
     75         for wnd in dockedRightGap:
     76             wnd.left = uicore.desktop.width - self.rightPush - wnd.width - SNAP_DISTANCE
     77 
     78         layers = (uicore.layer.inflight, uicore.layer.target)
     79         for layer in layers:
     80             layer.padLeft = self.leftPush
     81             layer.padRight = self.rightPush
     82 
     83         sm.ScatterEvent('OnUpdateWindowPosition', self.leftPush, self.rightPush)
     84 
     85     def GetSideOffset(self):
     86         leftPush = 0
     87         rightPush = 0
     88         for c in self.children:
     89             if c.name in self.inactivePanels or c.destroyed:
     90                 continue
     91             if c.align == uiconst.TOLEFT:
     92                 leftPush += c.width + c.left
     93             elif c.align == uiconst.TORIGHT:
     94                 rightPush += c.width + c.left
     95 
     96         leftPush = int(round(leftPush))
     97         rightPush = int(round(rightPush))
     98         return (leftPush, rightPush)