Repository: napari/napari

Issue:
Visual Bug: Labels Layer Controls get squished when toggling 3D
## 🐛 Bug

When toggling to 3D, the labels layer Layer Controls widget gains an extra line `rendering`.
However the widget doesn't resize for this, so it results in a visual bug of everything squished and partially cut off:
<img width="267" alt="image" src="https://user-images.githubusercontent.com/76622105/212083289-a7333963-f66a-4875-bd11-e49965ef7a77.png">

If you manually expand the widget, it will look fine. However, in contrast to the 2D version of the widget, it will let you resize it vertically to be too small, squishing the contents again.

## To Reproduce

Steps to reproduce the behavior:

1. open napari
2. make a labels layer (can be empty)
3. toggle 3D

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

The widget should either resize to permit the extra line item or start out sufficiently large that when the line item is added the visual isn't squished.

## Environment

macOS 13.1, pyqt5, 0.4.17

## Additional context

<!-- Add any other context about the problem here. -->



Discussion:
Hi, I think this is related to https://github.com/napari/napari/issues/2337 I was checking it and seems like the issue is caused due to setting a `min-width` `and min-height` to the layers controls container at https://github.com/napari/napari/blob/4f1f6a0979b0489b566aed64008da493c3180ac9/napari/_qt/qt_resources/styles/02_custom.qss#L274-L275

I think removing that and instead setting it for the empty widget the container widget creates could help with this and https://github.com/napari/napari/issues/2337 (that will enable for the container widget to resize depending on its contents). Something like this:

```
QFrame#empty_controls_widget {
    min-height: 295px;
    min-width: 240px;
}

QtLayerControlsContainer {
    border-radius: 2px;
    padding: 0px;
    margin: 10px;
    margin-left: 10px;
    margin-right: 8px;
    margin-bottom: 4px;
}
```

With those changes this is the behavior on Windows:

![resize](https://user-images.githubusercontent.com/16781833/212141918-9867f93f-67ed-406b-9eaa-eee5b5094371.gif)


Resolving patch:
diff --git a/napari/_qt/layer_controls/qt_layer_controls_container.py b/napari/_qt/layer_controls/qt_layer_controls_container.py
--- a/napari/_qt/layer_controls/qt_layer_controls_container.py
+++ b/napari/_qt/layer_controls/qt_layer_controls_container.py
@@ -101,6 +101,7 @@ def __init__(self, viewer):
 
         self.setMouseTracking(True)
         self.empty_widget = QFrame()
+        self.empty_widget.setObjectName("empty_controls_widget")
         self.widgets = {}
         self.addWidget(self.empty_widget)
         self.setCurrentWidget(self.empty_widget)


Test patch:
diff --git a/napari/_qt/_tests/test_qt_notifications.py b/napari/_qt/_tests/test_qt_notifications.py
--- a/napari/_qt/_tests/test_qt_notifications.py
+++ b/napari/_qt/_tests/test_qt_notifications.py
@@ -13,7 +13,7 @@
     NapariQtNotification,
     TracebackDialog,
 )
-from napari._tests.utils import DEFAULT_TIMEOUT_SECS
+from napari._tests.utils import DEFAULT_TIMEOUT_SECS, skip_on_win_ci
 from napari.utils.notifications import (
     ErrorNotification,
     Notification,
@@ -267,6 +267,7 @@ def test_notification_error(count_show, monkeypatch):
     assert count_show.show_traceback_count == 1
 
 
+@skip_on_win_ci
 @pytest.mark.sync_only
 def test_notifications_error_with_threading(
     make_napari_viewer, clean_current, monkeypatch
diff --git a/napari/_qt/_tests/test_qt_provide_theme.py b/napari/_qt/_tests/test_qt_provide_theme.py
--- a/napari/_qt/_tests/test_qt_provide_theme.py
+++ b/napari/_qt/_tests/test_qt_provide_theme.py
@@ -6,10 +6,12 @@
 
 from napari import Viewer
 from napari._qt import Window
+from napari._tests.utils import skip_on_win_ci
 from napari.settings import get_settings
 from napari.utils.theme import Theme, get_theme
 
 
+@skip_on_win_ci
 @patch.object(Window, "_remove_theme")
 @patch.object(Window, "_add_theme")
 def test_provide_theme_hook_registered_correctly(
diff --git a/napari/_qt/_tests/test_qt_viewer.py b/napari/_qt/_tests/test_qt_viewer.py
--- a/napari/_qt/_tests/test_qt_viewer.py
+++ b/napari/_qt/_tests/test_qt_viewer.py
@@ -515,6 +515,7 @@ def test_memory_leaking(qtbot, make_napari_viewer):
     assert labels() is None
 
 
+@skip_on_win_ci
 @skip_local_popups
 def test_leaks_image(qtbot, make_napari_viewer):
 
@@ -530,6 +531,7 @@ def test_leaks_image(qtbot, make_napari_viewer):
     assert not dr()
 
 
+@skip_on_win_ci
 @skip_local_popups
 def test_leaks_labels(qtbot, make_napari_viewer):
     viewer = make_napari_viewer(show=True)
diff --git a/napari/layers/image/experimental/_tests/test_octree_import.py b/napari/layers/image/experimental/_tests/test_octree_import.py
--- a/napari/layers/image/experimental/_tests/test_octree_import.py
+++ b/napari/layers/image/experimental/_tests/test_octree_import.py
@@ -2,6 +2,8 @@
 import subprocess
 import sys
 
+from napari._tests.utils import skip_on_win_ci
+
 CREATE_VIEWER_SCRIPT = """
 import numpy as np
 import napari
@@ -9,6 +11,7 @@
 """
 
 
+@skip_on_win_ci
 def test_octree_import():
     """Test we can create a viewer with NAPARI_OCTREE."""