prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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. -->
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `napari/_qt/layer_controls/qt_layer_controls_container.py`
  Content:
  ```
  1 from qtpy.QtWidgets import QFrame, QStackedWidget
  2 
  3 from napari._qt.layer_controls.qt_image_controls import QtImageControls
  4 from napari._qt.layer_controls.qt_labels_controls import QtLabelsControls
  5 from napari._qt.layer_controls.qt_points_controls import QtPointsControls
  6 from napari._qt.layer_controls.qt_shapes_controls import QtShapesControls
  7 from napari._qt.layer_controls.qt_surface_controls import QtSurfaceControls
  8 from napari._qt.layer_controls.qt_tracks_controls import QtTracksControls
  9 from napari._qt.layer_controls.qt_vectors_controls import QtVectorsControls
  10 from napari.layers import (
  11     Image,
  12     Labels,
  13     Points,
  14     Shapes,
  15     Surface,
  16     Tracks,
  17     Vectors,
  18 )
  19 from napari.utils import config
  20 from napari.utils.translations import trans
  21 
  22 layer_to_controls = {
  23     Labels: QtLabelsControls,
  24     Image: QtImageControls,
  25     Points: QtPointsControls,
  26     Shapes: QtShapesControls,
  27     Surface: QtSurfaceControls,
  28     Vectors: QtVectorsControls,
  29     Tracks: QtTracksControls,
  30 }
  31 
  32 if config.async_loading:
  33     from napari.layers.image.experimental.octree_image import _OctreeImageBase
  34 
  35     # The user visible layer controls for OctreeImage layers are identical
  36     # to the regular image layer controls, for now.
  37     layer_to_controls[_OctreeImageBase] = QtImageControls
  38 
  39 
  40 def create_qt_layer_controls(layer):
  41     """
  42     Create a qt controls widget for a layer based on its layer type.
  43 
  44     In case of a subclass, the type higher in the layer's method resolution
  45     order will be used.
  46 
  47     Parameters
  48     ----------
  49     layer : napari.layers._base_layer.Layer
  50         Layer that needs its controls widget created.
  51 
  52     Returns
  53     -------
  54     controls : napari.layers.base.QtLayerControls
  55         Qt controls widget
  56     """
  57     candidates = []
  58     for layer_type in layer_to_controls:
  59         if isinstance(layer, layer_type):
  60             candidates.append(layer_type)
  61 
  62     if not candidates:
  63         raise TypeError(
  64             trans._(
  65                 'Could not find QtControls for layer of type {type_}',
  66                 deferred=True,
  67                 type_=type(layer),
  68             )
  69         )
  70 
  71     layer_cls = layer.__class__
  72     # Sort the list of candidates by 'lineage'
  73     candidates.sort(key=lambda layer_type: layer_cls.mro().index(layer_type))
  74     controls = layer_to_controls[candidates[0]]
  75     return controls(layer)
  76 
  77 
  78 class QtLayerControlsContainer(QStackedWidget):
  79     """Container widget for QtLayerControl widgets.
  80 
  81     Parameters
  82     ----------
  83     viewer : napari.components.ViewerModel
  84         Napari viewer containing the rendered scene, layers, and controls.
  85 
  86     Attributes
  87     ----------
  88     empty_widget : qtpy.QtWidgets.QFrame
  89         Empty placeholder frame for when no layer is selected.
  90     viewer : napari.components.ViewerModel
  91         Napari viewer containing the rendered scene, layers, and controls.
  92     widgets : dict
  93         Dictionary of key value pairs matching layer with its widget controls.
  94         widgets[layer] = controls
  95     """
  96 
  97     def __init__(self, viewer):
  98         super().__init__()
  99         self.setProperty("emphasized", True)
  100         self.viewer = viewer
  101 
  102         self.setMouseTracking(True)
  103         self.empty_widget = QFrame()
  104         self.widgets = {}
  105         self.addWidget(self.empty_widget)
  106         self.setCurrentWidget(self.empty_widget)
  107 
  108         self.viewer.layers.events.inserted.connect(self._add)
  109         self.viewer.layers.events.removed.connect(self._remove)
  110         viewer.layers.selection.events.active.connect(self._display)
  111 
  112     def _display(self, event):
  113         """Change the displayed controls to be those of the target layer.
  114 
  115         Parameters
  116         ----------
  117         event : Event
  118             Event with the target layer at `event.item`.
  119         """
  120         layer = event.value
  121         if layer is None:
  122             self.setCurrentWidget(self.empty_widget)
  123         else:
  124             controls = self.widgets[layer]
  125             self.setCurrentWidget(controls)
  126 
  127     def _add(self, event):
  128         """Add the controls target layer to the list of control widgets.
  129 
  130         Parameters
  131         ----------
  132         event : Event
  133             Event with the target layer at `event.value`.
  134         """
  135         layer = event.value
  136         controls = create_qt_layer_controls(layer)
  137         self.addWidget(controls)
  138         self.widgets[layer] = controls
  139 
  140     def _remove(self, event):
  141         """Remove the controls target layer from the list of control widgets.
  142 
  143         Parameters
  144         ----------
  145         event : Event
  146             Event with the target layer at `event.value`.
  147         """
  148         layer = event.value
  149         controls = self.widgets[layer]
  150         self.removeWidget(controls)
  151         # controls.close()
  152         controls.hide()
  153         controls.deleteLater()
  154         controls = None
  155         del self.widgets[layer]
  156
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: 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 @@
   
           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)
  
verification_info: {"golden_diff": "diff --git a/napari/_qt/layer_controls/qt_layer_controls_container.py b/napari/_qt/layer_controls/qt_layer_controls_container.py\n--- a/napari/_qt/layer_controls/qt_layer_controls_container.py\n+++ b/napari/_qt/layer_controls/qt_layer_controls_container.py\n@@ -101,6 +101,7 @@\n \n         self.setMouseTracking(True)\n         self.empty_widget = QFrame()\n+        self.empty_widget.setObjectName(\"empty_controls_widget\")\n         self.widgets = {}\n         self.addWidget(self.empty_widget)\n         self.setCurrentWidget(self.empty_widget)\n", "issue": "Visual Bug: Labels Layer Controls get squished when toggling 3D\n## \ud83d\udc1b Bug\r\n\r\nWhen toggling to 3D, the labels layer Layer Controls widget gains an extra line `rendering`.\r\nHowever the widget doesn't resize for this, so it results in a visual bug of everything squished and partially cut off:\r\n<img width=\"267\" alt=\"image\" src=\"https://user-images.githubusercontent.com/76622105/212083289-a7333963-f66a-4875-bd11-e49965ef7a77.png\">\r\n\r\nIf 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.\r\n\r\n## To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. open napari\r\n2. make a labels layer (can be empty)\r\n3. toggle 3D\r\n\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n\r\n## Expected behavior\r\n\r\nThe 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.\r\n\r\n## Environment\r\n\r\nmacOS 13.1, pyqt5, 0.4.17\r\n\r\n## Additional context\r\n\r\n<!-- Add any other context about the problem here. -->\r\n\n", "before_files": [{"content": "from qtpy.QtWidgets import QFrame, QStackedWidget\n\nfrom napari._qt.layer_controls.qt_image_controls import QtImageControls\nfrom napari._qt.layer_controls.qt_labels_controls import QtLabelsControls\nfrom napari._qt.layer_controls.qt_points_controls import QtPointsControls\nfrom napari._qt.layer_controls.qt_shapes_controls import QtShapesControls\nfrom napari._qt.layer_controls.qt_surface_controls import QtSurfaceControls\nfrom napari._qt.layer_controls.qt_tracks_controls import QtTracksControls\nfrom napari._qt.layer_controls.qt_vectors_controls import QtVectorsControls\nfrom napari.layers import (\n    Image,\n    Labels,\n    Points,\n    Shapes,\n    Surface,\n    Tracks,\n    Vectors,\n)\nfrom napari.utils import config\nfrom napari.utils.translations import trans\n\nlayer_to_controls = {\n    Labels: QtLabelsControls,\n    Image: QtImageControls,\n    Points: QtPointsControls,\n    Shapes: QtShapesControls,\n    Surface: QtSurfaceControls,\n    Vectors: QtVectorsControls,\n    Tracks: QtTracksControls,\n}\n\nif config.async_loading:\n    from napari.layers.image.experimental.octree_image import _OctreeImageBase\n\n    # The user visible layer controls for OctreeImage layers are identical\n    # to the regular image layer controls, for now.\n    layer_to_controls[_OctreeImageBase] = QtImageControls\n\n\ndef create_qt_layer_controls(layer):\n    \"\"\"\n    Create a qt controls widget for a layer based on its layer type.\n\n    In case of a subclass, the type higher in the layer's method resolution\n    order will be used.\n\n    Parameters\n    ----------\n    layer : napari.layers._base_layer.Layer\n        Layer that needs its controls widget created.\n\n    Returns\n    -------\n    controls : napari.layers.base.QtLayerControls\n        Qt controls widget\n    \"\"\"\n    candidates = []\n    for layer_type in layer_to_controls:\n        if isinstance(layer, layer_type):\n            candidates.append(layer_type)\n\n    if not candidates:\n        raise TypeError(\n            trans._(\n                'Could not find QtControls for layer of type {type_}',\n                deferred=True,\n                type_=type(layer),\n            )\n        )\n\n    layer_cls = layer.__class__\n    # Sort the list of candidates by 'lineage'\n    candidates.sort(key=lambda layer_type: layer_cls.mro().index(layer_type))\n    controls = layer_to_controls[candidates[0]]\n    return controls(layer)\n\n\nclass QtLayerControlsContainer(QStackedWidget):\n    \"\"\"Container widget for QtLayerControl widgets.\n\n    Parameters\n    ----------\n    viewer : napari.components.ViewerModel\n        Napari viewer containing the rendered scene, layers, and controls.\n\n    Attributes\n    ----------\n    empty_widget : qtpy.QtWidgets.QFrame\n        Empty placeholder frame for when no layer is selected.\n    viewer : napari.components.ViewerModel\n        Napari viewer containing the rendered scene, layers, and controls.\n    widgets : dict\n        Dictionary of key value pairs matching layer with its widget controls.\n        widgets[layer] = controls\n    \"\"\"\n\n    def __init__(self, viewer):\n        super().__init__()\n        self.setProperty(\"emphasized\", True)\n        self.viewer = viewer\n\n        self.setMouseTracking(True)\n        self.empty_widget = QFrame()\n        self.widgets = {}\n        self.addWidget(self.empty_widget)\n        self.setCurrentWidget(self.empty_widget)\n\n        self.viewer.layers.events.inserted.connect(self._add)\n        self.viewer.layers.events.removed.connect(self._remove)\n        viewer.layers.selection.events.active.connect(self._display)\n\n    def _display(self, event):\n        \"\"\"Change the displayed controls to be those of the target layer.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.item`.\n        \"\"\"\n        layer = event.value\n        if layer is None:\n            self.setCurrentWidget(self.empty_widget)\n        else:\n            controls = self.widgets[layer]\n            self.setCurrentWidget(controls)\n\n    def _add(self, event):\n        \"\"\"Add the controls target layer to the list of control widgets.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.value`.\n        \"\"\"\n        layer = event.value\n        controls = create_qt_layer_controls(layer)\n        self.addWidget(controls)\n        self.widgets[layer] = controls\n\n    def _remove(self, event):\n        \"\"\"Remove the controls target layer from the list of control widgets.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.value`.\n        \"\"\"\n        layer = event.value\n        controls = self.widgets[layer]\n        self.removeWidget(controls)\n        # controls.close()\n        controls.hide()\n        controls.deleteLater()\n        controls = None\n        del self.widgets[layer]\n", "path": "napari/_qt/layer_controls/qt_layer_controls_container.py"}], "after_files": [{"content": "from qtpy.QtWidgets import QFrame, QStackedWidget\n\nfrom napari._qt.layer_controls.qt_image_controls import QtImageControls\nfrom napari._qt.layer_controls.qt_labels_controls import QtLabelsControls\nfrom napari._qt.layer_controls.qt_points_controls import QtPointsControls\nfrom napari._qt.layer_controls.qt_shapes_controls import QtShapesControls\nfrom napari._qt.layer_controls.qt_surface_controls import QtSurfaceControls\nfrom napari._qt.layer_controls.qt_tracks_controls import QtTracksControls\nfrom napari._qt.layer_controls.qt_vectors_controls import QtVectorsControls\nfrom napari.layers import (\n    Image,\n    Labels,\n    Points,\n    Shapes,\n    Surface,\n    Tracks,\n    Vectors,\n)\nfrom napari.utils import config\nfrom napari.utils.translations import trans\n\nlayer_to_controls = {\n    Labels: QtLabelsControls,\n    Image: QtImageControls,\n    Points: QtPointsControls,\n    Shapes: QtShapesControls,\n    Surface: QtSurfaceControls,\n    Vectors: QtVectorsControls,\n    Tracks: QtTracksControls,\n}\n\nif config.async_loading:\n    from napari.layers.image.experimental.octree_image import _OctreeImageBase\n\n    # The user visible layer controls for OctreeImage layers are identical\n    # to the regular image layer controls, for now.\n    layer_to_controls[_OctreeImageBase] = QtImageControls\n\n\ndef create_qt_layer_controls(layer):\n    \"\"\"\n    Create a qt controls widget for a layer based on its layer type.\n\n    In case of a subclass, the type higher in the layer's method resolution\n    order will be used.\n\n    Parameters\n    ----------\n    layer : napari.layers._base_layer.Layer\n        Layer that needs its controls widget created.\n\n    Returns\n    -------\n    controls : napari.layers.base.QtLayerControls\n        Qt controls widget\n    \"\"\"\n    candidates = []\n    for layer_type in layer_to_controls:\n        if isinstance(layer, layer_type):\n            candidates.append(layer_type)\n\n    if not candidates:\n        raise TypeError(\n            trans._(\n                'Could not find QtControls for layer of type {type_}',\n                deferred=True,\n                type_=type(layer),\n            )\n        )\n\n    layer_cls = layer.__class__\n    # Sort the list of candidates by 'lineage'\n    candidates.sort(key=lambda layer_type: layer_cls.mro().index(layer_type))\n    controls = layer_to_controls[candidates[0]]\n    return controls(layer)\n\n\nclass QtLayerControlsContainer(QStackedWidget):\n    \"\"\"Container widget for QtLayerControl widgets.\n\n    Parameters\n    ----------\n    viewer : napari.components.ViewerModel\n        Napari viewer containing the rendered scene, layers, and controls.\n\n    Attributes\n    ----------\n    empty_widget : qtpy.QtWidgets.QFrame\n        Empty placeholder frame for when no layer is selected.\n    viewer : napari.components.ViewerModel\n        Napari viewer containing the rendered scene, layers, and controls.\n    widgets : dict\n        Dictionary of key value pairs matching layer with its widget controls.\n        widgets[layer] = controls\n    \"\"\"\n\n    def __init__(self, viewer):\n        super().__init__()\n        self.setProperty(\"emphasized\", True)\n        self.viewer = viewer\n\n        self.setMouseTracking(True)\n        self.empty_widget = QFrame()\n        self.empty_widget.setObjectName(\"empty_controls_widget\")\n        self.widgets = {}\n        self.addWidget(self.empty_widget)\n        self.setCurrentWidget(self.empty_widget)\n\n        self.viewer.layers.events.inserted.connect(self._add)\n        self.viewer.layers.events.removed.connect(self._remove)\n        viewer.layers.selection.events.active.connect(self._display)\n\n    def _display(self, event):\n        \"\"\"Change the displayed controls to be those of the target layer.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.item`.\n        \"\"\"\n        layer = event.value\n        if layer is None:\n            self.setCurrentWidget(self.empty_widget)\n        else:\n            controls = self.widgets[layer]\n            self.setCurrentWidget(controls)\n\n    def _add(self, event):\n        \"\"\"Add the controls target layer to the list of control widgets.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.value`.\n        \"\"\"\n        layer = event.value\n        controls = create_qt_layer_controls(layer)\n        self.addWidget(controls)\n        self.widgets[layer] = controls\n\n    def _remove(self, event):\n        \"\"\"Remove the controls target layer from the list of control widgets.\n\n        Parameters\n        ----------\n        event : Event\n            Event with the target layer at `event.value`.\n        \"\"\"\n        layer = event.value\n        controls = self.widgets[layer]\n        self.removeWidget(controls)\n        # controls.close()\n        controls.hide()\n        controls.deleteLater()\n        controls = None\n        del self.widgets[layer]\n", "path": "napari/_qt/layer_controls/qt_layer_controls_container.py"}]}