Commit 801203c5a8996311535eb8e6d944e6b5aee326af

Authored by Paul Wisbey
1 parent 88009136

Gaussian blur demos

Change-Id: I5339a44b6df5826ba7c9ad8f7ec3ae2328e8c966
com.samsung.dali-demo.xml
... ... @@ -299,6 +299,12 @@
299 299 <ui-application appid="visual-fitting-mode.example" exec="/usr/apps/com.samsung.dali-demo/bin/visual-fitting-mode.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
300 300 <label>Visual Fitting Mode</label>
301 301 </ui-application>
  302 + <ui-application appid="gaussian-blur-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/gaussian-blur-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  303 + <label>Gaussian Blur</label>
  304 + </ui-application>
  305 + <ui-application appid="super-blur-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/super-blur-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  306 + <label>Super Blur</label>
  307 + </ui-application>
302 308  
303 309 <privileges>
304 310 <privilege>http://tizen.org/privilege/mediastorage</privilege>
... ...
examples-reel/dali-examples-reel.cpp
... ... @@ -50,6 +50,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
50 50 demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND));
51 51 demo.AddExample(Example("frame-callback.example", DALI_DEMO_STR_TITLE_FRAME_CALLBACK));
52 52 demo.AddExample(Example("focus-integration.example", DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION));
  53 + demo.AddExample(Example("gaussian-blur-view.example", DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW));
53 54 demo.AddExample(Example("gestures.example", DALI_DEMO_STR_TITLE_GESTURES));
54 55 demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT));
55 56 demo.AddExample(Example("hello-world.example", DALI_DEMO_STR_TITLE_HELLO_WORLD));
... ... @@ -80,6 +81,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
80 81 demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW));
81 82 demo.AddExample(Example("size-negotiation.example", DALI_DEMO_STR_TITLE_NEGOTIATE_SIZE));
82 83 demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING));
  84 + demo.AddExample(Example("super-blur-view.example", DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW));
