Skip to content

Provide useful API to access Node bounds #252

@ystrot

Description

@ystrot

There were several issues related to Node bounds calculation and I think it makes sense to keep all discussions in one place. This is actually a complicated task, because bounds calculation requires rendering context and in fact it's only accessible after drawing. However users don't want to think about such implementation details, instead they want to be able to access Node bounds immediately after creation and access actual information even after some updates.

This task might be implemented during several milestones, so we need to provide useful workaround for current issues. So here is a plan:

  1. We'll provide temporary public utility method to calculate Node bounds. This method will create synthetic rendering context and calculate bounds using this context once. This step is workaround to solve current issues.
  2. We'll provide Node.bounds() -> Rect method. This method will work immediately and access actual information. In the first version we'll just use utility method from step 1.
  3. Implementation from step 2 will be very slow and we actually don't need to recalculate bounds on each call, because we can just use cache to remember bounds. Moreover, during rendering we calculate bounds anyway, so if we render Node we don't need to use synthetic context. So on this step we'll provide complicated implementation to make a fast and useful solution to calculate bounds.
  4. Finally, good implementation will allow us to add ability to monitor Node.bounds changes and it will make possible complicated layouts for nodes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions