Commit 762c7ea311e8ca9584679bf61f4475f07d9166ac
[dali_1.2.7] Merge branch 'devel/master'
Change-Id: I9efc857ec2d1602ab762a9951b0a2f3bb7154977
Showing
14 changed files
with
160 additions
and
72 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -64,7 +64,7 @@ |
| 64 | 64 | <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"> |
| 65 | 65 | <label>Scroll View</label> |
| 66 | 66 | </ui-application> |
| 67 | - <ui-application appid="shadow-bone-lighting.example" exec="/usr/apps/com.samsung.dali-demo/bin/shadow-bone-lighting.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 67 | + <ui-application appid="shadows-and-lights.example" exec="/usr/apps/com.samsung.dali-demo/bin/shadows-and-lights.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 68 | 68 | <label>Shadows and Lights</label> |
| 69 | 69 | </ui-application> |
| 70 | 70 | <ui-application appid="dali-builder" exec="/usr/apps/com.samsung.dali-demo/bin/dali-builder" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ... | ... |
demo/dali-demo.cpp
| ... | ... | @@ -48,7 +48,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 48 | 48 | demo.AddExample(Example("page-turn-view.example", DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW)); |
| 49 | 49 | demo.AddExample(Example("refraction-effect.example", DALI_DEMO_STR_TITLE_REFRACTION)); |
| 50 | 50 | demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW)); |
| 51 | - demo.AddExample(Example("shadow-bone-lighting.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS)); | |
| 51 | + demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS)); | |
| 52 | 52 | demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI)); |
| 53 | 53 | demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING)); |
| 54 | 54 | demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING)); | ... | ... |
examples/page-turn-view/page-turn-view-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -18,6 +18,10 @@ |
| 18 | 18 | #include <dali/dali.h> |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | #include <dali-toolkit/devel-api/image-atlas/image-atlas.h> |
| 21 | +#include <dali-toolkit/devel-api/controls/page-turn-view/page-factory.h> | |
| 22 | +#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h> | |
| 23 | +#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h> | |
| 24 | +#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h> | |
| 21 | 25 | #include <dali/devel-api/images/atlas.h> |
| 22 | 26 | |
| 23 | 27 | #include <assert.h> | ... | ... |
examples/primitive-shapes/primitive-shapes-example.cpp
| ... | ... | @@ -19,6 +19,9 @@ namespace |
| 19 | 19 | DEMO_IMAGE_DIR "octahedron-button.png" |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | + //Prefix of all shape titles. | |
| 23 | + const std::string SHAPE_TITLE_PREFIX = "Current Shape: "; | |
| 24 | + | |
| 22 | 25 | //Shape property defaults |
| 23 | 26 | const int DEFAULT_SLICES = 32; |
| 24 | 27 | const int DEFAULT_STACKS = 32; |
| ... | ... | @@ -94,9 +97,11 @@ public: |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | 99 | //Place buttons on the top of the screen, which allow for selection of the shape to be displayed. |
| 100 | + //A title above indicates the currently selected shape. | |
| 97 | 101 | //The buttons are laid out like so: |
| 98 | 102 | // |
| 99 | 103 | // ^ +--------------------------------+ |
| 104 | + // | | Current Shape: ~~~~~ | | |
| 100 | 105 | // | | | |
| 101 | 106 | // | | +----+ +----+ +----+ +----+ | |
| 102 | 107 | // | | | | | | | | | | | |
| ... | ... | @@ -123,26 +128,39 @@ public: |
| 123 | 128 | // | | |
| 124 | 129 | // | | |
| 125 | 130 | // | | |
| 126 | - // | | | |
| 127 | 131 | // +--------------------------------+ |
| 128 | 132 | // |
| 129 | 133 | void SetupButtons( Layer layer ) |
| 130 | 134 | { |
| 131 | 135 | float containerPadding = 10.0f; |
| 132 | - float buttonPadding = 5.0f; | |
| 136 | + float elementPadding = 5.0f; | |
| 137 | + | |
| 138 | + //Used to layout the title and the buttons below it. | |
| 139 | + Control topAlignment = Control::New(); | |
| 140 | + topAlignment.SetParentOrigin( ParentOrigin::TOP_CENTER ); | |
| 141 | + topAlignment.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | |
| 142 | + topAlignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 143 | + topAlignment.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); | |
| 144 | + layer.Add( topAlignment ); | |
| 145 | + | |
| 146 | + //Add a title to indicate the currently selected shape. | |
| 147 | + mShapeTitle = TextLabel::New( "DEFAULT" ); | |
| 148 | + mShapeTitle.SetParentOrigin( ParentOrigin::CENTER ); | |
| 149 | + mShapeTitle.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 150 | + mShapeTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); | |
| 151 | + mShapeTitle.SetPadding( Padding( elementPadding, elementPadding, elementPadding, elementPadding ) ); | |
| 152 | + topAlignment.Add( mShapeTitle ); | |
| 133 | 153 | |
| 134 | 154 | //Create a variable-length container that can wrap buttons around as more are added. |
| 135 | 155 | FlexContainer buttonContainer = FlexContainer::New(); |
| 136 | - buttonContainer.SetParentOrigin( ParentOrigin::TOP_CENTER ); | |
| 156 | + buttonContainer.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 137 | 157 | buttonContainer.SetAnchorPoint( AnchorPoint::TOP_CENTER ); |
| 138 | 158 | buttonContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 139 | - buttonContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); | |
| 140 | - buttonContainer.SetSizeModeFactor( Vector3( 0.0, 0.3, 0.0 ) ); //30% of height. | |
| 159 | + buttonContainer.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT ); | |
| 141 | 160 | buttonContainer.SetPadding( Padding( containerPadding, containerPadding, containerPadding, containerPadding ) ); |
| 142 | 161 | buttonContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW ); |
| 143 | 162 | buttonContainer.SetProperty( FlexContainer::Property::FLEX_WRAP, FlexContainer::WRAP ); |
| 144 | - | |
| 145 | - layer.Add( buttonContainer ); | |
| 163 | + topAlignment.Add( buttonContainer ); | |
| 146 | 164 | |
| 147 | 165 | //Create buttons and place them in the container. |
| 148 | 166 | for( int modelNumber = 0; modelNumber < NUM_MODELS; modelNumber++ ) |
| ... | ... | @@ -151,7 +169,7 @@ public: |
| 151 | 169 | button.SetParentOrigin( ParentOrigin::CENTER ); |
| 152 | 170 | button.SetAnchorPoint( AnchorPoint::CENTER ); |
| 153 | 171 | button.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); |
| 154 | - button.SetPadding( Padding( buttonPadding, buttonPadding, buttonPadding, buttonPadding ) ); | |
| 172 | + button.SetPadding( Padding( elementPadding, elementPadding, elementPadding, elementPadding ) ); | |
| 155 | 173 | button.SetProperty( Button::Property::UNSELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) ); |
| 156 | 174 | button.SetProperty( Button::Property::SELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) ); |
| 157 | 175 | button.RegisterProperty( "modelNumber", Property::Value( modelNumber ) ); |
| ... | ... | @@ -333,12 +351,18 @@ public: |
| 333 | 351 | |
| 334 | 352 | //Set up sliders. |
| 335 | 353 | SetupSlider( 0, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); |
| 336 | - SetupMarks( mSliders.at( 0 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 354 | + SetupMarks( 0, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 355 | + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); | |
| 356 | + | |
| 337 | 357 | SetupSlider( 1, STACKS_LOWER_BOUND, STACKS_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::STACKS, "stacks" ); |
| 338 | - SetupMarks( mSliders.at( 1 ), STACKS_LOWER_BOUND, STACKS_UPPER_BOUND ); | |
| 358 | + SetupMarks( 1, STACKS_LOWER_BOUND, STACKS_UPPER_BOUND ); | |
| 359 | + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); | |
| 339 | 360 | |
| 340 | 361 | //Set model in control. |
| 341 | 362 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 363 | + | |
| 364 | + //Update title. | |
| 365 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Sphere" ); | |
| 342 | 366 | } |
| 343 | 367 | |
| 344 | 368 | //Sets the 3D model to a cone and modifies the sliders appropriately. |
| ... | ... | @@ -354,12 +378,20 @@ public: |
| 354 | 378 | |
| 355 | 379 | //Set up sliders. |
| 356 | 380 | SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); |
| 381 | + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 382 | + | |
| 357 | 383 | SetupSlider( 1, 1.0f, 32.0f, DEFAULT_SCALE_BOTTOM_RADIUS, PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, "scaleBottomRadius" ); |
| 384 | + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 385 | + | |
| 358 | 386 | SetupSlider( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); |
| 359 | - SetupMarks( mSliders.at( 2 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 387 | + SetupMarks( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 388 | + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); | |
| 360 | 389 | |
| 361 | 390 | //Set model in control. |
| 362 | 391 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 392 | + | |
| 393 | + //Update title. | |
| 394 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cone" ); | |
| 363 | 395 | } |
| 364 | 396 | |
| 365 | 397 | //Sets the 3D model to a conical frustrum and modifies the sliders appropriately. |
| ... | ... | @@ -376,11 +408,19 @@ public: |
| 376 | 408 | |
| 377 | 409 | //Set up used sliders. |
| 378 | 410 | SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); |
| 411 | + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 412 | + | |
| 379 | 413 | SetupSlider( 1, 0.0f, 32.0f, DEFAULT_SCALE_BOTTOM_RADIUS, PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, "scaleBottomRadius" ); |
| 414 | + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 415 | + | |
| 380 | 416 | SetupSlider( 2, 0.0f, 32.0f, DEFAULT_SCALE_TOP_RADIUS, PrimitiveVisual::Property::SCALE_TOP_RADIUS, "scaleTopRadius" ); |
| 417 | + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 381 | 418 | |
| 382 | 419 | //Set model in control. |
| 383 | 420 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 421 | + | |
| 422 | + //Update title. | |
| 423 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Conical Frustrum" ); | |
| 384 | 424 | } |
| 385 | 425 | |
| 386 | 426 | //Sets the 3D model to a cylinder and modifies the sliders appropriately. |
| ... | ... | @@ -396,12 +436,20 @@ public: |
| 396 | 436 | |
| 397 | 437 | //Set up used sliders. |
| 398 | 438 | SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); |
| 439 | + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 440 | + | |
| 399 | 441 | SetupSlider( 1, 1.0f, 32.0f, DEFAULT_SCALE_RADIUS, PrimitiveVisual::Property::SCALE_RADIUS, "scaleRadius" ); |
| 442 | + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); | |
| 443 | + | |
| 400 | 444 | SetupSlider( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); |
| 401 | - SetupMarks( mSliders.at( 2 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 445 | + SetupMarks( 2 , SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); | |
| 446 | + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); | |
| 402 | 447 | |
| 403 | 448 | //Set model in control. |
| 404 | 449 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 450 | + | |
| 451 | + //Update title. | |
| 452 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cylinder" ); | |
| 405 | 453 | } |
| 406 | 454 | |
| 407 | 455 | //Sets the 3D model to a cube and modifies the sliders appropriately. |
| ... | ... | @@ -414,6 +462,9 @@ public: |
| 414 | 462 | |
| 415 | 463 | //Set model in control. |
| 416 | 464 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 465 | + | |
| 466 | + //Update title. | |
| 467 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cube" ); | |
| 417 | 468 | } |
| 418 | 469 | |
| 419 | 470 | //Sets the 3D model to a bevelled cube and modifies the sliders appropriately. |
| ... | ... | @@ -428,10 +479,16 @@ public: |
| 428 | 479 | |
| 429 | 480 | //Set up used sliders. |
| 430 | 481 | SetupSlider( 0, 0.0f, 1.0f, DEFAULT_BEVEL_PERCENTAGE, PrimitiveVisual::Property::BEVEL_PERCENTAGE, "bevelPercentage" ); |
| 482 | + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 2 ) ); | |
| 483 | + | |
| 431 | 484 | SetupSlider( 1, 0.0f, 1.0f, DEFAULT_BEVEL_SMOOTHNESS, PrimitiveVisual::Property::BEVEL_SMOOTHNESS, "bevelSmoothness" ); |
| 485 | + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 2 ) ); | |
| 432 | 486 | |
| 433 | 487 | //Set model in control. |
| 434 | 488 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 489 | + | |
| 490 | + //Update title. | |
| 491 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Bevelled Cube" ); | |
| 435 | 492 | } |
| 436 | 493 | |
| 437 | 494 | //Sets the 3D model to an octahedron and modifies the sliders appropriately. |
| ... | ... | @@ -444,6 +501,9 @@ public: |
| 444 | 501 | |
| 445 | 502 | //Set model in control. |
| 446 | 503 | mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); |
| 504 | + | |
| 505 | + //Update title. | |
| 506 | + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Octahedron" ); | |
| 447 | 507 | } |
| 448 | 508 | |
| 449 | 509 | //Sets up the slider at the given index for the supplied property, and labels it appropriately. |
| ... | ... | @@ -475,7 +535,7 @@ public: |
| 475 | 535 | } |
| 476 | 536 | |
| 477 | 537 | //Setup snapping to integer values between the two given values. |
| 478 | - void SetupMarks( Slider& slider, int lower, int upper ) | |
| 538 | + void SetupMarks( int sliderIndex, int lower, int upper ) | |
| 479 | 539 | { |
| 480 | 540 | Property::Array marks; |
| 481 | 541 | |
| ... | ... | @@ -484,8 +544,8 @@ public: |
| 484 | 544 | marks.PushBack( Property::Value( mark ) ); |
| 485 | 545 | } |
| 486 | 546 | |
| 487 | - slider.SetProperty( Slider::Property::MARKS, Property::Value( marks ) ); | |
| 488 | - slider.SetProperty( Slider::Property::SNAP_TO_MARKS, Property::Value( true ) ); | |
| 547 | + mSliders.at( sliderIndex ).SetProperty( Slider::Property::MARKS, Property::Value( marks ) ); | |
| 548 | + mSliders.at( sliderIndex ).SetProperty( Slider::Property::SNAP_TO_MARKS, Property::Value( true ) ); | |
| 489 | 549 | } |
| 490 | 550 | |
| 491 | 551 | //When a shape button is tapped, switch to the corresponding shape. |
| ... | ... | @@ -612,18 +672,19 @@ public: |
| 612 | 672 | private: |
| 613 | 673 | Application& mApplication; |
| 614 | 674 | |
| 615 | - std::vector<Slider> mSliders; ///< Holds the sliders on screen that each shape accesses. | |
| 616 | - std::vector<TextLabel> mSliderLabels; ///< Holds the labels to each slider. | |
| 617 | - TableView mSliderTable; ///< A table to layout the sliders next to their labels. | |
| 675 | + std::vector<Slider> mSliders; ///< Holds the sliders on screen that each shape accesses. | |
| 676 | + std::vector<TextLabel> mSliderLabels; ///< Holds the labels to each slider. | |
| 677 | + TableView mSliderTable; ///< A table to layout the sliders next to their labels. | |
| 618 | 678 | |
| 619 | - Property::Map mVisualMap; ///< Property map to create a primitive visual. | |
| 620 | - Control mModel; ///< Control to house the primitive visual. | |
| 679 | + Property::Map mVisualMap; ///< Property map to create a primitive visual. | |
| 680 | + Control mModel; ///< Control to house the primitive visual. | |
| 681 | + TextLabel mShapeTitle; ///< Indicates what the currently selected shape is. | |
| 621 | 682 | |
| 622 | - PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model. | |
| 623 | - Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. | |
| 683 | + PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model. | |
| 684 | + Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. | |
| 624 | 685 | |
| 625 | - Vector4 mColor; ///< Color to set all shapes. | |
| 626 | - Vector2 mRotation; ///< Keeps track of model rotation. | |
| 686 | + Vector4 mColor; ///< Color to set all shapes. | |
| 687 | + Vector2 mRotation; ///< Keeps track of model rotation. | |
| 627 | 688 | }; |
| 628 | 689 | |
| 629 | 690 | void RunTest( Application& application ) | ... | ... |
examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp renamed to examples/shadows-and-lights/shadows-and-lights-example.cpp
| ... | ... | @@ -35,7 +35,7 @@ const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-default.png" ); |
| 35 | 35 | const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); |
| 36 | 36 | |
| 37 | 37 | const char* APPLICATION_TITLE_PAN_LIGHT( "Lighting: Pan Light" ); |
| 38 | -const char* APPLICATION_TITLE_PAN_OBJECT( "Lighting: Rotate Object" ); | |
| 38 | +const char* APPLICATION_TITLE_ROTATE_OBJECT( "Lighting: Rotate Object" ); | |
| 39 | 39 | const char* APPLICATION_TITLE_PAN_SCENE( "Lighting: Pan Scene" ); |
| 40 | 40 | const char* APPLICATION_TITLE_ROTATE_SCENE( "Lighting: Rotate Scene" ); |
| 41 | 41 | const char* CHANGE_EFFECT_IMAGE( DEMO_IMAGE_DIR "icon-change.png" ); |
| ... | ... | @@ -60,8 +60,8 @@ const Vector2 DEFAULT_STAGE_SIZE( 480.0f, 800.0f ); |
| 60 | 60 | |
| 61 | 61 | const float X_ROTATION_DISPLACEMENT_FACTOR = 60.f; |
| 62 | 62 | const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.f; |
| 63 | -const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 180.f; | |
| 64 | -const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 180.f; | |
| 63 | +const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 1/360.f; | |
| 64 | +const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 1/360.f; | |
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
| ... | ... | @@ -81,16 +81,16 @@ public: |
| 81 | 81 | TestApp(Application &app) |
| 82 | 82 | : mApp(app), |
| 83 | 83 | mPaused(false), |
| 84 | - mTranslation(Vector3::ZERO), | |
| 85 | - mSceneYRotation( Dali::ANGLE_30 * 0.5f ), | |
| 86 | - mSceneXRotation( Dali::ANGLE_30 ), | |
| 87 | - mLightYRotation(0.0f), | |
| 88 | - mLightXRotation(0.0f), | |
| 89 | - mObjectYRotation(0.0f), | |
| 84 | + mTranslation(22.0f, -1.0f, 0.0f), | |
| 85 | + mSceneXRotation( Degree(-6.0f) ), // Initial values give a reasonable off-straight view. | |
| 86 | + mSceneYRotation( Degree(20.0f) ), | |
| 87 | + mLightXRotation( Degree(-1.5f) ), | |
| 88 | + mLightYRotation( Degree(-9.5f) ), | |
| 90 | 89 | mObjectXRotation(0.0f), |
| 91 | - mPinchScale(0.5f), | |
| 92 | - mScaleAtPinchStart(0.5f), | |
| 93 | - mPanState(PAN_SCENE) | |
| 90 | + mObjectYRotation(0.0f), | |
| 91 | + mPinchScale(0.6f), | |
| 92 | + mScaleAtPinchStart(0.6f), | |
| 93 | + mPanState(PAN_LIGHT) | |
| 94 | 94 | { |
| 95 | 95 | app.InitSignal().Connect(this, &TestApp::Create); |
| 96 | 96 | app.TerminateSignal().Connect(this, &TestApp::Terminate); |
| ... | ... | @@ -157,7 +157,7 @@ public: |
| 157 | 157 | toolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); |
| 158 | 158 | |
| 159 | 159 | // Set Title text |
| 160 | - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) ); | |
| 160 | + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); | |
| 161 | 161 | |
| 162 | 162 | //Add a reset button |
| 163 | 163 | Toolkit::PushButton resetButton = Toolkit::PushButton::New(); |
| ... | ... | @@ -167,7 +167,7 @@ public: |
| 167 | 167 | toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); |
| 168 | 168 | |
| 169 | 169 | // Setup |
| 170 | - mView.SetPosition(Vector3(0.0f, 0.0f, -50)); | |
| 170 | + mView.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); | |
| 171 | 171 | |
| 172 | 172 | mContents.SetBehavior(Layer::LAYER_3D); |
| 173 | 173 | mContents.SetPosition(mTranslation); |
| ... | ... | @@ -324,9 +324,9 @@ public: |
| 324 | 324 | { |
| 325 | 325 | case PAN_LIGHT: |
| 326 | 326 | { |
| 327 | - mLightXRotation = mLightXRotation - gesture.displacement.y / LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis | |
| 327 | + mLightXRotation = mLightXRotation - gesture.displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis | |
| 328 | 328 | mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 ); |
| 329 | - mLightYRotation = mLightYRotation + gesture.displacement.x / LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis | |
| 329 | + mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis | |
| 330 | 330 | mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 ); |
| 331 | 331 | mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) ); |
| 332 | 332 | break; |
| ... | ... | @@ -407,22 +407,22 @@ public: |
| 407 | 407 | { |
| 408 | 408 | switch(mPanState) |
| 409 | 409 | { |
| 410 | - case PAN_SCENE: | |
| 411 | - mPanState = ROTATE_SCENE; | |
| 412 | - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) ); | |
| 413 | - break; | |
| 414 | - case ROTATE_SCENE: | |
| 415 | - mPanState = PAN_LIGHT; | |
| 416 | - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); | |
| 417 | - break; | |
| 418 | 410 | case PAN_LIGHT: |
| 419 | 411 | mPanState = ROTATE_OBJECT; |
| 420 | - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_OBJECT) ); | |
| 412 | + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_OBJECT) ); | |
| 421 | 413 | break; |
| 422 | 414 | case ROTATE_OBJECT: |
| 415 | + mPanState = ROTATE_SCENE; | |
| 416 | + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) ); | |
| 417 | + break; | |
| 418 | + case ROTATE_SCENE: | |
| 423 | 419 | mPanState = PAN_SCENE; |
| 424 | 420 | mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) ); |
| 425 | 421 | break; |
| 422 | + case PAN_SCENE: | |
| 423 | + mPanState = PAN_LIGHT; | |
| 424 | + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); | |
| 425 | + break; | |
| 426 | 426 | default: |
| 427 | 427 | break; |
| 428 | 428 | } |
| ... | ... | @@ -464,12 +464,12 @@ private: |
| 464 | 464 | PinchGestureDetector mPinchGestureDetector; |
| 465 | 465 | TapGestureDetector mTapGestureDetector; |
| 466 | 466 | Vector3 mTranslation; |
| 467 | - Radian mSceneYRotation; | |
| 468 | 467 | Radian mSceneXRotation; |
| 469 | - Radian mLightYRotation; | |
| 468 | + Radian mSceneYRotation; | |
| 470 | 469 | Radian mLightXRotation; |
| 471 | - Radian mObjectYRotation; | |
| 470 | + Radian mLightYRotation; | |
| 472 | 471 | Radian mObjectXRotation; |
| 472 | + Radian mObjectYRotation; | |
| 473 | 473 | float mPinchScale; |
| 474 | 474 | float mScaleAtPinchStart; |
| 475 | 475 | ... | ... |
examples/text-editor/text-editor-example.cpp
| ... | ... | @@ -40,7 +40,7 @@ const float TOOLBAR_BUTTON_PERCENTAGE = 0.1f; ///< The but |
| 40 | 40 | const float TOOLBAR_TITLE_PERCENTAGE = 0.7f; ///< The title's width as a percentage of the toolbar's width. |
| 41 | 41 | const float TOOLBAR_HEIGHT_PERCENTAGE = 0.05f; ///< The toolbar's height as a percentage of the stage's height. |
| 42 | 42 | const float TOOLBAR_PADDING = 4.f; ///< The padding in pixels. |
| 43 | -const Vector3 BUTTON_PERCENTAGE( 0.8f, 0.8f, 1.f ); ///< The button's width as a percentage of the space for the buttons in the toolbar. | |
| 43 | +const float BUTTON_PERCENTAGE = 0.8f; ///< The button's height as a percentage of the space for the buttons in the toolbar. | |
| 44 | 44 | const Vector3 TEXT_EDITOR_RELATIVE_SIZE( 1.f, 0.45f, 1.0f ); ///< The size of the text editor as a percentage of the stage's size. |
| 45 | 45 | const Vector4 TEXT_EDITOR_BACKGROUND_COLOR( 1.f, 1.f, 1.f, 0.15f ); ///< The background color of the text editor. |
| 46 | 46 | |
| ... | ... | @@ -108,17 +108,46 @@ public: |
| 108 | 108 | "", |
| 109 | 109 | viewStyle ); |
| 110 | 110 | |
| 111 | + // Create a label for the color selection button. | |
| 112 | + // The button will be a child of this, so as to be placed next to it. | |
| 113 | + TextLabel colorLabel = TextLabel::New( "Text Color: " ); | |
| 114 | + colorLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH ); | |
| 115 | + colorLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); | |
| 116 | + colorLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); | |
| 117 | + | |
| 118 | + // Create a container for the color button, to layout the drop-down list below it. | |
| 119 | + mColorContainer = Control::New(); | |
| 120 | + mColorContainer.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH ); | |
| 121 | + mColorContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); | |
| 122 | + mColorContainer.SetSizeModeFactor( Vector3( 0.0f, BUTTON_PERCENTAGE, 0.0f ) ); | |
| 123 | + | |
| 124 | + // Place to right of parent. | |
| 125 | + mColorContainer.SetParentOrigin( ParentOrigin::CENTER_RIGHT ); | |
| 126 | + mColorContainer.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); | |
| 127 | + colorLabel.Add( mColorContainer ); | |
| 128 | + | |
| 129 | + // Add border to highlight harder-to-see colors. | |
| 130 | + // We use a color rather than border visual as the container will always be behind the button. | |
| 131 | + Property::Map colorMap; | |
| 132 | + colorMap.Insert( Visual::Property::TYPE, Visual::COLOR); | |
| 133 | + colorMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLACK ); | |
| 134 | + mColorContainer.SetProperty( Control::Property::BACKGROUND, colorMap ); | |
| 135 | + | |
| 111 | 136 | // Create a 'select color' button. |
| 112 | 137 | mColorButtonOption = Toolkit::PushButton::New(); |
| 113 | 138 | mColorButtonOption.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 114 | - mColorButtonOption.SetSizeModeFactor( BUTTON_PERCENTAGE ); | |
| 139 | + mColorButtonOption.SetSizeModeFactor( Vector3( 0.9f, 0.9f, 0.0f ) ); // Smaller than container to show border. | |
| 140 | + mColorButtonOption.SetParentOrigin( ParentOrigin::CENTER ); | |
| 141 | + mColorButtonOption.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 115 | 142 | |
| 116 | 143 | mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, Color::BLACK ); |
| 117 | 144 | mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, Color::BLACK ); |
| 118 | 145 | |
| 119 | 146 | mColorButtonOption.ClickedSignal().Connect( this, &TextEditorExample::OnChangeColorButtonClicked ); |
| 147 | + mColorContainer.Add( mColorButtonOption ); | |
| 120 | 148 | |
| 121 | - mToolBar.AddControl( mColorButtonOption, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); | |
| 149 | + //Add label to toolbar, which will also add the color button next to it. | |
| 150 | + mToolBar.AddControl( colorLabel, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); | |
| 122 | 151 | |
| 123 | 152 | // Create the text editor. |
| 124 | 153 | mEditor = TextEditor::New(); |
| ... | ... | @@ -159,21 +188,14 @@ public: |
| 159 | 188 | void CreateButtonContainer() |
| 160 | 189 | { |
| 161 | 190 | mButtonContainer = Toolkit::TableView::New( NUMBER_OF_COLORS, 1u ); |
| 162 | - mButtonContainer.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 163 | - mButtonContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 164 | - | |
| 165 | - Stage stage = Stage::GetCurrent(); | |
| 166 | - const Vector2 stageSize = stage.GetSize(); | |
| 167 | - const float toolBarHeight = TOOLBAR_HEIGHT_PERCENTAGE * stageSize.height; | |
| 168 | - mButtonContainer.SetPosition( TOOLBAR_PADDING, 2.f * TOOLBAR_PADDING + toolBarHeight, 0.f ); | |
| 169 | - | |
| 170 | 191 | mButtonContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 192 | + mButtonContainer.SetSizeModeFactor( Vector3( 1.0f, NUMBER_OF_COLORS, 1.0f ) ); | |
| 171 | 193 | |
| 172 | - const Vector3 containerPercentage( 0.8f * TOOLBAR_BUTTON_PERCENTAGE, NUMBER_OF_COLORS, 1.f ); | |
| 173 | - mButtonContainer.SetSizeModeFactor( containerPercentage ); | |
| 174 | - | |
| 175 | - Layer toolbarLayer = mToolBar.GetLayer(); | |
| 176 | - toolbarLayer.Add( mButtonContainer ); | |
| 194 | + // Place below color selection button. | |
| 195 | + mButtonContainer.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 196 | + mButtonContainer.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | |
| 197 | + mButtonContainer.SetPosition( 0.0f, 2.f * TOOLBAR_PADDING, 0.f ); | |
| 198 | + mColorContainer.Add( mButtonContainer ); | |
| 177 | 199 | |
| 178 | 200 | const Vector3 buttonPercentage( 1.f, 0.8f / static_cast<float>( NUMBER_OF_COLORS ), 1.f ); |
| 179 | 201 | for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index ) |
| ... | ... | @@ -260,6 +282,7 @@ private: |
| 260 | 282 | Toolkit::Control mView; |
| 261 | 283 | Toolkit::ToolBar mToolBar; |
| 262 | 284 | Toolkit::TextEditor mEditor; |
| 285 | + Toolkit::Control mColorContainer; | |
| 263 | 286 | Toolkit::PushButton mColorButtonOption; |
| 264 | 287 | Toolkit::TableView mButtonContainer; |
| 265 | 288 | }; | ... | ... |
packaging/com.samsung.dali-demo.spec
resources/images/bevelled-cube-button.png
resources/images/cone-button.png
resources/images/conical-frustrum-button.png
resources/images/cube-button.png
resources/images/cylinder-button.png
resources/images/octahedron-button.png
resources/images/sphere-button.png