-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Move to float32 coordinates #1661
Conversation
It was in there already for the |
I have no problem it it, it just seemed like something that could be done as a function that takes the interface instance as an arg. It's pretty trivial either way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of questions and opinions. See comments and:
- The alignment of colour channel sliders and submenu arrows looked better before, IMO. Should we adjust that?
- Unfortunately I don’t have the time to read all discussions on Slack. A PR should explain its intent or the decision it is based on, but this doesn’t. Why should we make this move?
- The removal of the deprecated
Union
would have been better in an own PR, IMO. - The same goes for the new
Vector
type. - At least one commit (058e998) contains stuff that belongs to earlier commits :/. That might look like nit picking but I think focused commits help a lot with the review process. That’s why I put a significant amount of time into diff review before creating a commit and into commit clean-up before creating a PR.
test/markup_renderer.go
Outdated
func (r *markupRenderer) setIntAttrWithDefault(attrs map[string]*string, name string, i int, d int) { | ||
if i == d { | ||
func (r *markupRenderer) setIntAttrWithDefault(attrs map[string]*string, name string, i float32, d float32) { | ||
if int(i) == int(d) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d prefer to not use float32
as input to a method that’s intended to process int
values.
AFAICS it’s only used for text size. Since text size now is float, we might use setFloatAttrWithDefault
instead and remove setIntAttrWithDefault
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I missed the name for some reason
geometry.go
Outdated
@@ -1,5 +1,12 @@ | |||
package fyne | |||
|
|||
// Vec2 marks geometry types that can operate as a coordinate vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does Vec2
mean?
What is its purpose?
Is there a better name to it?
I think Get()
is named to generic. If it returns the elements of the vector, why isn’t it called Elements()
? Or Components()
?
When thinking longer about this, it seems that even Vector
is too generic. Maybe Coordinate
is better? It might even be necessary to include the amount of dimensions in the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will see if the other name suggestions work better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Coordinate is better than Vector. It is generic on purpose - it can refer to a coordinate, a size, a delta etc. It's just X and Y quantity of some sort, and I can't find a better name for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course we could make Vector
a more specific XYDelta
(as that is what what it's been used for so far), and then rename Vec2
as Vector
or Vector2
.
The rest of the naming is now tidied up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I like the idea of using Vector
for the interface.
The mathematical correct name for the current Vector
implementation would be Displacement
(https://en.wikipedia.org/wiki/Displacement_(geometry)). Unless you or someone else has a better idea, I would favour this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mathematical correct name for the current
Vector
implementation would beDisplacement
Good point, though not a commonly used phrase and has a very specific meaning whereas this is trying to be quite generic. Delta feels more commonly used, or we could even go simpler with Move
- this will be alongside Size
and Position
so looking for something commonplace word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m okay with Move
or Movement
but don’t really like Delta
:).
Answers to the questions above that did not relate to lines of code (answered inline):
This change does not intentionally move anything, it is a result of the rounding/truncating being removed.
By using
Maybe, but this is a re-working of geometry, of which the Union is part, so it seemed related enough and avoided a separate, tiny, PR.
As above, I guess you could argue that, but it's all related.
Apologies for this. As you can imagine this change took 2 full days to perform and polish. I suspected that unpicking, cherry-picking and reworking the commits would have taken another half day which didn't seem like it offered value for time. |
Okay, I just filed #1674 for this.
I understand your argument but nevertheless disagree. Both of these changes make complete sense on their own, without the
Apology accepted, subterfuge not. Sorry if some of this seems harsh, I don't want to offend you but I wanted to make my point clear. |
P.S.: Despite my long rant, I don’t expect that you extract any of these things into a separate PR now. I just want to suggest this for future PRs. |
geometry.go
Outdated
IsZero() bool | ||
} | ||
|
||
// Vector is a generic X, Y coordinate type | ||
// Vector is a generic X, Y coordinate or size representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And movement (or displacement) :).
Thanks for the clarification, I was worried about lots of required changes until I read this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I like that we got rid of a bunch of casts, tho it is a shame there isn't a way to define 32bit float point literals without the cast.
The color slider looks more inline with the label, so I think this change actually improves it.
@@ -24,8 +24,8 @@ type Line struct { | |||
|
|||
// Size returns the current size of bounding box for this line object | |||
func (l *Line) Size() fyne.Size { | |||
return fyne.NewSize(int(math.Abs(float64(l.Position2.X)-float64(l.Position1.X))), | |||
int(math.Abs(float64(l.Position2.Y)-float64(l.Position1.Y)))) | |||
return fyne.NewSize(float32(math.Abs(float64(l.Position2.X)-float64(l.Position1.X))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 'downcasting to float32 from the math library's float64' pattern could end up being quite common. Could we instead add fyne.Abs
alongside fyne.Min
& fyne.Max
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think we could add a few more helpers building on the new types
Not at all - points taken. Perhaps I am running too fast at some of this stuff. |
Because the discussion grow to some length, here’s a checklist of the remaining tasks from my wishlist:
|
Also ScrollEvent.Delta to ScrollEvent.Scrolled (as we are breaking anyway).
I think the Int naminng was fixed yesteday @toaster - I moved it to Size based name, so it's less generic. The other naming is now updated too. |
Move coordinates to float32.
Move text size as well.
Add new Vector type for mouse events (also float32s).
More interoperability between Size/Position/Vector.
Checklist: