This commit is contained in:
2025-10-13 13:35:52 +02:00
parent 2494897360
commit bf636cbc66
21 changed files with 331 additions and 276 deletions

View File

@@ -229,163 +229,122 @@ def draw_generate_button(layout):
row.scale_y = 1.5
row.operator("text_texture.generate", text="Generate Text Texture", icon='IMAGE_DATA')
def draw_composition_image_section(layout, props):
pass
"""Draw image overlay controls for the composition panel."""
def _iter_components_by_placement(props, placement_mode):
"""Yield (index, component) pairs filtered by placement mode."""
try:
overlays = list(props.image_overlays)
except TypeError:
overlays = props.image_overlays
for index, component in enumerate(overlays):
if getattr(component, "placement_mode", 'ABSOLUTE') == placement_mode:
yield index, component
def _draw_component_header(row, component):
"""Draw shared header controls for a component."""
row.prop(component, "enabled", text="", icon='CHECKBOX_HLT' if component.enabled else 'CHECKBOX_DEHLT')
name_row = row.row(align=True)
name_row.prop(component, "name", text="")
name_row.prop(component, "component_type", text="")
def _draw_component_footer(row, props, index):
"""Draw the footer action buttons for a component."""
premium_lock = create_premium_lock_function()
dup_op = safe_operator_call(row, "text_texture.duplicate_overlay", premium_lock, text="", icon='DUPLICATE')
if dup_op:
dup_op.overlay_index = index
del_op = safe_operator_call(row, "text_texture.delete_overlay", premium_lock, text="", icon='TRASH')
if del_op:
del_op.overlay_index = index
move_up = safe_operator_call(row, "text_texture.move_overlay", premium_lock, text="", icon='TRIA_UP')
if move_up:
move_up.overlay_index = index
move_up.direction = 'UP'
move_down = safe_operator_call(row, "text_texture.move_overlay", premium_lock, text="", icon='TRIA_DOWN')
if move_down:
move_down.overlay_index = index
move_down.direction = 'DOWN'
def _draw_component_details(container, component):
"""Render component-specific detail controls."""
details_col = container.column(align=True)
details_col.enabled = component.enabled
details_col.prop(component, "placement_mode", text="Placement")
if component.component_type == 'TEXT':
details_col.prop(component, "text_content", text="Text")
details_col.prop(component, "text_spacing", text="Spacing (%)")
else:
details_col.prop(component, "image_path", text="Image File")
details_col.prop(component, "text_spacing", text="Spacing (%)")
details_col.prop(component, "image_spacing", text="Component Spacing (%)")
if component.placement_mode == 'ABSOLUTE':
pos_row = details_col.row(align=True)
pos_row.prop(component, "x_position", text="X")
pos_row.prop(component, "y_position", text="Y")
transform_row = details_col.row(align=True)
transform_row.prop(component, "scale", text="Scale")
transform_row.prop(component, "rotation", text="Rotation")
transform_row.prop(component, "z_index", text="Z-Level")
def draw_component_section(layout, props, placement_mode, title, icon):
"""Render a section for a specific placement mode."""
section = layout.box()
section.use_property_split = False
section.use_property_decorate = False
section.label(text="Image Elements", icon='IMAGE_DATA')
# Check if image overlays are available
if not has_image_overlays():
pass
draw_feature_lock_indicator(section, 'image_overlays')
header = section.row(align=True)
header.label(text=title, icon=icon)
# Add new component button
add_row = section.row(align=True)
premium_lock = create_premium_lock_function()
add_op = safe_operator_call(
add_row,
"text_texture.add_overlay",
premium_lock,
text="Add Component",
icon='ADD'
)
if add_op:
add_op.placement_mode = placement_mode
components = list(_iter_components_by_placement(props, placement_mode))
if not components:
return
# Add overlay button - use safe operator call
row = section.row()
safe_operator_call(row, "text_texture.add_overlay",
lambda layout: draw_feature_lock_indicator(layout, 'image_overlays'),
text="Add Image Overlay", icon='ADD')
# Individual overlay controls
if props.image_overlays:
pass
section.separator()
for i, overlay in enumerate(props.image_overlays):
pass
# Create collapsible box for each overlay
box = section.box()
# Header row with controls
header_row = box.row(align=True)
# Enable/Disable checkbox with clear label
header_row.prop(overlay, "enabled", text="", icon='CHECKBOX_HLT' if overlay.enabled else 'CHECKBOX_DEHLT')
# Overlay name
name_row = header_row.row()
name_row.enabled = overlay.enabled # Gray out name if disabled
name_row.prop(overlay, "name", text="")
# Action buttons
# Duplicate button - use safe operator call
premium_lock = create_premium_lock_function()
dup_op = safe_operator_call(header_row, "text_texture.duplicate_overlay", premium_lock,
text="", icon='DUPLICATE')
if dup_op:
dup_op.overlay_index = i
# Delete button - use safe operator call
del_op = safe_operator_call(header_row, "text_texture.delete_overlay", premium_lock,
text="", icon='TRASH')
if del_op:
del_op.overlay_index = i
# Move buttons for reordering - use safe operator calls
if i > 0:
move_up_op = safe_operator_call(header_row, "text_texture.move_overlay", premium_lock,
text="", icon='TRIA_UP')
if move_up_op:
move_up_op.overlay_index = i
move_up_op.direction = 'UP'
if i < len(props.image_overlays) - 1:
move_down_op = safe_operator_call(header_row, "text_texture.move_overlay", premium_lock,
text="", icon='TRIA_DOWN')
if move_down_op:
move_down_op.overlay_index = i
move_down_op.direction = 'DOWN'
# Show details section with enable/disable state
details_col = box.column()
details_col.enabled = overlay.enabled # Gray out all controls if disabled
# Status indicator
if not overlay.enabled:
pass
status_row = details_col.row()
status_row.label(text="⚠️ Overlay Disabled", icon='INFO')
details_col.separator()
# Image file selection
details_col.prop(overlay, "image_path", text="Image File")
# Positioning mode
details_col.prop(overlay, "positioning_mode", text="Position Mode")
if overlay.positioning_mode == 'ABSOLUTE':
pass
# Position controls for absolute mode
pos_row = details_col.row(align=True)
pos_row.prop(overlay, "x_position", text="X Position")
pos_row.prop(overlay, "y_position", text="Y Position")
elif overlay.positioning_mode in ['APPEND', 'PREPEND']:
# Spacing controls for append/prepend modes with percentage labels
details_col.prop(overlay, "text_spacing", text="Text Spacing (%)")
details_col.prop(overlay, "image_spacing", text="Image Spacing (%)")
# Transform controls
trans_row = details_col.row(align=True)
trans_row.prop(overlay, "scale", text="Scale")
trans_row.prop(overlay, "rotation", text="Rotation")
trans_row.prop(overlay, "z_index", text="Z-Level")
def draw_text_composition_section(layout, props):
pass
"""Draw additional text controls consolidated in the composition panel."""
section = layout.box()
section.use_property_split = False
section.use_property_decorate = False
section.label(text="Text Elements", icon='OUTLINER_OB_FONT')
layout_row = section.row(align=True)
layout_row.prop(props, "prepend_append_layout", text="Layout")
section.separator(factor=0.6)
def draw_text_block(label_text, icon, text_prop, margin_prop):
block = section.box()
block.use_property_split = False
block.use_property_decorate = False
header = block.row(align=True)
header.label(text=label_text, icon=icon)
text_row = block.row(align=True)
text_row.prop(props, text_prop, text="")
spacing_row = block.row(align=True)
spacing_row.enabled = bool(getattr(props, text_prop).strip())
spacing_row.prop(props, margin_prop, text="Spacing", slider=True)
draw_text_block("Prepend Text", 'TRIA_RIGHT', "prepend_text", "prepend_margin")
section.separator(factor=0.4)
draw_text_block("Append Text", 'TRIA_LEFT', "append_text", "append_margin")
for index, component in components:
box = section.box()
header_row = box.row(align=True)
_draw_component_header(header_row, component)
_draw_component_footer(header_row, props, index)
_draw_component_details(box, component)
def draw_composition_section(layout, props):
pass
"""Draw combined composition controls for text and images."""
"""Draw combined composition controls for text and image components."""
if not has_image_overlays():
pass
draw_feature_lock_indicator(layout, 'image_overlays')
return
content = layout.column(align=True)
content.use_property_split = False
content.use_property_decorate = False
tabs_row = content.row(align=True)
tabs_row.prop(props, "composition_active_tab", expand=True)
content.separator(factor=0.6)
if props.composition_active_tab == 'IMAGE':
pass
if not has_image_overlays():
pass
draw_feature_lock_indicator(content, 'image_overlays')
return
draw_composition_image_section(content, props)
else:
pass
draw_text_composition_section(content, props)
draw_component_section(content, props, 'ABSOLUTE', "Absolute Components", 'CURSOR')
draw_component_section(content, props, 'PREPEND', "Prepended Components", 'TRIA_LEFT_BAR')
draw_component_section(content, props, 'APPEND', "Appended Components", 'TRIA_RIGHT_BAR')
def draw_positioning_section(layout, props):
pass