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
Refactoring: internal widgets #875
Refactoring: internal widgets #875
Conversation
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.
Nice job Tilo, very readable code!
} | ||
|
||
b.hidden = false | ||
w.Refresh() |
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.
how come show uses w.Refresh(), but hide uses canvas.Refresh(w)?
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.
That’s because a hidden widget won’t be rendered. Therefore w.Refresh()
is a waste of time there.
r.Layout(size) | ||
} | ||
|
||
func (b *base) show(w fyne.Widget) { |
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 was going to ask if show can be moved up next to hide, then I realized you have made all of these files declare members in alphabetical order and I think I prefer that, danke!
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.
Gern geschehen! (My pleasure!)
internal/widget/base_renderer.go
Outdated
) | ||
|
||
// NewBaseRenderer creates a new BaseRenderer. | ||
func NewBaseRenderer(objects []fyne.CanvasObject) BaseRenderer { |
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.
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.
"fyne.io/fyne/theme" | ||
) | ||
|
||
type baseRenderer struct { |
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 understand why this was moved into internal, however this convenience is no longer unaccessible for developers creating custom widgets. We could expose it as:
package widget
import "fyne.io/fyne/internal/widget"
type BaseRenderer struct {
widget.baseRenderer
}
What do you think?
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 think the advantage is too small to do so.
@andydotxyz convinced me to not add such a construct for the base widget where the advantage would be much bigger. Therefore I would not do that here and now.
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 think this was not available to any custom widget creation because it was not exposed. The conversation I had with @toaster largely came to the conclusion that someone writing a widget could be expected to write a complete renderer, they do not have the same inheritance properties that widget objects do. Additionally if we make it too "simple" or "static" then there is a much higher chance that third party widgets would not respond well on refresh or theme change (I guess?).
There is another discussion about making it easier to create widgets with trivial renderers at #709 but honestly I am coming to the view that such enablers might encourage things that we don't think are good ideas (such as realising that customisation is difficult resorting to everything becoming a clickable image using a png that does not reflect theme colours)...
It's probably quite a big discussion but given that this was not exposed we can always decide to add your proposed solution in the future.
Description:
This PR moves several internal widgets (which are needed for the upcoming menu refactoring) into a new internal
widget
package.Checklist:
[ ] Tests included.