NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

draggableShareContainer.py (3358B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\draggableShareContainer.py
      2 import localization
      3 from carbonui import uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.fill import Fill
      6 from carbonui.primitives.frame import Frame
      7 from carbonui.primitives.layoutGrid import LayoutGrid
      8 from carbonui.primitives.sprite import Sprite
      9 from eve.client.script.ui.control.eveIcon import DraggableIcon
     10 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     11 from eve.client.script.ui.control.labelEditable import LabelEditable
     12 
     13 class DraggableShareContainer(LayoutGrid):
     14     default_state = uiconst.UI_PICKCHILDREN
     15     default_align = uiconst.CENTERRIGHT
     16     default_name = 'draggableShareContainer'
     17 
     18     def ApplyAttributes(self, attributes):
     19         self.sharedNameLabel = None
     20         LayoutGrid.ApplyAttributes(self, attributes)
     21         self.columns = 2
     22         maxLength = attributes.get('maxLength', 40)
     23         currentText = attributes.currentText
     24         defaultText = attributes.defaultText
     25         configName = attributes.configName
     26         hintText = attributes.hintText
     27         self.getDragDataFunc = attributes.getDragDataFunc
     28         self.sharedNameLabel = LabelEditable(name='%s_LabelEditable' % configName, parent=self, align=uiconst.CENTERRIGHT, pos=(0, 1, 0, 0), text=currentText, hint=hintText, configName=configName, maxLength=maxLength, minLength=2, defaultText=defaultText)
     29         self.dragCont = dragCont = Container(parent=self, name='dragCont', pos=(6, 0, 30, 21), align=uiconst.CENTERRIGHT, state=uiconst.UI_NORMAL)
     30         Frame(bgParent=dragCont, color=(1, 1, 1, 0.15))
     31         f = Fill(bgParent=dragCont, color=(1.0, 1.0, 1.0, 0.125))
     32         f.display = False
     33         dragSprite = Sprite(parent=dragCont, pos=(3, 0, 15, 15), align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, texturePath='res:/UI/Texture/classes/Overview/shareableOverview_small.png')
     34         text = localization.GetByLabel('UI/Overview/ShareOverview')
     35         shareText = EveLabelMedium(text=text, parent=dragCont, left=20, state=uiconst.UI_DISABLED, align=uiconst.CENTERLEFT)
     36         dragCont.width = shareText.textwidth + shareText.left + 9
     37         dragCont.hint = hintText
     38         dragCont.cursor = uiconst.UICURSOR_DRAGGABLE
     39 
     40         def ChangeDisplayState(display, *args):
     41             f.display = display
     42 
     43         dragCont.OnMouseEnter = (ChangeDisplayState, True)
     44         dragCont.OnMouseExit = (ChangeDisplayState, False)
     45         for eachObject in (dragCont, self.sharedNameLabel.textLabel):
     46             eachObject.isDragObject = True
     47             eachObject.GetDragData = self.GetObjectDragData
     48             eachObject.PrepareDrag = self.PrepareObjectDrag
     49 
     50     def GetObjectDragData(self):
     51         return self.getDragDataFunc(self.sharedNameLabel.GetValue())
     52 
     53     def PrepareObjectDrag(self, dragContainer, dragSource):
     54         icon = DraggableIcon(align=uiconst.TOPLEFT, pos=(0, 0, 64, 64))
     55         icon.LoadIcon('res:/UI/Texture/classes/Overview/shareableOverview.png')
     56         dragContainer.children.append(icon)
     57         return (0, 0)
     58 
     59     def SetMaxWidth(self, width):
     60         if self.sharedNameLabel is None:
     61             return
     62         maxLabelWidth = width - self.dragCont.width - self.dragCont.left
     63         self.sharedNameLabel.SetMaxWidth(maxLabelWidth)