Commit 34294f1b7f0bb8961d9c80bd029a79b3148ab7c4
[dali_1.3.28] Merge branch 'devel/master'
Change-Id: I7c8e44e485ed3bb8b3a5c38077e3144864a50dbe
Showing
6 changed files
with
514 additions
and
1 deletions
examples/simple-layout/custom-layout-impl.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 | +// CLASS HEADER | |
| 18 | +#include "custom-layout-impl.h" | |
| 19 | + | |
| 20 | +// EXTERNAL INCLUDES | |
| 21 | +#include <dali/public-api/actors/actor.h> | |
| 22 | + | |
| 23 | +namespace Demo | |
| 24 | +{ | |
| 25 | + | |
| 26 | +namespace Internal | |
| 27 | +{ | |
| 28 | + | |
| 29 | +using Dali::Actor; | |
| 30 | +using Dali::Toolkit::MeasuredSize; | |
| 31 | + | |
| 32 | +CustomLayoutPtr CustomLayout::New() | |
| 33 | +{ | |
| 34 | + CustomLayoutPtr layout( new CustomLayout() ); | |
| 35 | + return layout; | |
| 36 | +} | |
| 37 | + | |
| 38 | +void CustomLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) | |
| 39 | +{ | |
| 40 | + auto accumulatedWidth = 0; | |
| 41 | + auto maxHeight = 0; | |
| 42 | + | |
| 43 | + // In this layout we will: | |
| 44 | + // Measuring the layout with the children in a horizontal configuration, one after another | |
| 45 | + // Set the required width to be the accumulated width of our children | |
| 46 | + // Set the required height to be the maximum height of any of our children | |
| 47 | + | |
| 48 | + for( unsigned int i=0; i<GetChildCount(); ++i ) | |
| 49 | + { | |
| 50 | + auto childLayout = GetChildAt( i ); | |
| 51 | + if( childLayout ) | |
| 52 | + { | |
| 53 | + MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); | |
| 54 | + accumulatedWidth += childLayout->GetMeasuredWidth(); | |
| 55 | + std::max( childLayout->GetMeasuredHeight().mValue, maxHeight ); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + | |
| 59 | + // Finally, call this method to set the dimensions we would like | |
| 60 | + SetMeasuredDimensions( MeasuredSize( accumulatedWidth ), MeasuredSize( maxHeight ) ); | |
| 61 | +} | |
| 62 | + | |
| 63 | +void CustomLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) | |
| 64 | +{ | |
| 65 | + LayoutLength childTop( 0 ); | |
| 66 | + LayoutLength childLeft( 0 ); | |
| 67 | + | |
| 68 | + // We want to vertically align the children to the middle | |
| 69 | + auto height = bottom - top; | |
| 70 | + auto middle = height / 2; | |
| 71 | + | |
| 72 | + // Horizontally align the children to the middle of the space they are given too | |
| 73 | + auto width = right - left; | |
| 74 | + int count = GetChildCount(); | |
| 75 | + auto childIncrement = width / count; | |
| 76 | + auto center = childIncrement / 2; | |
| 77 | + | |
| 78 | + // Check layout direction | |
| 79 | + auto owner = GetOwner(); | |
| 80 | + auto actor = Actor::DownCast(owner); | |
| 81 | + const bool isLayoutRtl = actor ? actor.GetProperty< bool >( Actor::Property::LAYOUT_DIRECTION ) : false; | |
| 82 | + | |
| 83 | + for( int i = 0; i < count; i++) | |
| 84 | + { | |
| 85 | + auto itemIndex = isLayoutRtl ? count - 1 - i : i; // If RTL, then layout the last item first | |
| 86 | + | |
| 87 | + Dali::Toolkit::Internal::LayoutItemPtr childLayout = GetChildAt( itemIndex ); | |
| 88 | + if( childLayout != nullptr ) | |
| 89 | + { | |
| 90 | + auto childWidth = childLayout->GetMeasuredWidth(); | |
| 91 | + auto childHeight = childLayout->GetMeasuredHeight(); | |
| 92 | + | |
| 93 | + childTop = middle - (childHeight / 2); | |
| 94 | + | |
| 95 | + auto left = childLeft + center - childWidth / 2; | |
| 96 | + | |
| 97 | + childLayout->Layout( left, childTop, left + childWidth, childTop + childHeight ); | |
| 98 | + childLeft += childIncrement; | |
| 99 | + } | |
| 100 | + } | |
| 101 | +} | |
| 102 | + | |
| 103 | +} // namespace Internal | |
| 104 | + | |
| 105 | +} // namespace Demo | ... | ... |
examples/simple-layout/custom-layout-impl.h
0 → 100644
| 1 | +#ifndef DEMO_INTERNAL_CUSTOM_LAYOUT_H | |
| 2 | +#define DEMO_INTERNAL_CUSTOM_LAYOUT_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 | +// EXTERNAL INCLUDES | |
| 21 | +#include <dali/public-api/common/intrusive-ptr.h> | |
| 22 | +#include <dali-toolkit/devel-api/layouting/layout-group-impl.h> | |
| 23 | + | |
| 24 | +// INTERNAL INCLUDES | |
| 25 | +#include "custom-layout.h" | |
| 26 | + | |
| 27 | +namespace Demo | |
| 28 | +{ | |
| 29 | + | |
| 30 | +namespace Internal | |
| 31 | +{ | |
| 32 | + | |
| 33 | +using Dali::Toolkit::MeasureSpec; | |
| 34 | +using Dali::Toolkit::LayoutLength; | |
| 35 | + | |
| 36 | +class CustomLayout; | |
| 37 | +using CustomLayoutPtr = Dali::IntrusivePtr< CustomLayout >; | |
| 38 | + | |
| 39 | +/** | |
| 40 | + * @brief The implementation of our custom layout. | |
| 41 | + * | |
| 42 | + * Here we will override the methods that we require to mimic a very simple horizontal layout. | |
| 43 | + */ | |
| 44 | +class CustomLayout final : public Dali::Toolkit::Internal::LayoutGroup | |
| 45 | +{ | |
| 46 | +public: | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * @brief Create a new CustomLayout object. | |
| 50 | + * @return An intrusive pointer to the created CustomLayout object | |
| 51 | + */ | |
| 52 | + static CustomLayoutPtr New(); | |
| 53 | + | |
| 54 | + // Movable but not copyable | |
| 55 | + CustomLayout( const CustomLayout& other ) = delete; | |
| 56 | + CustomLayout& operator=( const CustomLayout& ) = delete; | |
| 57 | + CustomLayout( CustomLayout&& other ) = default; | |
| 58 | + CustomLayout& operator=( CustomLayout&& other ) = default; | |
| 59 | + | |
| 60 | +private: | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * @brief Default Constructor | |
| 64 | + */ | |
| 65 | + CustomLayout() = default; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Virtual Destructor | |
| 69 | + */ | |
| 70 | + virtual ~CustomLayout() = default; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * @copydoc LayoutItem::OnMeasure | |
| 74 | + * | |
| 75 | + * Overriding this method so that we can calculate the size we require using our children's sizes | |
| 76 | + */ | |
| 77 | + virtual void OnMeasure( MeasureSpec widthMeasureSpec, Dali::Toolkit::MeasureSpec heightMeasureSpec ) override; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * @copydoc LayoutItem::OnLayout | |
| 81 | + * | |
| 82 | + * Overriding this method so that we can layout our children as required. | |
| 83 | + */ | |
| 84 | + virtual void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) override; | |
| 85 | + | |
| 86 | +}; | |
| 87 | + | |
| 88 | +} // namespace Internal | |
| 89 | + | |
| 90 | +inline Internal::CustomLayout& GetImplementation( Demo::CustomLayout& handle ) | |
| 91 | +{ | |
| 92 | + DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" ); | |
| 93 | + Dali::BaseObject& object = handle.GetBaseObject(); | |
| 94 | + return static_cast<Internal::CustomLayout&>( object ); | |
| 95 | +} | |
| 96 | + | |
| 97 | +inline const Internal::CustomLayout& GetImplementation( const Demo::CustomLayout& handle ) | |
| 98 | +{ | |
| 99 | + DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" ); | |
| 100 | + const Dali::BaseObject& object = handle.GetBaseObject(); | |
| 101 | + return static_cast<const Internal::CustomLayout&>( object ); | |
| 102 | +} | |
| 103 | + | |
| 104 | +} // namespace Demo | |
| 105 | + | |
| 106 | +#endif // DEMO_INTERNAL_CUSTOM_LAYOUT_H | ... | ... |
examples/simple-layout/custom-layout.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 | +// CLASS HEADER | |
| 18 | +#include "custom-layout.h" | |
| 19 | + | |
| 20 | +// INTERNAL HEADERS | |
| 21 | +#include "custom-layout-impl.h" | |
| 22 | + | |
| 23 | +namespace Demo | |
| 24 | +{ | |
| 25 | + | |
| 26 | +CustomLayout CustomLayout::New() | |
| 27 | +{ | |
| 28 | + Internal::CustomLayoutPtr internal = Internal::CustomLayout::New(); | |
| 29 | + return CustomLayout( internal.Get() ); | |
| 30 | +} | |
| 31 | + | |
| 32 | +CustomLayout CustomLayout::DownCast( BaseHandle handle ) | |
| 33 | +{ | |
| 34 | + return CustomLayout( dynamic_cast< Demo::Internal::CustomLayout* >( handle.GetObjectPtr() ) ); | |
| 35 | +} | |
| 36 | + | |
| 37 | +CustomLayout::CustomLayout( Internal::CustomLayout* object ) | |
| 38 | +: Dali::Toolkit::LayoutGroup( object ) | |
| 39 | +{ | |
| 40 | +} | |
| 41 | + | |
| 42 | +} // namespace Demo | ... | ... |
examples/simple-layout/custom-layout.h
0 → 100644
| 1 | +#ifndef DEMO_CUSTOM_LAYOUT_H | |
| 2 | +#define DEMO_CUSTOM_LAYOUT_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 | +// EXTERNAL INCLUDES | |
| 21 | +#include <dali/public-api/object/base-handle.h> | |
| 22 | +#include <dali-toolkit/devel-api/layouting/layout-group.h> | |
| 23 | + | |
| 24 | +namespace Demo | |
| 25 | +{ | |
| 26 | + | |
| 27 | +namespace Internal | |
| 28 | +{ | |
| 29 | +class CustomLayout; | |
| 30 | +} | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * @brief This is the handle class to a very simple Custom Layout. | |
| 34 | + * | |
| 35 | + * This class lays out its children horizontally in a very simple manner. | |
| 36 | + */ | |
| 37 | +class CustomLayout : public Dali::Toolkit::LayoutGroup | |
| 38 | +{ | |
| 39 | +public: | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * @brief Creates an uninitialized CustomLayout handle. | |
| 43 | + * | |
| 44 | + * Initialize it using CustomLayout::New(). | |
| 45 | + * Calling member functions with an uninitialized handle is not allowed. | |
| 46 | + */ | |
| 47 | + CustomLayout() = default; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * @brief Creates a CustomLayout object. | |
| 51 | + */ | |
| 52 | + static CustomLayout New(); | |
| 53 | + | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * @brief Default destructor. | |
| 57 | + * | |
| 58 | + * This is non-virtual, since derived Handle types must not contain data or virtual methods | |
| 59 | + */ | |
| 60 | + ~CustomLayout() = default; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * @brief Copy constructor | |
| 64 | + */ | |
| 65 | + CustomLayout( const CustomLayout& ) = default; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @brief Assigment operator | |
| 69 | + */ | |
| 70 | + CustomLayout& operator=( const CustomLayout& ) = default; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * @brief Move constructor | |
| 74 | + */ | |
| 75 | + CustomLayout( CustomLayout&& ) = default; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * @brief Movable assignment operator | |
| 79 | + */ | |
| 80 | + CustomLayout& operator=( CustomLayout&& ) = default; | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * @brief Downcasts a handle to a CustomLayout handle. | |
| 84 | + * | |
| 85 | + * If handle points to a CustomLayout, the downcast produces a valid handle. | |
| 86 | + * If not, the returned handle is left uninitialized. | |
| 87 | + | |
| 88 | + * @param[in] handle to an object | |
| 89 | + * @return Handle to a CustomLayout or an uninitialized handle | |
| 90 | + */ | |
| 91 | + static CustomLayout DownCast( BaseHandle handle ); | |
| 92 | + | |
| 93 | +public: // Not intended for application developers | |
| 94 | + | |
| 95 | + /// @cond internal | |
| 96 | + /** | |
| 97 | + * @brief This constructor is used by CustomLayout::New() methods. | |
| 98 | + * | |
| 99 | + * @param[in] actor A pointer to a newly allocated Dali resource | |
| 100 | + */ | |
| 101 | + explicit CustomLayout( Internal::CustomLayout* body ); | |
| 102 | + /// @endcond | |
| 103 | +}; | |
| 104 | + | |
| 105 | +} // namespace Demo | |
| 106 | + | |
| 107 | +#endif // DEMO_CUSTOM_LAYOUT_H | ... | ... |
examples/simple-layout/simple-layout-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 | +#include <dali-toolkit/dali-toolkit.h> | |
| 19 | + | |
| 20 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | |
| 21 | +#include <dali-toolkit/devel-api/layouting/hbox-layout.h> | |
| 22 | +#include <dali-toolkit/devel-api/layouting/layout-item-impl.h> | |
| 23 | + | |
| 24 | +#include "custom-layout.h" | |
| 25 | + | |
| 26 | +using namespace Dali; | |
| 27 | +using namespace Dali::Toolkit; | |
| 28 | + | |
| 29 | +namespace | |
| 30 | +{ | |
| 31 | + | |
| 32 | +/// Child image filenames | |
| 33 | +const char* IMAGE_PATH[] = { | |
| 34 | + DEMO_IMAGE_DIR "application-icon-101.png", | |
| 35 | + DEMO_IMAGE_DIR "application-icon-102.png", | |
| 36 | + DEMO_IMAGE_DIR "application-icon-103.png", | |
| 37 | + DEMO_IMAGE_DIR "application-icon-104.png", | |
| 38 | +}; | |
| 39 | +const unsigned int NUMBER_OF_IMAGES = sizeof( IMAGE_PATH ) / sizeof( char* ); | |
| 40 | + | |
| 41 | +/** | |
| 42 | + * @brief Helper function to create ImageViews with given filename and size. | |
| 43 | + * @param[in] filename The filename of the image to use | |
| 44 | + * @param[in] size The size that the image should be loaded at | |
| 45 | + * @return The created ImageView | |
| 46 | + */ | |
| 47 | +ImageView CreateChildImageView( const char* filename, Size size ) | |
| 48 | +{ | |
| 49 | + ImageView imageView = ImageView::New(); | |
| 50 | + Property::Map imagePropertyMap; | |
| 51 | + imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; | |
| 52 | + imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename; | |
| 53 | + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width; | |
| 54 | + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height; | |
| 55 | + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap ); | |
| 56 | + imageView.SetName("ImageView"); | |
| 57 | + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 58 | + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); | |
| 59 | + return imageView; | |
| 60 | +} | |
| 61 | + | |
| 62 | +} // unnamed namespace | |
| 63 | + | |
| 64 | +/** | |
| 65 | + * @brief Demonstrates how to create a very simple layout and apply that to any Control. | |
| 66 | + */ | |
| 67 | +class SimpleLayoutExample : public ConnectionTracker | |
| 68 | +{ | |
| 69 | +public: | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * @brief Constructor. | |
| 73 | + * @param[in] application A reference to the Application class. | |
| 74 | + */ | |
| 75 | + SimpleLayoutExample( Application& application ) | |
| 76 | + : mApplication( application ) | |
| 77 | + { | |
| 78 | + // Connect to the Application's Init signal | |
| 79 | + mApplication.InitSignal().Connect( this, &SimpleLayoutExample::Create ); | |
| 80 | + } | |
| 81 | + | |
| 82 | +private: | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * @brief Called to initialise the application content | |
| 86 | + * @param[in] application A reference to the Application class. | |
| 87 | + */ | |
| 88 | + void Create( Application& application ) | |
| 89 | + { | |
| 90 | + // Get a handle to the stage, change the background color and connect to the Touch & Key signals | |
| 91 | + Stage stage = Stage::GetCurrent(); | |
| 92 | + stage.SetBackgroundColor( Color::WHITE ); | |
| 93 | + stage.GetRootLayer().TouchSignal().Connect( this, &SimpleLayoutExample::OnTouch ); | |
| 94 | + stage.KeyEventSignal().Connect( this, &SimpleLayoutExample::OnKeyEvent ); | |
| 95 | + stage.KeepRendering(0.5f); // TODO: Should remove after bugfix, but currently required to ensure renders are done after resources are loaded | |
| 96 | + | |
| 97 | + | |
| 98 | + // Create a new control | |
| 99 | + Control control = Control::New(); | |
| 100 | + control.SetParentOrigin( ParentOrigin::CENTER ); | |
| 101 | + control.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 102 | + stage.Add( control); | |
| 103 | + | |
| 104 | + // Set our Custom Layout on the control | |
| 105 | + auto layout = Demo::CustomLayout::New(); | |
| 106 | + DevelControl::SetLayout( control, layout ); | |
| 107 | + | |
| 108 | + // Add child image-views to the created control | |
| 109 | + for( auto i = 0u; i < NUMBER_OF_IMAGES; ++i ) | |
| 110 | + { | |
| 111 | + control.Add( CreateChildImageView( IMAGE_PATH[ i ], Size( 100.0f, 100.0f ) ) ); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * @brief Called when the stage is touched. | |
| 117 | + * | |
| 118 | + * We will use this to quit the application. | |
| 119 | + */ | |
| 120 | + bool OnTouch( Actor /* actor */, const TouchData& /* touch */ ) | |
| 121 | + { | |
| 122 | + mApplication.Quit(); | |
| 123 | + return true; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * @brief Called when any key event is received. | |
| 128 | + * | |
| 129 | + * Will use this to quit the application if Back or the Escape key is received | |
| 130 | + * @param[in] event The key event information | |
| 131 | + */ | |
| 132 | + void OnKeyEvent( const KeyEvent& event ) | |
| 133 | + { | |
| 134 | + if( event.state == KeyEvent::Down ) | |
| 135 | + { | |
| 136 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 137 | + { | |
| 138 | + mApplication.Quit(); | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | +private: | |
| 144 | + Application& mApplication; ///< A reference to the application object. | |
| 145 | +}; | |
| 146 | + | |
| 147 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 148 | +{ | |
| 149 | + Application application = Application::New( &argc, &argv ); | |
| 150 | + SimpleLayoutExample test( application ); | |
| 151 | + application.MainLoop(); | |
| 152 | + return 0; | |
| 153 | +} | ... | ... |