Skip to content

Commit

Permalink
ocioview updates & fixes (AcademySoftwareFoundation#1966)
Browse files Browse the repository at this point in the history
* Improve ocioview exit, view, and icon UX

Signed-off-by: Michael Dolan <[email protected]>

* Fix message router property routing

Signed-off-by: Michael Dolan <[email protected]>

* Add processor context

Signed-off-by: Michael Dolan <[email protected]>

* Revise item type data descriptions

Signed-off-by: Michael Dolan <[email protected]>

* Split item name from item label

Signed-off-by: Michael Dolan <[email protected]>

* Update processor context direction handling

Signed-off-by: Michael Dolan <[email protected]>

---------

Signed-off-by: Michael Dolan <[email protected]>
  • Loading branch information
michdolan authored May 6, 2024
1 parent 813785e commit 7e91b0e
Show file tree
Hide file tree
Showing 34 changed files with 489 additions and 232 deletions.
5 changes: 3 additions & 2 deletions src/apps/ocioview/ocioview/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
ROOT_DIR = Path(__file__).parent.parent

# Sizes
ICON_SIZE_ITEM = QtCore.QSize(20, 20)
ICON_SIZE_BUTTON = QtCore.QSize(20, 20)
ICON_SIZE_BUTTON = QtCore.QSize(18, 18)
ICON_SIZE_ITEM = QtCore.QSize(18, 18)
ICON_SIZE_TAB = QtCore.QSize(16, 16)
ICON_SCALE_FACTOR = 1.15

MARGIN_WIDTH = 13 # Pixels
Expand Down
47 changes: 27 additions & 20 deletions src/apps/ocioview/ocioview/inspect/code_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pygments.formatters import HtmlFormatter
from PySide6 import QtCore, QtGui, QtWidgets

from ..constants import ICON_SIZE_TAB
from ..message_router import MessageRouter
from ..utils import get_glyph_icon, processor_to_shader_html
from ..widgets import EnumComboBox, LogView
Expand All @@ -26,7 +27,7 @@ def label(cls) -> str:

@classmethod
def icon(cls) -> QtGui.QIcon:
return get_glyph_icon("mdi6.code-json")
return get_glyph_icon("mdi6.code-json", size=ICON_SIZE_TAB)

def __init__(self, parent: Optional[QtCore.QObject] = None):
super().__init__(parent=parent)
Expand Down Expand Up @@ -63,9 +64,7 @@ def __init__(self, parent: Optional[QtCore.QObject] = None):

self.gpu_language_box = EnumComboBox(ocio.GpuLanguage)
self.gpu_language_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
self.gpu_language_box.set_member(
MessageRouter.get_instance().get_gpu_language()
)
self.gpu_language_box.set_member(MessageRouter.get_instance().gpu_language)
self.gpu_language_box.currentIndexChanged[int].connect(
self._on_gpu_language_changed
)
Expand All @@ -76,12 +75,20 @@ def __init__(self, parent: Optional[QtCore.QObject] = None):

# Layout
self.tabs = QtWidgets.QTabWidget()
self.tabs.addTab(self.config_view, get_glyph_icon("mdi6.code-json"), "Config")
self.tabs.addTab(
self.ctf_view, get_glyph_icon("mdi6.code-tags"), "Processor (CTF)"
self.config_view,
get_glyph_icon("mdi6.code-json", size=ICON_SIZE_TAB),
"Config",
)
self.tabs.addTab(
self.ctf_view,
get_glyph_icon("mdi6.code-tags", size=ICON_SIZE_TAB),
"Processor (CTF)",
)
self.tabs.addTab(
self.shader_view, get_glyph_icon("mdi6.dots-grid"), "Processor (Shader)"
self.shader_view,
get_glyph_icon("mdi6.dots-grid", size=ICON_SIZE_TAB),
"Processor (Shader)",
)

layout = QtWidgets.QVBoxLayout()
Expand Down Expand Up @@ -188,7 +195,7 @@ def _on_gpu_language_changed(self, index: int) -> None:
MessageRouter, which will provide future GPU processors.
"""
gpu_language = self.gpu_language_box.currentData()
MessageRouter.get_instance().set_gpu_language(gpu_language)
MessageRouter.get_instance().gpu_language = gpu_language
if self._prev_gpu_proc is not None:
shader_html_data = processor_to_shader_html(
self._prev_gpu_proc, gpu_language
Expand All @@ -212,22 +219,22 @@ def _on_tab_changed(self, index: int) -> None:
msg_router = MessageRouter.get_instance()

if index == -1:
msg_router.set_config_updates_allowed(False)
msg_router.set_ctf_updates_allowed(False)
msg_router.set_shader_updates_allowed(False)
msg_router.config_updates_allowed = False
msg_router.ctf_updates_allowed = False
msg_router.shader_updates_allowed = False
return

widget = self.tabs.widget(index)

if widget == self.config_view:
msg_router.set_config_updates_allowed(True)
msg_router.set_ctf_updates_allowed(False)
msg_router.set_shader_updates_allowed(False)
msg_router.config_updates_allowed = True
msg_router.ctf_updates_allowed = False
msg_router.shader_updates_allowed = False
elif widget == self.ctf_view:
msg_router.set_config_updates_allowed(False)
msg_router.set_ctf_updates_allowed(True)
msg_router.set_shader_updates_allowed(False)
msg_router.config_updates_allowed = False
msg_router.ctf_updates_allowed = True
msg_router.shader_updates_allowed = False
elif widget == self.shader_view:
msg_router.set_config_updates_allowed(False)
msg_router.set_ctf_updates_allowed(False)
msg_router.set_shader_updates_allowed(True)
msg_router.config_updates_allowed = False
msg_router.ctf_updates_allowed = False
msg_router.shader_updates_allowed = True
14 changes: 9 additions & 5 deletions src/apps/ocioview/ocioview/inspect/curve_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import PyOpenColorIO as ocio
from PySide6 import QtCore, QtGui, QtWidgets

from ..constants import R_COLOR, G_COLOR, B_COLOR, GRAY_COLOR
from ..constants import R_COLOR, G_COLOR, B_COLOR, GRAY_COLOR, ICON_SIZE_TAB
from ..message_router import MessageRouter
from ..processor_context import ProcessorContext
from ..utils import get_glyph_icon, SignalsBlocked
from ..widgets import EnumComboBox, FloatEditArray, IntEdit

Expand Down Expand Up @@ -39,7 +40,7 @@ def label(cls) -> str:

@classmethod
def icon(cls) -> QtGui.QIcon:
return get_glyph_icon("mdi6.chart-bell-curve-cumulative")
return get_glyph_icon("mdi6.chart-bell-curve-cumulative", size=ICON_SIZE_TAB)

def __init__(self, parent: Optional[QtCore.QObject] = None):
super().__init__(parent=parent)
Expand Down Expand Up @@ -256,14 +257,14 @@ def showEvent(self, event: QtGui.QShowEvent) -> None:
super().showEvent(event)

msg_router = MessageRouter.get_instance()
msg_router.set_processor_updates_allowed(True)
msg_router.processor_updates_allowed = True

def hideEvent(self, event: QtGui.QHideEvent) -> None:
"""Stop listening for processor updates, if not visible."""
super().hideEvent(event)

msg_router = MessageRouter.get_instance()
msg_router.set_processor_updates_allowed(False)
msg_router.processor_updates_allowed = False

def resizeEvent(self, event: QtGui.QResizeEvent) -> None:
"""Re-fit graph on resize, to always be centered."""
Expand Down Expand Up @@ -603,10 +604,13 @@ def _fit(self) -> None:
self.update()

@QtCore.Slot(ocio.CPUProcessor)
def _on_processor_ready(self, cpu_proc: ocio.CPUProcessor) -> None:
def _on_processor_ready(
self, proc_context: ProcessorContext, cpu_proc: ocio.CPUProcessor
) -> None:
"""
Update curves from sampled OCIO CPU processor.
:param proc_context: OCIO processor context data
:param cpu_proc: CPU processor of currently viewed transform
"""
self.reset()
Expand Down
3 changes: 2 additions & 1 deletion src/apps/ocioview/ocioview/inspect/log_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import PyOpenColorIO as ocio
from PySide6 import QtCore, QtGui, QtWidgets

from ..constants import ICON_SIZE_TAB
from ..log_handlers import set_logging_level
from ..message_router import MessageRouter
from ..utils import get_glyph_icon
Expand All @@ -23,7 +24,7 @@ def label(cls) -> str:

@classmethod
def icon(cls) -> QtGui.QIcon:
return get_glyph_icon("ph.terminal-window")
return get_glyph_icon("ph.terminal-window", size=ICON_SIZE_TAB)

def __init__(self, parent: Optional[QtCore.QObject] = None):
super().__init__(parent=parent)
Expand Down
3 changes: 2 additions & 1 deletion src/apps/ocioview/ocioview/items/active_display_view_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from PySide6 import QtCore, QtGui, QtWidgets

from ..constants import ICON_SIZE_ITEM
from ..widgets import ItemModelListWidget
from ..utils import get_glyph_icon
from .active_display_view_model import ActiveDisplayModel, ActiveViewModel
Expand Down Expand Up @@ -60,7 +61,7 @@ class ActiveDisplayViewEdit(QtWidgets.QWidget):

@classmethod
def item_type_icon(cls) -> QtGui.QIcon:
return get_glyph_icon("mdi6.sort-bool-ascending-variant")
return get_glyph_icon("mdi6.sort-bool-ascending-variant", size=ICON_SIZE_ITEM)

@classmethod
def item_type_label(cls, plural: bool = False) -> str:
Expand Down
14 changes: 10 additions & 4 deletions src/apps/ocioview/ocioview/items/color_space_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import PyOpenColorIO as ocio

from ..config_cache import ConfigCache
from ..constants import ICON_SIZE_ITEM
from ..utils import get_glyph_icon
from ..widgets import (
CheckBox,
Expand Down Expand Up @@ -39,12 +40,17 @@ def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
self.reference_space_type_combo = EnumComboBox(
ocio.ReferenceSpaceType,
icons={
ocio.REFERENCE_SPACE_SCENE: get_glyph_icon("ph.sun"),
ocio.REFERENCE_SPACE_DISPLAY: get_glyph_icon("ph.monitor"),
ocio.REFERENCE_SPACE_SCENE: get_glyph_icon(
"ph.sun", size=ICON_SIZE_ITEM
),
ocio.REFERENCE_SPACE_DISPLAY: get_glyph_icon(
"ph.monitor", size=ICON_SIZE_ITEM
),
},
)
self.aliases_list = StringListWidget(
item_basename="alias", item_icon=get_glyph_icon("ph.bookmark-simple")
item_basename="alias",
item_icon=get_glyph_icon("ph.bookmark-simple", size=ICON_SIZE_ITEM),
)
self.family_edit = CallbackComboBox(ConfigCache.get_families, editable=True)
self.encoding_edit = CallbackComboBox(ConfigCache.get_encodings, editable=True)
Expand All @@ -61,7 +67,7 @@ def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
)
self.categories_list = StringListWidget(
item_basename="category",
item_icon=get_glyph_icon("ph.bookmarks-simple"),
item_icon=get_glyph_icon("ph.bookmarks-simple", size=ICON_SIZE_ITEM),
get_presets=self._get_available_categories,
)

Expand Down
13 changes: 8 additions & 5 deletions src/apps/ocioview/ocioview/items/color_space_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from PySide6 import QtCore, QtGui

from ..config_cache import ConfigCache
from ..constants import ICON_SIZE_ITEM
from ..ref_space_manager import ReferenceSpaceManager
from ..utils import get_enum_member, get_glyph_icon
from .config_item_model import ColumnDesc, BaseConfigItemModel
Expand Down Expand Up @@ -50,8 +51,10 @@ def __init__(self, parent: Optional[QtCore.QObject] = None):
self._items = ocio.ColorSpaceSet()

self._ref_space_icons = {
ocio.REFERENCE_SPACE_SCENE: get_glyph_icon("ph.sun"),
ocio.REFERENCE_SPACE_DISPLAY: get_glyph_icon("ph.monitor"),
ocio.REFERENCE_SPACE_SCENE: get_glyph_icon("ph.sun", size=ICON_SIZE_ITEM),
ocio.REFERENCE_SPACE_DISPLAY: get_glyph_icon(
"ph.monitor", size=ICON_SIZE_ITEM
),
}

# Update on external config changes, in this case when a required reference
Expand All @@ -62,10 +65,10 @@ def get_item_names(self) -> list[str]:
return [item.getName() for item in self._get_items()]

def get_item_transforms(
self, item_name: str
self, item_label: str
) -> tuple[Optional[ocio.Transform], Optional[ocio.Transform]]:
# Get view name from subscription item name
item_name = self.extract_subscription_item_name(item_name)
# Get color space name from subscription item label
item_name = self.extract_subscription_item_name(item_label)

ref_space_name = ReferenceSpaceManager.scene_reference_space().getName()
return (
Expand Down
16 changes: 8 additions & 8 deletions src/apps/ocioview/ocioview/items/config_item_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from PySide6 import QtCore, QtGui, QtWidgets

from ..constants import MARGIN_WIDTH
from ..constants import MARGIN_WIDTH, ICON_SIZE_TAB
from ..transform_manager import TransformManager
from ..transforms import TransformEditStack
from ..utils import get_glyph_icon, SignalsBlocked
Expand Down Expand Up @@ -50,13 +50,13 @@ def __init__(self, parent: Optional[QtWidgets.QWidget] = None):
no_tf_color = palette.color(
palette.ColorGroup.Disabled, palette.ColorRole.Text
)
self._from_ref_icon = get_glyph_icon("mdi6.layers-plus")
self._from_ref_icon = get_glyph_icon("mdi6.layers-plus", size=ICON_SIZE_TAB)
self._no_from_ref_icon = get_glyph_icon(
"mdi6.layers-plus", color=no_tf_color
"mdi6.layers-plus", color=no_tf_color, size=ICON_SIZE_TAB
)
self._to_ref_icon = get_glyph_icon("mdi6.layers-minus")
self._to_ref_icon = get_glyph_icon("mdi6.layers-minus", size=ICON_SIZE_TAB)
self._no_to_ref_icon = get_glyph_icon(
"mdi6.layers-minus", color=no_tf_color
"mdi6.layers-minus", color=no_tf_color, size=ICON_SIZE_TAB
)

# Widgets
Expand Down Expand Up @@ -316,10 +316,10 @@ def eventFilter(self, watched: QtCore.QObject, event: QtCore.QEvent) -> bool:
)
):
current_index = self.list.current_index()
item_name = self.model.format_subscription_item_name(current_index)
if item_name:
item_label = self.model.format_subscription_item_label(current_index)
if item_label:
TransformManager.set_subscription(
int(event.text()), self.model, item_name
int(event.text()), self.model, item_label
)
return True

Expand Down
Loading

0 comments on commit 7e91b0e

Please sign in to comment.