More drop shadow effects in shipbrowser

This commit is contained in:
HomeWorld
2011-06-08 19:43:11 +03:00
parent 0d69ae966c
commit c3c07c0a45
3 changed files with 13 additions and 8 deletions

View File

@@ -17,7 +17,8 @@ class PFBaseButton(object):
def __init__(self, normalBitmap = wx.NullBitmap,label = "", callback = None, hoverBitmap = None, disabledBitmap = None, show = True):
self.normalBmp = normalBitmap
self.dropShadowBmp = self.CreateDropShadowBitmap()
self.dropShadowOpacity = 0.2
self.dropShadowBmp = drawUtils.CreateDropShadowBitmap(self.normalBmp, self.dropShadowOpacity)
self.hoverBmp = hoverBitmap
self.disabledBmp = disabledBitmap
self.label = label
@@ -63,7 +64,7 @@ class PFBaseButton(object):
def SetBitmap(self, bitmap):
self.normalBmp = bitmap
self.dropShadowBmp = self.CreateDropShadowBitmap()
self.dropShadowBmp = drawUtils.CreateDropShadowBitmap(self.normalBmp, self.dropShadowOpacity)
def GetLabel(self):
return self.label
@@ -78,11 +79,6 @@ class PFBaseButton(object):
return self.normalBmp
return self.disabledBmp
def CreateDropShadowBitmap(self):
img = wx.ImageFromBitmap(self.normalBmp)
img = img.AdjustChannels(0, 0, 0, 0.2)
return wx.BitmapFromImage(img)
def GetDropShadowBitmap(self):
return self.dropShadowBmp

View File

@@ -867,6 +867,8 @@ class CategoryItem(SFItem.SFBrowserItem):
else:
self.shipBmp = wx.EmptyBitmap(16,16)
self.dropShadowBitmap = drawUtils.CreateDropShadowBitmap(self.shipBmp, 0.2)
self.categoryID = categoryID
self.fittingInfo = fittingInfo
self.shipBrowser = self.Parent.Parent
@@ -942,7 +944,7 @@ class CategoryItem(SFItem.SFBrowserItem):
textColor = colorUtils.GetSuitableColor(windowColor, 1)
mdc.SetTextForeground(textColor)
mdc.DrawBitmap(self.dropShadowBitmap, self.shipBmpx + 1, self.shipBmpy + 1)
mdc.DrawBitmap(self.shipBmp,self.shipBmpx,self.shipBmpy,0)
mdc.SetFont(self.fontBig)
@@ -1010,6 +1012,7 @@ class ShipItem(SFItem.SFBrowserItem):
self.shipEffBkMirrored = wx.BitmapFromImage(img)
self.raceBmp = bitmapLoader.getBitmap("race_%s_small" % self.shipRace, "icons")
self.raceDropShadowBmp = drawUtils.CreateDropShadowBitmap(self.raceBmp, 0.2)
if self.shipName == "Apotheosis":
self.raceMBmp = bitmapLoader.getBitmap("race_jove_small","icons")
@@ -1197,6 +1200,7 @@ class ShipItem(SFItem.SFBrowserItem):
mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0)
mdc.DrawBitmap(self.raceDropShadowBmp, self.raceBmpx + 1, self.raceBmpy + 1)
mdc.DrawBitmap(self.raceBmp,self.raceBmpx, self.raceBmpy)
shipName, fittings = self.shipFittingInfo

View File

@@ -98,3 +98,8 @@ def GetRoundBitmap( w, h, r ):
def GetRoundShape( w, h, r ):
return wx.RegionFromBitmap( GetRoundBitmap(w,h,r) )
def CreateDropShadowBitmap(bitmap, opacity):
img = wx.ImageFromBitmap(bitmap)
img = img.AdjustChannels(0, 0, 0, opacity)
return wx.BitmapFromImage(img)