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 29c195f..3201631 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 622c301..2c46609 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 e1ba60d..63ead6e 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 bab37b3..d5931ff 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "ফটোশ্বপ ব্লেণ্ড মোড"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "অ্যানিমেটেড ইমেজ"
 
index 6190e2a..1ca9969 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 8f89fc0..6207632 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 8afbc95..1c5dcc2 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 6b4458b..ca08afa 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 5e7552e..132017c 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 e4b522a..dfbaee3 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "포토샵 블렌드 모드"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "애니메이션 이미지"
 
index 8873d62..9a24c30 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "ഫോട്ടോഷോപ്പ് ബ്ലെൻഡ് മോഡ്"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "അനിമേറ്റഡ് ചിത്രങ്ങൾ"
 
index 324368c..204af54 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "فوٹو شاپ بلینڈ موڈ"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "متحرک تصاویر"
 
index 68dfa53..d280944 100755 (executable)
@@ -1,3 +1,6 @@
+msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING"
+msgstr "高级混合"
+
 msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES"
 msgstr "动态图"
 
index b5884dc..f4b7a6b 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"