[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/stage-paulm-test3] stage/part: Add motion path icons (painted using the path stored in the
From:       Paul Mendez <paulestebanms () gmail ! com>
Date:       2012-07-29 6:04:19
Message-ID: 20120729060419.D3E6CA6094 () git ! kde ! org
[Download RAW message or body]

Git commit f857e027e1db5a7528227f76cde93ddea8172800 by Paul Mendez.
Committed on 29/07/2012 at 08:02.
Pushed by mendez into branch 'stage-paulm-test3'.

Add motion path icons (painted using the path stored in the animation)

M  +0    -42   stage/part/animations/animations.xml
M  +51   -3    stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp
M  +1    -0    stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.h

http://commits.kde.org/calligra/f857e027e1db5a7528227f76cde93ddea8172800

diff --git a/stage/part/animations/animations.xml \
b/stage/part/animations/animations.xml index b9ae43a..71c566b 100644
--- a/stage/part/animations/animations.xml
+++ b/stage/part/animations/animations.xml
@@ -709,14 +709,6 @@ xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" \
xmlns:smil="urn  </anim:par>
     </anim:par>
   </anim:par>
-  <anim:par smil:begin="indefinite" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
                presentation:preset-id="ooo-motionpath-buzz-saw">
-        <anim:animateMotion smil:dur="2" smil:fill="hold" svg:path="M 0 0  C -0.022 \
-0.02265  -0.033 -0.06129  -0.027 -0.09993  C -0.024 -0.11325  -0.02 -0.12658  -0.014 \
-0.13724  C -0.01 -0.10659  0.004 -0.07861  0.025 -0.06129  C 0.025 -0.0986  0.041 \
-0.13457  0.068 -0.15056  C 0.077 -0.15722  0.087 -0.15989  0.097 -0.16122  C 0.082 \
-0.13857  0.074 -0.10659  0.077 -0.07328  C 0.099 -0.09727  0.13 -0.1026  0.157 \
-0.08527  C 0.166 -0.07994  0.175 -0.07062  0.181 -0.06129  C 0.158 -0.06396  0.134 \
-0.05196  0.117 -0.02798  C 0.144 -0.01999  0.167 0.00799  0.174 0.04663  C 0.176 \
0.05996  0.176 0.07328  0.174 0.08661  C 0.161 0.06129  0.139 0.04397  0.115 0.0413  \
C 0.127 0.07461  0.124 0.11592  0.106 0.14656  C 0.099 0.15722  0.091 0.16655  0.082 \
0.17188  C 0.089 0.14257  0.085 0.10926  0.072 0.08261  C 0.06 0.11592  0.034 0.13857 \
0.004 0.13857  C -0.007 0.13857  -0.017 0.13591  -0.026 0.13058  C -0.004 0.11992  \
0.013 0.0946  0.021 0.06396  C -0.007 0.07195  -0.036 0.05996  -0.055 0.02931  C \
                -0.062 0.01732  -0.
-066 0.00533  -0.069 -0.00799  C -0.049 0.00933  -0.023 0.01199  0 0  Z"/>
-    </anim:par>
-    </anim:par>
-  </anim:par>
 <!-- C - D -->
   <anim:par smil:begin="indefinite" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold">
@@ -755,22 +747,6 @@ xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" \
xmlns:smil="urn  </anim:par>
   <anim:par smil:begin="indefinite" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
                presentation:preset-id="ooo-motionpath-curvy-left">
-        <anim:animateMotion smil:dur="2" smil:fill="hold" svg:path="M 0 0  C 0.008 \
0.01066  0.017 0.02132  0.021 0.03464  C 0.025 0.0493  0.027 0.06662  0.029 0.08394  \
C 0.031 0.10126  0.029 0.11592  0.027 0.13191  C 0.025 0.14656  0.022 0.16255  0.015 \
0.17588  C 0.009 0.1892  -0.001 0.19986  -0.012 0.20786  C -0.022 0.21585  -0.034 \
0.22118  -0.046 0.22384  C -0.058 0.22651  -0.07 0.22651  -0.081 0.22384  C -0.093 \
0.22118  -0.104 0.21452  -0.113 0.20386  C -0.122 0.19453  -0.13 0.18254  -0.134 \
0.16788  C -0.139 0.15456  -0.141 0.13591  -0.141 0.12125  C -0.142 0.10659  -0.141 \
0.08927  -0.136 0.07461  C -0.131 0.06129  -0.122 0.05063  -0.11 0.0453  C -0.098 \
0.0413  -0.086 0.04663  -0.078 0.05596  C -0.071 0.06529  -0.066 0.07994  -0.065 \
0.09727  C -0.065 0.11459  -0.066 0.13058  -0.071 0.1439  C -0.076 0.15722  -0.075 \
0.15989  -0.095 0.17721  C -0.113 0.19586  -0.131 0.19053  -0.142 0.19187  C -0.153 \
0.19187  -0.162 0.18654  -0.173 0.18121  C -0.185 0.17455  -0.195 0.16255  -0.202 \
                0.15189  C -0.209 0.14124  -
-0.212 0.12791  -0.216 0.10659  C -0.219 0.08527  -0.219 0.07461  -0.219 0.05863  C \
                -0.219 0.04264  -0.219 0.02665  -0.219 0.01066"/>
-    </anim:par>
-    </anim:par>
-  </anim:par>
-  <anim:par smil:begin="indefinite" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
                presentation:preset-id="ooo-motionpath-curvy-right">
-        <anim:animateMotion smil:dur="2" smil:fill="hold" svg:path="M 0 0  C -0.008 \
0.01066  -0.017 0.02132  -0.021 0.03464  C -0.025 0.0493  -0.027 0.06662  -0.029 \
0.08394  C -0.031 0.10126  -0.029 0.11592  -0.027 0.13191  C -0.025 0.14656  -0.022 \
0.16255  -0.015 0.17588  C -0.009 0.1892  0.001 0.19986  0.012 0.20786  C 0.022 \
0.21585  0.034 0.22118  0.046 0.22384  C 0.058 0.22651  0.07 0.22651  0.081 0.22384  \
C 0.093 0.22118  0.104 0.21452  0.113 0.20386  C 0.122 0.19453  0.13 0.18254  0.134 \
0.16788  C 0.139 0.15456  0.141 0.13591  0.141 0.12125  C 0.142 0.10659  0.141 \
0.08927  0.136 0.07461  C 0.131 0.06129  0.122 0.05063  0.11 0.0453  C 0.098 0.0413  \
0.086 0.04663  0.078 0.05596  C 0.071 0.06529  0.066 0.07994  0.065 0.09727  C 0.065 \
0.11459  0.066 0.13058  0.071 0.1439  C 0.076 0.15722  0.075 0.15989  0.095 0.17721  \
C 0.113 0.19586  0.131 0.19053  0.142 0.19187  C 0.153 0.19187  0.162 0.18654  0.173 \
0.18121  C 0.185 0.17455  0.195 0.16255  0.202 0.15189  C 0.209 0.14124  0.212 \
                0.12791  0.216 0.10659  C 0.
-219 0.08527  0.219 0.07461  0.219 0.05863  C 0.219 0.04264  0.219 0.02665  0.219 \
                0.01066"/>
-    </anim:par>
-    </anim:par>
-  </anim:par>
-  <anim:par smil:begin="indefinite" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
presentation:preset-id="ooo-motionpath-curvy-star">  <anim:animateMotion smil:dur="2" \
smil:fill="hold" svg:path="M 0 0  C 0.072 0.07728  0.1 0.20253  0.077 0.31711  C \
-0.015 0.31045  -0.093 0.23051  -0.125 0.12125  C -0.047 0.0533  0.051 0.05729  0.125 \
0.12125  C 0.092 0.23717  0.011 0.31045  -0.077 0.31711  C -0.101 0.1972  -0.068 \
0.07461  0 0  Z"/>  </anim:par>
@@ -833,16 +809,6 @@ xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" \
xmlns:smil="urn  </anim:par>
     </anim:par>
   </anim:par>
-  <anim:par smil:begin="indefinite" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
                presentation:preset-id="ooo-motionpath-funnel">
-        <anim:animateMotion smil:dur="2" smil:fill="hold" svg:path="M 0 0  C -0.001 \
0.03331  0.06 0.06262  0.137 0.06396  C 0.198 0.06662  0.248 0.05063  0.249 0.03065  \
C 0.249 0.01066  0.2 -0.00799  0.138 -0.00933  C 0.107 -0.00933  0.079 -0.00666  \
0.059 0  C 0.03 0.00933  0.013 0.02398  0.013 0.0413  C 0.013 0.05063  0.018 0.05996  \
0.027 0.06795  C 0.048 0.08527  0.089 0.09727  0.136 0.0986  C 0.191 0.10126  0.236 \
0.08661  0.236 0.06929  C 0.237 0.05063  0.192 0.03464  0.137 0.03198  C 0.109 \
0.03198  0.084 0.03464  0.065 0.03997  C 0.04 0.0493  0.024 0.06396  0.024 0.07861  C \
0.024 0.08661  0.029 0.0946  0.037 0.1026  C 0.056 0.11725  0.092 0.12924  0.135 \
0.13058  C 0.185 0.13191  0.225 0.11858  0.225 0.1026  C 0.226 0.08661  0.186 0.07195 \
0.136 0.07062  C 0.111 0.06929  0.088 0.07195  0.071 0.07728  C 0.048 0.08527  0.035 \
0.09727  0.035 0.11192  C 0.035 0.11858  0.039 0.12658  0.046 0.13324  C 0.063 \
0.14656  0.096 0.15722  0.134 0.15856  C 0.179 0.15856  0.215 0.1479  0.215 0.13324  \
                C 0.215 0.11858  0.18 
-0.10526  0.135 0.10393  C 0.113 0.10393  0.092 0.10659  0.077 0.11059  C 0.056 \
0.11725  0.044 0.12924  0.043 0.14124  C 0.043 0.1479  0.048 0.15456  0.054 0.15989  \
C 0.069 0.17321  0.099 0.18254  0.133 0.18254  C 0.173 0.18387  0.206 0.17455  0.206 \
0.16122  C 0.207 0.1479  0.174 0.13591  0.134 0.13457  C 0.114 0.13457  0.095 0.13591 \
0.082 0.14124  C 0.063 0.14656  0.052 0.15722  0.052 0.16788  C 0.052 0.17455  0.055 \
0.17988  0.061 0.1852  C 0.075 0.1972  0.101 0.20519  0.132 0.20652  C 0.169 0.20652  \
0.198 0.19853  0.198 0.18654  C 0.199 0.17455  0.17 0.16389  0.133 0.16255  C 0.115 \
0.16255  0.099 0.16389  0.087 0.16788  C 0.07 0.17321  0.06 0.18254  0.06 0.1932  C \
0.06 0.19853  0.063 0.20253  0.068 0.20786  C 0.08 0.21851  0.104 0.22518  0.132 \
0.22651  C 0.165 0.22784  0.191 0.21985  0.191 0.20786  C 0.191 0.19853  0.166 \
0.18787  0.133 0.18787  C 0.116 0.18654  0.101 0.1892  0.09 0.19187  C 0.075 0.1972  \
0.066 0.20519  0.066 0.21452  C 0.066 0.21985  0.069 0.22384  0.074 0.22784  C 0.085 \
                0.23717  0.107 0.
-24383  0.131 0.24516  C 0.161 0.2465  0.185 0.2385  0.185 0.22917  C 0.185 0.21851  \
0.161 0.21052  0.132 0.20919  C 0.118 0.20919  0.104 0.21052  0.094 0.21452  C 0.08 \
0.21851  0.072 0.22518  0.072 0.2345  C 0.072 0.2385  0.075 0.2425  0.079 0.2465  C \
0.089 0.25449  0.108 0.26115  0.131 0.26115  C 0.157 0.26248  0.179 0.25582  0.179 \
0.2465  C 0.179 0.2385  0.158 0.23051  0.131 0.23051  C 0.119 0.22917  0.106 0.23051  \
0.097 0.23317  C 0.085 0.2385  0.078 0.24516  0.078 0.25183  C 0.078 0.25582  0.08 \
0.25982  0.084 0.26248  C 0.093 0.27048  0.11 0.27581  0.131 0.27714  C 0.155 0.27714 \
0.174 0.27048  0.174 0.26382  C 0.174 0.25582  0.155 0.24783  0.131 0.24783  C 0.119 \
0.24783  0.108 0.24916  0.101 0.25183  C 0.089 0.25449  0.083 0.26115  0.083 0.26781  \
C 0.083 0.27048  0.085 0.27448  0.088 0.27714  C 0.096 0.28514  0.112 0.28913  0.13 \
0.29046  C 0.152 0.29046  0.169 0.28514  0.169 0.27847  C 0.169 0.27048  0.152 \
0.26515  0.131 0.26382  C 0.12 0.26382  0.11 0.26515  0.103 0.26781  C 0.093 0.27048  \
                0.087 0.
-27581  0.087 0.28247  C 0.087 0.28514  0.089 0.2878  0.092 0.29046"/>
-    </anim:par>
-    </anim:par>
-  </anim:par>
 <!-- G - H -->
   <anim:par smil:begin="indefinite" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold">
@@ -868,14 +834,6 @@ xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" \
xmlns:smil="urn  <!-- I - J - K -->
   <anim:par smil:begin="indefinite" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
                presentation:preset-id="ooo-motionpath-inverted-square">
-        <anim:animateMotion smil:dur="2" smil:fill="hold" svg:path="M 0 0  C 0.004 \
-0.00533  0.01 -0.00799  0.015 -0.00799  C 0.022 -0.00799  0.029 -0.004  0.033 \
0.00266  C 0.05 0.02931  0.063 0.08794  0.063 0.15722  C 0.063 0.15722  0.063 0.15856 \
0.063 0.15856  C 0.063 0.15856  0.063 0.15989  0.063 0.15989  C 0.063 0.22917  0.05 \
0.28913  0.033 0.31578  C 0.029 0.32111  0.022 0.32511  0.015 0.32511  C 0.01 0.32511 \
0.004 0.32244  0 0.31711  C -0.004 0.31178  -0.006 0.30512  -0.006 0.29713  C -0.006 \
0.2878  -0.003 0.27981  0.002 0.27448  C 0.022 0.25049  0.066 0.23317  0.118 0.23317  \
C 0.118 0.23317  0.119 0.23317  0.119 0.23317  C 0.119 0.23317  0.12 0.23317  0.12 \
0.23317  C 0.172 0.23317  0.217 0.25049  0.237 0.27448  C 0.241 0.27981  0.244 0.2878 \
0.244 0.29713  C 0.244 0.30512  0.242 0.31178  0.238 0.31711  C 0.234 0.32244  0.229 \
0.32511  0.223 0.32511  C 0.216 0.32511  0.21 0.32111  0.206 0.31578  C 0.188 0.28913 \
0.175 0.22917  0.175 0.15989  C 0.175 0.15989  0.175 0.15856  0.175 0.15856  C 0.175 \
                0.
-15856  0.175 0.15722  0.175 0.15722  C 0.175 0.08794  0.188 0.02931  0.206 0.00133  \
C 0.21 -0.004  0.216 -0.00799  0.223 -0.00799  C 0.229 -0.00799  0.234 -0.00533  \
0.238 0  C 0.242 0.00533  0.244 0.01332  0.244 0.01999  C 0.244 0.02931  0.241 \
0.03731  0.237 0.04397  C 0.217 0.06662  0.172 0.08394  0.12 0.08394  C 0.12 0.08394  \
0.12 0.08394  0.119 0.08394  C 0.119 0.08394  0.118 0.08394  0.118 0.08394  C 0.066 \
0.08394  0.022 0.06662  0.002 0.04397  C -0.003 0.03731  -0.006 0.02931  -0.006 \
                0.01999  C -0.006 0.01332  -0.004 0.00533  0 0  Z"/>
-    </anim:par>
-    </anim:par>
-  </anim:par>
-  <anim:par smil:begin="indefinite" smil:fill="hold">
-    <anim:par smil:begin="0" smil:fill="hold">
     <anim:par smil:begin="0" smil:fill="hold" smil:accelerate="0.5" \
smil:decelerate="0.5" presentation:node-type="on-click" \
presentation:preset-class="motion-path" \
presentation:preset-id="ooo-motionpath-inverted-triangle">  <anim:animateMotion \
smil:dur="2" smil:fill="hold" svg:path="M 0 0  C 0.015 0.03198  0.037 0.06529  0.055 \
0.07861  C 0.082 0.09993  0.108 0.10793  0.113 0.09727  C 0.117 0.08661  0.099 \
0.05996  0.072 0.03864  C 0.054 0.02532  0.021 0.01599  -0.008 0.01466  C -0.036 \
0.01599  -0.07 0.02532  -0.088 0.03864  C -0.115 0.05996  -0.133 0.08661  -0.128 \
0.09727  C -0.123 0.10793  -0.097 0.09993  -0.071 0.07861  C -0.053 0.06529  -0.03 \
0.03198  -0.016 0  C -0.001 -0.03331  0.009 -0.07728  0.009 -0.10526  C 0.009 -0.1479 \
0.002 -0.18121  -0.008 -0.18121  C -0.017 -0.18121  -0.025 -0.1479  -0.025 -0.10526  \
C -0.025 -0.07728  -0.014 -0.03331  0 0  Z"/>  </anim:par>
diff --git a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp \
b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp index \
                06052c9..152996d 100644
--- a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp
+++ b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.cpp
@@ -29,6 +29,9 @@
 //Qt Headers
 #include <QListWidget>
 #include <QListWidgetItem>
+#include <QPainterPath>
+#include <QPainter>
+#include <QImage>
 #include <QFont>
 
 //KDE Headers
@@ -46,6 +49,8 @@
 #include <KoXmlNS.h>
 #include <KoOdfStylesReader.h>
 #include <KoStore.h>
+#include <KoPathShape.h>
+#include <KoPathShapeLoader.h>
 
 KPrPredefinedAnimationsLoader::KPrPredefinedAnimationsLoader(QObject *parent)
     : QObject(parent)
@@ -128,13 +133,17 @@ void KPrPredefinedAnimationsLoader::loadDefaultAnimations()
                 continue;
             }
         }
