godot icon indicating copy to clipboard operation
godot copied to clipboard

Add Automatic Pivot Offset Adjustment to Control Node

Open Raftatul opened this issue 1 year ago • 8 comments

Automatically adjusted pivot offset using percent.

This PR adds a new feature that lets a Control node's pivot offset be automatically adjusted. Two more variables, pivot_offset_percent and pivot_mode, can be used to govern the adjustment.

pivot_mode:

  • PIVOT_MODE_PIXEL: Godot pivot offset in basic form
  • PIVOT_MODE_PERCENT: To modify the pivot offset depending on the control size, use a percent between 0 and 1 (more or less is allowed).

pivot_offset_percent:

This variable represent the offset percent of the pivot point. Example:

pivot_offset_percent = (0.5, 0.5)
size = (100.0, 100.0)

pivot_offset will be set to (50, 50)

In Editor

Raftatul avatar Sep 05 '24 22:09 Raftatul

It works but has the same issue as https://github.com/godotengine/godot/pull/70646#issuecomment-2002652414 It's probably better to call it ratio, it shows 0.5% in the UI now

passivestar avatar Sep 05 '24 23:09 passivestar

Also doesn't work with clip_contents but I believe that's a separate issue.

markdibarry avatar Sep 05 '24 23:09 markdibarry

It works but has the same issue as #70646 (comment) It's probably better to call it ratio, it shows 0.5% in the UI now

Thank you for the responses ! I'll take you feedbacks into count.

Raftatul avatar Sep 05 '24 23:09 Raftatul

Also doesn't work with clip_contents but I believe that's a separate issue.

What is exactly not working ? How do you recreate it ?

Raftatul avatar Sep 05 '24 23:09 Raftatul

Just rotate a Control with clip_contents enabled. Screenshot from 2024-09-05 20-27-14 Screenshot from 2024-09-05 20-27-38

Support for rotation with Control nodes is just limited at the moment, so this PR doesn't hurt, but it should still be avoided if clip_contents is enabled.

markdibarry avatar Sep 06 '24 00:09 markdibarry

but I believe that's a separate issue.

Yes: #20671

KoBeWi avatar Sep 06 '24 00:09 KoBeWi

would love to see this feature in engine :)

GeorgeDubuque avatar Sep 26 '24 02:09 GeorgeDubuque

Can't wait to see this in the engine!

MaltinR avatar Sep 27 '24 01:09 MaltinR

Why has this been closed?

Mickeon avatar Nov 30 '24 22:11 Mickeon