magscope.ui.widgets
===================

.. py:module:: magscope.ui.widgets

.. autoapi-nested-parse::

   "
   Miscellaneous custom Qt widgets for the GUI



Classes
-------

.. autoapisummary::

   magscope.ui.widgets.LabeledLineEditWithValue
   magscope.ui.widgets.LabeledLineEdit
   magscope.ui.widgets.LabeledCheckbox
   magscope.ui.widgets.LabeledStepperLineEdit
   magscope.ui.widgets.CollapsibleGroupBox
   magscope.ui.widgets.GripHandle
   magscope.ui.widgets.GripSplitter
   magscope.ui.widgets.BeadGraphic
   magscope.ui.widgets.FlashLabel
   magscope.ui.widgets.ResizableLabel


Module Contents
---------------

.. py:class:: LabeledLineEditWithValue(*, label_text: str, validator: PyQt6.QtGui.QValidator = None, widths: tuple[int, int, int] = (0, 0, 0), default=None, callback: callable = None)

   Bases: :py:obj:`PyQt6.QtWidgets.QWidget`


   Horizontally combined QLabel, QLineedit, and a second QLabel to show the value.


   .. py:attribute:: layout


   .. py:attribute:: label


   .. py:attribute:: lineedit


   .. py:attribute:: value_label


.. py:class:: LabeledLineEdit(*, label_text: str, widths: tuple[int, int] = (0, 0), default=None, validator: PyQt6.QtGui.QValidator = None, callback: callable = None)

   Bases: :py:obj:`PyQt6.QtWidgets.QWidget`


   Horizontally combined QLabel and QLineedit.


   .. py:attribute:: layout


   .. py:attribute:: label


   .. py:attribute:: lineedit


.. py:class:: LabeledCheckbox(*, label_text: str, widths: tuple[int, int] = (0, 0), default=False, callback: callable = None)

   Bases: :py:obj:`PyQt6.QtWidgets.QWidget`


   Horizontally combined QLabel and QCheckbox.


   .. py:attribute:: layout


   .. py:attribute:: label


   .. py:attribute:: checkbox


.. py:class:: LabeledStepperLineEdit(*, label_text: str, left_button_text: str, right_button_text: str, widths: tuple[int, int, int, int] = (0, 0, 0, 0), default=None, validator: PyQt6.QtGui.QValidator = None, callbacks: tuple[callable, callable, callable] = (None, None, None))

   Bases: :py:obj:`PyQt6.QtWidgets.QWidget`


   Horizontally combined QLabel and QLineedit with a QButton to increment/decrement the value on either side.


   .. py:attribute:: layout


   .. py:attribute:: name_label


   .. py:attribute:: left_button


   .. py:attribute:: lineedit


   .. py:attribute:: right_button


.. py:class:: CollapsibleGroupBox(title='', collapsed=False)

   Bases: :py:obj:`PyQt6.QtWidgets.QGroupBox`


   A collapsible QGroupBox with the title text as a toggle button to show/hide its content


   .. py:attribute:: title
      :value: ''



   .. py:attribute:: default_collapsed
      :value: False



   .. py:attribute:: _settings_key
      :value: '_Group Box Collapsed'



   .. py:attribute:: toggle_button


   .. py:attribute:: drag_handle


   .. py:attribute:: content_area


   .. py:attribute:: animation


   .. py:attribute:: collapsed


   .. py:method:: _animation_finished() -> None


   .. py:property:: settings_key
      :type: str



   .. py:method:: toggle(checked)


   .. py:method:: reset_to_default() -> None


   .. py:method:: _apply_collapsed_state(collapsed: bool, *, animate: bool, persist: bool) -> None


   .. py:method:: setContentLayout(content_layout)


   .. py:method:: _get_toggle_text(title, expanded)
      :staticmethod:



.. py:class:: GripHandle(orientation, parent)

   Bases: :py:obj:`PyQt6.QtWidgets.QSplitterHandle`


   Simple class for adding '...' to QSplitter handles.


   .. py:attribute:: released
      :type:  PyQt6.QtCore.pyqtSignal


   .. py:attribute:: _pressed
      :value: False



   .. py:method:: mousePressEvent(e)


   .. py:method:: mouseReleaseEvent(e)


   .. py:method:: enterEvent(e)


   .. py:method:: leaveEvent(e)


   .. py:method:: paintEvent(event)


.. py:class:: GripSplitter(orientation, name=None, parent=None)

   Bases: :py:obj:`PyQt6.QtWidgets.QSplitter`


   Simple class for adding '...' to QSplitter handles.


   .. py:attribute:: name
      :value: None



   .. py:attribute:: shown_once
      :value: False



   .. py:method:: showEvent(e)


   .. py:method:: createHandle()


   .. py:method:: handle_released()


