Commit bec7666cee2534e16bf080b9b94ed0ccc9a5f6a5
1 parent
4b01383a
Added Animated Gif example
Change-Id: I609238663f1ecd1d7925d5388f25e43c7094a294
Showing
18 changed files
with
199 additions
and
0 deletions
com.samsung.dali-demo.xml
| @@ -178,4 +178,7 @@ | @@ -178,4 +178,7 @@ | ||
| 178 | <ui-application appid="transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 178 | <ui-application appid="transitions.example" exec="/usr/apps/com.samsung.dali-demo/bin/transitions.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 179 | <label>Visual Transitions</label> | 179 | <label>Visual Transitions</label> |
| 180 | </ui-application> | 180 | </ui-application> |
| 181 | + <ui-application appid="animated-images.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-images.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 182 | + <label>Animated images</label> | ||
| 183 | + </ui-application> | ||
| 181 | </manifest> | 184 | </manifest> |
demo/dali-demo.cpp
| @@ -36,6 +36,7 @@ int DALI_EXPORT_API main(int argc, char **argv) | @@ -36,6 +36,7 @@ int DALI_EXPORT_API main(int argc, char **argv) | ||
| 36 | // Create the demo launcher | 36 | // Create the demo launcher |
| 37 | DaliTableView demo(app); | 37 | DaliTableView demo(app); |
| 38 | 38 | ||
| 39 | + demo.AddExample(Example("animated-images.example", DALI_DEMO_STR_TITLE_ANIMATED_IMAGES)); | ||
| 39 | demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); | 40 | demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); |
| 40 | demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES)); | 41 | demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES)); |
| 41 | demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS)); | 42 | demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS)); |
examples/animated-images/animated-images-example.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2016 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 | + | ||
| 20 | +#include "shared/utility.h" | ||
| 21 | + | ||
| 22 | +using namespace Dali; | ||
| 23 | +using namespace Dali::Toolkit; | ||
| 24 | + | ||
| 25 | +namespace | ||
| 26 | +{ | ||
| 27 | +const char * const PLAY_ICON( DEMO_IMAGE_DIR "icon-play.png" ); | ||
| 28 | +const char * const PLAY_ICON_SELECTED( DEMO_IMAGE_DIR "icon-play-selected.png" ); | ||
| 29 | + | ||
| 30 | +const char* const STATIC_GIF_DOG( DEMO_IMAGE_DIR "dog-static.gif" ); | ||
| 31 | +const char* const ANIMATE_GIF_DOG( DEMO_IMAGE_DIR "dog-anim.gif" ); | ||
| 32 | + | ||
| 33 | +const char* const STATIC_GIF_LOGO( DEMO_IMAGE_DIR "dali-logo-static.gif" ); | ||
| 34 | +const char* const ANIMATE_GIF_LOGO( DEMO_IMAGE_DIR "dali-logo-anim.gif" ); | ||
| 35 | + | ||
| 36 | +const Vector4 DIM_COLOR( 0.85f, 0.85f, 0.85f, 0.85f ); | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +/* This example shows how to display a GIF image. | ||
| 40 | + * First a static GIF image is loaded and then when the user presses on the "Play" icon, | ||
| 41 | + * the static image is replaced by an animated one | ||
| 42 | + */ | ||
| 43 | + | ||
| 44 | +class AnimatedImageController : public ConnectionTracker | ||
| 45 | +{ | ||
| 46 | +public: | ||
| 47 | + | ||
| 48 | + AnimatedImageController( Application& application ) | ||
| 49 | + : mApplication( application ) | ||
| 50 | + { | ||
| 51 | + // Connect to the Application's Init signal | ||
| 52 | + mApplication.InitSignal().Connect( this, &AnimatedImageController::Create ); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + ~AnimatedImageController() | ||
| 56 | + { | ||
| 57 | + // Nothing to do here; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // The Init signal is received once (only) during the Application lifetime | ||
| 61 | + void Create( Application& application ) | ||
| 62 | + { | ||
| 63 | + // Get a handle to the stage | ||
| 64 | + Stage stage = Stage::GetCurrent(); | ||
| 65 | + stage.SetBackgroundColor( Color::WHITE ); | ||
| 66 | + // Tie-in input event handlers: | ||
| 67 | + stage.KeyEventSignal().Connect( this, &AnimatedImageController::OnKeyEvent ); | ||
| 68 | + | ||
| 69 | + mActorDog = CreateGifViewWithOverlayButton( STATIC_GIF_DOG ); | ||
| 70 | + mActorDog.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 71 | + mActorDog.SetY( -100.f ); | ||
| 72 | + stage.Add( mActorDog ); | ||
| 73 | + | ||
| 74 | + mActorLogo = CreateGifViewWithOverlayButton( STATIC_GIF_LOGO ); | ||
| 75 | + mActorLogo.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 76 | + mActorLogo.SetY( 100.f ); | ||
| 77 | + stage.Add( mActorLogo ); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * Create the gif image view with an overlay play button. | ||
| 82 | + */ | ||
| 83 | + Toolkit::ImageView CreateGifViewWithOverlayButton( const std::string& gifUrl ) | ||
| 84 | + { | ||
| 85 | + Toolkit::ImageView imageView = Toolkit::ImageView::New( gifUrl ); | ||
| 86 | + imageView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 87 | + | ||
| 88 | + // Create a push button, and add it as child of the image view | ||
| 89 | + Toolkit::PushButton animateButton = Toolkit::PushButton::New(); | ||
| 90 | + animateButton.SetUnselectedImage( PLAY_ICON ); | ||
| 91 | + animateButton.SetSelectedImage( PLAY_ICON_SELECTED ); | ||
| 92 | + animateButton.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 93 | + animateButton.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 94 | + animateButton.ClickedSignal().Connect( this, &AnimatedImageController::OnPlayButtonClicked ); | ||
| 95 | + imageView.Add( animateButton ); | ||
| 96 | + | ||
| 97 | + // Apply dim color on the gif view and the play button | ||
| 98 | + imageView.SetColor( DIM_COLOR ); | ||
| 99 | + | ||
| 100 | + return imageView; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + bool OnPlayButtonClicked( Toolkit::Button button ) | ||
| 104 | + { | ||
| 105 | + Stage stage = Stage::GetCurrent(); | ||
| 106 | + | ||
| 107 | + // With play button clicked, the static gif is replaced with animated gif. | ||
| 108 | + if( button.GetParent() == mActorDog ) | ||
| 109 | + { | ||
| 110 | + // remove the static gif view, the play button is also removed as its child. | ||
| 111 | + stage.Remove( mActorDog ); | ||
| 112 | + | ||
| 113 | + mActorDog = Toolkit::ImageView::New( ANIMATE_GIF_DOG ); | ||
| 114 | + mActorDog.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 115 | + mActorDog.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 116 | + mActorDog.SetY( -100.f ); | ||
| 117 | + stage.Add( mActorDog ); | ||
| 118 | + } | ||
| 119 | + else // button.GetParent() == mActorLogo | ||
| 120 | + { | ||
| 121 | + // remove the static gif view, the play button is also removed as its child. | ||
| 122 | + stage.Remove( mActorLogo ); | ||
| 123 | + | ||
| 124 | + mActorLogo = Toolkit::ImageView::New( ANIMATE_GIF_LOGO ); | ||
| 125 | + mActorLogo.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 126 | + mActorLogo.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 127 | + mActorLogo.SetY( 100.f ); | ||
| 128 | + stage.Add( mActorLogo ); | ||
| 129 | + } | ||
| 130 | + return true; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + void OnKeyEvent(const KeyEvent& event) | ||
| 135 | + { | ||
| 136 | + if(event.state == KeyEvent::Down) | ||
| 137 | + { | ||
| 138 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | ||
| 139 | + { | ||
| 140 | + mApplication.Quit(); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | +private: | ||
| 146 | + Application& mApplication; | ||
| 147 | + Toolkit::ImageView mActorDog; | ||
| 148 | + Toolkit::ImageView mActorLogo; | ||
| 149 | +}; | ||
| 150 | + | ||
| 151 | +// Entry point for Linux & Tizen applications | ||
| 152 | +// | ||
| 153 | +int DALI_EXPORT_API main( int argc, char **argv ) | ||
| 154 | +{ | ||
| 155 | + Application application = Application::New( &argc, &argv ); | ||
| 156 | + | ||
| 157 | + AnimatedImageController test( application ); | ||
| 158 | + | ||
| 159 | + application.MainLoop(); | ||
| 160 | + | ||
| 161 | + return 0; | ||
| 162 | +} |
resources/images/dali-logo-anim.gif
0 → 100644
83.8 KB
resources/images/dali-logo-static.gif
0 → 100644
18.8 KB
resources/images/dog-anim.gif
0 → 100644
57.2 KB
resources/images/dog-static.gif
0 → 100644
8.03 KB
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
| @@ -32,6 +32,7 @@ extern "C" | @@ -32,6 +32,7 @@ extern "C" | ||
| 32 | 32 | ||
| 33 | #ifdef INTERNATIONALIZATION_ENABLED | 33 | #ifdef INTERNATIONALIZATION_ENABLED |
| 34 | 34 | ||
| 35 | +#define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES") | ||
| 35 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES") | 36 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES") |
| 36 | #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS") | 37 | #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS") |
| 37 | #define DALI_DEMO_STR_TITLE_BUBBLES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUBBLES") | 38 | #define DALI_DEMO_STR_TITLE_BUBBLES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUBBLES") |
| @@ -86,6 +87,7 @@ extern "C" | @@ -86,6 +87,7 @@ extern "C" | ||
| 86 | 87 | ||
| 87 | #else // !INTERNATIONALIZATION_ENABLED | 88 | #else // !INTERNATIONALIZATION_ENABLED |
| 88 | 89 | ||
| 90 | +#define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES "Animated Images" | ||
| 89 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes" | 91 | #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes" |
| 90 | #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks" | 92 | #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks" |
| 91 | #define DALI_DEMO_STR_TITLE_BUBBLES "Bubbles" | 93 | #define DALI_DEMO_STR_TITLE_BUBBLES "Bubbles" |