Skip to content

Commit 3f5b314

Browse files
committed
Update range selection items to display handles only when resizable
1 parent eae35f7 commit 3f5b314

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
* Setting item movable state now also sets the resizable state:
4242
* The PlotPy event system won't prevent the user from moving the item by dragging the handles if the item is just not movable: it has to be not resizable, which is not intuitive.
4343
* This is now fixed
44+
* Range selection items (`XRangeSelection`, `YRangeSelection`):
45+
* Handles are now displayed only when the item is resizable
46+
* If the item is set as not resizable (using the `set_resizable` method), the handles will be hidden
4447

4548
Other changes:
4649

plotpy/items/shape/range.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,11 @@ def draw(
318318
cx = rct.center().x()
319319
painter.drawLine(QC.QPointF(cx, rct.top()), QC.QPointF(cx, rct.bottom()))
320320

321-
painter.setPen(pen)
322-
x0, x1, y = self.get_handles_pos()
323-
sym.drawSymbol(painter, QC.QPointF(x0, y))
324-
sym.drawSymbol(painter, QC.QPointF(x1, y))
321+
if self.can_resize():
322+
painter.setPen(pen)
323+
x0, x1, y = self.get_handles_pos()
324+
sym.drawSymbol(painter, QC.QPointF(x0, y))
325+
sym.drawSymbol(painter, QC.QPointF(x1, y))
325326

326327
def hit_test(self, pos: QPointF) -> tuple[float, float, bool, None]:
327328
"""Return a tuple (distance, attach point, inside, other_object)
@@ -479,10 +480,11 @@ def draw(
479480
cy = rct.center().y()
480481
painter.drawLine(QC.QPointF(rct.left(), cy), QC.QPointF(rct.right(), cy))
481482

482-
painter.setPen(pen)
483-
y0, y1, x = self.get_handles_pos()
484-
sym.drawSymbol(painter, QC.QPointF(x, y0))
485-
sym.drawSymbol(painter, QC.QPointF(x, y1))
483+
if self.can_resize():
484+
painter.setPen(pen)
485+
y0, y1, x = self.get_handles_pos()
486+
sym.drawSymbol(painter, QC.QPointF(x, y0))
487+
sym.drawSymbol(painter, QC.QPointF(x, y1))
486488

487489
def hit_test(self, pos: QPointF) -> tuple[float, float, bool, None]:
488490
"""Return a tuple (distance, attach point, inside, other_object)

0 commit comments

Comments
 (0)