Public API to Retrieve Width/Height Type #1801

Closed
opened 2025-03-12 09:50:15 -07:00 by ehopperdietzel · 3 comments
ehopperdietzel commented 2025-03-12 09:50:15 -07:00 (Migrated from github.com)

Hi,

Is there a way to determine the type of width/height that has been set for a node? For instance, how can I differentiate if a width was defined using setWidth, setWidthPercent, or setWidthAuto?

A potential use case for this would be determining the smallest size of a node based on its content, where the workflow might look something like this:

  1. Save the node's current size type and values.
  2. Set width/height to auto.
  3. Calculate and store the resulting dimensions.
  4. Restore the initial size type and values.

If such an API doesn’t exist, could you clarify what the default size type is for each axis of a node?

Thank you!

Hi, Is there a way to determine the type of width/height that has been set for a node? For instance, how can I differentiate if a width was defined using `setWidth`, `setWidthPercent`, or `setWidthAuto`? A potential use case for this would be determining the smallest size of a node based on its content, where the workflow might look something like this: 1. Save the node's current size type and values. 2. Set width/height to auto. 3. Calculate and store the resulting dimensions. 4. Restore the initial size type and values. If such an API doesn’t exist, could you clarify what the default size type is for each axis of a node? Thank you!
ehopperdietzel commented 2025-03-12 10:03:19 -07:00 (Migrated from github.com)

I apologize, according to the documentation, the default type is set to auto. However, it would be beneficial to have an API that exposes this information to avoid the need for manually keeping track of it ourselves.

I apologize, according to the [documentation](https://www.yogalayout.dev/docs/styling/width-height), the default type is set to auto. However, it would be beneficial to have an API that exposes this information to avoid the need for manually keeping track of it ourselves.
NickGerleman commented 2025-03-12 15:35:18 -07:00 (Migrated from github.com)

Which language is this for? APIs like getWidth() should return a structure with both a value and unit. "auto" is, maybe unintuitively, considered its own unit.

Which language is this for? APIs like `getWidth()` should return a structure with both a value and unit. "auto" is, maybe unintuitively, considered its own unit.
ehopperdietzel commented 2025-03-12 15:51:22 -07:00 (Migrated from github.com)

C++ and omg! I had seen that, but I misread it as 'uint' and assumed it was an unsigned integer, possibly for internal calculations. My bad! And thank you!

C++ and omg! I had seen that, but I misread it as 'uint' and assumed it was an unsigned integer, possibly for internal calculations. My bad! And thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1801
No description provided.