Fix HiDPI scaling issues in VectorPicker
VectorPicker was DPI unware, so when asking GetClientSize() it would get the actual size multiplied by the scaling factor of GetContentScaleFactor(). This made the widget seem to be cut off and display only the upper left quarter of the circle. Similarly, when choosing the font size for the percentages, it wouldn't scale the maximum size, resulting in very large text.
This commit is contained in:
@@ -36,9 +36,9 @@ class VectorPicker(wx.Window):
|
||||
self._labelpos = int(kwargs.pop('labelpos', 0))
|
||||
self._offset = float(kwargs.pop('offset', 0))
|
||||
self._size = max(0, float(kwargs.pop('size', 50)))
|
||||
self._fontsize = max(1, float(kwargs.pop('fontsize', 8)))
|
||||
self._directionOnly = kwargs.pop('directionOnly', False)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._fontsize = max(1, float(kwargs.pop('fontsize', 8 / self.GetContentScaleFactor())))
|
||||
self._font = wx.Font(self._fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
|
||||
self._angle = 0
|
||||
self.__length = 1
|
||||
@@ -107,8 +107,11 @@ class VectorPicker(wx.Window):
|
||||
dc = wx.BufferedPaintDC(self)
|
||||
self.Draw(dc)
|
||||
|
||||
def GetScaledClientSize(self):
|
||||
return tuple([dim / self.GetContentScaleFactor() for dim in self.GetClientSize()])
|
||||
|
||||
def Draw(self, dc):
|
||||
width, height = self.GetClientSize()
|
||||
width, height = self.GetScaledClientSize()
|
||||
if not width or not height:
|
||||
return
|
||||
dc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.BRUSHSTYLE_SOLID))
|
||||
|
||||
Reference in New Issue
Block a user