UI: Unit completion hint when text editing #116103

Open
Falk David wants to merge 9 commits from filedescriptor/blender:ui-unit-text-completion into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Summary

This PR adds a useful little hint when typing into number fields with units.

image
image

Works for different scene unit defaults:
image

And also deals with pixel values and percentages seperately (they are not "units"):
image

This is especially useful when the unit is set to "Adaptive":

Notice that the previous value is in centimeters, but typing into the field actually defaults to meters (using adaptive units).
Previously, the user would not have a visual indication of what units will be used when entering a value.

Details

This PR does 2 things:

  1. Adds a completion string on a uiBut that gets displayed during text editing after whatever is currently being typed. This is drawn with the same faded color as the placeholder text.
  2. Sets the completion string for text buttons that use a unit to the unit set in the scene settings (or the default).
## Summary This PR adds a useful little hint when typing into number fields with units. ![image](/attachments/4a3bf751-494c-4b45-b1cc-34e904168ce6) ![image](/attachments/397db290-4494-4bc2-afea-760142fcfd8c) Works for different scene unit defaults: ![image](/attachments/0fe0e36c-d8ae-46dc-9582-2164a9fd0f9e) And also deals with pixel values and percentages seperately (they are not "units"): ![image](/attachments/858c8eb4-860f-4a65-a5c3-0e4f4c3ee061) This is especially useful when the unit is set to "Adaptive": <video muted controls src="/attachments/b94db13c-10b7-4af4-b4b1-079ac88c600f" type="video/mp4"/> Notice that the previous value is in centimeters, but typing into the field actually defaults to meters (using adaptive units). Previously, the user would not have a visual indication of what units will be used when entering a value. ## Details This PR does 2 things: 1) Adds a `completion` string on a `uiBut` that gets displayed during text editing after whatever is currently being typed. This is drawn with the same faded color as the `placeholder` text. 2) Sets the `completion` string for text buttons that use a unit to the unit set in the scene settings (or the default).
Falk David added 1 commit 2023-12-12 18:33:57 +01:00
Brecht Van Lommel requested review from Harley Acheson 2023-12-12 20:56:42 +01:00
Member

That's pretty neat!

It feels so good though that it does feel incomplete in areas when you don't see it. Like Output / Format Resolution not showing "px" or percentages not showing "%"

That's pretty neat! It feels so good though that it does feel incomplete in areas when you don't see it. Like Output / Format Resolution not showing "px" or percentages not showing "%"
Falk David added 2 commits 2023-12-13 12:47:17 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-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-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
8a6918b5cc
Add completion for pixel and percentage values
Falk David changed title from UI: Default base unit completion when text editing to UI: Unit completion hint when text editing 2023-12-13 12:47:31 +01:00
Iliya Katushenock added this to the User Interface project 2023-12-13 12:48:50 +01:00
Author
Member

@blender-bot build

@blender-bot build
Member

First, I need to say I love this idea. For me its only "problem" is that it is so cool that it becomes an expected thing so any time it doesn't appear or work as expected it causes a dissonance. Basically it has to work almost flawlessly, but we have some existing behavior (not introduced here) that might hinder that.

A very small example that is probably an easy thing to fix. It is so nice that it now works with "px" and percentages, but it doesn't show these hints at all the times I would expect. I click on a "90%" value and I just see "90" selected without the %. I insert my text cursor, use arrows to move it left and right, still no percentage. It only shows up if I start changing the value by deleting a character.

respx.gif

If I do so with a meter length value it is a little different. I click on a field that says "12 m" and I am now editing the string "12 m". I remove the "m" it now shows your "m" afterward. I still have another space to remove. Now I am editing "12" and it shows your "m" afterward. Select those two numbers and that "m" disappears while the mouse pointer is down but reappears when you release.

rem.gif

This current behavior of including the units in the editable string gets a bit weirder when the short and long descriptions of the unit differs.

You have a rotation field currently set to "12 °". As above, just click on the field and it shows "12d". Insert your mouse text cursor to the right of that and you are now editing the string "12d". Backspace to remove the "d" and now it shows you are editing "22" and it shows a degree symbol. But if you instead remove the "1" and/or "2" and you just have a "d".

redeg.gif

This existing behavior of having the units being part of the edited string is a little in conflict with your new behavior. I understand why it is there, as it helps lead the user to realize they can type things like "12 cm" into an input that shows meters. But when I do so I then have something showing "0.12 m", so it only ever displays the actual base units. So maybe with your change we could not show the units as part of the editable string, but only show your hint?

