mapViewCheckboxOptionButton.py (3847B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\controls\mapViewCheckboxOptionButton.py 2 import localization 3 from carbonui import const as uiconst 4 from carbonui.uicore import uicore 5 from carbonui.control.buttonIcon import ButtonIcon 6 from carbonui.control.checkbox import Checkbox 7 from carbonui.control.radioButton import RadioButton 8 from eve.client.script.ui.control.themeColored import LineThemeColored 9 from eve.client.script.ui.shared.mapView.mapViewSettings import ICON_ROOT, MV_GROUPS_BY_ID, GetMapViewSetting, LABEL_MAP_BY_ID, SetMapViewSetting 10 11 class MapViewCheckboxOptionButton(ButtonIcon): 12 default_iconSize = 24 13 default_width = 26 14 default_height = 26 15 settingGroupKeys = None 16 callback = None 17 18 def ApplyAttributes(self, attributes): 19 ButtonIcon.ApplyAttributes(self, attributes) 20 self.settingGroupKeys = attributes.settingGroupKeys 21 self.mapViewID = attributes.mapViewID 22 self.callback = attributes.callback 23 self.SetTexturePath(ICON_ROOT + 'icon_const_group.png') 24 25 def Close(self, *args): 26 ButtonIcon.Close(self, *args) 27 self.callback = None 28 29 def LoadTooltipPanel(self, tooltipPanel, *args): 30 if uicore.uilib.leftbtn: 31 return 32 tooltipPanel.columns = 2 33 tooltipPanel.AddLabelSmall(text=localization.GetByLabel('UI/Map/Layout'), bold=True, cellPadding=(8, 4, 4, 2), colSpan=tooltipPanel.columns) 34 for settingsGroupKey in self.settingGroupKeys: 35 if len(tooltipPanel.children): 36 divider = LineThemeColored(align=uiconst.TOTOP, height=1, padding=(1, 1, 1, 0), opacity=0.3) 37 tooltipPanel.AddCell(cellObject=divider, colSpan=tooltipPanel.columns) 38 if settingsGroupKey in MV_GROUPS_BY_ID: 39 for settingsID in MV_GROUPS_BY_ID[settingsGroupKey]: 40 checked = settingsID == GetMapViewSetting(settingsGroupKey, self.mapViewID) 41 textKey = (settingsGroupKey, settingsID) 42 checkBox = RadioButton(align=uiconst.TOPLEFT, text=LABEL_MAP_BY_ID[textKey], groupname=settingsGroupKey, checked=checked, wrapLabel=False, callback=self.OnRadioButtonChange, settingsKey=settingsGroupKey, retval=settingsID, settingsPath=None) 43 tooltipPanel.AddCell(cellObject=checkBox, colSpan=tooltipPanel.columns, cellPadding=(5, 0, 5, 0)) 44 45 else: 46 checked = bool(GetMapViewSetting(settingsGroupKey, self.mapViewID)) 47 checkBox = Checkbox(align=uiconst.TOPLEFT, text=LABEL_MAP_BY_ID[settingsGroupKey], checked=checked, wrapLabel=False, callback=self.OnCheckBoxChange, settingsKey=settingsGroupKey, settingsPath=None) 48 tooltipPanel.AddCell(cellObject=checkBox, colSpan=tooltipPanel.columns, cellPadding=(5, 0, 5, 0)) 49 50 tooltipPanel.state = uiconst.UI_NORMAL 51 52 def OnCheckBoxChange(self, checkbox): 53 key = checkbox.GetSettingsKey() 54 val = checkbox.checked 55 SetMapViewSetting(key, val, self.mapViewID) 56 if self.callback: 57 self.callback(key, val) 58 59 def OnRadioButtonChange(self, checkbox): 60 key = checkbox.GetSettingsKey() 61 val = checkbox.GetReturnValue() 62 SetMapViewSetting(key, val, self.mapViewID) 63 if self.callback: 64 self.callback(key, val) 65 66 def _LocalCallback(self, *args, **kwds): 67 if self.callback: 68 self.callback(*args, **kwds) 69 70 def GetTooltipDelay(self): 71 return 5 72 73 def GetTooltipPointer(self): 74 return uiconst.POINT_TOP_1 75 76 def GetTooltipPositionFallbacks(self): 77 return [uiconst.POINT_TOP_2, 78 uiconst.POINT_TOP_1, 79 uiconst.POINT_TOP_3, 80 uiconst.POINT_BOTTOM_2, 81 uiconst.POINT_BOTTOM_1, 82 uiconst.POINT_BOTTOM_3]