Commit 0281ae371a982881da982aa83317f411f17f11c0

Authored by Heeyong Song
1 parent 48b652d8

Add arc visual example

Change-Id: I54af064b6e2abcdd40dad6eecdbb21b98e1eeab5
com.samsung.dali-demo.xml
... ... @@ -31,6 +31,9 @@
31 31 <ui-application appid="animated-shapes.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-shapes.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
32 32 <label>Animated shapes</label>
33 33 </ui-application>
  34 + <ui-application appid="arc-visual.example" exec="/usr/apps/com.samsung.dali-demo/bin/arc-visual.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  35 + <label>Arc Visual</label>
  36 + </ui-application>
34 37 <ui-application appid="benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
35 38 <label>Benchmark</label>
36 39 </ui-application>
... ...
examples-reel/dali-examples-reel.cpp
... ... @@ -42,6 +42,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
42 42 demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES));
43 43 demo.AddExample(Example("animated-vector-images.example", DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES));
44 44 demo.AddExample(Example("alpha-blending-cpu.example", DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU));
  45 + demo.AddExample(Example("arc-visual.example", DALI_DEMO_STR_TITLE_ARC_VISUAL));
45 46 demo.AddExample(Example("bloom-view.example", DALI_DEMO_STR_TITLE_BLOOM_VIEW));
46 47 demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
47 48 demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS));
... ...
examples/arc-visual/arc-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/arc-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 float START_ANGLE_INITIAL_VALUE( 0.0f );
  31 +const float START_ANGLE_TARGET_VALUE( 360.0f );
  32 +const float SWEEP_ANGLE_INITIAL_VALUE( 90.0f );
  33 +const float SWEEP_ANGLE_TARGET_VALUE( 360.0f );
  34 +const float ANIMATION_DURATION( 5.0f );
  35 +
  36 +const Property::Value BACKGROUND
  37 +{
  38 + { Visual::Property::TYPE, DevelVisual::ARC },
  39 + { Visual::Property::MIX_COLOR, Color::RED },
  40 + { DevelArcVisual::Property::START_ANGLE, 0.0f },
  41 + { DevelArcVisual::Property::SWEEP_ANGLE, 90.0f },
  42 + { DevelArcVisual::Property::CAP, DevelArcVisual::Cap::ROUND },
  43 + { DevelArcVisual::Property::THICKNESS, 20.0f }
  44 +};
  45 +
  46 +} // namespace
  47 +
  48 +// This example shows the properties of the arc visual - thickness, startAngle and sweepAngle and animates them.
  49 +//
  50 +class ArcVisualExample : public ConnectionTracker
  51 +{
  52 +public:
  53 +
  54 + ArcVisualExample( Application& application )
  55 + : mApplication( application ),
  56 + mStartAngle( 0.0f ),
  57 + mSweepAngle( 0.0f )
  58 + {
  59 + // Connect to the Application's Init signal
  60 + mApplication.InitSignal().Connect( this, &ArcVisualExample::Create );
  61 + }
  62 +
  63 + ~ArcVisualExample() = default;
  64 +
  65 +private:
  66 +
  67 + // The Init signal is received once (only) during the Application lifetime
  68 + void Create( Application& application )
  69 + {
  70 + // Get a handle to the stage
  71 + Stage stage = Stage::GetCurrent();
  72 + stage.SetBackgroundColor( Color::WHITE );
  73 +
  74 + mControl = Control::New();
  75 + mControl.SetParentOrigin( ParentOrigin::CENTER );
  76 + mControl.SetSize( 200.0f, 200.0f );
  77 + mControl.SetProperty( Control::Property::BACKGROUND, BACKGROUND );
  78 +
  79 + stage.Add( mControl );
  80 +
  81 + // Respond to a click anywhere on the stage
  82 + stage.GetRootLayer().TouchSignal().Connect( this, &ArcVisualExample::OnTouch );
  83 +
  84 + // Respond to key events
  85 + stage.KeyEventSignal().Connect( this, &ArcVisualExample::OnKeyEvent );
  86 + }
  87 +
  88 + bool OnTouch( Actor actor, const TouchData& touch )
  89 + {
  90 + if( touch.GetState( 0 ) == PointState::UP )
  91 + {
  92 + Property::Array array;
  93 + array.PushBack( Property::Map().Add( "target", "background" )
  94 + .Add( "property", "startAngle" )
  95 + .Add( "initialValue", START_ANGLE_INITIAL_VALUE )
  96 + .Add( "targetValue", START_ANGLE_TARGET_VALUE )
  97 + .Add( "animator", Property::Map().Add( "duration", ANIMATION_DURATION ) ) );
  98 + array.PushBack( Property::Map().Add( "target", "background" )
  99 + .Add( "property", "sweepAngle" )
  100 + .Add( "initialValue", SWEEP_ANGLE_INITIAL_VALUE )
  101 + .Add( "targetValue", SWEEP_ANGLE_TARGET_VALUE )
  102 + .Add( "animator", Property::Map().Add( "duration", ANIMATION_DURATION ) ) );
  103 +
  104 + TransitionData transitionData = TransitionData::New( array );
  105 + Animation animation = DevelControl::CreateTransition( Toolkit::Internal::GetImplementation( mControl ), transitionData );
  106 + animation.Play();
  107 + }
  108 + return true;
  109 + }
  110 +
  111 + void OnKeyEvent( const KeyEvent& event )
  112 + {
  113 + if( event.state == KeyEvent::Down )
  114 + {
  115 + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
  116 + {
  117 + mApplication.Quit();
  118 + }
  119 + }
  120 + }
  121 +
  122 +private:
  123 + Application& mApplication;
  124 + Control mControl;
  125 + float mStartAngle;
  126 + float mSweepAngle;
  127 +};
  128 +
  129 +int DALI_EXPORT_API main( int argc, char **argv )
  130 +{
  131 + Application application = Application::New( &argc, &argv );
  132 + ArcVisualExample test( application );
  133 + application.MainLoop();
  134 + return 0;
  135 +}
