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)
283 image->
SetPan(value.toPoint());
330 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slide " + objectName());
383 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Already loading/loaded %1 in %2")
384 .arg(im->m_filePath, objectName()));
400 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Postponing load of %1 in %2")
401 .arg(im->m_filePath, objectName()));
439 LOG(VB_GENERAL, LOG_ERR,
LOC +
440 QString(
"Failed to load %1").arg(
m_data->m_filePath));
450 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Starting delayed load %1")
467 float newZoom = (percentage == 0)
514 QPoint start =
m_pan;
520 QPoint
dest = offset.isNull() ? QPoint(0, 0) : start + offset /
m_zoom;
551 float hRatio = float(imageArea.height()) /
m_area.height();
552 float wRatio = float(imageArea.width()) /
m_area.width();
553 float ratio = std::max(hRatio, wRatio);
559 int h = std::min(
int(roundf(
m_area.height() * ratio)), imageArea.height());
560 int w = std::min(
int(roundf(
m_area.width() * ratio)), imageArea.width());
561 int x = imageArea.center().x() - (w / 2);
562 int y = imageArea.center().y() - (h / 2);
565 int limitX = (imageArea.width() - w) / 2;
566 int limitY = (imageArea.height() - h) / 2;
591 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slidebuffer");
600 LOG(VB_GUI, LOG_DEBUG,
"Aborted Slidebuffer");
618 auto *slide =
new Slide(
nullptr,
"slide0", &image);
627 for (
size_t i = 1; i < size; ++i)
629 slide =
new Slide(&image, QString(
"slide%1").arg(i), slide);
632 slide->SetVisible(
false);
654 for (
int i = 0; i <
m_queue.size(); ++i)
656 QChar code(
m_queue.at(i)->GetDebugState());
657 state += (i ==
m_nextLoad ? code.toUpper() : code);
659 return QString(
"[%1] (%2)").arg(state,
m_queue.head()->objectName());
684 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Loading %1 in %2, %3")
685 .arg(im->m_filePath, slide->objectName(),
BufferState()));
687 return slide->
LoadSlide(im, direction,
true);
705 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Preloading %1 in %2, %3")
706 .arg(im->m_filePath, slide->objectName(),
BufferState()));
726 QString name = slide->objectName();
732 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Released %1").arg(name));
753 while (available <
m_queue.size() &&
m_queue.at(available)->IsLoaded())
761 QString path = im ? im->m_filePath :
"Unknown";
763 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"%1 %2 in %3, %4")
764 .arg(reason, path, slide->objectName(),
BufferState()));
771 Flush(slide,
"Loaded");
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)