Commit f809608ed8c0e7bb0608d6a410a40330e8fa1aaf
[dali_1.3.40] Merge branch 'devel/master'
Change-Id: I1ba2184f5a574d04018a4fae21cbd4377da6e1dc
Showing
11 changed files
with
407 additions
and
21 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -266,6 +266,9 @@ |
| 266 | 266 | <ui-application appid="simple-layout.example" exec="/usr/apps/com.samsung.dali-demo/bin/simple-layout.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app"> |
| 267 | 267 | <label>Simple Layout</label> |
| 268 | 268 | </ui-application> |
| 269 | + <ui-application appid="frame-callback.example" exec="/usr/apps/com.samsung.dali-demo/bin/frame-callback.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 270 | + <label>Frame Callback</label> | |
| 271 | + </ui-application> | |
| 269 | 272 | |
| 270 | 273 | <privileges> |
| 271 | 274 | <privilege>http://tizen.org/privilege/mediastorage</privilege> | ... | ... |
examples-reel/dali-examples-reel.cpp
| ... | ... | @@ -46,6 +46,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 46 | 46 | demo.AddExample(Example("dissolve-effect.example", DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION)); |
| 47 | 47 | demo.AddExample(Example("effects-view.example", DALI_DEMO_STR_TITLE_EFFECTS_VIEW)); |
| 48 | 48 | demo.AddExample(Example("flex-container.example", DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND)); |
| 49 | + demo.AddExample(Example("frame-callback.example", DALI_DEMO_STR_TITLE_FRAME_CALLBACK)); | |
| 49 | 50 | demo.AddExample(Example("focus-integration.example", DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION)); |
| 50 | 51 | demo.AddExample(Example("gradients.example", DALI_DEMO_STR_TITLE_COLOR_GRADIENT)); |
| 51 | 52 | demo.AddExample(Example("hello-world.example", DALI_DEMO_STR_TITLE_HELLO_WORLD)); | ... | ... |
examples/frame-callback/frame-callback-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2018 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 | +// EXTERNAL INCLUDES | |
| 19 | +#include <dali-toolkit/dali-toolkit.h> | |
| 20 | +#include <dali/devel-api/common/stage-devel.h> | |
| 21 | + | |
| 22 | +// INTERNAL INCLUDES | |
| 23 | +#include "frame-callback.h" | |
| 24 | + | |
| 25 | +using namespace Dali; | |
| 26 | +using namespace Dali::Toolkit; | |
| 27 | + | |
| 28 | +namespace | |
| 29 | +{ | |
| 30 | +const char * IMAGE_NAME = DEMO_IMAGE_DIR "application-icon-1.png"; | |
| 31 | + | |
| 32 | +const char * TEXT_ENABLED( "FrameCallback: ON" ); | |
| 33 | +const char * TEXT_DISABLED( "FrameCallback: OFF" ); | |
| 34 | +Vector4 TEXT_COLOR_ENABLED( Color::BLACK ); | |
| 35 | +Vector4 TEXT_COLOR_DISABLED( Color::RED ); | |
| 36 | + | |
| 37 | +float ANIMATION_TIME( 4.0f ); | |
| 38 | +float ANIMATION_PROGRESS_MULTIPLIER( 0.02f ); | |
| 39 | +} // unnamed namespace | |
| 40 | + | |
| 41 | +/** | |
| 42 | + * @brief An example of how to set/unset the FrameCallbackInterface in DALi. | |
| 43 | + * | |
| 44 | + * Creates a scene with several image-views which are animated from side-to-side. | |
| 45 | + * With the frame-callback enabled, the image-views' sizes expand as they hits the sides and the opacity | |
| 46 | + * changes to transparent as they go to the middle. | |
| 47 | + */ | |
| 48 | +class FrameCallbackController : public ConnectionTracker | |
| 49 | +{ | |
| 50 | +public: | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * @brief Constructor. | |
| 54 | + * @param[in] application The application. | |
| 55 | + */ | |
| 56 | + FrameCallbackController( Application& application ) | |
| 57 | + : mApplication( application ), | |
| 58 | + mStage(), | |
| 59 | + mFrameCallback(), | |
| 60 | + mTextLabel(), | |
| 61 | + mTapDetector(), | |
| 62 | + mFrameCallbackEnabled( false ) | |
| 63 | + { | |
| 64 | + // Connect to the Application's Init signal | |
| 65 | + mApplication.InitSignal().Connect( this, &FrameCallbackController::Create ); | |
| 66 | + } | |
| 67 | + | |
| 68 | +private: | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * @brief Creates the scene. | |
| 72 | + * | |
| 73 | + * Creates several image-views and places them appropriately. | |
| 74 | + * Animate all image-views. | |
| 75 | + * Set the FrameCallbackInterface on the stage. | |
| 76 | + * Tapping on the stage enables/disables the FrameCallback. | |
| 77 | + */ | |
| 78 | + void Create( Application& /* application */ ) | |
| 79 | + { | |
| 80 | + // Hide the indicator bar. | |
| 81 | + mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); | |
| 82 | + | |
| 83 | + // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit. | |
| 84 | + mStage = Stage::GetCurrent(); | |
| 85 | + mStage.SetBackgroundColor( Color::WHITE ); | |
| 86 | + mStage.KeyEventSignal().Connect( this, &FrameCallbackController::OnKeyEvent ); | |
| 87 | + | |
| 88 | + // Notify mFrameCallback about the stage width. | |
| 89 | + // Can call methods in mFrameCallback directly as we have not set it on the stage yet. | |
| 90 | + Vector2 stageSize = mStage.GetSize(); | |
| 91 | + mFrameCallback.SetStageWidth( stageSize.width ); | |
| 92 | + | |
| 93 | + // Detect taps on the root layer. | |
| 94 | + mTapDetector = TapGestureDetector::New(); | |
| 95 | + mTapDetector.Attach( mStage.GetRootLayer() ); | |
| 96 | + mTapDetector.DetectedSignal().Connect( this, &FrameCallbackController::OnTap ); | |
| 97 | + | |
| 98 | + // Create some key-frames to be used by all animations. | |
| 99 | + KeyFrames keyFrames = KeyFrames::New(); | |
| 100 | + keyFrames.Add( 0.0f, 0.0f ); | |
| 101 | + keyFrames.Add( 0.25f, stageSize.width * 0.5f ); | |
| 102 | + keyFrames.Add( 0.75f, -stageSize.width * 0.5f ); | |
| 103 | + keyFrames.Add( 1.0f, 0.0f ); | |
| 104 | + | |
| 105 | + float yPos = 0.0f; | |
| 106 | + for( int i = 0; yPos < stageSize.height; ++i ) | |
| 107 | + { | |
| 108 | + ImageView imageView = ImageView::New( IMAGE_NAME ); | |
| 109 | + imageView.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | |
| 110 | + imageView.SetParentOrigin( ParentOrigin::TOP_CENTER ); | |
| 111 | + imageView.SetY( yPos ); | |
| 112 | + yPos += imageView.GetNaturalSize().height; | |
| 113 | + | |
| 114 | + // Add the ID of the created ImageView to mFrameCallback. | |
| 115 | + // Again, can call methods in mFrameCallback directly as we have not set it on the stage yet. | |
| 116 | + mFrameCallback.AddId( imageView.GetId() ); | |
| 117 | + | |
| 118 | + mStage.Add( imageView ); | |
| 119 | + | |
| 120 | + // Create an animation and set the progress so that each image starts at a different point. | |
| 121 | + Animation animation = Animation::New( ANIMATION_TIME ); | |
| 122 | + animation.SetLooping( true ); | |
| 123 | + animation.AnimateBetween( Property( imageView, Actor::Property::POSITION_X ), keyFrames ); | |
| 124 | + animation.SetCurrentProgress( std::min( 1.0f, ANIMATION_PROGRESS_MULTIPLIER * i ) ); | |
| 125 | + animation.Play(); | |
| 126 | + } | |
| 127 | + | |
| 128 | + // Create a text-label to display whether the FrameCallback is enabled/disabled. | |
| 129 | + mTextLabel = TextLabel::New( TEXT_ENABLED ); | |
| 130 | + mTextLabel.SetProperty( TextLabel::Property::TEXT_COLOR, TEXT_COLOR_ENABLED ); | |
| 131 | + mTextLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | |
| 132 | + mTextLabel.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 133 | + mTextLabel.SetParentOrigin( ParentOrigin::CENTER ); | |
| 134 | + mStage.Add( mTextLabel ); | |
| 135 | + | |
| 136 | + // Set the FrameCallbackInterface on the root layer. | |
| 137 | + DevelStage::AddFrameCallback( mStage, mFrameCallback, mStage.GetRootLayer() ); | |
| 138 | + mFrameCallbackEnabled = true; | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * @brief Called when a tap on the stage occurs. | |
| 143 | + * | |
| 144 | + * Toggle enabling/disabling of the FrameCallbackInterface | |
| 145 | + */ | |
| 146 | + void OnTap( Actor /* actor */, const TapGesture& /* tap */ ) | |
| 147 | + { | |
| 148 | + if( mFrameCallbackEnabled ) | |
| 149 | + { | |
| 150 | + DevelStage::RemoveFrameCallback( mStage, mFrameCallback ); | |
| 151 | + mTextLabel.SetProperty( TextLabel::Property::TEXT, TEXT_DISABLED ); | |
| 152 | + mTextLabel.SetProperty( TextLabel::Property::TEXT_COLOR, TEXT_COLOR_DISABLED ); | |
| 153 | + } | |
| 154 | + else | |
| 155 | + { | |
| 156 | + DevelStage::AddFrameCallback( mStage, mFrameCallback, mStage.GetRootLayer() ); | |
| 157 | + mTextLabel.SetProperty( TextLabel::Property::TEXT, TEXT_ENABLED ); | |
| 158 | + mTextLabel.SetProperty( TextLabel::Property::TEXT_COLOR, TEXT_COLOR_ENABLED ); | |
| 159 | + } | |
| 160 | + | |
| 161 | + mFrameCallbackEnabled = !mFrameCallbackEnabled; | |
| 162 | + } | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * @brief Called when any key event is received | |
| 166 | + * | |
| 167 | + * Will use this to quit the application if Back or the Escape key is received | |
| 168 | + * @param[in] event The key event information | |
| 169 | + */ | |
| 170 | + void OnKeyEvent( const KeyEvent& event ) | |
| 171 | + { | |
| 172 | + if( event.state == KeyEvent::Down ) | |
| 173 | + { | |
| 174 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 175 | + { | |
| 176 | + mApplication.Quit(); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + } | |
| 180 | + | |
| 181 | +private: | |
| 182 | + Application& mApplication; ///< A reference to the application instance. | |
| 183 | + Stage mStage; ///< The stage we enable the FrameCallback on. | |
| 184 | + FrameCallback mFrameCallback; ///< An instance of our implementation of the FrameCallbackInterface. | |
| 185 | + TextLabel mTextLabel; ///< Text label which shows whether the frame-callback is enabled/disabled. | |
| 186 | + TapGestureDetector mTapDetector; ///< Tap detector to enable/disable the FrameCallbackInterface. | |
| 187 | + bool mFrameCallbackEnabled; ///< Stores whether the FrameCallbackInterface is enabled/disabled. | |
| 188 | +}; | |
| 189 | + | |
| 190 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 191 | +{ | |
| 192 | + Application application = Application::New( &argc, &argv ); | |
| 193 | + FrameCallbackController controller( application ); | |
| 194 | + application.MainLoop(); | |
| 195 | + return 0; | |
| 196 | +} | ... | ... |
examples/frame-callback/frame-callback.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2018 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 | +// CLASS HEADER | |
| 19 | +#include "frame-callback.h" | |
| 20 | + | |
| 21 | +#include <iostream> | |
| 22 | + | |
| 23 | +using namespace Dali; | |
| 24 | + | |
| 25 | +FrameCallback::FrameCallback() | |
| 26 | +: mActorIdContainer(), | |
| 27 | + stageHalfWidth( 0.0f ) | |
| 28 | +{ | |
| 29 | +} | |
| 30 | + | |
| 31 | +void FrameCallback::SetStageWidth( float stageWidth ) | |
| 32 | +{ | |
| 33 | + stageHalfWidth = stageWidth * 0.5f; | |
| 34 | +} | |
| 35 | + | |
| 36 | +void FrameCallback::AddId( unsigned int id ) | |
| 37 | +{ | |
| 38 | + mActorIdContainer.PushBack( id ); | |
| 39 | +} | |
| 40 | + | |
| 41 | +void FrameCallback::Update( Dali::UpdateProxy& updateProxy, float /* elapsedSeconds */ ) | |
| 42 | +{ | |
| 43 | + // Go through Actor ID container and check if we've hit the sides. | |
| 44 | + for( auto&& i : mActorIdContainer ) | |
| 45 | + { | |
| 46 | + Vector3 position; | |
| 47 | + Vector3 size; | |
| 48 | + updateProxy.GetPositionAndSize( i, position, size ); // Retrieve the position and size using the Actor ID. | |
| 49 | + | |
| 50 | + float halfWidthPoint = stageHalfWidth - size.width * 0.5f; | |
| 51 | + float xTranslation = std::abs( position.x ); | |
| 52 | + if( xTranslation > halfWidthPoint ) | |
| 53 | + { | |
| 54 | + // Actor has hit the edge, adjust the size accordingly. | |
| 55 | + float adjustment = xTranslation - halfWidthPoint; | |
| 56 | + size.width += adjustment * SIZE_MULTIPLIER; | |
| 57 | + size.height += adjustment * SIZE_MULTIPLIER; | |
| 58 | + | |
| 59 | + updateProxy.SetSize( i, size ); // Set the size using the UpdateProxy. | |
| 60 | + } | |
| 61 | + | |
| 62 | + // Retrieve the actor's position and set make it more transparent the closer it is to the middle. | |
| 63 | + Vector4 color = updateProxy.GetWorldColor( i ); | |
| 64 | + color.a = xTranslation / halfWidthPoint; | |
| 65 | + updateProxy.SetWorldColor( i, color ); | |
| 66 | + } | |
| 67 | +} | ... | ... |
examples/frame-callback/frame-callback.h
0 → 100644
| 1 | +#ifndef DEMO_FRAME_CALLBACK_H | |
| 2 | +#define DEMO_FRAME_CALLBACK_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 6 | + * | |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 | + * you may not use this file except in compliance with the License. | |
| 9 | + * You may obtain a copy of the License at | |
| 10 | + * | |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 12 | + * | |
| 13 | + * Unless required by applicable law or agreed to in writing, software | |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 16 | + * See the License for the specific language governing permissions and | |
| 17 | + * limitations under the License. | |
| 18 | + * | |
| 19 | + */ | |
| 20 | + | |
| 21 | +// EXTERNAL INCLUDES | |
| 22 | +#include <dali/devel-api/update/frame-callback-interface.h> | |
| 23 | +#include <dali/devel-api/update/update-proxy.h> | |
| 24 | +#include <dali/public-api/common/dali-vector.h> | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * @brief Implementation of the FrameCallbackInterface. | |
| 28 | + * | |
| 29 | + * When this is used, it will expand the size of the actors the closer they get to the horizontal edge | |
| 30 | + * and make the actor transparent the closer it gets to the middle. | |
| 31 | + */ | |
| 32 | +class FrameCallback : public Dali::FrameCallbackInterface | |
| 33 | +{ | |
| 34 | +public: | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * @brief Constructor. | |
| 38 | + */ | |
| 39 | + FrameCallback(); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * @brief Sets the stage width. | |
| 43 | + * @param[in] stageWidth The stage width. | |
| 44 | + */ | |
| 45 | + void SetStageWidth( float stageWidth ); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * @brief The actor with the specified ID will be changed when Update() is called. | |
| 49 | + * @param[in] id Actor ID of actor which should be changed by the FrameCallback. | |
| 50 | + */ | |
| 51 | + void AddId( unsigned int id ); | |
| 52 | + | |
| 53 | +private: | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * @brief Called when every frame is updated. | |
| 57 | + * @param[in] updateProxy Used to set the world-matrix and sizes. | |
| 58 | + * @param[in] elapsedSeconds Time elapsed time since the last frame (in seconds) | |
| 59 | + */ | |
| 60 | + virtual void Update( Dali::UpdateProxy& updateProxy, float elapsedSeconds ); | |
| 61 | + | |
| 62 | +private: | |
| 63 | + | |
| 64 | + Dali::Vector< unsigned int > mActorIdContainer; ///< Container of Actor IDs. | |
| 65 | + float stageHalfWidth; ///< Half the width of the stage. Center is 0,0 in the world matrix. | |
| 66 | + | |
| 67 | + constexpr static float SIZE_MULTIPLIER = 2.0f; ///< Multiplier for the size to set as the actors hit the edge. | |
| 68 | +}; | |
| 69 | + | |
| 70 | +#endif // DEMO_FRAME_CALLBACK_H | ... | ... |
examples/layouting/linear-example.cpp
| ... | ... | @@ -42,6 +42,9 @@ const char* ROTATE_CLOCKWISE_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-reset-selected |
| 42 | 42 | const char* ALIGN_IMAGE( DEMO_IMAGE_DIR "icon-replace.png" ); |
| 43 | 43 | const char* ALIGN_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-replace-selected.png" ); |
| 44 | 44 | |
| 45 | +const char* WEIGHT_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-grid.png" ); | |
| 46 | +const char* WEIGHT_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-grid-selected.png" ); | |
| 47 | + | |
| 45 | 48 | // Child image filenames |
| 46 | 49 | const char* IMAGE_PATH[] = { |
| 47 | 50 | DEMO_IMAGE_DIR "application-icon-101.png", |
| ... | ... | @@ -61,8 +64,8 @@ void CreateChildImageView( ImageView& imageView, const char* filename, Size size |
| 61 | 64 | imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename; |
| 62 | 65 | imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width; |
| 63 | 66 | imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height; |
| 64 | - imageView.SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap ); | |
| 65 | - imageView.SetName("ImageView"); | |
| 67 | + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap ); | |
| 68 | + imageView.SetName( "ImageView" ); | |
| 66 | 69 | imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 67 | 70 | imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); |
| 68 | 71 | } |
| ... | ... | @@ -74,7 +77,8 @@ namespace Demo |
| 74 | 77 | |
| 75 | 78 | LinearExample::LinearExample() |
| 76 | 79 | : Example( TITLE ), |
| 77 | - mLTRDirection(true) | |
| 80 | + mLTRDirection(true), | |
| 81 | + mImagesWeighted (false ) | |
| 78 | 82 | { |
| 79 | 83 | } |
| 80 | 84 | |
| ... | ... | @@ -86,30 +90,38 @@ void LinearExample::Create() |
| 86 | 90 | mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, RTL_IMAGE ); |
| 87 | 91 | mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); |
| 88 | 92 | mDirectionButton.ClickedSignal().Connect( this, &LinearExample::OnDirectionClicked ); |
| 89 | - mDirectionButton.SetParentOrigin( Vector3(0.33f, 1.0f, 0.5f ) ); | |
| 93 | + mDirectionButton.SetParentOrigin( Vector3( 0.2f, 1.0f, 0.5f ) ); | |
| 90 | 94 | mDirectionButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); |
| 91 | - mDirectionButton.SetSize(75, 75); | |
| 95 | + mDirectionButton.SetSize( 75, 75 ); | |
| 92 | 96 | stage.Add( mDirectionButton ); |
| 93 | 97 | |
| 94 | - mRotateButton = PushButton::New(); | |
| 95 | - mRotateButton.SetProperty( PushButton::Property::UNSELECTED_ICON, ROTATE_CLOCKWISE_IMAGE ); | |
| 96 | - mRotateButton.SetProperty( PushButton::Property::SELECTED_ICON, ROTATE_CLOCKWISE_SELECTED_IMAGE ); | |
| 97 | - mRotateButton.ClickedSignal().Connect( this, &LinearExample::OnRotateClicked ); | |
| 98 | - mRotateButton.SetParentOrigin( Vector3(0.66f, 1.0f, 0.5f )); | |
| 99 | - mRotateButton.SetAnchorPoint( Vector3(0.5f, 1.0f, 0.5f)); | |
| 100 | - mRotateButton.SetSize(75, 75); | |
| 101 | - stage.Add( mRotateButton ); | |
| 102 | - | |
| 103 | 98 | mAlignmentButton = PushButton::New(); |
| 104 | 99 | mAlignmentButton.SetProperty( PushButton::Property::UNSELECTED_ICON, ALIGN_IMAGE ); |
| 105 | 100 | mAlignmentButton.SetProperty( PushButton::Property::SELECTED_ICON, ALIGN_SELECTED_IMAGE ); |
| 106 | 101 | mAlignmentButton.ClickedSignal().Connect( this, &LinearExample::OnAlignmentClicked ); |
| 107 | - mAlignmentButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 102 | + mAlignmentButton.SetParentOrigin( Vector3( 0.4f, 1.0f, 0.5f ) ); | |
| 108 | 103 | mAlignmentButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); |
| 109 | - mAlignmentButton.SetSize(75, 75); | |
| 110 | - | |
| 104 | + mAlignmentButton.SetSize( 75, 75 ); | |
| 111 | 105 | stage.Add( mAlignmentButton ); |
| 112 | 106 | |
| 107 | + mWeightButton = Toolkit::PushButton::New(); | |
| 108 | + mWeightButton.SetProperty( PushButton::Property::UNSELECTED_ICON, WEIGHT_IMAGE ); | |
| 109 | + mWeightButton.SetProperty( PushButton::Property::SELECTED_ICON, WEIGHT_SELECTED_IMAGE ); | |
| 110 | + mWeightButton.ClickedSignal().Connect( this, &LinearExample::OnWeightClicked ); | |
| 111 | + mWeightButton.SetParentOrigin( Vector3( 0.6f, 1.0f, 0.5f ) ); | |
| 112 | + mWeightButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | |
| 113 | + mWeightButton.SetSize( 75, 75 ); | |
| 114 | + stage.Add( mWeightButton ); | |
| 115 | + | |
| 116 | + mRotateButton = PushButton::New(); | |
| 117 | + mRotateButton.SetProperty( PushButton::Property::UNSELECTED_ICON, ROTATE_CLOCKWISE_IMAGE ); | |
| 118 | + mRotateButton.SetProperty( PushButton::Property::SELECTED_ICON, ROTATE_CLOCKWISE_SELECTED_IMAGE ); | |
| 119 | + mRotateButton.ClickedSignal().Connect( this, &LinearExample::OnRotateClicked ); | |
| 120 | + mRotateButton.SetParentOrigin( Vector3( 0.8f, 1.0f, 0.5f ) ); | |
| 121 | + mRotateButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | |
| 122 | + mRotateButton.SetSize( 75, 75 ); | |
| 123 | + stage.Add( mRotateButton ); | |
| 124 | + | |
| 113 | 125 | // Create a linear layout |
| 114 | 126 | mLinearContainer = Control::New(); |
| 115 | 127 | auto layout = LinearLayout::New(); |
| ... | ... | @@ -129,8 +141,9 @@ void LinearExample::Create() |
| 129 | 141 | for( unsigned int x = 0; x < NUMBER_OF_RESOURCES; ++x ) |
| 130 | 142 | { |
| 131 | 143 | Toolkit::ImageView imageView; |
| 132 | - CreateChildImageView( imageView, IMAGE_PATH[ x ], Size(100.0f, 100.0f) ); | |
| 144 | + CreateChildImageView( imageView, IMAGE_PATH[ x ], Size( 100.0f, 100.0f ) ); | |
| 133 | 145 | mLinearContainer.Add( imageView ); |
| 146 | + mImages.push_back( imageView ); | |
| 134 | 147 | } |
| 135 | 148 | } |
| 136 | 149 | |
| ... | ... | @@ -140,8 +153,9 @@ void LinearExample::Remove() |
| 140 | 153 | if ( mLinearContainer ) |
| 141 | 154 | { |
| 142 | 155 | UnparentAndReset( mDirectionButton ); |
| 143 | - UnparentAndReset( mRotateButton ); | |
| 144 | 156 | UnparentAndReset( mAlignmentButton ); |
| 157 | + UnparentAndReset( mWeightButton ); | |
| 158 | + UnparentAndReset( mRotateButton ); | |
| 145 | 159 | UnparentAndReset( mLinearContainer); |
| 146 | 160 | } |
| 147 | 161 | } |
| ... | ... | @@ -213,4 +227,25 @@ bool LinearExample::OnAlignmentClicked( Button button ) |
| 213 | 227 | return true; |
| 214 | 228 | } |
| 215 | 229 | |
| 230 | +bool LinearExample::OnWeightClicked( Button button ) | |
| 231 | +{ | |
| 232 | + if( !mImagesWeighted ) | |
| 233 | + { | |
| 234 | + for( auto&& iter : mImages ) | |
| 235 | + { | |
| 236 | + iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + else | |
| 240 | + { | |
| 241 | + for( auto&& iter : mImages ) | |
| 242 | + { | |
| 243 | + iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.0f ); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + | |
| 247 | + mImagesWeighted = !mImagesWeighted; | |
| 248 | + return true; | |
| 249 | +} | |
| 250 | + | |
| 216 | 251 | } // namespace Demo | ... | ... |
examples/layouting/linear-example.h
| ... | ... | @@ -56,12 +56,18 @@ private: |
| 56 | 56 | // Cycles through alignment options |
| 57 | 57 | bool OnAlignmentClicked( Button button ); |
| 58 | 58 | |
| 59 | + // Justifies linear layout children using weight property | |
| 60 | + bool OnWeightClicked( Button button ); | |
| 61 | + | |
| 59 | 62 | private: |
| 60 | 63 | PushButton mDirectionButton; |
| 61 | - PushButton mRotateButton; | |
| 62 | 64 | PushButton mAlignmentButton; |
| 65 | + PushButton mWeightButton; | |
| 66 | + PushButton mRotateButton; | |
| 67 | + std::vector< Toolkit::ImageView > mImages; | |
| 63 | 68 | Control mLinearContainer; |
| 64 | 69 | bool mLTRDirection; |
| 70 | + bool mImagesWeighted; | |
| 65 | 71 | }; // class LinearContainer |
| 66 | 72 | |
| 67 | 73 | } // namespace Demo | ... | ... |
packaging/com.samsung.dali-demo.spec
resources/po/en_GB.po
| ... | ... | @@ -61,6 +61,9 @@ msgstr "Emoji Text" |
| 61 | 61 | msgid "DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND" |
| 62 | 62 | msgstr "Flexbox Playground" |
| 63 | 63 | |
| 64 | +msgid "DALI_DEMO_STR_TITLE_FRAME_CALLBACK" | |
| 65 | +msgstr "Frame Callback" | |
| 66 | + | |
| 64 | 67 | msgid "DALI_DEMO_STR_TITLE_HELLO_WORLD" |
| 65 | 68 | msgstr "Hello World" |
| 66 | 69 | ... | ... |
resources/po/en_US.po
| ... | ... | @@ -61,6 +61,9 @@ msgstr "Emoji Text" |
| 61 | 61 | msgid "DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND" |
| 62 | 62 | msgstr "Flexbox Playground" |
| 63 | 63 | |
| 64 | +msgid "DALI_DEMO_STR_TITLE_FRAME_CALLBACK" | |
| 65 | +msgstr "Frame Callback" | |
| 66 | + | |
| 64 | 67 | msgid "DALI_DEMO_STR_TITLE_HELLO_WORLD" |
| 65 | 68 | msgstr "Hello World" |
| 66 | 69 | ... | ... |
shared/dali-demo-strings.h
| ... | ... | @@ -55,6 +55,7 @@ extern "C" |
| 55 | 55 | #define DALI_DEMO_STR_TITLE_FPP_GAME dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FPP_GAME") |
| 56 | 56 | #define DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND") |
| 57 | 57 | #define DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION") |
| 58 | +#define DALI_DEMO_STR_TITLE_FRAME_CALLBACK dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_FRAME_CALLBACK") | |
| 58 | 59 | #define DALI_DEMO_STR_TITLE_HELLO_WORLD dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_HELLO_WORLD") |
| 59 | 60 | #define DALI_DEMO_STR_TITLE_HOMESCREEN dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_HOMESCREEN") |
| 60 | 61 | #define DALI_DEMO_STR_TITLE_IMAGE_POLICIES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_POLICIES") |
| ... | ... | @@ -138,6 +139,7 @@ extern "C" |
| 138 | 139 | #define DALI_DEMO_STR_TITLE_FPP_GAME "First Person Game" |
| 139 | 140 | #define DALI_DEMO_STR_TITLE_FLEXBOX_PLAYGROUND "Flexbox Playground" |
| 140 | 141 | #define DALI_DEMO_STR_TITLE_FOCUS_INTEGRATION "Focus Integration" |
| 142 | +#define DALI_DEMO_STR_TITLE_FRAME_CALLBACK "Frame Callback" | |
| 141 | 143 | #define DALI_DEMO_STR_TITLE_HELLO_WORLD "Hello World" |
| 142 | 144 | #define DALI_DEMO_STR_TITLE_HOMESCREEN "Homescreen Benchmark" |
| 143 | 145 | #define DALI_DEMO_STR_TITLE_IMAGE_POLICIES "Image Policies" | ... | ... |