Skip to content

Commit 4cac077

Browse files
committed
Refactor color combos & add sizing behavior
Introduce a ShrinkCurrentWidePopupComboBox and ComboSizing to make combobox controls shrink to the current selection while the popup widens to fit the longest item. Add factory helpers (make_colormap_combo, make_bbox_color_combo) that create/populate colormap and bbox-color combos with sizing, icons, tooltips and safer Matplotlib handling. Rename/refactor colormap helpers (list_colormap_names, _safe_mpl_colormaps_registry), improve gradient icon creation, and preserve editable behavior if Matplotlib is unavailable. Update main_window to use the new factories, pass sizing and icon options, and adjust key widths for layout consistency.
1 parent 38005ab commit 4cac077

2 files changed

Lines changed: 271 additions & 117 deletions

File tree

dlclivegui/gui/main_window.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -632,24 +632,22 @@ def _build_viz_group(self) -> QGroupBox:
632632
self.show_predictions_checkbox = QCheckBox("Display pose predictions")
633633
self.show_predictions_checkbox.setChecked(True)
634634

635-
self.cmap_combo = QComboBox()
636-
self.cmap_combo.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
637-
self.cmap_combo.setToolTip("Select colormap to use when displaying keypoints (bodypart-based coloring)")
638-
color_ui.populate_colormap_combo(
639-
self.cmap_combo,
635+
self.cmap_combo = color_ui.make_colormap_combo(
640636
current=self._colormap,
637+
tooltip="Select colormap to use when displaying keypoints (bodypart-based coloring)",
641638
favorites_first=["turbo", "jet", "hsv"],
642639
exclude_reversed=True,
643640
filters={"cet_": 5}, # include only first 5 colormaps from the 'cet_' family to avoid redundant options
641+
include_icons=True,
642+
sizing=color_ui.ComboSizing(min_width=80, max_width=200, popup_extra_padding=40),
644643
)
645-
lyts.enable_combo_shrink_to_current(self.cmap_combo, min_width=80, max_width=200)
646644

647645
keypoints_settings = lyts.make_two_field_row(
648646
"Keypoint colormap: ",
649647
self.cmap_combo,
650648
None,
651649
self.show_predictions_checkbox,
652-
key_width=None,
650+
key_width=120,
653651
left_stretch=0,
654652
right_stretch=0,
655653
)
@@ -658,19 +656,23 @@ def _build_viz_group(self) -> QGroupBox:
658656
self.bbox_enabled_checkbox = QCheckBox("Show bounding box")
659657
self.bbox_enabled_checkbox.setChecked(False)
660658

661-
self.bbox_color_combo = QComboBox()
662-
self.bbox_color_combo.setToolTip("Select color for bounding box")
663-
self.bbox_color_combo.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
664-
color_ui.populate_bbox_color_combo(self.bbox_color_combo, BBoxColors, current_bgr=self._bbox_color)
665-
self.bbox_color_combo.setCurrentIndex(0)
666-
lyts.enable_combo_shrink_to_current(self.bbox_color_combo, min_width=80, max_width=200)
659+
self.bbox_color_combo = color_ui.make_bbox_color_combo(
660+
BBoxColors,
661+
current_bgr=self._bbox_color,
662+
include_icons=True,
663+
tooltip="Select color for bounding box",
664+
sizing=color_ui.ComboSizing(
665+
min_width=80,
666+
max_width=200,
667+
),
668+
)
667669

668670
bbox_settings = lyts.make_two_field_row(
669671
"Bounding box color: ",
670672
self.bbox_color_combo,
671673
None,
672674
self.bbox_enabled_checkbox,
673-
key_width=None,
675+
key_width=120,
674676
left_stretch=0,
675677
right_stretch=0,
676678
)

0 commit comments

Comments
 (0)