First, I need to say I love this idea. For me its only "problem" is that it is so cool that it becomes an expected thing so any time it doesn't appear or work as expected it causes a dissonance. Basically it has to work almost flawlessly, but we have some existing behavior (not introduced here) that might hinder that. A very small example that is probably an easy thing to fix. It is so nice that it now works with "px" and percentages, but it doesn't show these hints at all the times I would expect. I click on a "90%" value and I just see "90" selected without the %. I insert my text cursor, use arrows to move it left and right, still no percentage. It only shows up if I start changing the value by deleting a character. ![respx.gif](/attachments/dc1df7fa-0206-4967-b516-5caae17ecd89) If I do so with a meter length value it is a little different. I click on a field that says "12 m" and I am now editing the string "12 m". I remove the "m" it now shows your "m" afterward. I still have another space to remove. Now I am editing "12" and it shows your "m" afterward. Select those two numbers and that "m" disappears while the mouse pointer is down but reappears when you release. ![rem.gif](/attachments/abce9f6d-63b1-450b-83c7-4d893cd72310) This _current behavior_ of including the units in the editable string gets a bit weirder when the short and long descriptions of the unit differs. You have a rotation field currently set to "12 °". As above, just click on the field and it shows "12d". Insert your mouse text cursor to the right of that and you are now editing the string "12d". Backspace to remove the "d" and now it shows you are editing "22" and it shows a degree symbol. But if you instead remove the "1" and/or "2" and you just have a "d". ![redeg.gif](/attachments/05f6f605-ef47-48b8-bc32-3f2406e9da1e) This existing behavior of having the units being part of the edited string is a little in conflict with your new behavior. I understand why it is there, as it helps lead the user to realize they can type things like "12 cm" into an input that shows meters. But when I do so I then have something showing "0.12 m", so it only ever displays the actual base units. So maybe with your change we could not show the units as part of the editable string, but only show your hint?
Author
Member

@Harley Thanks for the feedback!
Yes, I noticed 1) too when playing with the patch. Seems like that should be an easy fix.

I agree with your other remarks as well. It seems like with this "completion", we shouldn't need the default unit in the string anymore when editing. It's almost trying to do the same thing in a way.

So maybe an approach would be:

  • When editing a (unit/pixel/percentage) value, only the numerical part is in the edit string (selected)
  • The unit is automatically shown in the completion
  • If the user enters a different unit, the completion disapears (like it does now).
@Harley Thanks for the feedback! Yes, I noticed 1) too when playing with the patch. Seems like that should be an easy fix. I agree with your other remarks as well. It seems like with this "completion", we shouldn't need the default unit in the string anymore when editing. It's almost trying to do the same thing in a way. So maybe an approach would be: * When editing a (unit/pixel/percentage) value, only the numerical part is in the edit string (selected) * The unit is automatically shown in the completion * If the user enters a different unit, the completion disapears (like it does now).
Member

It seems like with this "completion", we shouldn't need the default unit in the string anymore when editing. It's almost trying to do the same thing in a way.

Yes, my gut feeling is that this unit hint could replace the unit in the editable string and would feel much better. Maybe.

I can imagine the more technical-minded of us liking that rotation entry shows that "d" in that it might be a hint you could enter "r". And maybe showing "m" might make you try "cm".

But entering values in our inputs is a modal operation. Maybe the status bar could show the user all the things that can be entered. Like different units, or math. Or how to add characters by Unicode value, etc. I think we have a bunch of hidden features we could show.

Another thing to consider is what strings are actually shown for this hint. The short versions you have selected might be best, but you don't necessarily have to show the same things while editing. You could show "meters" while editing even though it shows "m" afterward. That example is weird but consider rotation if the scene units are Radians. We currently show no symbol for radians, although we could use something like superscript R, like ᴿ. But while editing it could show "rad" or even "radians".

> It seems like with this "completion", we shouldn't need the default unit in the string anymore when editing. It's almost trying to do the same thing in a way. Yes, my gut feeling is that this unit hint could replace the unit in the editable string and would feel much better. Maybe. I can imagine the more technical-minded of us liking that rotation entry shows that "d" in that it might be a hint you could enter "r". And maybe showing "m" might make you try "cm". But entering values in our inputs is a modal operation. Maybe the status bar could show the user all the things that can be entered. Like different units, or math. Or how to add characters by Unicode value, etc. I think we have a bunch of hidden features we could show. Another thing to consider is what strings are actually shown for this hint. The short versions you have selected might be best, but you don't necessarily have to show the same things while editing. You could show "meters" while editing even though it shows "m" afterward. That example is weird but consider rotation if the scene units are Radians. We currently show no symbol for radians, although we could use something like superscript R, like ᴿ. But while editing it could show "rad" or even "radians".
Falk David added 2 commits 2023-12-13 19:18:12 +01:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
219b3c4468
Don't append unit when entering text editing
Author
Member