83 85 demo.AddExample(Example("text-editor.example", DALI_DEMO_STR_TITLE_TEXT_EDITOR));
84 86 demo.AddExample(Example("text-field.example", DALI_DEMO_STR_TITLE_TEXT_FIELD));
85 87 demo.AddExample(Example("text-label.example", DALI_DEMO_STR_TITLE_TEXT_LABEL));
... ...
examples/gaussian-blur-view/gaussian-blur-view-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2019 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 <algorithm>
  19 +
  20 +#include <dali-toolkit/dali-toolkit.h>
  21 +#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
  22 +
  23 +using namespace Dali;
  24 +using Dali::Toolkit::TextLabel;
  25 +using Dali::Toolkit::GaussianBlurView;
  26 +
  27 +namespace
  28 +{
  29 +
  30 +const char* const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" );
  31 +const float BACKGROUND_IMAGE_WIDTH = 2048.0f;
  32 +
  33 +}
  34 +
  35 +/**
  36 + * This example shows a scrolling background image which can be blurred (on/off) by tapping the screen
  37 + */
  38 +class GaussianBlurViewExample : public ConnectionTracker
  39 +{
  40 +public:
  41 +
  42 + GaussianBlurViewExample( Application& application )
  43 + : mApplication( application ),
  44 + mExcessWidth( 0.0f ),
  45 + mStrength( 1.0f )
  46 + {
  47 + mApplication.InitSignal().Connect( this, &GaussianBlurViewExample::Create );
  48 + }
  49 +
  50 + ~GaussianBlurViewExample() = default;
  51 +
  52 +private:
  53 +
  54 + void Create( Application& application )
  55 + {
  56 + Stage stage = Stage::GetCurrent();
  57 + Vector2 stageSize = stage.GetSize();
  58 + stage.KeyEventSignal().Connect(this, &GaussianBlurViewExample::OnKeyEvent);
  59 +
  60 + mImageView = Toolkit::ImageView::New( BACKGROUND_IMAGE );
  61 + mImageView.SetParentOrigin( ParentOrigin::CENTER );
  62 + mImageView.SetAnchorPoint( AnchorPoint::CENTER );
  63 +
  64 + stage.Add( mImageView );
  65 +
  66 + float excessWidth = std::max( 0.0f, (BACKGROUND_IMAGE_WIDTH - stageSize.width) * 0.5f );
  67 +
  68 + if( excessWidth > 0.0f )
  69 + {
  70 + // Move background image to show GaussianBlurView activity
  71 +
  72 + float pixelsPerSecond = 10.0f;
  73 + float duration = excessWidth / pixelsPerSecond;
  74 + float qDuration = duration * 0.25f;
  75 +
  76 + mAnimation = Animation::New( duration );
  77 + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), excessWidth, TimePeriod(0.0f , qDuration) );
  78 + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(qDuration , qDuration) );
  79 + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), -excessWidth, TimePeriod(2.0f*qDuration, qDuration) );
  80 + mAnimation.AnimateTo( Property(mImageView, Actor::Property::POSITION_X), 0.0f, TimePeriod(3.0f*qDuration, qDuration) );
  81 +
  82 + mAnimation.SetLooping( true );
  83 + mAnimation.Play();
  84 + }
  85 +
  86 + Layer onTop = Layer::New();
  87 + onTop.SetParentOrigin( ParentOrigin::CENTER );
  88 + onTop.SetAnchorPoint( AnchorPoint::CENTER );
  89 + onTop.SetSize( stageSize );
  90 + stage.Add( onTop );
  91 + onTop.RaiseToTop();
  92 +
  93 + mOnLabel = TextLabel::New( "Blur ON" );
  94 + mOnLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  95 + mOnLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
  96 + mOnLabel.SetVisible( false );
  97 + onTop.Add( mOnLabel );
  98 +
  99 + mOffLabel = TextLabel::New( "Blur OFF" );
  100 + mOffLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  101 + mOffLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE );
  102 + mOffLabel.SetVisible( true );
  103 + onTop.Add( mOffLabel );
  104 +
  105 + stage.GetRootLayer().TouchSignal().Connect( this, &GaussianBlurViewExample::OnTouch );
  106 + }
  107 +
  108 + bool OnTouch( Actor actor, const TouchData& touch )
  109 + {
  110 + const PointState::Type state = touch.GetState( 0 );
  111 +
  112 + if( PointState::DOWN == state )
  113 + {
  114 + Stage stage = Stage::GetCurrent();
  115 +
  116 + // Enable/disable blur effect
  117 +
  118 + if( !mGaussianBlurView )
  119 + {
  120 + mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false );
  121 + mGaussianBlurView.SetParentOrigin( ParentOrigin::CENTER );
  122 + mGaussianBlurView.SetAnchorPoint( AnchorPoint::CENTER );
  123 + mGaussianBlurView.SetSize( stage.GetSize() );
  124 + stage.Add( mGaussianBlurView );
  125 +
  126 + mGaussianBlurView.Add( mImageView );
  127 + mGaussianBlurView.Activate();
  128 +
  129 + mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength );
  130 +
  131 + mOnLabel.SetVisible( true );
  132 + mOffLabel.SetVisible( false );
  133 + }
  134 + else
  135 + {
  136 + stage.Add( mImageView );
  137 +
  138 + UnparentAndReset( mGaussianBlurView );
  139 +
  140 + mOnLabel.SetVisible( false );
  141 + mOffLabel.SetVisible( true );
  142 + }
  143 +
  144 + }
  145 +
  146 + return true;
  147 + }
  148 +
  149 + void OnKeyEvent(const KeyEvent& event)
  150 + {
  151 + if(event.state == KeyEvent::Down)
  152 + {
  153 + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
  154 + {
  155 + mApplication.Quit();
  156 + }
  157 + }
  158 + }
  159 +
  160 +private:
  161 +
  162 + Application& mApplication;
  163 +
  164 + Toolkit::ImageView mImageView;
  165 +
  166 + Animation mAnimation;
  167 +
  168 + TextLabel mOnLabel;
  169 + TextLabel mOffLabel;
  170 +
  171 + GaussianBlurView mGaussianBlurView;
  172 +
  173 + float mExcessWidth;
  174 + float mStrength;
  175 +};
  176 +
  177 +int DALI_EXPORT_API main( int argc, char **argv )
  178 +{
  179 + Application application = Application::New( &argc, &argv );
  180 +
  181 + GaussianBlurViewExample test( application );
  182 +
  183 + application.MainLoop();
  184 +
  185 + return 0;
  186 +}