-
         KPrCollectionItem temp;
         temp.id = animId;
         temp.name = animationName(animId);
-        temp.toolTip = temp.name;
-        temp.icon = loadAnimationIcon(temp.name);
+        temp.toolTip = temp.name;      
         temp.animationContext = m_animationContext.value(row);
+        if (animation->presetClass() == KPrShapeAnimation::Motion_Path) {
+            temp.icon = loadMotionPathIcon(temp.animationContext);
+        }
+        else {
+            temp.icon = loadAnimationIcon(temp.name);
+        }
 
         if (animation->presetClass() == KPrShapeAnimation::Entrance) {
             entranceList.append(temp);
@@ -291,6 +300,45 @@ QIcon KPrPredefinedAnimationsLoader::loadSubTypeIcon(const \
QString mainId, const  return icon;
 }
 
+QIcon KPrPredefinedAnimationsLoader::loadMotionPathIcon(const KoXmlElement &element)
+{
+    KoXmlElement e;
+    QString path;
+    forEachElement(e, element) {
+        path = e.attributeNS(KoXmlNS::svg, "path");
+        if (!path.isEmpty()) {
+            break;
+        }
+    }
+    if (!path.isEmpty()) {
+        const int margin = 8;
+        const int width = 4;
+        KoPathShape pathShape;
+        KoPathShapeLoader loader(&pathShape);
+        loader.parseSvg(path, true);
+        QImage thumb(QSize(KIconLoader::SizeHuge, KIconLoader::SizeHuge), \
QImage::Format_RGB32); +        // fill backgroung
+        thumb.fill(QColor(Qt::white).rgb());
+        QRect imageRect = thumb.rect();
+        // adjust to left space for margins
+        imageRect.adjust(margin, margin, -margin, -margin);
+        pathShape.setSize(imageRect.size());
+        QPainterPath m_path = pathShape.outline();
+        //Center path
+        m_path.translate(-m_path.boundingRect().x() + margin, \
-m_path.boundingRect().y() + margin); +        QPainter painter(&thumb);
+        painter.setPen(QPen(QColor(0, 100, 224), width, Qt::SolidLine,
+                            Qt::FlatCap, Qt::MiterJoin));
+        painter.drawPath(m_path);
+        QPixmap iconPixmap;
+        if (iconPixmap.convertFromImage(thumb)) {
+            return QIcon(iconPixmap);
+        }
+    }
+    // Default icon if path was not found (It must be a error?)
+    return KIcon("unrecognized_animation");
+}
+
 KPrShapeAnimation *KPrPredefinedAnimationsLoader::loadOdfShapeAnimation(const \
KoXmlElement &element, KoShapeLoadingContext &context, KoShape *animShape)  {
     // load preset and id
diff --git a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.h \
b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.h index \
                8d552fc..c6e1bc0 100644
--- a/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.h
+++ b/stage/part/tools/animationtool/KPrPredefinedAnimationsLoader.h
@@ -59,6 +59,7 @@ private:
     QString animationName(const QString id) const;
     QIcon loadAnimationIcon(const QString id);
     QIcon loadSubTypeIcon(const QString mainId, const QString subTypeId);
+    QIcon loadMotionPathIcon(const KoXmlElement &element);
 
     /**
      * Add a collection to the docker


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic