58 {
59
61
63
64 const Array *images = (Array *) this->images;
65 if (images->count == 0) {
66 return;
67 }
68
69 const Uint64 now = SDL_GetTicks();
70
71 if (this->current->image == NULL) {
72 Image *first = $(images, firstObject);
74 this->fadeEndedAt = now;
75 return;
76 }
77
78 if (images->count < 2) {
79 return;
80 }
81
82 if (this->fadeStartedAt) {
83 const float frac = (float) (now - this->fadeStartedAt) / (float) this->fadeDuration;
84 this->next->color.a = (Uint8) (SDL_min(frac, 1.f) * 255.f);
85 if (frac >= 1.f) {
86 $(this->current,
setImage, this->next->image);
88 this->next->color.a = 0;
89 this->fadeStartedAt = 0;
90 this->fadeEndedAt = now;
91 }
92 } else if (now - this->fadeEndedAt >= this->slideDuration) {
93 this->index = (this->index + 1) % images->count;
94 Image *image = $(images, objectAtIndex, this->index);
96 this->fadeStartedAt = now;
97 }
98}
static void setImage(ImageView *self, Image *image)