Eval-on-submit job settings: improve GUI in the add-on
Improve the usability of the 'eval-on-submit' toggle button: - Add a placeholder text that can be shown instead of the input field. This can be used to describe what the evaluated Python code will do. In the case of the 'Simple Blender Render' job, this is set to 'Scene frame range'. - Change the way in which the job type has to declare this, both for clarity and to add the extra placeholder string
This commit is contained in:
parent
ab399594c7
commit
242ed119ab
@ -97,7 +97,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
|
|
||||||
if setting.get("editable", True):
|
if setting.get("editable", True):
|
||||||
if job_types.setting_can_autoeval(setting):
|
if job_types.show_eval_on_submit_button(setting):
|
||||||
self.draw_setting_autoeval(row, propgroup, setting)
|
self.draw_setting_autoeval(row, propgroup, setting)
|
||||||
else:
|
else:
|
||||||
self.draw_setting_editable(row, propgroup, setting)
|
self.draw_setting_editable(row, propgroup, setting)
|
||||||
@ -146,11 +146,18 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel):
|
|||||||
if autoeval_enabled:
|
if autoeval_enabled:
|
||||||
# Mypy doesn't know the bl_rna attribute exists.
|
# Mypy doesn't know the bl_rna attribute exists.
|
||||||
label = propgroup.bl_rna.properties[setting.key].name # type: ignore
|
label = propgroup.bl_rna.properties[setting.key].name # type: ignore
|
||||||
layout.prop(
|
|
||||||
|
split = layout.split(factor=0.4, align=True)
|
||||||
|
split.alignment = "RIGHT"
|
||||||
|
split.label(text=label)
|
||||||
|
|
||||||
|
row = split.row(align=True)
|
||||||
|
row.label(text=setting.eval_on_submit.placeholder)
|
||||||
|
row.prop(
|
||||||
propgroup,
|
propgroup,
|
||||||
job_types.setting_autoeval_propname(setting),
|
job_types.setting_autoeval_propname(setting),
|
||||||
text=label,
|
text="",
|
||||||
icon="AUTO",
|
icon="LINKED",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.draw_setting_editable(layout, propgroup, setting)
|
self.draw_setting_editable(layout, propgroup, setting)
|
||||||
@ -158,7 +165,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel):
|
|||||||
propgroup,
|
propgroup,
|
||||||
job_types.setting_autoeval_propname(setting),
|
job_types.setting_autoeval_propname(setting),
|
||||||
text="",
|
text="",
|
||||||
icon="AUTO",
|
icon="UNLINKED",
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_flamenco_status(
|
def draw_flamenco_status(
|
||||||
|
@ -80,10 +80,15 @@ def setting_should_autoeval(
|
|||||||
return getattr(propgroup, propname, False)
|
return getattr(propgroup, propname, False)
|
||||||
|
|
||||||
|
|
||||||
def setting_can_autoeval(setting: _AvailableJobSetting) -> bool:
|
def show_eval_on_submit_button(setting: _AvailableJobSetting) -> bool:
|
||||||
# Note that this uses the Pythonified name; that's done by the OpenAPI code generator.
|
"""Return whether this setting should show the 'eval on submit' toggle button."""
|
||||||
can: bool = setting.get("autoeval_lockable", False)
|
|
||||||
return can
|
eval_on_submit = setting.get("eval_on_submit", None)
|
||||||
|
if not eval_on_submit:
|
||||||
|
return False
|
||||||
|
|
||||||
|
show_button: bool = eval_on_submit.get("show_button", False)
|
||||||
|
return show_button
|
||||||
|
|
||||||
|
|
||||||
def setting_autoeval_propname(setting: _AvailableJobSetting) -> str:
|
def setting_autoeval_propname(setting: _AvailableJobSetting) -> str:
|
||||||
|
@ -257,7 +257,7 @@ def generate(job_type: _AvailableJobType) -> type[JobTypePropertyGroup]:
|
|||||||
prop = _create_property(job_type, setting)
|
prop = _create_property(job_type, setting)
|
||||||
pg_type.__annotations__[setting.key] = prop
|
pg_type.__annotations__[setting.key] = prop
|
||||||
|
|
||||||
if job_types.setting_can_autoeval(setting):
|
if job_types.show_eval_on_submit_button(setting):
|
||||||
# Add RNA property for the 'auto-eval' toggle.
|
# Add RNA property for the 'auto-eval' toggle.
|
||||||
propname, prop = _create_autoeval_property(setting)
|
propname, prop = _create_autoeval_property(setting)
|
||||||
pg_type.__annotations__[propname] = prop
|
pg_type.__annotations__[propname] = prop
|
||||||
@ -323,7 +323,7 @@ def _create_autoeval_property(
|
|||||||
)
|
)
|
||||||
|
|
||||||
prop = bpy.props.BoolProperty(
|
prop = bpy.props.BoolProperty(
|
||||||
name="Auto Evaluate %s" % setting_name,
|
name="Use Automatic Value",
|
||||||
description=prop_descr,
|
description=prop_descr,
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,10 @@ const JOB_TYPE = {
|
|||||||
settings: [
|
settings: [
|
||||||
// Settings for artists to determine:
|
// Settings for artists to determine:
|
||||||
{ key: "frames", type: "string", required: true, eval: "f'{C.scene.frame_start}-{C.scene.frame_end}'",
|
{ key: "frames", type: "string", required: true, eval: "f'{C.scene.frame_start}-{C.scene.frame_end}'",
|
||||||
autoevalLockable: true,
|
evalOnSubmit: {
|
||||||
|
showButton: true,
|
||||||
|
placeholder: "Scene frame range",
|
||||||
|
},
|
||||||
description: "Frame range to render. Examples: '47', '1-30', '3, 5-10, 47-327'" },
|
description: "Frame range to render. Examples: '47', '1-30', '3, 5-10, 47-327'" },
|
||||||
{ key: "chunk_size", type: "int32", default: 1, description: "Number of frames to render in one Blender render task",
|
{ key: "chunk_size", type: "int32", default: 1, description: "Number of frames to render in one Blender render task",
|
||||||
visible: "submission" },
|
visible: "submission" },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user