Go to the documentation of this file.
14 #define LOC QString("Slide: ")
15 #define SBLOC QString("SlideBuffer: ")
50 std::chrono::milliseconds duration,
56 setDuration(duration.count());
57 setEasingCurve(curve);
68 auto duration_ms = std::chrono::milliseconds(duration());
69 if (duration_ms == 0ms)
271 image->
SetPan(value.toPoint());
318 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slide " + objectName());
371 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Already loading/loaded %1 in %2")
372 .arg(im->m_filePath, objectName()));
388 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Postponing load of %1 in %2")
389 .arg(im->m_filePath, objectName()));
427 LOG(VB_GENERAL, LOG_ERR,
LOC +
428 QString(
"Failed to load %1").arg(
m_data->m_filePath));
438 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Starting delayed load %1")
455 float newZoom = (percentage == 0)
500 QPoint start =
m_pan;
506 QPoint
dest = offset.isNull() ? QPoint(0, 0) : start + offset /
m_zoom;
535 float hRatio = float(imageArea.height()) /
m_area.height();
536 float wRatio = float(imageArea.width()) /
m_area.width();
537 float ratio = std::max(hRatio, wRatio);
543 int h = std::min(
int(roundf(
m_area.height() * ratio)), imageArea.height());
544 int w = std::min(
int(roundf(
m_area.width() * ratio)), imageArea.width());
545 int x = imageArea.center().x() - w / 2;
546 int y = imageArea.center().y() - h / 2;
549 int limitX = (imageArea.width() - w) / 2;
550 int limitY = (imageArea.height() - h) / 2;
551 m_pan.setX(std::clamp(pos.x(), -limitX, limitX));
552 m_pan.setY(std::clamp(pos.y(), -limitY, limitY));
575 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slidebuffer");
584 LOG(VB_GUI, LOG_DEBUG,
"Aborted Slidebuffer");
602 auto *slide =
new Slide(
nullptr,
"slide0", &image);
611 for (
size_t i = 1; i < size; ++i)
613 slide =
new Slide(&image, QString(
"slide%1").arg(i), slide);
616 slide->SetVisible(
false);
638 for (
int i = 0; i <
m_queue.size(); ++i)
640 QChar code(
m_queue.at(i)->GetDebugState());
641 state += (i ==
m_nextLoad ? code.toUpper() : code);
643 return QString(
"[%1] (%2)").arg(state,
m_queue.head()->objectName());
668 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Loading %1 in %2, %3")
669 .arg(im->m_filePath, slide->objectName(),
BufferState()));
671 return slide->
LoadSlide(im, direction,
true);
689 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Preloading %1 in %2, %3")
690 .arg(im->m_filePath, slide->objectName(),
BufferState()));
710 QString name = slide->objectName();
716 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Released %1").arg(name));
737 while (available <
m_queue.size() &&
m_queue.at(available)->IsLoaded())
745 QString path = im ? im->m_filePath :
"Unknown";
747 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"%1 %2 in %3, %4")
748 .arg(reason, path, slide->objectName(),
BufferState()));
755 Flush(slide,
"Loaded");
~Slide() override
Destructor.
std::chrono::milliseconds m_elapsed
Current millisec position within animation, 0..duration.
QSharedPointer< ImageItemK > ImagePtrK
A specialised image for slideshows.
void SetZoom(float zoom)
Sets slide zoom.
void SetSpeed(float speed) override
Change speed of group and all child animations.
QPoint m_pan
Pan position (0,0) = no pan.
Image widget, displays a single image or multiple images in sequence.
virtual void Finished()
To be called when animation completes.
UIEffects::Centre m_centre
QHash< int, MythImage * > m_images
void Finished() override
A child animation has completed.
QRect toQRect(void) const
void Pulse() override
Update pan & zoom animations.
void SlideReady(int count)
Signals that buffer has (count) loaded slides awaiting display.
void Finished() override
A child animation has completed.
PanAnimation * m_panAnimation
Dedicated animation for panning, if supported.
Slide(MythUIType *parent, const QString &name, MythUIImage *image)
Clone slide from a theme MythUIImage.
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SlideLoaded()
An image has completed loading.
int m_current
Index of child currently playing.
std::chrono::milliseconds m_lastUpdate
virtual MythPainter * GetPainter(void)
bool m_forwards
Play direction.
void SetOrientation(int orientation)
Saves the exif orientation value of the first image in the widget.
virtual void SetArea(const MythRect &rect)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QList< AbstractAnimation * > m_group
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Base animation class that is driven by a Myth pulse and implements variable speed.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
int GetCurrent(bool compensate)
Determines orientation required for an image.
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
void AddChild(MythUIType *child)
Add a child UIType.
void ReleaseCurrent()
Move head slide to back of queue and flush waiting slides.
ImagePtrK m_data
The image currently loading/loaded.
void Pulse() override
Progress single animation.
void SetCropRect(int x, int y, int width, int height)
Crop the image using the given rectangle, useful for removing unsightly edges from imported images or...
void Set(const QVariant &from, const QVariant &to, std::chrono::milliseconds duration=500ms, const QEasingCurve &curve=QEasingCurve::InOutCubic, UIEffects::Centre centre=UIEffects::Middle)
Initialises an animation.
bool Load(const ImagePtrK &im, int direction)
Assign an image to next available slide, start loading and signal when done.
int m_nextLoad
Index of first spare slide, (or last slide if none spare)
void SetAlpha(int newalpha)
virtual void Start(bool forwards, float speed=1.0)
Initialise & start base animation.
float m_speed
Real-time = 1.0, Double-speed = 2.0.
void updateCurrentValue(const QVariant &value) override
Update pan value.
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
void Flush(Slide *slide, const QString &reason)
Signal if any slides are waiting to be displayed.
void Clear()
Reset slide to unused state.
float m_zoom
Current zoom, 1.0 = fullsize.
void Start(bool forwards, float speed=1.0) override
Initialise & start base animation.
void Pan(QPoint offset)
Initiate pan.
bool LoadSlide(const ImagePtrK &im, int direction=0, bool notifyCompletion=false)
Load slide with an image.
void SetPan(QPoint pos)
Sets slide pan.
void ImageLoaded(Slide *)
Generated when the last requested image has loaded.
ImagePtrK GetImageData() const
Slide * m_parent
Image to be animated.
SlideState m_state
Slide validity.
static constexpr size_t SLIDE_BUFFER_SIZE
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
bool m_running
True whilst animation is active.
void Preload(const ImagePtrK &im)
Load an image in next available slide.
QChar GetDebugState() const
Return debug status.
The base class on which all widgets and screens are based.
void Initialise(MythUIImage &image)
Construct buffer.
A single animation controlling alpha, zoom, rotation and position.
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
Defines specialised images used by the Gallery slideshow and the animation framework used by transfor...
void Zoom(int percentage)
Initiate slide zoom.
QRecursiveMutex m_mutexQ
Queue protection.
void Start(bool forwards, float speed=1.0) override
Start sequential animation.
Animation * m_zoomAnimation
Dedicated animation for zoom, if supported.
void Start(bool forwards, float speed=1.0) override
Start parallel group. All children play simultaneously.
void SetSpeed(float speed) override
void Pulse() override
Progress sequential animation.
QString BufferState()
Determines buffer state for debug logging.
virtual void Add(AbstractAnimation *child)
Add child animation to group.
virtual void SetVisible(bool visible)
void SetSpeed(float speed) override
Change speed of current child animation and all subsequent ones.
int m_finished
Count of child animations that have finished.
void Pulse() override
Progress parallel animations.
int m_direction
Navigation that created this image, -1 = Prev, 0 = Update, 1 = Next.
void SetHorizontalZoom(float zoom)
void Clear() override
Delete all child animations.
Specialised animation for panning slideshow images (MythUI doesn't support panning)
QQueue< Slide * > m_queue
Queue of slides.
void SetCentre(UIEffects::Centre centre)
void SetAngle(float angle)
void SetVerticalZoom(float zoom)
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
ImagePtrK m_waitingFor
The most recently requested image. Null for preloads. Differs from m_data when skipping.
void Start(bool forwards=true, float speed=1.0) override
Start a single animation.
void finished()
Signals animation has finished.
Encapsulates Exif orientation processing.
void updateCurrentValue(const QVariant &value) override
Update animated value.