-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
New widget "Image Slideshow" #3406
Conversation
Hooray Jenkins reported success with all tests good! |
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 few changes
public void update(float delta) { | ||
if (isActive() && timestamp + speed * 1000 < getCurrentTimestamp()) { | ||
timestamp = getCurrentTimestamp(); | ||
nextImage(); |
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 the delta
here instead of making calls to Date.
Since delta
is the time since last call you can do something like this:
public void update(float delta) {
imageDisplayTime += delta;
if (imageDisplayTime >= speed) {
imageDisplayTime = 0f;
/* Call your image switching here */
}
}
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.
Great idea, thanks!
@Override | ||
public void onDraw(Canvas canvas) { | ||
if (currentImage.get() != null) { | ||
canvas.drawTexture(currentImage.get(), Color.WHITE); |
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.
Should this line be here? Won't it result in the image being drawn twice, once in the if
below and once here?
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.
Nope. thanks!
|
||
@Override | ||
public void onDraw(Canvas canvas) { | ||
if (currentImage.get() != 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.
I'm making a suggestion that instead of manually drawing the image here, you make this widget use an UIImage
.
You can simply call it's draw here and use a binding to automatically update the image in it when the image index here is altered.
You can also delegate to its getPreferredContentSize
.
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.
Alternatively you can consider extending the UIImage
which will also allow you to do similar and utilise it's default methods.
Hooray Jenkins reported success with all tests good! |
Tests out, nice work :-) I concur with Jelly's comments, happy to merge this after those are addressed. On Slack we discussed the possibility of a timed cycle variant vs manual back/forward. That could be done in a separate PR or along with this one, up to you. |
Uh oh, something went wrong with the build. Need to check on that |
Hooray Jenkins reported success with all tests good! |
Contains
This is new ui widget for slideshows images.
How to test
Currently, we don't have a bunch of associated images. But you could add for example "default" image.
e.g. GameDetailsScreen(line: 383).
Outstanding before merging
Not sure but now it works automatically. Do we need to add buttons "next" and "prev" ? Or better to add new card and put it to backlog ?