Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build package clean
.PHONY: build package clean check-doc

DIST_DIR := bin/MissionDMX-Editor.dist

Expand All @@ -14,4 +14,7 @@ package: $(wildcard build_files/*) submodules/resources/logo.png bin/MissionDMX-
python3 build_files/build_deb.py

clean:
rm -rf ./bin
rm -rf ./bin

check-doc:
ruff check --select D --ignore D203 --ignore D213 --ignore D401 --ignore D415
4 changes: 3 additions & 1 deletion src/model/board_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _distribute_filter_update_message(self, param: proto.FilterMode_pb2.update_p
for c in candidate_list:
c(param)

def register_filter_update_callback(self, target_scene: int, target_filter_id: str, c: Callable) -> None:
def register_filter_update_callback(self, target_scene: int | Scene, target_filter_id: str, c: Callable) -> None:
"""Register a new callback for filter update messages.

If filter update messages are received, they need to be routed to their intended destination. This is done using
Expand All @@ -243,6 +243,8 @@ def register_filter_update_callback(self, target_scene: int, target_filter_id: s
c: The callable to register.

"""
if isinstance(target_scene, Scene):
target_scene = target_scene.scene_id
callable_list = self._filter_update_msg_register.get((target_scene, target_filter_id))
if callable_list is None:
callable_list = set()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""A scene can have multiple pages"""
"""A scene can have multiple pages."""
from typing import override

from PySide6.QtCore import QPoint, Qt
Expand All @@ -13,9 +13,10 @@


class SceneUIPageEditorWidget(QWidget):
"""This class represents a part of a scene"""
"""Class represents a part of a scene."""

def __init__(self, page: UIPage, parent: QWidget) -> None:
"""Initialize editing widget."""
super().__init__(parent)
self._ui_page: UIPage = page
self.setLayout(QGridLayout(self))
Expand All @@ -35,46 +36,37 @@ def mousePressEvent(self, event: QMouseEvent) -> None:

def _widget_selection_menu(self, pos: QPoint) -> None:
menu = QMenu(self)
"""
added_filters = 0
for filter_ in self.ui_page.scene.filters:
if len(filter_.gui_update_keys.keys()) < 1:
continue
action = QAction(filter_.filter_id, self)
menu.addAction(action)
action.triggered.connect(lambda checked=False, filter__=filter_: self._add_filter_widget(filter__, pos))
added_filters += 1
if added_filters == 0:
action = QAction("There are no suitable filters in the scene", menu)
action.setEnabled(False)
menu.addAction(action)
menu.addSeparator()
auto_track_action = QAction("Auto Tracker", self)
auto_track_action.triggered.connect(lambda checked=False, filter__=None: self._add_generic_widget(
AutoTrackerUIWidget("", self._ui_page), pos)
)
menu.addAction(auto_track_action)
"""
categories: dict[str, QMenu] = {}
for widget_def in WIDGET_LIBRARY.values():
action = QAction(widget_def[0], menu)
category = widget_def[3]
if category is None:
parent = menu
else:
if category not in categories:
submenu = QMenu(category, menu)
menu.addMenu(submenu)
categories[category] = submenu
parent = categories[category]
action = QAction(widget_def[0], parent)
action.triggered.connect(lambda _, widget=widget_def: self._inst_generic_widget(widget, pos))
menu.addAction(action)
parent.addAction(action)
menu.popup(self.mapToGlobal(pos))

def _add_filter_widget(self, filter_: Filter, pos: QPoint) -> None:
"""Adds the filter widget to the page at the specified position.

Args:
ui_widget: A widget to manage a filter
filter_: The filter to use for widget linking
pos: The position at which the widget should be placed

"""
# TODO replace with filter.gui_update_keys to ui widget / Change function to construct one from the keys
# FIXME we should use this method to provide a context menu to nodes, enabling them to place widgets without
# relesecting them.
config_widget = filter_to_ui_widget(filter_, self._ui_page)
self._add_generic_widget(config_widget, pos)

def _inst_generic_widget(self, widget_def: tuple[str, type[UIWidget], list[list[FilterTypeEnumeration]]],
def _inst_generic_widget(self, widget_def: tuple[str, type[UIWidget], list[list[FilterTypeEnumeration]], str|None],
pos: QPoint) -> None:
config_widget = widget_def[1](self._ui_page, {})
key_filters = widget_def[2]
Expand All @@ -94,16 +86,17 @@ def _add_generic_widget(self, config_widget: UIWidget, pos: QPoint) -> None:
self._ui_page.display_update_required = True

def _remove_widget_holder(self, wh: UIWidgetHolder) -> None:
"""
This method should be invoked once a widget should be removed and handles the destruction of the container.
"""Method should be invoked once a widget should be removed and handles the destruction of the container.

Args:
wh: The widget that should be removed

"""
self._widgets.remove(wh)
self._ui_page.remove_widget(wh.widget)
self._ui_page.display_update_required = True

@property
def ui_page(self) -> UIPage:
"""The scene the page represents"""
"""The scene the page represents."""
return self._ui_page
57 changes: 49 additions & 8 deletions src/view/show_mode/show_ui_widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@
from view.show_mode.show_ui_widgets.pan_tilt_constant_show_ui import PanTiltConstantControlUIWidget
from view.show_mode.show_ui_widgets.sequencer_control import SequencerControlUIWidget
from view.show_mode.show_ui_widgets.show_label import ShowLabelUIWidget
from view.show_mode.show_ui_widgets.slider_constant_ctrl_uiwidget import SliderConstantUIWidget

"""
The widget library contains information about widgets, provided by their slug. The infomration that is stored consists
out of the human readable name, the type required to instantiate a requested widget, the supported filter types (that
should be selected for construction) and a number indicating how many filters should be selected.
"""
WIDGET_LIBRARY: dict[str, tuple[str, type[UIWidget], list[list[FilterTypeEnumeration]]]] = {
WIDGET_LIBRARY: dict[str, tuple[str, type[UIWidget], list[list[FilterTypeEnumeration]], str | None]] = {
"autotracker": (
"Auto Tracker",
AutoTrackerUIWidget,
[[FilterTypeEnumeration.VFILTER_POSITION_CONSTANT, FilterTypeEnumeration.VFILTER_AUTOTRACKER]],
None,
),
"buttonarray": (
"Button Array",
Expand All @@ -43,8 +45,12 @@
FilterTypeEnumeration.FILTER_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_CONSTANT_16_BIT,
FilterTypeEnumeration.FILTER_CONSTANT_FLOAT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_16BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_FLOAT,
]
],
"Constants",
),
"buttonarray_submit": (
"Button Array w/ Submit",
Expand All @@ -54,41 +60,75 @@
FilterTypeEnumeration.FILTER_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_CONSTANT_16_BIT,
FilterTypeEnumeration.FILTER_CONSTANT_FLOAT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_16BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_FLOAT,
]
],
"Constants",
),
"slider": (
"Slider",
SliderConstantUIWidget,
[
[
FilterTypeEnumeration.FILTER_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_CONSTANT_16_BIT,
FilterTypeEnumeration.FILTER_CONSTANT_FLOAT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_8BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_16BIT,
FilterTypeEnumeration.FILTER_RESPONDING_CONSTANT_FLOAT,
]
],
"Constants",
),
"colorpicker": (
"Color Picker",
ColorSelectionUIWidget,
[[FilterTypeEnumeration.FILTER_CONSTANT_COLOR]],
"Constants",
),
"colorpicker": ("Color Picker", ColorSelectionUIWidget, [[FilterTypeEnumeration.FILTER_CONSTANT_COLOR]]),
"cuecontrol": (
"Cue Control",
CueControlUIWidget,
[[FilterTypeEnumeration.FILTER_TYPE_CUES, FilterTypeEnumeration.VFILTER_CUES]],
None,
),
"pantiltconstant": (
"Pan/Tilt Control",
PanTiltConstantControlUIWidget,
[[FilterTypeEnumeration.VFILTER_POSITION_CONSTANT]],
"Constants",
),
"sequencercontrol": (
"Sequence Listing",
SequencerControlUIWidget,
[[FilterTypeEnumeration.VFILTER_SEQUENCER, FilterTypeEnumeration.FILTER_SEQUENCER]],
None,
),
"chaser-preset-selector": (
"Chaser Preset Selector",
ChaserApplyPresetUIWidget,
[[FilterTypeEnumeration.FILTER_COLOR_CHASER]]
[[FilterTypeEnumeration.FILTER_COLOR_CHASER]],
None,
),
"chaser-live-config": (
"Chaser Live Config Tool",
ChaserCreateConfigUIWidget,
[[FilterTypeEnumeration.FILTER_COLOR_CHASER]]
[[FilterTypeEnumeration.FILTER_COLOR_CHASER]],
None,
),
"label": ("Text Label", ShowLabelUIWidget, []),
"clock": ("BF Clock", ClockUIWidget, []),
"macrobuttons": ("Macro Buttons", MacroButtonUIWidget, []),
"label": ("Text Label", ShowLabelUIWidget, [], "Utility"),
"clock": ("BF Clock", ClockUIWidget, [], "Utility"),
"macrobuttons": ("Macro Buttons", MacroButtonUIWidget, [], None),
# TODO add direct inputs
# TODO add fader update widgets
"debug_color": ("Color Visualizer", ColorDebugVizWidget, [[FilterTypeEnumeration.FILTER_REMOTE_DEBUG_PIXEL]]),
"debug_color": (
"Color Visualizer",
ColorDebugVizWidget,
[[FilterTypeEnumeration.FILTER_REMOTE_DEBUG_PIXEL]],
"Output",
),
"debug_number": (
"Number Output",
NumberDebugVizWidget,
Expand All @@ -99,6 +139,7 @@
FilterTypeEnumeration.FILTER_REMOTE_DEBUG_8BIT,
]
],
"Output",
),
}

Expand Down
Loading
Loading