warningContainer.py (2624B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\primitives\warningContainer.py 2 from carbonui import uiconst, PickState 3 from carbonui.text.styles import TextBody 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.primitives.frame import Frame 6 from carbonui.primitives.sprite import Sprite 7 from eve.client.script.ui import eveColor 8 9 class WarningContainer(ContainerAutoSize): 10 default_textAlignment = uiconst.CENTERLEFT 11 default_minHeight = 43 12 default_warningColor = (247 / 255.0, 147 / 255.0, 30 / 255.0) 13 default_warningBackgroundColor = (247 / 255.0, 147 / 255.0, 30 / 255.0) 14 default_warningOpacity = 0.2 15 default_clipChildren = True 16 icon_path = 'res:/UI/Texture/classes/Warning/warningIconSmall.png' 17 18 def ApplyAttributes(self, attributes): 19 ContainerAutoSize.ApplyAttributes(self, attributes) 20 text = attributes.text 21 textAlignment = attributes.get('textAlignment', self.default_textAlignment) 22 warningColor = attributes.get('warningColor', self.default_warningColor) 23 warningBackgroundColor = attributes.get('warningBackgroundColor', self.default_warningBackgroundColor) 24 warningOpacity = attributes.get('warningOpacity', self.default_warningOpacity) 25 self.alignMode = textAlignment 26 Sprite(name='warningSprite', parent=self, texturePath=self.icon_path, pos=(8, 10, 20, 20), align=uiconst.TOPLEFT, pickState=PickState.OFF, color=warningColor) 27 self.warningLabel = TextBody(parent=self, text=text, align=textAlignment, pickState=PickState.OFF, top=-1) 28 if textAlignment in uiconst.PUSHALIGNMENTS: 29 self.warningLabel.padLeft = 37 30 self.warningLabel.padTop = self.warningLabel.padBottom = self.warningLabel.padRight = 11 31 else: 32 self.warningLabel.left = 37 33 self.warningLabel.padRight = 18 34 Sprite(name='cornerSprite', parent=self, align=uiconst.TOPLEFT, PickState=PickState.OFF, texturePath='res:/UI/Texture/classes/Warning/warningTriangle.png', pos=(0, 0, 8, 8), color=warningColor) 35 Frame(bgParent=self, texturePath='res:/UI/Texture/classes/Warning/solidFrame_12corner.png', cornerSize=12, color=warningBackgroundColor, opacity=warningOpacity) 36 37 @property 38 def text(self): 39 return self.warningLabel.text 40 41 @text.setter 42 def text(self, value): 43 self.warningLabel.text = value 44 45 46 class DangerContainer(WarningContainer): 47 default_warningColor = eveColor.DANGER_RED 48 default_warningBackgroundColor = eveColor.DANGER_RED 49 default_warningOpacity = 0.2