From 1a870364c5bf469ed469ea7012bff93926d13eb8 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 17 Jul 2021 16:17:36 -0400 Subject: [PATCH] Add label location description param for graphics path anchor --- piker/ui/_anchors.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/piker/ui/_anchors.py b/piker/ui/_anchors.py index 5d3a17f3..b04ea54a 100644 --- a/piker/ui/_anchors.py +++ b/piker/ui/_anchors.py @@ -158,16 +158,26 @@ def update_pp_nav( label.update() -def path_topright( +def gpath_pin( + gpath: QGraphicsPathItem, label: Label, # noqa + location_description: str = 'right-of-path-centered', + use_right_of_pp_label: bool = False, + ) -> QPointF: + # get actual arrow graphics path - path_br = gpath.mapToScene( - gpath.path() - ).boundingRect() + path_br = gpath.mapToScene(gpath.path()).boundingRect() # vb.locate(arrow_path) #, children=True) - return path_br.topRight() - QPointF(0, label.h / 3) + if location_description == 'right-of-path-centered': + return path_br.topRight() - QPointF(0, label.h / 3) + + elif location_description == 'below-path-left-aligned': + return path_br.bottomLeft() - QPointF(0, label.h / 6) + + elif location_description == 'below-path-right-aligned': + return path_br.bottomRight() - QPointF(label.w, label.h / 6)