Skip to content
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

Feature: Add API for Paragraph's Bounds #537

Closed
JordanMartinez opened this issue Jun 27, 2017 · 3 comments
Closed

Feature: Add API for Paragraph's Bounds #537

JordanMartinez opened this issue Jun 27, 2017 · 3 comments

Comments

@JordanMartinez
Copy link
Contributor

To help implement #77 and #405, there should be some API to calculate a given paragraph's bounds by its index (the index in the list of visible paragraphs and all paragraphs). For example

public final Optional<Bounds> paragraphBounds(int parIndex);
public final Optional<Bounds> visibleParagraphBounds(int parIndex);
@maPaydar
Copy link

Hi.
when you wanna implement that ?
i need some widget that show styled texts and emojis and be selecteble. some thing like generic styled area node.
but i want the height of node wrap height of text.

thanks you.

@dlemmermann
Copy link

Yes, this would be very critical for my current project, too.

@JordanMartinez
Copy link
Contributor Author

My question is, should the returned bounds object always be the area's width? Or should it only be limited to the area's width when it spans outside of the area? For example

         Area
       |------|
Line 1 |------|----
Line 2 |---   |
       |______|

In the case of Line 1, the area's width should be used because the second half of it is not visible. Thus, the area's width limits it.
However, in the case of Line 2, it doesn't take up all of the area's width. Should the bounds object use the line's actual width? Or just default to the area's width?

In #587, I chose the second option because someone might want to use the bounds to determine whether or not the user clicked on the paragraph. If the first option is used, they would need to click directly on the text. If the second is used, they can click on the text or somewhere in the paragraph's vertical region.

@maPaydar and @dlemmermann It would help to know what your use cases are to provide feedback on this API.

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

No branches or pull requests

3 participants