Use QPointF instead of QPoint for float input
This commit is contained in:
parent
f853d8b520
commit
955f1c37a6
|
@ -54,9 +54,12 @@ class JoystickButton(QtGui.QPushButton):
|
||||||
d = (d / self.radius) ** 2
|
d = (d / self.radius) ** 2
|
||||||
xy = [nxy[0] * d, nxy[1] * d]
|
xy = [nxy[0] * d, nxy[1] * d]
|
||||||
|
|
||||||
w2 = self.width()/2.
|
w2 = self.width() / 2
|
||||||
h2 = self.height() / 2
|
h2 = self.height() / 2
|
||||||
self.spotPos = QtCore.QPoint(w2*(1+xy[0]), h2*(1-xy[1]))
|
self.spotPos = QtCore.QPoint(
|
||||||
|
int(w2 * (1 + xy[0])),
|
||||||
|
int(h2 * (1 - xy[1]))
|
||||||
|
)
|
||||||
self.update()
|
self.update()
|
||||||
if self.state == xy:
|
if self.state == xy:
|
||||||
return
|
return
|
||||||
|
@ -67,7 +70,12 @@ class JoystickButton(QtGui.QPushButton):
|
||||||
super().paintEvent(ev)
|
super().paintEvent(ev)
|
||||||
p = QtGui.QPainter(self)
|
p = QtGui.QPainter(self)
|
||||||
p.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0)))
|
p.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0)))
|
||||||
p.drawEllipse(self.spotPos.x()-3,self.spotPos.y()-3,6,6)
|
p.drawEllipse(
|
||||||
|
self.spotPos.x() - 3,
|
||||||
|
self.spotPos.y() - 3,
|
||||||
|
6,
|
||||||
|
6
|
||||||
|
)
|
||||||
|
|
||||||
def resizeEvent(self, ev):
|
def resizeEvent(self, ev):
|
||||||
self.setState(*self.state)
|
self.setState(*self.state)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user