diff --git a/piker/tsp/_annotate.py b/piker/tsp/_annotate.py index fa9f04c3..c2c6e9a1 100644 --- a/piker/tsp/_annotate.py +++ b/piker/tsp/_annotate.py @@ -30,6 +30,7 @@ import tractor from piker.data._formatters import BGM from piker.storage import log +# from piker.ui._style import _font if TYPE_CHECKING: from piker.ui._remote_ctl import AnnotCtl @@ -236,6 +237,14 @@ async def markup_gaps( else: # down-gap anchor = (0, 1) # XXX y, x? + # ?TODO? why returning -1 !? + # [ ] use conf.toml value instead! + # + # font_size: int = _font.font.pixelSize() - 10 + # await tractor.pause() + # assert isinstance(font_size, int) + font_size = None + text_aid: int = await actl.add_text( fqme=fqme, timeframe=timeframe, @@ -244,6 +253,7 @@ async def markup_gaps( y=cls, color=color, anchor=anchor, + font_size=font_size, ) aids[text_aid] = {'text': gap_label} diff --git a/piker/ui/_remote_ctl.py b/piker/ui/_remote_ctl.py index ccea90e1..0fb2f2b7 100644 --- a/piker/ui/_remote_ctl.py +++ b/piker/ui/_remote_ctl.py @@ -48,8 +48,8 @@ from piker.service import find_service from piker.brokers import SymbolNotFound from piker.ui.qt import ( QGraphicsItem, - QColor, ) +from PyQt6.QtGui import QFont from ._display import DisplayState from ._interaction import ChartView from ._editors import ( @@ -248,6 +248,7 @@ async def serve_rc_annots( 'y': int()|float() as y, 'color': color, 'anchor': list(anchor), + 'font_size': int()|None as font_size, }, }: ds: DisplayState = _dss[fqme] @@ -264,7 +265,22 @@ async def serve_rc_annots( text=text, color=color_hex, anchor=anchor, + + # ?TODO, pin to github:main for this? + # legacy, can have scaling ish? + # ensureInBounds=True, ) + + # apply font size (default to DpiAwareFont if not + # provided) + if font_size is None: + from ._style import _font + font_size = _font.font.pixelSize() - 3 + + qfont: QFont = text_item.textItem.font() + qfont.setPixelSize(font_size) + text_item.setFont(qfont) + text_item.setPos(x, y) chart.plotItem.addItem(text_item) @@ -547,6 +563,7 @@ class AnnotCtl(Struct): y: float, color: str|tuple = 'dad_blue', anchor: tuple[float, float] = (0, 1), + font_size: int|None = None, from_acm: bool = False, @@ -555,6 +572,7 @@ class AnnotCtl(Struct): Add a `pg.TextItem` annotation to the target view. anchor: (x, y) where (0,0) is upper-left, (1,1) is lower-right + font_size: pixel size for font, defaults to `_font.font.pixelSize()` ''' ipc: MsgStream = self._get_ipc(fqme) @@ -568,6 +586,7 @@ class AnnotCtl(Struct): 'y': float(y), 'color': color, 'anchor': tuple(anchor), + 'font_size': font_size, }, }) aid: int = await ipc.receive()