Adding advanced blending example 31/265131/1
authorDavid Steele <david.steele@samsung.com>
Mon, 11 Oct 2021 11:59:44 +0000 (12:59 +0100)
committerDavid Steele <david.steele@samsung.com>
Mon, 11 Oct 2021 11:59:44 +0000 (12:59 +0100)
Change-Id: Ib81a3376864a98e496ddb73256b698ec6c6f6250

15 files changed:
README.md
com.samsung.dali-demo.xml
examples-reel/dali-examples-reel.cpp
examples/advanced-blend-mode/advanced-blend-mode-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 29c195f28ea2f802d74587160c626e35d3370f8e..320163140017ba5eed2b9d8a6b23158ddfb189d9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -187,3 +187,23 @@ To build, run:
 ```zsh
 % make install -j8
 ```
+
+# Creating an example
+In the dali-demo/examples folder, add another folder. This will become the name of your example executable, so for example the "hello-world" folder generates a "hello-world.example" binary.
+In this folder, you can add as many source code files as you need.
+
+Usually, create a single class file containing a main function that instantiates an Application. Usually, the class is named after your example, followed by "Controller", e.g. hello-world.cpp contains a class called HelloWorldController.
+
+There is a DemoHelper::CreateView method, which enables you to easiliy set up a title bar and buttons.
+
+Add at least a key handler such that Escape or Back keys can be used to quit the application. Some apps that only present a single thing also add a touch handler that quits the application.
+
+Add a launcher line to one of demo/dali-demo.cpp, examples-reel/dali-examples-reel.cpp or tests-reel/dali-tests-reel.cpp, depending on the nature of what you are demonstrating. Generally, dali-demo is for graphical showcase demos, dali-examples-reel is for reasonable examples that look ok, and dali-tests is for examples that are only for testing. This needs a language string defining for the title.
+
+Add 2 lines to shared/dali-demo-strings.h for the title of your application, please keep in alphabetic ordering. Add english strings and translations to each of the language files in resources/po.
+
+To ensure your application can run on a Tizen device through the launcher, add an entry to com.samsung.dali-demo.xml, ensuring that only tabs are used for XML indent.
+
+
+
+
index 622c301bf0f064fbc160f0b4f0b633dda834fb81..2c46609af1a9115586d4f1ece4bf19b78cd7af9b 100644 (file)
@@ -19,6 +19,9 @@
 
        <!-- PLEASE KEEP THE FOLLOWING IN ALPHABETICAL ORDER USING THE 'appid'. -->
 
+       <ui-application appid="advanced-blend-mode.example" exec="/usr/apps/com.samsung.dali-demo/bin/advanced-blend-mode.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
+               <label>Advanced Blending App</label>
+       </ui-application>
        <ui-application appid="animated-gradient-call-active.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-gradient-call-active.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
                <label>Call Active App</label>
        </ui-application>
index e1ba60d40fe1be043e915a51c54cad3d6b174940..63ead6e8f46c04dd98ff389b706a4f7d033096ab 100644 (file)
@@ -38,6 +38,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
   // Create the demo launcher
   DaliTableView demo(app);
 
+  demo.AddExample(Example("advanced-blend-mode.example", DALI_DEMO_STR_TITLE_ADVANCED_BLENDING));
   demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES));
   demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES));
   demo.AddExample(Example("animated-vector-images.example", DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES));
