Go to the documentation of this file.
10 #define LOC QString("Slide: ")
11 #define SBLOC QString("SlideBuffer: ")
21 #define SLIDE_BUFFER_SIZE 9
51 setDuration(duration);
52 setEasingCurve(curve);
80 int64_t
current = QDateTime::currentMSecsSinceEpoch();
265 image->
SetPan(value.toPoint());
312 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slide " + objectName());
365 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Already loading/loaded %1 in %2")
366 .
arg(im->m_filePath, objectName()));
382 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Postponing load of %1 in %2")
383 .
arg(im->m_filePath, objectName()));
421 LOG(VB_GENERAL, LOG_ERR,
LOC +
422 QString(
"Failed to load %1").
arg(
m_data->m_filePath));
432 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"Starting delayed load %1")
449 float newZoom = (percentage == 0)
495 QPoint start =
m_pan;
501 QPoint
dest = offset.isNull() ? QPoint(0, 0) : start + offset /
m_zoom;
530 float hRatio = float(imageArea.height()) /
m_area.height();
531 float wRatio = float(imageArea.width()) /
m_area.width();
532 float ratio = qMax(hRatio, wRatio);
538 int h = qMin(
int(roundf(
m_area.height() * ratio)), imageArea.height());
539 int w = qMin(
int(roundf(
m_area.width() * ratio)), imageArea.width());
540 int x = imageArea.center().x() - w / 2;
541 int y = imageArea.center().y() - h / 2;
544 int limitX = (imageArea.width() - w) / 2;
545 int limitY = (imageArea.height() - h) / 2;
546 m_pan.setX(qMax(qMin(pos.x(), limitX), -limitX));
547 m_pan.setY(qMax(qMin(pos.y(), limitY), -limitY));
570 LOG(VB_GUI, LOG_DEBUG,
"Deleted Slidebuffer");
579 LOG(VB_GUI, LOG_DEBUG,
"Aborted Slidebuffer");
597 auto *slide =
new Slide(
nullptr,
"slide0", &image);
606 for (
int i = 1; i < size; ++i)
608 slide =
new Slide(&image, QString(
"slide%1").
arg(i), slide);
611 slide->SetVisible(
false);
633 for (
int i = 0; i <
m_queue.size(); ++i)
635 QChar code(
m_queue.at(i)->GetDebugState());
636 state += (i ==
m_nextLoad ? code.toUpper() : code);
638 return QString(
"[%1] (%2)").arg(state,
m_queue.head()->objectName());
663 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Loading %1 in %2, %3")
666 return slide->
LoadSlide(im, direction,
true);
684 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Preloading %1 in %2, %3")
705 QString name = slide->objectName();
711 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"Released %1").
arg(name));
732 while (available <
m_queue.size() &&
m_queue.at(available)->IsLoaded())
740 QString path = im ? im->m_filePath :
"Unknown";
742 LOG(VB_FILE, LOG_DEBUG,
SBLOC + QString(
"%1 %2 in %3, %4")
750 Flush(slide,
"Loaded");
~Slide() override
Destructor.
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.
#define SLIDE_BUFFER_SIZE
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.
arg(title).arg(filename).arg(doDelete))
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_)
int m_elapsed
Current millisec position within animation, 0..duration.
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 Set(const QVariant &from, const QVariant &to, int duration=500, const QEasingCurve &curve=QEasingCurve::InOutCubic, UIEffects::Centre centre=UIEffects::Middle)
Initialises an animation.
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...
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.
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.
Defines specialised images used by the Gallery slideshow and the animation framework used by transfor...
void Zoom(int percentage)
Initiate slide zoom.
QMutex 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.