... ...
resources/po/en_GB.po
... ... @@ -7,6 +7,9 @@ msgstr &quot;Animated Shapes&quot;
7 7 msgid "DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU"
8 8 msgstr "CPU Alpha Blending"
9 9  
  10 +msgid "DALI_DEMO_STR_TITLE_ARC_VISUAL"
  11 +msgstr "Arc Visual"
  12 +
10 13 msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
11 14 msgstr "Basic Light"
12 15  
... ...
resources/po/en_US.po
... ... @@ -7,6 +7,9 @@ msgstr &quot;Animated Shapes&quot;
7 7 msgid "DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU"
8 8 msgstr "CPU Alpha Blending"
9 9  
  10 +msgid "DALI_DEMO_STR_TITLE_ARC_VISUAL"
  11 +msgstr "Arc Visual"
  12 +
10 13 msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
11 14 msgstr "Basic Light"
12 15  
... ...
resources/po/ko.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;애니메이션 이미지&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "애니메이션 모양"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_ARC_VISUAL"
  8 +msgstr "호 비주얼"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
8 11 msgstr "기본 조명"
9 12  
... ...
shared/dali-demo-strings.h
... ... @@ -38,6 +38,7 @@ extern &quot;C&quot;
38 38 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES")
39 39 #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES")
40 40 #define DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU")
  41 +#define DALI_DEMO_STR_TITLE_ARC_VISUAL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ARC_VISUAL")
41 42 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BASIC_LIGHT")
42 43 #define DALI_DEMO_STR_TITLE_BENCHMARK dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BENCHMARK")
43 44 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BEZIER_CURVE")
... ... @@ -139,6 +140,7 @@ extern &quot;C&quot;
139 140 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes"
140 141 #define DALI_DEMO_STR_TITLE_ANIMATED_VECTOR_IMAGES "Animated Vector Images"
141 142 #define DALI_DEMO_STR_TITLE_ALPHA_BLENDING_CPU "CPU Alpha Blending"
  143 +#define DALI_DEMO_STR_TITLE_ARC_VISUAL "Arc Visual"
142 144 #define DALI_DEMO_STR_TITLE_BASIC_LIGHT "Basic Light"
143 145 #define DALI_DEMO_STR_TITLE_BENCHMARK "ImageView Benchmark"
144 146 #define DALI_DEMO_STR_TITLE_BEZIER_CURVE "Alpha Function Bezier Curve"
... ...