Skip to content
This repository has been archived by the owner on Dec 8, 2018. It is now read-only.

Commit

Permalink
Added Mouse Click to move slides
Browse files Browse the repository at this point in the history
git-svn-id: https://pictureflow.googlecode.com/svn/trunk@11 f1dae18b-7a3c-0410-92e9-d7898dd3a7d1
  • Loading branch information
theo.bertozzi committed Jan 24, 2008
1 parent 9713d8a commit f9c3260
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pictureflow-qt4/pictureflow.cpp
Expand Up @@ -284,6 +284,7 @@ class PictureFlowPrivate

QImage buffer;
QBasicTimer animateTimer;
QVector<QRect> slidesRect;

private:
PictureFlow* widget;
Expand Down Expand Up @@ -606,18 +607,24 @@ void PictureFlowPrivate::render()

if(step == 0)
{
slidesRect.clear();
slidesRect.resize(11);

// no animation, boring plain rendering
for(int index = 0; index < nleft-1; index++)
{
int alpha = (index < nleft-2) ? 256 : 128;
QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1);
slidesRect[index] = rs;
if(!rs.isEmpty())
c1 = rs.left();
}
slidesRect[5] = r;
for(int index = 0; index < nright-1; index++)
{
int alpha = (index < nright-2) ? 256 : 128;
QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width());
slidesRect[6 + index] = rs;
if(!rs.isEmpty())
c2 = rs.right();
}
Expand Down Expand Up @@ -1058,6 +1065,14 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
event->ignore();
}

void PictureFlow::mouseReleaseEvent (QMouseEvent *event) {
showSlideAt(event->x(), event->y());
}

void PictureFlow::mouseMoveEvent (QMouseEvent *event) {
showSlideAt(event->x(), event->y());
}

void PictureFlow::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
Expand All @@ -1079,3 +1094,24 @@ void PictureFlow::timerEvent(QTimerEvent* event)
else
QWidget::timerEvent(event);
}

void PictureFlow::showSlideAt (int x, int y) {
if (d->slidesRect[5].contains(x, y))
return;

if (x < d->slidesRect[5].x()) {
for (int i=0; i < 5; ++i) {
if (d->slidesRect[i].contains(x, y)) {
showSlide(d->currentSlide() - (i + 1));
return;
}
}
} else {
for (int i=6; i < 11; ++i) {
if (d->slidesRect[i].contains(x, y)) {
showSlide(d->currentSlide() + (i - 5));
return;
}
}
}
}
5 changes: 5 additions & 0 deletions pictureflow-qt4/pictureflow.h
Expand Up @@ -150,11 +150,16 @@ public slots:


protected:
void mouseReleaseEvent (QMouseEvent *event);
void mouseMoveEvent (QMouseEvent *event);
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent* event);
void resizeEvent(QResizeEvent* event);
void timerEvent(QTimerEvent* event);

private:
void showSlideAt (int x, int y);

private:
PictureFlowPrivate* d;
};
Expand Down

0 comments on commit f9c3260

Please sign in to comment.