diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 4a58819..b7980de 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -64,7 +64,7 @@ - + diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp index f413590..408eb58 100644 --- a/demo/dali-demo.cpp +++ b/demo/dali-demo.cpp @@ -48,7 +48,7 @@ int DALI_EXPORT_API main(int argc, char **argv) demo.AddExample(Example("page-turn-view.example", DALI_DEMO_STR_TITLE_PAGE_TURN_VIEW)); demo.AddExample(Example("refraction-effect.example", DALI_DEMO_STR_TITLE_REFRACTION)); demo.AddExample(Example("scroll-view.example", DALI_DEMO_STR_TITLE_SCROLL_VIEW)); - demo.AddExample(Example("shadow-bone-lighting.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS)); + demo.AddExample(Example("shadows-and-lights.example", DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS)); demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI)); demo.AddExample(Example("image-scaling-and-filtering.example", DALI_DEMO_STR_TITLE_IMAGE_FITTING_SAMPLING)); demo.AddExample(Example("image-scaling-irregular-grid.example", DALI_DEMO_STR_TITLE_IMAGE_SCALING)); diff --git a/examples/page-turn-view/page-turn-view-example.cpp b/examples/page-turn-view/page-turn-view-example.cpp index 3d037eb..0503ae9 100644 --- a/examples/page-turn-view/page-turn-view-example.cpp +++ b/examples/page-turn-view/page-turn-view-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,10 @@ #include #include #include +#include +#include +#include +#include #include #include diff --git a/examples/primitive-shapes/primitive-shapes-example.cpp b/examples/primitive-shapes/primitive-shapes-example.cpp index 89ff58c..06e794a 100644 --- a/examples/primitive-shapes/primitive-shapes-example.cpp +++ b/examples/primitive-shapes/primitive-shapes-example.cpp @@ -19,6 +19,9 @@ namespace DEMO_IMAGE_DIR "octahedron-button.png" }; + //Prefix of all shape titles. + const std::string SHAPE_TITLE_PREFIX = "Current Shape: "; + //Shape property defaults const int DEFAULT_SLICES = 32; const int DEFAULT_STACKS = 32; @@ -94,9 +97,11 @@ public: } //Place buttons on the top of the screen, which allow for selection of the shape to be displayed. + //A title above indicates the currently selected shape. //The buttons are laid out like so: // // ^ +--------------------------------+ + // | | Current Shape: ~~~~~ | // | | | // | | +----+ +----+ +----+ +----+ | // | | | | | | | | | | | @@ -123,26 +128,39 @@ public: // | | // | | // | | - // | | // +--------------------------------+ // void SetupButtons( Layer layer ) { float containerPadding = 10.0f; - float buttonPadding = 5.0f; + float elementPadding = 5.0f; + + //Used to layout the title and the buttons below it. + Control topAlignment = Control::New(); + topAlignment.SetParentOrigin( ParentOrigin::TOP_CENTER ); + topAlignment.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + topAlignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + topAlignment.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); + layer.Add( topAlignment ); + + //Add a title to indicate the currently selected shape. + mShapeTitle = TextLabel::New( "DEFAULT" ); + mShapeTitle.SetParentOrigin( ParentOrigin::CENTER ); + mShapeTitle.SetAnchorPoint( AnchorPoint::CENTER ); + mShapeTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + mShapeTitle.SetPadding( Padding( elementPadding, elementPadding, elementPadding, elementPadding ) ); + topAlignment.Add( mShapeTitle ); //Create a variable-length container that can wrap buttons around as more are added. FlexContainer buttonContainer = FlexContainer::New(); - buttonContainer.SetParentOrigin( ParentOrigin::TOP_CENTER ); + buttonContainer.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); buttonContainer.SetAnchorPoint( AnchorPoint::TOP_CENTER ); buttonContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - buttonContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); - buttonContainer.SetSizeModeFactor( Vector3( 0.0, 0.3, 0.0 ) ); //30% of height. + buttonContainer.SetResizePolicy( ResizePolicy::FIXED, Dimension::HEIGHT ); buttonContainer.SetPadding( Padding( containerPadding, containerPadding, containerPadding, containerPadding ) ); buttonContainer.SetProperty( FlexContainer::Property::FLEX_DIRECTION, FlexContainer::ROW ); buttonContainer.SetProperty( FlexContainer::Property::FLEX_WRAP, FlexContainer::WRAP ); - - layer.Add( buttonContainer ); + topAlignment.Add( buttonContainer ); //Create buttons and place them in the container. for( int modelNumber = 0; modelNumber < NUM_MODELS; modelNumber++ ) @@ -151,7 +169,7 @@ public: button.SetParentOrigin( ParentOrigin::CENTER ); button.SetAnchorPoint( AnchorPoint::CENTER ); button.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - button.SetPadding( Padding( buttonPadding, buttonPadding, buttonPadding, buttonPadding ) ); + button.SetPadding( Padding( elementPadding, elementPadding, elementPadding, elementPadding ) ); button.SetProperty( Button::Property::UNSELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) ); button.SetProperty( Button::Property::SELECTED_STATE_IMAGE, Property::Value( BUTTON_IMAGE_URL[modelNumber] ) ); button.RegisterProperty( "modelNumber", Property::Value( modelNumber ) ); @@ -333,12 +351,18 @@ public: //Set up sliders. SetupSlider( 0, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); - SetupMarks( mSliders.at( 0 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + SetupMarks( 0, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); + SetupSlider( 1, STACKS_LOWER_BOUND, STACKS_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::STACKS, "stacks" ); - SetupMarks( mSliders.at( 1 ), STACKS_LOWER_BOUND, STACKS_UPPER_BOUND ); + SetupMarks( 1, STACKS_LOWER_BOUND, STACKS_UPPER_BOUND ); + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Sphere" ); } //Sets the 3D model to a cone and modifies the sliders appropriately. @@ -354,12 +378,20 @@ public: //Set up sliders. SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 1, 1.0f, 32.0f, DEFAULT_SCALE_BOTTOM_RADIUS, PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, "scaleBottomRadius" ); + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); - SetupMarks( mSliders.at( 2 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + SetupMarks( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cone" ); } //Sets the 3D model to a conical frustrum and modifies the sliders appropriately. @@ -376,11 +408,19 @@ public: //Set up used sliders. SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 1, 0.0f, 32.0f, DEFAULT_SCALE_BOTTOM_RADIUS, PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, "scaleBottomRadius" ); + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 2, 0.0f, 32.0f, DEFAULT_SCALE_TOP_RADIUS, PrimitiveVisual::Property::SCALE_TOP_RADIUS, "scaleTopRadius" ); + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Conical Frustrum" ); } //Sets the 3D model to a cylinder and modifies the sliders appropriately. @@ -396,12 +436,20 @@ public: //Set up used sliders. SetupSlider( 0, 1.0f, 32.0f, DEFAULT_SCALE_HEIGHT, PrimitiveVisual::Property::SCALE_HEIGHT, "scaleHeight" ); + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 1, 1.0f, 32.0f, DEFAULT_SCALE_RADIUS, PrimitiveVisual::Property::SCALE_RADIUS, "scaleRadius" ); + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 1 ) ); + SetupSlider( 2, SLICES_LOWER_BOUND, SLICES_UPPER_BOUND, DEFAULT_STACKS, PrimitiveVisual::Property::SLICES, "slices" ); - SetupMarks( mSliders.at( 2 ), SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + SetupMarks( 2 , SLICES_LOWER_BOUND, SLICES_UPPER_BOUND ); + mSliders.at( 2 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 0 ) ); //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cylinder" ); } //Sets the 3D model to a cube and modifies the sliders appropriately. @@ -414,6 +462,9 @@ public: //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Cube" ); } //Sets the 3D model to a bevelled cube and modifies the sliders appropriately. @@ -428,10 +479,16 @@ public: //Set up used sliders. SetupSlider( 0, 0.0f, 1.0f, DEFAULT_BEVEL_PERCENTAGE, PrimitiveVisual::Property::BEVEL_PERCENTAGE, "bevelPercentage" ); + mSliders.at( 0 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 2 ) ); + SetupSlider( 1, 0.0f, 1.0f, DEFAULT_BEVEL_SMOOTHNESS, PrimitiveVisual::Property::BEVEL_SMOOTHNESS, "bevelSmoothness" ); + mSliders.at( 1 ).SetProperty( Slider::Property::VALUE_PRECISION, Property::Value( 2 ) ); //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Bevelled Cube" ); } //Sets the 3D model to an octahedron and modifies the sliders appropriately. @@ -444,6 +501,9 @@ public: //Set model in control. mModel.SetProperty( Control::Property::BACKGROUND, Property::Value( mVisualMap ) ); + + //Update title. + mShapeTitle.SetProperty( TextLabel::Property::TEXT, SHAPE_TITLE_PREFIX + "Octahedron" ); } //Sets up the slider at the given index for the supplied property, and labels it appropriately. @@ -475,7 +535,7 @@ public: } //Setup snapping to integer values between the two given values. - void SetupMarks( Slider& slider, int lower, int upper ) + void SetupMarks( int sliderIndex, int lower, int upper ) { Property::Array marks; @@ -484,8 +544,8 @@ public: marks.PushBack( Property::Value( mark ) ); } - slider.SetProperty( Slider::Property::MARKS, Property::Value( marks ) ); - slider.SetProperty( Slider::Property::SNAP_TO_MARKS, Property::Value( true ) ); + mSliders.at( sliderIndex ).SetProperty( Slider::Property::MARKS, Property::Value( marks ) ); + mSliders.at( sliderIndex ).SetProperty( Slider::Property::SNAP_TO_MARKS, Property::Value( true ) ); } //When a shape button is tapped, switch to the corresponding shape. @@ -612,18 +672,19 @@ public: private: Application& mApplication; - std::vector mSliders; ///< Holds the sliders on screen that each shape accesses. - std::vector mSliderLabels; ///< Holds the labels to each slider. - TableView mSliderTable; ///< A table to layout the sliders next to their labels. + std::vector mSliders; ///< Holds the sliders on screen that each shape accesses. + std::vector mSliderLabels; ///< Holds the labels to each slider. + TableView mSliderTable; ///< A table to layout the sliders next to their labels. - Property::Map mVisualMap; ///< Property map to create a primitive visual. - Control mModel; ///< Control to house the primitive visual. + Property::Map mVisualMap; ///< Property map to create a primitive visual. + Control mModel; ///< Control to house the primitive visual. + TextLabel mShapeTitle; ///< Indicates what the currently selected shape is. - PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model. - Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. + PanGestureDetector mPanGestureDetector; ///< Detects pan gestures for rotation of the model. + Animation mRotationAnimation; ///< Automatically rotates the model, unless it is being panned. - Vector4 mColor; ///< Color to set all shapes. - Vector2 mRotation; ///< Keeps track of model rotation. + Vector4 mColor; ///< Color to set all shapes. + Vector2 mRotation; ///< Keeps track of model rotation. }; void RunTest( Application& application ) diff --git a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp b/examples/shadows-and-lights/shadows-and-lights-example.cpp index 72b6fa1..4ae5877 100644 --- a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp +++ b/examples/shadows-and-lights/shadows-and-lights-example.cpp @@ -35,7 +35,7 @@ const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "background-default.png" ); const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); const char* APPLICATION_TITLE_PAN_LIGHT( "Lighting: Pan Light" ); -const char* APPLICATION_TITLE_PAN_OBJECT( "Lighting: Rotate Object" ); +const char* APPLICATION_TITLE_ROTATE_OBJECT( "Lighting: Rotate Object" ); const char* APPLICATION_TITLE_PAN_SCENE( "Lighting: Pan Scene" ); const char* APPLICATION_TITLE_ROTATE_SCENE( "Lighting: Rotate Scene" ); const char* CHANGE_EFFECT_IMAGE( DEMO_IMAGE_DIR "icon-change.png" ); @@ -60,8 +60,8 @@ const Vector2 DEFAULT_STAGE_SIZE( 480.0f, 800.0f ); const float X_ROTATION_DISPLACEMENT_FACTOR = 60.f; const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.f; -const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 180.f; -const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 180.f; +const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 1/360.f; +const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 1/360.f; } @@ -81,16 +81,16 @@ public: TestApp(Application &app) : mApp(app), mPaused(false), - mTranslation(Vector3::ZERO), - mSceneYRotation( Dali::ANGLE_30 * 0.5f ), - mSceneXRotation( Dali::ANGLE_30 ), - mLightYRotation(0.0f), - mLightXRotation(0.0f), - mObjectYRotation(0.0f), + mTranslation(22.0f, -1.0f, 0.0f), + mSceneXRotation( Degree(-6.0f) ), // Initial values give a reasonable off-straight view. + mSceneYRotation( Degree(20.0f) ), + mLightXRotation( Degree(-1.5f) ), + mLightYRotation( Degree(-9.5f) ), mObjectXRotation(0.0f), - mPinchScale(0.5f), - mScaleAtPinchStart(0.5f), - mPanState(PAN_SCENE) + mObjectYRotation(0.0f), + mPinchScale(0.6f), + mScaleAtPinchStart(0.6f), + mPanState(PAN_LIGHT) { app.InitSignal().Connect(this, &TestApp::Create); app.TerminateSignal().Connect(this, &TestApp::Terminate); @@ -157,7 +157,7 @@ public: toolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); // Set Title text - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) ); + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); //Add a reset button Toolkit::PushButton resetButton = Toolkit::PushButton::New(); @@ -167,7 +167,7 @@ public: toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // Setup - mView.SetPosition(Vector3(0.0f, 0.0f, -50)); + mView.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); mContents.SetBehavior(Layer::LAYER_3D); mContents.SetPosition(mTranslation); @@ -324,9 +324,9 @@ public: { case PAN_LIGHT: { - mLightXRotation = mLightXRotation - gesture.displacement.y / LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis + mLightXRotation = mLightXRotation - gesture.displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 ); - mLightYRotation = mLightYRotation + gesture.displacement.x / LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis + mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 ); mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) ); break; @@ -407,22 +407,22 @@ public: { switch(mPanState) { - case PAN_SCENE: - mPanState = ROTATE_SCENE; - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) ); - break; - case ROTATE_SCENE: - mPanState = PAN_LIGHT; - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); - break; case PAN_LIGHT: mPanState = ROTATE_OBJECT; - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_OBJECT) ); + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_OBJECT) ); break; case ROTATE_OBJECT: + mPanState = ROTATE_SCENE; + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_ROTATE_SCENE) ); + break; + case ROTATE_SCENE: mPanState = PAN_SCENE; mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) ); break; + case PAN_SCENE: + mPanState = PAN_LIGHT; + mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); + break; default: break; } @@ -464,12 +464,12 @@ private: PinchGestureDetector mPinchGestureDetector; TapGestureDetector mTapGestureDetector; Vector3 mTranslation; - Radian mSceneYRotation; Radian mSceneXRotation; - Radian mLightYRotation; + Radian mSceneYRotation; Radian mLightXRotation; - Radian mObjectYRotation; + Radian mLightYRotation; Radian mObjectXRotation; + Radian mObjectYRotation; float mPinchScale; float mScaleAtPinchStart; diff --git a/examples/text-editor/text-editor-example.cpp b/examples/text-editor/text-editor-example.cpp index d2a05d7..209c280 100644 --- a/examples/text-editor/text-editor-example.cpp +++ b/examples/text-editor/text-editor-example.cpp @@ -40,7 +40,7 @@ const float TOOLBAR_BUTTON_PERCENTAGE = 0.1f; ///< The but const float TOOLBAR_TITLE_PERCENTAGE = 0.7f; ///< The title's width as a percentage of the toolbar's width. const float TOOLBAR_HEIGHT_PERCENTAGE = 0.05f; ///< The toolbar's height as a percentage of the stage's height. const float TOOLBAR_PADDING = 4.f; ///< The padding in pixels. -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. +const float BUTTON_PERCENTAGE = 0.8f; ///< The button's height as a percentage of the space for the buttons in the toolbar. 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. const Vector4 TEXT_EDITOR_BACKGROUND_COLOR( 1.f, 1.f, 1.f, 0.15f ); ///< The background color of the text editor. @@ -108,17 +108,46 @@ public: "", viewStyle ); + // Create a label for the color selection button. + // The button will be a child of this, so as to be placed next to it. + TextLabel colorLabel = TextLabel::New( "Text Color: " ); + colorLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH ); + colorLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); + colorLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); + + // Create a container for the color button, to layout the drop-down list below it. + mColorContainer = Control::New(); + mColorContainer.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH ); + mColorContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); + mColorContainer.SetSizeModeFactor( Vector3( 0.0f, BUTTON_PERCENTAGE, 0.0f ) ); + + // Place to right of parent. + mColorContainer.SetParentOrigin( ParentOrigin::CENTER_RIGHT ); + mColorContainer.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); + colorLabel.Add( mColorContainer ); + + // Add border to highlight harder-to-see colors. + // We use a color rather than border visual as the container will always be behind the button. + Property::Map colorMap; + colorMap.Insert( Visual::Property::TYPE, Visual::COLOR); + colorMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLACK ); + mColorContainer.SetProperty( Control::Property::BACKGROUND, colorMap ); + // Create a 'select color' button. mColorButtonOption = Toolkit::PushButton::New(); mColorButtonOption.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mColorButtonOption.SetSizeModeFactor( BUTTON_PERCENTAGE ); + mColorButtonOption.SetSizeModeFactor( Vector3( 0.9f, 0.9f, 0.0f ) ); // Smaller than container to show border. + mColorButtonOption.SetParentOrigin( ParentOrigin::CENTER ); + mColorButtonOption.SetAnchorPoint( AnchorPoint::CENTER ); mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, Color::BLACK ); mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, Color::BLACK ); mColorButtonOption.ClickedSignal().Connect( this, &TextEditorExample::OnChangeColorButtonClicked ); + mColorContainer.Add( mColorButtonOption ); - mToolBar.AddControl( mColorButtonOption, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + //Add label to toolbar, which will also add the color button next to it. + mToolBar.AddControl( colorLabel, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalLeft, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Create the text editor. mEditor = TextEditor::New(); @@ -159,21 +188,14 @@ public: void CreateButtonContainer() { mButtonContainer = Toolkit::TableView::New( NUMBER_OF_COLORS, 1u ); - mButtonContainer.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mButtonContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - - Stage stage = Stage::GetCurrent(); - const Vector2 stageSize = stage.GetSize(); - const float toolBarHeight = TOOLBAR_HEIGHT_PERCENTAGE * stageSize.height; - mButtonContainer.SetPosition( TOOLBAR_PADDING, 2.f * TOOLBAR_PADDING + toolBarHeight, 0.f ); - mButtonContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mButtonContainer.SetSizeModeFactor( Vector3( 1.0f, NUMBER_OF_COLORS, 1.0f ) ); - const Vector3 containerPercentage( 0.8f * TOOLBAR_BUTTON_PERCENTAGE, NUMBER_OF_COLORS, 1.f ); - mButtonContainer.SetSizeModeFactor( containerPercentage ); - - Layer toolbarLayer = mToolBar.GetLayer(); - toolbarLayer.Add( mButtonContainer ); + // Place below color selection button. + mButtonContainer.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); + mButtonContainer.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + mButtonContainer.SetPosition( 0.0f, 2.f * TOOLBAR_PADDING, 0.f ); + mColorContainer.Add( mButtonContainer ); const Vector3 buttonPercentage( 1.f, 0.8f / static_cast( NUMBER_OF_COLORS ), 1.f ); for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index ) @@ -260,6 +282,7 @@ private: Toolkit::Control mView; Toolkit::ToolBar mToolBar; Toolkit::TextEditor mEditor; + Toolkit::Control mColorContainer; Toolkit::PushButton mColorButtonOption; Toolkit::TableView mButtonContainer; }; diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 640bc1c..9964325 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.2.6 +Version: 1.2.7 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/images/bevelled-cube-button.png b/resources/images/bevelled-cube-button.png index 77b7ed6..4fcd084 100644 --- a/resources/images/bevelled-cube-button.png +++ b/resources/images/bevelled-cube-button.png diff --git a/resources/images/cone-button.png b/resources/images/cone-button.png index 6ad6c0b..61d8307 100644 --- a/resources/images/cone-button.png +++ b/resources/images/cone-button.png diff --git a/resources/images/conical-frustrum-button.png b/resources/images/conical-frustrum-button.png index be17563..c14c7e1 100644 --- a/resources/images/conical-frustrum-button.png +++ b/resources/images/conical-frustrum-button.png diff --git a/resources/images/cube-button.png b/resources/images/cube-button.png index 29611be..1e49e09 100644 --- a/resources/images/cube-button.png +++ b/resources/images/cube-button.png diff --git a/resources/images/cylinder-button.png b/resources/images/cylinder-button.png index 07d5494..d2cc96c 100644 --- a/resources/images/cylinder-button.png +++ b/resources/images/cylinder-button.png diff --git a/resources/images/octahedron-button.png b/resources/images/octahedron-button.png index 72bd52b..a04a8b0 100644 --- a/resources/images/octahedron-button.png +++ b/resources/images/octahedron-button.png diff --git a/resources/images/sphere-button.png b/resources/images/sphere-button.png index 319abb1..5ffc6f8 100644 --- a/resources/images/sphere-button.png +++ b/resources/images/sphere-button.png