summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/dial/DialLibrary/Dial.qml6
-rw-r--r--examples/declarative/dial/dial.qml2
-rw-r--r--examples/declarative/minehunt/minehunt.qml4
-rw-r--r--examples/declarative/minehunt/pics/back.pngbin0 -> 558 bytes
-rw-r--r--examples/declarative/minehunt/pics/cachepix-black.pngbin1658 -> 0 bytes
-rw-r--r--examples/declarative/minehunt/pics/cachepix-black.sci5
-rw-r--r--examples/declarative/minehunt/pics/cachepix-boxless.pngbin1819 -> 0 bytes
-rw-r--r--examples/declarative/minehunt/pics/cachepix-boxless.sci5
-rw-r--r--examples/declarative/minehunt/pics/front.pngbin0 -> 580 bytes
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/kernel/qobject.cpp8
-rw-r--r--src/corelib/kernel/qobject_p.h12
-rw-r--r--src/declarative/3rdparty/easing.cpp726
-rw-r--r--src/declarative/3rdparty/legal.qdoc35
-rw-r--r--src/declarative/canvas/qsimplecanvas.cpp1
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.cpp1
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.h1
-rw-r--r--src/declarative/extra/qmlsqlconnection.cpp8
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp6
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp4
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp45
-rw-r--r--src/declarative/fx/qfxblendedimage.h6
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp2
-rw-r--r--src/declarative/fx/qfxflickable.cpp15
-rw-r--r--src/declarative/fx/qfxflickable_p.h18
-rw-r--r--src/declarative/fx/qfxgridview.cpp6
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp8
-rw-r--r--src/declarative/fx/qfximage.cpp8
-rw-r--r--src/declarative/fx/qfxitem.cpp318
-rw-r--r--src/declarative/fx/qfxitem.h4
-rw-r--r--src/declarative/fx/qfxitem_p.h2
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp3
-rw-r--r--src/declarative/fx/qfxlistview.cpp17
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp3
-rw-r--r--src/declarative/fx/qfxparticles.cpp5
-rw-r--r--src/declarative/fx/qfxpathview.cpp15
-rw-r--r--src/declarative/fx/qfxpathview.h1
-rw-r--r--src/declarative/fx/qfxpathview_p.h7
-rw-r--r--src/declarative/fx/qfxrepeater.cpp10
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp12
-rw-r--r--src/declarative/fx/qfxwebview.cpp134
-rw-r--r--src/declarative/fx/qfxwebview.h4
-rw-r--r--src/declarative/qml/qml.h5
-rw-r--r--src/declarative/qml/qmlbindablevalue.cpp2
-rw-r--r--src/declarative/qml/qmlcompiler.cpp9
-rw-r--r--src/declarative/qml/qmlcompiler_p.h3
-rw-r--r--src/declarative/qml/qmlcontext.cpp2
-rw-r--r--src/declarative/qml/qmlcontext_p.h7
-rw-r--r--src/declarative/qml/qmlengine.cpp33
-rw-r--r--src/declarative/qml/qmlengine.h2
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp17
-rw-r--r--src/declarative/qml/qmlvme.cpp3
-rw-r--r--src/declarative/test/qfxtestengine.cpp2
-rw-r--r--src/declarative/timeline/gfxeasing.cpp811
-rw-r--r--src/declarative/timeline/gfxeasing.h107
-rw-r--r--src/declarative/timeline/qmltimeline.cpp (renamed from src/declarative/timeline/gfxtimeline.cpp)195
-rw-r--r--src/declarative/timeline/qmltimeline.h (renamed from src/declarative/timeline/gfxtimeline.h)54
-rw-r--r--src/declarative/timeline/qmltimelinevalueproxy.h (renamed from src/declarative/timeline/gfxvalueproxy.h)21
-rw-r--r--src/declarative/timeline/timeline.pri8
-rw-r--r--src/declarative/util/qmlanimation.cpp84
-rw-r--r--src/declarative/util/qmlanimation_p.h29
-rw-r--r--src/declarative/util/qmlbehaviour.cpp9
-rw-r--r--src/declarative/util/qmlbehaviour.h2
-rw-r--r--src/declarative/util/qmlconnection.cpp9
-rw-r--r--src/declarative/util/qmlfollow.cpp1
-rw-r--r--src/declarative/util/qmllistmodel.cpp11
-rw-r--r--src/declarative/util/qmlscript.cpp20
-rw-r--r--src/declarative/util/qmlstate.cpp1
-rw-r--r--src/declarative/util/qmlstate.h1
-rw-r--r--src/declarative/util/qmlstateoperations.cpp8
-rw-r--r--src/declarative/util/qmltransition.h1
71 files changed, 818 insertions, 2108 deletions
diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml
index e1b9f18..e2a11b1 100644
--- a/examples/declarative/dial/DialLibrary/Dial.qml
+++ b/examples/declarative/dial/DialLibrary/Dial.qml
@@ -1,12 +1,12 @@
<Item width="210" height="210">
<properties><Property name="value" type="real" value="0"/></properties>
<Image id="Background" src="background.svg"/>
+ <Item x="104" y="102" rotation="{Needle.rotation}">
+ <Image src="needle_shadow.svg" x="-104" y="-102"/>
+ </Item>
<Item id="Needle" x="102" y="98" rotation="-130">
<rotation><Follow spring="1.4" damping=".15" source="{Math.min(Math.max(-130, value*2.2 - 130), 133)}"/></rotation>
<Image src="needle.svg" x="-102" y="-98"/>
</Item>
- <Item x="104" y="102" rotation="{Needle.rotation}">
- <Image src="needle_shadow.svg" x="-104" y="-102"/>
- </Item>
<Image src="overlay.svg"/>
</Item>
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
index ce43b01..bda9b41 100644
--- a/examples/declarative/dial/dial.qml
+++ b/examples/declarative/dial/dial.qml
@@ -3,7 +3,7 @@
<!-- Dial with a slider to adjust it -->
<Dial id="Dial" value="{Slider.x-2}"/>
<Rect anchors.top="{Dial.bottom}" x="20" width="160" height="16" color="steelblue" gradientColor="lightsteelblue" radius="8" opacity="0.7">
- <Rect id="Slider" anchors.top="{Dial.bottom}" x="2" y="2" width="30" height="12" color="lightgray" gradientColor="gray" radius="6">
+ <Rect id="Slider" x="2" y="2" width="30" height="12" color="lightgray" gradientColor="gray" radius="6">
<MouseRegion anchors.fill="{parent}"
drag.target="{parent}"
drag.axis="x"
diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml
index 9cde164..9db0e84 100644
--- a/examples/declarative/minehunt/minehunt.qml
+++ b/examples/declarative/minehunt/minehunt.qml
@@ -10,7 +10,7 @@
<Axis id="axis" xStart="20" xEnd="20" yStart="20" yEnd="0" />
</transform>
<front>
- <Image src="pics/cachepix-boxless.sci" width="40" height="40">
+ <Image src="pics/front.png" width="40" height="40">
<Image anchors.horizontalCenter="{parent.horizontalCenter}"
anchors.verticalCenter="{parent.verticalCenter}"
src="pics/flag.png" opacity="{modelData.hasFlag}">
@@ -23,7 +23,7 @@
</Image>
</front>
<back>
- <Image src="pics/cachepix-black.sci" width="40" height="40">
+ <Image src="pics/back.png" width="40" height="40">
<Text anchors.horizontalCenter="{parent.horizontalCenter}" anchors.verticalCenter="{parent.verticalCenter}"
text="{modelData.hint}" color="white" font.bold="true"
opacity="{modelData.hasMine == false &amp;&amp; modelData.hint > 0}"/>
diff --git a/examples/declarative/minehunt/pics/back.png b/examples/declarative/minehunt/pics/back.png
new file mode 100644
index 0000000..f6b3f0b
--- /dev/null
+++ b/examples/declarative/minehunt/pics/back.png
Binary files differ
diff --git a/examples/declarative/minehunt/pics/cachepix-black.png b/examples/declarative/minehunt/pics/cachepix-black.png
deleted file mode 100644
index 53db3ae..0000000
--- a/examples/declarative/minehunt/pics/cachepix-black.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/minehunt/pics/cachepix-black.sci b/examples/declarative/minehunt/pics/cachepix-black.sci
deleted file mode 100644
index 21d5436..0000000
--- a/examples/declarative/minehunt/pics/cachepix-black.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-gridLeft: 10
-gridTop: 10
-gridBottom: 10
-gridRight: 10
-imageFile: cachepix-black.png
diff --git a/examples/declarative/minehunt/pics/cachepix-boxless.png b/examples/declarative/minehunt/pics/cachepix-boxless.png
deleted file mode 100644
index 288e0e4..0000000
--- a/examples/declarative/minehunt/pics/cachepix-boxless.png
+++ /dev/null
Binary files differ
diff --git a/examples/declarative/minehunt/pics/cachepix-boxless.sci b/examples/declarative/minehunt/pics/cachepix-boxless.sci
deleted file mode 100644
index d224fd9..0000000
--- a/examples/declarative/minehunt/pics/cachepix-boxless.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-gridLeft: 10
-gridTop: 10
-gridBottom: 10
-gridRight: 10
-imageFile: cachepix-boxless.png
diff --git a/examples/declarative/minehunt/pics/front.png b/examples/declarative/minehunt/pics/front.png
new file mode 100644
index 0000000..834331b
--- /dev/null
+++ b/examples/declarative/minehunt/pics/front.png
Binary files differ
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 35ccde1..7502842 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2070,7 +2070,7 @@ int QMetaProperty::propertyIndex() const
{
if (!mobj)
return -1;
- return ((handle - priv(mobj->d.data)->propertyData) / 3) + mobj->propertyOffset();
+ return idx + mobj->propertyOffset();
}
/*!
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 638c7d1..220e132 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -842,6 +842,14 @@ QObject::~QObject()
d->eventFilters.clear();
+ // As declarativeData is in a union with currentChildBeingDeleted, this must
+ // be done (and declarativeData set back to 0) before deleting children.
+ if(d->declarativeData) {
+ QDeclarativeData *dd = d->declarativeData;
+ d->declarativeData = 0;
+ dd->destroyed(this);
+ }
+
if (!d->children.isEmpty())
d->deleteChildren();
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 31b1593..81d3aba 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -85,6 +85,13 @@ inline QObjectData::~QObjectData() {}
enum { QObjectPrivateVersion = QT_VERSION };
+class Q_CORE_EXPORT QDeclarativeData
+{
+public:
+ virtual ~QDeclarativeData() {}
+ virtual void destroyed(QObject *) {}
+};
+
class Q_CORE_EXPORT QObjectPrivate : public QObjectData
{
Q_DECLARE_PUBLIC(QObject)
@@ -118,7 +125,10 @@ public:
// object currently activating the object
Sender *currentSender;
- QObject *currentChildBeingDeleted;
+ union {
+ QObject *currentChildBeingDeleted;
+ QDeclarativeData *declarativeData;
+ };
bool isSender(const QObject *receiver, const char *signal) const;
QObjectList receiverList(const char *signal) const;
diff --git a/src/declarative/3rdparty/easing.cpp b/src/declarative/3rdparty/easing.cpp
deleted file mode 100644
index 50e9e51..0000000
--- a/src/declarative/3rdparty/easing.cpp
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
-Disclaimer for Robert Penner's Easing Equations license:
-
-TERMS OF USE - EASING EQUATIONS
-
-Open source under the BSD License.
-
-Copyright © 2001 Robert Penner
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#ifndef M_PI_2
-#define M_PI_2 (M_PI / 2)
-#endif
-
-
-/**
- * Easing equation function for a simple linear tweening, with no easing.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeNone(float t, float b, float c, float d)
-{
- return c*t/d + b;
-}
-
-/**
- * Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInQuad(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- return c*t_adj*t_adj + b;
-}
-
-/**
-* Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutQuad(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- return -c *t_adj*(t_adj-2) + b;
-}
-
-/**
-* Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeInOutQuad(float t, float b, float c, float d)
-{
- float t_adj = 2.0f * (float)t / (float)d;
- if (t_adj < 1) {
- return c/2*t_adj*t_adj + b;
- } else {
- --t_adj;
- return -c/2 * ((t_adj)*(t_adj-2) - 1) + b;
- }
-}
-
-/**
-* Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutInQuad(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutQuad (t*2, b, c/2, d);
- return easeInQuad((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
-* Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeInCubic(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- return c*t_adj*t_adj*t_adj + b;
-}
-
-/**
-* Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutCubic(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)(d) - 1.0f;
- return c*(t_adj*t_adj*t_adj + 1) + b;
-}
-
-/**
-* Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeInOutCubic(float t, float b, float c, float d)
-{
- float t_adj = 2.0f * (float)t / (float)(d);
- if(t_adj < 1) return c/2*t_adj*t_adj*t_adj + b;
- else {
- t_adj -= 2;
- return c/2*(t_adj*t_adj*t_adj + 2) + b;
- }
-}
-
-/**
-* Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutInCubic(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutCubic (t*2, b, c/2, d);
- return easeInCubic((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
-* Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeInQuart(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- return c*t_adj*t_adj*t_adj*t_adj + b;
-}
-
-/**
-* Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutQuart(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d - 1.0f;
- return -c * (t_adj*t_adj*t_adj*t_adj - 1) + b;
-}
-
-/**
-* Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeInOutQuart(float t, float b, float c, float d)
-{
- float t_adj = 2.0f * (float)t / (float)d;
- if (t_adj < 1) return c/2*t_adj*t_adj*t_adj*t_adj + b;
- else {
- t_adj -= 2.0f;
- return -c/2 * (t_adj*t_adj*t_adj*t_adj - 2) + b;
- }
-}
-
-/**
-* Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
-*
-* @param t Current time (in frames or seconds).
-* @param b Starting value.
-* @param c Change needed in value.
-* @param d Expected easing duration (in frames or seconds).
-* @return The correct value.
-*/
-static float easeOutInQuart(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutQuart (t*2, b, c/2, d);
- return easeInQuart((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInQuint(float t, float b, float c, float d)
-{
- float t_adj = (float)t/(float)d;
- return c*t_adj*t_adj*t_adj*t_adj*t_adj + b;
-}
-
-/**
- * Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutQuint(float t, float b, float c, float d)
-{
- float t_adj = (float)t/(float)d - 1.0f;
- return c*(t_adj*t_adj*t_adj*t_adj*t_adj + 1) + b;
-}
-
-/**
- * Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInOutQuint(float t, float b, float c, float d)
-{
- float t_adj = 2.0f * (float)t/(float)d;
- if (t_adj < 1) return c/2*t_adj*t_adj*t_adj*t_adj*t_adj + b;
- else {
- t_adj -= 2.0f;
- return c/2*(t_adj*t_adj*t_adj*t_adj*t_adj + 2) + b;
- }
-}
-
-/**
- * Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutInQuint(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutQuint (t*2, b, c/2, d);
- return easeInQuint((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInSine(float t, float b, float c, float d)
-{
- float t_adj = (float)t/(float)d;
- return -c * ::cos(t_adj * M_PI_2) + c + b;
-}
-
-/**
- * Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutSine(float t, float b, float c, float d)
-{
- float t_adj = (float)t/(float)d;
- return c * ::sin(t_adj * M_PI_2) + b;
-}
-
-/**
- * Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInOutSine(float t, float b, float c, float d)
-{
- float t_adj = (float)t/(float)d;
- return -c/2 * (::cos(M_PI*t_adj) - 1) + b;
-}
-
-/**
- * Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutInSine(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutSine (t*2, b, c/2, d);
- return easeInSine((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInExpo(float t, float b, float c, float d)
-{
- return (t==0) ? b : c * ::pow(2, 10 * ((float)t/(float)d - 1)) + b - c * 0.001;
-}
-
-/**
- * Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutExpo(float t, float b, float c, float d)
-{
- return (t==d) ? b+c : c * 1.001 * (-::pow(2, -10 * (float)t/(float)d) + 1) + b;
-}
-
-/**
- * Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInOutExpo(float t, float b, float c, float d)
-{
- if (t==0) return b;
- if (t==d) return b+c;
- float t_adj = 2.0f * (float)t/(float)d;
- if (t_adj < 1) return c/2 * ::pow(2, 10 * (t_adj - 1)) + b - c * 0.0005;
- return c/2 * 1.0005 * (-::pow(2, -10 * (t_adj - 1)) + 2) + b;
-}
-
-/**
- * Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutInExpo(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutExpo (t*2, b, c/2, d);
- return easeInExpo((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInCirc(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- return -c * (::sqrt(1 - t_adj*t_adj) - 1) + b;
-}
-
-/**
- * Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutCirc(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d - 1.0f;
- return c * ::sqrt(1 - t_adj * t_adj) + b;
-}
-
-/**
- * Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInOutCirc(float t, float b, float c, float d)
-{
- float t_adj = 2.0f * (float)t / (float)d;
- if (t_adj < 1) return -c/2 * (::sqrt(1 - t_adj*t_adj) - 1) + b;
- else {
- t_adj -= 2.0f;
- return c/2 * (::sqrt(1 - t_adj*t_adj) + 1) + b;
- }
-}
-
-/**
- * Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutInCirc(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutCirc (t*2, b, c/2, d);
- return easeInCirc((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param a Amplitude.
- * @param p Period.
- * @return The correct value.
- */
-static float easeInElastic(float t, float b, float c, float d)
-{
- if (t==0) return b;
- float t_adj = (float)t / (float)d;
- if (t_adj==1) return b+c;
-
- qreal p = d * 0.3f;
- qreal a = c;
- qreal s = p / 4.0f;
-
- t_adj -= 1.0f;
- return -(a*::pow(2,10*t_adj) * ::sin( (t_adj*d-s)*(2*M_PI)/p )) + b;
-}
-
-/**
- * Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param a Amplitude.
- * @param p Period.
- * @return The correct value.
- */
-static float easeOutElastic(float t, float b, float c, float d)
-{
- if (t==0) return b;
- float t_adj = (float)t / (float)d;
- if (t_adj==1) return b+c;
-
- qreal p = d * 0.3f;
- qreal a = c;
- qreal s = p / 4;
-
- return (a*::pow(2,-10*t_adj) * ::sin( (t_adj*d-s)*(2*M_PI)/p ) + c + b);
-}
-
-/**
- * Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param a Amplitude.
- * @param p Period.
- * @return The correct value.
- */
-static float easeInOutElastic(float t, float b, float c, float d)
-{
- if (t==0) return b;
- float t_adj = 2.0f * (float)t / (float)d;
- if (t_adj==2) return b+c;
-
- // XXX
- qreal p = d * 0.3f * 1.5f;
- qreal a = c;
- qreal s = p / 4;
-
- if (t_adj < 1) return -.5*(a*::pow(2,10*(t_adj-1)) * ::sin( ((t_adj-1)*d-s)*(2*M_PI)/p )) + b;
- return a*::pow(2,-10*(t_adj-1)) * ::sin( ((t_adj-1)*d-s)*(2*M_PI)/p )*.5 + c + b;
-}
-
-/**
- * Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param a Amplitude.
- * @param p Period.
- * @return The correct value.
- */
-static float easeOutInElastic(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutElastic (t*2, b, c/2, d);
- return easeInElastic((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param s Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
- * @return The correct value.
- */
-static float easeInBack(float t, float b, float c, float d)
-{
- // XXX
- qreal s = 1.70158;
-
- float t_adj = (float)t / (float)d;
- return c*(t_adj)*t_adj*((s+1)*t_adj - s) + b;
-}
-
-/**
- * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param s Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
- * @return The correct value.
- */
-static float easeOutBack(float t, float b, float c, float d)
-{
- // XXX
- qreal s = 1.70158;
-
- float t_adj = (float)t / (float)d - 1.0f;
- return c*(t_adj*t_adj*((s+1)*t_adj + s) + 1) + b;
-}
-
-/**
- * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param s Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
- * @return The correct value.
- */
-static float easeInOutBack(float t, float b, float c, float d)
-{
- // XXX
- qreal s = 1.70158;
-
- float t_adj = 2.0f * (float)t / (float)d;
- if (t_adj < 1) {
- s *= 1.525f;
- return c/2*(t_adj*t_adj*((s+1)*t_adj - s)) + b;
- } else {
- t_adj -= 2;
- s *= 1.525f;
- return c/2*(t_adj*t_adj*((s+1)*t_adj + s) + 2) + b;
- }
-}
-
-/**
- * Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @param s Overshoot ammount: higher s means greater overshoot (0 produces cubic easing with no overshoot, and the default value of 1.70158 produces an overshoot of 10 percent).
- * @return The correct value.
- */
-static float easeOutInBack(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutBack (t*2, b, c/2, d);
- return easeInBack((t*2)-d, b+c/2, c/2, d);
-}
-
-/**
- * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutBounce(float t, float b, float c, float d)
-{
- float t_adj = (float)t / (float)d;
- if ((t_adj) < (1/2.75)) {
- return c*(7.5625*t_adj*t_adj) + b;
- } else if (t_adj < (2/2.75)) {
- t_adj -= (1.5f/2.75f);
- return c*(7.5625*t_adj*t_adj + .75) + b;
- } else if (t_adj < (2.5/2.75)) {
- t_adj -= (2.25f/2.75f);
- return c*(7.5625*t_adj*t_adj + .9375) + b;
- } else {
- t_adj -= (2.65f/2.75f);
- return c*(7.5625*t_adj*t_adj + .984375) + b;
- }
-}
-
-/**
- * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInBounce(float t, float b, float c, float d)
-{
- return c - easeOutBounce (d-t, 0, c, d) + b;
-}
-
-
-/**
- * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeInOutBounce(float t, float b, float c, float d)
-{
- if (t < d/2) return easeInBounce (t*2, 0, c, d) * .5 + b;
- else return easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b;
-}
-
-/**
- * Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
- *
- * @param t Current time (in frames or seconds).
- * @param b Starting value.
- * @param c Change needed in value.
- * @param d Expected easing duration (in frames or seconds).
- * @return The correct value.
- */
-static float easeOutInBounce(float t, float b, float c, float d)
-{
- if (t < d/2) return easeOutBounce (t*2, b, c/2, d);
- return easeInBounce((t*2)-d, b+c/2, c/2, d);
-}
-
diff --git a/src/declarative/3rdparty/legal.qdoc b/src/declarative/3rdparty/legal.qdoc
deleted file mode 100644
index bd0a9b2..0000000
--- a/src/declarative/3rdparty/legal.qdoc
+++ /dev/null
@@ -1,35 +0,0 @@
-/*!
-\page legal-easing.html
-\title easing
-\ingroup qtopia3rdparty
-Easing Equations by Robert Penner.
-\legalese
-\code
-Copyright (c) 2001 Robert Penner
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the author nor the names of contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\endcode
-\endlegalese
-*/
diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp
index 5d35a2a..4d2cc5b 100644
--- a/src/declarative/canvas/qsimplecanvas.cpp
+++ b/src/declarative/canvas/qsimplecanvas.cpp
@@ -541,6 +541,7 @@ void QSimpleCanvasGraphicsView::focusInEvent(QFocusEvent *)
}
/*!
+ \internal
\class QSimpleCanvas
\brief The QSimpleCanvas class implements the canvas used by Qt Declarative
*/
diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp
index b7e3ef0..446e331 100644
--- a/src/declarative/canvas/qsimplecanvasitem.cpp
+++ b/src/declarative/canvas/qsimplecanvasitem.cpp
@@ -62,6 +62,7 @@ QSimpleCanvasItemData::~QSimpleCanvasItemData()
}
/*!
+ \internal
\class QSimpleCanvasItem
\brief The QSimpleCanvasItem class is the base class of canvas items.
*/
diff --git a/src/declarative/canvas/qsimplecanvasitem.h b/src/declarative/canvas/qsimplecanvasitem.h
index 9b010e8..83f19c3 100644
--- a/src/declarative/canvas/qsimplecanvasitem.h
+++ b/src/declarative/canvas/qsimplecanvasitem.h
@@ -42,7 +42,6 @@
#ifndef QSIMPLECANVASITEM_H
#define QSIMPLECANVASITEM_H
-#include <gfxtimeline.h>
#include <qfxglobal.h>
#include <qsimplecanvas.h>
#include <QObject>
diff --git a/src/declarative/extra/qmlsqlconnection.cpp b/src/declarative/extra/qmlsqlconnection.cpp
index 3e2032c..7f1fec2 100644
--- a/src/declarative/extra/qmlsqlconnection.cpp
+++ b/src/declarative/extra/qmlsqlconnection.cpp
@@ -62,7 +62,6 @@ public:
int port;
QString name, databaseName, connectionOptions;
QString hostName, userName, password, driver;
- QmlContext *context;
};
/*!
@@ -177,8 +176,6 @@ public:
QmlSqlConnection::QmlSqlConnection(QObject *parent)
: QObject(*(new QmlSqlConnectionPrivate), parent)
{
- Q_D(QmlSqlConnection);
- d->context = QmlContext::activeContext();
}
/*!
@@ -416,10 +413,11 @@ QSqlDatabase QmlSqlConnection::database() const
}
if (db.isOpen())
return db;
- if ((d->driver.isEmpty() || d->driver == QLatin1String("QSQLITE")) && d->context) {
+ if ((d->driver.isEmpty() || d->driver == QLatin1String("QSQLITE")) &&
+ qmlContext(this)) {
// SQLITE uses files for databases, hence use relative pathing
// if possible.
- QUrl url = d->context->resolvedUrl(d->databaseName);
+ QUrl url = qmlContext(this)->resolvedUrl(d->databaseName);
if (url.isRelative() || url.scheme() == QLatin1String("file"))
db.setDatabaseName(url.toLocalFile());
else
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 13faab2..44787b5 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -87,7 +87,7 @@ class QmlXmlListModelPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlXmlListModel)
public:
- QmlXmlListModelPrivate() : size(-1), highestRole(Qt::UserRole), reply(0), context(0), roleObjects(this) {}
+ QmlXmlListModelPrivate() : size(-1), highestRole(Qt::UserRole), reply(0), roleObjects(this) {}
QString src;
QString query;
@@ -100,7 +100,6 @@ public:
QNetworkReply *reply;
mutable QByteArray xml;
QString prefix;
- QmlContext *context;
struct RoleList : public QmlConcreteList<XmlListModelRole *>
{
@@ -144,7 +143,6 @@ QmlXmlListModel::QmlXmlListModel(QObject *parent)
: QListModelInterface(*(new QmlXmlListModelPrivate), parent)
{
Q_D(QmlXmlListModel);
- d->context = QmlContext::activeContext();
}
QmlXmlListModel::~QmlXmlListModel()
@@ -249,7 +247,7 @@ void QmlXmlListModel::fetch()
QNetworkRequest req((QUrl(d->src)));
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = d->context->engine()->networkAccessManager()->get(req);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(requestFinished()));
}
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
index cc11b56..b5f0cc4 100644
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ b/src/declarative/fx/qfxanimatedimageitem.cpp
@@ -165,7 +165,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
}
d->source = url;
- d->url = itemContext()->resolvedUrl(url);
+ d->url = qmlContext(this)->resolvedUrl(url);
if(url.isEmpty()) {
delete d->_movie;
@@ -174,7 +174,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
d->status = Loading;
QNetworkRequest req(d->url);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = itemContext()->engine()->networkAccessManager()->get(req);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(movieRequestFinished()));
}
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index b5d9a9a..ec2b9cc 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
secondary image.
*/
QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
-: QFxItem(parent), _blend(0), dirty(false)
+: QFxItem(parent), _blend(0), _smooth(false), dirty(false)
{
#if defined(QFX_RENDER_OPENGL2)
setOptions(HasContents);
@@ -103,9 +103,9 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url)
if (!primSrc.isEmpty())
QFxPixmap::cancelGet(primUrl,this,SLOT(primaryLoaded()));
primSrc = url;
- primUrl = itemContext()->resolvedUrl(url);
+ primUrl = qmlContext(this)->resolvedUrl(url);
if (!primSrc.isEmpty())
- QFxPixmap::get(itemContext()->engine(), primUrl,this,SLOT(primaryLoaded()));
+ QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded()));
}
/*!
@@ -131,9 +131,9 @@ void QFxBlendedImage::setSecondaryUrl(const QString &url)
if (!secSrc.isEmpty())
QFxPixmap::cancelGet(secUrl,this,SLOT(secondaryLoaded()));
secSrc = url;
- secUrl = itemContext()->resolvedUrl(url);
+ secUrl = qmlContext(this)->resolvedUrl(url);
if (!secSrc.isEmpty())
- QFxPixmap::get(itemContext()->engine(), secUrl,this,SLOT(secondaryLoaded()));
+ QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded()));
}
/*!
@@ -154,16 +154,51 @@ void QFxBlendedImage::setBlend(qreal b)
update();
}
+/*!
+ \qmlproperty bool BlendedImage::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the BlendedImage is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+ */
+bool QFxBlendedImage::smoothTransform() const
+{
+ return _smooth;
+}
+
+void QFxBlendedImage::setSmoothTransform(bool s)
+{
+ if(_smooth == s)
+ return;
+ _smooth = s;
+ update();
+}
+
#if defined(QFX_RENDER_QPAINTER)
void QFxBlendedImage::paintContents(QPainter &p)
{
if (primSrc.isNull() && secSrc.isNull())
return;
+
+ if(_smooth) {
+ p.save();
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth);
+ }
+
if (_blend < 0.75)
p.drawImage(0, 0, primPix);
else
p.drawImage(0, 0, secPix);
+
+ if(_smooth) {
+ p.restore();
+ }
}
#elif defined(QFX_RENDER_OPENGL2)
diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h
index 96d3135..5cc0238 100644
--- a/src/declarative/fx/qfxblendedimage.h
+++ b/src/declarative/fx/qfxblendedimage.h
@@ -60,17 +60,22 @@ class QFxBlendedImage : public QFxItem
Q_PROPERTY(QString primaryUrl READ primaryUrl WRITE setPrimaryUrl)
Q_PROPERTY(QString secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
Q_PROPERTY(qreal blend READ blend WRITE setBlend)
+ Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxBlendedImage(QFxItem *parent=0);
QString primaryUrl() const;
void setPrimaryUrl(const QString &);
+
QString secondaryUrl() const;
void setSecondaryUrl(const QString &);
qreal blend() const;
void setBlend(qreal);
+ bool smoothTransform() const;
+ void setSmoothTransform(bool);
+
#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
#elif defined(QFX_RENDER_OPENGL2)
@@ -88,6 +93,7 @@ private:
QUrl secUrl;
qreal _blend;
+ bool _smooth;
bool dirty;
#if defined(QFX_RENDER_OPENGL2)
GLTexture prim;
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index b456716..02a6c86 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -109,7 +109,7 @@ void QFxComponentInstance::create()
{
Q_D(QFxComponentInstance);
if(d->component) {
- QObject *obj= d->component->create(itemContext());
+ QObject *obj= d->component->create(qmlContext(this));
if(obj) {
QFxItem *objitem = qobject_cast<QFxItem *>(obj);
if(objitem) {
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index a27e04d..b6eaa8e 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -43,13 +43,12 @@
#include "qfxflickable_p.h"
#include <QGraphicsSceneMouseEvent>
-#include <gfxeasing.h>
#include <QPointer>
#include <QTimer>
QT_BEGIN_NAMESPACE
-ElasticValue::ElasticValue(GfxValue &val)
+ElasticValue::ElasticValue(QmlTimeLineValue &val)
: _value(val)
{
_to = _value.value();
@@ -101,8 +100,8 @@ QFxFlickablePrivate::QFxFlickablePrivate()
, vTime(0), atXEnd(false), atXBeginning(true), pageXPosition(0.), pageWidth(0.)
, atYEnd(false), atYBeginning(true), pageYPosition(0.), pageHeight(0.)
{
- fixupXEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
- fixupYEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
+ fixupXEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
+ fixupYEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
}
void QFxFlickablePrivate::init()
@@ -128,11 +127,11 @@ void QFxFlickablePrivate::fixupX()
vTime = _tl.time();
if(_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
- _tl.move(_moveX, q->minXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
} else if(_moveX.value() < q->maxXExtent()) {
- _tl.move(_moveX, q->maxXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
}
@@ -147,10 +146,10 @@ void QFxFlickablePrivate::fixupY()
vTime = _tl.time();
if(_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- _tl.move(_moveY, q->minYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if(_moveY.value() < q->maxYExtent()) {
- _tl.move(_moveY, q->maxYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
flicked = false;
diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h
index 59450e0..ebd0327 100644
--- a/src/declarative/fx/qfxflickable_p.h
+++ b/src/declarative/fx/qfxflickable_p.h
@@ -57,7 +57,7 @@
#include "qfxflickable.h"
#include "qfxitem_p.h"
#include "qml.h"
-#include "gfxvalueproxy.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
class ElasticValue : public QAbstractAnimation {
Q_OBJECT
public:
- ElasticValue(GfxValue &);
+ ElasticValue(QmlTimeLineValue &);
void setValue(qreal to);
void clear();
@@ -81,7 +81,7 @@ private:
qreal _to;
qreal _myValue;
qreal _velocity;
- GfxValue &_value;
+ QmlTimeLineValue &_value;
QTime _startTime;
};
@@ -98,8 +98,8 @@ public:
public:
QFxItem *_flick;
- GfxValueProxy<QFxItem> _moveX;
- GfxValueProxy<QFxItem> _moveY;
+ QmlTimeLineValueProxy<QFxItem> _moveX;
+ QmlTimeLineValueProxy<QFxItem> _moveY;
QmlTimeLine _tl;
int vWidth;
int vHeight;
@@ -116,8 +116,8 @@ public:
qreal velocityX;
qreal velocityY;
QTime pressTime;
- GfxEvent fixupXEvent;
- GfxEvent fixupYEvent;
+ QmlTimeLineEvent fixupXEvent;
+ QmlTimeLineEvent fixupYEvent;
int maxVelocity;
bool locked;
QFxFlickable::DragMode dragMode;
@@ -128,12 +128,12 @@ public:
int velocityDecay;
void updateVelocity();
- struct Velocity : public GfxValue
+ struct Velocity : public QmlTimeLineValue
{
Velocity(QFxFlickablePrivate *p)
: parent(p) {}
virtual void setValue(qreal v) {
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
parent->updateVelocity();
}
QFxFlickablePrivate *parent;
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index f9a9f8c..5e4baac 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -558,7 +558,7 @@ void QFxGridViewPrivate::createHighlight()
return;
if (currentItem) {
- QmlContext *highlightContext = new QmlContext(q->itemContext());
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
QObject *nobj = highlightComponent->create(highlightContext);
if (nobj) {
highlightContext->setParent(nobj);
@@ -751,7 +751,7 @@ void QFxGridView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setModel(model);
@@ -796,7 +796,7 @@ void QFxGridView::setDelegate(QmlComponent *delegate)
{
Q_D(QFxGridView);
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setDelegate(delegate);
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
index d1ff3d3..d99b9e5 100644
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ b/src/declarative/fx/qfxhighlightfilter.cpp
@@ -56,10 +56,8 @@ class QFxHighlightFilterPrivate
{
public:
QFxHighlightFilterPrivate()
- : ctxt(QmlContext::activeContext()),
- xOffset(0), yOffset(0), tiled(false) {}
+ : xOffset(0), yOffset(0), tiled(false) {}
- QmlContext *ctxt;
QString source;
QUrl url;
int xOffset;
@@ -147,12 +145,12 @@ void QFxHighlightFilter::setSource(const QString &f)
if(!d->source.isEmpty())
QFxPixmap::cancelGet(d->url, this, SLOT(imageLoaded()));
d->source = f;
- d->url = QmlContext::activeContext()->resolvedUrl(f);
+ d->url = qmlContext(this)->resolvedUrl(f);
#if defined(QFX_RENDER_OPENGL2)
d->tex.clear();
#endif
if(!f.isEmpty())
- QFxPixmap::get(d->ctxt->engine(), d->url, this, SLOT(imageLoaded()));
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
else
emit sourceChanged(d->source);
}
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 9fe491c..2d0dbc7 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -842,7 +842,7 @@ void QFxImage::setSource(const QString &url)
QFxPixmap::cancelGet(d->sciurl, this, SLOT(requestFinished()));
d->source = url;
- d->url = itemContext()->resolvedUrl(url);
+ d->url = qmlContext(this)->resolvedUrl(url);
d->sciurl = QUrl();
if(url.isEmpty()) {
@@ -861,12 +861,12 @@ void QFxImage::setSource(const QString &url)
{
QNetworkRequest req(d->url);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = itemContext()->engine()->networkAccessManager()->get(req);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(sciRequestFinished()));
}
} else {
- QFxPixmap::get(itemContext()->engine(), d->url, this, SLOT(requestFinished()));
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(requestFinished()));
}
}
@@ -921,7 +921,7 @@ void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci)
emit statusChanged(d->status);
} else {
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- QFxPixmap::get(itemContext()->engine(), d->sciurl, this, SLOT(requestFinished()));
+ QFxPixmap::get(qmlEngine(this), d->sciurl, this, SLOT(requestFinished()));
QFxScaleGrid *sg = scaleGrid();
sg->setTop(sci.gridTop());
sg->setBottom(sci.gridBottom());
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index c2e35b9..644e812 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -228,6 +228,11 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
+ \property QFxItem::activeFocus
+ This property indicates whether the item has the active focus.
+ */
+
+/*!
\fn void QFxItem::activeFocusChanged()
This signal is emitted when this item gains active focus.
@@ -430,17 +435,25 @@ QFxItem::~QFxItem()
The default transform origin is \c TopLeft.
*/
+
/*!
\qmlproperty Item Item::parent
This property holds the parent of the item.
*/
+
+/*!
+ \property QFxItem::parent
+ This property holds the parent of the item.
+*/
void QFxItem::setItemParent(QFxItem *parent)
{
setParent(parent);
}
/*!
- XXX Playing around with view2view transitions.
+ \internal
+ \property QFxItem::moveToParent
+ Playing around with view2view transitions.
*/
void QFxItem::moveToParent(QFxItem *parent)
{
@@ -532,6 +545,19 @@ QFxItem *QFxItem::itemParent() const
*/
/*!
+ \property QFxItem::children
+
+ This property contains the list of visual children of this item.
+*/
+
+/*!
+ \property QFxItem::resources
+
+ This property contains non-visual resources that you want to
+ reference by name.
+*/
+
+/*!
Returns true if all of the attributes set via QML have been set;
otherwise returns false.
@@ -704,6 +730,18 @@ void QFxItemPrivate::children_clear()
data is a behind-the-scenes property: you should never need to explicitly
specify it.
*/
+
+/*!
+ \property QFxItem::data
+
+ The data property is allows you to freely mix the visual children
+ and the non-visual resources of an item. If you assign a visual
+ item to the data list it becomes a child and if you assign any
+ other object type, it is added as a resource.
+
+ data is a behind-the-scenes property: you should never need to
+ explicitly specify it.
+ */
QmlList<QObject *> *QFxItem::data()
{
Q_D(QFxItem);
@@ -728,6 +766,11 @@ QFxContents *QFxItem::contents()
return d->_contents;
}
+/*!
+ \internal
+ \property QFxItem::qmlItem
+*/
+
QFxItem *QFxItem::qmlItem() const
{
Q_D(const QFxItem);
@@ -742,6 +785,15 @@ QFxItem *QFxItem::qmlItem() const
item. Querying for the QML only has meaning if the QML has been
dynamically set; otherwise an empty string is returned.
*/
+
+/*!
+ \property QFxItem::qml
+ This property holds the dynamic QML for the item.
+
+ This property is used for dynamically loading QML into the
+ item. Querying for the QML only has meaning if the QML has been
+ dynamically set; otherwise an empty string is returned.
+*/
QString QFxItem::qml() const
{
Q_D(const QFxItem);
@@ -761,7 +813,7 @@ void QFxItem::setQml(const QString &qml)
}
d->_qml = qml;
- d->_qmlurl = itemContext()->resolvedUri(qml);
+ d->_qmlurl = qmlContext(this)->resolvedUri(qml);
d->qmlItem = 0;
if(d->_qml.isEmpty()) {
@@ -776,7 +828,7 @@ void QFxItem::setQml(const QString &qml)
emit qmlChanged();
} else {
d->_qmlcomp =
- new QmlComponent(itemContext()->engine(), d->_qmlurl, this);
+ new QmlComponent(qmlEngine(this), d->_qmlurl, this);
if(!d->_qmlcomp->isLoading())
qmlLoaded();
else
@@ -797,12 +849,12 @@ void QFxItem::qmlLoaded()
if(c->isLoading())
continue;
- QmlContext *ctxt = new QmlContext(itemContext());
+ QmlContext *ctxt = new QmlContext(qmlContext(this));
QObject* o = c ? c->create(ctxt):0;
QFxItem* ret = qobject_cast<QFxItem*>(o);
if (ret) {
ret->setItemParent(this);
- QScriptValue v = itemContext()->engine()->scriptEngine()->newQObject(ret);
+ QScriptValue v = qmlEngine(this)->scriptEngine()->newQObject(ret);
emit newChildCreated(d->_qmlnewloading.at(i).toString(),v);
}
@@ -815,7 +867,7 @@ void QFxItem::qmlLoaded()
// setQml...
if (d->_qmlcomp) {
- QmlContext *ctxt = new QmlContext(itemContext());
+ QmlContext *ctxt = new QmlContext(qmlContext(this));
ctxt->addDefaultObject(this);
QObject *obj = d->_qmlcomp->create(ctxt);
@@ -848,6 +900,39 @@ void QFxItem::qmlLoaded()
*/
/*!
+ \property QFxItem::width
+
+ Defines the item's width relative to its parent.
+ */
+
+/*!
+ \property QFxItem::height
+
+ Defines the item's height relative to its parent.
+ */
+
+/*!
+ \property QFxItem::x
+
+ The x coordinate of the item relative to its parent.
+*/
+
+/*!
+ \property QFxItem::y
+
+ The y coordinate of the item relative to its parent.
+*/
+
+/*!
+ \property QFxItem::z
+
+ The z coordinate of the item relative to its parent.
+
+ A negative z coordinate means the item will be painted below its parent.
+*/
+
+
+/*!
\qmlproperty real Item::z
Sets the stacking order of the item. By default the stacking order is 0.
@@ -900,12 +985,6 @@ void QFxItem::qmlLoaded()
\endqml
\endtable
*/
-/*!
- \property QFxItem::z
- \brief The z coordinate of the item relative to its parent.
-
- A negative z coordinate means the item will be painted below its parent.
-*/
void QFxItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
@@ -999,6 +1078,13 @@ void QFxItemPrivate::handleHeightChange(int yoffset)
When set, the item will be displayed flipped horizontally or vertically
about its center.
*/
+
+/*!
+ \property QFxItem::flipVertically
+
+ When set, the item will be displayed flipped horizontally or vertically
+ about its center.
+ */
bool QFxItem::flipVertically() const
{
return flip() & VerticalFlip;
@@ -1012,6 +1098,12 @@ void QFxItem::setFlipVertically(bool v)
setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip));
}
+/*!
+ \property QFxItem::flipHorizontally
+
+ When set, the item will be displayed flipped horizontally or vertically
+ about its center.
+ */
bool QFxItem::flipHorizontally() const
{
return flip() & HorizontalFlip;
@@ -1071,8 +1163,23 @@ QRectF QFxItem::sceneBoundingRect() const
\endqml
The identifier is available throughout to the \l {components}{component}
- where it is declared. Two items in the same component
- with the same identifier is invalid.
+ where it is declared. The identifier must be unique in thecomponent.
+*/
+
+/*!
+ \property QFxItem::id
+ This property holds the identifier for the item.
+
+ The identifier can be used in bindings and other expressions to
+ refer to the item. For example:
+
+ \qml
+ <Text id="myText" .../>
+ <Text text="{myText.text}"/>
+ \endqml
+
+ The identifier is available throughout the \l {components}{component}
+ where it is declared. The identifier must be unique in thecomponent.
*/
QString QFxItem::id() const
{
@@ -1142,6 +1249,54 @@ QFxAnchorLine QFxItem::verticalCenter() const
}
/*!
+ \property QFxItem::top
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::bottom
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::left
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::right
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::horizontalCenter
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::verticalCenter
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
\qmlproperty AnchorLine Item::top
\qmlproperty AnchorLine Item::bottom
\qmlproperty AnchorLine Item::left
@@ -1211,7 +1366,15 @@ QFxAnchorLine QFxItem::verticalCenter() const
*/
/*!
- \internal
+ \property QFxItem::baselineOffset
+ \brief The position of the item's baseline in global (scene) coordinates.
+
+ The baseline of a Text item is the imaginary line on which the text
+ sits. Controls containing text usually set their baseline to the
+ baseline of their text.
+
+ For non-text items, a default baseline offset of two-thirds of the
+ item's height is used to determine the baseline.
*/
int QFxItem::baselineOffset() const
{
@@ -1255,6 +1418,14 @@ void QFxItem::setBaselineOffset(int offset)
\endqml
\endtable
*/
+
+/*!
+ \property QFxItem::rotation
+ This property holds the rotation of the item in degrees.
+
+ This specifies how many degrees to rotate the item around its origin (0,0).
+ The default rotation is 0 degrees (i.e. not rotated at all).
+*/
qreal QFxItem::rotation() const
{
Q_D(const QFxItem);
@@ -1310,6 +1481,21 @@ void QFxItem::setRotation(qreal rotation)
\endqml
\endtable
*/
+
+/*!
+ \property QFxItem::scale
+ This property holds the scale of the item.
+
+ A scale of less than 1 means the item will be displayed smaller than
+ normal, and a scale of greater than 1 means the item will be
+ displayed larger than normal. A negative scale means the item will
+ be mirrored.
+
+ By default, items are displayed at a scale of 1 (i.e. at their
+ normal size).
+
+ Scaling is from the item's origin (0,0).
+*/
qreal QFxItem::scale() const
{
return QSimpleCanvasItem::scale();
@@ -1358,6 +1544,16 @@ void QFxItem::setScale(qreal s)
\endtable
*/
+/*!
+ \property QFxItem::opacity
+
+ The opacity of the item. Opacity is specified as a number between 0
+ (fully transparent) and 1 (fully opaque). The default is 1.
+
+ Opacity is an \e inherited attribute. That is, the opacity is
+ also applied individually to child items.
+*/
+
qreal QFxItem::opacity() const
{
return QSimpleCanvasItem::visible();
@@ -1425,6 +1621,13 @@ QmlList<QObject *> *QFxItem::resources()
\sa {states-transitions}{States and Transitions}
*/
+
+/*!
+ \property QFxItem::states
+ This property holds a list of states defined by the item.
+
+ \sa {states-transitions}{States and Transitions}
+*/
QmlList<QmlState *>* QFxItem::states()
{
Q_D(QFxItem);
@@ -1447,6 +1650,13 @@ QmlList<QmlState *>* QFxItem::states()
\sa {states-transitions}{States and Transitions}
*/
+
+/*!
+ \property QFxItem::transitions
+ This property holds a list of transitions defined by the item.
+
+ \sa {states-transitions}{States and Transitions}
+*/
QmlList<QmlTransition *>* QFxItem::transitions()
{
Q_D(QFxItem);
@@ -1454,6 +1664,11 @@ QmlList<QmlTransition *>* QFxItem::transitions()
}
/*!
+ \internal
+ \property QFxItem::filter
+*/
+
+/*!
\qmlproperty list<Filter> Item::filter
This property holds a list of graphical filters to be applied to the item.
@@ -1485,6 +1700,16 @@ QmlList<QmlTransition *>* QFxItem::transitions()
*/
/*!
+ \property QFxItem::clip
+ This property holds whether clipping is enabled.
+
+ if clipping is enabled, an item will clip its own painting, as well
+ as the painting of its children, to its bounding rectangle.
+
+ Non-rectangular clipping regions are not supported for performance reasons.
+*/
+
+/*!
Returns the state with \a name. Returns 0 if no matching state is found.
*/
QmlState *QFxItem::findState(const QString &name) const
@@ -1523,10 +1748,29 @@ QmlState *QFxItem::findState(const QString &name) const
*/
/*!
- \property QFxItem::state
- \brief the current state of the item.
+ \property QFxItem::state
+
+ This property holds the name of the current state of the item.
+
+ This property is often used in scripts to change between states. For
+ example:
- \sa {states-transitions}{States and Transitions}
+ \qml
+ <Script>
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ </Script>
+ \endqml
+
+ If the item is in its base state (i.e. no explicit state has been
+ set), \c state will be a blank string. Likewise, you can return an
+ item to its base state by setting its current state to \c ''.
+
+ \sa {states-transitions}{States and Transitions}
*/
QString QFxItem::state() const
{
@@ -1549,6 +1793,13 @@ void QFxItem::setState(const QString &state)
For more information see \l Transform.
*/
+
+/*!
+ \property QFxItem::transform
+ This property holds the list of transformations to apply.
+
+ For more information see \l Transform.
+*/
QList<QFxTransform *> *QFxItem::transform()
{
Q_D(QFxItem);
@@ -1556,6 +1807,16 @@ QList<QFxTransform *> *QFxItem::transform()
}
/*!
+ \property QFxItem::focus
+ This property holds the item's focus state.
+*/
+
+/*!
+ \property QFxItem::focusable
+ This property holds whether the item has focus state.
+*/
+
+/*!
Returns true if the item is visible; otherwise returns false.
An item is considered visible if its opacity is not 0.
@@ -1566,11 +1827,15 @@ bool QFxItem::isVisible() const
return d->visible;
}
-/*!
- Sets the visibility of the item to \a visible.
+/*!
+ \property QFxItem::visible
+
+ This property specifies whether the item is visible or invisible.
Setting visibility to false sets opacity to 0. Setting the
visibility to true restores the opacity to its previous value.
+
+ \sa isVisible()
*/
void QFxItem::setVisible(bool visible)
{
@@ -1615,12 +1880,12 @@ void QFxItem::newChild(const QString &type)
{
Q_D(QFxItem);
- QUrl url = itemContext()->resolvedUri(type);
+ QUrl url = qmlContext(this)->resolvedUri(type);
if (url.isEmpty())
return;
d->_qmlnewloading.append(url);
- d->_qmlnewcomp.append(new QmlComponent(itemContext()->engine(), url, this));
+ d->_qmlnewcomp.append(new QmlComponent(qmlEngine(this), url, this));
if(!d->_qmlnewcomp.last()->isLoading())
qmlLoaded();
@@ -1718,15 +1983,6 @@ void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
{
}
-/*!
- Returns the current QML context for this item.
-*/
-QmlContext *QFxItem::itemContext() const
-{
- Q_D(const QFxItem);
- return d->_ctxt;
-}
-
QmlStateGroup *QFxItemPrivate::states()
{
Q_Q(QFxItem);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 3f7784b..b76235b 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -121,7 +121,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS
Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically)
Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged )
+ Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
Q_PROPERTY(QFxAnchorLine left READ left)
Q_PROPERTY(QFxAnchorLine right READ right)
Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter)
@@ -209,8 +209,6 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
- QmlContext *itemContext() const;
-
public Q_SLOTS:
void newChild(const QString &url);
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 1266711..71fc912 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -84,7 +84,6 @@ public:
void init(QFxItem *parent)
{
Q_Q(QFxItem);
- _ctxt = QmlContext::activeContext();
if(parent)
q->setItemParent(parent);
@@ -92,7 +91,6 @@ public:
q->setAcceptedMouseButtons(Qt::NoButton);
}
- QmlContext *_ctxt;
QString _id;
// data property
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index c4ae3e3..d16c305 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -908,8 +908,7 @@ void QFxKeyActions::keyPressEvent(QKeyEvent *event)
{
Qt::Key key = (Qt::Key)event->key();
if(d->enabled && d->key(key)) {
- QmlExpression b(itemContext(), d->action(key),
- this, false);
+ QmlExpression b(qmlContext(this), d->action(key), this, false);
b.value();
event->accept();
} else {
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 3c8c12c..e03ec47 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -43,7 +43,6 @@
#include "qmlfollow.h"
#include "qlistmodelinterface.h"
#include "qfxvisualitemmodel.h"
-#include "gfxeasing.h"
#include "qfxlistview.h"
#include <qmlexpression.h>
@@ -395,7 +394,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
listItem->index = modelIndex;
// initialise attached properties
if (!sectionExpression.isEmpty()) {
- QmlExpression e(listItem->item->itemContext(), sectionExpression, q);
+ QmlExpression e(qmlContext(listItem->item), sectionExpression, q);
e.setTrackChange(false);
listItem->attached->m_section = e.value().toString();
if (modelIndex > 0) {
@@ -581,7 +580,7 @@ void QFxListViewPrivate::createHighlight()
if (currentItem) {
QFxItem *item = 0;
if (highlightComponent) {
- QmlContext *highlightContext = new QmlContext(q->itemContext());
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
QObject *nobj = highlightComponent->create(highlightContext);
if (nobj) {
highlightContext->setParent(nobj);
@@ -749,7 +748,7 @@ void QFxListViewPrivate::fixupY()
if (currentItem) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveY, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
@@ -761,7 +760,7 @@ void QFxListViewPrivate::fixupY()
else if (pos < -q->minYExtent())
pos = -q->minYExtent();
_tl.clear();
- _tl.move(_moveY, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -775,7 +774,7 @@ void QFxListViewPrivate::fixupX()
if (currItemMode == QFxListView::SnapAuto) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveX, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
int idx = snapIndex();
@@ -786,7 +785,7 @@ void QFxListViewPrivate::fixupX()
else if (pos < -q->minXExtent())
pos = -q->minXExtent();
_tl.clear();
- _tl.move(_moveX, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -900,7 +899,7 @@ void QFxListView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setModel(model);
@@ -945,7 +944,7 @@ void QFxListView::setDelegate(QmlComponent *delegate)
{
Q_D(QFxListView);
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setDelegate(delegate);
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index bfd03f7..be56786 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -323,7 +323,8 @@ void QFxMouseRegionPrivate::bindButtonValue(Qt::MouseButton b)
default:
bString = QLatin1String("None"); break;
}
- q->itemContext()->setContextProperty(QLatin1String("mouseButton"), bString);
+ // ### is this needed anymore?
+ qmlContext(q)->setContextProperty(QLatin1String("mouseButton"), bString);
}
void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 9319c46..8b16098 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-#include "gfxtimeline.h"
#include "qfxitem_p.h"
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
@@ -614,8 +613,8 @@ void QFxParticles::setUrl(const QString &name)
update();
} else {
d->source = name;
- d->url = itemContext()->resolvedUrl(name);
- QFxPixmap::get(itemContext()->engine(), d->url, this, SLOT(imageLoaded()));
+ d->url = qmlContext(this)->resolvedUrl(name);
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
}
}
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 99f6e86..b1cfaa5 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -43,7 +43,6 @@
#include <QDebug>
#include <QPen>
#include <QEvent>
-#include <gfxeasing.h>
#include "qmlbindablevalue.h"
#include "qmlstate.h"
#include "qlistmodelinterface.h"
@@ -595,6 +594,8 @@ void QFxPathViewPrivate::regenerate()
int minI = -1;
for(int i=0; i<numItems; i++){
QFxItem *item = model->item(i);
+ if (!item)
+ return;
items.append(item);
item->setZ(i);
item->setParent(q);
@@ -805,7 +806,7 @@ void QFxPathViewPrivate::snapToCurrent()
rounds--;
if(distance > 50)
rounds++;
- tl.move(moveOffset, targetOffset + 100.0*(-rounds), GfxEasing(GfxEasing::InOutQuad),
+ tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
tl.execute(fixupOffsetEvent);
return;
@@ -813,16 +814,16 @@ void QFxPathViewPrivate::snapToCurrent()
if (targetOffset - _offset > 50.0) {
qreal distance = 100 - targetOffset + _offset;
- tl.move(moveOffset, 0.0, GfxEasing(GfxEasing::OutQuad), int(200 * _offset / distance));
+ tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
tl.set(moveOffset, 100.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * (100-targetOffset) / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (100-targetOffset) / distance));
} else if (targetOffset - _offset <= -50.0) {
qreal distance = 100 - _offset + targetOffset;
- tl.move(moveOffset, 100.0, GfxEasing(GfxEasing::OutQuad), int(200 * (100-_offset) / distance));
+ tl.move(moveOffset, 100.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (100-_offset) / distance));
tl.set(moveOffset, 0.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * targetOffset / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
} else {
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InOutQuad), 200);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 6d4280d..2cc0769 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -44,7 +44,6 @@
#include <qfxitem.h>
#include <qfxpath.h>
-#include <gfxvalueproxy.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index 31933c0..a19d778 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -58,6 +58,7 @@
#include "qfxitem_p.h"
#include "qfxvisualitemmodel.h"
#include "qml.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -79,7 +80,7 @@ public:
, firstIndex(0), pathItems(-1), pathOffset(0), model(0)
, moveReason(Other)
{
- fixupOffsetEvent = GfxEvent::gfxEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
+ fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
}
void init()
@@ -115,8 +116,8 @@ public:
qreal snapPos;
qreal dragMargin;
QmlTimeLine tl;
- GfxValueProxy<QFxPathViewPrivate> moveOffset;
- GfxEvent fixupOffsetEvent;
+ QmlTimeLineValueProxy<QFxPathViewPrivate> moveOffset;
+ QmlTimeLineEvent fixupOffsetEvent;
int firstIndex;
int pathItems;
int pathOffset;
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 570d54d..ad4081b 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -259,7 +259,7 @@ void QFxRepeater::regenerate()
QStringList sl = qvariant_cast<QStringList>(d->dataSource);
for(int ii = 0; ii < sl.size(); ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -277,7 +277,7 @@ void QFxRepeater::regenerate()
QVariant v = QmlMetaType::listAt(d->dataSource, ii);
QObject *o = QmlMetaType::toQObject(v);
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -292,7 +292,7 @@ void QFxRepeater::regenerate()
return;
for(int ii = 0; ii < cnt; ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -313,7 +313,7 @@ void QFxRepeater::regenerate()
} else if (QObject *object = d->dataSource.value<QObject*>()) {
// A single object (i.e. list of size 1).
// Properties are the roles (excluding objectName).
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), QVariant(0));
@@ -335,7 +335,7 @@ void QFxRepeater::regenerate()
int count = qvariant_cast<int>(d->dataSource);
for(int ii = 0; ii < count; ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 145e750..e851bad 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -285,7 +285,7 @@ QFxVisualItemModelData *QFxVisualItemModelPrivate::data(QObject *item)
}
QFxVisualItemModel::QFxVisualItemModel()
-: QObject(*(new QFxVisualItemModelPrivate(QmlContext::activeContext())))
+: QObject(*(new QFxVisualItemModelPrivate(0)))
{
}
@@ -489,7 +489,9 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp
if(d->m_cache.contains(index)) {
nobj = d->m_cache[index];
} else {
- QmlContext *ctxt = new QmlContext(d->m_context);
+ QmlContext *ccontext = d->m_context;
+ if(!ccontext) ccontext = qmlContext(this);
+ QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->setContextProperty(QLatin1String("model"), data);
ctxt->addDefaultObject(data);
@@ -540,12 +542,14 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj
QObject *nobj = d->m_cache[index];
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
- QmlExpression e(item->itemContext(), expression, objectContext);
+ QmlExpression e(qmlContext(item), expression, objectContext);
e.setTrackChange(false);
value = e.value();
}
} else {
- QmlContext *ctxt = new QmlContext(d->m_context);
+ QmlContext *ccontext = d->m_context;
+ if(!ccontext) ccontext = qmlContext(this);
+ QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->addDefaultObject(data);
QmlExpression e(ctxt, expression, objectContext);
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index a5d2ac3..293c72b 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -199,23 +199,13 @@ QFxWebView::~QFxWebView()
void QFxWebView::init()
{
+ Q_D(QFxWebView);
+
setAcceptedMouseButtons(Qt::LeftButton);
setOptions(HasContents | MouseEvents);
setFocusable(true);
- QWebPage *wp = new QFxWebPage(this);
-
- // QML elements don't default to having a background,
- // even though most we pages will set one anyway.
- QPalette pal = QApplication::palette();
- pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
- wp->setPalette(pal);
-
- wp->setNetworkAccessManager(itemContext()->engine()->networkAccessManager());
- setPage(wp);
-
- // XXX settable from QML?
- settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ d->page = 0;
}
void QFxWebView::componentComplete()
@@ -297,26 +287,25 @@ void QFxWebView::doLoadFinished(bool ok)
*/
QString QFxWebView::url() const
{
- Q_D(const QFxWebView);
- return d->page->mainFrame()->url().toString();
+ return page()->mainFrame()->url().toString();
}
void QFxWebView::setUrl(const QString &n)
{
Q_D(QFxWebView);
- if(n == d->page->mainFrame()->url().toString())
+ if(n == page()->mainFrame()->url().toString())
return;
- d->page->setViewportSize(QSize(
+ page()->setViewportSize(QSize(
d->idealwidth>0 ? d->idealwidth : width(),
d->idealheight>0 ? d->idealheight : height()));
QUrl url(n);
if (url.isRelative())
- url = itemContext()->resolvedUrl(n);
+ url = qmlContext(this)->resolvedUrl(n);
if (isComponentComplete())
- d->page->mainFrame()->load(url);
+ page()->mainFrame()->load(url);
else {
d->pending = d->PendingUrl;
d->pending_url = url;
@@ -372,12 +361,16 @@ void QFxWebView::setIdealHeight(int ih)
}
/*!
- \qmlproperty bool WebView::interactive
- This property holds controls whether the item responds to mouse and key events.
+ \qmlproperty bool WebView::interactive
+
+ This property holds controls whether the item responds to mouse and
+ key events.
*/
+
/*!
- \property QFxWebView::interactive
- \brief controls whether the item responds to mouse and key events.
+ \property QFxWebView::interactive
+
+ \brief controls whether the item responds to mouse and key events.
*/
bool QFxWebView::interactive() const
{
@@ -425,7 +418,7 @@ void QFxWebView::updateCacheForVisibility()
void QFxWebView::expandToWebPage()
{
Q_D(QFxWebView);
- QSize cs = d->page->mainFrame()->contentsSize();
+ QSize cs = page()->mainFrame()->contentsSize();
if (cs.width() < d->idealwidth)
cs.setWidth(d->idealwidth);
if (cs.height() < d->idealheight)
@@ -434,8 +427,8 @@ void QFxWebView::expandToWebPage()
cs.setWidth(width());
if (heightValid() && cs.height() < height())
cs.setHeight(height());
- if (cs != d->page->viewportSize()) {
- d->page->setViewportSize(cs);
+ if (cs != page()->viewportSize()) {
+ page()->setViewportSize(cs);
d->clearCache();
setImplicitWidth(cs.width());
setImplicitHeight(cs.height());
@@ -458,19 +451,19 @@ void QFxWebView::paintPage(const QRect& r)
}
/*!
- \qmlproperty int WebView::cacheSize
- This property holds the maximum number of pixels of image cache to allow
+ \qmlproperty int WebView::cacheSize
- The default is 0.1 megapixels.
-
- The cache will not be larger than the (unscaled) size of the WebView.
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the WebView.
*/
+
/*!
- \property QFxWebView::cacheSize
- \brief the maximum number of pixels of image cache to allow
- The default is 0.1 megapixels.
+ \property QFxWebView::cacheSize
- The cache will not be larger than the (unscaled) size of the QFxWebView.
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QFxWebView.
*/
int QFxWebView::cacheSize() const
{
@@ -520,7 +513,7 @@ void QFxWebView::paintGLContents(GLPainter &p)
#endif
{
Q_D(QFxWebView);
- QWebFrame *frame = d->page->mainFrame();
+ QWebFrame *frame = page()->mainFrame();
const QRect content(QPoint(0,0),frame->contentsSize());
if (content.width() <= 0 || content.height() <= 0)
@@ -600,8 +593,7 @@ void QFxWebView::paintGLContents(GLPainter &p)
QString QFxWebView::propertyInfo() const
{
- Q_D(const QFxWebView);
- return d->page->mainFrame()->url().toString();
+ return page()->mainFrame()->url().toString();
}
static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
@@ -634,12 +626,12 @@ void QFxWebView::timerEvent(QTimerEvent *event)
if (event->timerId() ==d->dcTimer.timerId()) {
d->dcTimer.stop();
if (d->lastPress) {
- d->page->event(d->lastPress);
+ page()->event(d->lastPress);
delete d->lastPress;
d->lastPress = 0;
}
if (d->lastRelease) {
- d->page->event(d->lastRelease);
+ page()->event(d->lastRelease);
delete d->lastRelease;
d->lastRelease = 0;
}
@@ -715,7 +707,7 @@ void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(const QFxWebView);
if (d->interactive && !d->dcTimer.isActive()) {
QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- d->page->event(me);
+ page()->event(me);
event->setAccepted(
#if QT_VERSION <= 0x040500 // XXX see bug 230835
true
@@ -735,7 +727,7 @@ void QFxWebView::keyPressEvent(QKeyEvent* event)
{
Q_D(const QFxWebView);
if (d->interactive)
- d->page->event(event);
+ page()->event(event);
if (!event->isAccepted())
QFxItem::keyPressEvent(event);
}
@@ -744,7 +736,7 @@ void QFxWebView::keyReleaseEvent(QKeyEvent* event)
{
Q_D(const QFxWebView);
if (d->interactive)
- d->page->event(event);
+ page()->event(event);
if (!event->isAccepted())
QFxItem::keyReleaseEvent(event);
}
@@ -755,8 +747,7 @@ void QFxWebView::keyReleaseEvent(QKeyEvent* event)
*/
QAction *QFxWebView::backAction() const
{
- Q_D(const QFxWebView);
- return d->page->action(QWebPage::Back);
+ return page()->action(QWebPage::Back);
}
/*!
@@ -765,8 +756,7 @@ QAction *QFxWebView::backAction() const
*/
QAction *QFxWebView::forwardAction() const
{
- Q_D(const QFxWebView);
- return d->page->action(QWebPage::Forward);
+ return page()->action(QWebPage::Forward);
}
/*!
@@ -775,8 +765,7 @@ QAction *QFxWebView::forwardAction() const
*/
QAction *QFxWebView::reloadAction() const
{
- Q_D(const QFxWebView);
- return d->page->action(QWebPage::Reload);
+ return page()->action(QWebPage::Reload);
}
/*!
@@ -785,8 +774,7 @@ QAction *QFxWebView::reloadAction() const
*/
QAction *QFxWebView::stopAction() const
{
- Q_D(const QFxWebView);
- return d->page->action(QWebPage::Stop);
+ return page()->action(QWebPage::Stop);
}
/*!
@@ -805,10 +793,7 @@ QAction *QFxWebView::stopAction() const
*/
QString QFxWebView::title() const
{
- Q_D(const QFxWebView);
- if (d->page)
- return d->page->mainFrame()->title();
- return QString();
+ return page()->mainFrame()->title();
}
@@ -827,10 +812,7 @@ QString QFxWebView::title() const
*/
QPixmap QFxWebView::icon() const
{
- Q_D(const QFxWebView);
- if (d->page)
- return d->page->mainFrame()->icon().pixmap(QSize(256,256));
- return QPixmap();
+ return page()->mainFrame()->icon().pixmap(QSize(256,256));
}
@@ -844,8 +826,7 @@ QPixmap QFxWebView::icon() const
*/
void QFxWebView::setTextSizeMultiplier(qreal factor)
{
- Q_D(QFxWebView);
- d->page->mainFrame()->setTextSizeMultiplier(factor);
+ page()->mainFrame()->setTextSizeMultiplier(factor);
}
/*!
@@ -853,8 +834,7 @@ void QFxWebView::setTextSizeMultiplier(qreal factor)
*/
qreal QFxWebView::textSizeMultiplier() const
{
- Q_D(const QFxWebView);
- return d->page->mainFrame()->textSizeMultiplier();
+ return page()->mainFrame()->textSizeMultiplier();
}
void QFxWebView::setStatusBarMessage(const QString& s)
@@ -873,9 +853,31 @@ QString QFxWebView::status() const
QWebPage *QFxWebView::page() const
{
Q_D(const QFxWebView);
+
+ if (!d->page) {
+ QFxWebView *self = const_cast<QFxWebView*>(this);
+ QWebPage *wp = new QFxWebPage(self);
+
+ // QML elements don't default to having a background,
+ // even though most we pages will set one anyway.
+ QPalette pal = QApplication::palette();
+ pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
+ wp->setPalette(pal);
+
+ wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager());
+
+ // XXX settable from QML?
+ wp->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+
+ self->setPage(wp);
+
+ return wp;
+ }
+
return d->page;
}
+
void QFxWebView::setPage(QWebPage *page)
{
Q_D(QFxWebView);
@@ -1026,7 +1028,7 @@ public:
propertyValues(paramValues),
webview(view)
{
- QmlEngine *engine = webview->itemContext()->engine();
+ QmlEngine *engine = qmlEngine(webview);
component = new QmlComponent(engine, url, this);
item = 0;
connect(engine, SIGNAL(statusChanged(Status)), this, SLOT(qmlLoaded()));
@@ -1035,7 +1037,7 @@ public:
public Q_SLOTS:
void qmlLoaded()
{
- item = qobject_cast<QFxItem*>(component->create(webview->itemContext()));
+ item = qobject_cast<QFxItem*>(component->create(qmlContext(webview)));
item->setParent(webview);
for (int i=0; i<propertyNames.count(); ++i) {
if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
@@ -1070,7 +1072,7 @@ QFxWebView *QFxWebPage::view()
QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
{
- QUrl comp = view()->itemContext()->resolvedUri(url.toString());
+ QUrl comp = qmlContext(view())->resolvedUri(url.toString());
return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues);
}
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 463d0c4..1eede52 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -92,8 +92,10 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
Q_PROPERTY(int idealHeight READ idealHeight WRITE setIdealHeight NOTIFY idealHeightChanged)
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged())
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
+
Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
Q_PROPERTY(QObject* reload READ reloadAction)
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index bf7b6bc..fb288b7 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -88,6 +88,11 @@ QT_MODULE(Declarative)
#define QML_DEFINE_NOCREATE_TYPE(TYPE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterType<TYPE>(#TYPE));
+class QmlContext;
+class QmlEngine;
+Q_DECLARATIVE_EXPORT QmlContext *qmlContext(const QObject *);
+Q_DECLARATIVE_EXPORT QmlEngine *qmlEngine(const QObject *);
+
QML_DECLARE_TYPE(QObject);
Q_DECLARE_METATYPE(QVariant);
diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp
index 423fda8..c2632da 100644
--- a/src/declarative/qml/qmlbindablevalue.cpp
+++ b/src/declarative/qml/qmlbindablevalue.cpp
@@ -41,9 +41,7 @@
#include <qml.h>
#include "qmlbindablevalue.h"
-#include <gfxeasing.h>
#include <qmlcontext.h>
-#include <gfxtimeline.h>
#include <QVariant>
#include <qfxperf.h>
#include <QtCore/qdebug.h>
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index f03ce20..5436227 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1647,12 +1647,15 @@ QmlCompiledData &QmlCompiledData::operator=(const QmlCompiledData &other)
return *this;
}
-QObject *QmlCompiledData::TypeReference::createInstance() const
+QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const
{
if(type) {
- return type->create();
+ QObject *rv = type->create();
+ if(rv)
+ QmlEngine::setContextForObject(rv, ctxt);
+ return rv;
} else if(component) {
- return component->create(QmlContext::activeContext());
+ return component->create(ctxt);
} else {
return 0;
}
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index 754e284..286cda8 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -54,6 +54,7 @@ class QmlXmlParser;
class QmlEngine;
class QmlComponent;
class QmlCompiledComponent;
+class QmlContext;
namespace QmlParser {
class Object;
@@ -83,7 +84,7 @@ public:
QmlCustomParser *parser;
QmlRefCount *ref;
- QObject *createInstance() const;
+ QObject *createInstance(QmlContext *) const;
};
QList<TypeReference> types;
struct CustomTypeData
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 104f460..40e33c2 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -96,6 +96,8 @@ void QmlContextPrivate::init()
else
scopeChain = parent->d_func()->scopeChain;
scopeChain.prepend(scopeObj);
+
+ contextData.context = q;
}
void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority)
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index 8c51a6b..aa0bf3e 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -81,6 +81,13 @@ public:
NormalPriority
};
void addDefaultObject(QObject *, Priority);
+
+ class ContextData : public QDeclarativeData
+ {
+ public:
+ QmlContext *context;
+ };
+ ContextData contextData;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 5cbd02b..66c41f2 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -42,6 +42,7 @@
#include <QMetaProperty>
#include <private/qmlengine_p.h>
#include <private/qmlcontext_p.h>
+#include <private/qobject_p.h>
#ifdef QT_SCRIPTTOOLS_LIB
#include <QScriptEngineDebugger>
@@ -595,6 +596,38 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
return d->networkAccessManager;
}
+QmlContext *QmlEngine::contextForObject(const QObject *object)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
+ if(priv->declarativeData) {
+ return static_cast<QmlContextPrivate::ContextData *>(priv->declarativeData)->context;
+ } else {
+ return 0;
+ }
+}
+
+QmlContext *qmlContext(const QObject *obj)
+{
+ return QmlEngine::contextForObject(obj);
+}
+
+QmlEngine *qmlEngine(const QObject *obj)
+{
+ QmlContext *context = QmlEngine::contextForObject(obj);
+ return context?context->engine():0;
+}
+
+
+void QmlEngine::setContextForObject(QObject *object, QmlContext *context)
+{
+ QObjectPrivate *priv = QObjectPrivate::get(object);
+ if(priv->declarativeData) {
+ qWarning("QmlEngine::setContextForObject(): Object already has a QmlContext");
+ return;
+ }
+ priv->declarativeData = &context->d_func()->contextData;
+}
+
/*! \internal */
QScriptEngine *QmlEngine::scriptEngine()
{
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 086595a..fde84d4 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -81,6 +81,8 @@ public:
void setNetworkAccessManager(QNetworkAccessManager *);
QNetworkAccessManager *networkAccessManager() const;
+ static QmlContext *contextForObject(const QObject *);
+ static void setContextForObject(QObject *, QmlContext *);
private:
// LK: move to the private class
QScriptEngine *scriptEngine();
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index ef9e970..e7f7cfb 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -92,6 +92,9 @@ QmlMetaProperty::QmlMetaProperty()
{
}
+/*!
+ The destructor deletes its heap data.
+ */
QmlMetaProperty::~QmlMetaProperty()
{
delete d; d = 0;
@@ -954,7 +957,12 @@ bool QmlMetaProperty::hasChangedNotifier() const
}
/*!
- Connect the property's change notifier signal to the \a dest \a method.
+ Connects the property's change notifier signal to the
+ specified \a method of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a method.
*/
bool QmlMetaProperty::connectNotifier(QObject *dest, int method) const
{
@@ -969,7 +977,12 @@ bool QmlMetaProperty::connectNotifier(QObject *dest, int method) const
}
/*!
- Connect the property's change notifier signal to the \a dest \a slot.
+ Connects the property's change notifier signal to the
+ specified \a slot of the \a dest object and returns
+ true. Returns false if this metaproperty does not
+ represent a regular Qt property or if it has no
+ change notifier signal, or if the \a dest object does
+ not have the specified \a slot.
*/
bool QmlMetaProperty::connectNotifier(QObject *dest, const char *slot) const
{
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 966ef8a..b6d9173 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -253,7 +253,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxCompilerTimer<QFxCompiler::InstrCreateObject> cc;
#endif
- QObject *o = types.at(instr.create.type).createInstance();
+ QObject *o = types.at(instr.create.type).createInstance(QmlContext::activeContext());
if(!o)
VME_EXCEPTION("Unable to create object of type" << types.at(instr.create.type).className);
@@ -276,6 +276,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
QObject *o = QmlMetaType::toQObject(v);
if(!o)
VME_EXCEPTION("Unable to create" << types.at(instr.create.type).className);
+ QmlEngine::setContextForObject(o, QmlContext::activeContext());
if(!stack.isEmpty()) {
QObject *parent = stack.top();
diff --git a/src/declarative/test/qfxtestengine.cpp b/src/declarative/test/qfxtestengine.cpp
index 96ce451..d9e3533 100644
--- a/src/declarative/test/qfxtestengine.cpp
+++ b/src/declarative/test/qfxtestengine.cpp
@@ -41,7 +41,7 @@
#include <QFile>
#include <QmlComponent>
-#include <gfxtimeline.h>
+#include <qmltimeline.h>
#include "qfxtestengine.h"
#include "qfxtestobjects.h"
#include <QCryptographicHash>
diff --git a/src/declarative/timeline/gfxeasing.cpp b/src/declarative/timeline/gfxeasing.cpp
deleted file mode 100644
index 45b84eb..0000000
--- a/src/declarative/timeline/gfxeasing.cpp
+++ /dev/null
@@ -1,811 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used 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. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "gfxeasing.h"
-#include <math.h>
-#include <QHash>
-#include <QPainter>
-#include <QVariant>
-#include <QDebug>
-#include <QStringList>
-#include <QMouseEvent>
-#include "gfxtimeline.h"
-
-
-QT_BEGIN_NAMESPACE
-typedef QHash<QString, qreal> GfxEasingProperties;
-class GfxEasingFunction
-{
-public:
- virtual ~GfxEasingFunction() {}
- virtual float value(float t, float b, float c, float d) = 0;
- virtual GfxEasingFunction *copy() const = 0;
-};
-
-#include "../3rdparty/easing.cpp"
-
-struct ElasticEase : public GfxEasingFunction
-{
- enum Type { In, Out };
- ElasticEase(Type t) : _t(t), _p(0.0f), _a(0.0f) {}
-
- Type _t;
- qreal _p;
- qreal _a;
-
- GfxEasingFunction *copy() const
- {
- ElasticEase *rv = new ElasticEase(_t);
- rv->_p = _p;
- rv->_a = _a;
- return rv;
- }
-
- float value(float t, float b, float c, float d)
- {
- if (t==0) return b;
- float t_adj = (float)t / (float)d;
- if (t_adj==1) return b+c;
-
- qreal p = _p?_p:(d * 0.3f);
-
- qreal a;
- qreal s;
-
- if(!_a || _a < ::fabs(c)) {
- a = c;
- s = p / 4.0f;
- } else {
- a = _a;
- s = p / (2 * M_PI) * ::asin(c / a);
- }
-
- if(_t == In)
- t_adj -= 1.0f;
-
- return (a*::pow(2,-10*t_adj) * ::sin( (t_adj*d-s)*(2*M_PI)/p ) + c + b);
- }
-};
-
-struct BounceEase : public GfxEasingFunction
-{
- enum Type { In, Out };
- BounceEase(Type t) : _t(t), _a(-1.0) {}
-
- Type _t;
- qreal _a;
-
- GfxEasingFunction *copy() const
- {
- BounceEase *rv = new BounceEase(_t);
- rv->_t = _t;
- rv->_a = _a;
- return rv;
- }
-
- float value(float t, float b, float c, float d)
- {
- if(In == _t)
- return c - bounce(d - t, 0, c, d) + b;
- else
- return bounce(t, b, c, d);
- }
-
- float bounce(float t, float b, float c, float d)
- {
- float t_adj = (float)t / (float)d;
- float amp = (_a == -1.0)?c:_a;
- if ((t_adj) < (1/2.75)) {
- if(c == 0. && _a != -1.0) {
- t_adj -= (0.5f/2.75f);
- return -amp * (1. - (30.25*t_adj*t_adj)) + b;
- } else {
- return c*(7.5625*t_adj*t_adj) + b;
- }
- } else if (t_adj < (2/2.75)) {
- t_adj -= (1.5f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .75)) + (b + c);
- } else if (t_adj < (2.5/2.75)) {
- t_adj -= (2.25f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .9375)) + (b + c);
- } else {
- t_adj -= (2.65f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .984375)) + (b + c);
- }
- }
-};
-
-static GfxEasingFunction *easeInElasticC(const GfxEasingProperties &p)
-{
- ElasticEase *rv = new ElasticEase(ElasticEase::In);
- rv->_p = p[QLatin1String("period")];
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-
-static GfxEasingFunction *easeOutElasticC(const GfxEasingProperties &p)
-{
- ElasticEase *rv = new ElasticEase(ElasticEase::Out);
- rv->_p = p[QLatin1String("period")];
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-static GfxEasingFunction *easeOutBounceC(const GfxEasingProperties &p)
-{
- BounceEase *rv = new BounceEase(BounceEase::Out);
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-static GfxEasingFunction *easeInBounceC(const GfxEasingProperties &p)
-{
- BounceEase *rv = new BounceEase(BounceEase::Out);
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-
-struct SimpleConfig : public GfxEasingFunction
-{
- GfxEasing::Function func;
-
- float value(float t, float b, float c, float d)
- {
- return func(t, b, c, d);
- }
-
- GfxEasingFunction *copy() const
- {
- SimpleConfig *rv = new SimpleConfig;
- rv->func = func;
- return rv;
- }
-};
-
-GfxEasing::Function curveToFunc(GfxEasing::Curve curve)
-{
- switch(curve)
- {
- case GfxEasing::None:
- return &easeNone;
- case GfxEasing::InQuad:
- return &easeInQuad;
- case GfxEasing::OutQuad:
- return &easeOutQuad;
- case GfxEasing::InOutQuad:
- return &easeInOutQuad;
- case GfxEasing::OutInQuad:
- return &easeOutInQuad;
- case GfxEasing::InCubic:
- return &easeInCubic;
- case GfxEasing::OutCubic:
- return &easeOutCubic;
- case GfxEasing::InOutCubic:
- return &easeInOutCubic;
- case GfxEasing::OutInCubic:
- return &easeOutInCubic;
- case GfxEasing::InQuart:
- return &easeInQuart;
- case GfxEasing::OutQuart:
- return &easeOutQuart;
- case GfxEasing::InOutQuart:
- return &easeInOutQuart;
- case GfxEasing::OutInQuart:
- return &easeOutInQuart;
- case GfxEasing::InQuint:
- return &easeInQuint;
- case GfxEasing::OutQuint:
- return &easeOutQuint;
- case GfxEasing::InOutQuint:
- return &easeInOutQuint;
- case GfxEasing::OutInQuint:
- return &easeOutInQuint;
- case GfxEasing::InSine:
- return &easeInSine;
- case GfxEasing::OutSine:
- return &easeOutSine;
- case GfxEasing::InOutSine:
- return &easeInOutSine;
- case GfxEasing::OutInSine:
- return &easeOutInSine;
- case GfxEasing::InExpo:
- return &easeInExpo;
- case GfxEasing::OutExpo:
- return &easeOutExpo;
- case GfxEasing::InOutExpo:
- return &easeInOutExpo;
- case GfxEasing::OutInExpo:
- return &easeOutInExpo;
- case GfxEasing::InCirc:
- return &easeInCirc;
- case GfxEasing::OutCirc:
- return &easeOutCirc;
- case GfxEasing::InOutCirc:
- return &easeInOutCirc;
- case GfxEasing::OutInCirc:
- return &easeOutInCirc;
- case GfxEasing::InElastic:
- return &easeInElastic;
- case GfxEasing::OutElastic:
- return &easeOutElastic;
- case GfxEasing::InOutElastic:
- return &easeInOutElastic;
- case GfxEasing::OutInElastic:
- return &easeOutInElastic;
- case GfxEasing::InBack:
- return &easeInBack;
- case GfxEasing::OutBack:
- return &easeOutBack;
- case GfxEasing::InOutBack:
- return &easeInOutBack;
- case GfxEasing::OutInBack:
- return &easeOutInBack;
- case GfxEasing::InBounce:
- return &easeInBounce;
- case GfxEasing::OutBounce:
- return &easeOutBounce;
- case GfxEasing::InOutBounce:
- return &easeInOutBounce;
- case GfxEasing::OutInBounce:
- return &easeOutInBounce;
- default:
- return 0;
- };
-}
-
-struct NameFunctionMap : public QHash<QString, GfxEasing::Function>
-{
- NameFunctionMap()
- {
- insert(QLatin1String("easeNone"), easeNone);
- insert(QLatin1String("easeInQuad"), easeInQuad);
- insert(QLatin1String("easeOutQuad"), easeOutQuad);
- insert(QLatin1String("easeInOutQuad"), easeInOutQuad);
- insert(QLatin1String("easeOutInQuad"), easeOutInQuad);
- insert(QLatin1String("easeInCubic"), easeInCubic);
- insert(QLatin1String("easeOutCubic"), easeOutCubic);
- insert(QLatin1String("easeInOutCubic"), easeInOutCubic);
- insert(QLatin1String("easeOutInCubic"), easeOutInCubic);
- insert(QLatin1String("easeInQuart"), easeInQuart);
- insert(QLatin1String("easeOutQuart"), easeOutQuart);
- insert(QLatin1String("easeInOutQuart"), easeInOutQuart);
- insert(QLatin1String("easeOutInQuart"), easeOutInQuart);
- insert(QLatin1String("easeInQuint"), easeInQuint);
- insert(QLatin1String("easeOutQuint"), easeOutQuint);
- insert(QLatin1String("easeInOutQuint"), easeInOutQuint);
- insert(QLatin1String("easeOutInQuint"), easeOutInQuint);
- insert(QLatin1String("easeInSine"), easeInSine);
- insert(QLatin1String("easeOutSine"), easeOutSine);
- insert(QLatin1String("easeInOutSine"), easeInOutSine);
- insert(QLatin1String("easeOutInSine"), easeOutInSine);
- insert(QLatin1String("easeInExpo"), easeInExpo);
- insert(QLatin1String("easeOutExpo"), easeOutExpo);
- insert(QLatin1String("easeInOutExpo"), easeInOutExpo);
- insert(QLatin1String("easeOutInExpo"), easeOutInExpo);
- insert(QLatin1String("easeInCirc"), easeInCirc);
- insert(QLatin1String("easeOutCirc"), easeOutCirc);
- insert(QLatin1String("easeInOutCirc"), easeInOutCirc);
- insert(QLatin1String("easeOutInCirc"), easeOutInCirc);
- insert(QLatin1String("easeInElastic"), easeInElastic);
- insert(QLatin1String("easeOutElastic"), easeOutElastic);
- insert(QLatin1String("easeInOutElastic"), easeInOutElastic);
- insert(QLatin1String("easeOutInElastic"), easeOutInElastic);
- insert(QLatin1String("easeInBack"), easeInBack);
- insert(QLatin1String("easeOutBack"), easeOutBack);
- insert(QLatin1String("easeInOutBack"), easeInOutBack);
- insert(QLatin1String("easeOutInBack"), easeOutInBack);
- insert(QLatin1String("easeInBounce"), easeInBounce);
- insert(QLatin1String("easeOutBounce"), easeOutBounce);
- insert(QLatin1String("easeInOutBounce"), easeInOutBounce);
- insert(QLatin1String("easeOutInBounce"), easeOutInBounce);
- }
-};
-Q_GLOBAL_STATIC(NameFunctionMap, nameFunctionMap);
-
-typedef GfxEasingFunction *(*ConfigurableFunction)(const GfxEasingProperties &);
-struct ConfigFunctionMap : public QHash<QString, ConfigurableFunction>
-{
- ConfigFunctionMap()
- {
- insert(QLatin1String("easeInElastic"), easeInElasticC);
- insert(QLatin1String("easeOutElastic"), easeOutElasticC);
- insert(QLatin1String("easeInBounce"), easeInBounceC);
- insert(QLatin1String("easeOutBounce"), easeOutBounceC);
- }
-};
-Q_GLOBAL_STATIC(ConfigFunctionMap, configFunctionMap);
-
-/*!
- \class GfxEasing
- \ingroup group_animation
- \brief The GfxEasing class provides easing curves for controlling animation.
-
- Easing curves describe a function that controls how a value changes over
- time. Easing curves allow transitions from one value to another to appear
- more natural than a simple linear motion would allow. The GfxEasing class
- is usually used in conjunction with the GfxTimeLine class, but can be used
- on its own.
-
- To calculate the value at a given time, the easing curve function requires
- the starting value, the final value and the total time to change from the
- starting to the final value. When using the GfxEasing class with
- GfxTimeLine, these values are supplied by the GfxTimeLine. When using
- the GfxEasing class on its own, the programmer must specify them using
- the GfxEasing::setFrom(), GfxEasing::setTo() and GfxEasing::setLength()
- methods, or by passing them explicitly to the GfxEasing::valueAt() method.
-
- For example,
- \code
- GfxEasing easing(GfxEasing::InOutQuad);
- easing.setFrom(0);
- easing.setTo(1000);
- easing.setLength(1000);
-
- for(int milliseconds = 0; milliseconds < 1000; ++milliseconds)
- qWarning() << "Value at" << milliseconds << "milliseconds is
- << easing.valueAt(milliseconds);
- \endcode
- will print the value at each millisecond for an InOutQuad transition from
- 0 to 1000 over 1 second.
-
- When using a GfxTimeLine, the values are communicated implicitly.
- \code
- GfxTimeLine timeline;
- GfxValue value(0);
-
- timeline.move(value, 1000, GfxEasing(GfxEasing::InOutQuad), 1000);
- \endcode
- In this case, any values set using the previous setter methods would be
- ignored.
- */
-
-/*!
- \qmlproperty string NumericAnimation::easing
- \brief the easing curve used for the transition.
-
- Available values are:
-
- \list
- \i \e easeNone - Easing equation function for a simple linear tweening, with no easing.
- \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
- \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
- \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
- \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
- \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
- \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
- \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
- \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
- \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
- \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
- \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
- \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
- \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
- \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
- \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \i amplitude parameter, and the period of decay by the \i period parameter.
- \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \i amplitude parameter, and the period of decay by the \i period parameter.
- \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
- \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
- \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
- \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
- \endlist
-*/
-
-/*!
- \enum GfxEasing::Curve
-
- The type of easing curve.
-
- \value None
- Easing equation function for a simple linear tweening, with no easing.
-
- \value InQuad
- Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
-
- \value OutQuad
- Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
-
- \value InOutQuad
- Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuad
- Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
-
- \value InCubic
- Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
-
- \value OutCubic
- Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
-
- \value InOutCubic
- Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInCubic
- Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
-
- \value InQuart
- Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
-
- \value OutQuart
- Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
-
- \value InOutQuart
- Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuart
- Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
-
- \value InQuint
- Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
-
- \value OutQuint
- Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
-
- \value InOutQuint
- Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuint
- Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
-
- \value InSine
- Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
-
- \value OutSine
- Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
-
- \value InOutSine
- Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInSine
- Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
-
- \value InExpo
- Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
-
- \value OutExpo
- Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
-
- \value InOutExpo
- Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInExpo
- Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
-
- \value InCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
-
- \value OutCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
-
- \value InOutCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
-
- \value InElastic
- Easing equation function for an elastic (exponentially decaying
- sine wave) easing in: accelerating from zero velocity. The peak
- amplitude can be set with the \e amplitude parameter, and the
- period of decay by the \e period parameter.
-
- \value OutElastic
- Easing equation function for an elastic (exponentially decaying
- sine wave) easing out: decelerating from zero velocity. The peak
- amplitude can be set with the \e amplitude parameter, and the
- period of decay by the \e period parameter.
-
- \value InOutElastic
- Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInElastic
- Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
-
- \value InBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
-
- \value OutBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
-
- \value InOutBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
-
- \value OutBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
-
- \value InBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
-
- \value InOutBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
-*/
-
-/*!
- Construct a linear easing object. This is equivalent to \c {GfxEasing(GfxEasing::None)}.
- */
-GfxEasing::GfxEasing()
-: _config(0), _func(&easeNone), _b(0.), _c(1.), _d(1.)
-{
-}
-
-/*!
- Construct an easing object with the given \a curve.
- */
-GfxEasing::GfxEasing(Curve curve)
-: _config(0), _func(0), _b(0.), _c(1.), _d(1.)
-{
- _func = curveToFunc(curve);
- if(!_func) {
- qWarning("GfxEasing: Invalid curve type %d", curve);
- _func = &easeNone;
- }
-}
-
-/*!
- Construct an easing object with the given \a curve. If \a curve does not
- describe a legal curve, a linear easing object is constructed.
-
- Curve names have the form
- \c {ease<CurveName>[(<arg>: <arg value>[, <arg2>: <arg value>])]}. The
- \e CurveName is equivalent to the GfxEasing::Curve enum name. Some more
- advanced curves can take arguments to further refine their behaviour. Where
- applicable, these parameters are described in the corresponding
- GfxEasing::Curve value documentation.
-
- For example,
- \code
- GfxEasing easing("easeInOutQuad");
- GfxEasing easing2("easeInElastic(period: 5, amplitude: 100)");
- \endcode
- */
-GfxEasing::GfxEasing(const QString &curve)
-: _config(0), _func(&easeNone), _b(0.), _c(1.), _d(1.)
-{
- if(curve.contains(QLatin1Char('('))) {
- QString easeName = curve.trimmed();
- GfxEasingProperties prop;
- if(!easeName.endsWith(QLatin1Char(')'))) {
- qWarning("GfxEasing: Unmatched perenthesis in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- int idx = easeName.indexOf(QLatin1Char('('));
- QString prop_str =
- easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
- easeName = easeName.left(idx);
-
- QStringList props = prop_str.split(QLatin1Char(','));
- foreach(QString str, props) {
- int sep = str.indexOf(QLatin1Char(':'));
-
- if(sep == -1) {
- qWarning("GfxEasing: Improperly specified property in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- QString propName = str.left(sep).trimmed();
- bool isOk;
- qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk);
-
- if(propName.isEmpty() || !isOk) {
- qWarning("GfxEasing: Improperly specified property in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- prop.insert(propName, propValue);
- }
-
- QHash<QString, ConfigurableFunction>::Iterator iter =
- configFunctionMap()->find(easeName);
-
- if(iter != configFunctionMap()->end())
- _config = (*iter)(prop);
- } else {
- if(nameFunctionMap()->contains(curve))
- _func = *(nameFunctionMap()->find(curve));
- }
-
- if(!_func && !_config) {
- qWarning("GfxEasing: Unknown easing curve '%s'",
- curve.toLatin1().constData());
- _func = &easeNone;
- }
-}
-
-/*!
- Construct a copy of \a other.
- */
-GfxEasing::GfxEasing(const GfxEasing &other)
-: _config(0), _func(other._func), _b(other._b), _c(other._c), _d(other._d)
-{
- if(other._config) _config = other._config->copy();
-}
-
-/*!
- Copy \a other.
- */
-GfxEasing &GfxEasing::operator=(const GfxEasing &other)
-{
- if(_config) { delete _config; _config = 0; }
- if(other._config) _config = other._config->copy();
-
- _func = other._func;
- _b = other._b;
- _c = other._c;
- _d = other._d;
-
- return *this;
-}
-
-/*!
- Returns true if this is a linear easing object.
- */
-bool GfxEasing::isLinear() const
-{
- return !_config && _func == &easeNone;
-}
-
-/*!
- Return the starting value for the easing curve. By default this is 0.
- */
-qreal GfxEasing::from() const
-{
- return _b;
-}
-
-/*!
- Set the starting value for the easing curve to \a from.
- */
-void GfxEasing::setFrom(qreal from)
-{
- _b = from;
-}
-
-/*!
- Return the final value for the easing curve. By default this is 0.
- */
-qreal GfxEasing::to() const
-{
- return _c;
-}
-
-/*!
- Set the final value for the easing curve to \a to.
- */
-void GfxEasing::setTo(qreal to)
-{
- _c = to;
-}
-
-/*!
- Return the length of the easing curve, in milliseconds. By default this
- is 1.
- */
-qreal GfxEasing::length() const
-{
- return _d;
-}
-
-/*!
- Set the \a length of the easing curve, in milliseconds.
- */
-void GfxEasing::setLength(qreal length)
-{
- Q_ASSERT(length > 0);
- _d = length;
-}
-
-/*!
- Return the value for the easing curve at time \a t milliseconds, based on
- the parameters returned by GfxEasing::from(), GfxEasing::to() and
- GfxEasing::length().
-
- \a t is clamped to (0, GfxEasing::length()).
- */
-qreal GfxEasing::valueAt(qreal t) const
-{
- if(t < 0) t = 0;
- else if(t > length()) t = length();
-
- if(_config)
- return _config->value(t, _b, _c - _b, _d);
- else
- return _func(t, _b, _c - _b, _d);
-}
-
-/*
- Return the value for the easing curve at time \a t milliseconds, based on
- the provided parameters \a from, \a to and \a length. The values returned
- from the object's GfxEasing::from(), GfxEasing::to() and GfxEasing::length()
- methods are ignored.
-
- \a t is clamped to (0, \a length).
- */
-qreal GfxEasing::valueAt(qreal t, qreal from, qreal to, qreal length) const
-{
- if(t < 0) t = 0;
- else if(t > length) t = length;
-
- if(_config)
- return _config->value(t, from, to - from, length);
- else
- return _func(t, from, to - from, length);
-}
-
-/*!
- \internal
- */
-QStringList GfxEasing::curves()
-{
- return nameFunctionMap()->keys();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/timeline/gfxeasing.h b/src/declarative/timeline/gfxeasing.h
deleted file mode 100644
index c15aadc..0000000
--- a/src/declarative/timeline/gfxeasing.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used 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. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GFXEASING_H
-#define GFXEASING_H
-
-#include <qfxglobal.h>
-#include <QList>
-#include <QPair>
-#include <QWidget>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class GfxEasingFunction;
-class Q_DECLARATIVE_EXPORT GfxEasing
-{
-public:
- enum Curve {
- None,
- InQuad, OutQuad, InOutQuad, OutInQuad,
- InCubic, OutCubic, InOutCubic, OutInCubic,
- InQuart, OutQuart, InOutQuart, OutInQuart,
- InQuint, OutQuint, InOutQuint, OutInQuint,
- InSine, OutSine, InOutSine, OutInSine,
- InExpo, OutExpo, InOutExpo, OutInExpo,
- InCirc, OutCirc, InOutCirc, OutInCirc,
- InElastic, OutElastic, InOutElastic, OutInElastic,
- InBack, OutBack, InOutBack, OutInBack,
- InBounce, OutBounce, InOutBounce, OutInBounce
- };
-
- GfxEasing();
- GfxEasing(Curve);
- GfxEasing(const QString &);
- GfxEasing(const GfxEasing &);
- GfxEasing &operator=(const GfxEasing &);
-
- bool isLinear() const;
-
- qreal from() const;
- void setFrom(qreal);
- qreal to() const;
- void setTo(qreal);
- qreal length() const;
- void setLength(qreal);
-
- qreal valueAt(qreal t) const;
- qreal valueAt(qreal t, qreal from, qreal to, qreal length) const;
-
- static QStringList curves();
-
- typedef float (*Function)(float t, float b, float c, float d);
-private:
- GfxEasingFunction *_config;
- Function _func;
-
- qreal _b, _c, _d;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/timeline/gfxtimeline.cpp b/src/declarative/timeline/qmltimeline.cpp
index 3e84df8..fc901eb 100644
--- a/src/declarative/timeline/gfxtimeline.cpp
+++ b/src/declarative/timeline/qmltimeline.cpp
@@ -39,33 +39,31 @@
**
****************************************************************************/
-#include "gfxtimeline.h"
+#include "qmltimeline.h"
#include <QDebug>
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include <QEvent>
#include <QCoreApplication>
-#include "gfxeasing.h"
+#include <QEasingCurve>
#include <QTime>
QT_BEGIN_NAMESPACE
-#define TIMETICK 5
-
//
// Timeline stuff
//
struct Update {
- Update(GfxValue *_g, qreal _v)
+ Update(QmlTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
- Update(const GfxEvent &_e)
+ Update(const QmlTimeLineEvent &_e)
: g(0), v(0), e(_e) {}
- GfxValue *g;
+ QmlTimeLineValue *g;
qreal v;
- GfxEvent e;
+ QmlTimeLineEvent e;
};
struct QmlTimeLinePrivate
@@ -84,7 +82,7 @@ struct QmlTimeLinePrivate
};
Op() {}
Op(Type t, int l, qreal v, qreal v2, int o,
- const GfxEvent &ev = GfxEvent(), const GfxEasing &es = GfxEasing())
+ const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
Op(const Op &o)
@@ -103,8 +101,8 @@ struct QmlTimeLinePrivate
qreal value2;
int order;
- GfxEvent event;
- GfxEasing easing;
+ QmlTimeLineEvent event;
+ QEasingCurve easing;
};
struct TimeLine
{
@@ -144,7 +142,7 @@ QmlTimeLinePrivate::QmlTimeLinePrivate(QmlTimeLine *parent)
void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o)
{
if(g._t && g._t != q) {
- qWarning() << "QmlTimeLine: Cannot modify a GfxValue owned by"
+ qWarning() << "QmlTimeLine: Cannot modify a QmlTimeLineValue owned by"
<< "another timeline.";
return;
}
@@ -208,13 +206,12 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
} else if(time == (op.length)) {
return op.value;
} else {
- if(op.easing.isLinear()) {
- qreal delta = op.value - base;
- qreal pTime = (qreal)(time) / (qreal)op.length;
+ qreal delta = op.value - base;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if(op.easing.type() == QEasingCurve::Linear)
return base + delta * pTime;
- } else {
- return op.easing.valueAt(time, base, op.value, op.length);
- }
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
}
case Op::MoveBy:
if(time == 0) {
@@ -222,13 +219,12 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
} else if(time == (op.length)) {
return base + op.value;
} else {
- if(op.easing.isLinear()) {
- qreal delta = op.value;
- qreal pTime = (qreal)(time) / (qreal)op.length;
+ qreal delta = op.value;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if(op.easing.type() == QEasingCurve::Linear)
return base + delta * pTime;
- } else {
- return op.easing.valueAt(time, base, base + op.value, op.length);
- }
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
}
case Op::Accel:
if(time == 0) {
@@ -260,28 +256,29 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
}
/*!
+ \internal
\class QmlTimeLine
\ingroup group_animation
\brief The QmlTimeLine class provides a timeline for controlling animations.
QmlTimeLine is similar to QTimeLine except:
\list
- \i It updates GfxValue instances directly, rather than maintaining a single
+ \i It updates QmlTimeLineValue instances directly, rather than maintaining a single
current value.
For example, the following animates a simple value over 200 milliseconds:
\code
- GfxValue v(<starting value>);
+ QmlTimeLineValue v(<starting value>);
QmlTimeLine tl;
tl.move(v, 100., 200);
tl.start()
\endcode
If your program needs to know when values are changed, it can either
- connect to the QmlTimeLine's updated() signal, or inherit from GfxValue
- and reimplement the GfxValue::setValue() method.
+ connect to the QmlTimeLine's updated() signal, or inherit from QmlTimeLineValue
+ and reimplement the QmlTimeLineValue::setValue() method.
- \i Supports multiple GfxValue, arbitrary start and end values and allows
+ \i Supports multiple QmlTimeLineValue, arbitrary start and end values and allows
animations to be strung together for more complex effects.
For example, the following animation moves the x and y coordinates of
@@ -290,8 +287,8 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
milliseconds:
\code
- GfxValue x(<starting value>);
- GfxValue y(<starting value>);
+ QmlTimeLineValue x(<starting value>);
+ QmlTimeLineValue y(<starting value>);
QmlTimeLine tl;
tl.start();
@@ -358,7 +355,7 @@ void QmlTimeLine::setSyncMode(SyncMode syncMode)
}
/*!
- Pause \a gfxValue for \a time milliseconds.
+ Pause \a obj for \a time milliseconds.
*/
void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
{
@@ -370,28 +367,28 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
/*!
Execute the \a event.
*/
-void QmlTimeLine::execute(const GfxEvent &event)
+void QmlTimeLine::execute(const QmlTimeLineEvent &event)
{
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
d->add(*event.eventObject(), op);
}
/*!
- Set the \a value of \a gfxValue.
+ Set the \a value of \a timeLineValue.
*/
-void QmlTimeLine::set(GfxValue &gfxValue, qreal value)
+void QmlTimeLine::set(QmlTimeLineValue &timeLineValue, qreal value)
{
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Decelerate \a gfxValue from the starting \a velocity to zero at the
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
given \a acceleration rate. Although the \a acceleration is technically
a deceleration, it should always be positive. The QmlTimeLine will ensure
that the deceleration is in the opposite direction to the initial velocity.
*/
-int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
{
if((velocity > 0.0f) == (acceleration > 0.0f))
acceleration = acceleration * -1.0f;
@@ -399,7 +396,7 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
int time = static_cast<int>(-1000 * velocity / acceleration);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
@@ -407,14 +404,14 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
/*!
\overload
- Decelerate \a gfxValue from the starting \a velocity to zero at the
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
given \a acceleration rate over a maximum distance of maxDistance.
If necessary, QmlTimeLine will reduce the acceleration to ensure that the
entire operation does not require a move of more than \a maxDistance.
\a maxDistance should always be positive.
*/
-int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration, qreal maxDistance)
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
{
Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f);
@@ -428,19 +425,19 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration, q
int time = static_cast<int>(-1000 * velocity / acceleration);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
/*!
- Decelerate \a gfxValue from the starting \a velocity to zero over the given
+ Decelerate \a timeLineValue from the starting \a velocity to zero over the given
\a distance. This is like accel(), but the QmlTimeLine calculates the exact
deceleration to use.
\a distance should be positive.
*/
-int QmlTimeLine::accelDistance(GfxValue &gfxValue, qreal velocity, qreal distance)
+int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, qreal distance)
{
if (distance == 0.0f || velocity == 0.0f)
return -1;
@@ -449,68 +446,68 @@ int QmlTimeLine::accelDistance(GfxValue &gfxValue, qreal velocity, qreal distanc
int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
/*!
- Linearly change the \a gfxValue from its current value to the given
+ Linearly change the \a timeLineValue from its current value to the given
\a destination value over \a time milliseconds.
*/
-void QmlTimeLine::move(GfxValue &gfxValue, qreal destination, int time)
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int time)
{
if(time <= 0) return;
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Change the \a gfxValue from its current value to the given \a destination
+ Change the \a timeLineValue from its current value to the given \a destination
value over \a time milliseconds using the \a easing curve.
*/
-void QmlTimeLine::move(GfxValue &gfxValue, qreal destination, const GfxEasing &easing, int time)
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
{
if(time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, GfxEvent(), easing);
- d->add(gfxValue, op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
}
/*!
- Linearly change the \a gfxValue from its current value by the \a change amount
+ Linearly change the \a timeLineValue from its current value by the \a change amount
over \a time milliseconds.
*/
-void QmlTimeLine::moveBy(GfxValue &gfxValue, qreal change, int time)
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time)
{
if(time <= 0) return;
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Change the \a gfxValue from its current value by the \a change amount over
+ Change the \a timeLineValue from its current value by the \a change amount over
\a time milliseconds using the \a easing curve.
*/
-void QmlTimeLine::moveBy(GfxValue &gfxValue, qreal change, const GfxEasing &easing, int time)
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
{
if(time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, GfxEvent(), easing);
- d->add(gfxValue, op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
}
/*!
- Cancel (but don't complete) all scheduled actions for \a gfxValue.
+ Cancel (but don't complete) all scheduled actions for \a timeLineValue.
*/
-void QmlTimeLine::reset(GfxValue &gfxValue)
+void QmlTimeLine::reset(QmlTimeLineValue &timeLineValue)
{
- if(!gfxValue._t)
+ if(!timeLineValue._t)
return;
- if(gfxValue._t != this) {
- qWarning() << "QmlTimeLine: Cannot reset a GfxValue owned by another timeline.";
+ if(timeLineValue._t != this) {
+ qWarning() << "QmlTimeLine: Cannot reset a QmlTimeLineValue owned by another timeline.";
return;
}
- remove(&gfxValue);
- gfxValue._t = 0;
+ remove(&timeLineValue);
+ timeLineValue._t = 0;
}
int QmlTimeLine::duration() const
@@ -519,48 +516,48 @@ int QmlTimeLine::duration() const
}
/*!
- Synchronize the end point of \a gfxValue to the endpoint of \a syncTo
+ Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
within this timeline.
- Following operations on \a gfxValue in this timeline will be scheduled after
+ Following operations on \a timeLineValue in this timeline will be scheduled after
all the currently scheduled actions on \a syncTo are complete. In
psuedo-code this is equivalent to:
\code
- QmlTimeLine::pause(gfxValue, min(0, length_of(syncTo) - length_of(gfxValue)))
+ QmlTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
\endcode
*/
-void QmlTimeLine::sync(GfxValue &gfxValue, GfxValue &syncTo)
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo)
{
QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
if(iter == d->ops.end())
return;
int length = iter->length;
- iter = d->ops.find(&gfxValue);
+ iter = d->ops.find(&timeLineValue);
if(iter == d->ops.end()) {
- pause(gfxValue, length);
+ pause(timeLineValue, length);
} else {
int glength = iter->length;
- pause(gfxValue, length - glength);
+ pause(timeLineValue, length - glength);
}
}
/*!
- Synchronize the end point of \a gfxValue to the endpoint of the longest
- action currently scheduled in the timeline.
+ Synchronize the end point of \a timeLineValue to the endpoint of the longest
+ action cursrently scheduled in the timeline.
In psuedo-code, this is equivalent to:
\code
- QmlTimeLine::pause(gfxValue, length_of(timeline) - length_of(gfxValue))
+ QmlTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
\endcode
*/
-void QmlTimeLine::sync(GfxValue &gfxValue)
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue)
{
- QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&gfxValue);
+ QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
if(iter == d->ops.end()) {
- pause(gfxValue, d->length);
+ pause(timeLineValue, d->length);
} else {
- pause(gfxValue, d->length - iter->length);
+ pause(timeLineValue, d->length - iter->length);
}
}
@@ -623,7 +620,7 @@ int QmlTimeLine::syncPoint() const
/*!
Returns true if the timeline is active. An active timeline is one where
- GfxValue actions are still pending.
+ QmlTimeLineValue actions are still pending.
*/
bool QmlTimeLine::isActive() const
{
@@ -633,7 +630,7 @@ bool QmlTimeLine::isActive() const
/*!
Completes the timeline. All queued actions are played to completion, and then discarded. For example,
\code
- GfxValue v(0.);
+ QmlTimeLineValue v(0.);
QmlTimeLine tl;
tl.move(v, 100., 1000.);
// 500 ms passes
@@ -648,9 +645,9 @@ void QmlTimeLine::complete()
}
/*!
- Resets the timeline. All queued actions are discarded and GfxValue's retain their current value. For example,
+ Resets the timeline. All queued actions are discarded and QmlTimeLineValue's retain their current value. For example,
\code
- GfxValue v(0.);
+ QmlTimeLineValue v(0.);
QmlTimeLine tl;
tl.move(v, 100., 1000.);
// 500 ms passes
@@ -677,8 +674,8 @@ int QmlTimeLine::time() const
/*!
\fn void QmlTimeLine::updated()
- Emitted each time the timeline modifies GfxValues. Even if multiple
- GfxValues are changed, this signal is only emitted once for each clock tick.
+ Emitted each time the timeline modifies QmlTimeLineValues. Even if multiple
+ QmlTimeLineValues are changed, this signal is only emitted once for each clock tick.
*/
void QmlTimeLine::updateCurrentTime(int v)
@@ -750,7 +747,7 @@ int QmlTimeLinePrivate::advance(int t)
QList<QPair<int, Update> > updates;
for(Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
- GfxValue *v = static_cast<GfxValue *>(iter.key());
+ QmlTimeLineValue *v = static_cast<QmlTimeLineValue *>(iter.key());
TimeLine &tl = *iter;
Q_ASSERT(!tl.ops.isEmpty());
@@ -871,31 +868,31 @@ void QmlTimeLine::remove(QmlTimeLineObject *v)
}
/*!
- \class GfxValue
+ \class QmlTimeLineValue
\ingroup group_animation
- \brief The GfxValue class is modified by QmlTimeLine.
+ \brief The QmlTimeLineValue class is modified by QmlTimeLine.
*/
/*!
- \fn GfxValue::GfxValue(qreal value = 0)
+ \fn QmlTimeLineValue::QmlTimeLineValue(qreal value = 0)
- Construct a new GfxValue with an initial \a value.
+ Construct a new QmlTimeLineValue with an initial \a value.
*/
/*!
- \fn qreal GfxValue::value() const
+ \fn qreal QmlTimeLineValue::value() const
Return the current value.
*/
/*!
- \fn void GfxValue::setValue(qreal value)
+ \fn void QmlTimeLineValue::setValue(qreal value)
Set the current \a value.
*/
/*!
- \fn QmlTimeLine *GfxValue::timeLine() const
+ \fn QmlTimeLine *QmlTimeLineValue::timeLine() const
If a QmlTimeLine is operating on this value, return a pointer to it,
otherwise return null.
@@ -915,17 +912,17 @@ QmlTimeLineObject::~QmlTimeLineObject()
}
}
-GfxEvent::GfxEvent()
+QmlTimeLineEvent::QmlTimeLineEvent()
: d0(0), d1(0), d2(0)
{
}
-GfxEvent::GfxEvent(const GfxEvent &o)
+QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
: d0(o.d0), d1(o.d1), d2(o.d2)
{
}
-GfxEvent &GfxEvent::operator=(const GfxEvent &o)
+QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
{
d0 = o.d0;
d1 = o.d1;
@@ -933,12 +930,12 @@ GfxEvent &GfxEvent::operator=(const GfxEvent &o)
return *this;
}
-void GfxEvent::execute() const
+void QmlTimeLineEvent::execute() const
{
d0(d1);
}
-QmlTimeLineObject *GfxEvent::eventObject() const
+QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
{
return d2;
}
diff --git a/src/declarative/timeline/gfxtimeline.h b/src/declarative/timeline/qmltimeline.h
index 0bdddaf..ce9d1f2 100644
--- a/src/declarative/timeline/gfxtimeline.h
+++ b/src/declarative/timeline/qmltimeline.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef GFXTIMELINE_H
-#define GFXTIMELINE_H
+#ifndef QMLTIMELINE_H
+#define QMLTIMELINE_H
#include <QObject>
#include <qfxglobal.h>
@@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class GfxEasing;
-class GfxValue;
-class GfxEvent;
+class QEasingCurve;
+class QmlTimeLineValue;
+class QmlTimeLineEvent;
struct QmlTimeLinePrivate;
class QmlTimeLineObject;
class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
@@ -69,26 +69,26 @@ public:
void setSyncMode(SyncMode);
void pause(QmlTimeLineObject &, int);
- void execute(const GfxEvent &);
- void set(GfxValue &, qreal);
+ void execute(const QmlTimeLineEvent &);
+ void set(QmlTimeLineValue &, qreal);
- int accel(GfxValue &, qreal velocity, qreal accel);
- int accel(GfxValue &, qreal velocity, qreal accel, qreal maxDistance);
- int accelDistance(GfxValue &, qreal velocity, qreal distance);
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
+ int accelDistance(QmlTimeLineValue &, qreal velocity, qreal distance);
- void move(GfxValue &, qreal destination, int time = 500);
- void move(GfxValue &, qreal destination, const GfxEasing &, int time = 500);
- void moveBy(GfxValue &, qreal change, int time = 500);
- void moveBy(GfxValue &, qreal change, const GfxEasing &, int time = 500);
+ void move(QmlTimeLineValue &, qreal destination, int time = 500);
+ void move(QmlTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
void sync();
void setSyncPoint(int);
int syncPoint() const;
- void sync(GfxValue &);
- void sync(GfxValue &, GfxValue &);
+ void sync(QmlTimeLineValue &);
+ void sync(QmlTimeLineValue &, QmlTimeLineValue &);
- void reset(GfxValue &);
+ void reset(QmlTimeLineValue &);
void complete();
void clear();
@@ -123,10 +123,10 @@ protected:
QmlTimeLine *_t;
};
-class Q_DECLARATIVE_EXPORT GfxValue : public QmlTimeLineObject
+class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
{
public:
- GfxValue(qreal v = 0.) : _v(v) {}
+ QmlTimeLineValue(qreal v = 0.) : _v(v) {}
qreal value() const { return _v; }
virtual void setValue(qreal v) { _v = v; }
@@ -134,21 +134,21 @@ public:
QmlTimeLine *timeLine() const { return _t; }
operator qreal() const { return _v; }
- GfxValue &operator=(qreal v) { setValue(v); return *this; }
+ QmlTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
private:
friend class QmlTimeLine;
friend struct QmlTimeLinePrivate;
qreal _v;
};
-class Q_DECLARATIVE_EXPORT GfxEvent
+class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
{
public:
- GfxEvent();
- GfxEvent(const GfxEvent &o);
+ QmlTimeLineEvent();
+ QmlTimeLineEvent(const QmlTimeLineEvent &o);
template<class T, void (T::*method)()>
- GfxEvent(QmlTimeLineObject *b, T *c)
+ QmlTimeLineEvent(QmlTimeLineObject *b, T *c)
{
d0 = &callFunc<T, method>;
d1 = (void *)c;
@@ -156,16 +156,16 @@ public:
}
template<class T, void (T::*method)()>
- static GfxEvent gfxEvent(QmlTimeLineObject *b, T *c)
+ static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
{
- GfxEvent rv;
+ QmlTimeLineEvent rv;
rv.d0 = &callFunc<T, method>;
rv.d1 = (void *)c;
rv.d2 = b;
return rv;
}
- GfxEvent &operator=(const GfxEvent &o);
+ QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
void execute() const;
QmlTimeLineObject *eventObject() const;
diff --git a/src/declarative/timeline/gfxvalueproxy.h b/src/declarative/timeline/qmltimelinevalueproxy.h
index 1eaf44e..add45dd 100644
--- a/src/declarative/timeline/gfxvalueproxy.h
+++ b/src/declarative/timeline/qmltimelinevalueproxy.h
@@ -39,8 +39,11 @@
**
****************************************************************************/
-#ifndef GFXVALUEPROXY_H
-#define GFXVALUEPROXY_H
+#ifndef QMLTIMELINEVALUEPROXY_H
+#define QMLTIMELINEVALUEPROXY_H
+
+#include "qmltimeline.h"
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -48,24 +51,24 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
template<class T>
-class GfxValueProxy : public GfxValue
+class QmlTimeLineValueProxy : public QmlTimeLineValue
{
public:
- GfxValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : GfxValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
{
Q_ASSERT(_class);
}
- GfxValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
- : GfxValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
{
Q_ASSERT(_class);
}
virtual void setValue(qreal v)
{
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
if(_setFunctionReal) (_class->*_setFunctionReal)(v);
else if(_setFunctionInt) (_class->*_setFunctionInt)((int)v);
}
@@ -80,4 +83,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif//GFXVALUEPROXY
+#endif//QMLTIMELINEVALUEPROXY_H
diff --git a/src/declarative/timeline/timeline.pri b/src/declarative/timeline/timeline.pri
index 8994c78..a7b3cb9 100644
--- a/src/declarative/timeline/timeline.pri
+++ b/src/declarative/timeline/timeline.pri
@@ -1,9 +1,7 @@
SOURCES += \
- timeline/gfxeasing.cpp \
- timeline/gfxtimeline.cpp \
+ timeline/qmltimeline.cpp \
HEADERS += \
- timeline/gfxeasing.h \
- timeline/gfxtimeline.h \
- timeline/gfxvalueproxy.h \
+ timeline/qmltimeline.h \
+ timeline/qmltimelinevalueproxy.h \
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index ede4008..91a5361 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -40,19 +40,19 @@
****************************************************************************/
#include "qmlanimation.h"
-#include "gfxtimeline.h"
#include "qvariant.h"
#include "qcolor.h"
#include "qfile.h"
-#include "gfxeasing.h"
#include "qmlpropertyvaluesource.h"
#include "qml.h"
#include "qmlanimation_p.h"
-#include "gfxtimeline.h"
#include "qmlbehaviour.h"
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
#include <QtCore/qset.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
#include <QtDeclarative/qmlexpression.h>
#include <private/qmlstringconverters_p.h>
#include <private/qvariantanimation_p.h>
@@ -653,7 +653,7 @@ QmlColorAnimation::~QmlColorAnimation()
void QmlColorAnimationPrivate::init()
{
Q_Q(QmlColorAnimation);
- ca = new GfxValueAnimator(q);
+ ca = new QmlTimeLineValueAnimator(q);
ca->setStartValue(QVariant(0.0f));
ca->setEndValue(QVariant(1.0f));
}
@@ -791,7 +791,7 @@ void QmlColorAnimation::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
d->fromSourced = false;
- d->value.GfxValue::setValue(0.);
+ d->value.QmlTimeLineValue::setValue(0.);
d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
}
@@ -808,7 +808,7 @@ void QmlColorAnimation::transition(QmlStateActions &actions,
Q_D(QmlColorAnimation);
Q_UNUSED(direction);
- struct NTransitionData : public GfxValue
+ struct NTransitionData : public QmlTimeLineValue
{
QmlStateActions actions;
void write(QmlMetaProperty &property, const QColor &color)
@@ -820,7 +820,7 @@ void QmlColorAnimation::transition(QmlStateActions &actions,
void setValue(qreal v)
{
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
for(int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
@@ -1004,7 +1004,7 @@ void QmlRunScriptActionPrivate::execute()
}
if(!scriptStr.isEmpty()) {
- QmlExpression expr(ctxt, scriptStr, q);
+ QmlExpression expr(qmlContext(q), scriptStr, q);
expr.setTrackChange(false);
expr.value();
}
@@ -1362,7 +1362,7 @@ QmlNumericAnimation::~QmlNumericAnimation()
void QmlNumericAnimationPrivate::init()
{
Q_Q(QmlNumericAnimation);
- na = new GfxValueAnimator(q);
+ na = new QmlTimeLineValueAnimator(q);
na->setStartValue(QVariant(0.0f));
na->setEndValue(QVariant(1.0f));
}
@@ -1447,7 +1447,57 @@ void QmlNumericAnimation::setTo(qreal t)
emit toChanged(t);
}
-/* XML docs in GfxEasing */
+/*!
+ \qmlproperty string NumericAnimation::easing
+ \brief the easing curve used for the transition.
+
+ Available values are:
+
+ \list
+ \i \e easeNone - Easing equation function for a simple linear tweening, with no easing.
+ \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
+ \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
+ \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
+ \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
+ \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
+ \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
+ \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
+ \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
+ \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
+ \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
+ \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
+ \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
+ \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
+ \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
+ \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
+ \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
+ \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
+ \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
+ \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
+ \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
+ \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
+ \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
+ \endlist
+*/
+
/*!
\property QmlNumericAnimation::easing
This property holds the easing curve to use.
@@ -1550,7 +1600,7 @@ void QmlNumericAnimation::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
d->fromSourced = false;
- d->value.GfxValue::setValue(0.);
+ d->value.QmlTimeLineValue::setValue(0.);
d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
}
@@ -1567,12 +1617,12 @@ void QmlNumericAnimation::transition(QmlStateActions &actions,
Q_D(QmlNumericAnimation);
Q_UNUSED(direction);
- struct NTransitionData : public GfxValue
+ struct NTransitionData : public QmlTimeLineValue
{
QmlStateActions actions;
void setValue(qreal v)
{
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
for(int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
@@ -1901,7 +1951,7 @@ QmlVariantAnimation::~QmlVariantAnimation()
void QmlVariantAnimationPrivate::init()
{
Q_Q(QmlVariantAnimation);
- va = new GfxValueAnimator(q);
+ va = new QmlTimeLineValueAnimator(q);
va->setStartValue(QVariant(0.0f));
va->setEndValue(QVariant(1.0f));
}
@@ -2107,7 +2157,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p)
d->convertVariant(d->from.value, (QVariant::Type)d->property.propertyType());
d->fromSourced = false;
- d->value.GfxValue::setValue(0.);
+ d->value.QmlTimeLineValue::setValue(0.);
d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
}
@@ -2118,12 +2168,12 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
Q_D(QmlVariantAnimation);
Q_UNUSED(direction);
- struct NTransitionData : public GfxValue
+ struct NTransitionData : public QmlTimeLineValue
{
QmlStateActions actions;
void setValue(qreal v)
{
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
for(int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index db7cb18..80cc7f7 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -52,7 +52,7 @@
#include <QVariantAnimation>
#include <QAnimationGroup>
#include <QColor>
-#include <gfxvalueproxy.h>
+#include <qmltimelinevalueproxy.h>
QT_BEGIN_NAMESPACE
@@ -112,13 +112,13 @@ private:
DeletionPolicy policy;
};
-//animates GfxValue (assumes start and end values will be reals or compatible)
-class GfxValueAnimator : public QVariantAnimation
+//animates QmlTimeLineValue (assumes start and end values will be reals or compatible)
+class QmlTimeLineValueAnimator : public QVariantAnimation
{
public:
- GfxValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {}
- GfxValueAnimator(GfxValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {}
- void setAnimValue(GfxValue *value, DeletionPolicy p)
+ QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {}
+ QmlTimeLineValueAnimator(QmlTimeLineValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {}
+ void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p)
{
if (state() == Running)
stop();
@@ -141,7 +141,7 @@ protected:
}
private:
- GfxValue *animValue;
+ QmlTimeLineValue *animValue;
DeletionPolicy policy;
};
@@ -214,10 +214,10 @@ public:
bool fromSourced;
QColor fromValue;
QColor toValue;
- GfxValueAnimator *ca;
+ QmlTimeLineValueAnimator *ca;
virtual void valueChanged(qreal);
- GfxValueProxy<QmlColorAnimationPrivate> value;
+ QmlTimeLineValueProxy<QmlColorAnimationPrivate> value;
};
class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate
@@ -225,13 +225,12 @@ class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlRunScriptAction);
public:
QmlRunScriptActionPrivate()
- : QmlAbstractAnimationPrivate(), ctxt(QmlContext::activeContext()), proxy(this), rsa(0) {}
+ : QmlAbstractAnimationPrivate(), proxy(this), rsa(0) {}
void init();
QString script;
QString file;
- QmlContext* ctxt;
void execute();
@@ -295,10 +294,10 @@ public:
bool fromSourced;
qreal fromValue;
- GfxValueAnimator *na;
+ QmlTimeLineValueAnimator *na;
virtual void valueChanged(qreal);
- GfxValueProxy<QmlNumericAnimationPrivate> value;
+ QmlTimeLineValueProxy<QmlNumericAnimationPrivate> value;
};
class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate
@@ -360,10 +359,10 @@ public:
bool fromSourced;
QVariant fromValue;
- GfxValueAnimator *va;
+ QmlTimeLineValueAnimator *va;
virtual void valueChanged(qreal);
- GfxValueProxy<QmlVariantAnimationPrivate> value;
+ QmlTimeLineValueProxy<QmlVariantAnimationPrivate> value;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
static void convertVariant(QVariant &variant, QVariant::Type type);
diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/util/qmlbehaviour.cpp
index 3169f63..3fff06c 100644
--- a/src/declarative/util/qmlbehaviour.cpp
+++ b/src/declarative/util/qmlbehaviour.cpp
@@ -76,14 +76,13 @@ class QmlBehaviourPrivate : public QObjectPrivate
{
public:
QmlBehaviourPrivate()
- : context(0), oldContext(0), valueData(0), operations(this) {}
+ : context(0), valueData(0), operations(this) {}
QmlMetaProperty property;
QVariant currentValue;
QVariant fromValue;
QVariant toValue;
QmlContext *context;
- QmlContext *oldContext;
QmlBehaviourData *valueData;
class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
{
@@ -123,8 +122,6 @@ QmlBehaviour::QmlBehaviour(QObject *parent)
{
Q_D(QmlBehaviour);
d->valueData = new QmlBehaviourData(this);
- d->context = new QmlContext(QmlContext::activeContext(), this);
- d->context->addDefaultObject(d->valueData);
d->group = new QSequentialAnimationGroup(this);
}
@@ -234,6 +231,10 @@ void QmlBehaviour::setTarget(const QmlMetaProperty &property)
void QmlBehaviour::classBegin()
{
Q_D(QmlBehaviour);
+ if(!d->context) {
+ d->context = new QmlContext(qmlContext(this), this);
+ d->context->addDefaultObject(d->valueData);
+ }
d->context->activate();
}
diff --git a/src/declarative/util/qmlbehaviour.h b/src/declarative/util/qmlbehaviour.h
index 080423a..3d25cd8 100644
--- a/src/declarative/util/qmlbehaviour.h
+++ b/src/declarative/util/qmlbehaviour.h
@@ -45,8 +45,6 @@
#include <qmlpropertyvaluesource.h>
#include <qml.h>
#include <qmlstate.h>
-#include <gfxtimeline.h>
-
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp
index df45a31..b2fd450 100644
--- a/src/declarative/util/qmlconnection.cpp
+++ b/src/declarative/util/qmlconnection.cpp
@@ -51,9 +51,8 @@ QT_BEGIN_NAMESPACE
class QmlConnectionPrivate : public QObjectPrivate
{
public:
- QmlConnectionPrivate() : ctxt(0), boundsignal(0), signalSender(0), componentcomplete(false) {}
+ QmlConnectionPrivate() : boundsignal(0), signalSender(0), componentcomplete(false) {}
- QmlContext *ctxt;
QmlBoundSignal *boundsignal;
QObject *signalSender;
QString script;
@@ -112,8 +111,6 @@ public:
QmlConnection::QmlConnection(QObject *parent) :
QObject(*(new QmlConnectionPrivate), parent)
{
- Q_D(QmlConnection);
- d->ctxt = QmlContext::activeContext();
}
QmlConnection::~QmlConnection()
@@ -192,9 +189,9 @@ void QmlConnection::connectIfValid()
}
if (sigparams.isEmpty())
- d->boundsignal = new QmlBoundSignal(d->ctxt, d->script, sender, sigIdx, this);
+ d->boundsignal = new QmlBoundSignal(qmlContext(this), d->script, sender, sigIdx, this);
else
- d->boundsignal = new QmlBoundSignalProxy(new QmlContext(d->ctxt,this), d->script, sender, sigIdx, this);
+ d->boundsignal = new QmlBoundSignalProxy(new QmlContext(qmlContext(this),this), d->script, sender, sigIdx, this);
}
}
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index 01d8962..35f3c49 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -41,7 +41,6 @@
#include <limits.h>
#include <QtCore/qdebug.h>
-#include <gfxtimeline.h>
#include "private/qobject_p.h"
#include "qmlfollow.h"
#include "private/qmlanimation_p.h"
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 992185a..24f2d5c 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -537,7 +537,6 @@ ModelNode::~ModelNode()
struct ListModelData
{
int dataOffset;
- int id;
int instrCount;
ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); }
};
@@ -546,7 +545,6 @@ QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok)
{
*ok = true;
- QByteArray id;
QByteArray data;
QList<ListInstruction> instr;
int depth=0;
@@ -649,10 +647,6 @@ QByteArray ListModelParser::compile(QXmlStreamReader& reader, bool *ok)
rv.resize(size);
ListModelData *lmd = (ListModelData *)rv.data();
- if(id.count())
- lmd->id = 0;
- else
- lmd->id = -1;
lmd->dataOffset = sizeof(ListModelData) +
instr.count() * sizeof(ListInstruction);
lmd->instrCount = instr.count();
@@ -709,11 +703,6 @@ QVariant ListModelParser::create(const QByteArray &d)
}
}
- if(lmd->id != -1) {
- QmlContext *ctxt = QmlContext::activeContext();
- ctxt->setContextProperty(QLatin1String(data + lmd->id), rv);
- }
-
return QVariant::fromValue(rv);
}
diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp
index 859e21e..73c8c07 100644
--- a/src/declarative/util/qmlscript.cpp
+++ b/src/declarative/util/qmlscript.cpp
@@ -65,7 +65,7 @@ class QmlScriptPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlScript);
public:
- QmlScriptPrivate() : reply(0), ctxt(0) {}
+ QmlScriptPrivate() : reply(0) {}
void addScriptToEngine(const QString &, const QString &fileName=QString());
@@ -73,7 +73,6 @@ public:
QString source;
QNetworkReply *reply;
QUrl url;
- QmlContext *ctxt;
};
/*!
@@ -106,8 +105,6 @@ public:
QML_DEFINE_TYPE(QmlScript,Script);
QmlScript::QmlScript(QObject *parent) : QObject(*(new QmlScriptPrivate), parent)
{
- Q_D(QmlScript);
- d->ctxt = QmlContext::activeContext();
}
/*!
@@ -154,10 +151,10 @@ void QmlScript::setSource(const QString &source)
if (d->source == source)
return;
d->source = source;
- d->url = d->ctxt->resolvedUrl(source);
+ d->url = qmlContext(this)->resolvedUrl(source);
QNetworkRequest req(d->url);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = d->ctxt->engine()->networkAccessManager()->get(req);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(replyFinished()));
}
@@ -176,7 +173,8 @@ void QmlScript::replyFinished()
void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &fileName)
{
Q_Q(QmlScript);
- QmlEngine *engine = ctxt->engine();
+ QmlEngine *engine = qmlEngine(q);
+ QmlContext *context = qmlContext(q);
QScriptEngine *scriptEngine = engine->scriptEngine();
QScriptContext *currentContext = engine->scriptEngine()->currentContext();
@@ -186,11 +184,11 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &f
for (int i = 0; i < oldScopeChain.size(); ++i) {
currentContext->popScope();
}
- for (int i = ctxt->d_func()->scopeChain.size() - 1; i > -1; --i) {
- currentContext->pushScope(ctxt->d_func()->scopeChain.at(i));
+ for (int i = context->d_func()->scopeChain.size() - 1; i > -1; --i) {
+ currentContext->pushScope(context->d_func()->scopeChain.at(i));
}
- currentContext->setActivationObject(ctxt->d_func()->scopeChain.at(0));
+ currentContext->setActivationObject(context->d_func()->scopeChain.at(0));
QScriptValue val = scriptEngine->evaluate(script, fileName);
if (scriptEngine->hasUncaughtException()) {
@@ -209,7 +207,7 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &f
currentContext->setActivationObject(oldact);
- for (int i = 0; i < ctxt->d_func()->scopeChain.size(); ++i)
+ for (int i = 0; i < context->d_func()->scopeChain.size(); ++i)
currentContext->popScope();
for (int i = oldScopeChain.size() - 1; i > -1; --i)
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index f07fecb..9b1b695 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-#include <gfxeasing.h>
#include "qmltransition.h"
#include "qmlstategroup.h"
#include "qmlstate_p.h"
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 3e6727d..68c43fa 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -44,7 +44,6 @@
#include <QtCore/qobject.h>
#include <qfxglobal.h>
-#include <gfxtimeline.h>
#include <qml.h>
#include <QSequentialAnimationGroup>
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index a8779f9..c70977a 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include <private/qobject_p.h>
-#include <gfxeasing.h>
#include <qml.h>
#include <QtDeclarative/qmlcontext.h>
#include "qmlbindablevalue.h"
@@ -137,9 +136,8 @@ QmlStateOperation::ActionList QmlParentChange::actions()
class QmlRunScriptPrivate : public QObjectPrivate
{
public:
- QmlRunScriptPrivate() : ctxt(0) {}
+ QmlRunScriptPrivate() {}
- QmlContext *ctxt;
QString script;
QString name;
};
@@ -152,8 +150,6 @@ QML_DEFINE_TYPE(QmlRunScript,RunScript);
QmlRunScript::QmlRunScript(QObject *parent)
: QmlStateOperation(*(new QmlRunScriptPrivate), parent)
{
- Q_D(QmlRunScript);
- d->ctxt = QmlContext::activeContext();
}
QmlRunScript::~QmlRunScript()
@@ -192,7 +188,7 @@ void QmlRunScript::execute()
{
Q_D(QmlRunScript);
if(!d->script.isEmpty()) {
- QmlExpression expr(d->ctxt, d->script, this);
+ QmlExpression expr(qmlContext(this), d->script, this);
expr.setTrackChange(false);
expr.value();
}
diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h
index 0d86b7d..0b7ea14 100644
--- a/src/declarative/util/qmltransition.h
+++ b/src/declarative/util/qmltransition.h
@@ -44,7 +44,6 @@
#include <QtCore/qobject.h>
#include <qfxglobal.h>
-#include <gfxtimeline.h>
#include <qmlstate.h>
#include <qml.h>