aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Kapusta <dominik.kapusta@teleca.com>2010-12-01 15:19:01 +0100
committerDominik Kapusta <dominik.kapusta@teleca.com>2010-12-31 10:48:42 +0100
commit096b2200baebf35df115f4fb951907ffde464400 (patch)
treefda37003319512c2eeaeb936ec847c4b80b44ea2
parent506dc3a2e75a22dfa2cbb27c9cc1f3838d20f361 (diff)
New: MDialogAnimation
RevBy: Daniel, Marcin Details: Some additional animation for dialogs, messageboxes, comboboxes and object menus. Requires updating meegotouch-theme to work properly.
-rw-r--r--src/corelib/animation/widget/mdialoganimation.cpp404
-rw-r--r--src/corelib/animation/widget/mdialoganimation.h58
-rw-r--r--src/corelib/animation/widget/mdialoganimation_p.h74
-rw-r--r--src/corelib/animation/widget/mwidgetzoomanimation.cpp7
-rw-r--r--src/corelib/animation/widget/mwidgetzoomanimation.h2
-rw-r--r--src/corelib/animation/widget/widget.pri3
-rw-r--r--src/corelib/scene/mscenemanager.cpp177
-rw-r--r--src/corelib/style/mdialoganimationstyle.h63
-rw-r--r--src/corelib/style/style.pri1
-rw-r--r--src/views/mdialogview.cpp3
-rw-r--r--src/views/mmessageboxview.cpp1
-rw-r--r--src/views/mobjectmenuview.cpp3
12 files changed, 699 insertions, 97 deletions
diff --git a/src/corelib/animation/widget/mdialoganimation.cpp b/src/corelib/animation/widget/mdialoganimation.cpp
new file mode 100644
index 00000000..56599407
--- /dev/null
+++ b/src/corelib/animation/widget/mdialoganimation.cpp
@@ -0,0 +1,404 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#include "mdialoganimation.h"
+#include "mdialoganimation_p.h"
+#include "manimationcreator.h"
+#include "mdialog.h"
+#include "mscenemanager.h"
+
+#include <QPropertyAnimation>
+#include <QPauseAnimation>
+#include <QSequentialAnimationGroup>
+
+namespace {
+ qreal curve_points[] = {0, 0.0009, 0.0037, 0.0085, 0.0156, 0.0252, 0.0375, 0.0530, 0.0719, 0.0949,
+ 0.1226, 0.1557, 0.1954, 0.2432, 0.3014, 0.3736, 0.4658, 0.5866, 0.6698,
+ 0.7263, 0.7700, 0.8057, 0.8358, 0.8618, 0.8845, 0.9046, 0.9225, 0.9384,
+ 0.9528, 0.9657, 0.9773, 0.9879, 0.9974, 1.0060, 1.0138, 1.0208, 1.0271,
+ 1.0327, 1.0377, 1.0422, 1.0461, 1.0496, 1.0525, 1.0551, 1.0572, 1.0589,
+ 1.0603, 1.0613, 1.0619, 1.0623, 1.0623, 1.0621, 1.0615, 1.0607, 1.0597,
+ 1.0584, 1.0568, 1.0550, 1.0530, 1.0508, 1.0484, 1.0458, 1.0430, 1.0399,
+ 1.0368, 1.0340, 1.0313, 1.0289, 1.0266, 1.0244, 1.0224, 1.0206, 1.0188,
+ 1.0172, 1.0157, 1.0142, 1.0129, 1.0117, 1.0105, 1.0094, 1.0084, 1.0075,
+ 1.0066, 1.0058, 1.0051, 1.0044, 1.0038, 1.0032, 1.0027, 1.0023, 1.0019,
+ 1.0015, 1.0012, 1.0009, 1.0006, 1.0004, 1.0003, 1.0002, 1.0001, 1.0000};
+
+ qreal bezierEasingFunction(qreal progress) {
+ return curve_points[(int)(progress * (sizeof curve_points / sizeof curve_points[0] - 1))];
+ }
+}
+
+const QString MDialogAnimationPrivate::DialogBoxObjectName = "MDialogBox";
+
+MDialogAnimationPrivate::MDialogAnimationPrivate() :
+ MAbstractWidgetAnimationPrivate(),
+ delayedTitleBarAnimation(0),
+ delayedContentsViewportAnimation(0),
+ delayedButtonBoxAnimation(0),
+ titleBarAnimationDelay(0),
+ contentsViewportAnimationDelay(0),
+ buttonBoxAnimationDelay(0),
+ titleBarOpacityAnimation(0),
+ titleBarPositionAnimation(0),
+ contentsViewportOpacityAnimation(0),
+ contentsViewportScaleAnimation(0),
+ contentsViewportPositionAnimation(0),
+ buttonBoxOpacityAnimation(0),
+ buttonBoxPositionAnimation(0),
+ dialogBox(0),
+ titleBar(0),
+ contentsViewport(0),
+ buttonBox(0)
+{
+}
+
+void MDialogAnimationPrivate::init()
+{
+ Q_Q(MDialogAnimation);
+
+ direction = MDialogAnimation::In;
+
+ titleBarAnimationDelay = new QPauseAnimation;
+ titleBarOpacityAnimation = new QPropertyAnimation;
+ titleBarPositionAnimation = new QPropertyAnimation;
+ titleBarOpacityAnimation->setPropertyName("opacity");
+ titleBarPositionAnimation->setPropertyName("pos");
+
+ contentsViewportAnimationDelay = new QPauseAnimation;
+ contentsViewportOpacityAnimation = new QPropertyAnimation;
+ contentsViewportScaleAnimation = new QPropertyAnimation;
+ contentsViewportPositionAnimation = new QPropertyAnimation;
+ contentsViewportOpacityAnimation->setPropertyName("opacity");
+ contentsViewportScaleAnimation->setPropertyName("scale");
+ contentsViewportPositionAnimation->setPropertyName("pos");
+
+ buttonBoxAnimationDelay = new QPauseAnimation;
+ buttonBoxOpacityAnimation = new QPropertyAnimation;
+ buttonBoxPositionAnimation = new QPropertyAnimation;
+ buttonBoxOpacityAnimation->setPropertyName("opacity");
+ buttonBoxPositionAnimation->setPropertyName("pos");
+
+ QParallelAnimationGroup *titleBarAnimation = new QParallelAnimationGroup;
+ titleBarAnimation->addAnimation(titleBarOpacityAnimation);
+ titleBarAnimation->addAnimation(titleBarPositionAnimation);
+
+ delayedTitleBarAnimation = new QSequentialAnimationGroup(q);
+ delayedTitleBarAnimation->addAnimation(titleBarAnimationDelay);
+ delayedTitleBarAnimation->addAnimation(titleBarAnimation);
+
+ QParallelAnimationGroup *contentsViewportAnimation = new QParallelAnimationGroup;
+ contentsViewportAnimation->addAnimation(contentsViewportOpacityAnimation);
+ contentsViewportAnimation->addAnimation(contentsViewportScaleAnimation);
+ contentsViewportAnimation->addAnimation(contentsViewportPositionAnimation);
+
+ delayedContentsViewportAnimation = new QSequentialAnimationGroup(q);
+ delayedContentsViewportAnimation->addAnimation(contentsViewportAnimationDelay);
+ delayedContentsViewportAnimation->addAnimation(contentsViewportAnimation);
+
+ QParallelAnimationGroup *buttonBoxAnimation = new QParallelAnimationGroup;
+ buttonBoxAnimation->addAnimation(buttonBoxOpacityAnimation);
+ buttonBoxAnimation->addAnimation(buttonBoxPositionAnimation);
+
+ delayedButtonBoxAnimation = new QSequentialAnimationGroup(q);
+ delayedButtonBoxAnimation->addAnimation(buttonBoxAnimationDelay);
+ delayedButtonBoxAnimation->addAnimation(buttonBoxAnimation);
+}
+
+void MDialogAnimationPrivate::findComponentsForAnimation()
+{
+ Q_Q(MDialogAnimation);
+
+ dialogBox = findDialogBox(targetWidget);
+ QGraphicsItem *parentItem = dialogBox ? dialogBox : targetWidget;
+
+ foreach (QGraphicsItem *childItem, parentItem->childItems()) {
+ if (childItem->isWidget()) {
+ QGraphicsWidget *childWidget = static_cast<QGraphicsWidget*>(childItem);
+ if (!childWidget->objectName().isEmpty()) {
+ if (!titleBar && childWidget->objectName() == q->style()->titleBarObjectName()) {
+ titleBar = qobject_cast<MWidgetController*>(childWidget);
+ if (titleBar) {
+ titleBarOpacityAnimation->setTargetObject(childWidget);
+ titleBarPositionAnimation->setTargetObject(childWidget);
+ }
+ } else if (!contentsViewport && childWidget->objectName() == q->style()->contentsViewportObjectName()) {
+ contentsViewport = qobject_cast<MWidgetController*>(childWidget);
+ if (contentsViewport) {
+ contentsViewportOpacityAnimation->setTargetObject(childWidget);
+ contentsViewportScaleAnimation->setTargetObject(childWidget);
+ contentsViewportPositionAnimation->setTargetObject(childWidget);
+ }
+ } else if (!buttonBox && childWidget->objectName() == q->style()->buttonBoxObjectName()) {
+ buttonBox = qobject_cast<MWidgetController*>(childWidget);
+ if (buttonBox) {
+ buttonBoxOpacityAnimation->setTargetObject(childWidget);
+ buttonBoxPositionAnimation->setTargetObject(childWidget);
+ }
+ }
+ if (titleBar && contentsViewport && buttonBox)
+ break;
+ }
+ }
+ }
+}
+
+QPointF MDialogAnimationPrivate::setupPositionAnimation(const QPointF &widgetPos)
+{
+ Q_Q(MDialogAnimation);
+
+ QPointF distance = origin - widgetPos;
+ return widgetPos + distance * (1 - q->style()->scale());
+}
+
+MDialogAnimation::MDialogAnimation(QObject *parent) :
+ MAbstractWidgetAnimation(new MDialogAnimationPrivate, parent)
+{
+ Q_D(MDialogAnimation);
+
+ d->init();
+}
+
+MDialogAnimation::MDialogAnimation(MDialogAnimationPrivate *dd, QObject *parent) :
+ MAbstractWidgetAnimation(dd, parent)
+{
+ Q_D(MDialogAnimation);
+
+ d->init();
+}
+
+QGraphicsWidget* MDialogAnimationPrivate::findDialogBox(QGraphicsItem *parentItem)
+{
+ foreach (QGraphicsItem *childItem, parentItem->childItems()) {
+ if (childItem->isWidget()) {
+ QGraphicsWidget *childWidget = static_cast<QGraphicsWidget*>(childItem);
+ if (childWidget->objectName() == DialogBoxObjectName)
+ return childWidget;
+ }
+ }
+ return 0;
+}
+
+QPointF MDialogAnimation::origin() const
+{
+ Q_D(const MDialogAnimation);
+
+ return d->origin;
+}
+
+void MDialogAnimation::setOrigin(const QPointF &pos)
+{
+ Q_D(MDialogAnimation);
+
+ d->origin = pos;
+}
+
+void MDialogAnimation::restoreTargetWidgetState()
+{
+}
+
+void MDialogAnimation::setTransitionDirection(TransitionDirection direction)
+{
+ Q_D(MDialogAnimation);
+
+ d->direction = direction;
+
+ if (d->direction == In)
+ style().setObjectName("In");
+ else
+ style().setObjectName("Out");
+}
+
+void MDialogAnimation::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
+{
+ Q_D(MDialogAnimation);
+
+ QAbstractAnimation::updateState(newState, oldState);
+
+ if (!d->targetWidget || !d->targetWidget->sceneManager())
+ return;
+
+
+ if (oldState == QAbstractAnimation::Stopped &&
+ newState == QAbstractAnimation::Running)
+ {
+ d->findComponentsForAnimation();
+
+ if (style().objectName().isNull())
+ style().setObjectName("In");
+
+ d->origin.rx() = d->targetWidget->sceneManager()->visibleSceneSize().width() / 2;
+ d->origin = d->contentsViewport->mapFromScene(d->origin);
+ if (d->dialogBox)
+ d->origin.ry() = d->dialogBox->geometry().height() / 2;
+ else
+ d->origin.ry() = d->targetWidget->geometry().height() / 2;
+
+ d->setupDurations();
+ d->setupEasingCurves();
+
+ d->setupTitleBarAnimation();
+ d->setupContentsViewportAnimation();
+ d->setupButtonBoxAnimation();
+ }
+}
+
+void MDialogAnimationPrivate::setupTitleBarAnimation()
+{
+ if (!titleBar || !titleBar->isVisible()) {
+ delete delayedTitleBarAnimation;
+ delayedTitleBarAnimation = 0;
+ return;
+ }
+
+ Q_Q(MDialogAnimation);
+
+ QPointF titleBarPos = titleBar->pos();
+
+ if (direction == MDialogAnimation::In) {
+ titleBar->setOpacity(0);
+ titleBarOpacityAnimation->setStartValue(0);
+ titleBarOpacityAnimation->setEndValue(q->style()->opacity());
+
+ titleBarPositionAnimation->setEndValue(titleBarPos);
+ titleBarPos.ry() += q->style()->titleBarAnimationDistance();
+ titleBarPositionAnimation->setStartValue(titleBarPos);
+ } else {
+ titleBarOpacityAnimation->setStartValue(q->style()->opacity());
+ titleBarOpacityAnimation->setEndValue(0);
+
+ titleBarPositionAnimation->setStartValue(titleBarPos);
+ titleBarPos.ry() += q->style()->titleBarAnimationDistance();
+ titleBarPositionAnimation->setEndValue(titleBarPos);
+ }
+
+ origin.ry() += titleBar->sizeHint(Qt::PreferredSize).height();
+
+ q->addAnimation(delayedTitleBarAnimation);
+}
+
+void MDialogAnimationPrivate::setupContentsViewportAnimation()
+{
+ if (!contentsViewport || !contentsViewport->isVisible()) {
+ delete delayedContentsViewportAnimation;
+ delayedContentsViewportAnimation = 0;
+ return;
+ }
+
+ Q_Q(MDialogAnimation);
+
+ QPointF contentsViewportPos = contentsViewport->pos();
+ if (direction == MDialogAnimation::In) {
+ contentsViewport->setOpacity(0);
+ contentsViewportOpacityAnimation->setStartValue(0);
+ contentsViewportOpacityAnimation->setEndValue(q->style()->opacity());
+
+ contentsViewportScaleAnimation->setStartValue(q->style()->scale());
+ contentsViewportScaleAnimation->setEndValue(1);
+
+ contentsViewportPositionAnimation->setStartValue(setupPositionAnimation(contentsViewportPos));
+ contentsViewportPositionAnimation->setEndValue(contentsViewportPos);
+ } else {
+ contentsViewportOpacityAnimation->setStartValue(q->style()->opacity());
+ contentsViewportOpacityAnimation->setEndValue(0);
+
+ contentsViewportScaleAnimation->setStartValue(1);
+ contentsViewportScaleAnimation->setEndValue(q->style()->scale());
+
+ contentsViewportPositionAnimation->setStartValue(contentsViewportPos);
+ contentsViewportPositionAnimation->setEndValue(setupPositionAnimation(contentsViewportPos));
+ }
+
+ q->addAnimation(delayedContentsViewportAnimation);
+}
+
+void MDialogAnimationPrivate::setupButtonBoxAnimation()
+{
+ if (!buttonBox || !buttonBox->isVisible()) {
+ delete delayedButtonBoxAnimation;
+ delayedButtonBoxAnimation = 0;
+ return;
+ }
+
+ Q_Q(MDialogAnimation);
+
+ qreal buttonBoxPosY = qMin(contentsViewport->sizeHint(Qt::PreferredSize).height(),
+ contentsViewport->sizeHint(Qt::MaximumSize).height());
+
+ QPointF buttonBoxPos(0, buttonBoxPosY);
+ if (titleBar && titleBar->isVisible())
+ buttonBoxPos.ry() += titleBar->sizeHint(Qt::PreferredSize).height();
+
+ if (direction == MDialogAnimation::In) {
+ buttonBox->setOpacity(0);
+ buttonBoxOpacityAnimation->setStartValue(0);
+ buttonBoxOpacityAnimation->setEndValue(q->style()->opacity());
+
+ buttonBoxPositionAnimation->setEndValue(buttonBoxPos);
+ buttonBoxPos.ry() -= q->style()->buttonBoxAnimationDistance();
+ buttonBoxPositionAnimation->setStartValue(buttonBoxPos);
+ } else {
+ buttonBoxOpacityAnimation->setStartValue(q->style()->opacity());
+ buttonBoxOpacityAnimation->setEndValue(0);
+
+ buttonBoxPositionAnimation->setStartValue(buttonBoxPos);
+ buttonBoxPos.ry() -= q->style()->buttonBoxAnimationDistance();
+ buttonBoxPositionAnimation->setEndValue(buttonBoxPos);
+ }
+
+ q->addAnimation(delayedButtonBoxAnimation);
+}
+
+void MDialogAnimationPrivate::setupDurations()
+{
+ Q_Q(MDialogAnimation);
+
+ titleBarAnimationDelay->setDuration(q->style()->titleBarAnimationDelay());
+ contentsViewportAnimationDelay->setDuration(q->style()->contentsViewportAnimationDelay());
+ buttonBoxAnimationDelay->setDuration(q->style()->buttonBoxAnimationDelay());
+
+ titleBarOpacityAnimation->setDuration(q->style()->titleBarAnimationDuration());
+ titleBarPositionAnimation->setDuration(q->style()->titleBarAnimationDuration());
+ contentsViewportOpacityAnimation->setDuration(q->style()->contentsViewportOpacityAnimationDuration());
+ contentsViewportScaleAnimation->setDuration(q->style()->contentsViewportScaleAnimationDuration());
+ contentsViewportPositionAnimation->setDuration(q->style()->contentsViewportScaleAnimationDuration());
+ buttonBoxOpacityAnimation->setDuration(q->style()->buttonBoxAnimationDuration());
+ buttonBoxPositionAnimation->setDuration(q->style()->buttonBoxAnimationDuration());
+}
+
+void MDialogAnimationPrivate::setupEasingCurves()
+{
+ Q_Q(MDialogAnimation);
+
+ QEasingCurve bezierEasingCurve;
+ bezierEasingCurve.setCustomType(bezierEasingFunction);
+
+ titleBarOpacityAnimation->setEasingCurve(bezierEasingCurve);
+ titleBarPositionAnimation->setEasingCurve(bezierEasingCurve);
+ contentsViewportOpacityAnimation->setEasingCurve(q->style()->contentsViewportOpacityAnimationEasingCurve());
+ contentsViewportScaleAnimation->setEasingCurve(q->style()->contentsViewportScaleAnimationEasingCurve());
+ contentsViewportPositionAnimation->setEasingCurve(q->style()->contentsViewportScaleAnimationEasingCurve());
+ buttonBoxOpacityAnimation->setEasingCurve(bezierEasingCurve);
+ buttonBoxPositionAnimation->setEasingCurve(bezierEasingCurve);
+}
+
+#include "moc_mdialoganimation.cpp"
+
+M_REGISTER_ANIMATION(MDialogAnimation)
diff --git a/src/corelib/animation/widget/mdialoganimation.h b/src/corelib/animation/widget/mdialoganimation.h
new file mode 100644
index 00000000..98736e4a
--- /dev/null
+++ b/src/corelib/animation/widget/mdialoganimation.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef MDIALOGANIMATION_H
+#define MDIALOGANIMATION_H
+
+#include "mabstractwidgetanimation.h"
+#include <mdialoganimationstyle.h>
+
+#include <QPointF>
+
+//! \internal
+
+class MDialogAnimationPrivate;
+
+class MDialogAnimation : public MAbstractWidgetAnimation
+{
+ Q_OBJECT
+ Q_PROPERTY(QPointF origin READ origin WRITE setOrigin)
+ M_ANIMATION_GROUP(MDialogAnimationStyle)
+
+public:
+ MDialogAnimation(QObject *parent = NULL);
+
+ virtual void restoreTargetWidgetState();
+
+ void setTransitionDirection(TransitionDirection direction);
+
+ QPointF origin() const;
+ void setOrigin(const QPointF &pos);
+
+protected:
+ MDialogAnimation(MDialogAnimationPrivate *dd, QObject *parent = NULL);
+ virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
+
+private:
+ Q_DECLARE_PRIVATE(MDialogAnimation)
+};
+
+//! \internal_end
+
+#endif // MDIALOGANIMATION_H
diff --git a/src/corelib/animation/widget/mdialoganimation_p.h b/src/corelib/animation/widget/mdialoganimation_p.h
new file mode 100644
index 00000000..0ab84c45
--- /dev/null
+++ b/src/corelib/animation/widget/mdialoganimation_p.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef MDIALOGANIMATION_P_H
+#define MDIALOGANIMATION_P_H
+
+#include "mabstractwidgetanimation_p.h"
+#include "mdialoganimation.h"
+
+class QPropertyAnimation;
+class QPauseAnimation;
+
+class MDialogAnimationPrivate : MAbstractWidgetAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(MDialogAnimation)
+public:
+ MDialogAnimationPrivate();
+ void init();
+
+ void findComponentsForAnimation();
+ QGraphicsWidget* findDialogBox(QGraphicsItem *parentItem);
+ void setupDurations();
+ void setupEasingCurves();
+
+ void setupTitleBarAnimation();
+ void setupContentsViewportAnimation();
+ void setupButtonBoxAnimation();
+
+ QPointF setupPositionAnimation(const QPointF &widgetPos);
+
+ MDialogAnimation::TransitionDirection direction;
+ QPointF origin;
+
+ QSequentialAnimationGroup *delayedTitleBarAnimation;
+ QSequentialAnimationGroup *delayedContentsViewportAnimation;
+ QSequentialAnimationGroup *delayedButtonBoxAnimation;
+
+ QPauseAnimation *titleBarAnimationDelay;
+ QPauseAnimation *contentsViewportAnimationDelay;
+ QPauseAnimation *buttonBoxAnimationDelay;
+
+ QPropertyAnimation *titleBarOpacityAnimation;
+ QPropertyAnimation *titleBarPositionAnimation;
+ QPropertyAnimation *contentsViewportOpacityAnimation;
+ QPropertyAnimation *contentsViewportScaleAnimation;
+ QPropertyAnimation *contentsViewportPositionAnimation;
+ QPropertyAnimation *buttonBoxOpacityAnimation;
+ QPropertyAnimation *buttonBoxPositionAnimation;
+
+ QGraphicsWidget *dialogBox;
+ MWidgetController *titleBar;
+ MWidgetController *contentsViewport;
+ MWidgetController *buttonBox;
+
+ static const QString DialogBoxObjectName;
+};
+
+#endif // MDIALOGANIMATION_P_H
diff --git a/src/corelib/animation/widget/mwidgetzoomanimation.cpp b/src/corelib/animation/widget/mwidgetzoomanimation.cpp
index 9b561d47..4b6bcb8e 100644
--- a/src/corelib/animation/widget/mwidgetzoomanimation.cpp
+++ b/src/corelib/animation/widget/mwidgetzoomanimation.cpp
@@ -116,6 +116,13 @@ void MWidgetZoomAnimation::setOrigin(const QPointF &pos)
d->origin = pos;
}
+QPointF MWidgetZoomAnimation::origin() const
+{
+ Q_D(const MWidgetZoomAnimation);
+
+ return d->origin;
+}
+
void MWidgetZoomAnimation::updateState(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState)
{
diff --git a/src/corelib/animation/widget/mwidgetzoomanimation.h b/src/corelib/animation/widget/mwidgetzoomanimation.h
index ee3d36df..718854de 100644
--- a/src/corelib/animation/widget/mwidgetzoomanimation.h
+++ b/src/corelib/animation/widget/mwidgetzoomanimation.h
@@ -32,6 +32,7 @@ class MWidgetZoomAnimationPrivate;
class MWidgetZoomAnimation : public MAbstractWidgetAnimation
{
Q_OBJECT
+ Q_PROPERTY(QPointF origin READ origin WRITE setOrigin)
M_ANIMATION_GROUP(MWidgetZoomAnimationStyle)
public:
@@ -42,6 +43,7 @@ public:
void setTransitionDirection(TransitionDirection direction);
void setOrigin(const QPointF &pos);
+ QPointF origin() const;
protected:
MWidgetZoomAnimation(MWidgetZoomAnimationPrivate *dd, QObject *parent = NULL);
diff --git a/src/corelib/animation/widget/widget.pri b/src/corelib/animation/widget/widget.pri
index f6b2fe21..dac4326d 100644
--- a/src/corelib/animation/widget/widget.pri
+++ b/src/corelib/animation/widget/widget.pri
@@ -8,6 +8,7 @@ include(core/core.pri)
ANIMATIONS_WIDGET_SRC_DIR=./animation/widget
PUBLIC_HEADERS += \
+ $$ANIMATIONS_WIDGET_SRC_DIR/mdialoganimation.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetfadeanimation.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetmoveanimation.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetslideanimation.h \
@@ -16,6 +17,7 @@ PUBLIC_HEADERS += \
$$ANIMATIONS_WIDGET_SRC_DIR/mcontentfadeandslideanimation.h \
PRIVATE_HEADERS += \
+ $$ANIMATIONS_WIDGET_SRC_DIR/mdialoganimation_p.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetfadeanimation_p.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetmoveanimation_p.h \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetslideanimation_p.h \
@@ -24,6 +26,7 @@ PRIVATE_HEADERS += \
$$ANIMATIONS_WIDGET_SRC_DIR/mcontentfadeandslideanimation_p.h \
SOURCES += \
+ $$ANIMATIONS_WIDGET_SRC_DIR/mdialoganimation.cpp \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetfadeanimation.cpp \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetmoveanimation.cpp \
$$ANIMATIONS_WIDGET_SRC_DIR/mwidgetslideanimation.cpp \
diff --git a/src/corelib/scene/mscenemanager.cpp b/src/corelib/scene/mscenemanager.cpp
index 8e9f7712..cef6dbed 100644
--- a/src/corelib/scene/mscenemanager.cpp
+++ b/src/corelib/scene/mscenemanager.cpp
@@ -69,6 +69,7 @@
#include <mwidgetfadeanimation.h>
#include <mwidgetzoomanimation.h>
#include <mwidgetmoveanimation.h>
+#include <mdialoganimation.h>
#include <mtheme.h>
#ifdef Q_WS_X11
@@ -1576,63 +1577,55 @@ void MSceneManagerPrivate::freezeUIForAnimationDuration(QAbstractAnimation *anim
void MSceneManagerPrivate::createAppearanceAnimationForSceneWindow(MSceneWindow *sceneWindow)
{
Q_ASSERT(sceneWindow->d_func()->appearanceAnimation == 0);
- MAbstractWidgetAnimation *animation;
+ MAbstractWidgetAnimation *animation = 0;
// TODO: Get this from theme/CSS
switch(sceneWindow->windowType()) {
- case MSceneWindow::Dialog:
- case MSceneWindow::NotificationInformation:
- case MSceneWindow::NotificationEvent:
- case MSceneWindow::ApplicationMenu:
- case MSceneWindow::NavigationBar: {
- MWidgetSlideAnimation *slideInAnimation = new MWidgetSlideAnimation(sceneWindow);
- animation = slideInAnimation;
- break;
- }
- case MSceneWindow::PopupList:
- case MSceneWindow::MessageBox: {
- MWidgetZoomAnimation *objectMenuAnimation =
- new MWidgetZoomAnimation(sceneWindow);
-
- objectMenuAnimation->setOrigin(sceneWindow->boundingRect().center());
- animation = objectMenuAnimation;
- break;
- }
- case MSceneWindow::StatusBar: {
- MWidgetSlideAnimation *slideInAnimation = new MWidgetSlideAnimation(sceneWindow);
- animation = slideInAnimation;
-
- QList<QGraphicsWidget*> list = findRootElementsForMoveAnimation(sceneWindow);
- foreach(QGraphicsWidget *widget, list) {
- MWidgetMoveAnimation *moveAnimation = new MWidgetMoveAnimation;
- moveAnimation->setWidget(widget);
- moveAnimation->setFinalPos(QPointF(0, sceneWindow->effectiveSizeHint(Qt::PreferredSize).height()));
- animation->addAnimation(moveAnimation);
- }
- break;
- }
- case MSceneWindow::ObjectMenu: {
- MAbstractWidgetAnimation *objectMenuAnimation =
- qobject_cast<MAbstractWidgetAnimation*>(MTheme::animation(style()->objectMenuAnimation()));
- if (objectMenuAnimation)
- objectMenuAnimation->setParent(sceneWindow);
- animation = objectMenuAnimation;
- break;
- }
- default: {
- MWidgetFadeAnimation *fadeInAnimation = new MWidgetFadeAnimation(sceneWindow);
- animation = fadeInAnimation;
- break;
+ case MSceneWindow::NotificationInformation:
+ case MSceneWindow::NotificationEvent:
+ case MSceneWindow::ApplicationMenu:
+ case MSceneWindow::NavigationBar:
+ animation = new MWidgetSlideAnimation(sceneWindow);
+ break;
+ case MSceneWindow::PopupList:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->popupListAnimation()));
+ break;
+ case MSceneWindow::MessageBox:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->messageBoxAnimation()));
+ break;
+ case MSceneWindow::Dialog:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->dialogAnimation()));
+ break;
+ case MSceneWindow::ObjectMenu:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->objectMenuAnimation()));
+ break;
+ case MSceneWindow::StatusBar: {
+ animation = new MWidgetSlideAnimation(sceneWindow);
+
+ QList<QGraphicsWidget*> list = findRootElementsForMoveAnimation(sceneWindow);
+ foreach(QGraphicsWidget *widget, list) {
+ MWidgetMoveAnimation *moveAnimation = new MWidgetMoveAnimation;
+ moveAnimation->setWidget(widget);
+ moveAnimation->setFinalPos(QPointF(0, sceneWindow->effectiveSizeHint(Qt::PreferredSize).height()));
+ animation->addAnimation(moveAnimation);
}
+ break;
}
-
- if (!animation) {
- MWidgetFadeAnimation *fadeInAnimation = new MWidgetFadeAnimation(sceneWindow);
- animation = fadeInAnimation;
+ default:
+ break;
}
+ if (!animation)
+ animation = new MWidgetFadeAnimation(sceneWindow);
+
+ animation->setProperty("origin", sceneWindow->boundingRect().center());
animation->setTransitionDirection(MAbstractWidgetAnimation::In);
animation->setTargetWidget(sceneWindow);
+ animation->setParent(sceneWindow);
MSceneWindow *effect = sceneWindow->d_func()->effect;
if (effect)
@@ -1644,63 +1637,55 @@ void MSceneManagerPrivate::createAppearanceAnimationForSceneWindow(MSceneWindow
void MSceneManagerPrivate::createDisappearanceAnimationForSceneWindow(MSceneWindow *sceneWindow)
{
Q_ASSERT(sceneWindow->d_func()->disappearanceAnimation == 0);
- MAbstractWidgetAnimation *animation;
+ MAbstractWidgetAnimation *animation = 0;
// TODO: Get this from theme/CSS
switch(sceneWindow->windowType()) {
- case MSceneWindow::Dialog:
- case MSceneWindow::NotificationInformation:
- case MSceneWindow::NotificationEvent:
- case MSceneWindow::ApplicationMenu:
- case MSceneWindow::NavigationBar: {
- MWidgetSlideAnimation *slideOutAnimation = new MWidgetSlideAnimation(sceneWindow);
- animation = slideOutAnimation;
- break;
- }
- case MSceneWindow::PopupList:
- case MSceneWindow::MessageBox: {
- MWidgetZoomAnimation *zoomAnimation =
- new MWidgetZoomAnimation(sceneWindow);
-
- zoomAnimation->setOrigin(sceneWindow->boundingRect().center());
-
- animation = zoomAnimation;
- break;
- }
- case MSceneWindow::StatusBar: {
- MWidgetSlideAnimation *slideOutAnimation = new MWidgetSlideAnimation(sceneWindow);
- animation = slideOutAnimation;
-
- QList<QGraphicsWidget*> list = findRootElementsForMoveAnimation(sceneWindow);
- foreach(QGraphicsWidget *widget, list) {
- MWidgetMoveAnimation *moveAnimation = new MWidgetMoveAnimation;
- moveAnimation->setWidget(widget);
- moveAnimation->setFinalPos(QPointF(0, 0));
- animation->addAnimation(moveAnimation);
- }
- break;
- }
- case MSceneWindow::ObjectMenu: {
- MAbstractWidgetAnimation *objectMenuAnimation = qobject_cast<MAbstractWidgetAnimation*>(MTheme::animation(style()->objectMenuAnimation()));
- if (objectMenuAnimation)
- objectMenuAnimation->setParent(sceneWindow);
- animation = objectMenuAnimation;
- break;
- }
- default: {
- MWidgetFadeAnimation *fadeOutAnimation = new MWidgetFadeAnimation(sceneWindow);
- animation = fadeOutAnimation;
- break;
+ case MSceneWindow::NotificationInformation:
+ case MSceneWindow::NotificationEvent:
+ case MSceneWindow::ApplicationMenu:
+ case MSceneWindow::NavigationBar:
+ animation = new MWidgetSlideAnimation(sceneWindow);
+ break;
+ case MSceneWindow::PopupList:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->popupListAnimation()));
+ break;
+ case MSceneWindow::MessageBox:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->messageBoxAnimation()));
+ break;
+ case MSceneWindow::Dialog:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->dialogAnimation()));
+ break;
+ case MSceneWindow::ObjectMenu:
+ animation = qobject_cast<MAbstractWidgetAnimation*>(
+ MTheme::animation(style()->objectMenuAnimation()));
+ break;
+ case MSceneWindow::StatusBar: {
+ animation = new MWidgetSlideAnimation(sceneWindow);
+
+ QList<QGraphicsWidget*> list = findRootElementsForMoveAnimation(sceneWindow);
+ foreach(QGraphicsWidget *widget, list) {
+ MWidgetMoveAnimation *moveAnimation = new MWidgetMoveAnimation;
+ moveAnimation->setWidget(widget);
+ moveAnimation->setFinalPos(QPointF(0, 0));
+ animation->addAnimation(moveAnimation);
}
+ break;
}
-
- if (!animation) {
- MWidgetFadeAnimation *fadeOutAnimation = new MWidgetFadeAnimation(sceneWindow);
- animation = fadeOutAnimation;
+ default:
+ break;
}
+ if (!animation)
+ animation = new MWidgetFadeAnimation(sceneWindow);
+
+ animation->setProperty("origin", sceneWindow->boundingRect().center());
animation->setTransitionDirection(MAbstractWidgetAnimation::Out);
animation->setTargetWidget(sceneWindow);
+ animation->setParent(sceneWindow);
MSceneWindow *effect = sceneWindow->d_func()->effect;
if (effect)
diff --git a/src/corelib/style/mdialoganimationstyle.h b/src/corelib/style/mdialoganimationstyle.h
new file mode 100644
index 00000000..445601ca
--- /dev/null
+++ b/src/corelib/style/mdialoganimationstyle.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#ifndef MDIALOGANIMATIONSTYLE_H
+#define MDIALOGANIMATIONSTYLE_H
+
+#include <manimationstyle.h>
+#include <QEasingCurve>
+
+//! \internal
+class MDialogAnimationStyle: public MAnimationStyle
+{
+ Q_OBJECT
+ M_STYLE_INTERNAL(MDialogAnimationStyle)
+
+ M_STYLE_ATTRIBUTE(QString, titleBarObjectName, TitleBarObjectName)
+ M_STYLE_ATTRIBUTE(QString, contentsViewportObjectName, ContentsViewportObjectName)
+ M_STYLE_ATTRIBUTE(QString, buttonBoxObjectName, ButtonBoxObjectName)
+
+ M_STYLE_ATTRIBUTE(int, titleBarAnimationDelay, TitleBarAnimationDelay)
+ M_STYLE_ATTRIBUTE(int, contentsViewportAnimationDelay, ContentsViewportAnimationDelay)
+ M_STYLE_ATTRIBUTE(int, buttonBoxAnimationDelay, ButtonBoxAnimationDelay)
+
+ M_STYLE_ATTRIBUTE(int, titleBarAnimationDuration, TitleBarAnimationDuration)
+ M_STYLE_ATTRIBUTE(qreal, titleBarAnimationDistance, TitleBarAnimationDistance)
+
+ M_STYLE_ATTRIBUTE(int, contentsViewportOpacityAnimationDuration, ContentsViewportOpacityAnimationDuration)
+ M_STYLE_ATTRIBUTE(QEasingCurve, contentsViewportOpacityAnimationEasingCurve, ContentsViewportOpacityAnimationEasingCurve)
+
+ M_STYLE_ATTRIBUTE(int, contentsViewportScaleAnimationDuration, ContentsViewportScaleAnimationDuration)
+ M_STYLE_ATTRIBUTE(QEasingCurve, contentsViewportScaleAnimationEasingCurve, ContentsViewportScaleAnimationEasingCurve)
+
+ M_STYLE_ATTRIBUTE(int, buttonBoxAnimationDuration, ButtonBoxAnimationDuration)
+ M_STYLE_ATTRIBUTE(qreal, buttonBoxAnimationDistance, ButtonBoxAnimationDistance)
+
+ M_STYLE_ATTRIBUTE(qreal, scale, Scale)
+ M_STYLE_ATTRIBUTE(qreal, opacity, Opacity)
+};
+
+class MDialogAnimationStyleContainer : public MAnimationStyleContainer
+{
+ M_STYLE_CONTAINER_INTERNAL(MDialogAnimationStyle)
+};
+//! \internal_end
+
+#endif
+
diff --git a/src/corelib/style/style.pri b/src/corelib/style/style.pri
index 4e10c747..94e5a7cb 100644
--- a/src/corelib/style/style.pri
+++ b/src/corelib/style/style.pri
@@ -26,6 +26,7 @@ STYLE_HEADERS += \
$$STYLE_SRC_DIR/mscenewindowanimationstyle.h \
$$STYLE_SRC_DIR/mbasiclayoutanimationstyle.h \
$$STYLE_SRC_DIR/mcrossfadedorientationanimationstyle.h \
+ $$STYLE_SRC_DIR/mdialoganimationstyle.h \
$$STYLE_SRC_DIR/mgroupanimationstyle.h \
$$STYLE_SRC_DIR/mlayoutanimationstyle.h \
$$STYLE_SRC_DIR/mwidgetfadeanimationstyle.h \
diff --git a/src/views/mdialogview.cpp b/src/views/mdialogview.cpp
index 0d9ec2c1..52b66d96 100644
--- a/src/views/mdialogview.cpp
+++ b/src/views/mdialogview.cpp
@@ -135,6 +135,7 @@ void MDialogViewPrivate::createDialogBox()
contentsViewport = new MPannableViewport;
contentsViewport->setStyleName("MDialogContentsViewport");
+ contentsViewport->setObjectName(contentsViewport->styleName());
dialogBoxLayout->addItem(contentsViewport);
contents = new MWidgetController();
@@ -430,7 +431,7 @@ void MDialogViewPrivate::updateButtonBoxLayoutOrientation()
buttonBoxLayoutPolicy->setOrientation(Qt::Vertical);
if (q->model()->buttons().count()==0) {
- buttonBox->setPreferredHeight(0);
+ buttonBox->setPreferredHeight(q->style()->verticalSpacing());
} else if (buttonBoxLayoutPolicy->orientation()==Qt::Horizontal) {
buttonBox->setPreferredHeight(buttonBox->minimumHeight() + q->style()->verticalSpacing());
} else {
diff --git a/src/views/mmessageboxview.cpp b/src/views/mmessageboxview.cpp
index 2e8e920a..918631a4 100644
--- a/src/views/mmessageboxview.cpp
+++ b/src/views/mmessageboxview.cpp
@@ -152,6 +152,7 @@ MMessageBoxView::MMessageBoxView(MMessageBox *controller) :
{
Q_D(MMessageBoxView);
d->controller = qobject_cast<MMessageBox*>(controller);
+ d->buttonBox->setStyleName("MMessageBoxButtonBox");
}
MMessageBoxView::~MMessageBoxView()
diff --git a/src/views/mobjectmenuview.cpp b/src/views/mobjectmenuview.cpp
index 54746add..ffb93505 100644
--- a/src/views/mobjectmenuview.cpp
+++ b/src/views/mobjectmenuview.cpp
@@ -70,6 +70,8 @@ void MObjectMenuViewPrivate::init()
titleLayout->setSpacing(0);
titleLayout->setContentsMargins(0.0,0.0,0.0,0.0);
titleArea = new MObjectMenuTitleArea(controller);
+ titleArea->setStyleName("ObjectMenuTitleArea");
+ titleArea->setObjectName(titleArea->styleName());
titleArea->setLayout(titleLayout);
//create and add title icon
@@ -97,6 +99,7 @@ void MObjectMenuViewPrivate::init()
actionViewport = new MPannableViewport(controller);
actionViewport->setWidget(actionWidget);
actionViewport->setVerticalPanningPolicy(MPannableWidget::PanningAsNeeded);
+ actionViewport->setObjectName("ObjectMenuActionViewport");
mainLayout->addItem(actionViewport);
}