@Harley I pushed the fix for the first issue and an experimental commit to try out removing the unit in the text string and replacing it with the hint

image.gif

@Harley I pushed the fix for the first issue and an experimental commit to try out removing the unit in the text string and replacing it with the hint ![image.gif](/attachments/d081626b-73c9-477f-a2d0-b256fba4576a)
Author
Member

@blender-bot build

@blender-bot build
Member

That is so nice. It feels so natural and seems to fit in a way with the placeholders, both guiding in similar ways.

It is also a bit less disruptive when transitioning to/from editing. The entirety of what is shown is there when you start editing, with the unit looking disabled. And that is a good thing, it looks way better.

FocalLength.gif

Of course this effect erases my earlier idea of showing something more detailed while editing.

That is so nice. It feels so natural and seems to fit in a way with the placeholders, both guiding in similar ways. It is also a bit less disruptive when transitioning to/from editing. The entirety of what is shown is there when you start editing, with the unit looking disabled. And that is a good thing, it looks way better. ![FocalLength.gif](/attachments/2302291b-b04e-4785-800d-9e5ca43e1f56) Of course this effect erases my earlier idea of showing something more detailed while editing.
Member

So far the only place I'm not seeing it work is in 3DView Sidebar, Item, Dimensions.

So far the only place I'm not seeing it work is in 3DView Sidebar, Item, Dimensions.
Author
Member

Hm seems like the dimensions are some special property. Have to investigate this further.
I also noticed that multi-field editing is not working with the completion:
image

Hm seems like the dimensions are some special property. Have to investigate this further. I also noticed that multi-field editing is not working with the completion: ![image](/attachments/2d88cfeb-f580-4330-8d80-da63be94a791)
7.7 KiB
Falk David added 1 commit 2023-12-14 11:29:03 +01:00
Author
Member

So far the only place I'm not seeing it work is in 3DView Sidebar, Item, Dimensions.

Fixed! :)

> So far the only place I'm not seeing it work is in 3DView Sidebar, Item, Dimensions. Fixed! :)
Falk David added 1 commit 2023-12-14 12:01:21 +01:00
Falk David added 1 commit 2023-12-14 12:25:21 +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-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
5fb4003dff
Show completion when editing text across multiple buttons
Author
Member

@blender-bot build

@blender-bot build
Falk David added 1 commit 2023-12-14 13:36:36 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
3e5729c5cf
Formatting
Author
Member

@blender-bot build

@blender-bot build
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR116103) when ready.
Member

I love this feature, I’ve just noticed a quirk with the lights’ power in watts. This unit appears to be adaptive, without the user being able to choose so. 0.001 W is displayed as 1 mW, 1E6 W as 1 MW, etc. (1000 is still displayed as 1000 W for some reason).
When the value is e.g. 1 MW and you click to edit, the field goes back to 1 W, probably because the sub-unit is not detected.

I love this feature, I’ve just noticed a quirk with the lights’ power in watts. This unit appears to be adaptive, without the user being able to choose so. 0.001 W is displayed as 1 mW, 1E6 W as 1 MW, etc. (1000 is still displayed as 1000 W for some reason). When the value is e.g. 1 MW and you click to edit, the field goes back to 1 W, probably because the sub-unit is not detected. <video src="/attachments/e29970d2-128d-44f7-b22e-56dbc6c1c9e2" title="light_power.mp4" controls></video>
Author
Member

@pioverfour Indeed that is a bug I will have to fix :) Thanks for testing.

@pioverfour Indeed that is a bug I will have to fix :) Thanks for testing.
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
This pull request has changes conflicting with the target branch.
  • source/blender/blenkernel/intern/unit.cc
  • source/blender/editors/interface/interface.cc
  • source/blender/editors/interface/interface_intern.hh
  • source/blender/editors/transform/transform_mode_shrink_fatten.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u ui-unit-text-completion:filedescriptor-ui-unit-text-completion
git checkout filedescriptor-ui-unit-text-completion
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
4 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#116103
No description provided.