tab_with_count.py (2010B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\window\header\tab_with_count.py 2 import carbonui 3 import carbonui.text.styles 4 import eveui 5 from carbonui.control.tab import Tab 6 from eve.client.script.ui import eveThemeColor 7 8 class TabWithCount(Tab): 9 10 def __init__(self, count = 0, count_bg_color = None, *args, **kwargs): 11 self._count = count 12 self._count_bg_color = count_bg_color 13 super(TabWithCount, self).__init__(*args, **kwargs) 14 15 @property 16 def count(self): 17 return self._count 18 19 @count.setter 20 def count(self, value): 21 if self._count == value: 22 return 23 if self._count == 0: 24 self._count_container.display = True 25 self._count = value 26 self._count_label.text = str(self._count) 27 self._count_label.color = carbonui.TextColor.NORMAL if self._count > 0 else carbonui.TextColor.SECONDARY 28 if self._count == 0: 29 self._count_container.display = False 30 31 def _ConstructLabel(self): 32 super(TabWithCount, self)._ConstructLabel() 33 self._count_container = eveui.ContainerAutoSize(parent=self, align=carbonui.Align.CENTERLEFT, display=False) 34 self._count_label = carbonui.text.styles.TextBody(parent=self._count_container, align=carbonui.Align.CENTER, text=str(self._count), padding=(6, 0, 6, 0), color=carbonui.TextColor.SECONDARY) 35 self._bg_frame = eveui.Frame(bgParent=self._count_container, color=self._count_bg_color or eveThemeColor.THEME_FOCUSDARK, opacity=0.4, frameConst=carbonui.uiconst.FRAME_FILLED_CORNER4) 36 37 def UpdateTabSize(self): 38 self._count_container.left = self.label.left + self.label.width + 4 39 self.sr.width = self._count_container.left + self._count_container.GetAbsoluteSize()[0] 40 41 def OnColorThemeChanged(self): 42 super(TabWithCount, self).OnColorThemeChanged() 43 color = (self._count_bg_color or eveThemeColor.THEME_FOCUSDARK)[:3] 44 self._bg_frame.rgb = color