Commit cb64d707bb95474fe193654b1325575b311af254
Merge remote-tracking branch 'origin/tizen' into new_text
Conflicts: demo/dali-table-view.cpp Change-Id: Ib0075b320a16327e57d7eb2375082c8c4102f8a3
Showing
10 changed files
with
1291 additions
and
264 deletions
build/tizen/examples/Makefile.am
| @@ -29,6 +29,7 @@ bin_PROGRAMS = \ | @@ -29,6 +29,7 @@ bin_PROGRAMS = \ | ||
| 29 | new-window.example \ | 29 | new-window.example \ |
| 30 | page-turn-view.example \ | 30 | page-turn-view.example \ |
| 31 | radial-menu.example \ | 31 | radial-menu.example \ |
| 32 | + refraction-effect.example \ | ||
| 32 | scroll-view.example \ | 33 | scroll-view.example \ |
| 33 | shadow-bone-lighting.example \ | 34 | shadow-bone-lighting.example \ |
| 34 | dali-builder \ | 35 | dali-builder \ |
| @@ -129,6 +130,11 @@ radial_menu_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | @@ -129,6 +130,11 @@ radial_menu_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 129 | radial_menu_example_DEPENDENCIES = $(EXAMPLE_DEPS) | 130 | radial_menu_example_DEPENDENCIES = $(EXAMPLE_DEPS) |
| 130 | radial_menu_example_LDADD = $(EXAMPLE_LDADD) | 131 | radial_menu_example_LDADD = $(EXAMPLE_LDADD) |
| 131 | 132 | ||
| 133 | +refraction_effect_example_SOURCES = $(examples_src_dir)/shader-effect/refraction-effect-example.cpp | ||
| 134 | +refraction_effect_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 135 | +refraction_effect_example_DEPENDENCIES = $(EXAMPLE_DEPS) | ||
| 136 | +refraction_effect_example_LDADD = $(EXAMPLE_LDADD) | ||
| 137 | + | ||
| 132 | scroll_view_example_SOURCES = $(examples_src_dir)/scroll-view/scroll-view-example.cpp | 138 | scroll_view_example_SOURCES = $(examples_src_dir)/scroll-view/scroll-view-example.cpp |
| 133 | scroll_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | 139 | scroll_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) |
| 134 | scroll_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) | 140 | scroll_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) |
com.samsung.dali-demo.xml
| @@ -49,6 +49,9 @@ | @@ -49,6 +49,9 @@ | ||
| 49 | <ui-application appid="radial-menu.example" exec="/usr/apps/com.samsung.dali-demo/bin/radial-menu.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 49 | <ui-application appid="radial-menu.example" exec="/usr/apps/com.samsung.dali-demo/bin/radial-menu.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 50 | <label>Radial Menu</label> | 50 | <label>Radial Menu</label> |
| 51 | </ui-application> | 51 | </ui-application> |
| 52 | + <ui-application appid="refraction-effect.example" exec="/usr/apps/com.samsung.dali-demo/bin/refraction-effect.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 53 | + <label>Refraction effect</label> | ||
| 54 | + </ui-application> | ||
| 52 | <ui-application appid="scroll-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/scroll-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 55 | <ui-application appid="scroll-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/scroll-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 53 | <label>Scroll View</label> | 56 | <label>Scroll View</label> |
| 54 | </ui-application> | 57 | </ui-application> |
demo/dali-demo.cpp
| @@ -36,6 +36,7 @@ int main(int argc, char **argv) | @@ -36,6 +36,7 @@ int main(int argc, char **argv) | ||
| 36 | demo.AddExample(Example("motion-stretch.example", "Motion Stretch")); | 36 | demo.AddExample(Example("motion-stretch.example", "Motion Stretch")); |
| 37 | demo.AddExample(Example("page-turn-view.example", "Page Turn View")); | 37 | demo.AddExample(Example("page-turn-view.example", "Page Turn View")); |
| 38 | demo.AddExample(Example("radial-menu.example", "Radial Menu")); | 38 | demo.AddExample(Example("radial-menu.example", "Radial Menu")); |
| 39 | + demo.AddExample(Example("refraction-effect.example", "Refraction")); | ||
| 39 | demo.AddExample(Example("scroll-view.example", "Scroll View")); | 40 | demo.AddExample(Example("scroll-view.example", "Scroll View")); |
| 40 | demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); | 41 | demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); |
| 41 | demo.AddExample(Example("builder.example", "Script Based UI")); | 42 | demo.AddExample(Example("builder.example", "Script Based UI")); |
demo/dali-table-view.cpp
| @@ -53,11 +53,10 @@ const int MAX_PAGES = 256; ///< Maximum pag | @@ -53,11 +53,10 @@ const int MAX_PAGES = 256; ///< Maximum pag | ||
| 53 | const int EXAMPLES_PER_ROW = 3; | 53 | const int EXAMPLES_PER_ROW = 3; |
| 54 | const int ROWS_PER_PAGE = 3; | 54 | const int ROWS_PER_PAGE = 3; |
| 55 | const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; | 55 | const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; |
| 56 | -const float TOP_ROW_HEIGHT = 35.0f; | ||
| 57 | -const float BOTTOM_ROW_HEIGHT = 35.0f; | ||
| 58 | const int BOTTOM_PADDING_HEIGHT = 40; | 56 | const int BOTTOM_PADDING_HEIGHT = 40; |
| 59 | -const int LOGO_BOTTOM_PADDING_HEIGHT = 30; | ||
| 60 | -const Vector3 TABLE_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< TableView's relative size to the entire stage. | 57 | +const int LOGO_MARGIN = 50; |
| 58 | +const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent | ||
| 59 | +const Vector3 TABLE_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value will be calculated. | ||
| 61 | const float STENCIL_RELATIVE_SIZE = 1.0f; | 60 | const float STENCIL_RELATIVE_SIZE = 1.0f; |
| 62 | 61 | ||
| 63 | const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects | 62 | const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects |
| @@ -73,10 +72,18 @@ const float SCALE_SPEED_SIN = 0.1f; | @@ -73,10 +72,18 @@ const float SCALE_SPEED_SIN = 0.1f; | ||
| 73 | 72 | ||
| 74 | const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs | 73 | const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs |
| 75 | 74 | ||
| 76 | -const float BACKGROUND_Z = -1000.0f; | ||
| 77 | -const float BACKGROUND_SIZE_SCALE = 2.0f; | 75 | +const float BACKGROUND_Z = -1.0f; |
| 76 | +const float BACKGROUND_SIZE_SCALE = 1.0f; | ||
| 78 | const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); | 77 | const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); |
| 79 | 78 | ||
| 79 | +const float BUBBLE_MIN_Z = -1.0; | ||
| 80 | +const float BUBBLE_MAX_Z = 0.0f; | ||
| 81 | + | ||
| 82 | +// 3D Effect constants | ||
| 83 | +const Vector2 ANGLE_SWING_3DEFFECT( Math::PI_2 * 0.75, Math::PI_2 * 0.75f ); ///< Angle Swing in radians | ||
| 84 | +const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position Swing relative to stage size. | ||
| 85 | +const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0) | ||
| 86 | +const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1) | ||
| 80 | 87 | ||
| 81 | //const std::string DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNeue"); | 88 | //const std::string DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNeue"); |
| 82 | //const std::string DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); | 89 | //const std::string DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); |
| @@ -84,8 +91,17 @@ const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); | @@ -84,8 +91,17 @@ const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); | ||
| 84 | 91 | ||
| 85 | //const std::string TABLE_TEXT_STYLE_FONT_FAMILY("HelveticaNeue"); | 92 | //const std::string TABLE_TEXT_STYLE_FONT_FAMILY("HelveticaNeue"); |
| 86 | //const std::string TABLE_TEXT_STYLE_FONT_STYLE("Regular"); | 93 | //const std::string TABLE_TEXT_STYLE_FONT_STYLE("Regular"); |
| 94 | +//const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f ); | ||
| 95 | +//const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT); | ||
| 87 | //const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); | 96 | //const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); |
| 88 | 97 | ||
| 98 | +Vector3 ScalePointSize(const Vector3& vec) | ||
| 99 | +{ | ||
| 100 | + return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) ); | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +#define DP(x) DemoHelper::ScalePointSize(x) | ||
| 104 | + | ||
| 89 | /** | 105 | /** |
| 90 | * Creates the background image | 106 | * Creates the background image |
| 91 | */ | 107 | */ |
| @@ -233,7 +249,7 @@ void DaliTableView::Initialize( Application& application ) | @@ -233,7 +249,7 @@ void DaliTableView::Initialize( Application& application ) | ||
| 233 | { | 249 | { |
| 234 | Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent ); | 250 | Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent ); |
| 235 | 251 | ||
| 236 | - Vector2 stageSize = Stage::GetCurrent().GetSize(); | 252 | + const Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| 237 | 253 | ||
| 238 | // Background | 254 | // Background |
| 239 | mBackground = CreateBackground( mBackgroundImagePath ); | 255 | mBackground = CreateBackground( mBackgroundImagePath ); |
| @@ -245,7 +261,6 @@ void DaliTableView::Initialize( Application& application ) | @@ -245,7 +261,6 @@ void DaliTableView::Initialize( Application& application ) | ||
| 245 | mRootActor = TableView::New( 4, 1 ); | 261 | mRootActor = TableView::New( 4, 1 ); |
| 246 | mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); | 262 | mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 247 | mRootActor.SetParentOrigin( ParentOrigin::CENTER ); | 263 | mRootActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 248 | - mRootActor.SetFixedHeight( 3, BOTTOM_PADDING_HEIGHT ); | ||
| 249 | Stage::GetCurrent().Add( mRootActor ); | 264 | Stage::GetCurrent().Add( mRootActor ); |
| 250 | 265 | ||
| 251 | // Toolbar at top | 266 | // Toolbar at top |
| @@ -256,11 +271,17 @@ void DaliTableView::Initialize( Application& application ) | @@ -256,11 +271,17 @@ void DaliTableView::Initialize( Application& application ) | ||
| 256 | DemoHelper::DEFAULT_VIEW_STYLE); | 271 | DemoHelper::DEFAULT_VIEW_STYLE); |
| 257 | 272 | ||
| 258 | mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) ); | 273 | mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) ); |
| 259 | - mRootActor.SetFixedHeight( 0, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight ); | 274 | + const float toolbarHeight = DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight; |
| 275 | + mRootActor.SetFixedHeight( 0, toolbarHeight ); | ||
| 260 | 276 | ||
| 261 | // Add logo | 277 | // Add logo |
| 262 | mLogo = CreateLogo( LOGO_PATH ); | 278 | mLogo = CreateLogo( LOGO_PATH ); |
| 263 | - mRootActor.SetFixedHeight( 1, mLogo.GetImage().GetHeight() + LOGO_BOTTOM_PADDING_HEIGHT ); | 279 | + const float logoHeight = mLogo.GetImage().GetHeight() + DP(LOGO_MARGIN); |
| 280 | + mRootActor.SetFixedHeight( 1, logoHeight ); | ||
| 281 | + | ||
| 282 | + mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, ( stageSize.height - toolbarHeight - logoHeight - DP( BOTTOM_PADDING_HEIGHT ) ) / stageSize.height, TABLE_RELATIVE_SIZE.z ); | ||
| 283 | + | ||
| 284 | + mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); | ||
| 264 | 285 | ||
| 265 | Alignment alignment = Alignment::New(); | 286 | Alignment alignment = Alignment::New(); |
| 266 | alignment.Add(mLogo); | 287 | alignment.Add(mLogo); |
| @@ -271,7 +292,8 @@ void DaliTableView::Initialize( Application& application ) | @@ -271,7 +292,8 @@ void DaliTableView::Initialize( Application& application ) | ||
| 271 | 292 | ||
| 272 | mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); | 293 | mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); |
| 273 | mScrollView.SetParentOrigin( ParentOrigin::CENTER ); | 294 | mScrollView.SetParentOrigin( ParentOrigin::CENTER ); |
| 274 | - mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::RelativeToConstraint( TABLE_RELATIVE_SIZE ) ) ); | 295 | + mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), |
| 296 | + Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); | ||
| 275 | mScrollView.SetAxisAutoLock( true ); | 297 | mScrollView.SetAxisAutoLock( true ); |
| 276 | mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); | 298 | mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); |
| 277 | mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); | 299 | mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); |
| @@ -280,37 +302,22 @@ void DaliTableView::Initialize( Application& application ) | @@ -280,37 +302,22 @@ void DaliTableView::Initialize( Application& application ) | ||
| 280 | mScrollViewLayer = Layer::New(); | 302 | mScrollViewLayer = Layer::New(); |
| 281 | mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); | 303 | mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); |
| 282 | mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); | 304 | mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); |
| 283 | - mScrollViewLayer.SetSize( stageSize ); | 305 | + mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY ); |
| 306 | + | ||
| 307 | + // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show | ||
| 308 | + SetupBackground( mScrollView, mScrollViewLayer, stageSize ); | ||
| 309 | + | ||
| 284 | mScrollViewLayer.Add( mScrollView ); | 310 | mScrollViewLayer.Add( mScrollView ); |
| 285 | mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) ); | 311 | mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) ); |
| 286 | 312 | ||
| 287 | - // Setup the scenegraph | ||
| 288 | - // 1) Add scroll view effect and setup constraints on pages | 313 | + // Add scroll view effect and setup constraints on pages |
| 289 | ApplyScrollViewEffect(); | 314 | ApplyScrollViewEffect(); |
| 290 | 315 | ||
| 291 | - // 2) Add pages and tiles | 316 | + // Add pages and tiles |
| 292 | Populate(); | 317 | Populate(); |
| 293 | 318 | ||
| 294 | - // 3) Populate scrollview with background so constraints on background layers can work with scrollview | ||
| 295 | - SetupBackground( mScrollView, stageSize ); | ||
| 296 | - | ||
| 297 | - // 4) Remove constraints for inner cube effect | ||
| 298 | - for( TableViewListIter pageIter = mTableViewList.begin(); pageIter != mTableViewList.end(); ++pageIter ) | ||
| 299 | - { | ||
| 300 | - TableView page = *pageIter; | ||
| 301 | - | ||
| 302 | - unsigned int numChildren = page.GetChildCount(); | ||
| 303 | - Actor pageActor = page; | ||
| 304 | - for( unsigned int i=0; i<numChildren; ++i) | ||
| 305 | - { | ||
| 306 | - // Remove old effect's manual constraints. | ||
| 307 | - Actor child = pageActor.GetChildAt(i); | ||
| 308 | - if( child ) | ||
| 309 | - { | ||
| 310 | - child.RemoveConstraints(); | ||
| 311 | - } | ||
| 312 | - } | ||
| 313 | - } | 319 | + // Remove constraints for inner cube effect |
| 320 | + ApplyCubeEffectToActors(); | ||
| 314 | 321 | ||
| 315 | // Set initial orientation | 322 | // Set initial orientation |
| 316 | unsigned int degrees = application.GetOrientation().GetDegrees(); | 323 | unsigned int degrees = application.GetOrientation().GetDegrees(); |
| @@ -337,12 +344,29 @@ void DaliTableView::Initialize( Application& application ) | @@ -337,12 +344,29 @@ void DaliTableView::Initialize( Application& application ) | ||
| 337 | KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); | 344 | KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); |
| 338 | } | 345 | } |
| 339 | 346 | ||
| 347 | +void DaliTableView::ApplyCubeEffectToActors() | ||
| 348 | +{ | ||
| 349 | + for( ActorIter pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter ) | ||
| 350 | + { | ||
| 351 | + Actor page = *pageIter; | ||
| 352 | + | ||
| 353 | + unsigned int numChildren = page.GetChildCount(); | ||
| 354 | + Actor pageActor = page; | ||
| 355 | + for( unsigned int i=0; i<numChildren; ++i) | ||
| 356 | + { | ||
| 357 | + // Remove old effect's manual constraints. | ||
| 358 | + Actor child = pageActor.GetChildAt(i); | ||
| 359 | + if( child ) | ||
| 360 | + { | ||
| 361 | + ApplyCubeEffectToActor( child ); | ||
| 362 | + } | ||
| 363 | + } | ||
| 364 | + } | ||
| 365 | +} | ||
| 340 | void DaliTableView::Populate() | 366 | void DaliTableView::Populate() |
| 341 | { | 367 | { |
| 342 | const Vector2 stageSize = Stage::GetCurrent().GetSize(); | 368 | const Vector2 stageSize = Stage::GetCurrent().GetSize(); |
| 343 | 369 | ||
| 344 | - const Size demoTileSize( 0.25f * stageSize.width, 0.25f * stageSize.height ); | ||
| 345 | - | ||
| 346 | mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE; | 370 | mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE; |
| 347 | 371 | ||
| 348 | // Populate ScrollView. | 372 | // Populate ScrollView. |
| @@ -355,41 +379,32 @@ void DaliTableView::Populate() | @@ -355,41 +379,32 @@ void DaliTableView::Populate() | ||
| 355 | 379 | ||
| 356 | unsigned int exampleCount = 0; | 380 | unsigned int exampleCount = 0; |
| 357 | ExampleListConstIter iter = mExampleList.begin(); | 381 | ExampleListConstIter iter = mExampleList.begin(); |
| 382 | + | ||
| 358 | for( int t = 0; t < mTotalPages; t++ ) | 383 | for( int t = 0; t < mTotalPages; t++ ) |
| 359 | { | 384 | { |
| 360 | // Create Table. (contains up to 9 Examples) | 385 | // Create Table. (contains up to 9 Examples) |
| 361 | - TableView tableView = TableView::New( 4, 3 ); | 386 | + Actor page = Actor::New(); |
| 387 | + | ||
| 362 | // Add tableView to container. | 388 | // Add tableView to container. |
| 363 | - mScrollView.Add( tableView ); | ||
| 364 | - ApplyEffectToPage( tableView, TABLE_RELATIVE_SIZE ); | ||
| 365 | - | ||
| 366 | - tableView.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 367 | - tableView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 368 | - // 2 pixels of padding | ||
| 369 | - tableView.SetCellPadding( Size( 2.0f, 2.0f ) ); | ||
| 370 | - | ||
| 371 | - Constraint constraint = Constraint::New<Vector3>( Actor::SCALE, | ||
| 372 | - LocalSource( Actor::SIZE ), | ||
| 373 | - ParentSource( Actor::SIZE ), | ||
| 374 | - ScaleToFitConstraint() ); | ||
| 375 | - tableView.ApplyConstraint(constraint); | ||
| 376 | - | ||
| 377 | - // Apply visibility constraint to table view | ||
| 378 | - Constraint visibleConstraint = Constraint::New< bool >( Actor::VISIBLE, | ||
| 379 | - LocalSource( Actor::POSITION ), | ||
| 380 | - ParentSource( Actor::SIZE ), | ||
| 381 | - TableViewVisibilityConstraint() ); | ||
| 382 | - visibleConstraint.SetRemoveAction( Constraint::Discard ); | ||
| 383 | - tableView.ApplyConstraint( visibleConstraint ); | 389 | + mScrollView.Add( page ); |
| 390 | + | ||
| 391 | + page.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 392 | + page.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 393 | + page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 384 | 394 | ||
| 385 | // add cells to table | 395 | // add cells to table |
| 386 | - for( int y = 0; y < ROWS_PER_PAGE; y++ ) | 396 | + const float margin = 4.0f; |
| 397 | + | ||
| 398 | + // Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi. | ||
| 399 | + const Size tileSize((stageSize.x * mButtonsPageRelativeSize.x / EXAMPLES_PER_ROW) - margin, (stageSize.y * mButtonsPageRelativeSize.y / ROWS_PER_PAGE) - margin ); | ||
| 400 | + | ||
| 401 | + for(int row = 0; row < ROWS_PER_PAGE; row++) | ||
| 387 | { | 402 | { |
| 388 | - for( int x = 0; x < EXAMPLES_PER_ROW; x++ ) | 403 | + for(int column = 0; column < EXAMPLES_PER_ROW; column++) |
| 389 | { | 404 | { |
| 390 | const Example& example = ( *iter ); | 405 | const Example& example = ( *iter ); |
| 391 | 406 | ||
| 392 | - Actor tile = CreateTile( example.name, example.title, demoTileSize, true ); | 407 | + Actor tile = CreateTile( example.name, example.title, tileSize, true ); |
| 393 | FocusManager focusManager = FocusManager::Get(); | 408 | FocusManager focusManager = FocusManager::Get(); |
| 394 | focusManager.SetFocusOrder( tile, ++exampleCount ); | 409 | focusManager.SetFocusOrder( tile, ++exampleCount ); |
| 395 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL, | 410 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL, |
| @@ -398,7 +413,13 @@ void DaliTableView::Populate() | @@ -398,7 +413,13 @@ void DaliTableView::Populate() | ||
| 398 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT, | 413 | focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT, |
| 399 | "You can run this example" ); | 414 | "You can run this example" ); |
| 400 | 415 | ||
| 401 | - tableView.AddChild( tile, TableView::CellPosition( y, x ) ); | 416 | + Vector3 position( margin * 0.5f + (tileSize.x + margin) * column - stageSize.width * mButtonsPageRelativeSize.x * 0.5f, |
| 417 | + margin * 0.5f + (tileSize.y + margin) * row - stageSize.height * mButtonsPageRelativeSize.y * 0.5f, | ||
| 418 | + 0.0f); | ||
| 419 | + tile.SetPosition( position + Vector3( tileSize.x, tileSize.y, 0.0f ) * 0.5f ); | ||
| 420 | + tile.SetSize( tileSize ); | ||
| 421 | + page.Add( tile ); | ||
| 422 | + | ||
| 402 | iter++; | 423 | iter++; |
| 403 | 424 | ||
| 404 | if( iter == mExampleList.end() ) | 425 | if( iter == mExampleList.end() ) |
| @@ -406,31 +427,18 @@ void DaliTableView::Populate() | @@ -406,31 +427,18 @@ void DaliTableView::Populate() | ||
| 406 | break; | 427 | break; |
| 407 | } | 428 | } |
| 408 | } | 429 | } |
| 430 | + | ||
| 409 | if( iter == mExampleList.end() ) | 431 | if( iter == mExampleList.end() ) |
| 410 | { | 432 | { |
| 411 | break; | 433 | break; |
| 412 | } | 434 | } |
| 413 | } | 435 | } |
| 414 | 436 | ||
| 415 | - // last row is thin. | ||
| 416 | - tableView.SetFixedHeight( 3, BOTTOM_ROW_HEIGHT ); | ||
| 417 | - | ||
| 418 | - std::stringstream out; | ||
| 419 | - out << ( t + 1 ) << " of " << mTotalPages; | ||
| 420 | - Actor pageNumberText = CreateTile( "", out.str(), Size( 0.8f * stageSize.width, BOTTOM_ROW_HEIGHT ), false ); | ||
| 421 | - | ||
| 422 | - pageNumberText.ApplyConstraint( Constraint::New< Vector3 >( Actor::POSITION, Source( tableView, Actor::WORLD_POSITION), | ||
| 423 | - TranslateLocalConstraint( Vector3( 0.0f, stageSize.y * 0.4f, 0.0f ) ) ) ); | ||
| 424 | - pageNumberText.ApplyConstraint( Constraint::New< Quaternion >( Actor::ROTATION, Source( tableView, Actor::WORLD_ROTATION ), EqualToConstraint() ) ); | ||
| 425 | - pageNumberText.ApplyConstraint( Constraint::New< Vector4 >( Actor::COLOR, Source( tableView, Actor::COLOR ), EqualToConstraint() ) ); | ||
| 426 | - | ||
| 427 | - //Stage::GetCurrent().Add( pageNumberText ); | ||
| 428 | - | ||
| 429 | // Set tableview position | 437 | // Set tableview position |
| 430 | - Vector3 tableViewPos( stageSize.x * TABLE_RELATIVE_SIZE.x * t, 0.0f, 0.0f ); | ||
| 431 | - tableView.SetPosition( tableViewPos ); | 438 | + Vector3 pagePos( stageSize.x * mButtonsPageRelativeSize.x * t, 0.0f, 0.0f ); |
| 439 | + page.SetPosition( pagePos ); | ||
| 432 | 440 | ||
| 433 | - mTableViewList.push_back( tableView ); | 441 | + mPages.push_back( page ); |
| 434 | 442 | ||
| 435 | if( iter == mExampleList.end() ) | 443 | if( iter == mExampleList.end() ) |
| 436 | { | 444 | { |
| @@ -440,9 +448,9 @@ void DaliTableView::Populate() | @@ -440,9 +448,9 @@ void DaliTableView::Populate() | ||
| 440 | } | 448 | } |
| 441 | 449 | ||
| 442 | // Update Ruler info. | 450 | // Update Ruler info. |
| 443 | - mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x ); | 451 | + mScrollRulerX = new FixedRuler( stageSize.width * mButtonsPageRelativeSize.x ); |
| 444 | mScrollRulerY = new DefaultRuler(); | 452 | mScrollRulerY = new DefaultRuler(); |
| 445 | - mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.x, true ) ); | 453 | + mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * mButtonsPageRelativeSize.x, true ) ); |
| 446 | mScrollRulerY->Disable(); | 454 | mScrollRulerY->Disable(); |
| 447 | mScrollView.SetRulerX( mScrollRulerX ); | 455 | mScrollView.SetRulerX( mScrollRulerX ); |
| 448 | mScrollView.SetRulerY( mScrollRulerY ); | 456 | mScrollView.SetRulerY( mScrollRulerY ); |
| @@ -483,9 +491,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | @@ -483,9 +491,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | ||
| 483 | tile.SetAnchorPoint( AnchorPoint::CENTER ); | 491 | tile.SetAnchorPoint( AnchorPoint::CENTER ); |
| 484 | tile.SetParentOrigin( ParentOrigin::CENTER ); | 492 | tile.SetParentOrigin( ParentOrigin::CENTER ); |
| 485 | 493 | ||
| 486 | - // make the tile 100% of parent | ||
| 487 | - tile.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 488 | - | ||
| 489 | Actor content = Actor::New(); | 494 | Actor content = Actor::New(); |
| 490 | content.SetAnchorPoint( AnchorPoint::CENTER ); | 495 | content.SetAnchorPoint( AnchorPoint::CENTER ); |
| 491 | content.SetParentOrigin( ParentOrigin::CENTER ); | 496 | content.SetParentOrigin( ParentOrigin::CENTER ); |
| @@ -641,8 +646,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3& position ) | @@ -641,8 +646,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3& position ) | ||
| 641 | 646 | ||
| 642 | // move focus to 1st item of new page | 647 | // move focus to 1st item of new page |
| 643 | FocusManager focusManager = FocusManager::Get(); | 648 | FocusManager focusManager = FocusManager::Get(); |
| 644 | - focusManager.SetCurrentFocusActor(mTableViewList[mScrollView.GetCurrentPage()].GetChildAt(TableView::CellPosition(1, 0)) ); | 649 | + focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); |
| 645 | 650 | ||
| 651 | + ApplyCubeEffectToActors(); | ||
| 646 | } | 652 | } |
| 647 | 653 | ||
| 648 | bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) | 654 | bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) |
| @@ -673,36 +679,21 @@ void DaliTableView::ApplyScrollViewEffect() | @@ -673,36 +679,21 @@ void DaliTableView::ApplyScrollViewEffect() | ||
| 673 | 679 | ||
| 674 | void DaliTableView::SetupInnerPageCubeEffect() | 680 | void DaliTableView::SetupInnerPageCubeEffect() |
| 675 | { | 681 | { |
| 676 | - ScrollViewCustomEffect customEffect; | ||
| 677 | - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); | 682 | + mScrollViewEffect = ScrollViewCubeEffect::New(); |
| 678 | mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION ); | 683 | mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION ); |
| 679 | mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION ); | 684 | mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION ); |
| 680 | mScrollView.RemoveConstraintsFromChildren(); | 685 | mScrollView.RemoveConstraintsFromChildren(); |
| 681 | - | ||
| 682 | - customEffect.SetPageSpacing( Vector2( 30.0f, 30.0f ) ); | ||
| 683 | - customEffect.SetAngledOriginPageRotation( ANGLE_CUBE_PAGE_ROTATE ); | ||
| 684 | - customEffect.SetSwingAngle( ANGLE_CUBE_PAGE_ROTATE.x, Vector3( 0, -1, 0 ) ); | ||
| 685 | - customEffect.SetOpacityThreshold( 0.5f ); // Make fade out on edges | ||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | -void DaliTableView::ApplyEffectToPage( Actor page, const Vector3& tableRelativeSize ) | 688 | +void DaliTableView::ApplyCubeEffectToActor( Actor actor ) |
| 689 | { | 689 | { |
| 690 | - page.RemoveConstraints(); | 690 | + actor.RemoveConstraints(); |
| 691 | 691 | ||
| 692 | - Constraint constraint = Constraint::New<Vector3>( Actor::SCALE, | ||
| 693 | - LocalSource( Actor::SIZE ), | ||
| 694 | - ParentSource( Actor::SIZE ), | ||
| 695 | - ScaleToFitConstraint() ); | ||
| 696 | - page.ApplyConstraint(constraint); | ||
| 697 | - | ||
| 698 | - ApplyCustomEffectToPage( page ); | ||
| 699 | -} | ||
| 700 | - | ||
| 701 | -void DaliTableView::ApplyCustomEffectToPage( Actor page ) | ||
| 702 | -{ | ||
| 703 | - ScrollViewCustomEffect customEffect = ScrollViewCustomEffect::DownCast( mScrollViewEffect ); | ||
| 704 | - Vector2 vStageSize( Stage::GetCurrent().GetSize() ); | ||
| 705 | - customEffect.ApplyToPage( page, Vector3( vStageSize.x, vStageSize.y, 1.0f ) ); | 692 | + ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect); |
| 693 | + cubeEffect.ApplyToActor( actor, | ||
| 694 | + ScalePointSize( ( rand() & 1 ) ? ANCHOR_3DEFFECT_STYLE0 : ANCHOR_3DEFFECT_STYLE1 ), | ||
| 695 | + ANGLE_SWING_3DEFFECT, | ||
| 696 | + POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize())); | ||
| 706 | } | 697 | } |
| 707 | 698 | ||
| 708 | void DaliTableView::OnKeyEvent( const KeyEvent& event ) | 699 | void DaliTableView::OnKeyEvent( const KeyEvent& event ) |
| @@ -725,7 +716,7 @@ Actor CreateBackgroundActor( const Vector2& size ) | @@ -725,7 +716,7 @@ Actor CreateBackgroundActor( const Vector2& size ) | ||
| 725 | return layer; | 716 | return layer; |
| 726 | } | 717 | } |
| 727 | 718 | ||
| 728 | -void DaliTableView::SetupBackground( Actor addToLayer, const Vector2& size ) | 719 | +void DaliTableView::SetupBackground( Actor bubbleLayer, Actor backgroundLayer, const Vector2& size ) |
| 729 | { | 720 | { |
| 730 | // Create distance field shape | 721 | // Create distance field shape |
| 731 | BitmapImage distanceField; | 722 | BitmapImage distanceField; |
| @@ -760,13 +751,12 @@ void DaliTableView::SetupBackground( Actor addToLayer, const Vector2& size ) | @@ -760,13 +751,12 @@ void DaliTableView::SetupBackground( Actor addToLayer, const Vector2& size ) | ||
| 760 | layer.SetSize( size * BACKGROUND_SIZE_SCALE ); | 751 | layer.SetSize( size * BACKGROUND_SIZE_SCALE ); |
| 761 | layer.SetZ( BACKGROUND_Z ); | 752 | layer.SetZ( BACKGROUND_Z ); |
| 762 | layer.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); | 753 | layer.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); |
| 763 | - | ||
| 764 | - addToLayer.Add( layer ); | 754 | + backgroundLayer.Add( layer ); |
| 765 | 755 | ||
| 766 | // Parent the layers | 756 | // Parent the layers |
| 767 | - addToLayer.Add( backgroundAnimLayer0 ); | ||
| 768 | - addToLayer.Add( backgroundAnimLayer1 ); | ||
| 769 | - addToLayer.Add( backgroundAnimLayer2 ); | 757 | + bubbleLayer.Add( backgroundAnimLayer0 ); |
| 758 | + bubbleLayer.Add( backgroundAnimLayer1 ); | ||
| 759 | + bubbleLayer.Add( backgroundAnimLayer2 ); | ||
| 770 | 760 | ||
| 771 | // Add all the children | 761 | // Add all the children |
| 772 | AddBackgroundActors( backgroundAnimLayer0, NUM_BACKGROUND_IMAGES / 3, distanceField, size ); | 762 | AddBackgroundActors( backgroundAnimLayer0, NUM_BACKGROUND_IMAGES / 3, distanceField, size ); |
| @@ -798,7 +788,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis | @@ -798,7 +788,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis | ||
| 798 | Vector3 actorPos( | 788 | Vector3 actorPos( |
| 799 | Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), | 789 | Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), |
| 800 | Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), | 790 | Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), |
| 801 | - Random::Range(-1.0f, 0.0f) ); | 791 | + Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); |
| 802 | dfActor.SetPosition( actorPos ); | 792 | dfActor.SetPosition( actorPos ); |
| 803 | 793 | ||
| 804 | Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION, | 794 | Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION, |
| @@ -942,7 +932,7 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: | @@ -942,7 +932,7 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: | ||
| 942 | if ( !current && !proposed ) | 932 | if ( !current && !proposed ) |
| 943 | { | 933 | { |
| 944 | // Set the initial focus to the first tile in the current page should be focused. | 934 | // Set the initial focus to the first tile in the current page should be focused. |
| 945 | - nextFocusActor = mTableViewList[mScrollView.GetCurrentPage()].GetChildAt(TableView::CellPosition(0, 0)); | 935 | + nextFocusActor = mPages[mScrollView.GetCurrentPage()].GetChildAt(0); |
| 946 | } | 936 | } |
| 947 | else if( !proposed || (proposed && proposed == mScrollViewLayer) ) | 937 | else if( !proposed || (proposed && proposed == mScrollViewLayer) ) |
| 948 | { | 938 | { |
| @@ -982,12 +972,12 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: | @@ -982,12 +972,12 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: | ||
| 982 | int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 ); | 972 | int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 ); |
| 983 | 973 | ||
| 984 | // Move the focus to the last tile in the new page. | 974 | // Move the focus to the last tile in the new page. |
| 985 | - nextFocusActor = mTableViewList[newPage].GetChildAt(TableView::CellPosition(rowPos, colPos)); | 975 | + nextFocusActor = mPages[newPage].GetChildAt(colPos * EXAMPLES_PER_ROW + rowPos); |
| 986 | } | 976 | } |
| 987 | else | 977 | else |
| 988 | { | 978 | { |
| 989 | // Move the focus to the first tile in the new page. | 979 | // Move the focus to the first tile in the new page. |
| 990 | - nextFocusActor = mTableViewList[newPage].GetChildAt(TableView::CellPosition(0, 0)); | 980 | + nextFocusActor = mPages[newPage].GetChildAt(0); |
| 991 | } | 981 | } |
| 992 | } | 982 | } |
| 993 | 983 |
demo/dali-table-view.h
| @@ -243,19 +243,19 @@ private: // Application callbacks & implementation | @@ -243,19 +243,19 @@ private: // Application callbacks & implementation | ||
| 243 | void ApplyScrollViewEffect(); | 243 | void ApplyScrollViewEffect(); |
| 244 | 244 | ||
| 245 | /** | 245 | /** |
| 246 | - * Setup the inner cube effect | 246 | + * Apply the cube effect to all the page actors |
| 247 | */ | 247 | */ |
| 248 | - void SetupInnerPageCubeEffect(); | 248 | + void ApplyCubeEffectToActors(); |
| 249 | 249 | ||
| 250 | /** | 250 | /** |
| 251 | - * Apply the scroll view effect to a page | 251 | + * Setup the inner cube effect |
| 252 | */ | 252 | */ |
| 253 | - void ApplyEffectToPage(Dali::Actor page, const Dali::Vector3& tableRelativeSize); | 253 | + void SetupInnerPageCubeEffect(); |
| 254 | 254 | ||
| 255 | /** | 255 | /** |
| 256 | - * Apply a custom effect scroll view effect to a page | 256 | + * Apply the cube effect to an actor |
| 257 | */ | 257 | */ |
| 258 | - void ApplyCustomEffectToPage(Dali::Actor page); | 258 | + void ApplyCubeEffectToActor( Dali::Actor actor ); |
| 259 | 259 | ||
| 260 | /** | 260 | /** |
| 261 | * Apply a shader effect to a table tile | 261 | * Apply a shader effect to a table tile |
| @@ -275,9 +275,10 @@ private: // Application callbacks & implementation | @@ -275,9 +275,10 @@ private: // Application callbacks & implementation | ||
| 275 | /** | 275 | /** |
| 276 | * Create a depth field background | 276 | * Create a depth field background |
| 277 | * | 277 | * |
| 278 | - * @param[in] addToLayer Add the graphics to this layer | 278 | + * @param[in] bubbleLayer Add the graphics to this layer |
| 279 | + * @param[in] backgroundLayer Add the background to this layer | ||
| 279 | */ | 280 | */ |
| 280 | - void SetupBackground( Dali::Actor addToLayer, const Dali::Vector2& size ); | 281 | + void SetupBackground( Dali::Actor bubbleLayer, Dali::Actor backgroundLayer, const Dali::Vector2& size ); |
| 281 | 282 | ||
| 282 | /** | 283 | /** |
| 283 | * Create background actors for the given layer | 284 | * Create background actors for the given layer |
| @@ -378,7 +379,7 @@ private: | @@ -378,7 +379,7 @@ private: | ||
| 378 | Dali::Toolkit::TableView mButtons; ///< Navigation buttons | 379 | Dali::Toolkit::TableView mButtons; ///< Navigation buttons |
| 379 | ExampleList mExampleList; ///< List of examples. | 380 | ExampleList mExampleList; ///< List of examples. |
| 380 | ExampleMap mExampleMap; ///< Map LUT for examples. | 381 | ExampleMap mExampleMap; ///< Map LUT for examples. |
| 381 | - TableViewList mTableViewList; ///< List of tableviews | 382 | + Dali::ActorContainer mPages; ///< List of pages. |
| 382 | Dali::Actor mPressedActor; ///< The currently pressed actor. | 383 | Dali::Actor mPressedActor; ///< The currently pressed actor. |
| 383 | int mTotalPages; ///< Total pages within scrollview. | 384 | int mTotalPages; ///< Total pages within scrollview. |
| 384 | std::string mBackgroundImagePath; ///< The path to the background image. | 385 | std::string mBackgroundImagePath; ///< The path to the background image. |
| @@ -390,6 +391,8 @@ private: | @@ -390,6 +391,8 @@ private: | ||
| 390 | AnimationList mBackgroundAnimations;///< List of background bubble animations | 391 | AnimationList mBackgroundAnimations;///< List of background bubble animations |
| 391 | Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period | 392 | Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period |
| 392 | bool mBackgroundAnimsPlaying; ///< Are background animations playing | 393 | bool mBackgroundAnimsPlaying; ///< Are background animations playing |
| 394 | + | ||
| 395 | + Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size | ||
| 393 | }; | 396 | }; |
| 394 | 397 | ||
| 395 | #endif // __DALI_DEMO_H__ | 398 | #endif // __DALI_DEMO_H__ |
demo/models/surface_pattern_v01.obj
0 โ 100755
| 1 | +# This file uses centimeters as units for non-parametric coordinates. | ||
| 2 | + | ||
| 3 | +v 41.569229 47.497040 -1.497040 | ||
| 4 | +v 36.373077 50.500000 -1.500000 | ||
| 5 | +v 51.961536 47.497040 -1.497040 | ||
| 6 | +v 46.765385 50.500000 -1.500000 | ||
| 7 | +v 62.349571 47.497536 -1.497533 | ||
| 8 | +v 57.157692 50.500000 -1.500000 | ||
| 9 | +v 36.373077 56.500000 -1.500000 | ||
| 10 | +v 36.373077 50.500000 -1.500000 | ||
| 11 | +v 46.765381 50.500000 -1.500000 | ||
| 12 | +v 46.765381 56.500000 -1.500000 | ||
| 13 | +v 41.569229 59.500000 -1.500000 | ||
| 14 | +v 41.569229 53.500000 1.500000 | ||
| 15 | +v 46.765385 56.500000 -1.500000 | ||
| 16 | +v 46.765385 50.500000 -1.500000 | ||
| 17 | +v 57.157688 50.500000 -1.500000 | ||
| 18 | +v 57.157688 56.500000 -1.500000 | ||
| 19 | +v 51.961536 59.500000 -1.500000 | ||
| 20 | +v 51.961536 53.500000 1.500000 | ||
| 21 | +v 57.157692 56.500000 -1.500000 | ||
| 22 | +v 57.157692 50.500000 -1.500000 | ||
| 23 | +v 62.353844 59.500000 -1.500000 | ||
| 24 | +v 62.353844 53.500000 1.500000 | ||
| 25 | +v 36.373077 56.500000 -1.500000 | ||
| 26 | +v 41.569229 59.500000 -1.500000 | ||
| 27 | +v 41.569229 65.500000 -1.500000 | ||
| 28 | +v 36.373077 68.500000 -1.500000 | ||
| 29 | +v 36.373077 62.500000 1.500000 | ||
| 30 | +v 41.569233 65.500000 -1.500000 | ||
| 31 | +v 41.569233 59.500000 -1.500000 | ||
| 32 | +v 46.765385 56.500000 -1.500000 | ||
| 33 | +v 51.961536 59.500000 -1.500000 | ||
| 34 | +v 51.961536 65.500000 -1.500000 | ||
| 35 | +v 46.765385 68.500000 -1.500000 | ||
| 36 | +v 46.765385 62.500000 1.500000 | ||
| 37 | +v 51.961540 65.500000 -1.500000 | ||
| 38 | +v 51.961540 59.500000 -1.500000 | ||
| 39 | +v 57.157692 56.500000 -1.500000 | ||
| 40 | +v 62.353844 59.500000 -1.500000 | ||
| 41 | +v 62.353844 65.500000 -1.500000 | ||
| 42 | +v 57.157692 68.500000 -1.500000 | ||
| 43 | +v 57.157692 62.500000 1.500000 | ||
| 44 | +v 36.373077 74.500000 -1.500000 | ||
| 45 | +v 36.373077 68.500000 -1.500000 | ||
| 46 | +v 41.569229 65.500000 -1.500000 | ||
| 47 | +v 46.765381 68.500000 -1.500000 | ||
| 48 | +v 46.765381 74.500000 -1.500000 | ||
| 49 | +v 41.569229 77.500000 -1.500000 | ||
| 50 | +v 41.569229 71.500000 1.500000 | ||
| 51 | +v 46.765385 74.500000 -1.500000 | ||
| 52 | +v 46.765385 68.500000 -1.500000 | ||
| 53 | +v 51.961536 65.500000 -1.500000 | ||
| 54 | +v 57.157688 68.500000 -1.500000 | ||
| 55 | +v 57.157688 74.500000 -1.500000 | ||
| 56 | +v 51.961536 77.500000 -1.500000 | ||
| 57 | +v 51.961536 71.500000 1.500000 | ||
| 58 | +v 57.157692 74.500000 -1.500000 | ||
| 59 | +v 57.157692 68.500000 -1.500000 | ||
| 60 | +v 62.353844 65.500000 -1.500000 | ||
| 61 | +v 62.353844 77.500000 -1.500000 | ||
| 62 | +v 62.353844 71.500000 1.500000 | ||
| 63 | +v 36.373077 74.500000 -1.500000 | ||
| 64 | +v 41.569229 77.500000 -1.500000 | ||
| 65 | +v 41.569229 83.500000 -1.500000 | ||
| 66 | +v 36.373077 86.500000 -1.500000 | ||
| 67 | +v 36.373077 80.500000 1.500000 | ||
| 68 | +v 41.569233 83.500000 -1.500000 | ||
| 69 | +v 41.569233 77.500000 -1.500000 | ||
| 70 | +v 46.765385 74.500000 -1.500000 | ||
| 71 | +v 51.961536 77.500000 -1.500000 | ||
| 72 | +v 51.961536 83.500000 -1.500000 | ||
| 73 | +v 46.765385 86.500000 -1.500000 | ||
| 74 | +v 46.765385 80.500000 1.500000 | ||
| 75 | +v 51.961540 83.500000 -1.500000 | ||
| 76 | +v 51.961540 77.500000 -1.500000 | ||
| 77 | +v 57.157692 74.500000 -1.500000 | ||
| 78 | +v 62.353844 77.500000 -1.500000 | ||
| 79 | +v 62.353844 83.500000 -1.500000 | ||
| 80 | +v 57.157692 86.500000 -1.500000 | ||
| 81 | +v 57.157692 80.500000 1.500000 | ||
| 82 | +v 36.373077 86.500000 -1.500000 | ||
| 83 | +v 41.569229 83.500000 -1.500000 | ||
| 84 | +v 46.765381 86.500000 -1.500000 | ||
| 85 | +v 41.569229 89.504967 1.495031 | ||
| 86 | +v 46.765385 86.500000 -1.500000 | ||
| 87 | +v 51.961536 83.500000 -1.500000 | ||
| 88 | +v 57.157688 86.500000 -1.500000 | ||
| 89 | +v 51.961540 89.504967 1.495031 | ||
| 90 | +v 57.157692 86.500000 -1.500000 | ||
| 91 | +v 62.353844 83.500000 -1.500000 | ||
| 92 | +v 62.347389 89.503723 1.496273 | ||
| 93 | +v 46.765381 89.507454 -1.500000 | ||
| 94 | +v 57.157688 89.507454 -1.500000 | ||
| 95 | +v 36.373077 89.507446 -1.500000 | ||
| 96 | +v 46.765381 89.507446 -1.500000 | ||
| 97 | +v 57.157692 89.507446 -1.500000 | ||
| 98 | +v 36.373077 47.492599 0.003700 | ||
| 99 | +v 46.765385 47.492599 0.003700 | ||
| 100 | +v 57.157692 47.492599 0.003700 | ||
| 101 | + | ||
| 102 | +f 1 2 96 | ||
| 103 | +f 3 4 97 | ||
| 104 | +f 4 1 97 | ||
| 105 | +f 6 98 5 | ||
| 106 | +f 6 3 98 | ||
| 107 | +f 7 8 12 | ||
| 108 | +f 8 1 12 | ||
| 109 | +f 1 9 12 | ||
| 110 | +f 9 10 12 | ||
| 111 | +f 10 11 12 | ||
| 112 | +f 11 7 12 | ||
| 113 | +f 13 14 18 | ||
| 114 | +f 14 3 18 | ||
| 115 | +f 3 15 18 | ||
| 116 | +f 15 16 18 | ||
| 117 | +f 16 17 18 | ||
| 118 | +f 17 13 18 | ||
| 119 | +f 19 20 22 | ||
| 120 | +f 20 5 22 | ||
| 121 | +f 21 19 22 | ||
| 122 | +f 23 24 27 | ||
| 123 | +f 24 25 27 | ||
| 124 | +f 25 26 27 | ||
| 125 | +f 28 29 34 | ||
| 126 | +f 29 30 34 | ||
| 127 | +f 30 31 34 | ||
| 128 | +f 31 32 34 | ||
| 129 | +f 32 33 34 | ||
| 130 | +f 33 28 34 | ||
| 131 | +f 35 36 41 | ||
| 132 | +f 36 37 41 | ||
| 133 | +f 37 38 41 | ||
| 134 | +f 38 39 41 | ||
| 135 | +f 39 40 41 | ||
| 136 | +f 40 35 41 | ||
| 137 | +f 42 43 48 | ||
| 138 | +f 43 44 48 | ||
| 139 | +f 44 45 48 | ||
| 140 | +f 45 46 48 | ||
| 141 | +f 46 47 48 | ||
| 142 | +f 47 42 48 | ||
| 143 | +f 49 50 55 | ||
| 144 | +f 50 51 55 | ||
| 145 | +f 51 52 55 | ||
| 146 | +f 52 53 55 | ||
| 147 | +f 53 54 55 | ||
| 148 | +f 54 49 55 | ||
| 149 | +f 56 57 60 | ||
| 150 | +f 57 58 60 | ||
| 151 | +f 59 56 60 | ||
| 152 | +f 61 62 65 | ||
| 153 | +f 62 63 65 | ||
| 154 | +f 63 64 65 | ||
| 155 | +f 66 67 72 | ||
| 156 | +f 67 68 72 | ||
| 157 | +f 68 69 72 | ||
| 158 | +f 69 70 72 | ||
| 159 | +f 70 71 72 | ||
| 160 | +f 71 66 72 | ||
| 161 | +f 73 74 79 | ||
| 162 | +f 74 75 79 | ||
| 163 | +f 75 76 79 | ||
| 164 | +f 76 77 79 | ||
| 165 | +f 77 78 79 | ||
| 166 | +f 78 73 79 | ||
| 167 | +f 80 81 83 | ||
| 168 | +f 81 82 83 | ||
| 169 | +f 82 91 83 | ||
| 170 | +f 84 85 87 | ||
| 171 | +f 85 86 87 | ||
| 172 | +f 86 92 87 | ||
| 173 | +f 88 89 90 | ||
| 174 | +f 83 93 80 | ||
| 175 | +f 87 94 84 | ||
| 176 | +f 90 95 88 |
demo/models/surface_pattern_v02.obj
0 โ 100644
| 1 | +# WaveFront *.obj file (generated by CINEMA 4D) | ||
| 2 | + | ||
| 3 | +g Plane_2 | ||
| 4 | +v 1315.930042 2533.151253 120.777515 | ||
| 5 | +v 731.359001 2533.151253 0 | ||
| 6 | +v -427.551489 2533.151253 0 | ||
| 7 | +v 154.778338 2533.151253 120.777515 | ||
| 8 | +v -1012.032694 2533.151253 120.777515 | ||
| 9 | +v 1315.92994 2533.151253 120.777515 | ||
| 10 | +v -1590.689836 1678.225832 94.229274 | ||
| 11 | +v -1012.032796 1678.225832 157.523187 | ||
| 12 | +v -427.55154 1678.225832 94.229274 | ||
| 13 | +v 154.778235 1678.225832 157.523187 | ||
| 14 | +v 731.358898 1678.225832 94.229274 | ||
| 15 | +v 1315.92994 1678.225832 157.523187 | ||
| 16 | +v -1590.689836 810.079751 0 | ||
| 17 | +v -1012.032796 810.079751 120.777515 | ||
| 18 | +v -427.55154 810.079751 0 | ||
| 19 | +v 154.778235 810.079751 120.777515 | ||
| 20 | +v 731.358898 810.079751 0 | ||
| 21 | +v 1315.92994 810.079751 120.777515 | ||
| 22 | +v -1590.689836 -58.06633 94.229274 | ||
| 23 | +v -1012.032796 -58.06633 157.523187 | ||
| 24 | +v -427.55154 -58.06633 94.229274 | ||
| 25 | +v 154.778235 -58.06633 157.523187 | ||
| 26 | +v 731.358898 -58.06633 94.229274 | ||
| 27 | +v 1315.92994 -58.06633 157.523187 | ||
| 28 | +v -1590.689836 -929.240781 0 | ||
| 29 | +v -1012.032796 -929.240781 120.777515 | ||
| 30 | +v -427.55154 -929.996013 0 | ||
| 31 | +v 154.778235 -929.240781 120.777515 | ||
| 32 | +v 731.358898 -929.240781 0 | ||
| 33 | +v 1315.92994 -929.240781 120.777515 | ||
| 34 | +v 1315.92994 -929.240781 120.777515 | ||
| 35 | +v 1315.92994 -929.240781 120.777515 | ||
| 36 | +v 1315.92994 -929.240781 120.777515 | ||
| 37 | +v 1315.92994 -929.240781 120.777515 | ||
| 38 | +v 1315.92994 -929.240781 120.777515 | ||
| 39 | +v 1315.92994 -929.240781 120.777515 | ||
| 40 | +v -1590.689836 -1803.293408 94.229274 | ||
| 41 | +v -1012.032796 -1803.293408 157.523187 | ||
| 42 | +v -427.55154 -1803.293408 94.229274 | ||
| 43 | +v 154.778235 -1803.293408 157.523187 | ||
| 44 | +v 731.358898 -1803.293408 94.229274 | ||
| 45 | +v 1315.92994 -1803.293408 157.523187 | ||
| 46 | +v -427.55154 1367.329985 0 | ||
| 47 | +v -1590.689836 1974.544079 0 | ||
| 48 | +v -427.55154 1986.607668 0 | ||
| 49 | +v 731.358898 1367.329985 0 | ||
| 50 | +v 731.358898 1988.163735 0 | ||
| 51 | +v 154.778235 2244.138997 0 | ||
| 52 | +v 1315.92994 2244.138997 0 | ||
| 53 | +v -1012.032796 2252.046797 0 | ||
| 54 | +v -1012.032796 1115.71757 0 | ||
| 55 | +v 154.778235 1119.336098 0 | ||
| 56 | +v 1315.92994 1112.099043 0 | ||
| 57 | +v -427.55154 254.50799 0 | ||
| 58 | +v 731.358898 243.652407 0 | ||
| 59 | +v 1315.92994 504.186398 0 | ||
| 60 | +v 154.778235 496.949343 0 | ||
| 61 | +v -1012.032796 507.804926 0 | ||
| 62 | +v -1590.689836 255.677565 0 | ||
| 63 | +v 1315.92994 -630.008096 0 | ||
| 64 | +v 731.358898 -367.878765 0 | ||
| 65 | +v -427.55154 -367.878765 0 | ||
| 66 | +v -1590.689836 -354.913145 0 | ||
| 67 | +v 154.778235 -624.794228 0 | ||
| 68 | +v -1012.032796 -1236.3254 0 | ||
| 69 | +v -1012.032796 -617.557172 0 | ||
| 70 | +v -427.55154 -1492.875613 0 | ||
| 71 | +v 154.778235 -1233.431212 0 | ||
| 72 | +v 1315.92994 -1234.216769 0 | ||
| 73 | +v 731.358898 -1486.623941 0 | ||
| 74 | +v 731.358898 -1486.623941 0 | ||
| 75 | +v 731.358898 -1486.623941 0 | ||
| 76 | +v 731.358898 -1486.623941 0 | ||
| 77 | +v 731.358898 -1486.623941 0 | ||
| 78 | +v 731.358898 -1486.623941 0 | ||
| 79 | +v 731.358898 -1486.623941 0 | ||
| 80 | +v 731.358898 -1486.623941 0 | ||
| 81 | +v 731.358898 -1486.623941 0 | ||
| 82 | +v -1590.689836 -1496.890407 0 | ||
| 83 | +v -1590.689836 1373.417683 0 | ||
| 84 | +v 731.359001 3706.233193 0 | ||
| 85 | +v 1315.930042 3966.767184 0 | ||
| 86 | +v 154.778338 3959.530129 0 | ||
| 87 | +v -1012.032694 3970.385712 0 | ||
| 88 | +v -1590.689733 3718.258351 0 | ||
| 89 | +v -427.551437 3717.088776 0 | ||
| 90 | +v 1315.930042 2832.57269 0 | ||
| 91 | +v 731.359001 3094.702021 0 | ||
| 92 | +v -427.551437 3094.702021 0 | ||
| 93 | +v -1590.689733 3107.667641 0 | ||
| 94 | +v 154.778338 2837.786558 0 | ||
| 95 | +v -1012.032694 2845.023613 0 | ||
| 96 | +v -1590.689733 4272.660537 0 | ||
| 97 | +v -1012.032694 4272.660537 120.777515 | ||
| 98 | +v -427.551437 4272.660537 0 | ||
| 99 | +v 154.778338 4272.660537 120.777515 | ||
| 100 | +v 731.359001 4272.660537 0 | ||
| 101 | +v 1315.930042 4272.660537 120.777515 | ||
| 102 | +v -1590.689733 3404.514456 94.229274 | ||
| 103 | +v -1012.032694 3404.514456 157.523187 | ||
| 104 | +v -427.551437 3404.514456 94.229274 | ||
| 105 | +v 154.778338 3404.514456 157.523187 | ||
| 106 | +v 731.359001 3404.514456 94.229274 | ||
| 107 | +v 1315.930042 3404.514456 157.523187 | ||
| 108 | +v -1590.689733 2533.151253 0 | ||
| 109 | + | ||
| 110 | +f 8/17 7/16 44/68 | ||
| 111 | +f 3/10 45/69 8/17 | ||
| 112 | +f 10/25 9/18 45/69 | ||
| 113 | +f 2/3 47/71 10/20 | ||
| 114 | +f 12/27 47/71 2/3 | ||
| 115 | +f 8/17 51/75 13/28 | ||
| 116 | +f 8/17 15/30 51/75 | ||
| 117 | +f 15/30 10/24 52/77 | ||
| 118 | +f 52/76 10/21 17/32 | ||
| 119 | +f 12/27 53/78 17/32 | ||
| 120 | +f 58/83 20/35 13/28 | ||
| 121 | +f 15/30 54/79 20/35 | ||
| 122 | +f 22/37 21/36 54/79 | ||
| 123 | +f 17/32 22/37 57/82 | ||
| 124 | +f 17/32 24/39 55/80 | ||
| 125 | +f 20/35 63/88 19/34 | ||
| 126 | +f 62/87 27/51 20/35 | ||
| 127 | +f 64/89 28/52 27/50 | ||
| 128 | +f 23/38 61/86 22/37 | ||
| 129 | +f 60/85 30/54 29/53 | ||
| 130 | +f 26/41 65/90 25/40 | ||
| 131 | +f 65/90 26/41 27/49 | ||
| 132 | +f 27/48 62/87 22/37 | ||
| 133 | +f 29/53 70/96 40/64 | ||
| 134 | +f 30/54 69/95 29/53 | ||
| 135 | +f 17/32 55/80 22/37 | ||
| 136 | +f 46/70 11/26 12/27 | ||
| 137 | +f 27/47 26/41 66/91 | ||
| 138 | +f 27/46 38/62 65/90 | ||
| 139 | +f 17/32 18/33 56/81 | ||
| 140 | +f 10/23 46/70 17/32 | ||
| 141 | +f 10/20 3/10 48/72 | ||
| 142 | +f 2/3 6/15 49/73 | ||
| 143 | +f 10/20 48/72 2/3 | ||
| 144 | +f 10/19 43/67 9/18 | ||
| 145 | +f 20/35 58/83 15/30 | ||
| 146 | +f 8/17 50/74 3/10 | ||
| 147 | +f 13/28 80/106 8/17 | ||
| 148 | +f 8/17 9/18 43/67 | ||
| 149 | +f 105/132 5/14 50/74 | ||
| 150 | +f 43/67 15/30 8/17 | ||
| 151 | +f 44/68 105/132 8/17 | ||
| 152 | +f 45/69 9/18 8/17 | ||
| 153 | +f 45/69 3/10 10/22 | ||
| 154 | +f 10/21 11/26 46/70 | ||
| 155 | +f 47/71 11/26 10/20 | ||
| 156 | +f 12/27 11/26 47/71 | ||
| 157 | +f 48/72 4/12 2/3 | ||
| 158 | +f 49/73 12/27 2/3 | ||
| 159 | +f 3/10 4/12 48/72 | ||
| 160 | +f 50/74 5/14 3/10 | ||
| 161 | +f 50/74 8/17 105/132 | ||
| 162 | +f 10/19 15/30 43/67 | ||
| 163 | +f 12/27 17/32 46/70 | ||
| 164 | +f 51/75 14/29 13/28 | ||
| 165 | +f 15/30 14/29 51/75 | ||
| 166 | +f 52/77 16/31 15/30 | ||
| 167 | +f 17/32 16/31 52/76 | ||
| 168 | +f 53/78 18/33 17/32 | ||
| 169 | +f 15/30 16/31 57/82 | ||
| 170 | +f 54/79 21/36 20/35 | ||
| 171 | +f 55/80 23/38 22/37 | ||
| 172 | +f 24/39 23/38 55/80 | ||
| 173 | +f 56/81 24/39 17/32 | ||
| 174 | +f 57/82 22/37 15/30 | ||
| 175 | +f 57/82 16/31 17/32 | ||
| 176 | +f 22/37 54/79 15/30 | ||
| 177 | +f 14/29 58/83 13/28 | ||
| 178 | +f 58/83 14/29 15/30 | ||
| 179 | +f 20/35 19/34 59/84 | ||
| 180 | +f 59/84 13/28 20/35 | ||
| 181 | +f 29/53 64/89 22/37 | ||
| 182 | +f 29/53 24/39 60/85 | ||
| 183 | +f 61/86 23/38 24/39 | ||
| 184 | +f 61/86 29/53 22/37 | ||
| 185 | +f 24/39 29/53 61/86 | ||
| 186 | +f 21/36 62/87 20/35 | ||
| 187 | +f 62/87 21/36 22/37 | ||
| 188 | +f 20/35 27/45 66/91 | ||
| 189 | +f 66/91 26/41 25/40 | ||
| 190 | +f 65/90 38/62 25/40 | ||
| 191 | +f 27/44 67/92 38/62 | ||
| 192 | +f 67/93 40/64 39/63 | ||
| 193 | +f 27/43 22/37 64/89 | ||
| 194 | +f 25/40 20/35 66/91 | ||
| 195 | +f 29/53 28/52 64/89 | ||
| 196 | +f 38/62 37/61 79/105 | ||
| 197 | +f 67/93 27/42 40/64 | ||
| 198 | +f 67/92 39/63 38/62 | ||
| 199 | +f 27/42 28/52 68/94 | ||
| 200 | +f 29/53 68/94 28/52 | ||
| 201 | +f 68/94 40/64 27/42 | ||
| 202 | +f 40/64 68/94 29/53 | ||
| 203 | +f 29/53 42/66 70/96 | ||
| 204 | +f 69/95 42/66 29/53 | ||
| 205 | +f 70/96 41/65 40/64 | ||
| 206 | +f 42/66 41/65 70/96 | ||
| 207 | +f 79/105 25/40 38/62 | ||
| 208 | +f 25/40 63/88 20/35 | ||
| 209 | +f 80/106 7/16 8/17 | ||
| 210 | +f 100/126 84/110 95/121 | ||
| 211 | +f 82/108 104/130 97/123 | ||
| 212 | +f 83/109 102/128 95/121 | ||
| 213 | +f 83/109 96/122 97/123 | ||
| 214 | +f 95/121 96/122 83/109 | ||
| 215 | +f 102/128 86/112 95/121 | ||
| 216 | +f 94/120 84/110 93/119 | ||
| 217 | +f 84/110 94/120 95/121 | ||
| 218 | +f 100/126 99/125 85/111 | ||
| 219 | +f 85/111 93/119 100/126 | ||
| 220 | +f 84/110 100/126 93/119 | ||
| 221 | +f 95/121 86/112 100/126 | ||
| 222 | +f 102/128 101/127 86/112 | ||
| 223 | +f 97/123 102/128 83/109 | ||
| 224 | +f 97/123 104/130 81/107 | ||
| 225 | +f 100/126 90/116 99/125 | ||
| 226 | +f 89/115 3/9 100/126 | ||
| 227 | +f 91/117 4/11 3/8 | ||
| 228 | +f 103/129 88/114 102/128 | ||
| 229 | +f 87/113 1/1 2/2 | ||
| 230 | +f 104/130 2/2 88/114 | ||
| 231 | +f 101/127 89/115 100/126 | ||
| 232 | +f 3/7 89/115 102/128 | ||
| 233 | +f 89/115 101/127 102/128 | ||
| 234 | +f 100/126 3/6 92/118 | ||
| 235 | +f 92/118 5/13 105/131 | ||
| 236 | +f 3/5 102/128 91/117 | ||
| 237 | +f 105/131 100/126 92/118 | ||
| 238 | +f 2/2 4/11 91/117 | ||
| 239 | +f 105/131 90/116 100/126 | ||
| 240 | +f 97/123 81/107 102/128 | ||
| 241 | +f 2/2 91/117 102/128 | ||
| 242 | +f 3/4 5/13 92/118 | ||
| 243 | +f 2/2 104/130 87/113 | ||
| 244 | +f 97/123 98/124 82/108 | ||
| 245 | +f 88/114 103/129 104/130 | ||
| 246 | +f 86/112 101/127 100/126 | ||
| 247 | +f 81/107 103/129 102/128 | ||
| 248 | +f 104/130 103/129 81/107 | ||
| 249 | +f 88/114 2/2 102/128 | ||
| 250 | + |
examples/scroll-view/scroll-view-example.cpp
| @@ -31,21 +31,18 @@ namespace | @@ -31,21 +31,18 @@ namespace | ||
| 31 | const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); | 31 | const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); |
| 32 | const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); | 32 | const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); |
| 33 | const char * const APPLICATION_TITLE( "ScrollView" ); | 33 | const char * const APPLICATION_TITLE( "ScrollView" ); |
| 34 | -const char * const EFFECT_OUTER_CUBE_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-outer-cube.png" ); | ||
| 35 | const char * const EFFECT_DEPTH_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-depth.png" ); | 34 | const char * const EFFECT_DEPTH_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-depth.png" ); |
| 36 | const char * const EFFECT_INNER_CUBE_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-inner-cube.png" ); | 35 | const char * const EFFECT_INNER_CUBE_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-inner-cube.png" ); |
| 37 | const char * const EFFECT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-carousel.png" ); | 36 | const char * const EFFECT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-carousel.png" ); |
| 38 | -const char * const EFFECT_SPIRAL_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-spiral.png" ); | ||
| 39 | 37 | ||
| 40 | const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f); | 38 | const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f); |
| 41 | 39 | ||
| 42 | const char* EFFECT_MODE_NAME[] = { | 40 | const char* EFFECT_MODE_NAME[] = { |
| 43 | - "OuterCube", | ||
| 44 | "Depth", | 41 | "Depth", |
| 45 | "Cube", | 42 | "Cube", |
| 46 | - "InnerCube", | ||
| 47 | - "Carousel", | ||
| 48 | - "Spiral", | 43 | + "PageCarousel", |
| 44 | + "PageCube", | ||
| 45 | + "PageSpiral" | ||
| 49 | }; | 46 | }; |
| 50 | 47 | ||
| 51 | const char * const IMAGE_PATHS[] = { | 48 | const char * const IMAGE_PATHS[] = { |
| @@ -197,12 +194,11 @@ public: | @@ -197,12 +194,11 @@ public: | ||
| 197 | TOOLBAR_IMAGE, | 194 | TOOLBAR_IMAGE, |
| 198 | "" ); | 195 | "" ); |
| 199 | 196 | ||
| 200 | - mEffectIcon[ OuterCubeEffect ] = Image::New( EFFECT_OUTER_CUBE_IMAGE ); | ||
| 201 | mEffectIcon[ DepthEffect ] = Image::New( EFFECT_DEPTH_IMAGE ); | 197 | mEffectIcon[ DepthEffect ] = Image::New( EFFECT_DEPTH_IMAGE ); |
| 202 | mEffectIcon[ CubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); | 198 | mEffectIcon[ CubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); |
| 203 | - mEffectIcon[ InnerCubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); | ||
| 204 | - mEffectIcon[ CarouselEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); | ||
| 205 | - mEffectIcon[ SpiralEffect ] = Image::New( EFFECT_SPIRAL_IMAGE ); | 199 | + mEffectIcon[ PageCarouselEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); |
| 200 | + mEffectIcon[ PageCubeEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); | ||
| 201 | + mEffectIcon[ PageSpiralEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); | ||
| 206 | 202 | ||
| 207 | // Create a effect change button. (right of toolbar) | 203 | // Create a effect change button. (right of toolbar) |
| 208 | mEffectChangeButton = Toolkit::PushButton::New(); | 204 | mEffectChangeButton = Toolkit::PushButton::New(); |
| @@ -348,14 +344,8 @@ private: | @@ -348,14 +344,8 @@ private: | ||
| 348 | Stage stage = Stage::GetCurrent(); | 344 | Stage stage = Stage::GetCurrent(); |
| 349 | Vector2 stageSize = stage.GetSize(); | 345 | Vector2 stageSize = stage.GetSize(); |
| 350 | 346 | ||
| 351 | - switch(mEffectMode) | 347 | + switch( mEffectMode ) |
| 352 | { | 348 | { |
| 353 | - case OuterCubeEffect: | ||
| 354 | - { | ||
| 355 | - SetupOuterPageCubeEffect(); | ||
| 356 | - break; | ||
| 357 | - } | ||
| 358 | - | ||
| 359 | case DepthEffect: | 349 | case DepthEffect: |
| 360 | { | 350 | { |
| 361 | mScrollViewEffect = ScrollViewDepthEffect::New(); | 351 | mScrollViewEffect = ScrollViewDepthEffect::New(); |
| @@ -366,6 +356,7 @@ private: | @@ -366,6 +356,7 @@ private: | ||
| 366 | mScrollView.RemoveConstraintsFromChildren(); | 356 | mScrollView.RemoveConstraintsFromChildren(); |
| 367 | break; | 357 | break; |
| 368 | } | 358 | } |
| 359 | + | ||
| 369 | case CubeEffect: | 360 | case CubeEffect: |
| 370 | { | 361 | { |
| 371 | mScrollViewEffect = ScrollViewCubeEffect::New(); | 362 | mScrollViewEffect = ScrollViewCubeEffect::New(); |
| @@ -377,21 +368,36 @@ private: | @@ -377,21 +368,36 @@ private: | ||
| 377 | break; | 368 | break; |
| 378 | } | 369 | } |
| 379 | 370 | ||
| 380 | - case InnerCubeEffect: | 371 | + case PageCarouselEffect: |
| 381 | { | 372 | { |
| 382 | - SetupInnerPageCubeEffect(); | 373 | + mScrollViewEffect = ScrollViewPageCarouselEffect::New(); |
| 374 | + mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 375 | + mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 376 | + mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOut); | ||
| 377 | + mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOut); | ||
| 378 | + mScrollView.RemoveConstraintsFromChildren(); | ||
| 383 | break; | 379 | break; |
| 384 | } | 380 | } |
| 385 | 381 | ||
| 386 | - case CarouselEffect: | 382 | + case PageCubeEffect: |
| 387 | { | 383 | { |
| 388 | - SetupCarouselPageEffect(); | 384 | + mScrollViewEffect = ScrollViewPageCubeEffect::New(); |
| 385 | + mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 386 | + mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 387 | + mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOut); | ||
| 388 | + mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOut); | ||
| 389 | + mScrollView.RemoveConstraintsFromChildren(); | ||
| 389 | break; | 390 | break; |
| 390 | } | 391 | } |
| 391 | 392 | ||
| 392 | - case SpiralEffect: | 393 | + case PageSpiralEffect: |
| 393 | { | 394 | { |
| 394 | - SetupSpiralPageEffect(); | 395 | + mScrollViewEffect = ScrollViewPageSpiralEffect::New(); |
| 396 | + mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 397 | + mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 398 | + mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOut); | ||
| 399 | + mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOut); | ||
| 400 | + mScrollView.RemoveConstraintsFromChildren(); | ||
| 395 | break; | 401 | break; |
| 396 | } | 402 | } |
| 397 | 403 | ||
| @@ -399,9 +405,9 @@ private: | @@ -399,9 +405,9 @@ private: | ||
| 399 | { | 405 | { |
| 400 | break; | 406 | break; |
| 401 | } | 407 | } |
| 402 | - } // end switch | 408 | + } |
| 403 | 409 | ||
| 404 | - if(mScrollViewEffect) | 410 | + if( mScrollViewEffect ) |
| 405 | { | 411 | { |
| 406 | mScrollView.ApplyEffect(mScrollViewEffect); | 412 | mScrollView.ApplyEffect(mScrollViewEffect); |
| 407 | } | 413 | } |
| @@ -434,100 +440,47 @@ private: | @@ -434,100 +440,47 @@ private: | ||
| 434 | } | 440 | } |
| 435 | return new FixedRuler(gridSize); | 441 | return new FixedRuler(gridSize); |
| 436 | } | 442 | } |
| 437 | - | ||
| 438 | - void SetupInnerPageCubeEffect() | ||
| 439 | - { | ||
| 440 | - ScrollViewCustomEffect customEffect; | ||
| 441 | - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); | ||
| 442 | - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 443 | - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 444 | - mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 445 | - mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 446 | - mScrollView.RemoveConstraintsFromChildren(); | ||
| 447 | - | ||
| 448 | - customEffect.SetPageSpacing(Vector2(30.0f, 30.0f)); | ||
| 449 | - customEffect.SetAngledOriginPageRotation(ANGLE_CUBE_PAGE_ROTATE); | ||
| 450 | - customEffect.SetSwingAngle(ANGLE_CUBE_PAGE_ROTATE.x, Vector3(0,-1,0)); | ||
| 451 | - customEffect.SetOpacityThreshold(0.7f); | ||
| 452 | - } | ||
| 453 | - | ||
| 454 | - void SetupOuterPageCubeEffect() | ||
| 455 | - { | ||
| 456 | - ScrollViewCustomEffect customEffect; | ||
| 457 | - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); | ||
| 458 | - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 459 | - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 460 | - mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOut); | ||
| 461 | - mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOut); | ||
| 462 | - mScrollView.RemoveConstraintsFromChildren(); | ||
| 463 | - | ||
| 464 | - Vector2 pageSize = Stage::GetCurrent().GetSize(); | ||
| 465 | - customEffect.SetPageTranslation(Vector3(pageSize.x, pageSize.y, 0)); | ||
| 466 | - customEffect.SetSwingAngleOut(ANGLE_CUSTOM_CUBE_SWING.x, Vector3(0.0f, -1.0f, 0.0f)); | ||
| 467 | - customEffect.SetSwingAnchor(AnchorPoint::CENTER, AnchorPoint::CENTER_LEFT); | ||
| 468 | - customEffect.SetOpacityThreshold(0.5f); | ||
| 469 | - } | ||
| 470 | - | ||
| 471 | - void SetupCarouselPageEffect() | ||
| 472 | - { | ||
| 473 | - ScrollViewCustomEffect customEffect; | ||
| 474 | - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); | ||
| 475 | - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 476 | - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 477 | - mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 478 | - mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 479 | - mScrollView.RemoveConstraintsFromChildren(); | ||
| 480 | - | ||
| 481 | - customEffect.SetPageTranslation(Vector3(0,0,0), Vector3(-30, 0, 0)); | ||
| 482 | - customEffect.SetPageSpacing(Vector2(60.0f, 60.0f)); | ||
| 483 | - customEffect.SetAngledOriginPageRotation(-ANGLE_CUBE_PAGE_ROTATE); | ||
| 484 | - customEffect.SetOpacityThreshold(0.2f, 0.6f); | ||
| 485 | - } | ||
| 486 | - | ||
| 487 | - void SetupSpiralPageEffect() | ||
| 488 | - { | ||
| 489 | - ScrollViewCustomEffect customEffect; | ||
| 490 | - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); | ||
| 491 | - mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 492 | - mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 493 | - mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 494 | - mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 495 | - mScrollView.RemoveConstraintsFromChildren(); | ||
| 496 | - | ||
| 497 | - Vector2 pageSize = Stage::GetCurrent().GetSize(); | ||
| 498 | - customEffect.SetPageTranslation(Vector3(pageSize.x, pageSize.y, 0.0f)); | ||
| 499 | - customEffect.SetSwingAngle(-ANGLE_SPIRAL_SWING_IN.x, Vector3(0.0f, -1.0f, 0.0f), ANGLE_SPIRAL_SWING_OUT.x, Vector3(0.0f, -1.0f, 0.0f)); | ||
| 500 | - customEffect.SetSwingAnchor(AnchorPoint::CENTER_RIGHT); | ||
| 501 | - customEffect.SetPageTranslation(Vector3(pageSize.x, pageSize.y, 0), Vector3(pageSize.x, pageSize.y, 0) * 0.5f); | ||
| 502 | - customEffect.SetOpacityThreshold(0.66f); | ||
| 503 | - } | ||
| 504 | - | 443 | + // end switch |
| 505 | /** | 444 | /** |
| 506 | - * [Page] | ||
| 507 | - * Applies effect to the pages within scroll view. | ||
| 508 | - * | ||
| 509 | - * @param[in] page The page Actor to apply effect to. | ||
| 510 | - */ | ||
| 511 | - void ApplyEffectToPage(Actor page) | ||
| 512 | - { | ||
| 513 | - page.RemoveConstraints(); | ||
| 514 | - page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 515 | - | ||
| 516 | - if( ( mEffectMode == InnerCubeEffect ) || | ||
| 517 | - ( mEffectMode == OuterCubeEffect ) || | ||
| 518 | - ( mEffectMode == SpiralEffect ) || | ||
| 519 | - ( mEffectMode == CarouselEffect) ) | ||
| 520 | - { | ||
| 521 | - ApplyCustomEffectToPage(page); | ||
| 522 | - } | ||
| 523 | - } | ||
| 524 | - | ||
| 525 | - void ApplyCustomEffectToPage(Actor page) | ||
| 526 | - { | ||
| 527 | - ScrollViewCustomEffect customEffect = ScrollViewCustomEffect::DownCast(mScrollViewEffect); | ||
| 528 | - Vector2 vStageSize(Stage::GetCurrent().GetSize()); | ||
| 529 | - customEffect.ApplyToPage(page, Vector3(vStageSize.x, vStageSize.y, 1.0f)); | ||
| 530 | - } | 445 | + * [Page] |
| 446 | + * Applies effect to the pages within scroll view. | ||
| 447 | + * | ||
| 448 | + * @param[in] page The page Actor to apply effect to. | ||
| 449 | + */ | ||
| 450 | + void ApplyEffectToPage(Actor page) | ||
| 451 | + { | ||
| 452 | + page.RemoveConstraints(); | ||
| 453 | + page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 454 | + | ||
| 455 | + switch( mEffectMode ) | ||
| 456 | + { | ||
| 457 | + case PageCarouselEffect: | ||
| 458 | + { | ||
| 459 | + ScrollViewPageCarouselEffect effect = ScrollViewPageCarouselEffect::DownCast( mScrollViewEffect ); | ||
| 460 | + effect.ApplyToPage( page ); | ||
| 461 | + break; | ||
| 462 | + } | ||
| 463 | + | ||
| 464 | + case PageCubeEffect: | ||
| 465 | + { | ||
| 466 | + ScrollViewPageCubeEffect effect = ScrollViewPageCubeEffect::DownCast( mScrollViewEffect ); | ||
| 467 | + effect.ApplyToPage( page, ANGLE_SWING_3DEFFECT ); | ||
| 468 | + break; | ||
| 469 | + } | ||
| 470 | + | ||
| 471 | + case PageSpiralEffect: | ||
| 472 | + { | ||
| 473 | + ScrollViewPageSpiralEffect effect = ScrollViewPageSpiralEffect::DownCast( mScrollViewEffect ); | ||
| 474 | + effect.ApplyToPage( page, ANGLE_SWING_3DEFFECT ); | ||
| 475 | + break; | ||
| 476 | + } | ||
| 477 | + | ||
| 478 | + default: | ||
| 479 | + { | ||
| 480 | + break; | ||
| 481 | + } | ||
| 482 | + } | ||
| 483 | + } | ||
| 531 | 484 | ||
| 532 | /** | 485 | /** |
| 533 | * [Actor] | 486 | * [Actor] |
| @@ -542,13 +495,24 @@ private: | @@ -542,13 +495,24 @@ private: | ||
| 542 | */ | 495 | */ |
| 543 | void ApplyEffectToActor( Actor child, Actor page ) | 496 | void ApplyEffectToActor( Actor child, Actor page ) |
| 544 | { | 497 | { |
| 545 | - if( mEffectMode == DepthEffect ) | 498 | + switch( mEffectMode ) |
| 546 | { | 499 | { |
| 547 | - ApplyDepthEffectToActor( child ); | ||
| 548 | - } | ||
| 549 | - else if(mEffectMode == CubeEffect ) | ||
| 550 | - { | ||
| 551 | - ApplyCubeEffectToActor( child ); | 500 | + case DepthEffect: |
| 501 | + { | ||
| 502 | + ApplyDepthEffectToActor( child ); | ||
| 503 | + break; | ||
| 504 | + } | ||
| 505 | + | ||
| 506 | + case CubeEffect: | ||
| 507 | + { | ||
| 508 | + ApplyCubeEffectToActor( child ); | ||
| 509 | + break; | ||
| 510 | + } | ||
| 511 | + | ||
| 512 | + default: | ||
| 513 | + { | ||
| 514 | + break; | ||
| 515 | + } | ||
| 552 | } | 516 | } |
| 553 | } | 517 | } |
| 554 | 518 | ||
| @@ -701,14 +665,13 @@ private: | @@ -701,14 +665,13 @@ private: | ||
| 701 | */ | 665 | */ |
| 702 | enum EffectMode | 666 | enum EffectMode |
| 703 | { | 667 | { |
| 704 | - OuterCubeEffect, ///< Outer Cube Effect | ||
| 705 | DepthEffect, ///< Depth Effect | 668 | DepthEffect, ///< Depth Effect |
| 706 | CubeEffect, ///< Cube effect | 669 | CubeEffect, ///< Cube effect |
| 707 | - InnerCubeEffect, ///< Page Cube Effect | ||
| 708 | - CarouselEffect, ///< Page Carousel Effect | ||
| 709 | - SpiralEffect, ///< Page Spiral Effect | 670 | + PageCarouselEffect, ///< Page carousel effect |
| 671 | + PageCubeEffect, ///< Page cube effect | ||
| 672 | + PageSpiralEffect, ///< Page spiral effect | ||
| 710 | 673 | ||
| 711 | - Total, | 674 | + Total |
| 712 | }; | 675 | }; |
| 713 | 676 | ||
| 714 | EffectMode mEffectMode; ///< Current Effect mode | 677 | EffectMode mEffectMode; ///< Current Effect mode |
examples/shader-effect/refraction-effect-example.cpp
0 โ 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2014 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/dali.h> | ||
| 19 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 20 | +#include "../shared/view.h" | ||
| 21 | + | ||
| 22 | +#include <fstream> | ||
| 23 | +#include <sstream> | ||
| 24 | + | ||
| 25 | +using namespace Dali; | ||
| 26 | + | ||
| 27 | +namespace | ||
| 28 | +{ | ||
| 29 | +const char * const APPLICATION_TITLE( "Refraction Effect" ); | ||
| 30 | +const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); | ||
| 31 | +const char * const CHANGE_TEXTURE_ICON( DALI_IMAGE_DIR "icon-change.png" ); | ||
| 32 | +const char * const CHANGE_MESH_ICON( DALI_IMAGE_DIR "icon-replace.png" ); | ||
| 33 | + | ||
| 34 | +const char* MESH_FILES[] = | ||
| 35 | +{ | ||
| 36 | + DALI_MODEL_DIR "surface_pattern_v01.obj", | ||
| 37 | + DALI_MODEL_DIR "surface_pattern_v02.obj" | ||
| 38 | +}; | ||
| 39 | +const unsigned int NUM_MESH_FILES( sizeof( MESH_FILES ) / sizeof( MESH_FILES[0] ) ); | ||
| 40 | + | ||
| 41 | +const char* TEXTURE_IMAGES[]= | ||
| 42 | +{ | ||
| 43 | + DALI_IMAGE_DIR "background-1.jpg", | ||
| 44 | + DALI_IMAGE_DIR "background-2.jpg", | ||
| 45 | + DALI_IMAGE_DIR "background-3.jpg", | ||
| 46 | + DALI_IMAGE_DIR "background-4.jpg" | ||
| 47 | +}; | ||
| 48 | +const unsigned int NUM_TEXTURE_IMAGES( sizeof( TEXTURE_IMAGES ) / sizeof( TEXTURE_IMAGES[0] ) ); | ||
| 49 | + | ||
| 50 | +#define MAKE_SHADER(A)#A | ||
| 51 | + | ||
| 52 | +struct LightOffsetConstraint | ||
| 53 | +{ | ||
| 54 | + LightOffsetConstraint( float radius ) | ||
| 55 | + : mRadius( radius ) | ||
| 56 | + { | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty) | ||
| 60 | + { | ||
| 61 | + float spinAngle = spinAngleProperty.GetFloat(); | ||
| 62 | + return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + float mRadius; | ||
| 66 | +}; | ||
| 67 | + | ||
| 68 | +} // namespace | ||
| 69 | + | ||
| 70 | +/************************************************************************************************ | ||
| 71 | + *** This shader is used when the MeshActor is not touched*** | ||
| 72 | + ************************************************************************************************/ | ||
| 73 | +class NoEffect : public ShaderEffect | ||
| 74 | +{ | ||
| 75 | +public: | ||
| 76 | + /** | ||
| 77 | + * Create an empty handle. | ||
| 78 | + */ | ||
| 79 | + NoEffect() | ||
| 80 | + { | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * Virtual destructor | ||
| 85 | + */ | ||
| 86 | + virtual ~NoEffect() | ||
| 87 | + { | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Create a NoEffect object. | ||
| 92 | + * @return A handle to a newly allocated NoEffect | ||
| 93 | + */ | ||
| 94 | + static NoEffect New() | ||
| 95 | + { | ||
| 96 | + std::string vertexShader = MAKE_SHADER( | ||
| 97 | + uniform mediump vec4 uTextureRect;\n | ||
| 98 | + void main()\n | ||
| 99 | + {\n | ||
| 100 | + gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n | ||
| 101 | + vTexCoord = aTexCoord.xy;\n | ||
| 102 | + }\n | ||
| 103 | + ); | ||
| 104 | + std::string fragmentShader = MAKE_SHADER( | ||
| 105 | + void main()\n | ||
| 106 | + {\n | ||
| 107 | + gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n | ||
| 108 | + }\n | ||
| 109 | + ); | ||
| 110 | + ShaderEffect shaderEffect = ShaderEffect::New( vertexShader, fragmentShader, | ||
| 111 | + GeometryType( GEOMETRY_TYPE_TEXTURED_MESH), | ||
| 112 | + ShaderEffect::GeometryHints( ShaderEffect::HINT_NONE ) ); | ||
| 113 | + NoEffect handle( shaderEffect ); | ||
| 114 | + return handle; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | +private: | ||
| 118 | + /** | ||
| 119 | + * Helper for New() | ||
| 120 | + */ | ||
| 121 | + NoEffect( ShaderEffect handle ) | ||
| 122 | + : ShaderEffect( handle ) | ||
| 123 | + { | ||
| 124 | + } | ||
| 125 | +}; | ||
| 126 | + | ||
| 127 | +/************************************************************/ | ||
| 128 | +/* Custom refraction effect shader******************************/ | ||
| 129 | +/************************************************************/ | ||
| 130 | + | ||
| 131 | +class RefractionEffect : public ShaderEffect | ||
| 132 | +{ | ||
| 133 | +public: | ||
| 134 | + | ||
| 135 | + /** | ||
| 136 | + * Create an empty RefractionEffect handle. | ||
| 137 | + */ | ||
| 138 | + RefractionEffect() | ||
| 139 | + { | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * Virtual destructor | ||
| 144 | + */ | ||
| 145 | + virtual ~RefractionEffect() | ||
| 146 | + { | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * Create a RefractionEffect object. | ||
| 151 | + * @return A handle to a newly allocated RefractionEffect | ||
| 152 | + */ | ||
| 153 | + static RefractionEffect New() | ||
| 154 | + { | ||
| 155 | + std::string vertexShader = MAKE_SHADER( | ||
| 156 | + varying mediump vec2 vTextureOffset;\n | ||
| 157 | + void main()\n | ||
| 158 | + {\n | ||
| 159 | + gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n | ||
| 160 | + vTexCoord = aTexCoord.xy;\n | ||
| 161 | + | ||
| 162 | + vNormal = aNormal;\n | ||
| 163 | + vVertex = vec4( aPosition, 1.0 );\n | ||
| 164 | + float length = max(0.01, length(aNormal.xy)) * 40.0;\n | ||
| 165 | + vTextureOffset = aNormal.xy / length;\n | ||
| 166 | + }\n | ||
| 167 | + ); | ||
| 168 | + | ||
| 169 | + std::string fragmentShader = MAKE_SHADER( | ||
| 170 | + uniform mediump float uEffectStrength;\n | ||
| 171 | + uniform mediump vec3 uLightPosition;\n | ||
| 172 | + uniform mediump vec2 uLightXYOffset;\n | ||
| 173 | + uniform mediump vec2 uLightSpinOffset;\n | ||
| 174 | + uniform mediump float uLightIntensity;\n | ||
| 175 | + varying mediump vec2 vTextureOffset;\n | ||
| 176 | + | ||
| 177 | + vec3 rgb2hsl(vec3 rgb)\n | ||
| 178 | + {\n | ||
| 179 | + float epsilon = 1.0e-10;\n | ||
| 180 | + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n | ||
| 181 | + vec4 P = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n | ||
| 182 | + vec4 Q = mix(vec4(P.xyw, rgb.r), vec4(rgb.r, P.yzx), step(P.x, rgb.r));\n | ||
| 183 | + \n | ||
| 184 | + // RGB -> HCV | ||
| 185 | + float value = Q.x;\n | ||
| 186 | + float chroma = Q.x - min(Q.w, Q.y);\n | ||
| 187 | + float hue = abs(Q.z + (Q.w-Q.y) / (6.0*chroma+epsilon));\n | ||
| 188 | + // HCV -> HSL | ||
| 189 | + float lightness = value - chroma*0.5;\n | ||
| 190 | + return vec3( hue, chroma/max( 1.0-abs(lightness*2.0-1.0), 1.0e-1 ), lightness );\n | ||
| 191 | + }\n | ||
| 192 | + | ||
| 193 | + vec3 hsl2rgb( vec3 hsl ) | ||
| 194 | + { | ||
| 195 | + // pure hue->RGB | ||
| 196 | + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n | ||
| 197 | + vec3 p = abs(fract(hsl.xxx + K.xyz) * 6.0 - K.www);\n | ||
| 198 | + vec3 RGB = clamp(p - K.xxx, 0.0, 1.0);\n | ||
| 199 | + \n | ||
| 200 | + float chroma = ( 1.0 - abs( hsl.z*2.0-1.0 ) ) * hsl.y;\n | ||
| 201 | + return ( RGB - 0.5 ) * chroma + hsl.z; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + void main()\n | ||
| 205 | + {\n | ||
| 206 | + vec3 normal = normalize( vNormal);\n | ||
| 207 | + | ||
| 208 | + vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.f);\n | ||
| 209 | + mediump vec3 vecToLight = normalize( (lightPosition - vVertex.xyz) * 0.01 );\n | ||
| 210 | + mediump float spotEffect = pow( max(0.05, vecToLight.z ) - 0.05, 8.0);\n | ||
| 211 | + | ||
| 212 | + spotEffect = spotEffect * uEffectStrength;\n | ||
| 213 | + mediump float lightDiffuse = ( ( dot( vecToLight, normal )-0.75 ) *uLightIntensity ) * spotEffect;\n | ||
| 214 | + | ||
| 215 | + lowp vec4 color = texture2D( sTexture, vTexCoord + vTextureOffset * spotEffect );\n | ||
| 216 | + vec3 lightedColor = hsl2rgb( rgb2hsl(color.rgb) + vec3(0.0,0.0,lightDiffuse) );\n | ||
| 217 | + | ||
| 218 | + gl_FragColor = vec4( lightedColor, color.a ) * uColor;\n | ||
| 219 | + }\n | ||
| 220 | + ); | ||
| 221 | + | ||
| 222 | + ShaderEffect shaderEffect = ShaderEffect::New( vertexShader, fragmentShader, | ||
| 223 | + GeometryType( GEOMETRY_TYPE_TEXTURED_MESH), | ||
| 224 | + ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) ); | ||
| 225 | + RefractionEffect handle( shaderEffect ); | ||
| 226 | + | ||
| 227 | + Vector2 stageSize = Stage::GetCurrent().GetSize(); | ||
| 228 | + handle.SetLightPosition( Vector2(stageSize.x, 0.f) ); | ||
| 229 | + handle.SetUniform( "uLightXYOffset", Vector2::ZERO ); | ||
| 230 | + handle.SetUniform( "uLightSpinOffset", Vector2::ZERO ); | ||
| 231 | + handle.SetUniform( "uEffectStrength", 0.f ); | ||
| 232 | + handle.SetUniform( "uLightIntensity", 2.5f ); | ||
| 233 | + | ||
| 234 | + Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f ); | ||
| 235 | + Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"), | ||
| 236 | + LocalSource(index), | ||
| 237 | + LightOffsetConstraint(stageSize.x*0.1f)); | ||
| 238 | + handle.ApplyConstraint( constraint ); | ||
| 239 | + | ||
| 240 | + return handle; | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + void SetLightPosition( const Vector2& position ) | ||
| 244 | + { | ||
| 245 | + Vector2 stageHalfSize = Stage::GetCurrent().GetSize() * 0.5f; | ||
| 246 | + SetUniform( "uLightPosition", Vector3( position.x - stageHalfSize.x, position.y - stageHalfSize.y, stageHalfSize.x ) ); | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + void SetLightXYOffset( const Vector2& offset ) | ||
| 250 | + { | ||
| 251 | + SetUniform( "uLightXYOffset", offset ); | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + void SetEffectStrength( float strength ) | ||
| 255 | + { | ||
| 256 | + SetUniform( "uEffectStrength", strength ); | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + void SetLightIntensity( float intensity ) | ||
| 260 | + { | ||
| 261 | + SetUniform( "uLightIntensity", intensity ); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | +private: | ||
| 265 | + /** | ||
| 266 | + * Helper for New() | ||
| 267 | + */ | ||
| 268 | + RefractionEffect( ShaderEffect handle ) | ||
| 269 | + : ShaderEffect( handle ) | ||
| 270 | + { | ||
| 271 | + } | ||
| 272 | +}; | ||
| 273 | + | ||
| 274 | +/*************************************************/ | ||
| 275 | +/*Demo using RefractionEffect*****************/ | ||
| 276 | +/*************************************************/ | ||
| 277 | +class RefractionEffectExample : public ConnectionTracker | ||
| 278 | +{ | ||
| 279 | +public: | ||
| 280 | + RefractionEffectExample( Application &application ) | ||
| 281 | + : mApplication( application ), | ||
| 282 | + mIsDown( false ), | ||
| 283 | + mCurrentTextureId( 1 ), | ||
| 284 | + mCurrentMeshId( 0 ) | ||
| 285 | + { | ||
| 286 | + // Connect to the Application's Init signal | ||
| 287 | + application.InitSignal().Connect(this, &RefractionEffectExample::Create); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + ~RefractionEffectExample() | ||
| 291 | + { | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | +private: | ||
| 295 | + | ||
| 296 | + // The Init signal is received once (only) during the Application lifetime | ||
| 297 | + void Create(Application& application) | ||
| 298 | + { | ||
| 299 | + Stage stage = Stage::GetCurrent(); | ||
| 300 | + mStageHalfSize = stage.GetSize() * 0.5f; | ||
| 301 | + | ||
| 302 | + stage.KeyEventSignal().Connect(this, &RefractionEffectExample::OnKeyEvent); | ||
| 303 | + | ||
| 304 | + // Creates a default view with a default tool bar. | ||
| 305 | + // The view is added to the stage. | ||
| 306 | + Toolkit::ToolBar toolBar; | ||
| 307 | + Toolkit::View view; | ||
| 308 | + mContent = DemoHelper::CreateView( application, | ||
| 309 | + view, | ||
| 310 | + toolBar, | ||
| 311 | + "", | ||
| 312 | + TOOLBAR_IMAGE, | ||
| 313 | + APPLICATION_TITLE ); | ||
| 314 | + | ||
| 315 | + // Add a button to change background. (right of toolbar) | ||
| 316 | + mChangeTextureButton = Toolkit::PushButton::New(); | ||
| 317 | + mChangeTextureButton.SetBackgroundImage( Image::New( CHANGE_TEXTURE_ICON ) ); | ||
| 318 | + mChangeTextureButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeTexture ); | ||
| 319 | + toolBar.AddControl( mChangeTextureButton, | ||
| 320 | + DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, | ||
| 321 | + Toolkit::Alignment::HorizontalRight, | ||
| 322 | + DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); | ||
| 323 | + // Add a button to change mesh pattern. ( left of bar ) | ||
| 324 | + mChangeMeshButton = Toolkit::PushButton::New(); | ||
| 325 | + mChangeMeshButton.SetBackgroundImage( Image::New( CHANGE_MESH_ICON ) ); | ||
| 326 | + mChangeMeshButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeMesh ); | ||
| 327 | + toolBar.AddControl( mChangeMeshButton, | ||
| 328 | + DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, | ||
| 329 | + Toolkit::Alignment::HorizontalLeft, | ||
| 330 | + DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); | ||
| 331 | + | ||
| 332 | + // creates the shader effects applied on the mesh actor | ||
| 333 | + mRefractionEffect = RefractionEffect::New(); // used when the finger is touching the screen | ||
| 334 | + mNoEffect = NoEffect::New(); // used in the other situations, basic render shader | ||
| 335 | + // Create the mesh from the obj file and add to stage | ||
| 336 | + mMaterial = Material::New( "Material" ) ; | ||
| 337 | + mMaterial.SetDiffuseTexture(Image::New(TEXTURE_IMAGES[mCurrentTextureId])); | ||
| 338 | + CreateSurface( MESH_FILES[mCurrentMeshId] ); | ||
| 339 | + | ||
| 340 | + // Connect the callback to the touch signal on the mesh actor | ||
| 341 | + mContent.TouchedSignal().Connect( this, &RefractionEffectExample::OnTouch ); | ||
| 342 | + | ||
| 343 | + // the animation which spin the light around the finger touch position | ||
| 344 | + mLightPosition = Vector2( mStageHalfSize.x*2.f, 0.f); | ||
| 345 | + mLightAnimation = Animation::New(2.f); | ||
| 346 | + mLightAnimation.AnimateTo( Property( mRefractionEffect, "uSpinAngle" ), Math::PI*2.f ); | ||
| 347 | + mLightAnimation.SetLooping( true ); | ||
| 348 | + mLightAnimation.Pause(); | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + /** | ||
| 352 | + * Create a mesh actor with different geometry to replace the current one | ||
| 353 | + */ | ||
| 354 | + bool OnChangeMesh( Toolkit::Button button ) | ||
| 355 | + { | ||
| 356 | + if( mMeshActor ) | ||
| 357 | + { | ||
| 358 | + UnparentAndReset( mMeshActor ); | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + mCurrentMeshId = ( mCurrentMeshId + 1 ) % NUM_MESH_FILES; | ||
| 362 | + CreateSurface( MESH_FILES[mCurrentMeshId] ); | ||
| 363 | + | ||
| 364 | + return true; | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + bool OnChangeTexture( Toolkit::Button button ) | ||
| 368 | + { | ||
| 369 | + mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES; | ||
| 370 | + mMaterial.SetDiffuseTexture(Image::New(TEXTURE_IMAGES[mCurrentTextureId])); | ||
| 371 | + | ||
| 372 | + return true; | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + bool OnTouch( Actor actor , const TouchEvent& event ) | ||
| 376 | + { | ||
| 377 | + const TouchPoint &point = event.GetPoint(0); | ||
| 378 | + | ||
| 379 | + switch(point.state) | ||
| 380 | + { | ||
| 381 | + case TouchPoint::Down: | ||
| 382 | + { | ||
| 383 | + mIsDown = true; | ||
| 384 | + mDownPosition = point.screen; | ||
| 385 | + | ||
| 386 | + mLightAnimation.Play(); | ||
| 387 | + | ||
| 388 | + if( mStrenghAnimation ) | ||
| 389 | + { | ||
| 390 | + mStrenghAnimation.Clear(); | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + mRefractionEffect.SetLightXYOffset( point.screen - mLightPosition ); | ||
| 394 | + mMeshActor.SetShaderEffect( mRefractionEffect ); | ||
| 395 | + mStrenghAnimation= Animation::New(0.5f); | ||
| 396 | + mStrenghAnimation.AnimateTo( Property( mRefractionEffect, "uEffectStrength" ), 1.f ); | ||
| 397 | + mStrenghAnimation.Play(); | ||
| 398 | + | ||
| 399 | + break; | ||
| 400 | + } | ||
| 401 | + case TouchPoint::Motion: | ||
| 402 | + { | ||
| 403 | + if(mIsDown) | ||
| 404 | + { | ||
| 405 | + // make the light position following the finger movement | ||
| 406 | + mRefractionEffect.SetLightXYOffset( point.screen - mLightPosition ); | ||
| 407 | + } | ||
| 408 | + break; | ||
| 409 | + } | ||
| 410 | + case TouchPoint::Up: | ||
| 411 | + case TouchPoint::Leave: | ||
| 412 | + case TouchPoint::Interrupted: | ||
| 413 | + { | ||
| 414 | + if(mIsDown) | ||
| 415 | + { | ||
| 416 | + mLightAnimation.Pause(); | ||
| 417 | + | ||
| 418 | + if( mStrenghAnimation ) | ||
| 419 | + { | ||
| 420 | + mStrenghAnimation.Clear(); | ||
| 421 | + } | ||
| 422 | + mStrenghAnimation = Animation::New(0.5f); | ||
| 423 | + mStrenghAnimation.AnimateTo( Property( mRefractionEffect, "uEffectStrength" ), 0.f ); | ||
| 424 | + mStrenghAnimation.FinishedSignal().Connect( this, &RefractionEffectExample::OnTouchFinished ); | ||
| 425 | + mStrenghAnimation.Play(); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + mIsDown = false; | ||
| 429 | + break; | ||
| 430 | + } | ||
| 431 | + case TouchPoint::Stationary: | ||
| 432 | + case TouchPoint::Last: | ||
| 433 | + default: | ||
| 434 | + { | ||
| 435 | + break; | ||
| 436 | + } | ||
| 437 | + } | ||
| 438 | + return true; | ||
| 439 | + } | ||
| 440 | + | ||
| 441 | + void OnTouchFinished( Animation& source ) | ||
| 442 | + { | ||
| 443 | + mMeshActor.SetShaderEffect( mNoEffect ); | ||
| 444 | + mRefractionEffect.SetLightXYOffset( Vector2::ZERO ); | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + void CreateSurface( const std::string& objFileName ) | ||
| 448 | + { | ||
| 449 | + MeshData::VertexContainer vertices; | ||
| 450 | + MeshData::FaceIndices faces; | ||
| 451 | + MeshData meshData; | ||
| 452 | + | ||
| 453 | + std::vector<float> boundingBox; | ||
| 454 | + std::vector<Vector3> vertexPositions; | ||
| 455 | + std::vector<int> faceIndices; | ||
| 456 | + // read the vertice and faces from the .obj file, and record the bounding box | ||
| 457 | + ReadObjFile( objFileName, boundingBox, vertexPositions, faceIndices ); | ||
| 458 | + | ||
| 459 | + std::vector<Vector2> textureCoordinates; | ||
| 460 | + // align the mesh, scale it to fit the screen size, and calculate the texture coordinate for each vertex | ||
| 461 | + ShapeResizeAndTexureCoordinateCalculation( boundingBox, vertexPositions, textureCoordinates ); | ||
| 462 | + | ||
| 463 | + // re-organize the mesh, the vertices are duplicated, each vertex only belongs to one triangle. | ||
| 464 | + // Without sharing vertex between triangle, so we can manipulate the texture offset on each triangle conveniently. | ||
| 465 | + for( std::size_t i=0; i<faceIndices.size(); i=i+3 ) | ||
| 466 | + { | ||
| 467 | + Vector3 edge1 = vertexPositions[ faceIndices[i+2] ] - vertexPositions[ faceIndices[i] ]; | ||
| 468 | + Vector3 edge2 = vertexPositions[ faceIndices[i+1] ] - vertexPositions[ faceIndices[i] ]; | ||
| 469 | + Vector3 normal = edge1.Cross(edge2); | ||
| 470 | + normal.Normalize(); | ||
| 471 | + | ||
| 472 | + if( normal.z > 0 ) | ||
| 473 | + { | ||
| 474 | + faces.push_back( i ); | ||
| 475 | + faces.push_back( i+1 ); | ||
| 476 | + faces.push_back( i+2 ); | ||
| 477 | + } | ||
| 478 | + else | ||
| 479 | + { | ||
| 480 | + normal *= -1.f; | ||
| 481 | + faces.push_back( i ); | ||
| 482 | + faces.push_back( i+2 ); | ||
| 483 | + faces.push_back( i+1 ); | ||
| 484 | + } | ||
| 485 | + | ||
| 486 | + vertices.push_back( MeshData::Vertex( vertexPositions[ faceIndices[i] ], textureCoordinates[ faceIndices[i] ], normal ) ); | ||
| 487 | + vertices.push_back( MeshData::Vertex( vertexPositions[ faceIndices[i+1] ], textureCoordinates[ faceIndices[i+1] ], normal ) ); | ||
| 488 | + vertices.push_back( MeshData::Vertex( vertexPositions[ faceIndices[i+2] ], textureCoordinates[ faceIndices[i+2] ], normal ) ); | ||
| 489 | + | ||
| 490 | + } | ||
| 491 | + | ||
| 492 | + // Now ready to construct the mesh actor | ||
| 493 | + meshData.SetMaterial( mMaterial ); | ||
| 494 | + meshData.SetVertices( vertices ); | ||
| 495 | + meshData.SetFaceIndices( faces ); | ||
| 496 | + meshData.SetHasTextureCoords(true); | ||
| 497 | + meshData.SetHasNormals(true); | ||
| 498 | + mMeshActor = MeshActor::New( Mesh::New( meshData ) ); | ||
| 499 | + mMeshActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 500 | + mMeshActor.SetAffectedByLighting( false ); | ||
| 501 | + mMeshActor.SetShaderEffect( mNoEffect ); | ||
| 502 | + mContent.Add( mMeshActor ); | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + void ReadObjFile( const std::string& objFileName, | ||
| 506 | + std::vector<float>& boundingBox, | ||
| 507 | + std::vector<Vector3>& vertexPositions, | ||
| 508 | + std::vector<int>& faceIndices) | ||
| 509 | + { | ||
| 510 | + std::ifstream ifs( objFileName.c_str(), std::ios::in ); | ||
| 511 | + | ||
| 512 | + boundingBox.resize( 6 ); | ||
| 513 | + boundingBox[0]=boundingBox[2]=boundingBox[4] = std::numeric_limits<float>::max(); | ||
| 514 | + boundingBox[1]=boundingBox[3]=boundingBox[5] = -std::numeric_limits<float>::max(); | ||
| 515 | + | ||
| 516 | + std::string line; | ||
| 517 | + while( std::getline( ifs, line ) ) | ||
| 518 | + { | ||
| 519 | + if( line[0] == 'v' && std::isspace(line[1])) // vertex | ||
| 520 | + { | ||
| 521 | + std::istringstream iss(line.substr(2), std::istringstream::in); | ||
| 522 | + unsigned int i = 0; | ||
| 523 | + Vector3 vertex; | ||
| 524 | + while( iss >> vertex[i++] && i < 3); | ||
| 525 | + if( vertex.x < boundingBox[0] ) boundingBox[0] = vertex.x; | ||
| 526 | + if( vertex.x > boundingBox[1] ) boundingBox[1] = vertex.x; | ||
| 527 | + if( vertex.y < boundingBox[2] ) boundingBox[2] = vertex.y; | ||
| 528 | + if( vertex.y > boundingBox[3] ) boundingBox[3] = vertex.y; | ||
| 529 | + if( vertex.z < boundingBox[4] ) boundingBox[4] = vertex.z; | ||
| 530 | + if( vertex.z > boundingBox[5] ) boundingBox[5] = vertex.z; | ||
| 531 | + vertexPositions.push_back( vertex ); | ||
| 532 | + } | ||
| 533 | + else if( line[0] == 'f' ) //face | ||
| 534 | + { | ||
| 535 | + unsigned int numOfInt = 3; | ||
| 536 | + while( true ) | ||
| 537 | + { | ||
| 538 | + std::size_t found = line.find('/'); | ||
| 539 | + if( found == std::string::npos ) | ||
| 540 | + { | ||
| 541 | + break; | ||
| 542 | + } | ||
| 543 | + line[found] = ' '; | ||
| 544 | + numOfInt++; | ||
| 545 | + } | ||
| 546 | + | ||
| 547 | + std::istringstream iss(line.substr(2), std::istringstream::in); | ||
| 548 | + int indices[ numOfInt ]; | ||
| 549 | + unsigned int i=0; | ||
| 550 | + while( iss >> indices[i++] && i < numOfInt); | ||
| 551 | + unsigned int step = (i+1) / 3; | ||
| 552 | + faceIndices.push_back( indices[0]-1 ); | ||
| 553 | + faceIndices.push_back( indices[step]-1 ); | ||
| 554 | + faceIndices.push_back( indices[2*step]-1 ); | ||
| 555 | + } | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + ifs.close(); | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + void ShapeResizeAndTexureCoordinateCalculation( const std::vector<float>& boundingBox, | ||
| 562 | + std::vector<Vector3>& vertexPositions, | ||
| 563 | + std::vector<Vector2>& textureCoordinates) | ||
| 564 | + { | ||
| 565 | + Vector3 bBoxSize( boundingBox[1] - boundingBox[0], boundingBox[3] - boundingBox[2], boundingBox[5] - boundingBox[4]); | ||
| 566 | + Vector3 bBoxMinCorner( boundingBox[0], boundingBox[2], boundingBox[4] ); | ||
| 567 | + | ||
| 568 | + Vector2 stageSize = Stage::GetCurrent().GetSize(); | ||
| 569 | + Vector3 scale( stageSize.x / bBoxSize.x, stageSize.y / bBoxSize.y, 1.f ); | ||
| 570 | + scale.z = (scale.x + scale.y)/2.f; | ||
| 571 | + | ||
| 572 | + for( std::vector<Vector3>::iterator iter = vertexPositions.begin(); iter != vertexPositions.end(); iter++ ) | ||
| 573 | + { | ||
| 574 | + Vector3 newPosition( (*iter) - bBoxMinCorner ) ; | ||
| 575 | + | ||
| 576 | + Vector2 textureCoord( newPosition.x / bBoxSize.x, newPosition.y / bBoxSize.y ); | ||
| 577 | + textureCoordinates.push_back( textureCoord ); | ||
| 578 | + | ||
| 579 | + newPosition -= bBoxSize * 0.5f; | ||
| 580 | + (*iter) = newPosition * scale; | ||
| 581 | + } | ||
| 582 | + } | ||
| 583 | + | ||
| 584 | + /** | ||
| 585 | + * Main key event handler | ||
| 586 | + */ | ||
| 587 | + void OnKeyEvent(const KeyEvent& event) | ||
| 588 | + { | ||
| 589 | + if(event.state == KeyEvent::Down) | ||
| 590 | + { | ||
| 591 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | ||
| 592 | + { | ||
| 593 | + mApplication.Quit(); | ||
| 594 | + } | ||
| 595 | + } | ||
| 596 | + } | ||
| 597 | + | ||
| 598 | +private: | ||
| 599 | + | ||
| 600 | + Application& mApplication; | ||
| 601 | + Layer mContent; | ||
| 602 | + | ||
| 603 | + bool mIsDown; | ||
| 604 | + Vector2 mDownPosition; | ||
| 605 | + Vector2 mLightPosition; | ||
| 606 | + Vector2 mStageHalfSize; | ||
| 607 | + | ||
| 608 | + Material mMaterial; | ||
| 609 | + MeshActor mMeshActor; | ||
| 610 | + | ||
| 611 | + RefractionEffect mRefractionEffect; | ||
| 612 | + NoEffect mNoEffect; | ||
| 613 | + Animation mLightAnimation; | ||
| 614 | + Animation mStrenghAnimation; | ||
| 615 | + | ||
| 616 | + Toolkit::PushButton mChangeTextureButton; | ||
| 617 | + Toolkit::PushButton mChangeMeshButton; | ||
| 618 | + unsigned int mCurrentTextureId; | ||
| 619 | + unsigned int mCurrentMeshId; | ||
| 620 | +}; | ||
| 621 | + | ||
| 622 | +/*****************************************************************************/ | ||
| 623 | + | ||
| 624 | +static void | ||
| 625 | +RunTest(Application& app) | ||
| 626 | +{ | ||
| 627 | + RefractionEffectExample theApp(app); | ||
| 628 | + app.MainLoop(); | ||
| 629 | +} | ||
| 630 | + | ||
| 631 | +/*****************************************************************************/ | ||
| 632 | + | ||
| 633 | +int | ||
| 634 | +main(int argc, char **argv) | ||
| 635 | +{ | ||
| 636 | + Application app = Application::New(&argc, &argv); | ||
| 637 | + | ||
| 638 | + RunTest(app); | ||
| 639 | + | ||
| 640 | + return 0; | ||
| 641 | +} |
packaging/com.samsung.dali-demo.spec
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | Name: com.samsung.dali-demo | 3 | Name: com.samsung.dali-demo |
| 4 | Summary: The OpenGLES Canvas Core Demo | 4 | Summary: The OpenGLES Canvas Core Demo |
| 5 | -Version: 1.0.23 | 5 | +Version: 1.0.26 |
| 6 | Release: 1 | 6 | Release: 1 |
| 7 | Group: System/Libraries | 7 | Group: System/Libraries |
| 8 | License: Apache-2.0 | 8 | License: Apache-2.0 |
| @@ -46,12 +46,6 @@ PREFIX="/usr" | @@ -46,12 +46,6 @@ PREFIX="/usr" | ||
| 46 | CXXFLAGS+=" -Wall -g -O2" | 46 | CXXFLAGS+=" -Wall -g -O2" |
| 47 | LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -fPIC" | 47 | LDFLAGS+=" -Wl,--rpath=$PREFIX/lib -Wl,--as-needed -fPIC" |
| 48 | 48 | ||
| 49 | -%if 0%{?sec_build_binary_debug_enable} | ||
| 50 | -export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" | ||
| 51 | -export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" | ||
| 52 | -export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" | ||
| 53 | -%endif | ||
| 54 | - | ||
| 55 | %ifarch %{arm} | 49 | %ifarch %{arm} |
| 56 | EXTRA_CONFIGURE_OPTIONS=" --host=arm" | 50 | EXTRA_CONFIGURE_OPTIONS=" --host=arm" |
| 57 | CXXFLAGS+=" -D_ARCH_ARM_" | 51 | CXXFLAGS+=" -D_ARCH_ARM_" |