Commit 8d3db54d authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Reenable the Qt4-PictureFlow

These patches now should integrate better into the StandardPanel etc.
Parts had to be rearranged to be able to merge some code from libqxt into the source.
Fix bugs due to PL/ML change

Patch by VlcVelope
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 391bb327
...@@ -378,11 +378,17 @@ PicFlowView::PicFlowView( PLModel *p_model, QWidget *parent ) : QAbstractItemVie ...@@ -378,11 +378,17 @@ PicFlowView::PicFlowView( PLModel *p_model, QWidget *parent ) : QAbstractItemVie
QHBoxLayout *layout = new QHBoxLayout( this ); QHBoxLayout *layout = new QHBoxLayout( this );
layout->setMargin( 0 ); layout->setMargin( 0 );
picFlow = new PictureFlow( this, p_model ); picFlow = new PictureFlow( this, p_model );
picFlow->setSlideSize(QSize(128,128));
layout->addWidget( picFlow ); layout->addWidget( picFlow );
picFlow->setSlideSize(QSize( 4*LISTVIEW_ART_SIZE, 3*LISTVIEW_ART_SIZE) );
setSelectionMode( QAbstractItemView::SingleSelection ); setSelectionMode( QAbstractItemView::SingleSelection );
} }
void PicFlowView::setModel( QAbstractItemModel *model )
{
QAbstractItemView::setModel( model );
picFlow->setModel( model );
}
int PicFlowView::horizontalOffset() const int PicFlowView::horizontalOffset() const
{ {
return 0; return 0;
......
...@@ -104,6 +104,7 @@ public: ...@@ -104,6 +104,7 @@ public:
virtual QRect visualRect(const QModelIndex&) const; virtual QRect visualRect(const QModelIndex&) const;
virtual void scrollTo(const QModelIndex&, QAbstractItemView::ScrollHint); virtual void scrollTo(const QModelIndex&, QAbstractItemView::ScrollHint);
virtual QModelIndex indexAt(const QPoint&) const; virtual QModelIndex indexAt(const QPoint&) const;
virtual void setModel(QAbstractItemModel *model);
protected: protected:
virtual int horizontalOffset() const; virtual int horizontalOffset() const;
......
This diff is collapsed.
/* /*
PictureFlow - animated image show widget PictureFlow - animated image show widget
http://pictureflow.googlecode.com http://pictureflow.googlecode.com
and
http://libqxt.org <foundation@libqxt.org>
Copyright (C) 2009 Ariya Hidayat (ariya@kde.org) Copyright (C) 2009 Ariya Hidayat (ariya@kde.org)
Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) Copyright (C) 2008 Ariya Hidayat (ariya@kde.org)
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
Copyright (C) Qxt Foundation. Some rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
...@@ -28,9 +32,23 @@ ...@@ -28,9 +32,23 @@
#ifndef PICTUREFLOW_H #ifndef PICTUREFLOW_H
#define PICTUREFLOW_H #define PICTUREFLOW_H
#include <qwidget.h> #include <QApplication>
#include <QCache>
#include <QHash>
#include <QImage>
#include <QKeyEvent>
#include <QPainter>
#include <QPixmap>
#include <QTimer>
#include <QVector>
#include <QWidget>
#include <QAbstractItemModel>
#include <QPersistentModelIndex>
#include <QList>
#include "../components/playlist/playlist_model.hpp" /* getArtPixmap etc */ #include "../components/playlist/playlist_model.hpp" /* getArtPixmap etc */
class PictureFlowPrivate; class PictureFlowPrivate;
/*! /*!
...@@ -70,6 +88,9 @@ public: ...@@ -70,6 +88,9 @@ public:
*/ */
~PictureFlow(); ~PictureFlow();
void setModel(QAbstractItemModel * model);
QAbstractItemModel * model();
/*! /*!
Returns the background color. Returns the background color.
*/ */
...@@ -158,6 +179,7 @@ protected: ...@@ -158,6 +179,7 @@ protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
void wheelEvent(QWheelEvent* event);
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
private slots: private slots:
...@@ -167,5 +189,197 @@ private: ...@@ -167,5 +189,197 @@ private:
PictureFlowPrivate* d; PictureFlowPrivate* d;
}; };
// for fixed-point arithmetic, we need minimum 32-bit long
// long long (64-bit) might be useful for multiplication and division
typedef long PFreal;
#define PFREAL_SHIFT 10
#define PFREAL_ONE (1 << PFREAL_SHIFT)
#define IANGLE_MAX 1024
#define IANGLE_MASK 1023
inline PFreal fmul(PFreal a, PFreal b)
{
return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT;
}
inline PFreal fdiv(PFreal num, PFreal den)
{
long long p = (long long)(num) << (PFREAL_SHIFT * 2);
long long q = p / (long long)den;
long long r = q >> PFREAL_SHIFT;
return r;
}
inline PFreal fsin(int iangle)
{
// warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed!
static const PFreal tab[] = {
3, 103, 202, 300, 394, 485, 571, 652,
726, 793, 853, 904, 947, 980, 1004, 1019,
1023, 1018, 1003, 978, 944, 901, 849, 789,
721, 647, 566, 479, 388, 294, 196, 97,
-4, -104, -203, -301, -395, -486, -572, -653,
-727, -794, -854, -905, -948, -981, -1005, -1020,
-1024, -1019, -1004, -979, -945, -902, -850, -790,
-722, -648, -567, -480, -389, -295, -197, -98,
3
};
while (iangle < 0)
iangle += IANGLE_MAX;
iangle &= IANGLE_MASK;
int i = (iangle >> 4);
PFreal p = tab[i];
PFreal q = tab[(i+1)];
PFreal g = (q - p);
return p + g *(iangle - i*16) / 16;
}
inline PFreal fcos(int iangle)
{
return fsin(iangle + (IANGLE_MAX >> 2));
}
struct SlideInfo {
int slideIndex;
int angle;
PFreal cx;
PFreal cy;
int blend;
};
class PictureFlow;
class PictureFlowState
{
public:
PictureFlowState();
~PictureFlowState();
void reposition();
void reset();
QRgb backgroundColor;
int slideWidth;
int slideHeight;
PictureFlow::ReflectionEffect reflectionEffect;
int angle;
int spacing;
PFreal offsetX;
PFreal offsetY;
VLCModel *model;
SlideInfo centerSlide;
QVector<SlideInfo> leftSlides;
QVector<SlideInfo> rightSlides;
int centerIndex;
};
class PictureFlowAnimator
{
public:
PictureFlowAnimator();
PictureFlowState* state;
void start(int slide);
void stop(int slide);
void update();
int target;
int step;
int frame;
QTimer animateTimer;
};
class PictureFlowAbstractRenderer
{
public:
PictureFlowAbstractRenderer(): state(0), dirty(false), widget(0) {}
virtual ~PictureFlowAbstractRenderer() {}
PictureFlowState* state;
bool dirty;
QWidget* widget;
virtual void init() = 0;
virtual void paint() = 0;
};
class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer
{
public:
PictureFlowSoftwareRenderer();
~PictureFlowSoftwareRenderer();
virtual void init();
virtual void paint();
private:
QSize size;
QRgb bgcolor;
int effect;
QImage buffer;
QVector<PFreal> rays;
QImage* blankSurface;
void render();
void renderSlides();
QRect renderSlide(const SlideInfo &slide, int col1 = -1, int col2 = -1);
QImage* surface(QModelIndex);
QHash<QString, QImage*> cache;
};
class PictureFlowPrivate : public QObject
{
Q_OBJECT
public:
PictureFlowState* state;
PictureFlowAnimator* animator;
PictureFlowAbstractRenderer* renderer;
QTimer triggerTimer;
void setModel(QAbstractItemModel * model);
void clear();
void triggerRender();
void insertSlide(int index, const QImage& image);
void replaceSlide(int index, const QImage& image);
void removeSlide(int index);
void setCurrentIndex(QModelIndex index);
void showSlide(int index);
int picrole;
int textrole;
int piccolumn;
int textcolumn;
void reset();
QList<QPersistentModelIndex> modelmap;
QPersistentModelIndex currentcenter;
QPoint lastgrabpos;
QModelIndex rootindex;
public Q_SLOTS:
void columnsAboutToBeInserted(const QModelIndex & parent, int start, int end);
void columnsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
void columnsInserted(const QModelIndex & parent, int start, int end);
void columnsRemoved(const QModelIndex & parent, int start, int end);
void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
void headerDataChanged(Qt::Orientation orientation, int first, int last);
void layoutAboutToBeChanged();
void layoutChanged();
void modelAboutToBeReset();
void modelReset();
void rowsAboutToBeInserted(const QModelIndex & parent, int start, int end);
void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
void rowsInserted(const QModelIndex & parent, int start, int end);
void rowsRemoved(const QModelIndex & parent, int start, int end);
};
#endif // PICTUREFLOW_H #endif // PICTUREFLOW_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment