progressBar.py (2606B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\carbonui\control\progressBar.py 2 import math 3 import blue 4 import uthread 5 from carbonui import uiconst 6 from carbonui.primitives.container import Container 7 from eve.client.script.ui.control.themeColored import FillThemeColored 8 9 class ProgressBar(Container): 10 default_name = 'ProgressBar' 11 default_barWidth = 5 12 default_duration = 3.0 13 default_pauseTime = 1.0 14 default_state = uiconst.UI_DISABLED 15 default_clipChildren = True 16 17 def ApplyAttributes(self, attributes): 18 Container.ApplyAttributes(self, attributes) 19 self.barWidth = attributes.get('barWidth', self.default_barWidth) 20 self.duration = attributes.get('duration', self.default_duration) 21 self.pauseTime = attributes.get('pauseTime', self.default_pauseTime) 22 w, _ = self.GetAbsoluteSize() 23 self.bars = [] 24 for i in xrange(w / self.barWidth + 1): 25 bar = Bar(align=uiconst.TOLEFT, parent=self, opacity=0.75, width=self.barWidth, padLeft=0) 26 self.bars.append(bar) 27 28 uthread.new(self.Animate) 29 30 def Animate(self): 31 time = 0.0 32 duration = 5.0 33 numTotal = len(self.bars) 34 n = 0 35 while not self.destroyed: 36 blue.synchro.Yield() 37 if not self.display: 38 continue 39 time += 1.0 / blue.os.fps 40 if time > duration: 41 time -= duration 42 n += 2 43 if n > numTotal: 44 n = 0 45 t = time / duration 46 k = 2 * math.pi 47 for i, bar in enumerate(self.bars): 48 x = float(i) / (numTotal - 1) 49 fT = 1.0 50 fX = -1.0 51 bar.value = 2.0 * math.sin(k * (fT * t - fX * x)) 52 fT = 2.0 53 fX = 1.0 54 bar.value += 0.5 * math.sin(k * (fT * t - fX * x)) 55 fT = 3.0 56 fX = 2.0 57 bar.value += 0.7 * math.sin(k * (fT * t - fX * x)) 58 fT = 3.0 59 fX = -2.0 60 bar.value += 0.7 * math.sin(k * (fT * t - fX * x)) 61 62 63 class Bar(Container): 64 default_name = 'Bar' 65 66 def __init__(self, **kwargs): 67 self._value = 0.0 68 super(Bar, self).__init__(**kwargs) 69 FillThemeColored(bgParent=self, colorType=uiconst.COLORTYPE_UIHILIGHT) 70 71 @property 72 def value(self): 73 return self._value 74 75 @value.setter 76 def value(self, value): 77 value = max(0.25, value) 78 self._value = value 79 self.opacity = value