Commit 48b652d8b892d08b1c273ab70afa3eeb88158e6e
1 parent
df3c45cd
Add color visual example
Change-Id: I7a424bc4bb90f53e2aa4e0a81f90d67550a30563
Showing
7 changed files
with
159 additions
and
3 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -58,6 +58,9 @@ |
| 58 | 58 | <ui-application appid="clipping.example" exec="/usr/apps/com.samsung.dali-demo/bin/clipping.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 59 | 59 | <label>Clipping</label> |
| 60 | 60 | </ui-application> |
| 61 | + <ui-application appid="color-visual.example" exec="/usr/apps/com.samsung.dali-demo/bin/color-visual.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 62 | + <label>Color Visual</label> | |
| 63 | + </ui-application> | |
| 61 | 64 | <ui-application appid="compressed-texture-formats.example" exec="/usr/apps/com.samsung.dali-demo/bin/compressed-texture-formats.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app"> |
| 62 | 65 | <label>Compressed Texture Formats</label> |
| 63 | 66 | </ui-application> | ... | ... |
examples-reel/dali-examples-reel.cpp
| ... | ... | @@ -47,6 +47,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 47 | 47 | demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS)); |
| 48 | 48 | demo.AddExample(Example("clipping.example", DALI_DEMO_STR_TITLE_CLIPPING)); |
| 49 | 49 | demo.AddExample(Example("clipping-draw-order.example", DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER)); |
| 50 | + demo.AddExample(Example("color-visual.example", DALI_DEMO_STR_TITLE_COLOR_VISUAL)); | |
| 50 | 51 | demo.AddExample(Example("deferred-shading.example", DALI_DEMO_STR_TITLE_DEFERRED_SHADING)); |
| 51 | 52 | demo.AddExample(Example("dissolve-effect.example", DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION)); |
| 52 | 53 | demo.AddExample(Example("drag-and-drop.example", DALI_DEMO_STR_TITLE_DRAG_AND_DROP)); | ... | ... |
examples/color-visual/color-visual-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2020 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-toolkit/devel-api/controls/control-devel.h> | |
| 20 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 21 | +#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h> | |
| 22 | +#include <dali-toolkit/devel-api/visual-factory/transition-data.h> | |
| 23 | + | |
| 24 | +using namespace Dali; | |
| 25 | +using namespace Dali::Toolkit; | |
| 26 | + | |
| 27 | +namespace | |
| 28 | +{ | |
| 29 | + | |
| 30 | +const char* IMAGE_FILE( DEMO_IMAGE_DIR "gallery-medium-1.jpg" ); | |
| 31 | + | |
| 32 | +const float BLUR_RADIUS_VALUE( 10.0f ); | |
| 33 | +const float NO_BLUR_VALUE( 0.0f ); | |
| 34 | +const float ANIMATION_DURATION( 2.0f ); | |
| 35 | + | |
| 36 | +const Property::Value SHADOW | |
| 37 | +{ | |
| 38 | + { Visual::Property::TYPE, Visual::COLOR }, | |
| 39 | + { Visual::Property::MIX_COLOR, Vector4( 0.0f, 0.0f, 0.0f, 0.5f ) }, | |
| 40 | + { Visual::Property::TRANSFORM, Property::Map{ { Visual::Transform::Property::OFFSET, Vector2( 0.05f, 0.05f ) }, | |
| 41 | + { Visual::Transform::Property::SIZE, Vector2( 1.05f, 1.05f ) }, | |
| 42 | + { Visual::Transform::Property::ORIGIN, Align::CENTER }, | |
| 43 | + { Visual::Transform::Property::ANCHOR_POINT, Align::CENTER } } }, | |
| 44 | + { DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_VALUE } | |
| 45 | +}; | |
| 46 | + | |
| 47 | +} // namespace | |
| 48 | + | |
| 49 | +// This example shows the blur radius property of the color visual and animates it. | |
| 50 | +// | |
| 51 | +class ColorVisualExample : public ConnectionTracker | |
| 52 | +{ | |
| 53 | +public: | |
| 54 | + | |
| 55 | + ColorVisualExample( Application& application ) | |
| 56 | + : mApplication( application ), | |
| 57 | + mShadowVisible( true ) | |
| 58 | + { | |
| 59 | + // Connect to the Application's Init signal | |
| 60 | + mApplication.InitSignal().Connect( this, &ColorVisualExample::Create ); | |
| 61 | + } | |
| 62 | + | |
| 63 | + ~ColorVisualExample() | |
| 64 | + { | |
| 65 | + // Nothing to do here; | |
| 66 | + } | |
| 67 | + | |
| 68 | + // The Init signal is received once (only) during the Application lifetime | |
| 69 | + void Create( Application& application ) | |
| 70 | + { | |
| 71 | + // Get a handle to the stage | |
| 72 | + Stage stage = Stage::GetCurrent(); | |
| 73 | + stage.SetBackgroundColor( Color::WHITE ); | |
| 74 | + | |
| 75 | + mImageView = ImageView::New( IMAGE_FILE ); | |
| 76 | + mImageView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 77 | + mImageView.SetSize( 200.0f, 200.0f ); | |
| 78 | + mImageView.SetProperty( DevelControl::Property::SHADOW, SHADOW ); | |
| 79 | + | |
| 80 | + stage.Add( mImageView ); | |
| 81 | + | |
| 82 | + // Respond to a click anywhere on the stage | |
| 83 | + stage.GetRootLayer().TouchSignal().Connect( this, &ColorVisualExample::OnTouch ); | |
| 84 | + | |
| 85 | + // Respond to key events | |
| 86 | + stage.KeyEventSignal().Connect( this, &ColorVisualExample::OnKeyEvent ); | |
| 87 | + } | |
| 88 | + | |
| 89 | + bool OnTouch( Actor actor, const TouchData& touch ) | |
| 90 | + { | |
| 91 | + if( touch.GetState( 0 ) == PointState::UP ) | |
| 92 | + { | |
| 93 | + float initialValue, targetValue; | |
| 94 | + if( !mShadowVisible ) | |
| 95 | + { | |
| 96 | + initialValue = NO_BLUR_VALUE; | |
| 97 | + targetValue = BLUR_RADIUS_VALUE; | |
| 98 | + } | |
| 99 | + else | |
| 100 | + { | |
| 101 | + initialValue = BLUR_RADIUS_VALUE; | |
| 102 | + targetValue = NO_BLUR_VALUE; | |
| 103 | + } | |
| 104 | + | |
| 105 | + mShadowVisible = !mShadowVisible; | |
| 106 | + | |
| 107 | + TransitionData transitionData = TransitionData::New( Property::Map().Add( "target", "shadow" ) | |
| 108 | + .Add( "property", "blurRadius" ) | |
| 109 | + .Add( "initialValue", initialValue ) | |
| 110 | + .Add( "targetValue", targetValue ) | |
| 111 | + .Add( "animator", Property::Map().Add( "duration", ANIMATION_DURATION ) ) ); | |
| 112 | + Animation animation = DevelControl::CreateTransition( Toolkit::Internal::GetImplementation( mImageView ), transitionData ); | |
| 113 | + animation.Play(); | |
| 114 | + } | |
| 115 | + return true; | |
| 116 | + } | |
| 117 | + | |
| 118 | + void OnKeyEvent( const KeyEvent& event ) | |
| 119 | + { | |
| 120 | + if( event.state == KeyEvent::Down ) | |
| 121 | + { | |
| 122 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 123 | + { | |
| 124 | + mApplication.Quit(); | |
| 125 | + } | |
| 126 | + } | |
| 127 | + } | |
| 128 | + | |
| 129 | +private: | |
| 130 | + Application& mApplication; | |
| 131 | + ImageView mImageView; | |
| 132 | + bool mShadowVisible; | |
| 133 | +}; | |
| 134 | + | |
| 135 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 136 | +{ | |
| 137 | + Application application = Application::New( &argc, &argv ); | |
| 138 | + ColorVisualExample test( application ); | |
| 139 | + application.MainLoop(); | |
| 140 | + return 0; | |
| 141 | +} | ... | ... |
resources/po/en_GB.po
| ... | ... | @@ -43,6 +43,9 @@ msgstr "Clipping" |
| 43 | 43 | msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER" |
| 44 | 44 | msgstr "Clipping Draw Order" |
| 45 | 45 | |
| 46 | +msgid "DALI_DEMO_STR_TITLE_COLOR_VISUAL" | |
| 47 | +msgstr "Colour Visual" | |
| 48 | + | |
| 46 | 49 | msgid "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW" |
| 47 | 50 | msgstr "Gaussian Blur" |
| 48 | 51 | ... | ... |
resources/po/en_US.po
| ... | ... | @@ -43,6 +43,9 @@ msgstr "Clipping" |
| 43 | 43 | msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER" |
| 44 | 44 | msgstr "Clipping Draw Order" |
| 45 | 45 | |
| 46 | +msgid "DALI_DEMO_STR_TITLE_COLOR_VISUAL" | |
| 47 | +msgstr "Color Visual" | |
| 48 | + | |
| 46 | 49 | msgid "DALI_DEMO_STR_TITLE_DEFERRED_SHADING" |
| 47 | 50 | msgstr "Deferred Shading" |
| 48 | 51 | ... | ... |
resources/po/ko.po
| ... | ... | @@ -5,7 +5,7 @@ msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES" |
| 5 | 5 | msgstr "애니메이션 모양" |
| 6 | 6 | |
| 7 | 7 | msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT" |
| 8 | -msgstr "기본 표시 등" | |
| 8 | +msgstr "기본 조명" | |
| 9 | 9 | |
| 10 | 10 | msgid "DALI_DEMO_STR_TITLE_BLOCKS" |
| 11 | 11 | msgstr "블록" |
| ... | ... | @@ -23,16 +23,19 @@ msgid "DALI_DEMO_STR_TITLE_CARD_ACTIVE" |
| 23 | 23 | msgstr "NFC 카드 태깅" |
| 24 | 24 | |
| 25 | 25 | msgid "DALI_DEMO_STR_TITLE_CLIPPING" |
| 26 | -msgstr "깎는" | |
| 26 | +msgstr "클리핑" | |
| 27 | 27 | |
| 28 | 28 | msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER" |
| 29 | 29 | msgstr "드로잉 순서를 클리핑" |
| 30 | 30 | |
| 31 | +msgid "DALI_DEMO_STR_TITLE_COLOR_VISUAL" | |
| 32 | +msgstr "색상 비주얼" | |
| 33 | + | |
| 31 | 34 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 32 | 35 | msgstr "색상 그라디언트" |
| 33 | 36 | |
| 34 | 37 | msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" |
| 35 | -msgstr "접촉" | |
| 38 | +msgstr "연락처" | |
| 36 | 39 | |
| 37 | 40 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 38 | 41 | msgstr "입방체 전환" | ... | ... |
shared/dali-demo-strings.h
| ... | ... | @@ -49,6 +49,7 @@ extern "C" |
| 49 | 49 | #define DALI_DEMO_STR_TITLE_CARD_ACTIVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CARD_ACTIVE") |
| 50 | 50 | #define DALI_DEMO_STR_TITLE_CLIPPING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING") |
| 51 | 51 | #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER") |
| 52 | +#define DALI_DEMO_STR_TITLE_COLOR_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COLOR_VISUAL") | |
| 52 | 53 | #define DALI_DEMO_STR_TITLE_DEFERRED_SHADING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_DEFERRED_SHADING") |
| 53 | 54 | #define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW") |
| 54 | 55 | #define DALI_DEMO_STR_TITLE_GESTURES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GESTURES") |
| ... | ... | @@ -149,6 +150,7 @@ extern "C" |
| 149 | 150 | #define DALI_DEMO_STR_TITLE_CARD_ACTIVE "Card Active" |
| 150 | 151 | #define DALI_DEMO_STR_TITLE_CLIPPING "Clipping" |
| 151 | 152 | #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER "Clipping Draw Order" |
| 153 | +#define DALI_DEMO_STR_TITLE_COLOR_VISUAL "Color Visual" | |
| 152 | 154 | #define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW "Gaussian Blur" |
| 153 | 155 | #define DALI_DEMO_STR_TITLE_GESTURES "Gestures" |
| 154 | 156 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT "Color Gradient" | ... | ... |