Spring AlphaFunction Sample 20/323020/7
authorSeungho Baek <sbsh.baek@samsung.com>
Tue, 22 Apr 2025 05:15:29 +0000 (14:15 +0900)
committerSeungho Baek <sbsh.baek@samsung.com>
Wed, 30 Apr 2025 05:45:34 +0000 (14:45 +0900)
Change-Id: Iba86afa31057f4ce5731081f9834493482fd081b
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
15 files changed:
com.samsung.dali-demo.xml
demo/dali-demo.cpp
examples/spring-alphafunction/README.md [new file with mode: 0644]
examples/spring-alphafunction/spring-alphafunction-example.cpp [new file with mode: 0644]
resources/po/as.po
resources/po/de.po
resources/po/en_GB.po
resources/po/en_US.po
resources/po/es.po
resources/po/fi.po
resources/po/ko.po
resources/po/ml.po
resources/po/ur.po
resources/po/zn_CH.po
shared/dali-demo-strings.h

index 5a1f35e4e9a5c34d39831fac035b1f3fcb362e50..a6154678431288c3b16193b9aa9e95aab9d7d8b6 100644 (file)
        <ui-application appid="sparkle.example" exec="/usr/apps/com.samsung.dali-demo/bin/sparkle.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Sparkle</label>
        </ui-application>
+       <ui-application appid="spring-alphafunction.example" exec="/usr/apps/com.samsung.dali-demo/bin/spring-alphafunction.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Spring AlphaFunction</label>
+       </ui-application>
        <ui-application appid="styling.example" exec="/usr/apps/com.samsung.dali-demo/bin/styling.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Styling</label>
        </ui-application>
index cfbab00914be7f95766fe51755ecc3fbb9c96cc6..8a726355157a3def7f81886fe3b752b203badb62 100644 (file)
@@ -67,6 +67,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
 #endif //DALI_SCENE3D_AVAILABLE
   demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS));
   demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE));
+  demo.AddExample(Example("spring-alphafunction.example", DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION));
   demo.AddExample(Example("waves.example", DALI_DEMO_STR_TITLE_WAVES));
 
   demo.SortAlphabetically(true);