.. py:class:: BeadGraphic(parent: magscope.ui.ui.UIManager, id: int, roi: tuple[int, int, int, int], view_scene)

   Bases: :py:obj:`PyQt6.QtWidgets.QGraphicsRectItem`


   .. py:attribute:: LABEL_FONT


   .. py:attribute:: LABEL_COLOR


   .. py:attribute:: LABEL_OFFSET_X
      :value: 10



   .. py:attribute:: LABEL_OFFSET_Y
      :value: 1



   .. py:attribute:: BORDER_COLOR_DEFAULT
      :value: (0, 255, 255, 255)



   .. py:attribute:: FILL_COLOR_DEFAULT
      :value: None



   .. py:attribute:: BORDER_COLOR_SELECTED
      :value: (255, 0, 0, 255)



   .. py:attribute:: FILL_COLOR_SELECTED
      :value: None



   .. py:attribute:: BORDER_COLOR_REFERENCE
      :value: (0, 255, 0, 255)



   .. py:attribute:: FILL_COLOR_REFERENCE
      :value: None



   .. py:attribute:: HOVER_BORDER_COLOR
      :value: (255, 96, 96, 255)



   .. py:attribute:: DRAG_BORDER_COLOR
      :value: (255, 255, 255, 255)



   .. py:attribute:: IDLE_PEN_WIDTH
      :value: 0



   .. py:attribute:: HOVER_PEN_WIDTH
      :value: 2



   .. py:attribute:: SELECTED_PEN_WIDTH
      :value: 2



   .. py:attribute:: DRAG_PEN_WIDTH
      :value: 3



   .. py:attribute:: CORNER_GRIP_SIZE
      :value: 6.0



   .. py:attribute:: _shared_pens
      :type:  dict[str, PyQt6.QtGui.QPen] | None
      :value: None



   .. py:attribute:: _shared_brushes
      :type:  dict[str, PyQt6.QtGui.QBrush] | None
      :value: None



   .. py:attribute:: _parent
      :type:  magscope.ui.ui.UIManager


   .. py:attribute:: id
      :type:  int


   .. py:attribute:: _initializing
      :type:  bool
      :value: True



   .. py:attribute:: _is_moving
      :type:  bool
      :value: False



   .. py:attribute:: _is_hovered
      :type:  bool
      :value: False



   .. py:attribute:: _locked
      :type:  bool


   .. py:attribute:: _color_state
      :type:  str
      :value: 'default'



   .. py:attribute:: _cached_roi
      :type:  tuple[int, int, int, int] | None
      :value: None



   .. py:attribute:: pen_width
      :value: 0



   .. py:attribute:: label


   .. py:property:: locked


   .. py:attribute:: view_scene


   .. py:method:: remove()


   .. py:method:: roi_from_center(x: float, y: float, width: float) -> tuple[int, int, int, int]
      :classmethod:



   .. py:method:: label_scene_position_for_roi(roi: tuple[int, int, int, int]) -> PyQt6.QtCore.QPointF
      :classmethod:



   .. py:method:: clamp_roi_to_scene(roi: tuple[int, int, int, int], scene_rect: PyQt6.QtCore.QRectF) -> tuple[int, int, int, int]
      :classmethod:



   .. py:method:: move_roi(roi: tuple[int, int, int, int], dx: int, dy: int, scene_rect: PyQt6.QtCore.QRectF) -> tuple[int, int, int, int]
      :classmethod:



   .. py:method:: set_selection_state(state: str)

      Update the bead overlay color to match selection/reference state.



   .. py:method:: _ensure_shared_pens_and_brushes() -> None
      :classmethod:



   .. py:method:: _create_pen(color: tuple[int, int, int, int]) -> PyQt6.QtGui.QPen
      :staticmethod:



   .. py:method:: _create_brush(color: tuple[int, int, int, int] | None) -> PyQt6.QtGui.QBrush
      :staticmethod:



   .. py:method:: _apply_color()


   .. py:method:: _current_visual_state() -> str


   .. py:method:: _current_border_color() -> PyQt6.QtGui.QColor


   .. py:method:: _current_pen_width() -> int


   .. py:method:: _update_cursor() -> None


   .. py:method:: _corner_grip_rects() -> list[PyQt6.QtCore.QRectF]


   .. py:method:: _paint_rect() -> PyQt6.QtCore.QRectF


   .. py:method:: _current_scene_rect() -> PyQt6.QtCore.QRectF


   .. py:method:: paint(painter, option, widget=None)


   .. py:method:: move(dx, dy)


   .. py:method:: validate_move(value)

      Prevents the graphic from moving outside the scene border



   .. py:method:: get_label_scene_position() -> PyQt6.QtCore.QPointF


   .. py:method:: set_roi_bounds(roi: tuple[int, int, int, int]) -> None


   .. py:method:: itemChange(change, value)


   .. py:method:: hoverEnterEvent(event)


   .. py:method:: hoverLeaveEvent(event)


   .. py:method:: mousePressEvent(event)


   .. py:method:: mouseReleaseEvent(event)


   .. py:method:: on_move_completed()


   .. py:method:: get_roi_bounds() -> tuple[int, int, int, int]


   .. py:method:: _update_cached_roi()


.. py:class:: FlashLabel(text='')

   Bases: :py:obj:`PyQt6.QtWidgets.QLabel`


   .. py:attribute:: _flash_progress
      :value: 0.0



   .. py:attribute:: _timer


   .. py:attribute:: _step
      :value: 0



   .. py:method:: _update_flash()


   .. py:method:: setText(text)


.. py:class:: ResizableLabel(parent=None)

   Bases: :py:obj:`PyQt6.QtWidgets.QLabel`


   Custom QLabel that emits a signal when it's resized.


   .. py:attribute:: resized


   .. py:method:: resizeEvent(event)

      Override resize event to emit signal with new dimensions.



