UI: Operator Props Dialog Changes #117528

Merged
Harley Acheson merged 9 commits from Harley/blender:OpPropertyDialog into main 2024-01-26 20:52:39 +01:00
Member

Changes to WM_operator_props_dialog_popup to allow configuration,
including via python, and with look consistent with new confirms.


Existing wmOpPopUp extended to include the many ways that all of these related functions could be configured.

In the WM API, properties added to invoke_props_dialog for "title", "confirm_text", "cancel_default." New rna_Operator_props_dialog_popup added that calls existing WM_operator_props_dialog_popup that is extended with default arguments so that existing uses are not changed.

WM_operator_props_dialog_popup creates the same dialog as now, with wm_block_dialog_create, but passes along larger wmOpPopUp with more options and set defaults.

The dialog itself is altered to have optional mousemove_quit behavior, a cancel button (in OS order), and with either button set as default. Positioning is also configurable. Padding is changed. The title is bold.

a dialog_cancel_cb added to handle the action of the Cancel button.

An example of a current dialog:

image

Note that the above shows grey-out text showing the operator name, and a single "OK" button. This PR, by default, creates the following:

image

It shows the operator description as title in bold. There is a confirm button using the operator name, and a Cancel button to back out. And of course the title, the button text, and which button is configurable in Python, with more configuration possible in C++.

Note that is borrows code and inspiration from Guillermo Venegas' #117143

Changes to WM_operator_props_dialog_popup to allow configuration, including via python, and with look consistent with new confirms. --- Existing `wmOpPopUp` extended to include the many ways that all of these related functions could be configured. In the WM API, properties added to `invoke_props_dialog` for "title", "confirm_text", "cancel_default." New `rna_Operator_props_dialog_popup` added that calls existing `WM_operator_props_dialog_popup` that is extended with default arguments so that existing uses are not changed. `WM_operator_props_dialog_popup` creates the same dialog as now, with `wm_block_dialog_create`, but passes along larger `wmOpPopUp` with more options and set defaults. The dialog itself is altered to have optional mousemove_quit behavior, a cancel button (in OS order), and with either button set as default. Positioning is also configurable. Padding is changed. The title is bold. a `dialog_cancel_cb` added to handle the action of the Cancel button. An example of a current dialog: ![image](/attachments/96af1b6d-9a93-44d1-9a70-8d57cd6199e8) Note that the above shows grey-out text showing the operator name, and a single "OK" button. This PR, by default, creates the following: ![image](/attachments/34dafae9-54e9-4d9e-9aca-123ac0232ced) It shows the operator description as title in bold. There is a confirm button using the operator name, and a Cancel button to back out. And of course the title, the button text, and which button is configurable in Python, with more configuration possible in C++. Note that is borrows code and inspiration from Guillermo Venegas' #117143
Harley Acheson added 1 commit 2024-01-26 03:21:38 +01:00
cc04e22abf UI: Operator Props Dialog Changes
Changes to WM_operator_props_dialog_popup to allow configuration,
including via python, and with look consistent with new confirms.
Harley Acheson added 1 commit 2024-01-26 03:24:20 +01:00
Harley Acheson added 1 commit 2024-01-26 03:28:52 +01:00
Harley Acheson added this to the User Interface project 2024-01-26 03:45:34 +01:00
Harley Acheson requested review from Brecht Van Lommel 2024-01-26 03:50:18 +01:00
Guillermo Venegas reviewed 2024-01-26 04:20:29 +01:00
Guillermo Venegas left a comment
Contributor

Looking forward for this.
Some details

Looking forward for this. Some details
@ -221,0 +229,4 @@
{
title = RNA_translate_ui_text(title, text_ctxt, nullptr, nullptr, translate);
confirm_text = RNA_translate_ui_text(confirm_text, text_ctxt, nullptr, nullptr, translate);
return WM_operator_props_dialog_popup(C, op, width, title, confirm_text, cancel_default);
Contributor

Misses nullptr checks in WM_operator_props_dialog_popup string params

Misses `nullptr` checks in `WM_operator_props_dialog_popup` string params
Harley marked this conversation as resolved
@ -1675,0 +1684,4 @@
/* Only invoked by Cancel button in popups created with wm_block_dialog_create() */
static void dialog_cancel_cb(bContext *C, void *arg1, void *arg2)
{
wmOpPopUp *data = static_cast<wmOpPopUp *>(arg1);
Contributor

this few lines (1687-1700) duplicates wm_operator_ui_popup_cancel

this few lines (1687-1700) duplicates `wm_operator_ui_popup_cancel`
Harley marked this conversation as resolved
Harley Acheson added 1 commit 2024-01-26 05:33:31 +01:00
Author
Member

@guishe - Some details

Thanks! Can you double-check these to make sure I fixed them as you expected?

> @guishe - Some details Thanks! Can you double-check these to make sure I fixed them as you expected?
Contributor

Works as expected!

Works as expected!
Brecht Van Lommel requested changes 2024-01-26 16:33:06 +01:00
@ -867,2 +881,4 @@
rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE | WM_GEN_INVOKE_RETURN);
parm = RNA_def_property(func, "title", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(parm, "Title", "Optional text to show as title of the title.");

title of the tile -> title of the popup

title of the tile -> title of the popup
Harley marked this conversation as resolved
@ -869,0 +887,4 @@
parm,
"Confirm Text",
"Optional text to show instead to the default \"OK\" confirmation button text.");
parm = RNA_def_property(func, "cancel_default", PROP_BOOLEAN, PROP_NONE);

I'm not sure it makes sense to have cancel_default without also being able to change the text of the cancel button. Or if we want to have popups that do this at all actually.

Can we leave this out of the Python API until it's more clear if this is something we actually want to recommend people use? I don't mind having it in C++.

I'm not sure it makes sense to have `cancel_default` without also being able to change the text of the cancel button. Or if we want to have popups that do this at all actually. Can we leave this out of the Python API until it's more clear if this is something we actually want to recommend people use? I don't mind having it in C++.
Harley marked this conversation as resolved
@ -869,0 +900,4 @@
"Override automatic translation context of the given text");
RNA_def_property_clear_flag(parm, PROP_NEVER_NULL);
RNA_def_boolean(
func, "translate", true, "", "Translate the given text, when UI translation is enabled");

