From 10e302a1b4afff21a4f3d7cefebb1a28f53fd050 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 15 Mar 2017 19:35:33 +0000 Subject: [PATCH] Added example of remote image load Change-Id: Ie8e8523d5a8ff8aac50931bb96ca764195890f15 --- com.samsung.dali-demo.xml | 17 +- examples-reel/dali-examples-reel.cpp | 1 + .../remote-image-loading-example.cpp | 225 ++++++++++++++++++ resources/po/en_GB.po | 3 + resources/po/en_US.po | 3 + shared/dali-demo-strings.h | 6 +- 6 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 examples/remote-image-loading/remote-image-loading-example.cpp diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index fc16157a..9e3e8d82 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -1,7 +1,6 @@ - Jonghyun Ho DALi demo Application @@ -203,6 +202,9 @@ + + + @@ -233,4 +235,17 @@ + + http://tizen.org/privilege/mediastorage + http://tizen.org/privilege/externalstorage + http://tizen.org/privilege/externalstorage.appdata + http://tizen.org/privilege/unlimitedstorage + http://tizen.org/privilege/filesystem.write + http://tizen.org/privilege/filesystem.read + http://tizen.org/privilege/download + http://tizen.org/privilege/internet + http://tizen.org/privilege/network.get + http://tizen.org/privilege/network.profile + http://tizen.org/privilege/network.set + diff --git a/examples-reel/dali-examples-reel.cpp b/examples-reel/dali-examples-reel.cpp index 04a8c831..8a7e66b9 100644 --- a/examples-reel/dali-examples-reel.cpp +++ b/examples-reel/dali-examples-reel.cpp @@ -82,6 +82,7 @@ int DALI_EXPORT_API main(int argc, char **argv) demo.AddExample(Example("text-label-emojis.example", DALI_DEMO_STR_TITLE_EMOJI_TEXT)); demo.AddExample(Example("text-overlap.example", DALI_DEMO_STR_TITLE_TEXT_OVERLAP)); demo.AddExample(Example("text-scrolling.example", DALI_DEMO_STR_TITLE_TEXT_SCROLLING)); + demo.AddExample(Example("remote-image-loading.example", DALI_DEMO_STR_TITLE_REMOTE_IMAGE)); demo.AddExample(Example("textured-mesh.example", DALI_DEMO_STR_TITLE_TEXTURED_MESH)); demo.AddExample(Example("tilt.example", DALI_DEMO_STR_TITLE_TILT_SENSOR)); demo.AddExample(Example("tooltip.example", DALI_DEMO_STR_TITLE_TOOLTIP)); diff --git a/examples/remote-image-loading/remote-image-loading-example.cpp b/examples/remote-image-loading/remote-image-loading-example.cpp new file mode 100644 index 00000000..2733d3de --- /dev/null +++ b/examples/remote-image-loading/remote-image-loading-example.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include +#include +#include +#include +#include + + +using namespace Dali; +using namespace Dali::Toolkit; + +// This example shows the load-time image scaling and filtering features. +// +class MyTester : public ConnectionTracker +{ +public: + MyTester(Application &application) : mApplication(application) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect(this, &MyTester::Create); + } + + ~MyTester() + { + // Nothing to do here; + } + + void ConnectEventSignal(Control control) + { + control.TouchSignal().Connect(this, &MyTester::OnControlTouch); + + control.SetKeyboardFocusable(true); + control.KeyEventSignal().Connect(this, &MyTester::OnControlKeyEvent); + control.KeyInputFocusGainedSignal().Connect(this, &MyTester::OnFocusSet); + control.KeyInputFocusLostSignal().Connect(this, &MyTester::OnFocusUnSet); + } + + // The Init signal is received once (only) during the Application lifetime + void Create(Application &application) + { + stage = Stage::GetCurrent(); + stage.SetBackgroundColor(Color::BLACK); + stage.KeyEventSignal().Connect(this, &MyTester::OnKey); + stage.TouchSignal().Connect(this, &MyTester::OnTouch); + + TextLabel rubric = TextLabel::New( "You will need a working internet connection to see the images below"); + rubric.SetProperty( TextLabel::Property::MULTI_LINE, true ); + rubric.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE ); + rubric.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + rubric.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + rubric.SetParentOrigin( ParentOrigin::TOP_CENTER ); + rubric.SetAnchorPoint( ParentOrigin::TOP_CENTER ); + stage.Add( rubric ); + + mImageView1 = Toolkit::ImageView::New("http://static.midomi.com/s/s/images/000/000/000/000/293/259/19/520_000000000000293259191500x1500_72dpi_RGB_q70.jpg"); + + mImageView1.SetName("mImageView1"); + mImageView1.SetParentOrigin(ParentOrigin::TOP_LEFT); + mImageView1.SetAnchorPoint(AnchorPoint::TOP_CENTER); + mImageView1.SetProperty(DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + mImageView1.SetPosition(0, 100); + mImageView1.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + stage.Add(mImageView1); + + mImageView2 = Toolkit::ImageView::New("http://static.midomi.com/s/s/images/000/000/000/000/212/651/88/520_000000000000212651881500x1500_72dpi_RGB_q70.jpg"); + mImageView2.SetName("mImageView2"); + mImageView2.SetParentOrigin(ParentOrigin::TOP_LEFT); + mImageView2.SetAnchorPoint(AnchorPoint::TOP_CENTER); + mImageView2.SetProperty(DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + mImageView2.SetPosition(400, 100); + mImageView2.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + stage.Add(mImageView2); + + mImageView3 = Toolkit::ImageView::New("http://static.midomi.com/s/s/images/000/000/000/000/212/353/21/520_000000000000212353211500x1500_72dpi_RGB_q70.jpg"); + mImageView3.SetName("mImageView3"); + mImageView3.SetParentOrigin(ParentOrigin::TOP_LEFT); + mImageView3.SetAnchorPoint(AnchorPoint::TOP_CENTER); + mImageView3.SetProperty(DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + mImageView3.SetPosition(0, 400); + mImageView3.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + stage.Add(mImageView3); + + mImageView4 = Toolkit::ImageView::New("http://d2k43l0oslhof9.cloudfront.net/platform/image/contents/vc/20/01/58/20170629100630071189_0bf6b911-a847-cba4-e518-be40fe2f579420170629192203240.jpg"); + mImageView4.SetName("mImageView4"); + mImageView4.SetParentOrigin(ParentOrigin::TOP_LEFT); + mImageView4.SetAnchorPoint(AnchorPoint::TOP_CENTER); + mImageView4.SetProperty(DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + mImageView4.SetPosition(400, 400); + mImageView4.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + stage.Add(mImageView4); + + mImageView5 = Toolkit::ImageView::New("http://static.midomi.com/h/images/w/weather_sunny.png"); + mImageView5.SetName("mImageView5"); + mImageView4.SetParentOrigin(ParentOrigin::TOP_LEFT); + mImageView5.SetAnchorPoint(AnchorPoint::TOP_CENTER); + mImageView5.SetProperty(DevelActor::Property::POSITION_USES_ANCHOR_POINT, false); + mImageView5.SetPosition(800, 100); + mImageView5.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); + stage.Add(mImageView5); + + // Tie-in input event handlers: + stage.KeyEventSignal().Connect( this, &MyTester::OnKeyEvent ); + } + + void OnAnimationEnd(Animation &source) + { + std::cout<<"OnAnimationEnd" << std::endl; + } + + void OnKeyEvent(const KeyEvent& event) + { + if( event.state == KeyEvent::Down ) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + + void OnKey(const KeyEvent &event) + { + if (event.state == KeyEvent::Down) + { + std::cout<<"Stage key : " << event.keyCode << std::endl; + } + } + + void OnTouch(const TouchData &touch) + { + if (touch.GetState(0) == PointState::DOWN) + { + std::cout<<"Stage touch" << std::endl; + } + } + + bool OnControlKeyEvent(Toolkit::Control control, const KeyEvent &event) + { + if (event.state == KeyEvent::Down) + { + std::cout<<"Control down key : " << control.GetName() << ", keyCode : " << event.keyCode << std::endl; + } + else + { + std::cout<<"Control up key : " << control.GetName() << ", keyCode : " << event.keyCode << std::endl; + } + return false; + } + + bool OnControlTouch(Actor actor, const TouchData &touch) + { + if (touch.GetState(0) == PointState::DOWN) + { + + std::cout<<"Control touch " << actor.GetName() << ", parent " << actor.GetParent().GetName() << std::endl; + } + + return false; + } + + void OnFocusSet(Control control) + { + std::cout<<"OnFocusSet " << control.GetName() << std::endl; + } + + void OnFocusUnSet(Control control) + { + std::cout<<"OnFocusUnSet " << control.GetName() << std::endl; + } + +private: + Stage stage; + Application &mApplication; + + Control mControl1; + Control mControl2; + ImageView mImageView1; + ImageView mImageView2; + ImageView mImageView3; + ImageView mImageView4; + ImageView mImageView5; + + TextLabel mTextLabel1; + TextLabel mTextLabel2; + TextField mTextField; + TextEditor mTextEditor; + + Animation mAnimation; + Timer mTimer; + +}; + +void RunTest(Application &application) +{ + MyTester test(application); + application.MainLoop(); +} + +// Entry point for Linux & Tizen applications +int DALI_EXPORT_API main(int argc, char **argv) +{ + + Application application = Application::New(&argc, &argv, ""); + RunTest(application); + + return 0; +} diff --git a/resources/po/en_GB.po b/resources/po/en_GB.po index 877b2ee3..3ceb1901 100755 --- a/resources/po/en_GB.po +++ b/resources/po/en_GB.po @@ -169,6 +169,9 @@ msgstr "FPP Game" msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" msgstr "Visual Transitions" +msgid "DALI_DEMO_STR_TITLE_REMOTE_IMAGE" +msgstr "Remote Image" + msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" msgstr "Textured cube" diff --git a/resources/po/en_US.po b/resources/po/en_US.po index b2976b8d..c52ac670 100755 --- a/resources/po/en_US.po +++ b/resources/po/en_US.po @@ -169,6 +169,9 @@ msgstr "FPP Game" msgid "DALI_DEMO_STR_TITLE_VISUAL_TRANSITIONS" msgstr "Visual Transitions" +msgid "DALI_DEMO_STR_TITLE_REMOTE_IMAGE" +msgstr "Remote Image" + msgid "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE" msgstr "Textured cube" diff --git a/shared/dali-demo-strings.h b/shared/dali-demo-strings.h index 47baf36d..83ad3464 100644 --- a/shared/dali-demo-strings.h +++ b/shared/dali-demo-strings.h @@ -73,13 +73,14 @@ extern "C" #define DALI_DEMO_STR_TITLE_PIVOT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PIVOT") #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES") #define DALI_DEMO_STR_TITLE_PROGRESS_BAR dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_PROGRESS_BAR") +#define DALI_DEMO_STR_TITLE_REFRACTION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_REFRACTION") +#define DALI_DEMO_STR_TITLE_REMOTE_IMAGE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_REMOTE_IMAGE") #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE") #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE") #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE") #define DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE") #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS") #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING") -#define DALI_DEMO_STR_TITLE_REFRACTION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_REFRACTION") #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_RENDERER_STENCIL") #define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SIMPLE_VISUALS") #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI") @@ -141,13 +142,14 @@ extern "C" #define DALI_DEMO_STR_TITLE_PIVOT "Pivot" #define DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES "Primitive Shapes" #define DALI_DEMO_STR_TITLE_PROGRESS_BAR "Progress Bar" +#define DALI_DEMO_STR_TITLE_REFRACTION "Refract Effect" +#define DALI_DEMO_STR_TITLE_REMOTE_IMAGE "Remote Image" #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE "Draw Line" #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE "Draw Triangle" #define DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE "Draw Cube" #define DALI_DEMO_STR_TITLE_RENDERING_TEXTURED_CUBE "Textured Cube" #define DALI_DEMO_STR_TITLE_RENDERING_RAY_MARCHING "Ray Marching" #define DALI_DEMO_STR_TITLE_RENDERING_RADIAL_PROGRESS "Radial Progress" -#define DALI_DEMO_STR_TITLE_REFRACTION "Refract Effect" #define DALI_DEMO_STR_TITLE_RENDERER_STENCIL "Renderer Stencils" #define DALI_DEMO_STR_TITLE_SIMPLE_VISUALS_CONTROL "Simple Visuals Control" #define DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI "Script Based UI" -- 2.34.1