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

dropdownColorPicker.py (3136B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\dropdownColorPicker.py
      2 from carbonui import uiconst
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.fill import Fill
      5 from carbonui.primitives.frame import Frame
      6 from carbonui.primitives.sprite import Sprite
      7 from eve.client.script.ui.control.colorPanel import ColorPanel
      8 from localization import GetByLabel
      9 
     10 class DropdownColorPicker(Container):
     11     __guid__ = 'dropdownColorPicker'
     12     default_height = 20
     13     default_width = 27
     14     default_name = 'colorPicker'
     15     default_state = uiconst.UI_NORMAL
     16     default_align = uiconst.CENTERRIGHT
     17     default_colorPos = (0, 0, 16, 16)
     18     default_numColumns = 5
     19     COLOR_LIST = [(1.0, 0.7, 0.0),
     20      (1.0, 0.35, 0.0),
     21      (0.75, 0.0, 0.0),
     22      (0.1, 0.6, 0.1),
     23      (0.0, 0.63, 0.57),
     24      (0.2, 0.5, 1.0),
     25      (0.0, 0.15, 0.6),
     26      (0.0, 0.0, 0.0),
     27      (0.7, 0.7, 0.7)]
     28 
     29     def ApplyAttributes(self, attributes):
     30         Container.ApplyAttributes(self, attributes)
     31         self.numColumns = attributes.get('numColumns', self.default_numColumns)
     32         self.currentColor = attributes.currentColor
     33         self.callback = attributes.callback
     34         self.colorPos = attributes.colorPos or self.default_colorPos
     35         self.arrowSprite = Sprite(parent=self, pos=(-2, 0, 16, 16), name='arrow', align=uiconst.CENTERRIGHT, texturePath='res:/ui/texture/icons/38_16_229.png', color=(1, 1, 1, 0.5), state=uiconst.UI_DISABLED)
     36         self.colorCont = Container(parent=self, name='colorCont', pos=(2, 0, 12, 12), align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED)
     37         Frame(parent=self.colorCont, name='colorFrame', color=(1, 1, 1, 0.2))
     38         self.colorFill = Fill(parent=self.colorCont, color=(0, 0, 0, 0))
     39         self.SetCurrentFill(self.currentColor)
     40 
     41     def GetTooltipPointer(self):
     42         return uiconst.POINT_LEFT_2
     43 
     44     def GetTooltipDelay(self):
     45         return 50
     46 
     47     def LoadTooltipPanel(self, tooltipPanel, *args):
     48         tooltipPanel.state = uiconst.UI_NORMAL
     49         tooltipPanel.LoadStandardSpacing()
     50         colorPanel = ColorPanel(callback=lambda color: self.SetColorFromPanel(color=color, tooltipPanel=tooltipPanel), currentColor=self.currentColor, colorList=self.GetColors(), columns=self.numColumns)
     51         tooltipPanel.AddLabelSmall(text=GetByLabel('UI/Mail/Select Color'))
     52         tooltipPanel.AddCell(cellObject=colorPanel)
     53 
     54     def SetColorFromPanel(self, color, tooltipPanel):
     55         self.SetCurrentFill(color)
     56         self.callback(color, self)
     57         tooltipPanel.Close()
     58 
     59     def GetColors(self):
     60         return self.COLOR_LIST
     61 
     62     def SetCurrentFill(self, color):
     63         if color:
     64             color = tuple(color)
     65             if not isinstance(color, (tuple, list)):
     66                 color = None
     67         self.currentColor = color
     68         fillColor = color
     69         self.colorFill.display = True
     70         if color is None:
     71             fillColor = (0, 0, 0, 0)
     72             self.colorFill.display = True
     73         elif len(fillColor) == 3:
     74             fillColor = color + (1,)
     75         self.colorFill.SetRGBA(*fillColor)