To deduplicate code, I suggest to add a api_ui_item_common_text_translation with these two properties, that is then also called by api_ui_item_common_text.

To deduplicate code, I suggest to add a `api_ui_item_common_text_translation` with these two properties, that is then also called by `api_ui_item_common_text`.
Harley marked this conversation as resolved
Harley Acheson added 2 commits 2024-01-26 17:57:55 +01:00
Author
Member

@brecht - I'm not sure it makes sense to have cancel_default

You are right. It makes sense that we might want to have the Cancel be default for confirmations, but these dialogs are always the result of deliberate actions.

without also being able to change the text of the cancel button

At first I thought there might be need for this in some places, but have not found any examples where we'd want the "do nothing" path to have a different button text. If you can think of any that would be really appreciated. The obvious "Yes" and "No" dialogs are problematic in that they can require careful parsing of a question in the content to know you are taking the right path, while Action/Cancel is much clearer. And I cringe at the idea of a clever addon maker using a cancel synonym like "Outa Here!." LOL

> @brecht - I'm not sure it makes sense to have cancel_default You are right. It makes sense that we might want to have the Cancel be default for confirmations, but these dialogs are always the result of deliberate actions. > without also being able to change the text of the cancel button At first I thought there might be need for this in some places, but have not found any examples where we'd want the "do nothing" path to have a different button text. If you can think of any that would be really appreciated. The obvious "Yes" and "No" dialogs are problematic in that they can require careful parsing of a question in the content to know you are taking the right path, while Action/Cancel is much clearer. And I cringe at the idea of a clever addon maker using a cancel synonym like "Outa Here!." LOL
Brecht Van Lommel approved these changes 2024-01-26 18:11:01 +01:00
Brecht Van Lommel left a comment
Owner

Looks good to me now.

I think we should ensure the available arguments and styling is consistent for other popups in 4.1. I guess the plan would be to follow up this change with further PR(s) for the other popups?

The one potentially controversial change is invoke_confirm I think. We could add a compact argument there which defaults to True for the existing behavior. Though it may also be reasonable to just have the new layout, or at least switch the default of such an option to False; but that is a decision to be agreed in the UI module.

Looks good to me now. I think we should ensure the available arguments and styling is consistent for other popups in 4.1. I guess the plan would be to follow up this change with further PR(s) for the other popups? The one potentially controversial change is `invoke_confirm` I think. We could add a `compact` argument there which defaults to `True` for the existing behavior. Though it may also be reasonable to just have the new layout, or at least switch the default of such an option to `False`; but that is a decision to be agreed in the UI module.
Author
Member

I guess the plan would be to follow up this change with further PR(s) for the other popups?

Almost immediately after this I was going to propose what I think is a nice way to do the custom confirmations without that "confirm" callback.

The one potentially controversial change is invoke_confirm I think... We could add a compact...

Early on with the confirmations I did have a compact size for the default confirm but proposing any changes to that was tough, mostly with mouse move quit behavior making it hard to find a consensus. We can talk it through in the upcoming module meeting.

> I guess the plan would be to follow up this change with further PR(s) for the other popups? Almost immediately after this I was going to propose what I think is a nice way to do the custom confirmations without that "confirm" callback. > The one potentially controversial change is `invoke_confirm` I think... We could add a `compact`... Early on with the confirmations I did have a `compact` size for the default confirm but proposing any changes to that was tough, mostly with mouse move quit behavior making it hard to find a consensus. We can talk it through in the upcoming module meeting.
Harley Acheson added 1 commit 2024-01-26 20:18:27 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
8a1b01b357
Merge branch 'main' of projects.blender.org:blender/blender into OpPropertyDialog
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson added 1 commit 2024-01-26 20:48:36 +01:00
Harley Acheson added 1 commit 2024-01-26 20:51:09 +01:00
Harley Acheson merged commit 0d6aec1c21 into main 2024-01-26 20:52:39 +01:00
Harley Acheson deleted branch OpPropertyDialog 2024-01-26 20:52:41 +01:00

I missed that this is making the description the title everywhere. That just doesn't work, the description is not meant for this. It is often much too long and contains too many details that make no sense as a title. It also often uses alternative wording than the operator name intentionally to help clarify, but it's not a good title.

I will revert that part of the change in main now, because it breaks a lot of popups.

I missed that this is making the description the title everywhere. That just doesn't work, the description is not meant for this. It is often much too long and contains too many details that make no sense as a title. It also often uses alternative wording than the operator name intentionally to help clarify, but it's not a good title. I will revert that part of the change in main now, because it breaks a lot of popups.
Author
Member

That just doesn't work, the description is not meant for this...will revert that part of the change

That makes sense. using WM_operatortype_name is perfect. Thanks!

> That just doesn't work, the description is not meant for this...will revert that part of the change That makes sense. using `WM_operatortype_name` is perfect. Thanks!
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117528
No description provided.