Commit 88f4247651c1010fd455be1df0149a1d6958dcbf
[dali_1.3.29] Merge branch 'devel/master'
Change-Id: I314f6254a032a9bdf0907fe2173ee6231f6987fa
Showing
22 changed files
with
1188 additions
and
6 deletions
com.samsung.dali-demo.xml
| @@ -248,8 +248,13 @@ | @@ -248,8 +248,13 @@ | ||
| 248 | <label>Card Active App</label> | 248 | <label>Card Active App</label> |
| 249 | </ui-application> | 249 | </ui-application> |
| 250 | <ui-application appid="image-policies.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-policies.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app"> | 250 | <ui-application appid="image-policies.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-policies.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app"> |
| 251 | - <label>Image Policies</label></ui-application> | ||
| 252 | - <privileges> | 251 | + <label>Image Policies</label> |
| 252 | + </ui-application> | ||
| 253 | + <ui-application appid="layouting.example" exec="/usr/apps/com.samsung.dali-demo/bin/layouting.example" nodisplay="true" multiple="false" taskmanage="true" type="c++app"> | ||
| 254 | + <label>Layouting</label> | ||
| 255 | + </ui-application> | ||
| 256 | + | ||
| 257 | + <privileges> | ||
| 253 | <privilege>http://tizen.org/privilege/mediastorage</privilege> | 258 | <privilege>http://tizen.org/privilege/mediastorage</privilege> |
| 254 | <privilege>http://tizen.org/privilege/externalstorage</privilege> | 259 | <privilege>http://tizen.org/privilege/externalstorage</privilege> |
| 255 | <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege> | 260 | <privilege>http://tizen.org/privilege/externalstorage.appdata</privilege> |
examples-reel/dali-examples-reel.cpp
| 1 | /* | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| @@ -56,6 +56,7 @@ int DALI_EXPORT_API main(int argc, char **argv) | @@ -56,6 +56,7 @@ int DALI_EXPORT_API main(int argc, char **argv) | ||
| 56 | demo.AddExample(Example("image-view-pixel-area.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA)); | 56 | demo.AddExample(Example("image-view-pixel-area.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_PIXEL_AREA)); |
| 57 | demo.AddExample(Example("image-view-svg.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_SVG)); | 57 | demo.AddExample(Example("image-view-svg.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_SVG)); |
| 58 | demo.AddExample(Example("image-view-url.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL)); | 58 | demo.AddExample(Example("image-view-url.example", DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL)); |
| 59 | + demo.AddExample(Example("layouting.example", DALI_DEMO_STR_TITLE_LAYOUTING)); | ||
| 59 | demo.AddExample(Example("line-mesh.example", DALI_DEMO_STR_TITLE_LINE_MESH)); | 60 | demo.AddExample(Example("line-mesh.example", DALI_DEMO_STR_TITLE_LINE_MESH)); |
| 60 | demo.AddExample(Example("magnifier.example", DALI_DEMO_STR_TITLE_MAGNIFIER)); | 61 | demo.AddExample(Example("magnifier.example", DALI_DEMO_STR_TITLE_MAGNIFIER)); |
| 61 | demo.AddExample(Example("mesh-morph.example", DALI_DEMO_STR_TITLE_MESH_MORPH)); | 62 | demo.AddExample(Example("mesh-morph.example", DALI_DEMO_STR_TITLE_MESH_MORPH)); |
examples/layouting/absolute-example.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2017 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 <string> | ||
| 19 | +#include "absolute-example.h" | ||
| 20 | +#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> | ||
| 21 | +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | ||
| 22 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | ||
| 23 | +#include <dali-toolkit/devel-api/layouting/absolute-layout.h> | ||
| 24 | + | ||
| 25 | +using namespace Dali; | ||
| 26 | +using namespace Dali::Toolkit; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +namespace | ||
| 30 | +{ | ||
| 31 | + | ||
| 32 | +struct ImageDetails | ||
| 33 | +{ | ||
| 34 | + const char * name; | ||
| 35 | + Vector2 position; | ||
| 36 | + Size size; | ||
| 37 | +}; | ||
| 38 | + | ||
| 39 | +ImageDetails IMAGES[] = | ||
| 40 | +{ | ||
| 41 | + { DEMO_IMAGE_DIR "gallery-small-23.jpg", Vector2( 0.0f, 0.0f ), Size( 100.0f, 100.0f ) }, | ||
| 42 | + { DEMO_IMAGE_DIR "gallery-small-23.jpg", Vector2( 100.0f, 0.0f ), Size( 100.0f, 100.0f ) }, | ||
| 43 | + { DEMO_IMAGE_DIR "gallery-small-23.jpg", Vector2( 0.0f, 100.0f ), Size( 100.0f, 100.0f ) }, | ||
| 44 | + { DEMO_IMAGE_DIR "gallery-small-23.jpg", Vector2( 200.0f, 200.0f ), Size( 100.0f, 100.0f ) }, | ||
| 45 | +}; | ||
| 46 | +unsigned int IMAGE_COUNT=sizeof(IMAGES)/sizeof(IMAGES[0]); | ||
| 47 | + | ||
| 48 | +// Helper function to create ImageViews with given filename and size. | ||
| 49 | +void CreateChildImageView( ImageView& imageView, unsigned imageIndex ) | ||
| 50 | +{ | ||
| 51 | + imageView = ImageView::New(); | ||
| 52 | + Property::Map imagePropertyMap; | ||
| 53 | + imagePropertyMap[ Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; | ||
| 54 | + imagePropertyMap[ ImageVisual::Property::URL ] = IMAGES[imageIndex].name; | ||
| 55 | + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = IMAGES[imageIndex].size.width ; | ||
| 56 | + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = IMAGES[imageIndex].size.height; | ||
| 57 | + imageView.SetProperty( ImageView::Property::IMAGE , imagePropertyMap ); | ||
| 58 | + imageView.SetName("ImageView"); | ||
| 59 | + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 60 | + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); | ||
| 61 | + imageView.SetProperty( Dali::Actor::Property::POSITION, Vector3( IMAGES[imageIndex].position ) ); | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +} // namespace | ||
| 65 | + | ||
| 66 | +namespace Demo | ||
| 67 | +{ | ||
| 68 | + | ||
| 69 | +AbsoluteExample::AbsoluteExample() | ||
| 70 | +: mRootLayoutControl(), | ||
| 71 | + mAbsoluteLayoutContainer(), | ||
| 72 | + mLayoutSizeToggleStatus( true ), | ||
| 73 | + mToggleButton() | ||
| 74 | +{ | ||
| 75 | + | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +void AbsoluteExample::Create() | ||
| 79 | +{ | ||
| 80 | + // Create a root layout, ideally Dali would have a default layout in the root layer. | ||
| 81 | + // Without this root layer the mAbsoluteLayout (or any other layout) will not | ||
| 82 | + // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings. | ||
| 83 | + // It uses the default stage size and ideally should have a layout added to it. | ||
| 84 | + auto stage = Stage::GetCurrent(); | ||
| 85 | + mRootLayoutControl = Control::New(); | ||
| 86 | + auto rootLayout = AbsoluteLayout::New(); | ||
| 87 | + DevelControl::SetLayout( mRootLayoutControl, rootLayout ); | ||
| 88 | + mRootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 89 | + mRootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 90 | + stage.Add( mRootLayoutControl ); | ||
| 91 | + | ||
| 92 | + // Create an Absolute Layout to show ImageViews at explictly provided positions. | ||
| 93 | + mAbsoluteLayoutContainer = Control::New(); | ||
| 94 | + mAbsoluteLayoutContainer.SetBackgroundColor( Color::WHITE ); | ||
| 95 | + auto absoluteLayout = AbsoluteLayout::New(); | ||
| 96 | + DevelControl::SetLayout( mAbsoluteLayoutContainer, absoluteLayout ); | ||
| 97 | + mAbsoluteLayoutContainer.SetName("AbsoluteLayout"); | ||
| 98 | + | ||
| 99 | + mAbsoluteLayoutContainer.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 100 | + mAbsoluteLayoutContainer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 101 | + | ||
| 102 | + // Initially absolute layout to use these specifications, toggle button will alter them. | ||
| 103 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); | ||
| 104 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); | ||
| 105 | + | ||
| 106 | + mRootLayoutControl.Add( mAbsoluteLayoutContainer ); | ||
| 107 | + | ||
| 108 | + for( unsigned int x = 0; x < NUMBER_OF_IMAGE_VIEWS; x++ ) | ||
| 109 | + { | ||
| 110 | + CreateChildImageView( mImageViews[x], x%IMAGE_COUNT ); | ||
| 111 | + mAbsoluteLayoutContainer.Add( mImageViews[x] ); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + // Button toggles the size of the layout | ||
| 115 | + mToggleButton = PushButton::New(); | ||
| 116 | + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Change layout size" ); | ||
| 117 | + mToggleButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | ||
| 118 | + mToggleButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 119 | + mToggleButton.ClickedSignal().Connect( this, &Demo::AbsoluteExample::ChangeSizeClicked ); | ||
| 120 | + mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | ||
| 121 | + mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | ||
| 122 | + | ||
| 123 | + stage.Add( mToggleButton ); | ||
| 124 | + | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +void AbsoluteExample::Remove() | ||
| 128 | +{ | ||
| 129 | + UnparentAndReset( mAbsoluteLayoutContainer ); | ||
| 130 | + UnparentAndReset( mToggleButton ); | ||
| 131 | + UnparentAndReset( mRootLayoutControl ); | ||
| 132 | +} | ||
| 133 | + | ||
| 134 | +bool AbsoluteExample::ChangeSizeClicked( Toolkit::Button button ) | ||
| 135 | +{ | ||
| 136 | + if ( true == mLayoutSizeToggleStatus ) | ||
| 137 | + { | ||
| 138 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 480 ); | ||
| 139 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 700 ); | ||
| 140 | + mLayoutSizeToggleStatus = false; | ||
| 141 | + } | ||
| 142 | + else | ||
| 143 | + { | ||
| 144 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); | ||
| 145 | + mAbsoluteLayoutContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); | ||
| 146 | + mLayoutSizeToggleStatus = true; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + return true; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +} // namespace Demo | ||
| 0 | \ No newline at end of file | 153 | \ No newline at end of file |
examples/layouting/absolute-example.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_ABSOLUTE_EXAMPLE_H | ||
| 2 | +#define DALI_DEMO_ABSOLUTE_EXAMPLE_H | ||
| 3 | + | ||
| 4 | +/* | ||
| 5 | + * Copyright (c) 2017 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 | +#include <string> | ||
| 22 | +#include <dali/dali.h> | ||
| 23 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 24 | +#include "example.h" | ||
| 25 | + | ||
| 26 | +using namespace Dali; | ||
| 27 | +using namespace Dali::Toolkit; | ||
| 28 | + | ||
| 29 | +namespace Demo | ||
| 30 | +{ | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * @file absolute-example.hcpp | ||
| 34 | + * @brief Example of a Linear Layout with padding applied, enables updating of padding values for | ||
| 35 | + * one of the children. | ||
| 36 | + */ | ||
| 37 | +class AbsoluteExample: public ConnectionTracker, public Example | ||
| 38 | +{ | ||
| 39 | +public: | ||
| 40 | + static const unsigned int NUMBER_OF_IMAGE_VIEWS = 4; | ||
| 41 | + | ||
| 42 | + AbsoluteExample(); | ||
| 43 | + | ||
| 44 | + // Creates a Absolute Layout Example and displays it. | ||
| 45 | + virtual void Create() override; | ||
| 46 | + | ||
| 47 | + // Remove and destroy this layout | ||
| 48 | + virtual void Remove() override; | ||
| 49 | + | ||
| 50 | +private: | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + // Callback when change size button is pressed | ||
| 54 | + bool ChangeSizeClicked( Toolkit::Button button ); | ||
| 55 | + | ||
| 56 | +private: | ||
| 57 | + | ||
| 58 | + Toolkit::Control mRootLayoutControl; | ||
| 59 | + Toolkit::Control mAbsoluteLayoutContainer; | ||
| 60 | + Toolkit::ImageView mImageViews[ NUMBER_OF_IMAGE_VIEWS ]; | ||
| 61 | + bool mLayoutSizeToggleStatus; | ||
| 62 | + Toolkit::PushButton mToggleButton; | ||
| 63 | +}; | ||
| 64 | + | ||
| 65 | +} // namespace Demo | ||
| 66 | + | ||
| 67 | +#endif // DALI_DEMO_ABSOLUTE_EXAMPLE_H |
examples/layouting/example.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_LAYOUTING_EXAMPLE_H | ||
| 2 | +#define DALI_DEMO_LAYOUTING_EXAMPLE_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 | +namespace Demo | ||
| 22 | +{ | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * @brief Abstract base class for layouting examples. | ||
| 26 | + */ | ||
| 27 | +class Example | ||
| 28 | +{ | ||
| 29 | +public: | ||
| 30 | + /// Should be overridden by deriving classes to create the required Layouting example | ||
| 31 | + virtual void Create() = 0; | ||
| 32 | + | ||
| 33 | + /// Should be overridden by deriving classes to remove their layouting example from stage | ||
| 34 | + virtual void Remove() = 0; | ||
| 35 | + | ||
| 36 | + /// Virtual destructor | ||
| 37 | + virtual ~Example() = default; | ||
| 38 | +}; | ||
| 39 | + | ||
| 40 | +} // namespace Demo | ||
| 41 | + | ||
| 42 | +#endif // DALI_DEMO_LAYOUTING_EXAMPLE_H |
examples/layouting/flex-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 "flex-example.h" | ||
| 19 | +#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> | ||
| 20 | +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | ||
| 21 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | ||
| 22 | +#include <dali-toolkit/devel-api/layouting/flex-layout.h> | ||
| 23 | + | ||
| 24 | +using namespace Dali; | ||
| 25 | +using namespace Dali::Toolkit; | ||
| 26 | + | ||
| 27 | +namespace | ||
| 28 | +{ | ||
| 29 | + | ||
| 30 | +// Button file names | ||
| 31 | +const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" ); | ||
| 32 | +const char* LTR_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-play-selected.png" ); | ||
| 33 | + | ||
| 34 | +const char* RTL_IMAGE( DEMO_IMAGE_DIR "icon-reverse.png" ); | ||
| 35 | +const char* RTL_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-reverse-selected.png" ); | ||
| 36 | + | ||
| 37 | +const char* ROTATE_CLOCKWISE_IMAGE( DEMO_IMAGE_DIR "icon-reset.png" ); | ||
| 38 | +const char* ROTATE_CLOCKWISE_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-reset-selected.png" ); | ||
| 39 | + | ||
| 40 | +const char* WRAP_IMAGE( DEMO_IMAGE_DIR "icon-replace.png" ); | ||
| 41 | +const char* WRAP_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-replace-selected.png" ); | ||
| 42 | + | ||
| 43 | +const char* JUSTIFY_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-grid.png" ); | ||
| 44 | +const char* JUSTIFY_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-item-view-layout-grid-selected.png" ); | ||
| 45 | + | ||
| 46 | +// Child image filenames | ||
| 47 | +const char* IMAGE_PATH[] = { | ||
| 48 | + DEMO_IMAGE_DIR "application-icon-101.png", | ||
| 49 | + DEMO_IMAGE_DIR "application-icon-102.png", | ||
| 50 | + DEMO_IMAGE_DIR "application-icon-103.png", | ||
| 51 | + DEMO_IMAGE_DIR "application-icon-104.png", | ||
| 52 | + DEMO_IMAGE_DIR "application-icon-105.png", | ||
| 53 | + DEMO_IMAGE_DIR "application-icon-106.png", | ||
| 54 | + DEMO_IMAGE_DIR "application-icon-107.png", | ||
| 55 | + DEMO_IMAGE_DIR "application-icon-108.png", | ||
| 56 | + DEMO_IMAGE_DIR "application-icon-109.png", | ||
| 57 | + DEMO_IMAGE_DIR "application-icon-110.png" | ||
| 58 | + | ||
| 59 | +}; | ||
| 60 | + | ||
| 61 | +const unsigned int NUMBER_OF_RESOURCES = sizeof(IMAGE_PATH) / sizeof(char*); | ||
| 62 | + | ||
| 63 | +// Helper function to create ImageViews with given filename and size. | ||
| 64 | +void CreateChildImageView( ImageView& imageView, const char* filename, Size size ) | ||
| 65 | +{ | ||
| 66 | + imageView = ImageView::New(); | ||
| 67 | + Property::Map imagePropertyMap; | ||
| 68 | + imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; | ||
| 69 | + imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename; | ||
| 70 | + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width; | ||
| 71 | + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height; | ||
| 72 | + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap ); | ||
| 73 | + imageView.SetName("ImageView"); | ||
| 74 | + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 75 | + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +} // namespace | ||
| 79 | + | ||
| 80 | +namespace Demo | ||
| 81 | +{ | ||
| 82 | + | ||
| 83 | +FlexExample::FlexExample() | ||
| 84 | +: mLTRDirection(true) | ||
| 85 | +{ | ||
| 86 | + | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +void FlexExample::Create() | ||
| 90 | +{ | ||
| 91 | + // The Init signal is received once (only) during the Application lifetime | ||
| 92 | + auto stage = Stage::GetCurrent(); | ||
| 93 | + | ||
| 94 | + mDirectionButton = PushButton::New(); | ||
| 95 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, RTL_IMAGE ); | ||
| 96 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); | ||
| 97 | + mDirectionButton.ClickedSignal().Connect( this, &FlexExample::OnDirectionClicked ); | ||
| 98 | + mDirectionButton.SetParentOrigin( Vector3(0.2f, 1.0f, 0.5f ) ); | ||
| 99 | + mDirectionButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 100 | + mDirectionButton.SetSize(75, 75); | ||
| 101 | + stage.Add( mDirectionButton ); | ||
| 102 | + | ||
| 103 | + mWrapButton = Toolkit::PushButton::New(); | ||
| 104 | + mWrapButton.SetProperty( PushButton::Property::UNSELECTED_ICON, WRAP_IMAGE ); | ||
| 105 | + mWrapButton.SetProperty( PushButton::Property::SELECTED_ICON, WRAP_SELECTED_IMAGE ); | ||
| 106 | + mWrapButton.ClickedSignal().Connect( this, &FlexExample::OnWrapClicked ); | ||
| 107 | + mWrapButton.SetParentOrigin( Vector3(0.4f, 1.0f, 0.5f )); | ||
| 108 | + mWrapButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 109 | + mWrapButton.SetSize(75, 75); | ||
| 110 | + stage.Add( mWrapButton ); | ||
| 111 | + | ||
| 112 | + mJustifyButton = Toolkit::PushButton::New(); | ||
| 113 | + mJustifyButton.SetProperty( PushButton::Property::UNSELECTED_ICON, JUSTIFY_IMAGE ); | ||
| 114 | + mJustifyButton.SetProperty( PushButton::Property::SELECTED_ICON, JUSTIFY_SELECTED_IMAGE ); | ||
| 115 | + mJustifyButton.ClickedSignal().Connect( this, &FlexExample::OnJustifyClicked ); | ||
| 116 | + mJustifyButton.SetParentOrigin( Vector3(0.6f, 1.0f, 0.5f )); | ||
| 117 | + mJustifyButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 118 | + mJustifyButton.SetSize(75, 75); | ||
| 119 | + stage.Add( mJustifyButton ); | ||
| 120 | + | ||
| 121 | + mRotateButton = PushButton::New(); | ||
| 122 | + mRotateButton.SetProperty( PushButton::Property::UNSELECTED_ICON, ROTATE_CLOCKWISE_IMAGE ); | ||
| 123 | + mRotateButton.SetProperty( PushButton::Property::SELECTED_ICON, ROTATE_CLOCKWISE_SELECTED_IMAGE ); | ||
| 124 | + mRotateButton.ClickedSignal().Connect( this, &FlexExample::OnRotateClicked ); | ||
| 125 | + mRotateButton.SetParentOrigin( Vector3(0.8f, 1.0f, 0.5f )); | ||
| 126 | + mRotateButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 127 | + mRotateButton.SetSize(75, 75); | ||
| 128 | + stage.Add( mRotateButton ); | ||
| 129 | + | ||
| 130 | + // Create a flex container | ||
| 131 | + mFlexContainer = Control::New(); | ||
| 132 | + | ||
| 133 | + auto layout = FlexLayout::New(); | ||
| 134 | + layout.SetAnimateLayout( true ); | ||
| 135 | + layout.SetFlexDirection( Toolkit::FlexLayout::FlexDirection::ROW ); | ||
| 136 | + layout.SetFlexWrap( Toolkit::FlexLayout::WrapType::NO_WRAP ); | ||
| 137 | + layout.SetFlexJustification( Toolkit::FlexLayout::Justification::FLEX_START ); | ||
| 138 | + layout.SetFlexAlignment( Toolkit::FlexLayout::Alignment::FLEX_START ); | ||
| 139 | + | ||
| 140 | + DevelControl::SetLayout( mFlexContainer, layout ); | ||
| 141 | + | ||
| 142 | + mFlexContainer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 143 | + mFlexContainer.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 144 | + mFlexContainer.SetName( "FlexExample" ); | ||
| 145 | + mFlexContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); | ||
| 146 | + mFlexContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); | ||
| 147 | + mFlexContainer.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 148 | + mFlexContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT ); | ||
| 149 | + | ||
| 150 | + for( unsigned int x = 0; x < NUMBER_OF_RESOURCES; ++x ) | ||
| 151 | + { | ||
| 152 | + Toolkit::ImageView imageView; | ||
| 153 | + CreateChildImageView( imageView, IMAGE_PATH[ x ], Size(100.0f, 100.0f) ); | ||
| 154 | + imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents(0.f, 0.f, 0.f, 0.f) ); | ||
| 155 | + imageView.SetProperty( Toolkit::Control::Property::MARGIN, Extents(2.0f, 2.0f, 2.0f, 2.0f) ); | ||
| 156 | + imageView.SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::CENTER ); | ||
| 157 | + imageView.SetProperty( Toolkit::FlexLayout::ChildProperty::FLEX, 0.f ); | ||
| 158 | + mFlexContainer.Add( imageView ); | ||
| 159 | + } | ||
| 160 | + stage.Add( mFlexContainer ); | ||
| 161 | +} | ||
| 162 | + | ||
| 163 | +// Remove controls added by this example from stage | ||
| 164 | +void FlexExample::Remove() | ||
| 165 | +{ | ||
| 166 | + if ( mFlexContainer ) | ||
| 167 | + { | ||
| 168 | + UnparentAndReset( mDirectionButton ); | ||
| 169 | + UnparentAndReset( mWrapButton ); | ||
| 170 | + UnparentAndReset( mJustifyButton ); | ||
| 171 | + UnparentAndReset( mRotateButton ); | ||
| 172 | + UnparentAndReset( mFlexContainer); | ||
| 173 | + } | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +// Mirror items in layout | ||
| 177 | +bool FlexExample::OnDirectionClicked( Button button ) | ||
| 178 | +{ | ||
| 179 | + mLTRDirection = !mLTRDirection; | ||
| 180 | + if( mLTRDirection ) | ||
| 181 | + { | ||
| 182 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, LTR_IMAGE ); | ||
| 183 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, LTR_SELECTED_IMAGE ); | ||
| 184 | + mFlexContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT ); | ||
| 185 | + } | ||
| 186 | + else | ||
| 187 | + { | ||
| 188 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, RTL_IMAGE ); | ||
| 189 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); | ||
| 190 | + mFlexContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT ); | ||
| 191 | + } | ||
| 192 | + return true; | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +// Rotate layout by changing layout | ||
| 196 | +bool FlexExample::OnRotateClicked( Button button ) | ||
| 197 | +{ | ||
| 198 | + auto layout = FlexLayout::DownCast(DevelControl::GetLayout( mFlexContainer )); | ||
| 199 | + if( layout.GetFlexDirection() == Toolkit::FlexLayout::FlexDirection::COLUMN ) | ||
| 200 | + { | ||
| 201 | + layout.SetFlexDirection( Toolkit::FlexLayout::FlexDirection::ROW ); | ||
| 202 | + } | ||
| 203 | + else | ||
| 204 | + { | ||
| 205 | + layout.SetFlexDirection( Toolkit::FlexLayout::FlexDirection::COLUMN ); | ||
| 206 | + } | ||
| 207 | + return true; | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +// Alternates the layout wrapping from wrapping to none | ||
| 211 | +bool FlexExample::OnWrapClicked( Button button ) | ||
| 212 | +{ | ||
| 213 | + auto layout = FlexLayout::DownCast(DevelControl::GetLayout( mFlexContainer )); | ||
| 214 | + if ( layout.GetFlexWrap() == Toolkit::FlexLayout::WrapType::NO_WRAP ) | ||
| 215 | + { | ||
| 216 | + layout.SetFlexWrap( Toolkit::FlexLayout::WrapType::WRAP ); | ||
| 217 | + layout.SetFlexAlignment( Toolkit::FlexLayout::Alignment::CENTER ); | ||
| 218 | + mFlexContainer.SetProperty( Toolkit::Control::Property::PADDING, Extents(0.0f, 0.0f, 45.0f, 75.0f) ); | ||
| 219 | + } | ||
| 220 | + else | ||
| 221 | + { | ||
| 222 | + layout.SetFlexWrap( Toolkit::FlexLayout::WrapType::NO_WRAP ); | ||
| 223 | + layout.SetFlexAlignment( Toolkit::FlexLayout::Alignment::FLEX_START ); | ||
| 224 | + mFlexContainer.SetProperty( Toolkit::Control::Property::PADDING, Extents(0.0f, 0.0f, 0.0f, 0.0f) ); | ||
| 225 | + } | ||
| 226 | + return true; | ||
| 227 | +} | ||
| 228 | + | ||
| 229 | +// Alternates the layout to justify space between items or not | ||
| 230 | +bool FlexExample::OnJustifyClicked( Button button ) | ||
| 231 | +{ | ||
| 232 | + auto layout = FlexLayout::DownCast(DevelControl::GetLayout( mFlexContainer )); | ||
| 233 | + if ( layout.GetFlexJustification() == Toolkit::FlexLayout::Justification::FLEX_START ) | ||
| 234 | + { | ||
| 235 | + layout.SetFlexJustification( Toolkit::FlexLayout::Justification::SPACE_BETWEEN); | ||
| 236 | + } | ||
| 237 | + else | ||
| 238 | + { | ||
| 239 | + layout.SetFlexJustification( Toolkit::FlexLayout::Justification::FLEX_START ); | ||
| 240 | + } | ||
| 241 | + return true; | ||
| 242 | +} | ||
| 243 | + | ||
| 244 | +} // namespace Demo |
examples/layouting/flex-example.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_FLEX_EXAMPLE_H | ||
| 2 | +#define DALI_DEMO_FLEX_EXAMPLE_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 | +#include <dali/dali.h> | ||
| 22 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 23 | + | ||
| 24 | +#include "example.h" | ||
| 25 | + | ||
| 26 | +using namespace Dali; | ||
| 27 | +using namespace Dali::Toolkit; | ||
| 28 | + | ||
| 29 | +namespace Demo | ||
| 30 | +{ | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * @file flex-example.hcpp | ||
| 34 | + * @brief Example of a Flex Layout with mirror feature and | ||
| 35 | + * transition from horizontal to vertical. | ||
| 36 | + */ | ||
| 37 | +class FlexExample final: public ConnectionTracker, public Example | ||
| 38 | +{ | ||
| 39 | +public: | ||
| 40 | + FlexExample(); | ||
| 41 | + | ||
| 42 | + // Creates a Flex Layout Example and displays it. | ||
| 43 | + virtual void Create() override; | ||
| 44 | + | ||
| 45 | + // Remove and destroy this layout | ||
| 46 | + virtual void Remove() override; | ||
| 47 | + | ||
| 48 | +private: | ||
| 49 | + | ||
| 50 | + // Changes the direction of the items. | ||
| 51 | + bool OnDirectionClicked( Button button ); | ||
| 52 | + | ||
| 53 | + // Alternates the layout from horizontal to vertical | ||
| 54 | + bool OnRotateClicked( Button button ); | ||
| 55 | + | ||
| 56 | + // Alternates the layout wrapping from wrapping to none | ||
| 57 | + bool OnWrapClicked( Button button ); | ||
| 58 | + | ||
| 59 | + // Alternates the layout to justify space between items or not | ||
| 60 | + bool OnJustifyClicked( Button button ); | ||
| 61 | + | ||
| 62 | +private: | ||
| 63 | + PushButton mDirectionButton; | ||
| 64 | + PushButton mRotateButton; | ||
| 65 | + PushButton mWrapButton; | ||
| 66 | + PushButton mJustifyButton; | ||
| 67 | + Control mFlexContainer; | ||
| 68 | + bool mLTRDirection; | ||
| 69 | +}; // class FlexExample | ||
| 70 | + | ||
| 71 | +} // namespace Demo | ||
| 72 | + | ||
| 73 | +#endif //DALI_DEMO_FLEX_EXAMPLE_H |
examples/layouting/layouting-examples.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 <memory> | ||
| 20 | +#include <string> | ||
| 21 | +#include <dali/dali.h> | ||
| 22 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 23 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | ||
| 24 | + | ||
| 25 | +// INTERNAL INCLUDES | ||
| 26 | +#include "shared/view.h" | ||
| 27 | +#include "linear-example.h" | ||
| 28 | +#include "padding-example.h" | ||
| 29 | +#include "flex-example.h" | ||
| 30 | +#include "example.h" | ||
| 31 | +#include "absolute-example.h" | ||
| 32 | + | ||
| 33 | +using namespace Dali; | ||
| 34 | +using namespace Dali::Toolkit; | ||
| 35 | + | ||
| 36 | +namespace | ||
| 37 | +{ | ||
| 38 | + | ||
| 39 | +const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" ); | ||
| 40 | +const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); | ||
| 41 | + | ||
| 42 | +const char* APPLICATION_TITLE( "Layout Tester" ); | ||
| 43 | + | ||
| 44 | +typedef std::unique_ptr< Demo::Example > ExamplePointer; | ||
| 45 | +typedef std::vector< ExamplePointer > ExampleContainer; | ||
| 46 | + | ||
| 47 | +/// All layouting examples to be shown should be added to this method | ||
| 48 | +void CreateExamples( ExampleContainer& container ) | ||
| 49 | +{ | ||
| 50 | + container.push_back( ExamplePointer( new Demo::LinearExample ) ); | ||
| 51 | + container.push_back( ExamplePointer( new Demo::PaddingExample ) ); | ||
| 52 | + container.push_back( ExamplePointer( new Demo::AbsoluteExample ) ); | ||
| 53 | + container.push_back( ExamplePointer( new Demo::FlexExample ) ); | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +} // anonymous namespace | ||
| 57 | + | ||
| 58 | +class LayoutingExample: public ConnectionTracker | ||
| 59 | +{ | ||
| 60 | + public: | ||
| 61 | + | ||
| 62 | + LayoutingExample( Application& application ) | ||
| 63 | + : mApplication( application ), | ||
| 64 | + mLayoutingExamples(), | ||
| 65 | + mLayoutIndex( 0 ) | ||
| 66 | + { | ||
| 67 | + // Connect to the Application's Init signal | ||
| 68 | + mApplication.InitSignal().Connect( this, &LayoutingExample::Create ); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +private: | ||
| 72 | + | ||
| 73 | + void Create( Application& application ) | ||
| 74 | + { | ||
| 75 | + auto stage = Stage::GetCurrent(); | ||
| 76 | + stage.KeyEventSignal().Connect( this, &LayoutingExample::OnKeyEvent ); | ||
| 77 | + | ||
| 78 | + auto bg = ImageView::New( BACKGROUND_IMAGE ); | ||
| 79 | + bg.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 80 | + stage.Add( bg ); | ||
| 81 | + auto toolbar = ImageView::New( TOOLBAR_IMAGE ); | ||
| 82 | + toolbar.SetParentOrigin( ParentOrigin::TOP_CENTER ); | ||
| 83 | + toolbar.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | ||
| 84 | + toolbar.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | ||
| 85 | + toolbar.SetProperty( Actor::Property::SIZE_HEIGHT, 50.0f); | ||
| 86 | + | ||
| 87 | + stage.Add( toolbar ); | ||
| 88 | + | ||
| 89 | + auto title = TextLabel::New( APPLICATION_TITLE ); | ||
| 90 | + title.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 91 | + title.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 92 | + title.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE ); | ||
| 93 | + title.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::LEFT ); | ||
| 94 | + toolbar.Add( title ); | ||
| 95 | + | ||
| 96 | + mNextLayout = PushButton::New(); | ||
| 97 | + mNextLayout.SetProperty( Toolkit::Button::Property::LABEL, "change layout"); | ||
| 98 | + mNextLayout.ClickedSignal().Connect( this, &LayoutingExample::ChangeLayout ); | ||
| 99 | + mNextLayout.SetParentOrigin( ParentOrigin::TOP_RIGHT ); | ||
| 100 | + mNextLayout.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); | ||
| 101 | + mNextLayout.SetSize(175, 50); | ||
| 102 | + toolbar.Add( mNextLayout ); | ||
| 103 | + | ||
| 104 | + CreateExamples( mLayoutingExamples ); | ||
| 105 | + if( ! mLayoutingExamples.empty() ) | ||
| 106 | + { | ||
| 107 | + mLayoutingExamples[ mLayoutIndex ]->Create(); | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + bool ChangeLayout( Button button ) | ||
| 112 | + { | ||
| 113 | + if( ! mLayoutingExamples.empty() ) | ||
| 114 | + { | ||
| 115 | + mLayoutingExamples[ mLayoutIndex ]->Remove(); | ||
| 116 | + mLayoutIndex = ( mLayoutIndex + 1 ) % mLayoutingExamples.size(); | ||
| 117 | + mLayoutingExamples[ mLayoutIndex ]->Create(); | ||
| 118 | + } | ||
| 119 | + return true; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * Main key event handler | ||
| 124 | + */ | ||
| 125 | + void OnKeyEvent(const KeyEvent& event) | ||
| 126 | + { | ||
| 127 | + if(event.state == KeyEvent::Down) | ||
| 128 | + { | ||
| 129 | + if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) | ||
| 130 | + { | ||
| 131 | + mApplication.Quit(); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + | ||
| 137 | +private: | ||
| 138 | + Application& mApplication; | ||
| 139 | + ExampleContainer mLayoutingExamples; | ||
| 140 | + PushButton mNextLayout; | ||
| 141 | + unsigned int mLayoutIndex; | ||
| 142 | +}; | ||
| 143 | + | ||
| 144 | +int DALI_EXPORT_API main( int argc, char **argv ) | ||
| 145 | +{ | ||
| 146 | + Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); | ||
| 147 | + LayoutingExample test( application ); | ||
| 148 | + application.MainLoop(); | ||
| 149 | + return 0; | ||
| 150 | +}; |
examples/layouting/linear-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 <string> | ||
| 19 | +#include "linear-example.h" | ||
| 20 | +#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> | ||
| 21 | +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | ||
| 22 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | ||
| 23 | +#include <dali-toolkit/devel-api/layouting/linear-layout.h> | ||
| 24 | + | ||
| 25 | +using namespace Dali; | ||
| 26 | +using namespace Dali::Toolkit; | ||
| 27 | + | ||
| 28 | +namespace | ||
| 29 | +{ | ||
| 30 | + | ||
| 31 | +// Button file names | ||
| 32 | +const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" ); | ||
| 33 | +const char* LTR_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-play-selected.png" ); | ||
| 34 | + | ||
| 35 | +const char* RTL_IMAGE( DEMO_IMAGE_DIR "icon-reverse.png" ); | ||
| 36 | +const char* RTL_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-reverse-selected.png" ); | ||
| 37 | + | ||
| 38 | +const char* ROTATE_CLOCKWISE_IMAGE( DEMO_IMAGE_DIR "icon-reset.png" ); | ||
| 39 | +const char* ROTATE_CLOCKWISE_SELECTED_IMAGE( DEMO_IMAGE_DIR "icon-reset-selected.png" ); | ||
| 40 | + | ||
| 41 | +// Child image filenames | ||
| 42 | +const char* IMAGE_PATH[] = { | ||
| 43 | + DEMO_IMAGE_DIR "application-icon-101.png", | ||
| 44 | + DEMO_IMAGE_DIR "application-icon-102.png", | ||
| 45 | + DEMO_IMAGE_DIR "application-icon-103.png", | ||
| 46 | + DEMO_IMAGE_DIR "application-icon-104.png" | ||
| 47 | +}; | ||
| 48 | + | ||
| 49 | +const unsigned int NUMBER_OF_RESOURCES = sizeof(IMAGE_PATH) / sizeof(char*); | ||
| 50 | + | ||
| 51 | +// Helper function to create ImageViews with given filename and size. | ||
| 52 | +void CreateChildImageView( ImageView& imageView, const char* filename, Size size ) | ||
| 53 | +{ | ||
| 54 | + imageView = ImageView::New(); | ||
| 55 | + Property::Map imagePropertyMap; | ||
| 56 | + imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; | ||
| 57 | + imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename; | ||
| 58 | + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width; | ||
| 59 | + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height; | ||
| 60 | + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap ); | ||
| 61 | + imageView.SetName("ImageView"); | ||
| 62 | + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 63 | + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +} // namespace | ||
| 67 | + | ||
| 68 | +namespace Demo | ||
| 69 | +{ | ||
| 70 | + | ||
| 71 | +LinearExample::LinearExample() | ||
| 72 | +: mLTRDirection(true) | ||
| 73 | +{ | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +void LinearExample::Create() | ||
| 77 | +{ | ||
| 78 | + auto stage = Stage::GetCurrent(); | ||
| 79 | + | ||
| 80 | + mDirectionButton = PushButton::New(); | ||
| 81 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, RTL_IMAGE ); | ||
| 82 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); | ||
| 83 | + mDirectionButton.ClickedSignal().Connect( this, &LinearExample::OnDirectionClicked ); | ||
| 84 | + mDirectionButton.SetParentOrigin( Vector3(0.33f, 1.0f, 0.5f ) ); | ||
| 85 | + mDirectionButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 86 | + mDirectionButton.SetSize(75, 75); | ||
| 87 | + stage.Add( mDirectionButton ); | ||
| 88 | + | ||
| 89 | + mRotateButton = PushButton::New(); | ||
| 90 | + mRotateButton.SetProperty( PushButton::Property::UNSELECTED_ICON, ROTATE_CLOCKWISE_IMAGE ); | ||
| 91 | + mRotateButton.SetProperty( PushButton::Property::SELECTED_ICON, ROTATE_CLOCKWISE_SELECTED_IMAGE ); | ||
| 92 | + mRotateButton.ClickedSignal().Connect( this, &LinearExample::OnRotateClicked ); | ||
| 93 | + mRotateButton.SetParentOrigin( Vector3(0.66f, 1.0f, 0.5f )); | ||
| 94 | + mRotateButton.SetAnchorPoint( Vector3(0.5f, 1.0f, 0.5f)); | ||
| 95 | + mRotateButton.SetSize(75, 75); | ||
| 96 | + stage.Add( mRotateButton ); | ||
| 97 | + | ||
| 98 | + // Create a linear layout | ||
| 99 | + mLinearContainer = Control::New(); | ||
| 100 | + auto layout = LinearLayout::New(); | ||
| 101 | + layout.SetAnimateLayout(true); | ||
| 102 | + layout.SetOrientation( LinearLayout::Orientation::VERTICAL ); | ||
| 103 | + DevelControl::SetLayout( mLinearContainer, layout ); | ||
| 104 | + | ||
| 105 | + mLinearContainer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 106 | + mLinearContainer.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 107 | + mLinearContainer.SetName( "LinearExample" ); | ||
| 108 | + stage.Add( mLinearContainer ); | ||
| 109 | + mLinearContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); | ||
| 110 | + mLinearContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); | ||
| 111 | + mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT ); | ||
| 112 | + | ||
| 113 | + for( unsigned int x = 0; x < NUMBER_OF_RESOURCES; ++x ) | ||
| 114 | + { | ||
| 115 | + Toolkit::ImageView imageView; | ||
| 116 | + CreateChildImageView( imageView, IMAGE_PATH[ x ], Size(100.0f, 100.0f) ); | ||
| 117 | + mLinearContainer.Add( imageView ); | ||
| 118 | + } | ||
| 119 | +} | ||
| 120 | + | ||
| 121 | +// Remove controls added by this example from stage | ||
| 122 | +void LinearExample::Remove() | ||
| 123 | +{ | ||
| 124 | + if ( mLinearContainer ) | ||
| 125 | + { | ||
| 126 | + UnparentAndReset( mDirectionButton ); | ||
| 127 | + UnparentAndReset( mRotateButton ); | ||
| 128 | + UnparentAndReset( mLinearContainer); | ||
| 129 | + } | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +// Mirror items in layout | ||
| 133 | +bool LinearExample::OnDirectionClicked( Button button ) | ||
| 134 | +{ | ||
| 135 | + if( !mLTRDirection ) | ||
| 136 | + { | ||
| 137 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, LTR_IMAGE ); | ||
| 138 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, LTR_SELECTED_IMAGE ); | ||
| 139 | + mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT ); | ||
| 140 | + } | ||
| 141 | + else | ||
| 142 | + { | ||
| 143 | + mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, RTL_IMAGE ); | ||
| 144 | + mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); | ||
| 145 | + mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT ); | ||
| 146 | + } | ||
| 147 | + mLTRDirection = !mLTRDirection; | ||
| 148 | + return true; | ||
| 149 | +} | ||
| 150 | + | ||
| 151 | +// Rotate layout by changing layout | ||
| 152 | +bool LinearExample::OnRotateClicked( Button button ) | ||
| 153 | +{ | ||
| 154 | + auto layout = LinearLayout::DownCast( DevelControl::GetLayout( mLinearContainer ) ); | ||
| 155 | + if( layout.GetOrientation() == LinearLayout::Orientation::VERTICAL ) | ||
| 156 | + { | ||
| 157 | + layout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); | ||
| 158 | + } | ||
| 159 | + else | ||
| 160 | + { | ||
| 161 | + layout.SetOrientation( LinearLayout::Orientation::VERTICAL ); | ||
| 162 | + } | ||
| 163 | + return true; | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +} // namespace Demo |
examples/layouting/linear-example.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_LINEAR_EXAMPLE_H | ||
| 2 | +#define DALI_DEMO_LINEAR_EXAMPLE_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 | +#include <dali/dali.h> | ||
| 22 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 23 | + | ||
| 24 | +#include "example.h" | ||
| 25 | + | ||
| 26 | +using namespace Dali; | ||
| 27 | +using namespace Dali::Toolkit; | ||
| 28 | + | ||
| 29 | +namespace Demo | ||
| 30 | +{ | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * @file linear-example.hcpp | ||
| 34 | + * @brief Example of a Linear Layout with mirror feature and | ||
| 35 | + * transition from horizontal to vertical. | ||
| 36 | + */ | ||
| 37 | +class LinearExample final: public ConnectionTracker, public Example | ||
| 38 | +{ | ||
| 39 | +public: | ||
| 40 | + LinearExample(); | ||
| 41 | + | ||
| 42 | + // Creates a Linear Layout Example and displays it. | ||
| 43 | + virtual void Create() override; | ||
| 44 | + | ||
| 45 | + // Remove and destroy this layout | ||
| 46 | + virtual void Remove() override; | ||
| 47 | + | ||
| 48 | +private: | ||
| 49 | + | ||
| 50 | + // Changes the direction of the items. | ||
| 51 | + bool OnDirectionClicked( Button button ); | ||
| 52 | + | ||
| 53 | + // Alternates the linear layout from horizontal to vertical | ||
| 54 | + bool OnRotateClicked( Button button ); | ||
| 55 | + | ||
| 56 | +private: | ||
| 57 | + PushButton mDirectionButton; | ||
| 58 | + PushButton mRotateButton; | ||
| 59 | + Control mLinearContainer; | ||
| 60 | + bool mLTRDirection; | ||
| 61 | +}; // class LinearContainer | ||
| 62 | + | ||
| 63 | +} // namespace Demo | ||
| 64 | + | ||
| 65 | +#endif //DALI_DEMO_LINEAR_CONTAINER_H |
examples/layouting/padding-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 <string> | ||
| 19 | +#include "padding-example.h" | ||
| 20 | +#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> | ||
| 21 | +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h> | ||
| 22 | +#include <dali-toolkit/devel-api/controls/control-devel.h> | ||
| 23 | +#include <dali-toolkit/devel-api/layouting/absolute-layout.h> | ||
| 24 | +#include <dali-toolkit/devel-api/layouting/linear-layout.h> | ||
| 25 | + | ||
| 26 | +using namespace Dali; | ||
| 27 | +using namespace Dali::Toolkit; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +namespace | ||
| 31 | +{ | ||
| 32 | + | ||
| 33 | +// Helper function to create ImageViews with given filename and size. | ||
| 34 | +void CreateChildImageView( ImageView& imageView, const char* filename, Size size ) | ||
| 35 | +{ | ||
| 36 | + imageView = ImageView::New(); | ||
| 37 | + Property::Map imagePropertyMap; | ||
| 38 | + imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; | ||
| 39 | + imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename; | ||
| 40 | + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width; | ||
| 41 | + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height; | ||
| 42 | + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap ); | ||
| 43 | + imageView.SetName("ImageView"); | ||
| 44 | + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 45 | + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +namespace Demo | ||
| 51 | +{ | ||
| 52 | + | ||
| 53 | +void PaddingExample::Create() | ||
| 54 | +{ | ||
| 55 | + // The Init signal is received once (only) during the Application lifetime | ||
| 56 | + | ||
| 57 | + // Create a root layout, ideally Dali would have a default layout in the root layer. | ||
| 58 | + // Without this root layer the mAbsoluteLayout (or any other layout) will not | ||
| 59 | + // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings. | ||
| 60 | + // It uses the default stage size and ideally should have a layout added to it. | ||
| 61 | + auto stage = Stage::GetCurrent(); | ||
| 62 | + auto rootLayoutControl = Control::New(); | ||
| 63 | + rootLayoutControl.SetName( "AbsoluteLayout"); | ||
| 64 | + auto rootLayout = AbsoluteLayout::New(); | ||
| 65 | + DevelControl::SetLayout( rootLayoutControl, rootLayout ); | ||
| 66 | + rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 67 | + rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 68 | + stage.Add( rootLayoutControl ); | ||
| 69 | + | ||
| 70 | + // Create a table view to show a pair of buttons above each image. | ||
| 71 | + mHorizontalBox = Control::New(); | ||
| 72 | + | ||
| 73 | + // Create LinearLayout for this control. | ||
| 74 | + auto hboxLayout = LinearLayout::New(); | ||
| 75 | + DevelControl::SetLayout( mHorizontalBox, hboxLayout ); | ||
| 76 | + mHorizontalBox.SetName("HBox"); | ||
| 77 | + mHorizontalBox.SetBackgroundColor( Color::WHITE ); | ||
| 78 | + mHorizontalBox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 480 ); | ||
| 79 | + mHorizontalBox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 700 ); | ||
| 80 | + mHorizontalBox.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 81 | + mHorizontalBox.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 82 | + | ||
| 83 | + rootLayoutControl.Add( mHorizontalBox ); | ||
| 84 | + | ||
| 85 | + mToggleButton = Toolkit::PushButton::New(); | ||
| 86 | + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Padding on #2" ); | ||
| 87 | + mToggleButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | ||
| 88 | + mToggleButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); | ||
| 89 | + mToggleButton.ClickedSignal().Connect( this, &Demo::PaddingExample::ChangePaddingClicked ); | ||
| 90 | + mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | ||
| 91 | + mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | ||
| 92 | + | ||
| 93 | + stage.Add( mToggleButton ); | ||
| 94 | + | ||
| 95 | + for( unsigned int x = 0; x < NUMBER_OF_IMAGE_VIEWS; x++ ) | ||
| 96 | + { | ||
| 97 | + CreateChildImageView( mImageViews[x], DEMO_IMAGE_DIR "gallery-small-23.jpg" , Size(100.0f, 100.0f) ); | ||
| 98 | + | ||
| 99 | + // Set Padding for second ImageView | ||
| 100 | + if( 1 == x ) | ||
| 101 | + { | ||
| 102 | + mImageViews[x].SetProperty(Toolkit::Control::Property::PADDING, Extents( 10.0f,10.0f,5.0f, 5.0f)); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + // Set margin for first ImageView | ||
| 106 | + if( 0 == x ) | ||
| 107 | + { | ||
| 108 | + mImageViews[x].SetProperty(Toolkit::Control::Property::MARGIN, Extents( 10.0f,10.0f,0.0f, 0.0f)); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + mHorizontalBox.Add( mImageViews[x] ); | ||
| 112 | + | ||
| 113 | + mImageViewToggleStatus[ x ] = true; | ||
| 114 | + } | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +void PaddingExample::Remove() | ||
| 118 | +{ | ||
| 119 | + UnparentAndReset( mToggleButton ); | ||
| 120 | + UnparentAndReset( mHorizontalBox ); | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +bool PaddingExample::ChangePaddingClicked( Toolkit::Button button ) | ||
| 124 | +{ | ||
| 125 | + if ( true == mImageViewToggleStatus[ 1 ] ) | ||
| 126 | + { | ||
| 127 | + mImageViews[1].SetProperty(Toolkit::Control::Property::PADDING, Extents( .0f, .0f, .0f, .0f)); | ||
| 128 | + mImageViews[1].SetProperty(Actor::Property::COLOR_ALPHA, 0.5f); | ||
| 129 | + mImageViewToggleStatus[ 1 ] = false; | ||
| 130 | + } | ||
| 131 | + else | ||
| 132 | + { | ||
| 133 | + mImageViews[1].SetProperty(Toolkit::Control::Property::PADDING, Extents( 10.0f, 10.0f, 5.0f, 5.0f)); | ||
| 134 | + mImageViews[1].SetProperty(Actor::Property::COLOR_ALPHA, 1.0f); | ||
| 135 | + mImageViewToggleStatus[ 1 ] = true; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + return true; | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +} // namespace Demo |
examples/layouting/padding-example.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_PADDING_EXAMPLE_H | ||
| 2 | +#define DALI_DEMO_PADDING_EXAMPLE_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 | +#include <string> | ||
| 22 | +#include <dali/dali.h> | ||
| 23 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 24 | + | ||
| 25 | +#include "example.h" | ||
| 26 | + | ||
| 27 | +using namespace Dali; | ||
| 28 | +using namespace Dali::Toolkit; | ||
| 29 | + | ||
| 30 | +namespace Demo | ||
| 31 | +{ | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * @file padding-example.hcpp | ||
| 35 | + * @brief Example of a Linear Layout with padding applied, enables updating of padding values for | ||
| 36 | + * one of the children. | ||
| 37 | + */ | ||
| 38 | +class PaddingExample final: public ConnectionTracker, public Example | ||
| 39 | +{ | ||
| 40 | +public: | ||
| 41 | + | ||
| 42 | + static const unsigned int NUMBER_OF_IMAGE_VIEWS = 3; | ||
| 43 | + | ||
| 44 | + // Create a Linear layout of ImagesViews, one with a Margin, One with padding. | ||
| 45 | + void Create() override; | ||
| 46 | + | ||
| 47 | + // Remove created Layout | ||
| 48 | + void Remove() override; | ||
| 49 | + | ||
| 50 | +private: | ||
| 51 | + | ||
| 52 | + // Change Paddding callback | ||
| 53 | + bool ChangePaddingClicked( Toolkit::Button button ); | ||
| 54 | + | ||
| 55 | +private: | ||
| 56 | + | ||
| 57 | + Toolkit::Control mHorizontalBox; | ||
| 58 | + Toolkit::ImageView mImageViews[ NUMBER_OF_IMAGE_VIEWS ]; | ||
| 59 | + bool mImageViewToggleStatus[ NUMBER_OF_IMAGE_VIEWS ]; | ||
| 60 | + Toolkit::PushButton mToggleButton; | ||
| 61 | + | ||
| 62 | +}; | ||
| 63 | + | ||
| 64 | +} // namespace Demo | ||
| 65 | + | ||
| 66 | +#endif // DALI_DEMO_PADDING_EXAMPLE_H |
examples/simple-layout/simple-layout-example.cpp
| @@ -18,7 +18,6 @@ | @@ -18,7 +18,6 @@ | ||
| 18 | #include <dali-toolkit/dali-toolkit.h> | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | 19 | ||
| 20 | #include <dali-toolkit/devel-api/controls/control-devel.h> | 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> | 21 | #include <dali-toolkit/devel-api/layouting/layout-item-impl.h> |
| 23 | 22 | ||
| 24 | #include "custom-layout.h" | 23 | #include "custom-layout.h" |
packaging/com.samsung.dali-demo.spec
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | Name: com.samsung.dali-demo | 3 | Name: com.samsung.dali-demo |
| 4 | Summary: The OpenGLES Canvas Core Demo | 4 | Summary: The OpenGLES Canvas Core Demo |
| 5 | -Version: 1.3.28 | 5 | +Version: 1.3.29 |
| 6 | Release: 1 | 6 | Release: 1 |
| 7 | Group: System/Libraries | 7 | Group: System/Libraries |
| 8 | License: Apache-2.0 | 8 | License: Apache-2.0 |
resources/images/icon-reverse-selected.png
0 → 100644
1.79 KB
resources/images/icon-reverse.png
0 → 100644
1.68 KB
resources/images/icon-rotate-anticlockwise-selected.png
0 → 100644
2.03 KB
resources/images/icon-rotate-anticlockwise.png
0 → 100644
2.06 KB
resources/po/en_GB.po
| @@ -82,6 +82,9 @@ msgstr "Item View" | @@ -82,6 +82,9 @@ msgstr "Item View" | ||
| 82 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" | 82 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" |
| 83 | msgstr "Lights and Shadows" | 83 | msgstr "Lights and Shadows" |
| 84 | 84 | ||
| 85 | +msgid "DALI_DEMO_STR_TITLE_LAYOUTING" | ||
| 86 | +msgstr "Layouting" | ||
| 87 | + | ||
| 85 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" | 88 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" |
| 86 | msgstr "Mesh Line" | 89 | msgstr "Mesh Line" |
| 87 | 90 |
resources/po/en_US.po
| @@ -85,6 +85,9 @@ msgstr "Item View" | @@ -85,6 +85,9 @@ msgstr "Item View" | ||
| 85 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" | 85 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" |
| 86 | msgstr "Lights and Shadows" | 86 | msgstr "Lights and Shadows" |
| 87 | 87 | ||
| 88 | +msgid "DALI_DEMO_STR_TITLE_LAYOUTING" | ||
| 89 | +msgstr "Layouting" | ||
| 90 | + | ||
| 88 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" | 91 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" |
| 89 | msgstr "Mesh Line" | 92 | msgstr "Mesh Line" |
| 90 | 93 |
resources/po/ur.po
| @@ -64,6 +64,9 @@ msgstr "چیزوں کی فہرست" | @@ -64,6 +64,9 @@ msgstr "چیزوں کی فہرست" | ||
| 64 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" | 64 | msgid "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS" |
| 65 | msgstr "روشنی اور سائے" | 65 | msgstr "روشنی اور سائے" |
| 66 | 66 | ||
| 67 | +msgid "DALI_DEMO_STR_TITLE_LAYOUTING" | ||
| 68 | +msgstr "تَرتيب" | ||
| 69 | + | ||
| 67 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" | 70 | msgid "DALI_DEMO_STR_TITLE_LINE_MESH" |
| 68 | msgstr "لکیریں" | 71 | msgstr "لکیریں" |
| 69 | 72 |
shared/dali-demo-strings.h
| 1 | /* | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| @@ -63,6 +63,7 @@ extern "C" | @@ -63,6 +63,7 @@ extern "C" | ||
| 63 | #define DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL") | 63 | #define DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL") |
| 64 | #define DALI_DEMO_STR_TITLE_ITEM_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ITEM_VIEW") | 64 | #define DALI_DEMO_STR_TITLE_ITEM_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ITEM_VIEW") |
| 65 | #define DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS") | 65 | #define DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS") |
| 66 | +#define DALI_DEMO_STR_TITLE_LAYOUTING dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LAYOUTING") | ||
| 66 | #define DALI_DEMO_STR_TITLE_LINE_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LINE_MESH") | 67 | #define DALI_DEMO_STR_TITLE_LINE_MESH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_LINE_MESH") |
| 67 | #define DALI_DEMO_STR_TITLE_MAGNIFIER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MAGNIFIER") | 68 | #define DALI_DEMO_STR_TITLE_MAGNIFIER dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MAGNIFIER") |
| 68 | #define DALI_DEMO_STR_TITLE_MESH_MORPH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MESH_MORPH") | 69 | #define DALI_DEMO_STR_TITLE_MESH_MORPH dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_MESH_MORPH") |
| @@ -137,6 +138,7 @@ extern "C" | @@ -137,6 +138,7 @@ extern "C" | ||
| 137 | #define DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL "Image View URL" | 138 | #define DALI_DEMO_STR_TITLE_IMAGE_VIEW_URL "Image View URL" |
| 138 | #define DALI_DEMO_STR_TITLE_ITEM_VIEW "Item View" | 139 | #define DALI_DEMO_STR_TITLE_ITEM_VIEW "Item View" |
| 139 | #define DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS "Lights and shadows" | 140 | #define DALI_DEMO_STR_TITLE_LIGHTS_AND_SHADOWS "Lights and shadows" |
| 141 | +#define DALI_DEMO_STR_TITLE_LAYOUTING "Layouting" | ||
| 140 | #define DALI_DEMO_STR_TITLE_LINE_MESH "Mesh Line" | 142 | #define DALI_DEMO_STR_TITLE_LINE_MESH "Mesh Line" |
| 141 | #define DALI_DEMO_STR_TITLE_MAGNIFIER "Magnifier" | 143 | #define DALI_DEMO_STR_TITLE_MAGNIFIER "Magnifier" |
| 142 | #define DALI_DEMO_STR_TITLE_MESH_MORPH "Mesh Morph" | 144 | #define DALI_DEMO_STR_TITLE_MESH_MORPH "Mesh Morph" |