From 07d70c2cc7b082f94a1111aa0d12f77e11d9818f Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Sun, 16 Jan 2011 15:19:00 +0200 Subject: [PATCH] Added loading animation for shipbrowser stage 2 --- gui/shipBrowser.py | 22 ++++++++++++++++++++++ gui/utils/animUtils.py | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 66a54a6a8..57c28e8f3 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -11,6 +11,7 @@ from wx.lib.buttons import GenBitmapButton import gui.utils.colorUtils as colorUtils import gui.utils.drawUtils as drawUtils +import gui.utils.animUtils as animUtils import gui.sfBrowserItem as SFItem FitRenamed, EVT_FIT_RENAMED = wx.lib.newevent.NewEvent() @@ -26,6 +27,23 @@ class PFWidgetsContainer(PFListPane): def __init__(self,parent): PFListPane.__init__(self,parent) + self.anim = animUtils.LoadAnimation(self,label = "", size=(100,12)) + self.anim.Stop() + self.anim.Show(False) + + def ShowLoading(self, mode = True): + if mode: + aweight,aheight = self.anim.GetSize() + cweight,cheight = self.GetSize() + ax = (cweight - aweight)/2 + ay = (cheight - aheight)/2 + self.anim.SetPosition((ax,ay)) + self.anim.Show() + self.anim.Play() + else: + self.anim.Stop() + self.anim.Show(False) + def IsWidgetSelectedByContext(self, widget): mainFrame = gui.mainFrame.MainFrame.getInstance() stage = self.Parent.GetActiveStage() @@ -162,6 +180,7 @@ class ShipBrowser(wx.Panel): else: self.lpane.AddWidget(ShipItem(self.lpane, ID, (name, fits), race)) + self.lpane.ShowLoading(False) self.lpane.RefreshList() def stage2(self, event): @@ -175,6 +194,9 @@ class ShipBrowser(wx.Panel): self.lpane.RemoveAllChildren() + + self.lpane.ShowLoading() + sMarket = service.Market.getInstance() sMarket.getShipListDelayed(self.stage2Callback, categoryID) diff --git a/gui/utils/animUtils.py b/gui/utils/animUtils.py index a8e5265d7..c225d0b13 100644 --- a/gui/utils/animUtils.py +++ b/gui/utils/animUtils.py @@ -23,6 +23,16 @@ class LoadAnimation(wx.Window): self.animTimer.Start(self.animTimerPeriod) + def Play(self): + if self.animTimer.IsRunning(): + self.animTimer.Stop() + self.animCount = 0 + self.animTimer.Start(self.animTimerPeriod) + + def Stop(self): + if self.animTimer.IsRunning(): + self.animTimer.Stop() + def OnTimer(self, event): self.animCount += self.animDir