Source code for simvx.editor.panels.inspector_sections._post_process_section
"""PostProcessToggleSection -- quick enable/disable for post-process effects.
Registered with the section registry via @register_inspector_section at
import time.
"""
from simvx.core import CheckBox, Control, Vec2
from ._base import (
InspectorSection,
_font_size,
_row_h,
register_inspector_section,
)
# Maps display label -> WorldEnvironment property name
_POST_PROCESS_TOGGLES: list[tuple[str, str]] = [
("Bloom", "bloom_enabled"),
("SSAO", "ssao_enabled"),
("Depth of Field", "dof_enabled"),
("Motion Blur", "motion_blur_enabled"),
("Film Grain", "film_grain_enabled"),
("Vignette", "vignette_enabled"),
("Chromatic Aberration", "chromatic_aberration_enabled"),
("Fog", "fog_enabled"),
("Colour Grading", "colour_grading_enabled"),
]
[docs]
@register_inspector_section
class PostProcessToggleSection(InspectorSection):
"""Compact toggle summary for post-processing effects on WorldEnvironment."""
section_title = "Post Processing"
priority = 5
[docs]
def can_handle(self, node):
from simvx.core.world_environment import WorldEnvironment
return isinstance(node, WorldEnvironment)
[docs]
def handled_properties(self, node):
return {prop for _, prop in _POST_PROCESS_TOGGLES}
[docs]
def build_rows(self, node, ctx):
rows: list[Control] = []
for label_text, prop_name in _POST_PROCESS_TOGGLES:
current = getattr(node, prop_name, False)
cb = CheckBox(label_text, checked=current)
cb.size = Vec2(200, _row_h())
cb.font_size = _font_size()
cb.toggled.connect(
lambda checked, p=prop_name, c=ctx, n=node: c.on_property_changed(
n, p, getattr(n, p), checked
)
)
rows.append(cb)
ctx.register_widget(f"pp_{prop_name}", cb)
return rows
# NOTE: collision_layer / collision_mask / cull_mask are now `Bitmask` typed
# Properties and are rendered generically by the inspector widget registry
# (see :mod:`.inspector_widgets`). They group naturally under the node's
# declared Property ``group="Collision"``.