diff --git a/examples/advanced-blend-mode/advanced-blend-mode-example.cpp b/examples/advanced-blend-mode/advanced-blend-mode-example.cpp
new file mode 100644 (file)
index 0000000..be5cab2
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2021 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/devel-api/actors/actor-devel.h>
+
+#include <dali/devel-api/common/capabilities.h>
+#include <dali/integration-api/debug.h>
+
+using namespace Dali;
+using Dali::Toolkit::TextLabel;
+
+// This example shows how to create and display Hello World! using a simple TextActor
+//
+class AdvancedBlendModeController : public ConnectionTracker
+{
+public:
+  AdvancedBlendModeController(Application& application)
+  : mApplication(application)
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect(this, &AdvancedBlendModeController::Create);
+  }
+
+  ~AdvancedBlendModeController() = 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 stage
+    Window window = application.GetWindow();
+    window.SetBackgroundColor(Color::BLACK);
+
+    Toolkit::ImageView imageView = Toolkit::ImageView::New();
+    Property::Map      imagePropertyMap;
+    imagePropertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
+    imagePropertyMap.Insert(Toolkit::ImageVisual::Property::URL, DEMO_IMAGE_DIR "gallery-large-19.jpg");
+    imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap);
+    imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+    imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600));
+    window.Add(imageView);
+
+    Toolkit::Control control_1 = Toolkit::Control::New();
+    Property::Map    colorVisualMap_1;
+    colorVisualMap_1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+    colorVisualMap_1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::RED);
+    colorVisualMap_1.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true);
+    control_1.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_1);
+    control_1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+    control_1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    control_1.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
+    control_1.SetProperty(Actor::Property::SIZE, Vector2(600, 200));
+    if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN))
+    {
+      control_1.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY);
+    }
+    window.Add(control_1);
+
+    Toolkit::Control control_2 = Toolkit::Control::New();
+    Property::Map    colorVisualMap_2;
+    colorVisualMap_2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+    colorVisualMap_2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::GREEN);
+    colorVisualMap_2.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true);
+    control_2.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_2);
+    control_2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+    control_2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    control_2.SetProperty(Actor::Property::POSITION, Vector2(0, 200));
+    control_2.SetProperty(Actor::Property::SIZE, Vector2(600, 200));
+    if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN))
+    {
+      control_2.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY);
+    }
+    window.Add(control_2);
+
+    Toolkit::Control control_3 = Toolkit::Control::New();
+    Property::Map    colorVisualMap_3;
+    colorVisualMap_3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+    colorVisualMap_3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::BLUE);
+    colorVisualMap_3.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true);
+    control_3.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_3);
+    control_3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+    control_3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    control_3.SetProperty(Actor::Property::POSITION, Vector2(0, 400));
+    control_3.SetProperty(Actor::Property::SIZE, Vector2(600, 200));
+    if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN))
+    {
+      control_3.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY);
+    }
+    window.Add(control_3);
+
+    // Add text to explain what's being seen.
+    auto label = Toolkit::TextLabel::New("If your device supports advanced blending, this shows an image at different levels of luminosity. If not, it instead shows red/green/blue sections.");
+
+    label[Toolkit::TextLabel::Property::MULTI_LINE] = true;
+    label[Toolkit::TextLabel::Property::TEXT_COLOR] = Color::WHITE;
+    label[Toolkit::TextLabel::Property::POINT_SIZE] = 12.0f;
+    label[Actor::Property::PARENT_ORIGIN]           = ParentOrigin::BOTTOM_CENTER;
+    label[Actor::Property::ANCHOR_POINT]            = AnchorPoint::BOTTOM_CENTER;
+    label.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
+    window.Add(label);
+
+    // Respond to a touch anywhere on the window
+    window.GetRootLayer().TouchedSignal().Connect(this, &AdvancedBlendModeController::OnTouch);
+
+    // Respond to key events
+    window.KeyEventSignal().Connect(this, &AdvancedBlendModeController::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:
+  Application& mApplication;
+};
+
+int DALI_EXPORT_API main(int argc, char** argv)
+{
+  Application                 application = Application::New(&argc, &argv);
+  AdvancedBlendModeController test(application);
+  application.MainLoop();
+  return 0;
+}
index bab37b32c3869dbdae4d6c164f91f33bd4d4bb40..d5931ff04bd612bb4598af7266719da9de5b4449 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "ফটোশ্বপ ব্লেণ্ড মোড"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "অ্যানিমেটেড ইমেজ"
 
index 6190e2adc9ccdb31468c60f401d50a1f510e1c02..1ca9969e5b22ddb892ef75ee5acb4c82f02533c1 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "Photoshop-Mischmodus"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "Animierte Bilder"
 
index 8f89fc0d42bc34dfbebb779aa9767de5ac354645..6207632d963d7c1eecf07286c50ffca2c1ca65dd 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "Advanced Blending"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "Animated Images"
 
index 8afbc950f466bd1ff7ea5ce5a60ba203a663243c..1c5dcc293d7371dee0307d9b2e8337d131e2b532 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "Advanced Blending"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "Animated Images"
 
index 6b4458ba5b579009c218f9381c6ceeaacb884376..ca08afad689439da0dec25b2f344f41a9d5fcc81 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "Modo de fusión"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "Imágenes animadas"
 
index 5e7552eaccc469945f59538398bbc1317ae48a0d..132017cf6e0a5a6a0eefcf3173dbbd2ed8f3bfdc 100755 (executable)
@@ -1,5 +1,8 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "Photoshop sekoitus tila"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
-msgstr "animoituja kuvia"
+msgstr "Animoituja kuvia"
 
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
 msgstr "Animoidut Muodot"
index e4b522a4c69b7a418b9c772f4a6ff1b0eff9bd17..dfbaee303aa5aa95028187395637de27dcd75ae1 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "포토샵 블렌드 모드"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "애니메이션 이미지"
 
index 8873d6263da55dff092aa5dd1eed9cbb9528a680..9a24c304a71b9853e4b0ec35e835fdb4f1485a47 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "ഫോട്ടോഷോപ്പ് ബ്ലെൻഡ് മോഡ്"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "അനിമേറ്റഡ് ചിത്രങ്ങൾ"
 
index 324368c77fb2941c3c4462ecf691fd7b88e70e89..204af542138b94b42f884bf384e1227d49e4622a 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "فوٹو شاپ بلینڈ موڈ"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "متحرک تصاویر"
 
index 68dfa53727312eb0f6d3f3527510a5fb88376387..d2809443ff030837ae4d4e10146acb5840502bc6 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "高级混合"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "动态图"
 
index b5884dc060ef71e60836b37829c9dd3ecb5eed73..f4b7a6b50b7df64bac960b1e20f619821ae668f9 100644 (file)
@@ -34,6 +34,7 @@ extern "C"
 
 #ifdef INTERNATIONALIZATION_ENABLED
 
+#define DALI_DEMO_STR_TITLE_ADVANCED_BLENDING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING")
 #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES")
 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES")
 #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES")
@@ -141,6 +142,7 @@ extern "C"
 
 #else // !INTERNATIONALIZATION_ENABLED
 
+#define DALI_DEMO_STR_TITLE_ADVANCED_BLENDING "Advanced Blending"
 #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES "Animated Images"
 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes"
 #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES "Animated Vector Images"