Added InfiniteLine.setHoverPen
This commit is contained in:
parent
f30c1a59d1
commit
6a4a653989
@ -52,6 +52,7 @@ pyqtgraph-0.9.9 [unreleased]
|
|||||||
- Added 'stepMode' argument to PlotDataItem()
|
- Added 'stepMode' argument to PlotDataItem()
|
||||||
- Added ViewBox.invertX()
|
- Added ViewBox.invertX()
|
||||||
- Docks now have optional close button
|
- Docks now have optional close button
|
||||||
|
- Added InfiniteLine.setHoverPen
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- PlotCurveItem now has correct clicking behavior--clicks within a few px
|
- PlotCurveItem now has correct clicking behavior--clicks within a few px
|
||||||
|
@ -59,7 +59,9 @@ class InfiniteLine(GraphicsObject):
|
|||||||
|
|
||||||
if pen is None:
|
if pen is None:
|
||||||
pen = (200, 200, 100)
|
pen = (200, 200, 100)
|
||||||
|
|
||||||
self.setPen(pen)
|
self.setPen(pen)
|
||||||
|
self.setHoverPen(color=(255,0,0), width=self.pen.width())
|
||||||
self.currentPen = self.pen
|
self.currentPen = self.pen
|
||||||
#self.setFlag(self.ItemSendsScenePositionChanges)
|
#self.setFlag(self.ItemSendsScenePositionChanges)
|
||||||
|
|
||||||
@ -77,8 +79,22 @@ class InfiniteLine(GraphicsObject):
|
|||||||
"""Set the pen for drawing the line. Allowable arguments are any that are valid
|
"""Set the pen for drawing the line. Allowable arguments are any that are valid
|
||||||
for :func:`mkPen <pyqtgraph.mkPen>`."""
|
for :func:`mkPen <pyqtgraph.mkPen>`."""
|
||||||
self.pen = fn.mkPen(*args, **kwargs)
|
self.pen = fn.mkPen(*args, **kwargs)
|
||||||
self.currentPen = self.pen
|
if not self.mouseHovering:
|
||||||
self.update()
|
self.currentPen = self.pen
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def setHoverPen(self, *args, **kwargs):
|
||||||
|
"""Set the pen for drawing the line while the mouse hovers over it.
|
||||||
|
Allowable arguments are any that are valid
|
||||||
|
for :func:`mkPen <pyqtgraph.mkPen>`.
|
||||||
|
|
||||||
|
If the line is not movable, then hovering is also disabled.
|
||||||
|
|
||||||
|
Added in version 0.9.9."""
|
||||||
|
self.hoverPen = fn.mkPen(*args, **kwargs)
|
||||||
|
if self.mouseHovering:
|
||||||
|
self.currentPen = self.hoverPen
|
||||||
|
self.update()
|
||||||
|
|
||||||
def setAngle(self, angle):
|
def setAngle(self, angle):
|
||||||
"""
|
"""
|
||||||
@ -168,8 +184,9 @@ class InfiniteLine(GraphicsObject):
|
|||||||
px = self.pixelLength(direction=Point(1,0), ortho=True) ## get pixel length orthogonal to the line
|
px = self.pixelLength(direction=Point(1,0), ortho=True) ## get pixel length orthogonal to the line
|
||||||
if px is None:
|
if px is None:
|
||||||
px = 0
|
px = 0
|
||||||
br.setBottom(-px*4)
|
w = (max(4, self.pen.width()/2, self.hoverPen.width()/2)+1) * px
|
||||||
br.setTop(px*4)
|
br.setBottom(-w)
|
||||||
|
br.setTop(w)
|
||||||
return br.normalized()
|
return br.normalized()
|
||||||
|
|
||||||
def paint(self, p, *args):
|
def paint(self, p, *args):
|
||||||
@ -184,25 +201,6 @@ class InfiniteLine(GraphicsObject):
|
|||||||
else:
|
else:
|
||||||
return (0,0)
|
return (0,0)
|
||||||
|
|
||||||
#def mousePressEvent(self, ev):
|
|
||||||
#if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
|
||||||
#ev.accept()
|
|
||||||
#self.pressDelta = self.mapToParent(ev.pos()) - QtCore.QPointF(*self.p)
|
|
||||||
#else:
|
|
||||||
#ev.ignore()
|
|
||||||
|
|
||||||
#def mouseMoveEvent(self, ev):
|
|
||||||
#self.setPos(self.mapToParent(ev.pos()) - self.pressDelta)
|
|
||||||
##self.emit(QtCore.SIGNAL('dragged'), self)
|
|
||||||
#self.sigDragged.emit(self)
|
|
||||||
#self.hasMoved = True
|
|
||||||
|
|
||||||
#def mouseReleaseEvent(self, ev):
|
|
||||||
#if self.hasMoved and ev.button() == QtCore.Qt.LeftButton:
|
|
||||||
#self.hasMoved = False
|
|
||||||
##self.emit(QtCore.SIGNAL('positionChangeFinished'), self)
|
|
||||||
#self.sigPositionChangeFinished.emit(self)
|
|
||||||
|
|
||||||
def mouseDragEvent(self, ev):
|
def mouseDragEvent(self, ev):
|
||||||
if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
||||||
if ev.isStart():
|
if ev.isStart():
|
||||||
@ -239,12 +237,12 @@ class InfiniteLine(GraphicsObject):
|
|||||||
self.setMouseHover(False)
|
self.setMouseHover(False)
|
||||||
|
|
||||||
def setMouseHover(self, hover):
|
def setMouseHover(self, hover):
|
||||||
## Inform the item that the mouse is(not) hovering over it
|
## Inform the item that the mouse is (not) hovering over it
|
||||||
if self.mouseHovering == hover:
|
if self.mouseHovering == hover:
|
||||||
return
|
return
|
||||||
self.mouseHovering = hover
|
self.mouseHovering = hover
|
||||||
if hover:
|
if hover:
|
||||||
self.currentPen = fn.mkPen(255, 0,0)
|
self.currentPen = self.hoverPen
|
||||||
else:
|
else:
|
||||||
self.currentPen = self.pen
|
self.currentPen = self.pen
|
||||||
self.update()
|
self.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user