... ...
examples/super-blur-view/super-blur-view-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2019 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/dali.h>
  19 +#include <dali-toolkit/dali-toolkit.h>
  20 +#include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h>
  21 +
  22 +using namespace Dali;
  23 +using Dali::Toolkit::Button;
  24 +using Dali::Toolkit::PushButton;
  25 +using Dali::Toolkit::SuperBlurView;
  26 +
  27 +namespace
  28 +{
  29 +
  30 +const char* const BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-4.jpg" );
  31 +
  32 +const unsigned int DEFAULT_BLUR_LEVEL(5u); ///< The default blur level when creating SuperBlurView from the type registry
  33 +
  34 +}
  35 +
  36 +/**
  37 + * This example shows a background image which is "super blurred" while the push-button control is pressed.
  38 + */
  39 +class SuperBlurViewExample : public ConnectionTracker
  40 +{
  41 +public:
  42 +
  43 + SuperBlurViewExample( Application& application )
  44 + : mApplication( application )
  45 + {
  46 + mApplication.InitSignal().Connect( this, &SuperBlurViewExample::Create );
  47 + }
  48 +
  49 + ~SuperBlurViewExample() = default;
  50 +
  51 +private:
  52 +
  53 + void Create( Application& application )
  54 + {
  55 + Stage stage = Stage::GetCurrent();
  56 + stage.KeyEventSignal().Connect( this, &SuperBlurViewExample::OnKeyEvent );
  57 +
  58 + mSuperBlurView = SuperBlurView::New( DEFAULT_BLUR_LEVEL );
  59 + mSuperBlurView.SetParentOrigin( ParentOrigin::CENTER );
  60 + mSuperBlurView.SetAnchorPoint( AnchorPoint::CENTER );
  61 + mSuperBlurView.SetSize( 800, 1280 );
  62 + mSuperBlurView.SetProperty( SuperBlurView::Property::IMAGE_URL, BACKGROUND_IMAGE );
  63 + stage.Add( mSuperBlurView );
  64 +
  65 + mBlurAnimation = Animation::New(1.0f);
  66 + mBlurAnimation.AnimateTo( Property(mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex()), 1.0f );
  67 +
  68 + mClearAnimation = Animation::New(1.0f);
  69 + mClearAnimation.AnimateTo( Property(mSuperBlurView, mSuperBlurView.GetBlurStrengthPropertyIndex()), 0.0f );
  70 +
  71 + mPushButton = PushButton::New();
  72 + mPushButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
  73 + mPushButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
  74 + mPushButton.SetProperty( Button::Property::LABEL_TEXT, "Blur" );
  75 + mPushButton.PressedSignal().Connect( this, &SuperBlurViewExample::OnButtonPressed );
  76 + mPushButton.ReleasedSignal().Connect( this, &SuperBlurViewExample::OnButtonReleased );
  77 + stage.Add( mPushButton );
  78 + }
  79 +
  80 + bool OnButtonPressed( Button button )
  81 + {
  82 + mBlurAnimation.Play();
  83 + return true;
  84 + }
  85 +
  86 + bool OnButtonReleased( Button button )
  87 + {
  88 + mClearAnimation.Play();
  89 + return true;
  90 + }
  91 +
  92 + void OnKeyEvent( const KeyEvent& event )
  93 + {
  94 + if ( event.state == KeyEvent::Down )
  95 + {
  96 + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
  97 + {
  98 + mApplication.Quit();
  99 + }
  100 + }
  101 + }
  102 +
  103 +private:
  104 +
  105 + Application& mApplication;
  106 +
  107 + SuperBlurView mSuperBlurView;
  108 +
  109 + PushButton mPushButton;
  110 +
  111 + Animation mBlurAnimation;
  112 + Animation mClearAnimation;
  113 +};
  114 +
  115 +int DALI_EXPORT_API main( int argc, char **argv )
  116 +{
  117 + Application application = Application::New( &argc, &argv );
  118 +
  119 + SuperBlurViewExample test( application );
  120 +
  121 + application.MainLoop();
  122 +
  123 + return 0;
  124 +}
... ...
resources/po/en_GB.po
... ... @@ -40,6 +40,9 @@ msgstr &quot;Clipping&quot;
40 40 msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER"
41 41 msgstr "Clipping Draw Order"
42 42  
  43 +msgid "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW"
  44 +msgstr "Gaussian Blur"
  45 +
43 46 msgid "DALI_DEMO_STR_TITLE_GESTURES"
44 47 msgstr "Gestures"
45 48  
... ... @@ -181,6 +184,9 @@ msgstr &quot;Sparkle&quot;
181 184 msgid "DALI_DEMO_STR_TITLE_STYLING"
182 185 msgstr "Styling"
183 186  
  187 +msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW"
  188 +msgstr "Super Blur"
  189 +
