7#ifndef __cpp_size_t_suffix
16#define LOC QString("Slide: ")
17#define SBLOC QString("SlideBuffer: ")
52 std::chrono::milliseconds duration,
58 setDuration(duration.count());
59 setEasingCurve(curve);
70 auto duration_ms = std::chrono::milliseconds(duration());
71 if (duration_ms == 0ms)
285 image->
SetPan(value.toPoint());
332 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slide " + objectName());
385 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Already loading/loaded %1 in %2")
386 .arg(im->m_filePath, objectName()));
402 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Postponing load of %1 in %2")
403 .arg(im->m_filePath, objectName()));
441 LOG(VB_GENERAL, LOG_ERR,
LOC +
442 QString(
"Failed to load %1").arg(
m_data->m_filePath));
452 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Starting delayed load %1")
469 float newZoom = (percentage == 0)
516 QPoint start =
m_pan;
522 QPoint
dest = offset.isNull() ? QPoint(0, 0) : start + offset /
m_zoom;
553 float hRatio = float(imageArea.height()) /
m_area.height();
554 float wRatio = float(imageArea.width()) /
m_area.width();
555 float ratio = std::max(hRatio, wRatio);
561 int h = std::min(
int(roundf(
m_area.height() * ratio)), imageArea.height());
562 int w = std::min(
int(roundf(
m_area.width() * ratio)), imageArea.width());
563 int x = imageArea.center().x() - (w / 2);
564 int y = imageArea.center().y() - (h / 2);
567 int limitX = (imageArea.width() - w) / 2;
568 int limitY = (imageArea.height() - h) / 2;
593 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slidebuffer");
602 LOG(VB_GUI, LOG_DEBUG,
"Aborted Slidebuffer");
615#ifdef __cpp_size_t_suffix
624 auto *slide =
new Slide(
nullptr,
"slide0", &image);
633 for (
size_t i = 1; i < size; ++i)
635 slide =
new Slide(&image, QString(
"slide%1").arg(i), slide);
638 slide->SetVisible(
false);
660 for (
int i = 0; i <
m_queue.size(); ++i)
662 QChar code(
m_queue.at(i)->GetDebugState());
663 state += (i ==
m_nextLoad ? code.toUpper() : code);
665 return QString(
"[%1] (%2)").arg(state,
m_queue.head()->objectName());
690 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Loading %1 in %2, %3")
691 .arg(im->m_filePath, slide->objectName(),
BufferState()));
693 return slide->
LoadSlide(im, direction,
true);
711 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Preloading %1 in %2, %3")
712 .arg(im->m_filePath, slide->objectName(),
BufferState()));
732 QString name = slide->objectName();
738 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Released %1").arg(name));
759 while (available <
m_queue.size() &&
m_queue.at(available)->IsLoaded())
767 QString path = im ? im->m_filePath :
"Unknown";
769 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"%1 %2 in %3, %4")
770 .arg(reason, path, slide->objectName(),
BufferState()));
777 Flush(slide,
"Loaded");
780#include "moc_galleryslide.cpp"
Base animation class that is driven by a Myth pulse and implements variable speed.
virtual void Finished()
To be called when animation completes.
void finished()
Signals animation has finished.
virtual void Start(bool forwards, float speed=1.0)
Initialise & start base animation.
float m_speed
Real-time = 1.0, Double-speed = 2.0.
bool m_forwards
Play direction.
bool m_running
True whilst animation is active.
A single animation controlling alpha, zoom, rotation and position.
std::chrono::milliseconds m_lastUpdate
UIEffects::Centre m_centre
void updateCurrentValue(const QVariant &value) override
Update animated value.
void Start(bool forwards=true, float speed=1.0) override
Start a single animation.
Slide * m_parent
Image to be animated.
void Pulse() override
Progress single animation.
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.
std::chrono::milliseconds m_elapsed
Current millisec position within animation, 0..duration.
void SetSpeed(float speed) override
QList< AbstractAnimation * > m_group
void Clear() override
Delete all child animations.
void Start(bool forwards, float speed=1.0) override
Initialise & start base animation.
virtual void Add(AbstractAnimation *child)
Add child animation to group.
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
QRect toQRect(void) const
Image widget, displays a single image or multiple images in sequence.
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
QHash< int, MythImage * > m_images
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
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 SetOrientation(int orientation)
Saves the exif orientation value of the first image in the widget.
The base class on which all widgets and screens are based.
void AddChild(MythUIType *child)
Add a child UIType.
virtual void SetVisible(bool visible)
virtual MythPainter * GetPainter(void)
virtual void SetArea(const MythRect &rect)
void SetAngle(float angle)
void SetVerticalZoom(float zoom)
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
void SetPosition(int x, int y)
Convenience method, calls SetPosition(const MythPoint&) Override that instead to change functionality...
void SetAlpha(int newalpha)
void SetCentre(UIEffects::Centre centre)
void SetHorizontalZoom(float zoom)
Encapsulates Exif orientation processing.
int GetCurrent() const
Determines orientation required for an image.
Specialised animation for panning slideshow images (MythUI doesn't support panning)
void updateCurrentValue(const QVariant &value) override
Update pan value.
void SetSpeed(float speed) override
Change speed of group and all child animations.
void Finished() override
A child animation has completed.
void Start(bool forwards, float speed=1.0) override
Start parallel group. All children play simultaneously.
int m_finished
Count of child animations that have finished.
void Pulse() override
Progress parallel animations.
void Start(bool forwards, float speed=1.0) override
Start sequential animation.
void Finished() override
A child animation has completed.
void Pulse() override
Progress sequential animation.
int m_current
Index of child currently playing.
void SetSpeed(float speed) override
Change speed of current child animation and all subsequent ones.
QString BufferState()
Determines buffer state for debug logging.
void Flush(Slide *slide, const QString &reason)
Signal if any slides are waiting to be displayed.
void ReleaseCurrent()
Move head slide to back of queue and flush waiting slides.
void Initialise(MythUIImage &image)
Construct buffer.
int m_nextLoad
Index of first spare slide, (or last slide if none spare)
bool Load(const ImagePtrK &im, int direction)
Assign an image to next available slide, start loading and signal when done.
void Preload(const ImagePtrK &im)
Load an image in next available slide.
QRecursiveMutex m_mutexQ
Queue protection.
QQueue< Slide * > m_queue
Queue of slides.
void SlideReady(int count)
Signals that buffer has (count) loaded slides awaiting display.
A specialised image for slideshows.
int m_direction
Navigation that created this image, -1 = Prev, 0 = Update, 1 = Next.
QChar GetDebugState() const
Return debug status.
float m_zoom
Current zoom, 1.0 = fullsize.
void Pan(QPoint offset)
Initiate pan.
QPoint m_pan
Pan position (0,0) = no pan.
void ImageLoaded(Slide *)
Generated when the last requested image has loaded.
PanAnimation * m_panAnimation
Dedicated animation for panning, if supported.
void Zoom(int percentage)
Initiate slide zoom.
Animation * m_zoomAnimation
Dedicated animation for zoom, if supported.
ImagePtrK GetImageData() const
ImagePtrK m_data
The image currently loading/loaded.
SlideState m_state
Slide validity.
void SetZoom(float zoom)
Sets slide zoom.
bool LoadSlide(const ImagePtrK &im, int direction=0, bool notifyCompletion=false)
Load slide with an image.
void SetPan(QPoint pos)
Sets slide pan.
void Pulse() override
Update pan & zoom animations.
void SlideLoaded()
An image has completed loading.
void Clear()
Reset slide to unused state.
~Slide() override
Destructor.
ImagePtrK m_waitingFor
The most recently requested image. Null for preloads. Differs from m_data when skipping.
Slide(MythUIType *parent, const QString &name, MythUIImage *image)
Clone slide from a theme MythUIImage.
static constexpr size_t SLIDE_BUFFER_SIZE
Defines specialised images used by the Gallery slideshow and the animation framework used by transfor...
QSharedPointer< ImageItemK > ImagePtrK
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
static eu8 clamp(eu8 value, eu8 low, eu8 high)