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
Redraw the swing terminal on Canvas.paint(). #78
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.
Pretty cool PR, thank you for your effort! So this just adds a callback which gets called from Swing? I guess it looks for an onPaint
method?
companion object { | ||
private fun createCanvas() = Canvas() | ||
private class TerminalCanvas() : Canvas() { | ||
var onPaint: (() -> Unit)? = null |
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.
You can use lateinit var onPaint: (() -> Unit)
here so you don't have to bother with the null
s
Updated to use a |
Great thanks. I'll pull this out today and create a new |
Thanks! |
So I refactored it to have a default |
You can find the new snapshot on jitpack. |
It's funny how Swing was intended to hide all platform-specific nuances like this, but they're still popping up. On X11, |
Me neither. At least it is now tested on all major platforms. :) I was not able to reproduce the tearing you mentioned on Windows so I would have been completely oblivious to this bug. |
Fixes #77.
This creates a private
Canvas
subclass that invokes anonPaint
callback.This also removes
canvas.ignoreRepaint = true
.I remember reading somewhere in the Swing docs (can't seem to find it now) that it recommended
canvas.setIgnoreRepaint(true)
, but I believe this is only necessary for real-time rendering.I'm not sure how zircon handles animations, as this library is still new to me, but it definitely doesn't render in real-time when there are no animations playing, so repainting is needed on some platforms.
Edit: Do you know if there's any other importance to ignoring repaint?