Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust brush size with hotkeys #14638

Merged
merged 6 commits into from
Jan 20, 2024

Conversation

WebDev9000
Copy link
Contributor

@WebDev9000 WebDev9000 commented Jan 13, 2024

Description

Allows the brush size on the canvas to be adjusted via [ and ] Edit: Q and W keys
(Changed due to console error with non a-z keys)

Screenshots/videos:

slider

Checklist:

@w-e-w
Copy link
Collaborator

w-e-w commented Jan 14, 2024

not objecting but isn't scroll wheel enough?


if the hotkey is going to be added it they should be corresponding option to disable the hotkey

"canvas_disabled_functions": shared.OptionInfo(["Overlap"], "Disable function that you don't use", gr.CheckboxGroup, {"choices": ["Zoom","Adjust brush size", "Moving canvas","Fullscreen","Reset Zoom","Overlap"]}),

image

and the [ ] keys should be configurable similar to other hotkeys keys
image


cc: @daswer123

he's the person that made Canvas Zoo

@WebDev9000
Copy link
Contributor Author

WebDev9000 commented Jan 14, 2024

not objecting but isn't scroll wheel enough?

  • I prefer hotkeys as small adjustments are easier
  • it's easier to not move the brush location in the process
  • It's intuitive if you're use to standard paint apps
  • If you're using a tablet to sketch, you won't have a scroll wheel
  • It's just another shortcut to do what Gradio already does on the UI, like all the others.

if the hotkey is going to be added it they should be corresponding option to disable the hotkey
and the [ ] keys should be configurable similar to other hotkeys keys

Honestly didn't know these sections existed, I'll see about adding in the configs.
It looks like I accidentally used "defaultHotkeysConfig" instead of "hotkeysConfig". I'll change that as well.

@w-e-w
Copy link
Collaborator

w-e-w commented Jan 14, 2024

not objecting but isn't scroll wheel enough?

I prefer hotkeys as small adjustments are easier

okay fair enough, like I said I don't have objections just curious

If you're using a tablet to sketch, you won't have a scroll wheel

well, depends on your tablet mine does have scroll wheel, good point that not every tablet has a screw wheel

Honestly didn't know these sections existed, I'll see about adding in the configs.
It looks like I accidentally used "defaultHotkeysConfig" instead of "hotkeysConfig". I'll change that as well.

👍

@WebDev9000
Copy link
Contributor Author

WebDev9000 commented Jan 14, 2024

okay fair enough, like I said I don't have objections just curious

No worries, it probably just comes down to hardware and preference. My mousewheel isn't very accurate, and my tablet doesn't have a scrollwheel.

The config changes are in and tested...

image
image

everything works - disabling, changing hotkeys, but I've hit a snag:

When set back to [ and ] there is a console error:

zoom.js?1705224988.3909583:136 Hotkey: [ for canvas_hotkey_shrink_brush is not valid. The default hotkey is used: BracketLeft
zoom.js?1705224988.3909583:136 Hotkey: ] for canvas_hotkey_grow_brush is not valid. The default hotkey is used: BracketRight

However, the keys function fine.

I can add [ and ] to the valid test by adjusting Zoom.js line 84 /[a-z]/i.test(value)) || to /[a-z\[\]]/i.test(value)) ||, which will get rid of the console log, but then the keys will not actually work, I believe because it needs BracketLeft and BracketRight instead, which they fallback to above.

I'm open to suggestions. One option is to let them fallback, and if the keys are [ or ], don't display the error.
A simple option is to just use different keys instead of [ and ], like Q and W.

@daswer123 - any ideas on allowing [ and ] via the config?

@WebDev9000
Copy link
Contributor Author

WebDev9000 commented Jan 20, 2024

I want to leave this PR in a good state, so I've switched the default keys to Q and W.
Personally I prefer [ and ] as it's more standard, but this should resolve any outstanding issues.

@AUTOMATIC1111 AUTOMATIC1111 merged commit 5cbda43 into AUTOMATIC1111:dev Jan 20, 2024
3 checks passed
@w-e-w w-e-w mentioned this pull request Feb 17, 2024
@alexbofa
Copy link

Hello, Canvas Zoom had this feature built in commit 120f46e but it was done on the [ ] keys in the same way as in photoshop

@daswer123 Pay attention to this PR

@pawel665j pawel665j mentioned this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants