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

Add a handler for converting view frame to other coordinate systems #65

Open
sedyh opened this issue Oct 20, 2023 · 3 comments
Open

Add a handler for converting view frame to other coordinate systems #65

sedyh opened this issue Oct 20, 2023 · 3 comments

Comments

@sedyh
Copy link

sedyh commented Oct 20, 2023

Hello. Just tried to use furex for my project and it seems great, but since I can zoom the camera closer, I need to adjust the position of the root view and the sizes of all child views to be able to scale according to this number with the layout rearranged during zoom. Is it possible to add some FrameHandler / UIScale *float64 / WorldToScreenConverter to do this automatically?
Right now I'm updating them manually via Left/Top/Width/Height + Layout().

@sedyh sedyh changed the title Add a handler for converting frame to other coordinate systems Add a handler for converting view frame to other coordinate systems Oct 20, 2023
@yohamta
Copy link
Owner

yohamta commented Oct 21, 2023

Hello @sedyh 👋, thanks for the great suggestion! Yeah, I like the idea and it seems really awesome. Would you happen to have the implementation idea already? If that's the case, I really appreciate if you would kindly spare a moment to create a PR for it.

Is it possible to add some FrameHandler / UIScale *float64 / WorldToScreenConverter to do this automatically?

@sedyh
Copy link
Author

sedyh commented Oct 21, 2023

Well, I have some sort of FrameHandler but it's not finished yet, I'll probably make a PR later.
Btw, is it possible to not specify the size of the root element? I would like it to be calculated depending on the sizes of the internal elements or with a minimum size, as in css.

@yohamta
Copy link
Owner

yohamta commented Oct 22, 2023

Oh that's really great, thanks a lot!

Btw, is it possible to not specify the size of the root element? I would like it to be calculated depending on the sizes of the internal elements or with a minimum size, as in css.

Yeah, I think that's possible. Right now, it only calculates the size of the children's view during layout.
But we could probably introduce a functional option parameter or maybe even a new constructor that lets you create an instance without needing the size(width, height) parameter.

furex/view.go

Lines 81 to 97 in 78826a5

func (v *View) startLayout() {
v.lock.Lock()
defer v.lock.Unlock()
if !v.hasParent {
v.frame = image.Rect(v.Left, v.Top, v.Left+v.Width, v.Top+v.Height)
}
v.flexEmbed.View = v
for _, child := range v.children {
if child.item.Position == PositionStatic {
child.item.startLayout()
}
}
v.layout(v.frame.Dx(), v.frame.Dy(), &v.containerEmbed)
v.isDirty = false
}

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

No branches or pull requests

2 participants