184 190 msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
185 191 msgstr "Mesh Texture"
186 192  
... ...
resources/po/en_US.po
... ... @@ -40,6 +40,9 @@ msgstr &quot;Clipping&quot;
40 40 msgid "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER"
41 41 msgstr "Clipping Draw Order"
42 42  
  43 +msgid "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW"
  44 +msgstr "Gaussian Blur"
  45 +
43 46 msgid "DALI_DEMO_STR_TITLE_GESTURES"
44 47 msgstr "Gestures"
45 48  
... ... @@ -184,6 +187,9 @@ msgstr &quot;Sparkle&quot;
184 187 msgid "DALI_DEMO_STR_TITLE_STYLING"
185 188 msgstr "Styling"
186 189  
  190 +msgid "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW"
  191 +msgstr "Super Blur"
  192 +
187 193 msgid "DALI_DEMO_STR_TITLE_TEXTURED_MESH"
188 194 msgstr "Mesh Texture"
189 195  
... ...
resources/scripts/super-blur-view.json
... ... @@ -52,9 +52,7 @@
52 52 "parentOrigin": "TOP_CENTER",
53 53 "anchorPoint": "TOP_CENTER",
54 54 "size": [800, 1280, 0],
55   - "image": {
56   - "filename": "{DEMO_IMAGE_DIR}background-4.jpg"
57   - }
  55 + "imageUrl": "{DEMO_IMAGE_DIR}background-4.jpg"
58 56 },
59 57  
60 58 // Button to blur/clear
... ...
shared/dali-demo-strings.h
... ... @@ -46,6 +46,7 @@ extern &quot;C&quot;
46 46 #define DALI_DEMO_STR_TITLE_CARD_ACTIVE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CARD_ACTIVE")
47 47 #define DALI_DEMO_STR_TITLE_CLIPPING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING")
48 48 #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER")
  49 +#define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW")
49 50 #define DALI_DEMO_STR_TITLE_GESTURES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_GESTURES")
50 51 #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COLOR_GRADIENT")
51 52 #define DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS")
... ... @@ -105,6 +106,7 @@ extern &quot;C&quot;
105 106 #define DALI_DEMO_STR_TITLE_SKYBOX dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SKYBOX")
106 107 #define DALI_DEMO_STR_TITLE_SPARKLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SPARKLE")
107 108 #define DALI_DEMO_STR_TITLE_STYLING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_STYLING")
  109 +#define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW")
108 110 #define DALI_DEMO_STR_TITLE_TEXTURED_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXTURED_MESH")
109 111 #define DALI_DEMO_STR_TITLE_TEXT_EDITOR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_EDITOR")
110 112 #define DALI_DEMO_STR_TITLE_TEXT_FIELD dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_TEXT_FIELD")
... ... @@ -139,6 +141,7 @@ extern &quot;C&quot;
139 141 #define DALI_DEMO_STR_TITLE_CARD_ACTIVE "Card Active"
140 142 #define DALI_DEMO_STR_TITLE_CLIPPING "Clipping"
141 143 #define DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER "Clipping Draw Order"
  144 +#define DALI_DEMO_STR_TITLE_GAUSSIAN_BLUR_VIEW "Gaussian Blur"
142 145 #define DALI_DEMO_STR_TITLE_GESTURES "Gestures"
143 146 #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT "Color Gradient"
144 147 #define DALI_DEMO_STR_TITLE_COMPRESSED_TEXTURE_FORMATS "Compressed Texture Formats"
... ... @@ -198,6 +201,7 @@ extern &quot;C&quot;
198 201 #define DALI_DEMO_STR_TITLE_SKYBOX "Skybox"
199 202 #define DALI_DEMO_STR_TITLE_SPARKLE "Sparkle"
200 203 #define DALI_DEMO_STR_TITLE_STYLING "Styling"
  204 +#define DALI_DEMO_STR_TITLE_SUPER_BLUR_VIEW "Super Blur"
201 205 #define DALI_DEMO_STR_TITLE_TEXTURED_MESH "Mesh Texture"
202 206 #define DALI_DEMO_STR_TITLE_TEXT_EDITOR "Text Editor"
203 207 #define DALI_DEMO_STR_TITLE_TEXT_FIELD "Text Field"
... ...