From 4f15ce346bd0dc3c7b99c30214c034363ee0cef1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Sep 2022 13:51:37 -0400 Subject: [PATCH] Drop splitter resizes except for once at startup Also adds a `GodWidget.resize_all()` helper method which resizes all sub-widgets and charts to their default ratios and/or parent-widget dependent defaults using the detected available space on screen. This is a "default layout" config method that eventually we'll probably want allow users to customize. --- piker/ui/_chart.py | 22 ++++++++++++++-------- piker/ui/_display.py | 12 ++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 575e6286..eb76112f 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -292,11 +292,6 @@ class GodWidget(QWidget): if hist_chart: hist_chart.qframe.set_sidepane(self.search) - # NOTE: this resizes the fast chart as well as all it's - # downstream fsp subcharts AND the slow chart which is part of - # the same splitter. - self.rt_linked.set_split_sizes() - # set window titlebar info symbol = self.rt_linked.symbol if symbol is not None: @@ -356,6 +351,19 @@ class GodWidget(QWidget): for linked in [self.hist_linked, self.rt_linked]: yield linked + def resize_all(self) -> None: + ''' + Dynamic resize sequence: adjusts all sub-widgets/charts to + sensible default ratios of what space is detected as available + on the display / window. + + ''' + rt_linked = self.rt_linked + rt_linked.set_split_sizes() + self.rt_linked.resize_sidepanes() + self.hist_linked.resize_sidepanes(from_linked=rt_linked) + self.search.on_resize() + class ChartnPane(QFrame): ''' @@ -488,7 +496,7 @@ class LinkedSplits(QWidget): prop = 3/8 h = self.height() - histview_h = h * ((6/16) ** 2) + histview_h = h * (6/16) * 0.666 h = h - histview_h major = 1 - prop @@ -740,8 +748,6 @@ class LinkedSplits(QWidget): anchor_at=anchor_at, ) - # scale split regions - self.set_split_sizes() self.resize_sidepanes() return cpw diff --git a/piker/ui/_display.py b/piker/ui/_display.py index 3edf8b20..ada76f01 100644 --- a/piker/ui/_display.py +++ b/piker/ui/_display.py @@ -979,6 +979,8 @@ async def display_symbol_data( # rt_linked.splitter.addWidget(hist_linked) rt_linked.focus() + godwidget.resize_all() + vlm_chart: Optional[ChartPlotWidget] = None async with trio.open_nursery() as ln: @@ -1027,6 +1029,8 @@ async def display_symbol_data( hist_linked.graphics_cycle() await trio.sleep(0) + godwidget.resize_all() + async with ( open_order_mode( feed, @@ -1042,9 +1046,9 @@ async def display_symbol_data( # let Qt run to render all widgets and make sure the # sidepanes line up vertically. await trio.sleep(0) - rt_linked.resize_sidepanes() - rt_linked.set_split_sizes() - hist_linked.resize_sidepanes(from_linked=rt_linked) + + # dynamic resize steps + godwidget.resize_all() # TODO: look into this because not sure why it was # commented out / we ever needed it XD @@ -1067,7 +1071,7 @@ async def display_symbol_data( # push it 1/16th away from the y-axis y_offset=round(bars_in_mem / 16), ) - rt_linked.set_split_sizes() + godwidget.resize_all() # let the app run.. bby await trio.sleep_forever()