Skip to content

Clean up numeric EditorProperty setup() methods#108065

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
lodetrick:range-hint-cleanup
Oct 14, 2025
Merged

Clean up numeric EditorProperty setup() methods#108065
Repiteo merged 1 commit intogodotengine:masterfrom
lodetrick:range-hint-cleanup

Conversation

@lodetrick
Copy link
Contributor

@lodetrick lodetrick commented Jun 28, 2025

Currently, the numeric EditorProperty setup() methods are somewhat brittle. When these properties are created, they are first bundled into a struct, which is then destructed in the method call. This PR changes the signature of the numeric setup() calls to use the struct directly. This has several benefits:

  • If any new functionality is wanted for these properties (like in Allow @export_range to support numeric types #105878), this change makes it easy to make these changes without adding any arguments.
  • It removes the use of "magic numbers". In several internal files, EditorPropertyIntegers are created directly (I don't know how much this should be encouraged). Their setup() calls have many seemingly arbitrary numbers and booleans that are hard to understand without looking at the editor_properties.h file. This change makes it clear within the file what the parameters that the code is changing.

Note: In making this change I found multiple invalid calls to setup(), most looking like: setup(-1, 99999, true); where there is a boolean in the third argument (which is defined as double p_step). I'm not sure what the intention was originally, but making this change will prevent future invalid calls and help catch other invalid calls before they are propagated.

@lodetrick lodetrick requested a review from a team June 28, 2025 00:45
@lodetrick lodetrick force-pushed the range-hint-cleanup branch from 79be1dc to 11e31fd Compare June 28, 2025 00:56
@lodetrick lodetrick changed the title Clean Up numeric EditorProperty setup() methods Clean up numeric EditorProperty setup() methods Jun 28, 2025
@AThousandShips AThousandShips added this to the 4.x milestone Jun 30, 2025
@lodetrick lodetrick requested a review from a team as a code owner September 25, 2025 21:20
@lodetrick lodetrick requested review from a team September 25, 2025 21:20
@KoBeWi
Copy link
Member

KoBeWi commented Oct 8, 2025

This could wait for #100749
C++20 has a nice syntax for initializing structs, like

property->setup(EditorPropertyRangeHint{ .min = range.x, .max = range.y, .or_greater = false, or_less = false });

etc.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

The new syntax I mentioned in #108065 (comment) could be applied later, the struct doesn't look directly created that much.

@lodetrick
Copy link
Contributor Author

Updated the function signatures as suggested by KoBeWi

@Repiteo Repiteo modified the milestones: 4.x, 4.6 Oct 13, 2025
@Repiteo Repiteo merged commit 2568505 into godotengine:master Oct 14, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 14, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants