Set launcher background from stylesheet 84/48684/5
authorXiangyin Ma <x1.ma@samsung.com>
Thu, 24 Sep 2015 16:16:33 +0000 (17:16 +0100)
committerXiangyin Ma <x1.ma@samsung.com>
Thu, 1 Oct 2015 13:49:29 +0000 (14:49 +0100)
Change-Id: I3bb7ab3711311431cd0cbff0abc2cfdd11ee616d

demo/dali-table-view.cpp
demo/dali-table-view.h
examples/magnifier/magnifier-example.cpp
resources/images/Logo-for-demo.png [new file with mode: 0644]
resources/style/demo-theme.json
resources/style/mobile/demo-theme.json

index 990a787..50b52a8 100644 (file)
@@ -43,8 +43,7 @@ const std::string BUTTON_QUIT( "Quit" );
 const std::string BUTTON_OK( "Ok" );
 const std::string BUTTON_CANCEL( "Cancel" );
 
-const std::string DEFAULT_BACKGROUND_IMAGE_PATH( DALI_IMAGE_DIR "background-gradient.jpg" );
-const std::string LOGO_PATH( DALI_IMAGE_DIR "dali-logo.png" );
+const std::string LOGO_PATH( DALI_IMAGE_DIR "Logo-for-demo.png" );
 const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DALI_IMAGE_DIR "top-bar.png" );
 const std::string BUTTON_BACKGROUND(DALI_IMAGE_DIR "button-background.png");
 const std::string TILE_BACKGROUND(DALI_IMAGE_DIR "item-background.png");
@@ -88,14 +87,14 @@ const float BUBBLE_MAX_Z = 0.0f;
 /**
  * Creates the background image
  */
-ImageView CreateBackground( std::string imagePath )
+Control CreateBackground( std::string stylename )
 {
-  Image image = ResourceImage::New( imagePath );
-  ImageView background = ImageView::New( image );
+  Control background = Control::New();
+  Stage::GetCurrent().Add( background );
+  background.SetProperty( Control::Property::STYLE_NAME,stylename);
   background.SetName( "BACKGROUND" );
   background.SetAnchorPoint( AnchorPoint::CENTER );
   background.SetParentOrigin( ParentOrigin::CENTER );
-  background.SetZ( -1.0f );
   background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
 
   return background;
@@ -171,7 +170,6 @@ DaliTableView::DaliTableView( Application& application )
   mBackgroundAnimations(),
   mExampleList(),
   mExampleMap(),
-  mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
   mTotalPages(),
   mScrolling( false ),
   mSortAlphabetically( false ),
@@ -190,11 +188,6 @@ void DaliTableView::AddExample( Example example )
   mExampleMap[ example.name ] = example;
 }
 
-void DaliTableView::SetBackgroundPath( std::string imagePath )
-{
-  mBackgroundImagePath = imagePath;
-}
-
 void DaliTableView::SortAlphabetically( bool sortAlphabetically )
 {
   mSortAlphabetically = sortAlphabetically;
@@ -207,10 +200,10 @@ void DaliTableView::Initialize( Application& application )
   const Vector2 stageSize = Stage::GetCurrent().GetSize();
 
   // Background
-  ImageView background = CreateBackground( mBackgroundImagePath );
+  Control background = CreateBackground( "launcherbackground" );
   Stage::GetCurrent().Add( background );
 
-  // Render entire content as overlays, as is all on same 2D plane.
+  // Add root actor
   mRootActor = TableView::New( 4, 1 );
   mRootActor.SetAnchorPoint( AnchorPoint::CENTER );
   mRootActor.SetParentOrigin( ParentOrigin::CENTER );
index 8b1353d..9db332d 100644 (file)
@@ -99,15 +99,6 @@ public:
   void AddExample(Example example);
 
   /**
-   * Sets the background image PATH.
-   *
-   * @param[in] imagePath The file path to the image to use as the background.
-   *
-   * @note Should be called before the Application MainLoop is started.
-   */
-  void SetBackgroundPath( std::string imagePath );
-
-  /**
    * Sorts the example list alphabetically by Title if parameter is true.
    *
    * @param[in] sortAlphabetically If true, example list is sorted alphabetically.
@@ -407,7 +398,6 @@ private:
   ExampleList                     mExampleList;              ///< List of examples.
   ExampleMap                      mExampleMap;               ///< Map LUT for examples.
 
-  std::string                     mBackgroundImagePath;      ///< The path to the background image.
   int                             mTotalPages;               ///< Total pages within scrollview.
 
   bool                            mScrolling:1;              ///< Flag indicating whether view is currently being scrolled
index b5632d5..8f0945d 100644 (file)
@@ -223,7 +223,7 @@ public:
     Stage::GetCurrent().Add(overlay);
 
     mMagnifier = Toolkit::Magnifier::New();
-    mMagnifier.SetSourceActor( mView.GetChildAt( 0 ) );
+    mMagnifier.SetSourceActor( mView );
     mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width );  // Size of magnifier is in relation to stage width
     mMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR );
     mMagnifier.SetScale(Vector3::ZERO);
@@ -240,7 +240,7 @@ public:
 
     // Create bouncing magnifier automatically bounces around screen.
     mBouncingMagnifier = Toolkit::Magnifier::New();
-    mBouncingMagnifier.SetSourceActor( mView.GetChildAt( 0 ) );
+    mBouncingMagnifier.SetSourceActor( mView );
     mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width
     mBouncingMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR );
     overlay.Add( mBouncingMagnifier );
diff --git a/resources/images/Logo-for-demo.png b/resources/images/Logo-for-demo.png
new file mode 100644 (file)
index 0000000..ab8c2a4
Binary files /dev/null and b/resources/images/Logo-for-demo.png differ
index 9611646..64fe786 100644 (file)
@@ -59,6 +59,19 @@ distributing this software or its derivatives.
     "buttonlabel":
     {
       "point-size":11
+    },
+
+    "launcherbackground":
+    {
+      "background":
+      {
+        "renderer-type": "gradient-renderer",
+        "gradient-center": [240, 400],
+        "gradient-radius": 932,
+        "gradient-units": "user-space",
+        "gradient-stop-color": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]],
+        "gradient-stop-offset":[0.0,1.0]
+      }
     }
   }
 }
index b22e987..653fbea 100644 (file)
@@ -66,7 +66,7 @@ distributing this software or its derivatives.
     {
       "point-size":10
     },
-    
+
     "scrollview":
     {
       "overshoot-effect-color":"B018"
@@ -80,6 +80,19 @@ distributing this software or its derivatives.
     "buttonlabel":
     {
       "point-size":8
+    },
+
+    "launcherbackground":
+    {
+      "background":
+      {
+        "renderer-type": "gradient-renderer",
+        "gradient-center": [360, 640],
+        "gradient-radius": 1468,
+        "gradient-units": "user-space",
+        "gradient-stop-color": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]],
+        "gradient-stop-offset":[0.0,1.0]
+      }
     }
   }
 }