Commit 086a93e8dc4f5f0864230975f3ffcbdeeb08c1d9
1 parent
69ef99ba
Adding advanced blending example
Change-Id: Ib81a3376864a98e496ddb73256b698ec6c6f6250
Showing
15 changed files
with
209 additions
and
1 deletions
README.md
| @@ -187,3 +187,23 @@ To build, run: | @@ -187,3 +187,23 @@ To build, run: | ||
| 187 | ```zsh | 187 | ```zsh |
| 188 | % make install -j8 | 188 | % make install -j8 |
| 189 | ``` | 189 | ``` |
| 190 | + | ||
| 191 | +# Creating an example | ||
| 192 | +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. | ||
| 193 | +In this folder, you can add as many source code files as you need. | ||
| 194 | + | ||
| 195 | +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. | ||
| 196 | + | ||
| 197 | +There is a DemoHelper::CreateView method, which enables you to easiliy set up a title bar and buttons. | ||
| 198 | + | ||
| 199 | +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. | ||
| 200 | + | ||
| 201 | +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. | ||
| 202 | + | ||
| 203 | +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. | ||
| 204 | + | ||
| 205 | +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. | ||
| 206 | + | ||
| 207 | + | ||
| 208 | + | ||
| 209 | + |
com.samsung.dali-demo.xml
| @@ -19,6 +19,9 @@ | @@ -19,6 +19,9 @@ | ||
| 19 | 19 | ||
| 20 | <!-- PLEASE KEEP THE FOLLOWING IN ALPHABETICAL ORDER USING THE 'appid'. --> | 20 | <!-- PLEASE KEEP THE FOLLOWING IN ALPHABETICAL ORDER USING THE 'appid'. --> |
| 21 | 21 | ||
| 22 | + <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"> | ||
| 23 | + <label>Advanced Blending App</label> | ||
| 24 | + </ui-application> | ||
| 22 | <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"> | 25 | <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"> |
| 23 | <label>Call Active App</label> | 26 | <label>Call Active App</label> |
| 24 | </ui-application> | 27 | </ui-application> |
examples-reel/dali-examples-reel.cpp
| @@ -38,6 +38,7 @@ int DALI_EXPORT_API main(int argc, char** argv) | @@ -38,6 +38,7 @@ int DALI_EXPORT_API main(int argc, char** argv) | ||
| 38 | // Create the demo launcher | 38 | // Create the demo launcher |
| 39 | DaliTableView demo(app); | 39 | DaliTableView demo(app); |
| 40 | 40 | ||
| 41 | + demo.AddExample(Example("advanced-blend-mode.example", DALI_DEMO_STR_TITLE_ADVANCED_BLENDING)); | ||
| 41 | demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES)); | 42 | demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES)); |
| 42 | demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); | 43 | demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); |
| 43 | demo.AddExample(Example("animated-vector-images.example", DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES)); | 44 | demo.AddExample(Example("animated-vector-images.example", DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES)); |
examples/advanced-blend-mode/advanced-blend-mode-example.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2021 Samsung Electronics Co., Ltd. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | +#include <dali/devel-api/actors/actor-devel.h> | ||
| 20 | + | ||
| 21 | +#include <dali/devel-api/common/capabilities.h> | ||
| 22 | +#include <dali/integration-api/debug.h> | ||
| 23 | + | ||
| 24 | +using namespace Dali; | ||
| 25 | +using Dali::Toolkit::TextLabel; | ||
| 26 | + | ||
| 27 | +// This example shows how to create and display Hello World! using a simple TextActor | ||
| 28 | +// | ||
| 29 | +class AdvancedBlendModeController : public ConnectionTracker | ||
| 30 | +{ | ||
| 31 | +public: | ||
| 32 | + AdvancedBlendModeController(Application& application) | ||
| 33 | + : mApplication(application) | ||
| 34 | + { | ||
| 35 | + // Connect to the Application's Init signal | ||
| 36 | + mApplication.InitSignal().Connect(this, &AdvancedBlendModeController::Create); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + ~AdvancedBlendModeController() = default; // Nothing to do in destructor | ||
| 40 | + | ||
| 41 | + // The Init signal is received once (only) during the Application lifetime | ||
| 42 | + void Create(Application& application) | ||
| 43 | + { | ||
| 44 | + // Get a handle to the stage | ||
| 45 | + Window window = application.GetWindow(); | ||
| 46 | + window.SetBackgroundColor(Color::BLACK); | ||
| 47 | + | ||
| 48 | + Toolkit::ImageView imageView = Toolkit::ImageView::New(); | ||
| 49 | + Property::Map imagePropertyMap; | ||
| 50 | + imagePropertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE); | ||
| 51 | + imagePropertyMap.Insert(Toolkit::ImageVisual::Property::URL, DEMO_IMAGE_DIR "gallery-large-19.jpg"); | ||
| 52 | + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imagePropertyMap); | ||
| 53 | + imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); | ||
| 54 | + imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); | ||
| 55 | + imageView.SetProperty(Actor::Property::SIZE, Vector2(600, 600)); | ||
| 56 | + window.Add(imageView); | ||
| 57 | + | ||
| 58 | + Toolkit::Control control_1 = Toolkit::Control::New(); | ||
| 59 | + Property::Map colorVisualMap_1; | ||
| 60 | + colorVisualMap_1.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); | ||
| 61 | + colorVisualMap_1.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::RED); | ||
| 62 | + colorVisualMap_1.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true); | ||
| 63 | + control_1.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_1); | ||
| 64 | + control_1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); | ||
| 65 | + control_1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); | ||
| 66 | + control_1.SetProperty(Actor::Property::POSITION, Vector2(0, 0)); | ||
| 67 | + control_1.SetProperty(Actor::Property::SIZE, Vector2(600, 200)); | ||
| 68 | + if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN)) | ||
| 69 | + { | ||
| 70 | + control_1.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY); | ||
| 71 | + } | ||
| 72 | + window.Add(control_1); | ||
| 73 | + | ||
| 74 | + Toolkit::Control control_2 = Toolkit::Control::New(); | ||
| 75 | + Property::Map colorVisualMap_2; | ||
| 76 | + colorVisualMap_2.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); | ||
| 77 | + colorVisualMap_2.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::GREEN); | ||
| 78 | + colorVisualMap_2.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true); | ||
| 79 | + control_2.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_2); | ||
| 80 | + control_2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); | ||
| 81 | + control_2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); | ||
| 82 | + control_2.SetProperty(Actor::Property::POSITION, Vector2(0, 200)); | ||
| 83 | + control_2.SetProperty(Actor::Property::SIZE, Vector2(600, 200)); | ||
| 84 | + if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN)) | ||
| 85 | + { | ||
| 86 | + control_2.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY); | ||
| 87 | + } | ||
| 88 | + window.Add(control_2); | ||
| 89 | + | ||
| 90 | + Toolkit::Control control_3 = Toolkit::Control::New(); | ||
| 91 | + Property::Map colorVisualMap_3; | ||
| 92 | + colorVisualMap_3.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR); | ||
| 93 | + colorVisualMap_3.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Dali::Color::BLUE); | ||
| 94 | + colorVisualMap_3.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, true); | ||
| 95 | + control_3.SetProperty(Toolkit::Control::Property::BACKGROUND, colorVisualMap_3); | ||
| 96 | + control_3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); | ||
| 97 | + control_3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); | ||
| 98 | + control_3.SetProperty(Actor::Property::POSITION, Vector2(0, 400)); | ||
| 99 | + control_3.SetProperty(Actor::Property::SIZE, Vector2(600, 200)); | ||
| 100 | + if(Dali::Capabilities::IsBlendEquationSupported(Dali::DevelBlendEquation::SCREEN)) | ||
| 101 | + { | ||
| 102 | + control_3.SetProperty(Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::LUMINOSITY); | ||
| 103 | + } | ||
| 104 | + window.Add(control_3); | ||
| 105 | + | ||
| 106 | + // Add text to explain what's being seen. | ||
| 107 | + 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."); | ||
| 108 | + | ||
| 109 | + label[Toolkit::TextLabel::Property::MULTI_LINE] = true; | ||
| 110 | + label[Toolkit::TextLabel::Property::TEXT_COLOR] = Color::WHITE; | ||
| 111 | + label[Toolkit::TextLabel::Property::POINT_SIZE] = 12.0f; | ||
| 112 | + label[Actor::Property::PARENT_ORIGIN] = ParentOrigin::BOTTOM_CENTER; | ||
| 113 | + label[Actor::Property::ANCHOR_POINT] = AnchorPoint::BOTTOM_CENTER; | ||
| 114 | + label.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | ||
| 115 | + window.Add(label); | ||
| 116 | + | ||
| 117 | + // Respond to a touch anywhere on the window | ||
| 118 | + window.GetRootLayer().TouchedSignal().Connect(this, &AdvancedBlendModeController::OnTouch); | ||
| 119 | + | ||
| 120 | + // Respond to key events | ||
| 121 | + window.KeyEventSignal().Connect(this, &AdvancedBlendModeController::OnKeyEvent); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + bool OnTouch(Actor actor, const TouchEvent& touch) | ||
| 125 | + { | ||
| 126 | + // quit the application | ||
| 127 | + mApplication.Quit(); | ||
| 128 | + return true; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + void OnKeyEvent(const KeyEvent& event) | ||
| 132 | + { | ||
| 133 | + if(event.GetState() == KeyEvent::DOWN) | ||
| 134 | + { | ||
| 135 | + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) | ||
| 136 | + { | ||
| 137 | + mApplication.Quit(); | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | +private: | ||
| 143 | + Application& mApplication; | ||
| 144 | +}; | ||
| 145 | + | ||
| 146 | +int DALI_EXPORT_API main(int argc, char** argv) | ||
| 147 | +{ | ||
| 148 | + Application application = Application::New(&argc, &argv); | ||
| 149 | + AdvancedBlendModeController test(application); | ||
| 150 | + application.MainLoop(); | ||
| 151 | + return 0; | ||
| 152 | +} |
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
| 1 | +msgid "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING" | ||
| 2 | +msgstr "Photoshop sekoitus tila" | ||
| 3 | + | ||
| 1 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES" | 4 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES" |
| 2 | -msgstr "animoituja kuvia" | 5 | +msgstr "Animoituja kuvia" |
| 3 | 6 | ||
| 4 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES" | 7 | msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES" |
| 5 | msgstr "Animoidut Muodot" | 8 | msgstr "Animoidut Muodot" |
resources/po/ko.po
resources/po/ml.po
resources/po/ur.po
resources/po/zn_CH.po
shared/dali-demo-strings.h
| @@ -34,6 +34,7 @@ extern "C" | @@ -34,6 +34,7 @@ extern "C" | ||
| 34 | 34 | ||
| 35 | #ifdef INTERNATIONALIZATION_ENABLED | 35 | #ifdef INTERNATIONALIZATION_ENABLED |
| 36 | 36 | ||
| 37 | +#define DALI_DEMO_STR_TITLE_ADVANCED_BLENDING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ADVANCED_BLENDING") | ||
| 37 | #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES") | 38 | #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES") |
| 38 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES") | 39 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES") |
| 39 | #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES") | 40 | #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" | @@ -141,6 +142,7 @@ extern "C" | ||
| 141 | 142 | ||
| 142 | #else // !INTERNATIONALIZATION_ENABLED | 143 | #else // !INTERNATIONALIZATION_ENABLED |
| 143 | 144 | ||
| 145 | +#define DALI_DEMO_STR_TITLE_ADVANCED_BLENDING "Advanced Blending" | ||
| 144 | #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES "Animated Images" | 146 | #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES "Animated Images" |
| 145 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes" | 147 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes" |
| 146 | #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES "Animated Vector Images" | 148 | #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES "Animated Vector Images" |