Skip to content

Commit d419145

Browse files
xiao-1011claude
andauthored
Equalize dock zone sizes on startup (#265)
* Fix unit visibility change not propagating to other views `get_visible_unit_ids()` returned a direct reference to the internal `_visible_unit_ids` list. Callers that snapshot the list before and after `set_unit_visibility()` to detect changes were comparing the same mutated object, so the comparison always found no difference and never triggered `notify_unit_visibility_changed()`. Return a copy instead so before/after comparisons work correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Equalize dock zone sizes on startup Dock widgets created by splitDockWidget() have uneven default sizes. Add a showEvent hook that calls resizeDocks() with equal weights after the window is visible, so all zones start proportionally sized. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Use processEvents instead of timer for dock equalization Replace QTimer.singleShot(100ms) hack with QApplication.processEvents() to flush pending layout events synchronously before calling resizeDocks. Deterministic and avoids arbitrary delay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix dock equalization not working on macOS Replace synchronous processEvents() + resizeDocks() with a deferred QTimer.singleShot(0) call. On macOS, the Cocoa window system performs a layout pass after Qt's showEvent, overwriting sizes set synchronously. The deferred call ensures resizeDocks runs after the native layout completes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5186578 commit d419145

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

spikeinterface_gui/backend_qt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ def create_main_layout(self):
255255
# make visible the first of each zone
256256
self.docks[view_name0].raise_()
257257

258+
def showEvent(self, event):
259+
super().showEvent(event)
260+
if not hasattr(self, '_splitters_equalized'):
261+
self._splitters_equalized = True
262+
# On macOS, the native Cocoa window system performs a layout pass after
263+
# Qt's showEvent, overwriting any sizes set synchronously. A deferred
264+
# call via QTimer.singleShot ensures resizeDocks runs after both Qt and
265+
# the macOS window server have finished laying out the docks.
266+
QT.QTimer.singleShot(0, self._equalize_dock_sizes)
267+
268+
def _equalize_dock_sizes(self):
269+
all_docks = [dock for dock in self.docks.values() if dock.isVisible()]
270+
if all_docks:
271+
size_weight = 1
272+
self.resizeDocks(all_docks, [size_weight] * len(all_docks), QT.Qt.Horizontal)
273+
self.resizeDocks(all_docks, [size_weight] * len(all_docks), QT.Qt.Vertical)
274+
258275
def make_half_layout(self, widgets_zone, left_or_right):
259276
"""
260277
Function contains the logic for the greedy layout. Given the 2x2 box of zones

0 commit comments

Comments
 (0)