Anim: Add option to show modified property on slider #119920

Merged
Christoph Lendenfeld merged 9 commits from ChrisLend/blender:slider_show_modified_property into main 2024-04-25 15:48:32 +02:00

This PR adds the feature of displaying which property is modified
to the slider GUI.

This is useful in cases like #117287: Anim: Add Sharpness to Ease operator
where the slider can modify different properties during the modal operation.

The string is optional and will be empty by default.

This label is placed to the left of the slider where the percentage was usually located.
The percentage has now been moved to the right.


In use on the Ease operator
image
image

This PR adds the feature of displaying which property is modified to the slider GUI. This is useful in cases like [#117287: Anim: Add Sharpness to Ease operator](https://projects.blender.org/blender/blender/pulls/117287) where the slider can modify different properties during the modal operation. The string is optional and will be empty by default. This label is placed to the left of the slider where the percentage was usually located. The percentage has now been moved to the right. ------ In use on the Ease operator ![image](/attachments/e62cab78-0dc3-4a7c-8778-254ca1f3144e) ![image](/attachments/9ef20f48-2942-4f33-ab44-6edf2c00b86e)
2.2 KiB
2.0 KiB
Christoph Lendenfeld added this to the 4.2 LTS milestone 2024-03-26 15:09:17 +01:00
Christoph Lendenfeld added the
Interest
User Interface
Module
Animation & Rigging
labels 2024-03-26 15:09:17 +01:00
Christoph Lendenfeld added 1 commit 2024-03-26 15:09:28 +01:00
Sybren A. Stüvel requested changes 2024-04-09 12:01:55 +02:00
Sybren A. Stüvel left a comment
Member

Nice!

"Property name" is a bit ambiguous, as it could mean different things (could be the RNA name). I think it would be better to use either label or ui_name instead of name, so that it's clear it's a for-humans UI thing.

I decided to put it to the right of the slider because on the left, the factor is constantly changing its size, making the text jump around.

Good to have this documented. I do feel that this ordering (label to the right of the value) makes this part of the UI feel a bit inconsistent with the rest of Blender's UI. Would it be much work to move the factor to the right, and the label to the left of the slider? I also wonder what @pablovazquez thinks about this.

Nice! "Property name" is a bit ambiguous, as it could mean different things (could be the RNA name). I think it would be better to use either `label` or `ui_name` instead of `name`, so that it's clear it's a for-humans UI thing. > I decided to put it to the right of the slider because on the left, the factor is constantly changing its size, making the text jump around. Good to have this documented. I do feel that this ordering (label to the right of the value) makes this part of the UI feel a bit inconsistent with the rest of Blender's UI. Would it be much work to move the factor to the right, and the label to the left of the slider? I also wonder what @pablovazquez thinks about this.
@ -83,1 +84,4 @@
/* Optional string that will display next to the slider to indicate which property is modified
* right now. */
char property_name[SLIDER_PROPERTY_STRING_SIZE];

Given that this is runtime data that's owned by tSlider anyway, do we need a fixed-size char[]? Or could we just use std::string instead? That could get rid of the fixed array size. Passing references around could then be via a StringRef instead of const char *.

Given that this is runtime data that's owned by `tSlider` anyway, do we need a fixed-size `char[]`? Or could we just use `std::string` instead? That could get rid of the fixed array size. Passing references around could then be via a `StringRef` instead of `const char *`.
@ -363,1 +382,4 @@
fontid, factor_string_pos_x, (region->winy / 2) - factor_string_pixel_size[1] / 2, 0.0f);
BLF_draw(fontid, factor_string, sizeof(factor_string));
if (slider->property_name) {

warning: address of array 'slider->property_name' will always evaluate to 'true'

I think you want if (slider->property_name[0])

`warning: address of array 'slider->property_name' will always evaluate to 'true'` I think you want `if (slider->property_name[0])`
dr.sybren marked this conversation as resolved
Author
Member

Would it be much work to move the factor to the right, and the label to the left of the slider?

Not at all. The reason why it was on the left in the first place is because it means the % will be less prone to jumping around. But I think we can mitigate that. I agree it would make more sense to have the unit name on the left

> Would it be much work to move the factor to the right, and the label to the left of the slider? Not at all. The reason why it was on the left in the first place is because it means the % will be less prone to jumping around. But I think we can mitigate that. I agree it would make more sense to have the unit name on the left
Christoph Lendenfeld added 1 commit 2024-04-09 13:05:46 +02:00
Christoph Lendenfeld added 1 commit 2024-04-09 15:36:35 +02:00
Member

Would it be much work to move the factor to the right, and the label to the left of the slider? I also wonder what @pablovazquez thinks about this.

Thanks for bringing this up!

Yes. Since the UI is meant to be read left-to-right, it would be more consistent to have the label on the left and values on the right.

mockup

> Would it be much work to move the factor to the right, and the label to the left of the slider? I also wonder what @pablovazquez thinks about this. Thanks for bringing this up! Yes. Since the UI is meant to be read left-to-right, it would be more consistent to have the label on the left and values on the right. ![mockup](/attachments/ba67038e-ec02-47ea-80c6-8aa83b4fcf6a)
Christoph Lendenfeld added 2 commits 2024-04-11 14:48:16 +02:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2024-04-11 14:53:22 +02:00
Author
Member

@dr.sybren @pablovazquez I changed the order of the slider to read left to right.
The percentage number on the right does jump around a bit now, but I don't feel it is too distracting.
Example images in the PR description have been updated.

@dr.sybren @pablovazquez I changed the order of the slider to read left to right. The percentage number on the right does jump around a bit now, but I don't feel it is too distracting. Example images in the PR description have been updated.
Member

Thanks! Haven't compiled this patch yet but by looking at the screenshots it seems the label is overflowing the background?

Made the image brighter so it's easier to spot:
label

It's also rounded on the left but not the right, might have to do with that? Some kind of offset.

Thanks! Haven't compiled this patch yet but by looking at the screenshots it seems the label is overflowing the background? Made the image brighter so it's easier to spot: ![label](/attachments/d875a7ba-a559-4475-b7d3-c31d63b972bf) It's also rounded on the left but not the right, might have to do with that? Some kind of offset.
6.7 KiB
Christoph Lendenfeld added 1 commit 2024-04-11 15:57:11 +02:00
Author
Member

@pablovazquez well spotted. Didn't see that on my screen but I forgot to change the backdrop padding with the text

@pablovazquez well spotted. Didn't see that on my screen but I forgot to change the backdrop padding with the text
Christoph Lendenfeld added 1 commit 2024-04-19 14:34:46 +02:00
Sybren A. Stüvel approved these changes 2024-04-22 12:22:46 +02:00
Sybren A. Stüvel left a comment
Member

Just a small (but important) note, can be handled when landing.

Just a small (but important) note, can be handled when landing.
@ -364,0 +384,4 @@
float property_name_pixel_size[2];
BLF_width_and_height(fontid,
slider->property_label.c_str(),
sizeof(slider->property_label),

sizeof is incorrect here, I think you need slider->property_label.length()

`sizeof` is incorrect here, I think you need `slider->property_label.length()`
@ -364,0 +391,4 @@
main_line_rect.xmin - text_padding - property_name_pixel_size[0],
(region->winy / 2) - property_name_pixel_size[1] / 2,
0.0f);
BLF_draw(fontid, slider->property_label.c_str(), sizeof(slider->property_label));

same sizeof here

same `sizeof` here
Christoph Lendenfeld added 2 commits 2024-04-23 10:41:00 +02:00
Christoph Lendenfeld merged commit 78583bf22e into main 2024-04-25 15:48:32 +02:00
Christoph Lendenfeld deleted branch slider_show_modified_property 2024-04-25 15:48:35 +02:00
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#119920
No description provided.