colorPanel.py (2019B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\colorPanel.py 2 import eveicon 3 from carbonui.control.buttonIcon import ButtonIcon 4 from carbonui.primitives.layoutGrid import LayoutGrid 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.frame import Frame 7 import carbonui.const as uiconst 8 from carbonui.util.color import Color 9 from eve.client.script.ui import eveColor 10 from localization import GetByLabel 11 12 class ColorPanel(LayoutGrid): 13 default_colorPos = (0, 0, 16, 16) 14 default_columns = 5 15 16 def ApplyAttributes(self, attributes): 17 LayoutGrid.ApplyAttributes(self, attributes) 18 self.cellPadding = 0 19 self.cellSpacing = 4 20 self.margin = 0 21 self.addClear = attributes.get('addClear', True) 22 self.colorList = attributes['colorList'] 23 self.callback = attributes.callback 24 currentColor = attributes.currentColor 25 self.colorPos = attributes.colorPos or self.default_colorPos 26 for color in self.colorList: 27 c = Container(name='colorFill', pos=self.colorPos, align=uiconst.NOALIGN, state=uiconst.UI_NORMAL, bgColor=color) 28 frameColor = Color(*color).SetBrightness(1.0).SetOpacity(0.15).GetRGBA() 29 Frame(parent=c, color=frameColor, padding=-1) 30 if color == currentColor: 31 Frame(parent=c, name='selectedColorFrame', color=eveColor.PLATINUM_GREY, padding=-2) 32 c.OnClick = lambda c = color, *args: self.OnColorSelected(color=c) 33 self.AddCell(cellObject=c, colSpan=1, cellPadding=1) 34 35 if self.addClear: 36 self.AddCell(cellObject=self.GetClearButton(c), colSpan=1) 37 38 def GetClearButton(self, c): 39 return ButtonIcon(texturePath=eveicon.close.resolve(16), align=uiconst.NOALIGN, hint=GetByLabel('UI/SystemMenu/ResetSettings/Clear'), func=lambda *args: self.OnColorSelected(None), pos=self.colorPos) 40 41 def OnColorSelected(self, color): 42 self.callback(color)