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 an example of compareable solvers in a README? #113

Open
dimsuz opened this issue Dec 3, 2020 · 5 comments
Open

Add an example of compareable solvers in a README? #113

dimsuz opened this issue Dec 3, 2020 · 5 comments

Comments

@dimsuz
Copy link

dimsuz commented Dec 3, 2020

I've only now watched Adam's presentation about Contour and while I was using it for some time now, this slide blew my mind

I've been occasionally struggling with the fact that sometimes I want one solver and sometimes (depending on view config) another. As a result I had to invent some clever tricks, while I didn't know about this feature.

Can it be somehow made more obvious? Perhaps a mention in README or in some other documentation source?

@dimsuz
Copy link
Author

dimsuz commented Dec 3, 2020

Another feature I constantly wish to have is having maxOf(), minOf() being available not only for 2 parameters, but any number of them (varargs?). This can be worked around with maxOf(xint1.value, xint2.value, xint3.value).toXInt() but feels hacky. If this is something possible I can create another issue (and perhaps a PR later).

@saket
Copy link
Collaborator

saket commented Dec 3, 2020

This would fit very well with #87.

Another feature I constantly wish to have is having maxOf(), minOf() being available not only for 2 parameters, but any number of them (varargs?).

I agree, but adding new solvers may not be very scalable. It'd be really nice to have an axis solver of type () -> XAxisSolver so that people can mix any kind of lazy-evaluated solvers depending on view config. We haven't felt a strong need for this yet because it's still indirectly doable (as you mentioned) but I would be interested in seeing this happen.

@dimsuz
Copy link
Author

dimsuz commented Dec 3, 2020

I now feel I shouldn't have mixed min/max in this issue. I actually was referring not to minOf/maxOf on solvers, but rather their overloads on XInt/YInt. I sometimes find myself having not 2, but 3 or 4 views where I want to write

view1.layoutBy(x = leftTo { maxOf(view2.left(), view3.left(), view4.left(), ...) })

As for solvers probably 2 would be the most common case here, so I agree that this perhaps has to be still proven as really needed to make it into a library...

As for the issue, if it's covered by #87 then this one should be closed, Recipes is a perfectly good place for this stuff! :)

@saket
Copy link
Collaborator

saket commented Jan 11, 2021

Sorry I forgot to follow-up. Yeah I wouldn't be against adding more overloads if others are running into it too. For now, I'd recommend maintaining an extension function for your project?

@dimsuz
Copy link
Author

dimsuz commented Jan 11, 2021

Yeah, I did extension function for minOf(XInt/YInt), like this:

fun ContourLayout.minOf(y1: YInt, y2: YInt, y3: YInt): YInt {
  return minOf(minOf(y1, y2), y3)
}

but unfortunately I can't do the same for YAxisSolver, because there's no minOf overload which accepts access solvers (which would be produced by the inner minOf above)

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