X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fremote-image-loading%2Fremote-image-loading-example.cpp;h=1063e1a8853d3206aead5eb41c89c3fbd407f548;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=5bf7e1faf293755f14dfce567065abcac8c75090;hpb=694dced621016315f10a5bdbd3f4552f5e29e380;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/remote-image-loading/remote-image-loading-example.cpp b/examples/remote-image-loading/remote-image-loading-example.cpp index 5bf7e1f..1063e1a 100644 --- a/examples/remote-image-loading/remote-image-loading-example.cpp +++ b/examples/remote-image-loading/remote-image-loading-example.cpp @@ -15,14 +15,12 @@ * */ - +#include +#include +#include #include #include #include -#include -#include -#include - using namespace Dali; using namespace Dali::Toolkit; @@ -32,7 +30,8 @@ using namespace Dali::Toolkit; class MyTester : public ConnectionTracker { public: - MyTester(Application &application) : mApplication(application) + MyTester(Application& application) + : mApplication(application) { // Connect to the Application's Init signal mApplication.InitSignal().Connect(this, &MyTester::Create); @@ -45,132 +44,131 @@ public: void ConnectEventSignal(Control control) { - control.TouchSignal().Connect(this, &MyTester::OnControlTouch); + control.TouchedSignal().Connect(this, &MyTester::OnControlTouch); - control.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true); + control.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, 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) + void Create(Application& application) { mWindow = application.GetWindow(); mWindow.SetBackgroundColor(Color::BLACK); mWindow.KeyEventSignal().Connect(this, &MyTester::OnKey); - mWindow.TouchSignal().Connect(this, &MyTester::OnTouch); + mWindow.TouchedSignal().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.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); - rubric.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_CENTER ); - mWindow.Add( rubric ); + 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.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); + rubric.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::TOP_CENTER); + mWindow.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.SetProperty( Dali::Actor::Property::NAME,"mImageView1"); - mImageView1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); - mImageView1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_CENTER); + mImageView1.SetProperty(Dali::Actor::Property::NAME, "mImageView1"); + mImageView1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mImageView1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); mImageView1.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false); - mImageView1.SetProperty( Actor::Property::POSITION, Vector2(0, 100)); + mImageView1.SetProperty(Actor::Property::POSITION, Vector2(0, 100)); mImageView1.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mWindow.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.SetProperty( Dali::Actor::Property::NAME,"mImageView2"); - mImageView2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); - mImageView2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_CENTER); + mImageView2.SetProperty(Dali::Actor::Property::NAME, "mImageView2"); + mImageView2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mImageView2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); mImageView2.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false); - mImageView2.SetProperty( Actor::Property::POSITION, Vector2(400, 100)); + mImageView2.SetProperty(Actor::Property::POSITION, Vector2(400, 100)); mImageView2.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mWindow.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.SetProperty( Dali::Actor::Property::NAME,"mImageView3"); - mImageView3.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); - mImageView3.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_CENTER); + mImageView3.SetProperty(Dali::Actor::Property::NAME, "mImageView3"); + mImageView3.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mImageView3.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); mImageView3.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false); - mImageView3.SetProperty( Actor::Property::POSITION, Vector2(0, 400)); + mImageView3.SetProperty(Actor::Property::POSITION, Vector2(0, 400)); mImageView3.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mWindow.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.SetProperty( Dali::Actor::Property::NAME,"mImageView4"); - mImageView4.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); - mImageView4.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_CENTER); + mImageView4.SetProperty(Dali::Actor::Property::NAME, "mImageView4"); + mImageView4.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mImageView4.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); mImageView4.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false); - mImageView4.SetProperty( Actor::Property::POSITION, Vector2(400, 400)); + mImageView4.SetProperty(Actor::Property::POSITION, Vector2(400, 400)); mImageView4.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mWindow.Add(mImageView4); mImageView5 = Toolkit::ImageView::New("http://static.midomi.com/h/images/w/weather_sunny.png"); - mImageView5.SetProperty( Dali::Actor::Property::NAME,"mImageView5"); - mImageView4.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT); - mImageView5.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_CENTER); + mImageView5.SetProperty(Dali::Actor::Property::NAME, "mImageView5"); + mImageView4.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mImageView5.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); mImageView5.SetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT, false); - mImageView5.SetProperty( Actor::Property::POSITION, Vector2(800, 100)); + mImageView5.SetProperty(Actor::Property::POSITION, Vector2(800, 100)); mImageView5.SetBackgroundColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mWindow.Add(mImageView5); // Tie-in input event handlers: - mWindow.KeyEventSignal().Connect( this, &MyTester::OnKeyEvent ); + mWindow.KeyEventSignal().Connect(this, &MyTester::OnKeyEvent); } - void OnAnimationEnd(Animation &source) + void OnAnimationEnd(Animation& source) { - std::cout<<"OnAnimationEnd" << std::endl; + std::cout << "OnAnimationEnd" << std::endl; } void OnKeyEvent(const KeyEvent& event) { - if( event.state == KeyEvent::Down ) + if(event.GetState() == KeyEvent::DOWN) { - if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) { mApplication.Quit(); } } } - void OnKey(const KeyEvent &event) + void OnKey(const KeyEvent& event) { - if (event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { - std::cout<<"Window key : " << event.keyCode << std::endl; + std::cout << "Window key : " << event.GetKeyCode() << std::endl; } } - void OnTouch(const TouchData &touch) + void OnTouch(const TouchEvent& touch) { - if (touch.GetState(0) == PointState::DOWN) + if(touch.GetState(0) == PointState::DOWN) { - std::cout<<"Window touch" << std::endl; + std::cout << "Window touch" << std::endl; } } - bool OnControlKeyEvent(Toolkit::Control control, const KeyEvent &event) + bool OnControlKeyEvent(Toolkit::Control control, const KeyEvent& event) { - if (event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { - std::cout<<"Control down key : " << control.GetProperty< std::string >( Dali::Actor::Property::NAME ) << ", keyCode : " << event.keyCode << std::endl; + std::cout << "Control down key : " << control.GetProperty(Dali::Actor::Property::NAME) << ", keyCode : " << event.GetKeyCode() << std::endl; } else { - std::cout<<"Control up key : " << control.GetProperty< std::string >( Dali::Actor::Property::NAME ) << ", keyCode : " << event.keyCode << std::endl; + std::cout << "Control up key : " << control.GetProperty(Dali::Actor::Property::NAME) << ", keyCode : " << event.GetKeyCode() << std::endl; } return false; } - bool OnControlTouch(Actor actor, const TouchData &touch) + bool OnControlTouch(Actor actor, const TouchEvent& touch) { - if (touch.GetState(0) == PointState::DOWN) + if(touch.GetState(0) == PointState::DOWN) { - - std::cout<<"Control touch " << actor.GetProperty< std::string >( Dali::Actor::Property::NAME ) << ", parent " << actor.GetParent().GetProperty< std::string >( Dali::Actor::Property::NAME ) << std::endl; + std::cout << "Control touch " << actor.GetProperty(Dali::Actor::Property::NAME) << ", parent " << actor.GetParent().GetProperty(Dali::Actor::Property::NAME) << std::endl; } return false; @@ -178,40 +176,39 @@ public: void OnFocusSet(Control control) { - std::cout<<"OnFocusSet " << control.GetProperty< std::string >( Dali::Actor::Property::NAME ) << std::endl; + std::cout << "OnFocusSet " << control.GetProperty(Dali::Actor::Property::NAME) << std::endl; } void OnFocusUnSet(Control control) { - std::cout<<"OnFocusUnSet " << control.GetProperty< std::string >( Dali::Actor::Property::NAME ) << std::endl; + std::cout << "OnFocusUnSet " << control.GetProperty(Dali::Actor::Property::NAME) << std::endl; } private: - Window mWindow; - Application &mApplication; + Window mWindow; + Application& mApplication; - Control mControl1; - Control mControl2; + Control mControl1; + Control mControl2; ImageView mImageView1; ImageView mImageView2; ImageView mImageView3; ImageView mImageView4; ImageView mImageView5; - TextLabel mTextLabel1; - TextLabel mTextLabel2; - TextField mTextField; + TextLabel mTextLabel1; + TextLabel mTextLabel2; + TextField mTextField; TextEditor mTextEditor; Animation mAnimation; Timer mTimer; - }; -int DALI_EXPORT_API main(int argc, char **argv) +int DALI_EXPORT_API main(int argc, char** argv) { Application application = Application::New(&argc, &argv, ""); - MyTester test(application); + MyTester test(application); application.MainLoop(); return 0; }