parameter_container.py (5526B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\control\parametertypes\parameter_container.py 2 import carbonui.text.styles 3 import eveui 4 import carbonui 5 import threadutils 6 from carbonui import Align, TextColor, TextAlign, PickState 7 from carbonui.control.parametertypes.more_entries_window import load_more_window 8 from carbonui.primitives.cardsContainer import CardsContainer 9 from eve.client.script.ui import eveColor 10 from localization import GetByLabel 11 12 class ParameterContainer(eveui.ContainerAutoSize): 13 default_alignMode = Align.TOTOP 14 15 def __init__(self, controller, *args, **kwargs): 16 super(ParameterContainer, self).__init__(*args, **kwargs) 17 self._controller = controller 18 self._job = kwargs.get('job', None) 19 self._layout() 20 21 def reload_content(self): 22 self.Flush() 23 self._layout() 24 25 def _layout(self): 26 header_cont = eveui.ContainerAutoSize(name='header_cont', parent=self, align=Align.TOTOP, alignMode=Align.TOTOP, padBottom=6) 27 self.more_label = carbonui.text.styles.TextBody(name='more_label', parent=header_cont, align=Align.CENTERRIGHT, text=GetByLabel('UI/Generic/ViewAll'), color=eveColor.CRYO_BLUE, display=False, pickState=PickState.ON) 28 self.more_label.OnClick = self.load_more_entries_window 29 carbonui.text.styles.TextBody(name='header', parent=header_cont, align=Align.TOTOP, text=self._controller.title, color=TextColor.SECONDARY) 30 content = eveui.ContainerAutoSize(name='content', parent=self, align=Align.TOTOP, alignMode=Align.TOTOP, minHeight=32) 31 icon_container = eveui.Container(name='icon_container', parent=content, state=carbonui.uiconst.UI_NORMAL, align=Align.TOPLEFT, width=32, height=32, bgTexturePath='res:/UI/Texture/Shared/DarkStyle/panel1Corner_SolidMirrored.png', bgColor=(1, 1, 1, 0.05), hint=self._controller.info) 32 eveui.Sprite(name='icon', parent=icon_container, align=Align.CENTER, color=TextColor.SECONDARY, width=16, height=16, texturePath=self._controller.icon) 33 values = self._controller.values 34 entries_parent = CardsContainer(parent=content, align=Align.TOTOP, padLeft=36, cardHeight=self._controller.get_entry_height() if values else 32, cardMaxWidth=260, contentSpacing=(8, 8), allow_stretch=True) 35 if values: 36 if isinstance(values, list): 37 for value in threadutils.be_nice_iter(30, self._controller.values): 38 self._construct_entry(entries_parent, value) 39 40 else: 41 self._construct_entry(entries_parent, values) 42 self._update_more_label() 43 else: 44 self._construct_none_entry(entries_parent) 45 46 def _update_more_label(self): 47 if self._controller.number_of_values_to_show_in_view_all: 48 self.more_label.Show() 49 self.more_label.text = '%s (%s)' % (GetByLabel('UI/Generic/ViewAll'), self._controller.number_of_values_to_show_in_view_all) 50 else: 51 self.more_label.Hide() 52 53 def _construct_entry(self, parent, value): 54 entry = eveui.Container(name=u'entry_{}'.format(value), parent=parent, align=Align.TOTOP, state=carbonui.uiconst.UI_NORMAL, clipChildren=True, hint=self._controller.get_entry_tooltip(value)) 55 entry.GetMenu = lambda *args, **kwargs: self._controller.get_entry_menu(value) 56 entry.GetDragData = lambda *args: self._get_entry_drag_data(value) 57 entry.MakeDragObject() 58 eveui.Frame(bgParent=entry, cornerSize=9, texturePath='res:/UI/Texture/Shared/DarkStyle/panel1Corner_Solid.png', color=self._controller.get_entry_color(value), opacity=0.2) 59 content = eveui.Container(parent=entry, align=Align.TOALL, padding=8) 60 icon = self._controller.construct_entry_icon(value) 61 if icon: 62 icon_container = eveui.ContainerAutoSize(name='icon_container', parent=content, align=Align.TOLEFT, padRight=8) 63 icon.SetParent(icon_container) 64 icon.GetMenu = entry.GetMenu 65 icon.GetDragData = entry.GetDragData 66 icon.MakeDragObject() 67 label_container = eveui.ContainerAutoSize(parent=content, align=Align.VERTICALLY_CENTERED) 68 subtitle = self._controller.get_entry_subtitle(value) 69 if subtitle: 70 carbonui.text.styles.TextDetail(parent=label_container, align=Align.TOTOP, text=subtitle, maxLines=1, autoFadeSides=16, color=TextColor.SECONDARY) 71 title = self._controller.get_entry_title(value) 72 carbonui.text.styles.TextBody(parent=label_container, align=Align.TOTOP, text=title, maxLines=1, autoFadeSides=16, color=self._controller.get_entry_color(value)) 73 74 def _construct_none_entry(self, parent): 75 entry = eveui.Container(parent=parent, align=Align.TOTOP, state=carbonui.uiconst.UI_NORMAL) 76 entry.GetMenu = lambda *args, **kwargs: self._controller.get_none_entry_menu() 77 eveui.Frame(bgParent=entry, cornerSize=9, texturePath='res:/UI/Texture/Shared/DarkStyle/panel1Corner_Solid.png', color=(1, 1, 1, 0.1)) 78 content = eveui.Container(parent=entry, align=Align.TOALL, padding=8, clipChildren=True) 79 carbonui.text.styles.TextBody(parent=content, align=Align.CENTERLEFT, text=self._controller.get_none_value_text(), autoFadeSides=16) 80 81 def _get_entry_drag_data(self, value): 82 data = self._controller.get_entry_drag_data(value) 83 if data: 84 return [data] 85 86 def load_more_entries_window(self, *args): 87 load_more_window(self._controller, self._job)