UI拡充
This commit is contained in:
+93
-6
@@ -9,6 +9,7 @@ import bpy
|
||||
from bpy.types import Panel
|
||||
|
||||
from ..core.async_generator import get_generator
|
||||
from ..core.utils import get_server_status, get_cache_info, format_size
|
||||
|
||||
|
||||
class SEQUENCER_PT_face_mask(Panel):
|
||||
@@ -22,21 +23,29 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = context.scene
|
||||
wm = context.window_manager
|
||||
seq_editor = context.scene.sequence_editor
|
||||
# Note: Blender 5.0 uses 'strips' instead of 'sequences'
|
||||
|
||||
|
||||
generator = get_generator()
|
||||
|
||||
|
||||
# Always show parameters and status
|
||||
self._draw_parameters(layout, scene)
|
||||
self._draw_server_status(layout)
|
||||
self._draw_cache_info(layout, seq_editor)
|
||||
|
||||
layout.separator()
|
||||
|
||||
# Show progress if generating
|
||||
if generator.is_running:
|
||||
self._draw_progress(layout, wm, generator)
|
||||
return
|
||||
|
||||
|
||||
# Show controls if strip selected
|
||||
if seq_editor and seq_editor.active_strip:
|
||||
strip = seq_editor.active_strip
|
||||
|
||||
|
||||
if strip.type in {'MOVIE', 'IMAGE'}:
|
||||
self._draw_generation_controls(layout, context, strip)
|
||||
self._draw_blur_controls(layout, context, strip)
|
||||
@@ -45,18 +54,96 @@ class SEQUENCER_PT_face_mask(Panel):
|
||||
else:
|
||||
layout.label(text="No strip selected")
|
||||
|
||||
def _draw_parameters(self, layout, scene):
|
||||
"""Draw detection parameters."""
|
||||
box = layout.box()
|
||||
box.label(text="Parameters", icon='PREFERENCES')
|
||||
|
||||
col = box.column(align=True)
|
||||
col.prop(scene, "facemask_conf_threshold")
|
||||
col.prop(scene, "facemask_iou_threshold")
|
||||
col.prop(scene, "facemask_mask_scale")
|
||||
|
||||
def _draw_server_status(self, layout):
|
||||
"""Draw server status and GPU info."""
|
||||
box = layout.box()
|
||||
box.label(text="Server Status", icon='SYSTEM')
|
||||
|
||||
status = get_server_status()
|
||||
|
||||
# Server status
|
||||
row = box.row()
|
||||
if status['running']:
|
||||
row.label(text="Server:", icon='CHECKMARK')
|
||||
row.label(text="Running")
|
||||
else:
|
||||
row.label(text="Server:", icon='ERROR')
|
||||
row.label(text="Stopped")
|
||||
|
||||
# GPU status
|
||||
if status['running']:
|
||||
row = box.row()
|
||||
if status['gpu_available']:
|
||||
row.label(text="GPU:", icon='CHECKMARK')
|
||||
gpu_name = status['gpu_device'] or "Available"
|
||||
# Truncate long GPU names
|
||||
if len(gpu_name) > 25:
|
||||
gpu_name = gpu_name[:22] + "..."
|
||||
row.label(text=gpu_name)
|
||||
else:
|
||||
row.label(text="GPU:", icon='ERROR')
|
||||
row.label(text="Not Available")
|
||||
|
||||
def _draw_cache_info(self, layout, seq_editor):
|
||||
"""Draw cache information and clear button."""
|
||||
box = layout.box()
|
||||
box.label(text="Cache", icon='FILE_CACHE')
|
||||
|
||||
# Get cache info
|
||||
if seq_editor and seq_editor.active_strip:
|
||||
strip_name = seq_editor.active_strip.name
|
||||
cache_path, total_size, file_count = get_cache_info(strip_name)
|
||||
else:
|
||||
cache_path, total_size, file_count = get_cache_info()
|
||||
|
||||
# Cache info
|
||||
row = box.row()
|
||||
row.label(text="Size:")
|
||||
row.label(text=format_size(total_size))
|
||||
|
||||
row = box.row()
|
||||
row.label(text="Files:")
|
||||
row.label(text=str(file_count))
|
||||
|
||||
# Clear cache buttons
|
||||
row = box.row(align=True)
|
||||
if seq_editor and seq_editor.active_strip:
|
||||
op = row.operator(
|
||||
"sequencer.clear_mask_cache",
|
||||
text="Clear Strip Cache",
|
||||
icon='TRASH',
|
||||
)
|
||||
op.all_strips = False
|
||||
|
||||
op = row.operator(
|
||||
"sequencer.clear_mask_cache",
|
||||
text="Clear All",
|
||||
icon='TRASH',
|
||||
)
|
||||
op.all_strips = True
|
||||
|
||||
def _draw_progress(self, layout, wm, generator):
|
||||
"""Draw progress bar during generation."""
|
||||
box = layout.box()
|
||||
box.label(text="Generating Masks...", icon='RENDER_ANIMATION')
|
||||
|
||||
|
||||
# Progress bar
|
||||
progress = wm.mask_progress / max(wm.mask_total, 1)
|
||||
box.progress(
|
||||
factor=progress,
|
||||
text=f"Frame {wm.mask_progress} / {wm.mask_total}",
|
||||
)
|
||||
|
||||
|
||||
# Cancel button
|
||||
box.operator(
|
||||
"sequencer.cancel_mask_generation",
|
||||
|
||||
Reference in New Issue
Block a user