diff --git a/examples/spring-alphafunction/README.md b/examples/spring-alphafunction/README.md
new file mode 100644 (file)
index 0000000..3b2e0d2
--- /dev/null
@@ -0,0 +1,15 @@
+# Spring AlphaFunction Test Example
+
+This is a various test example for Animation with Spring AlphaFunction
+
+ - 7 kinds of spring animation is repeatedly played.
+ - (Preset) GENTLE
+ - (Preset) QUICK
+ - (Preset) BOUNCY
+ - (Preset) SLOW
+ - (Custom) Stiffness : 100,  Damping : 10,   Mass : 1
+ - (Custom) Stiffness : 4420, Damping : 20.8, Mass : 1
+ - (Custom) Stiffness : 1000, Damping : 10,   Mass : 10
+
+Please update this note if you add some more test cases.
+
diff --git a/examples/spring-alphafunction/spring-alphafunction-example.cpp b/examples/spring-alphafunction/spring-alphafunction-example.cpp
new file mode 100644 (file)
index 0000000..d79fcc6
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class SpringAlphaFunctionController : public ConnectionTracker
+{
+public:
+  SpringAlphaFunctionController(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &SpringAlphaFunctionController::Create);
+  }
+
+  ~SpringAlphaFunctionController() = default; // Nothing to do in destructor
+
+  // The Init signal is received once (only) during the Application lifetime
+  void Create(Application& application)
+  {
+    // Get a handle to the window
+    Window window = application.GetWindow();
+    window.SetBackgroundColor(Color::WHITE);
+
+    Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+    control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    control.SetProperty(Dali::Actor::Property::SIZE, Vector2(250, 1000));
+    control.SetProperty(Dali::Actor::Property::POSITION_X, 250);
+    control.SetBackgroundColor(Color::PINK);
+    window.Add(control);
+
+    mGentle = Dali::Toolkit::TextLabel::New("Gentle");
+    mGentle.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mGentle.SetProperty(Dali::Actor::Property::NAME, "Gentle");
+    mGentle.SetProperty(Dali::Actor::Property::POSITION_Y, 0.0f);
+    window.Add(mGentle);
+
+    mQuick = Dali::Toolkit::TextLabel::New("Quick");
+    mQuick.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mQuick.SetProperty(Dali::Actor::Property::NAME, "Quick");
+    mQuick.SetProperty(Dali::Actor::Property::POSITION_Y, 100.0f);
+    window.Add(mQuick);
+
+    mBouncy = Dali::Toolkit::TextLabel::New("Bouncy");
+    mBouncy.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mBouncy.SetProperty(Dali::Actor::Property::NAME, "Bouncy");
+    mBouncy.SetProperty(Dali::Actor::Property::POSITION_Y, 200.0f);
+    window.Add(mBouncy);
+
+    mSlow = Dali::Toolkit::TextLabel::New("Slow");
+    mSlow.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mSlow.SetProperty(Dali::Actor::Property::NAME, "Slow");
+    mSlow.SetProperty(Dali::Actor::Property::POSITION_Y, 300.0f);
+    window.Add(mSlow);
+
+    mS100D10M1 = Dali::Toolkit::TextLabel::New("S100_D10_M1");
+    mS100D10M1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mS100D10M1.SetProperty(Dali::Actor::Property::NAME, "S100_D10_M1");
+    mS100D10M1.SetProperty(Dali::Actor::Property::POSITION_Y, 400.0f);
+    window.Add(mS100D10M1);
+
+    mS4420D20_8M1 = Dali::Toolkit::TextLabel::New("S4420_D20.8_M1");
+    mS4420D20_8M1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mS4420D20_8M1.SetProperty(Dali::Actor::Property::NAME, "S4420_D20.8_M1");
+    mS4420D20_8M1.SetProperty(Dali::Actor::Property::POSITION_Y, 500.0f);
+    window.Add(mS4420D20_8M1);
+
+    mS1000D10M10 = Dali::Toolkit::TextLabel::New("S1000_D10_M10");
+    mS1000D10M10.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+    mS1000D10M10.SetProperty(Dali::Actor::Property::NAME, "S1000_D10_M10");
+    mS1000D10M10.SetProperty(Dali::Actor::Property::POSITION_Y, 600.0f);
+    window.Add(mS1000D10M10);
+
+    Animation animation = Animation::New(1.0f);  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mGentle, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction(Dali::AlphaFunction::SpringType::GENTLE));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(1.0f);  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mQuick, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction(Dali::AlphaFunction::SpringType::QUICK));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(1.0f);  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mBouncy, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction(Dali::AlphaFunction::SpringType::BOUNCY));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(1.0f);  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mSlow, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction(Dali::AlphaFunction::SpringType::SLOW));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(SpringData::GetDuration({100.0f, 10.0f, 1.0f}));  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mS100D10M1, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction({100.0f, 10.0f, 1.0f}));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(SpringData::GetDuration({4420.0f, 20.8f, 1.0f}));  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mS4420D20_8M1, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction({4420.0f, 20.8f, 1.0f}));
+    animation.SetLooping(true);
+    animation.Play();
+
+    animation = Animation::New(SpringData::GetDuration({1000.0f, 10.0f, 10.0f}));  // Set the longest duration.
+    animation.AnimateTo(Dali::Property(mS1000D10M10, Dali::Actor::Property::POSITION_X), 500.0f, Dali::AlphaFunction({1000.0f, 10.0f, 10.0f}));
+    animation.SetLooping(true);
+    animation.Play();
+
+    // Respond to a touch anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect(this, &SpringAlphaFunctionController::OnTouch);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &SpringAlphaFunctionController::OnKeyEvent);
+  }
+
+  bool OnTouch(Actor actor, const TouchEvent& touch)
+  {
+    // quit the application
+    mApplication.Quit();
+    return true;
+  }
+
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.GetState() == KeyEvent::DOWN)
+    {
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
+private:
+  Dali::Toolkit::TextLabel mGentle, mQuick, mBouncy, mSlow, mS100D10M1, mS4420D20_8M1, mS1000D10M10;
+  Application& mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application          application = Application::New(&argc, &argv);
+  SpringAlphaFunctionController test(application);
+  application.MainLoop();
+  return 0;
+}
index 5a8d67a4f76054295870c5eb62b04c9b9299ab67..a7e9c7a85ae0f31e318e36bd8f45e0c14fe1112e 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "স্ক্ৰ'ল কৰক"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "তাৰকা"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "শৈলী"
 
