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
Software Driver POC #4811
base: develop
Are you sure you want to change the base?
Software Driver POC #4811
Conversation
app/app_software.go
Outdated
"fyne.io/fyne/v2" | ||
software2 "fyne.io/fyne/v2/driver/software" |
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 probably switch the naming here as the first of the two is the one called "software" in the public API
app/app_software.go
Outdated
|
||
// NewWithSoftwareDriver returns a new app instance using the Software (custom) driver. | ||
// The ID string should be globally unique to this app. | ||
func NewWithSoftwareDriver(id string, painter func(image.Image), events chan any) fyne.App { |
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.
Won't the painter always be the one we have in the software package?
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.
TBH I didn't really look at the logic for how that worked, but I needed a way to add some extra params and wasn't sure a good way to do that with the existing interfaces.
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.
Some good work here - but I would hesitate from pulling so much internal API code into a public driver package.
The initial entry point should be all that is needed to change I would have thought - provide an event source and wire in the internal software painter by default?
Yea, you're right about that. It can pretty easily moved into an internal package, I just didn't put it there. I'll move things around once the code is in a more complete state. Also, this is pretty much the exact code from the test driver (for the most part) so I'll probably have it replace the test painter once it's all said and done. |
pad := painter.VectorPad(circle) | ||
scaledWidth := scale.ToScreenCoordinate(c, circle.Size().Width+pad*2) | ||
scaledHeight := scale.ToScreenCoordinate(c, circle.Size().Height+pad*2) | ||
scaledX, scaledY := scale.ToScreenCoordinate(c, pos.X-pad), scale.ToScreenCoordinate(c, pos.Y-pad) | ||
bounds := clip.Intersect(image.Rect(scaledX, scaledY, scaledX+scaledWidth, scaledY+scaledHeight)) | ||
|
||
raw := painter.DrawCircle(circle, pad, func(in float32) float32 { | ||
return float32(math.Round(float64(in) * float64(c.Scale()))) | ||
raw, err := p.getTexture(circle, func(object fyne.CanvasObject) Texture { |
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 is a problem for tests (wrong type for TextureType
), and I'm not quite sure what's a good way around it...
Maybe we could make the painter functions internal and add a wrapper file (i.e. draw_extern_software.go
, draw_extern.go
) that handles storing in the cache (or does nothing)? being that it's only a few lines, it should be eligible for inlining, so the wrapper should be functionally free.
Description:
This POC adds a new Driver that allows one to include their own event source and framebuffer (through an
image.Image
). It's based almost entirely on a combination of thetestDriver
and some choice bits from themobileDriver
(mainly the basic event loop and touch handling).This is an incredibly rough draft, I'm putting it up so that it can be discussed. Moreover, the actual API surface and basic design hasn't really been discussed yet, so this couldn't be merged either way. But most importantly, it does work, which is a good start.
Checklist:
Where applicable: