Skip to content

Add the unit, display_decimal_places, and step parameter widget macro attributes #2706

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

Merged
merged 10 commits into from
Jun 15, 2025

Conversation

Ripper53
Copy link
Contributor

@Ripper53 Ripper53 commented Jun 11, 2025

  • unit macro for a unit suffix, eg. "°" or " px"
  • display_decimal_places to show certain amount of decimal places for float numbers (default 2)
  • step for little arrows on each end of a number input to increment and decrement based on the step value (default 1.)

Example Usage

Code:

#[unit(" MEOW")]
#[display_decimal_places(4)]
#[step(2.)]
meow_num: f64

Expected result shown in image after adjusting value to 2.51231237:
image


Macros are not being used anywhere except in the copy_to_points function inside of vector_nodes.rs, however, these were already being used before and I believe they were not doing anything because a unit macro did not exist. The Multiplier field already added a unit suffix of "x" so the unit macro does not provide any utility, though, I have left it unchanged.

The way I tested to make sure these macros work:

  1. Add a f64 field to the repeat function in vector_nodes.rs with the new macros
  2. Compile code and in Graphite, add a Repeat node to a shape
  3. See if the new field within the Repeat node changes depending on the parameters of the new macros

@Keavon Keavon changed the title unit, display_decimal_places, and step macros Add the unit, display_decimal_places, and step parameter widget macro attributes Jun 11, 2025
@Ripper53 Ripper53 marked this pull request as ready for review June 11, 2025 02:53
@Keavon Keavon enabled auto-merge (squash) June 15, 2025 00:19
@Keavon Keavon merged commit 2c673d0 into GraphiteEditor:master Jun 15, 2025
4 checks passed
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.

2 participants