Skip to content

macOS Fixes #2346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gui/bitmap_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ def loadBitmap(cls, name, location):
if img is None:
pyfalog.warning("Missing icon file: {0}/{1}".format(location, filename))
return None
return BitmapLoader.getScaledBitmap(image=img, scale=scale)

bmp: wx.Bitmap = img.ConvertToBitmap()
@staticmethod
def getScaledBitmap(image: wx.Image, scale: int) -> wx.Bitmap:
if scale > 1:
bmp.SetSize((bmp.GetWidth() // scale, bmp.GetHeight() // scale))
return bmp
image.Rescale(image.GetWidth() // scale, image.GetHeight() // scale)
return image.ConvertToBitmap()

@classmethod
def loadScaledBitmap(cls, name, location, scale=0):
Expand Down
19 changes: 14 additions & 5 deletions gui/builtinShipBrowser/fitItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ def MouseMove(self, event):
if self.dragMotionTrigger < 0:
if not self.HasCapture():
self.CaptureMouse()
self._updateDragBitmap()
self.dragWindow = PFBitmapFrame(self, pos, self.dragTLFBmp)
self.dragWindow.Show()
self.dragged = True
Expand All @@ -430,6 +431,18 @@ def MouseMove(self, event):
self.dragWindow.SetPosition(pos)
return

def _updateDragBitmap(self):
dc = wx.ClientDC(self)
bufferedDC = wx.BufferedDC(dc)
self.DrawItem(dc)

rect = self.GetRect()
tdc = wx.MemoryDC()
self.dragTLFBmp = wx.Bitmap((self.toolbarx if self.toolbarx < 200 else 200), rect.height, 24)
tdc.SelectObject(self.dragTLFBmp)
tdc.Blit(0, 0, (self.toolbarx if self.toolbarx < 200 else 200), rect.height, bufferedDC, 0, 0, wx.COPY)
tdc.SelectObject(wx.NullBitmap)

def selectFit(self, event=None, newTab=False):
if newTab:
wx.PostEvent(self.mainFrame, FitSelected(fitID=self.fitID, startup=2))
Expand Down Expand Up @@ -477,6 +490,7 @@ def UpdateElementsPos(self, mdc):
self.thoverw = wlabel

def DrawItem(self, mdc):
self.dragTLFBmp = None
rect = self.GetRect()

windowColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
Expand Down Expand Up @@ -519,11 +533,6 @@ def DrawItem(self, mdc):
if self.tcFitName.IsShown():
self.AdjustControlSizePos(self.tcFitName, self.textStartx, self.toolbarx - self.editWidth - self.padding)

tdc = wx.MemoryDC()
self.dragTLFBmp = wx.Bitmap((self.toolbarx if self.toolbarx < 200 else 200), rect.height, 24)
tdc.SelectObject(self.dragTLFBmp)
tdc.Blit(0, 0, (self.toolbarx if self.toolbarx < 200 else 200), rect.height, mdc, 0, 0, wx.COPY)
tdc.SelectObject(wx.NullBitmap)

def AdjustControlSizePos(self, editCtl, start, end):
fnEditSize = editCtl.GetSize()
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
wxPython == 4.0.6
wxPython == 4.1.1
logbook >= 1.0.0
numpy == 1.19.2
matplotlib == 3.2.2
numpy == 1.20.2
matplotlib == 3.4.1
python-dateutil
requests >= 2.0.0
sqlalchemy == 1.3.23
Expand Down