Commit 25e0237281a127819e590c3c674dce8973c27bf1

Authored by Xiangyin Ma
1 parent 3728d7df

Set launcher background from stylesheet

Change-Id: I3bb7ab3711311431cd0cbff0abc2cfdd11ee616d
demo/dali-table-view.cpp
... ... @@ -43,8 +43,7 @@ const std::string BUTTON_QUIT( "Quit" );
43 43 const std::string BUTTON_OK( "Ok" );
44 44 const std::string BUTTON_CANCEL( "Cancel" );
45 45  
46   -const std::string DEFAULT_BACKGROUND_IMAGE_PATH( DALI_IMAGE_DIR "background-gradient.jpg" );
47   -const std::string LOGO_PATH( DALI_IMAGE_DIR "dali-logo.png" );
  46 +const std::string LOGO_PATH( DALI_IMAGE_DIR "Logo-for-demo.png" );
48 47 const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DALI_IMAGE_DIR "top-bar.png" );
49 48 const std::string BUTTON_BACKGROUND(DALI_IMAGE_DIR "button-background.png");
50 49 const std::string TILE_BACKGROUND(DALI_IMAGE_DIR "item-background.png");
... ... @@ -88,14 +87,14 @@ const float BUBBLE_MAX_Z = 0.0f;
88 87 /**
89 88 * Creates the background image
90 89 */
91   -ImageView CreateBackground( std::string imagePath )
  90 +Control CreateBackground( std::string stylename )
92 91 {
93   - Image image = ResourceImage::New( imagePath );
94   - ImageView background = ImageView::New( image );
  92 + Control background = Control::New();
  93 + Stage::GetCurrent().Add( background );
  94 + background.SetProperty( Control::Property::STYLE_NAME,stylename);
95 95 background.SetName( "BACKGROUND" );
96 96 background.SetAnchorPoint( AnchorPoint::CENTER );
97 97 background.SetParentOrigin( ParentOrigin::CENTER );
98   - background.SetZ( -1.0f );
99 98 background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
100 99  
101 100 return background;
... ... @@ -171,7 +170,6 @@ DaliTableView::DaliTableView( Application& application )
171 170 mBackgroundAnimations(),
172 171 mExampleList(),
173 172 mExampleMap(),
174   - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
175 173 mTotalPages(),
176 174 mScrolling( false ),
177 175 mSortAlphabetically( false ),
... ... @@ -190,11 +188,6 @@ void DaliTableView::AddExample( Example example )
190 188 mExampleMap[ example.name ] = example;
191 189 }
192 190  
193   -void DaliTableView::SetBackgroundPath( std::string imagePath )
194   -{
195   - mBackgroundImagePath = imagePath;
196   -}
197   -
198 191 void DaliTableView::SortAlphabetically( bool sortAlphabetically )
199 192 {
200 193 mSortAlphabetically = sortAlphabetically;
... ... @@ -207,10 +200,10 @@ void DaliTableView::Initialize( Application& application )
207 200 const Vector2 stageSize = Stage::GetCurrent().GetSize();
208 201  
209 202 // Background
210   - ImageView background = CreateBackground( mBackgroundImagePath );
  203 + Control background = CreateBackground( "launcherbackground" );
211 204 Stage::GetCurrent().Add( background );
212 205  
213   - // Render entire content as overlays, as is all on same 2D plane.
  206 + // Add root actor
214 207 mRootActor = TableView::New( 4, 1 );
215 208 mRootActor.SetAnchorPoint( AnchorPoint::CENTER );
216 209 mRootActor.SetParentOrigin( ParentOrigin::CENTER );
... ...
demo/dali-table-view.h
... ... @@ -99,15 +99,6 @@ public:
99 99 void AddExample(Example example);
100 100  
101 101 /**
102   - * Sets the background image PATH.
103   - *
104   - * @param[in] imagePath The file path to the image to use as the background.
105   - *
106   - * @note Should be called before the Application MainLoop is started.
107   - */
108   - void SetBackgroundPath( std::string imagePath );
109   -
110   - /**
111 102 * Sorts the example list alphabetically by Title if parameter is true.
112 103 *
113 104 * @param[in] sortAlphabetically If true, example list is sorted alphabetically.
... ... @@ -407,7 +398,6 @@ private:
407 398 ExampleList mExampleList; ///< List of examples.
408 399 ExampleMap mExampleMap; ///< Map LUT for examples.
409 400  
410   - std::string mBackgroundImagePath; ///< The path to the background image.
411 401 int mTotalPages; ///< Total pages within scrollview.
412 402  
413 403 bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled
... ...
examples/magnifier/magnifier-example.cpp
... ... @@ -223,7 +223,7 @@ public:
223 223 Stage::GetCurrent().Add(overlay);
224 224  
225 225 mMagnifier = Toolkit::Magnifier::New();
226   - mMagnifier.SetSourceActor( mView.GetChildAt( 0 ) );
  226 + mMagnifier.SetSourceActor( mView );
227 227 mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width
228 228 mMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR );
229 229 mMagnifier.SetScale(Vector3::ZERO);
... ... @@ -240,7 +240,7 @@ public:
240 240  
241 241 // Create bouncing magnifier automatically bounces around screen.
242 242 mBouncingMagnifier = Toolkit::Magnifier::New();
243   - mBouncingMagnifier.SetSourceActor( mView.GetChildAt( 0 ) );
  243 + mBouncingMagnifier.SetSourceActor( mView );
244 244 mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width
245 245 mBouncingMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR );
246 246 overlay.Add( mBouncingMagnifier );
... ...
resources/images/Logo-for-demo.png 0 โ†’ 100644

38.8 KB

resources/style/demo-theme.json
... ... @@ -59,6 +59,19 @@ distributing this software or its derivatives.
59 59 "buttonlabel":
60 60 {
61 61 "point-size":11
  62 + },
  63 +
  64 + "launcherbackground":
  65 + {
  66 + "background":
  67 + {
  68 + "renderer-type": "gradient-renderer",
  69 + "gradient-center": [240, 400],
  70 + "gradient-radius": 932,
  71 + "gradient-units": "user-space",
  72 + "gradient-stop-color": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]],
  73 + "gradient-stop-offset":[0.0,1.0]
  74 + }
62 75 }
63 76 }
64 77 }
... ...
resources/style/mobile/demo-theme.json
... ... @@ -66,7 +66,7 @@ distributing this software or its derivatives.
66 66 {
67 67 "point-size":10
68 68 },
69   -
  69 +
70 70 "scrollview":
71 71 {
72 72 "overshoot-effect-color":"B018"
... ... @@ -80,6 +80,19 @@ distributing this software or its derivatives.
80 80 "buttonlabel":
81 81 {
82 82 "point-size":8
  83 + },
  84 +
  85 + "launcherbackground":
  86 + {
  87 + "background":
  88 + {
  89 + "renderer-type": "gradient-renderer",
  90 + "gradient-center": [360, 640],
  91 + "gradient-radius": 1468,
  92 + "gradient-units": "user-space",
  93 + "gradient-stop-color": [[0.247,0.38,0.52,1.0],[0.055,0.18,0.286,1.0]],
  94 + "gradient-stop-offset":[0.0,1.0]
  95 + }
83 96 }
84 97 }
85 98 }
... ...