index 28136c4dd7a40cf6121c2fa8ed97b0a6fe732213..cc80e21bd8d827de6b4db7ca9c0f55f686fecf91 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "Scroll-Ansicht"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "Funkeln"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "Styling"
 
index 17f3043507194827aacb6feda2deaefa3a742e33..6ff521e321ea2cd95dd7209c5849319d28015e20 100755 (executable)
@@ -271,6 +271,9 @@ msgstr "Simple Visuals Control"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "Sparkle"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "Styling"
 
index 56113ddb9cbf2619d2e5fd88d366a6a38a0104b3..2f123ffa4f60434635f8007ca9a50c0899792d51 100755 (executable)
@@ -280,6 +280,9 @@ msgstr "Simple Visuals Control"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "Sparkle"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "Styling"
 
index 5307429c733c8b5ae2f60937c23120f71c970879..2fd6ac14200d967eab01eff7f42a888a39be2cf8 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "Vista de desplazamiento"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "Brillar"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "Estilo"
 
index 094bb143a73a42341e4231ab3ab7a4179f2395c9..f5aefde4315d0d8acadd9c9b4148518bd68ea55f 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "Vieritysnäkymä"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "Kimalteluefekti"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "UI Tyyli"
 
index 6a1a2e1d4964063f47f8e860cf31e743c967656f..41eee5fbf81da822d6af702acddba2df5607780f 100755 (executable)
@@ -154,6 +154,9 @@ msgstr "스크롤 뷰"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "불꽃"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "스타일링"
 
index 2fa8579e0a60f0c4a15f0f1b57d290588260b39a..09d6c1430490fb310e5d45b95afadd43cb6b3458 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "സ്ക്രോള്ചെയ്യുക കാഴ്ച"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "നക്ഷത്ര"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "ശൈലി"
 
index ea08c029bfa1cf2b58c2a77dabda6f58ce30b3e7..882dc5fd9ec229cbbfc32715d28795d9c3eb19fb 100755 (executable)
@@ -130,6 +130,9 @@ msgstr "سکرول ویو"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "سٹار"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "سٹائل"
 
index 01b6cfdcbfe00f5194563473622d5b108e1c987c..49270d7db59422bc2851e8089bc3a456bce5cfe9 100755 (executable)
@@ -133,6 +133,9 @@ msgstr "滚动视图"
 msgid "DALI_DEMO_STR_TITLE_SPARKLE"
 msgstr "火花"
 
+msgid "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION"
+msgstr "Spring AlphaFunction"
+
 msgid "DALI_DEMO_STR_TITLE_STYLING"
 msgstr "样式"
 
index ada9d697d727a8c284aa6f1edd756346c0370ad8..09b613068a2e4c1da7b307fb7d0c71dfc2d3e6ea 100644 (file)
@@ -141,6 +141,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL")
 #define DALI_DEMO_STR_TITLE_SKYBOX dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SKYBOX")
 #define DALI_DEMO_STR_TITLE_SPARKLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPARKLE")
+#define DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION")
 #define DALI_DEMO_STR_TITLE_STYLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_STYLING")
 #define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW")
 #define DALI_DEMO_STR_TITLE_TEXTURED_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXTURED_MESH")
@@ -273,6 +274,7 @@ extern "C"
 #define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL "Simple Visuals Control"
 #define DALI_DEMO_STR_TITLE_SKYBOX "Skybox"
 #define DALI_DEMO_STR_TITLE_SPARKLE "Sparkle"
+#define DALI_DEMO_STR_TITLE_SPRING_ALPHAFUNCTION "Spring AlphaFunction"
 #define DALI_DEMO_STR_TITLE_STYLING "Styling"
 #define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW "Super Blur"
 #define DALI_DEMO_STR_TITLE_TEXTURED_MESH "Mesh Texture"