From 242ed119abb99bb362c57d64874c10a5d1e653f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 13 Jul 2023 14:44:24 +0200 Subject: [PATCH] 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 --- addon/flamenco/gui.py | 17 ++++++++++++----- addon/flamenco/job_types.py | 13 +++++++++---- addon/flamenco/job_types_propgroup.py | 4 ++-- .../scripts/simple_blender_render.js | 5 ++++- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/addon/flamenco/gui.py b/addon/flamenco/gui.py index c234850f..9d6a27da 100644 --- a/addon/flamenco/gui.py +++ b/addon/flamenco/gui.py @@ -97,7 +97,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): row = layout.row(align=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) else: self.draw_setting_editable(row, propgroup, setting) @@ -146,11 +146,18 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): if autoeval_enabled: # Mypy doesn't know the bl_rna attribute exists. 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, job_types.setting_autoeval_propname(setting), - text=label, - icon="AUTO", + text="", + icon="LINKED", ) else: self.draw_setting_editable(layout, propgroup, setting) @@ -158,7 +165,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): propgroup, job_types.setting_autoeval_propname(setting), text="", - icon="AUTO", + icon="UNLINKED", ) def draw_flamenco_status( diff --git a/addon/flamenco/job_types.py b/addon/flamenco/job_types.py index 6bf91777..407d7f54 100644 --- a/addon/flamenco/job_types.py +++ b/addon/flamenco/job_types.py @@ -80,10 +80,15 @@ def setting_should_autoeval( return getattr(propgroup, propname, False) -def setting_can_autoeval(setting: _AvailableJobSetting) -> bool: - # Note that this uses the Pythonified name; that's done by the OpenAPI code generator. - can: bool = setting.get("autoeval_lockable", False) - return can +def show_eval_on_submit_button(setting: _AvailableJobSetting) -> bool: + """Return whether this setting should show the 'eval on submit' toggle button.""" + + 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: diff --git a/addon/flamenco/job_types_propgroup.py b/addon/flamenco/job_types_propgroup.py index 84e42c36..e5de0ce2 100644 --- a/addon/flamenco/job_types_propgroup.py +++ b/addon/flamenco/job_types_propgroup.py @@ -257,7 +257,7 @@ def generate(job_type: _AvailableJobType) -> type[JobTypePropertyGroup]: prop = _create_property(job_type, setting) 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. propname, prop = _create_autoeval_property(setting) pg_type.__annotations__[propname] = prop @@ -323,7 +323,7 @@ def _create_autoeval_property( ) prop = bpy.props.BoolProperty( - name="Auto Evaluate %s" % setting_name, + name="Use Automatic Value", description=prop_descr, default=True, ) diff --git a/internal/manager/job_compilers/scripts/simple_blender_render.js b/internal/manager/job_compilers/scripts/simple_blender_render.js index 411477e4..d39d00c2 100644 --- a/internal/manager/job_compilers/scripts/simple_blender_render.js +++ b/internal/manager/job_compilers/scripts/simple_blender_render.js @@ -5,7 +5,10 @@ const JOB_TYPE = { settings: [ // Settings for artists to determine: { 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'" }, { key: "chunk_size", type: "int32", default: 1, description: "Number of frames to render in one Blender render task", visible: "submission" },