Commit e0d5c698d57eaee2da5688c5219a6d0775a96c6f
1 parent
acad6b41
Added an example which shows a layout containing animating contact cards
Change-Id: Ic59f2e05275694ed1730628b9a1ac4950a759e3f
Showing
29 changed files
with
1226 additions
and
1 deletions
.gitignore
build/tizen/CMakeLists.txt
| ... | ... | @@ -93,6 +93,7 @@ CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp ) |
| 93 | 93 | |
| 94 | 94 | #Replace @DEMO_STYLE_IMAGE_DIR@ in following files |
| 95 | 95 | CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/demo-theme.json.in ${LOCAL_STYLE_DIR}/demo-theme.json ) |
| 96 | +CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/contact-cards-example-theme.json.in ${LOCAL_STYLE_DIR}/contact-cards-example-theme.json ) | |
| 96 | 97 | CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-one.json.in ${LOCAL_STYLE_DIR}/style-example-theme-one.json ) |
| 97 | 98 | CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-two.json.in ${LOCAL_STYLE_DIR}/style-example-theme-two.json ) |
| 98 | 99 | CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-three.json.in ${LOCAL_STYLE_DIR}/style-example-theme-three.json ) | ... | ... |
com.samsung.dali-demo.xml
| ... | ... | @@ -169,4 +169,7 @@ |
| 169 | 169 | <ui-application appid="progress-bar.example" exec="/usr/apps/com.samsung.dali-demo/bin/progress-bar.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 170 | 170 | <label>Progress Bar</label> |
| 171 | 171 | </ui-application> |
| 172 | + <ui-application appid="contact-cards.example" exec="/usr/apps/com.samsung.dali-demo/bin/contact-cards.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 173 | + <label>Contact Cards</label> | |
| 174 | + </ui-application> | |
| 172 | 175 | </manifest> | ... | ... |
demo/dali-demo.cpp
| ... | ... | @@ -83,6 +83,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 83 | 83 | demo.AddExample(Example("styling.example", DALI_DEMO_STR_TITLE_STYLING)); |
| 84 | 84 | demo.AddExample(Example("sparkle.example", DALI_DEMO_STR_TITLE_SPARKLE)); |
| 85 | 85 | demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR)); |
| 86 | + demo.AddExample(Example("contact-cards.example", DALI_DEMO_STR_TITLE_CONTACT_CARDS)); | |
| 86 | 87 | |
| 87 | 88 | demo.SortAlphabetically( true ); |
| 88 | 89 | ... | ... |
examples/contact-cards/README.md
0 → 100644
examples/contact-cards/clipped-image.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 | +// HEADER | |
| 19 | +#include "clipped-image.h" | |
| 20 | + | |
| 21 | +// EXTERNAL INCLUDES | |
| 22 | +#include <dali-toolkit/dali-toolkit.h> | |
| 23 | + | |
| 24 | +namespace ClippedImage | |
| 25 | +{ | |
| 26 | + | |
| 27 | +using namespace Dali; | |
| 28 | +using namespace Dali::Toolkit; | |
| 29 | + | |
| 30 | +namespace | |
| 31 | +{ | |
| 32 | + | |
| 33 | +const char * const DELTA_PROPERTY_NAME( "uDelta" ); ///< Name of uniform used to mix the Circle and Quad geometries. | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * @brief This vertex-shader mixes in the quad and circle geometry depending on the value of uDelta. | |
| 37 | + * | |
| 38 | + * uDelta is used to mix in the Circle and the Quad positions. | |
| 39 | + * If uDelta is 0.0f, then the circle position is adopted and if it is 1.0f, then the quad position is adopted. | |
| 40 | + */ | |
| 41 | +const char * VERTEX_SHADER = DALI_COMPOSE_SHADER( | |
| 42 | + attribute mediump vec2 aPositionCircle;\n | |
| 43 | + attribute mediump vec2 aPositionQuad;\n | |
| 44 | + uniform mediump float uDelta; | |
| 45 | + uniform mediump mat4 uMvpMatrix;\n | |
| 46 | + uniform mediump vec3 uSize;\n | |
| 47 | + \n | |
| 48 | + void main()\n | |
| 49 | + {\n | |
| 50 | + mediump vec4 vertexPosition = vec4(mix(aPositionCircle,aPositionQuad,uDelta), 0.0, 1.0);\n | |
| 51 | + vertexPosition.xyz *= uSize;\n | |
| 52 | + gl_Position = uMvpMatrix * vertexPosition;\n | |
| 53 | + }\n | |
| 54 | +); | |
| 55 | + | |
| 56 | +/** | |
| 57 | + * @brief This fragment-shader does not output anything. It's for a control which is just going to clip as specified in the vertex shader. | |
| 58 | + */ | |
| 59 | +const char * FRAGMENT_SHADER = DALI_COMPOSE_SHADER( | |
| 60 | + void main()\n | |
| 61 | + {\n | |
| 62 | + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n | |
| 63 | + }\n | |
| 64 | +); | |
| 65 | + | |
| 66 | +/** | |
| 67 | + * @brief Creates the shader required for the clipped image | |
| 68 | + * @return A reference to a static handle to a shader object (only created when first called). | |
| 69 | + */ | |
| 70 | +Shader& CreateShader() | |
| 71 | +{ | |
| 72 | + // Only need to create it once | |
| 73 | + // The issue with using a static is that the shader will only get destroyed at application destruction. | |
| 74 | + // This is OK for a simple use cases such as this example, but for more polished applications, the shader creation/destruction needs to | |
| 75 | + // be managed by the application writer. | |
| 76 | + static Shader shader; | |
| 77 | + | |
| 78 | + if( !shader ) | |
| 79 | + { | |
| 80 | + shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); | |
| 81 | + } | |
| 82 | + | |
| 83 | + return shader; | |
| 84 | +} | |
| 85 | + | |
| 86 | +/** | |
| 87 | + * @brief Creates the geometry required for the clipped image | |
| 88 | + * @return A reference to a static handle to a geometry object (only created when first called). | |
| 89 | + */ | |
| 90 | +Geometry& CreateGeometry() | |
| 91 | +{ | |
| 92 | + // Only need to create it once | |
| 93 | + // The issue with using a static is that the geometry will only get destroyed at application destruction. | |
| 94 | + // This is OK for a simple use cases such as this example, but for more polished applications, the geometry creation/destruction needs to | |
| 95 | + // be managed by the application writer. | |
| 96 | + static Geometry geometry; | |
| 97 | + | |
| 98 | + if ( !geometry ) | |
| 99 | + { | |
| 100 | + const int vertexCount = 34; // Needs to be 4n plus 2 where n is a positive integer above 4 | |
| 101 | + | |
| 102 | + // Create the circle geometry | |
| 103 | + | |
| 104 | + // Radius is bound to actor's dimensions so this should not be increased. | |
| 105 | + // If a bigger circle is required then the actor size should be increased. | |
| 106 | + const float radius = 0.5f; | |
| 107 | + const Vector2 center = Vector2::ZERO; | |
| 108 | + | |
| 109 | + // Create a buffer for vertex data | |
| 110 | + Vector2 circleBuffer[vertexCount]; | |
| 111 | + int idx = 0; | |
| 112 | + | |
| 113 | + // Center vertex for triangle fan | |
| 114 | + circleBuffer[ idx++ ] = center; | |
| 115 | + | |
| 116 | + // Outer vertices of the circle | |
| 117 | + const int outerVertexCount = vertexCount - 1; | |
| 118 | + | |
| 119 | + for ( int i = 0; i < outerVertexCount; ++i ) | |
| 120 | + { | |
| 121 | + const float percent = ( i / static_cast< float >( outerVertexCount - 1 ) ); | |
| 122 | + const float rad = percent * 2.0f * Math::PI; | |
| 123 | + | |
| 124 | + // Vertex position | |
| 125 | + Vector2 outer; | |
| 126 | + outer.x = center.x + radius * cos( rad ); | |
| 127 | + outer.y = center.y + radius * sin( rad ); | |
| 128 | + | |
| 129 | + circleBuffer[ idx++ ] = outer; | |
| 130 | + } | |
| 131 | + | |
| 132 | + Property::Map circleVertexFormat; | |
| 133 | + circleVertexFormat["aPositionCircle"] = Property::VECTOR2; | |
| 134 | + PropertyBuffer circleVertices = PropertyBuffer::New( circleVertexFormat ); | |
| 135 | + circleVertices.SetData( circleBuffer, vertexCount ); | |
| 136 | + | |
| 137 | + // Create the Quad Geometry | |
| 138 | + Vector2 quadBuffer[vertexCount]; | |
| 139 | + idx = 0; | |
| 140 | + quadBuffer[ idx++ ] = center; | |
| 141 | + | |
| 142 | + const size_t vertsPerSide = ( vertexCount - 2 ) / 4; | |
| 143 | + Vector2 outer( 0.5f, 0.0f ); | |
| 144 | + quadBuffer[ idx++ ] = outer; | |
| 145 | + float incrementPerBuffer = 1.0f / static_cast< float >( vertsPerSide ); | |
| 146 | + | |
| 147 | + for( size_t i = 0; i < vertsPerSide && outer.y < 0.5f; ++i ) | |
| 148 | + { | |
| 149 | + outer.y += incrementPerBuffer; | |
| 150 | + quadBuffer[ idx++ ] = outer; | |
| 151 | + } | |
| 152 | + | |
| 153 | + for( size_t i = 0; i < vertsPerSide && outer.x > -0.5f; ++i ) | |
| 154 | + { | |
| 155 | + outer.x -= incrementPerBuffer; | |
| 156 | + quadBuffer[ idx++ ] = outer; | |
| 157 | + } | |
| 158 | + | |
| 159 | + for( size_t i = 0; i < vertsPerSide && outer.y > -0.5f; ++i ) | |
| 160 | + { | |
| 161 | + outer.y -= incrementPerBuffer; | |
| 162 | + quadBuffer[ idx++ ] = outer; | |
| 163 | + } | |
| 164 | + | |
| 165 | + for( size_t i = 0; i < vertsPerSide && outer.x < 0.5f; ++i ) | |
| 166 | + { | |
| 167 | + outer.x += incrementPerBuffer; | |
| 168 | + quadBuffer[ idx++ ] = outer; | |
| 169 | + } | |
| 170 | + | |
| 171 | + for( size_t i = 0; i < vertsPerSide && outer.y < 0.0f; ++i ) | |
| 172 | + { | |
| 173 | + outer.y += incrementPerBuffer; | |
| 174 | + quadBuffer[ idx++ ] = outer; | |
| 175 | + } | |
| 176 | + | |
| 177 | + Property::Map vertexFormat; | |
| 178 | + vertexFormat["aPositionQuad"] = Property::VECTOR2; | |
| 179 | + PropertyBuffer quadVertices2 = PropertyBuffer::New( vertexFormat ); | |
| 180 | + quadVertices2.SetData( quadBuffer, vertexCount ); | |
| 181 | + | |
| 182 | + // Create the geometry object itself | |
| 183 | + geometry = Geometry::New(); | |
| 184 | + geometry.AddVertexBuffer( circleVertices ); | |
| 185 | + geometry.AddVertexBuffer( quadVertices2 ); | |
| 186 | + geometry.SetType( Geometry::TRIANGLE_FAN ); | |
| 187 | + } | |
| 188 | + | |
| 189 | + return geometry; | |
| 190 | +} | |
| 191 | + | |
| 192 | +} // unnamed namespace | |
| 193 | + | |
| 194 | +const float CIRCLE_GEOMETRY = 0.0f; | |
| 195 | +const float QUAD_GEOMETRY = 1.0f; | |
| 196 | + | |
| 197 | +Dali::Toolkit::Control Create( const std::string& imagePath, Property::Index& propertyIndex ) | |
| 198 | +{ | |
| 199 | + // Create a control which whose geometry will be morphed between a circle and a quad | |
| 200 | + Control clippedImage = Control::New(); | |
| 201 | + clippedImage.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); | |
| 202 | + | |
| 203 | + // Create the required renderer and add to the clipped image control | |
| 204 | + Renderer renderer = Renderer::New( CreateGeometry(), CreateShader() ); | |
| 205 | + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); | |
| 206 | + clippedImage.AddRenderer( renderer ); | |
| 207 | + | |
| 208 | + // Register the property on the clipped image control which will allow animations between a circle and a quad | |
| 209 | + propertyIndex = clippedImage.RegisterProperty( DELTA_PROPERTY_NAME, 0.0f ); | |
| 210 | + | |
| 211 | + // Add the actual image to the control | |
| 212 | + Control image = ImageView::New( imagePath ); | |
| 213 | + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 214 | + image.SetParentOrigin( ParentOrigin::CENTER ); | |
| 215 | + image.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 216 | + clippedImage.Add( image ); | |
| 217 | + | |
| 218 | + return clippedImage; | |
| 219 | +} | |
| 220 | + | |
| 221 | +} // namespace ClippedImage | ... | ... |
examples/contact-cards/clipped-image.h
0 → 100644
| 1 | +#ifndef CLIPPED_IMAGE_H | |
| 2 | +#define CLIPPED_IMAGE_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2016 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 <string> | |
| 23 | +#include <dali-toolkit/public-api/controls/control.h> | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * @brief This namespace provides a helper function to create a control that clips an image either as a quad or a circle. | |
| 27 | + * | |
| 28 | + * The CIRCLE_GEOMETRY and QUAD_GEOMETRY constants can be used to set or animate to the different clipping geometries. | |
| 29 | + */ | |
| 30 | +namespace ClippedImage | |
| 31 | +{ | |
| 32 | + | |
| 33 | +extern const float CIRCLE_GEOMETRY; ///< Setting or animating the returned propertyIndex in Create() to this value will provide a circle geometry on the image @see Create | |
| 34 | +extern const float QUAD_GEOMETRY; ///< Setting or animating the returned propertyIndex in Create() to this value will provide a quad geometry on the image @see Create | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * @brief Creates a clipping image whose geometry (i.e. clip area) can be morphed between a circle and a quad by animating the propertyIndex out parameter. | |
| 38 | + * | |
| 39 | + * The propertyIndex parameter can be set or animated to CIRCLE_GEOMETRY or QUAD_GEOMETRY depending on the type of clipping required. | |
| 40 | + * If set to a value between these two constants, then the resulting geometry will be somewhere in between a circle and a quad. | |
| 41 | + * | |
| 42 | + * @param[in] imagePath The path to the image to show. | |
| 43 | + * @param[out] propertyIndex Gets set with the property index which the caller can animate using the CIRCLE_GEOMETRY & QUAD_GEOMETRY values. | |
| 44 | + * @return The image-mesh control | |
| 45 | + */ | |
| 46 | +Dali::Toolkit::Control Create( const std::string& imagePath, Dali::Property::Index& propertyIndex ); | |
| 47 | + | |
| 48 | +} // namespace ClippedImage | |
| 49 | + | |
| 50 | +#endif // CLIPPED_IMAGE_H | ... | ... |
examples/contact-cards/contact-card-layout-info.h
0 → 100644
| 1 | +#ifndef CONTACT_CARD_LAYOUT_INFO_H | |
| 2 | +#define CONTACT_CARD_LAYOUT_INFO_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2016 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/public-api/math/vector2.h> | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * @brief This is the common data that is used by all contact cards. | |
| 26 | + * | |
| 27 | + * In this context, "unfolded" means when all the details, including the name, address and image are shown. | |
| 28 | + * In this scenario, the control takes up most of the screen and a header is also shown. | |
| 29 | + * | |
| 30 | + * When the contact card is "folded", this means when only brief information is shown to the user, i.e. the image and name. | |
| 31 | + * In this scenario, the control is small and there should be several of these contact cards visible on the screen. | |
| 32 | + */ | |
| 33 | +struct ContactCardLayoutInfo | |
| 34 | +{ | |
| 35 | + Dali::Vector2 unfoldedPosition; ///< The position of the entire contact card when all details (unfolded) are shown | |
| 36 | + Dali::Vector2 unfoldedSize; ///< The size of the entire contact card when all details (unfolded) are shown | |
| 37 | + Dali::Vector2 foldedSize; ///< The size of each contact card when only the brief information is shown (folded) | |
| 38 | + | |
| 39 | + Dali::Vector2 padding; ///< The default padding to use throughout | |
| 40 | + | |
| 41 | + Dali::Vector2 headerSize; ///< The size of the header area (only shown when unfolded) | |
| 42 | + Dali::Vector2 headerFoldedPosition; ///< The position of the header area when folded - required for animation purposes only as it's actually clipped | |
| 43 | + Dali::Vector2 headerUnfoldedPosition; ///< The position of the header area when unfolded | |
| 44 | + | |
| 45 | + Dali::Vector2 imageSize; ///< The size of the image | |
| 46 | + Dali::Vector2 imageFoldedPosition; ///< The position of the image when folded | |
| 47 | + Dali::Vector2 imageUnfoldedPosition; ///< The position of the image when unfolded | |
| 48 | + | |
| 49 | + Dali::Vector2 textFoldedPosition; ///< The position of the text when folded | |
| 50 | + Dali::Vector2 textUnfoldedPosition; ///< The position of the text when unfolded | |
| 51 | +}; | |
| 52 | + | |
| 53 | +#endif // CONTACT_CARD_LAYOUT_INFO_H | |
| 54 | + | ... | ... |
examples/contact-cards/contact-card-layouter.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 "contact-card-layouter.h" | |
| 20 | + | |
| 21 | +// EXTERNAL INCLUDES | |
| 22 | +#include <dali/public-api/common/stage.h> | |
| 23 | + | |
| 24 | +// INTERNAL INCLUDES | |
| 25 | +#include "contact-card.h" | |
| 26 | + | |
| 27 | +using namespace Dali; | |
| 28 | + | |
| 29 | +namespace | |
| 30 | +{ | |
| 31 | +const float DEFAULT_PADDING = 25.0f; | |
| 32 | + | |
| 33 | +const float MINIMUM_ITEMS_PER_ROW_OR_COLUMN( 3.0f ); | |
| 34 | + | |
| 35 | +const float HEADER_HEIGHT_TO_UNFOLDED_SIZE_RATIO( 0.1f ); | |
| 36 | +const Vector2 HEADER_FOLDED_POSITION_AS_RATIO_OF_SIZE( -0.05f, -1.5f ); | |
| 37 | +const Vector2 HEADER_UNFOLDED_POSITION( Vector2::ZERO ); | |
| 38 | + | |
| 39 | +const float IMAGE_SIZE_AS_RATIO_TO_FOLDED_SIZE( 0.5f ); | |
| 40 | +const Vector2 IMAGE_FOLDED_POSITION_AS_RATIO_OF_SIZE( 0.5f, 0.25f ); | |
| 41 | + | |
| 42 | +const float FOLDED_TEXT_POSITION_AS_RATIO_OF_IMAGE_SIZE( 1.01f ); | |
| 43 | +} // unnamed namespace | |
| 44 | + | |
| 45 | +ContactCardLayouter::ContactCardLayouter() | |
| 46 | +: mContactCardLayoutInfo(), | |
| 47 | + mContactCards(), | |
| 48 | + mLastPosition(), | |
| 49 | + mPositionIncrementer(), | |
| 50 | + mItemsPerRow( 0 ), | |
| 51 | + mInitialized( false ) | |
| 52 | +{ | |
| 53 | +} | |
| 54 | + | |
| 55 | +ContactCardLayouter::~ContactCardLayouter() | |
| 56 | +{ | |
| 57 | + // Nothing to do as ContactCardContainer uses intrusive pointers so they will be automatically deleted | |
| 58 | +} | |
| 59 | + | |
| 60 | +void ContactCardLayouter::AddContact( const std::string& contactName, const std::string& contactAddress, const std::string& imagePath ) | |
| 61 | +{ | |
| 62 | + if( ! mInitialized ) | |
| 63 | + { | |
| 64 | + // Set up the common layouting info shared between all contact cards when first called | |
| 65 | + | |
| 66 | + mContactCardLayoutInfo.unfoldedPosition = mContactCardLayoutInfo.padding = Vector2( DEFAULT_PADDING, DEFAULT_PADDING ); | |
| 67 | + mContactCardLayoutInfo.unfoldedSize = Stage::GetCurrent().GetSize() - mContactCardLayoutInfo.padding * ( MINIMUM_ITEMS_PER_ROW_OR_COLUMN - 1.0f ); | |
| 68 | + | |
| 69 | + // Calculate the size of the folded card (use the minimum of width/height as size) | |
| 70 | + mContactCardLayoutInfo.foldedSize = ( mContactCardLayoutInfo.unfoldedSize - ( mContactCardLayoutInfo.padding * ( MINIMUM_ITEMS_PER_ROW_OR_COLUMN - 1.0f ) ) ) / MINIMUM_ITEMS_PER_ROW_OR_COLUMN; | |
| 71 | + mContactCardLayoutInfo.foldedSize.width = mContactCardLayoutInfo.foldedSize.height = std::min( mContactCardLayoutInfo.foldedSize.width, mContactCardLayoutInfo.foldedSize.height ); | |
| 72 | + | |
| 73 | + // Set the size and positions of the header | |
| 74 | + mContactCardLayoutInfo.headerSize.width = mContactCardLayoutInfo.unfoldedSize.width; | |
| 75 | + mContactCardLayoutInfo.headerSize.height = mContactCardLayoutInfo.unfoldedSize.height * HEADER_HEIGHT_TO_UNFOLDED_SIZE_RATIO; | |
| 76 | + mContactCardLayoutInfo.headerFoldedPosition = mContactCardLayoutInfo.headerSize * HEADER_FOLDED_POSITION_AS_RATIO_OF_SIZE; | |
| 77 | + mContactCardLayoutInfo.headerUnfoldedPosition = HEADER_UNFOLDED_POSITION; | |
| 78 | + | |
| 79 | + // Set the image size and positions | |
| 80 | + mContactCardLayoutInfo.imageSize = mContactCardLayoutInfo.foldedSize * IMAGE_SIZE_AS_RATIO_TO_FOLDED_SIZE; | |
| 81 | + mContactCardLayoutInfo.imageFoldedPosition = mContactCardLayoutInfo.imageSize * IMAGE_FOLDED_POSITION_AS_RATIO_OF_SIZE; | |
| 82 | + mContactCardLayoutInfo.imageUnfoldedPosition.x = mContactCardLayoutInfo.padding.width; | |
| 83 | + mContactCardLayoutInfo.imageUnfoldedPosition.y = mContactCardLayoutInfo.headerSize.height + mContactCardLayoutInfo.padding.height; | |
| 84 | + | |
| 85 | + // Set the positions of the contact name | |
| 86 | + mContactCardLayoutInfo.textFoldedPosition.x = 0.0f; | |
| 87 | + mContactCardLayoutInfo.textFoldedPosition.y = mContactCardLayoutInfo.imageFoldedPosition.x + mContactCardLayoutInfo.imageSize.height * FOLDED_TEXT_POSITION_AS_RATIO_OF_IMAGE_SIZE; | |
| 88 | + mContactCardLayoutInfo.textUnfoldedPosition.x = mContactCardLayoutInfo.padding.width; | |
| 89 | + mContactCardLayoutInfo.textUnfoldedPosition.y = mContactCardLayoutInfo.imageUnfoldedPosition.y + mContactCardLayoutInfo.imageSize.height + mContactCardLayoutInfo.padding.height; | |
| 90 | + | |
| 91 | + // Figure out the positions of the contact cards | |
| 92 | + mItemsPerRow = ( mContactCardLayoutInfo.unfoldedSize.width + mContactCardLayoutInfo.padding.width ) / ( mContactCardLayoutInfo.foldedSize.width + mContactCardLayoutInfo.padding.width ); | |
| 93 | + mLastPosition = mContactCardLayoutInfo.unfoldedPosition; | |
| 94 | + mPositionIncrementer.x = mContactCardLayoutInfo.foldedSize.width + mContactCardLayoutInfo.padding.width; | |
| 95 | + mPositionIncrementer.y = mContactCardLayoutInfo.foldedSize.height + mContactCardLayoutInfo.padding.height; | |
| 96 | + | |
| 97 | + mInitialized = true; | |
| 98 | + } | |
| 99 | + | |
| 100 | + // Create a new contact card and add to our container | |
| 101 | + mContactCards.push_back( new ContactCard( mContactCardLayoutInfo, contactName, contactAddress, imagePath, NextCardPosition() ) ); | |
| 102 | +} | |
| 103 | + | |
| 104 | +const Vector2& ContactCardLayouter::NextCardPosition() | |
| 105 | +{ | |
| 106 | + size_t currentNumOfCards = mContactCards.size(); | |
| 107 | + | |
| 108 | + if( currentNumOfCards ) | |
| 109 | + { | |
| 110 | + if( currentNumOfCards % mItemsPerRow ) | |
| 111 | + { | |
| 112 | + mLastPosition.x += mPositionIncrementer.x; | |
| 113 | + } | |
| 114 | + else // go to the next row | |
| 115 | + { | |
| 116 | + mLastPosition.x = mContactCardLayoutInfo.unfoldedPosition.x; | |
| 117 | + mLastPosition.y += mPositionIncrementer.y; | |
| 118 | + } | |
| 119 | + } | |
| 120 | + return mLastPosition; | |
| 121 | +} | ... | ... |
examples/contact-cards/contact-card-layouter.h
0 → 100644
| 1 | +#ifndef CONTACT_CARD_LAYOUTER_H | |
| 2 | +#define CONTACT_CARD_LAYOUTER_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2016 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 <vector> | |
| 23 | +#include <string> | |
| 24 | +#include <dali/public-api/common/intrusive-ptr.h> | |
| 25 | +#include <dali/public-api/math/vector2.h> | |
| 26 | + | |
| 27 | +// INTERNAL INCLUDES | |
| 28 | +#include "contact-card-layout-info.h" | |
| 29 | + | |
| 30 | +class ContactCard; | |
| 31 | + | |
| 32 | +/** | |
| 33 | + * @brief This class lays out contact cards on the screen appropriately. | |
| 34 | + * | |
| 35 | + * The contact cards are added to the stage directly and it uses the stage size to figure out exactly how to layout them. | |
| 36 | + * It supports a minimum of 3 items on each row or column. | |
| 37 | + * | |
| 38 | + * Relayouting is not supported. | |
| 39 | + */ | |
| 40 | +class ContactCardLayouter | |
| 41 | +{ | |
| 42 | +public: | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * @brief Constructor. | |
| 46 | + */ | |
| 47 | + ContactCardLayouter(); | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * @brief Destructor. | |
| 51 | + */ | |
| 52 | + ~ContactCardLayouter(); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * @brief Creates a contact card with the given information. | |
| 56 | + * @param[in] contactName The name of the contact to display. | |
| 57 | + * @param[in] contactAddress The address of the contact to display. | |
| 58 | + * @param[in] imagePath The path to the image to display. | |
| 59 | + */ | |
| 60 | + void AddContact( const std::string& contactName, const std::string& contactAddress, const std::string& imagePath ); | |
| 61 | + | |
| 62 | +private: | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * @brief Calculates the next position of the contact card that's about to be added to our container. | |
| 66 | + * @return A reference to the next position. | |
| 67 | + */ | |
| 68 | + const Dali::Vector2& NextCardPosition(); | |
| 69 | + | |
| 70 | + ContactCardLayoutInfo mContactCardLayoutInfo; ///< The common layouting information used by all contact cards. Set up when AddContact is first called. | |
| 71 | + | |
| 72 | + typedef Dali::IntrusivePtr< ContactCard > ContactCardPtr; ///< Better than raw pointers as these are ref counted and the memory is released when the count reduces to 0. | |
| 73 | + typedef std::vector< ContactCardPtr > ContactCardContainer; | |
| 74 | + ContactCardContainer mContactCards; ///< Contains all the contact cards. | |
| 75 | + | |
| 76 | + Dali::Vector2 mLastPosition; ///< The last position a contact card was added. | |
| 77 | + Dali::Vector2 mPositionIncrementer; ///< Calculated once when AddContact is first called. | |
| 78 | + size_t mItemsPerRow; ///< Calculated once when AddContact is first called and stores the number of items we have in a row. | |
| 79 | + | |
| 80 | + bool mInitialized; ///< Whether initialization has taken place or not. | |
| 81 | +}; | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | +#endif // CONTACT_CARD_LAYOUTER_H | ... | ... |
examples/contact-cards/contact-card.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 "contact-card.h" | |
| 20 | + | |
| 21 | +// EXTERNAL INCLUDES | |
| 22 | +#include <dali-toolkit/dali-toolkit.h> | |
| 23 | + | |
| 24 | +// INTERNAL INCLUDES | |
| 25 | +#include "contact-card-layout-info.h" | |
| 26 | +#include "clipped-image.h" | |
| 27 | + | |
| 28 | +using namespace Dali; | |
| 29 | +using namespace Dali::Toolkit; | |
| 30 | + | |
| 31 | +namespace | |
| 32 | +{ | |
| 33 | +/* | |
| 34 | + * The constants below are used to create the following Unfold Animation. | |
| 35 | + * | |
| 36 | + * 0ms 50 100 150 200 250 300 350 400 Total Animation time in Milliseconds | |
| 37 | + * | | | | | | | | | | |
| 38 | + * o-----------------------------------o | X Position Animation ( 0ms To 360ms) | |
| 39 | + * | o-----------------------------------o Y Position Animation (40ms To 400ms) | |
| 40 | + * o-----------------------------------o | Width Animation ( 0ms To 360ms) | |
| 41 | + * | o-----------------------------------o Height Animation (40ms To 400ms) | |
| 42 | + * o-------o | | | | | | | Fade out Name Text Animation ( 0ms To 80ms) | |
| 43 | + * | o-------o | | | | | Fade in Details Text Animation (80ms To 160ms) | |
| 44 | + * o---------------o | | | | | Fade out other cards Animation ( 0ms To 160ms) | |
| 45 | + * o---------------------------------------o Mesh Morph Animation ( 0ms To 400ms) | |
| 46 | + */ | |
| 47 | +const TimePeriod TIME_PERIOD_UNFOLD_X( 0.0f, 0.36f ); ///< Start at 0ms, duration 360ms | |
| 48 | +const TimePeriod TIME_PERIOD_UNFOLD_Y( 0.04f, 0.36f ); ///< Start at 40ms, duration 360ms | |
| 49 | +const TimePeriod TIME_PERIOD_UNFOLD_WIDTH( 0.0f, 0.36f ); ///< Start at 0ms, duration 360ms | |
| 50 | +const TimePeriod TIME_PERIOD_UNFOLD_HEIGHT( 0.04f, 0.36f ); ///< Start at 40ms, duration 360ms | |
| 51 | +const TimePeriod TIME_PERIOD_UNFOLD_NAME_OPACITY( 0.0f, 0.08f ); ///< Start at 0ms, duration 80ms | |
| 52 | +const TimePeriod TIME_PERIOD_UNFOLD_DETAIL_OPACITY( 0.08f, 0.08f ); ///< Start at 80ms, duration 80ms | |
| 53 | +const TimePeriod TIME_PERIOD_UNFOLD_SIBLING_OPACITY( 0.0f, 0.08f ); ///< Start at 0ms, duration 80ms | |
| 54 | +const TimePeriod TIME_PERIOD_UNFOLD_MESH_MORPH( 0.0f, 0.4f ); ///< Start at 0ms, duration 400ms | |
| 55 | + | |
| 56 | +/* | |
| 57 | + * The constants below are used to create the following Fold Animation: | |
| 58 | + * | |
| 59 | + * 0ms 50 100 150 200 250 300 350 400 Total Animation time in Milliseconds | |
| 60 | + * | | | | | | | | | | |
| 61 | + * | |o---------------------------------o X Position Animation ( 64ms To 400ms) | |
| 62 | + * o---------------------------------o| | Y Position Animation ( 0ms To 336ms) | |
| 63 | + * | |o---------------------------------o Width Animation ( 64ms To 400ms) | |
| 64 | + * o---------------------------------o| | Height Animation ( 0ms To 336ms) | |
| 65 | + * | o-------o | | | | | Fade in Name Text animation ( 80ms To 160ms) | |
| 66 | + * o-------o | | | | | | | Fade out Details Text animation ( 0ms To 80ms) | |
| 67 | + * | | | | | | | o-------o Fade in other cards animation (320ms To 400ms) | |
| 68 | + * o---------------------------------------o Morph Animation ( 0ms To 400ms) | |
| 69 | + */ | |
| 70 | +const TimePeriod TIME_PERIOD_FOLD_X( 0.064f, 0.336f ); ///< Start at 64ms, duration 336ms | |
| 71 | +const TimePeriod TIME_PERIOD_FOLD_Y( 0.0f, 0.336f ); ///< Start at 0ms, duration 336ms | |
| 72 | +const TimePeriod TIME_PERIOD_FOLD_WIDTH( 0.064f, 0.336f ); ///< Start at 64ms, duration 336ms | |
| 73 | +const TimePeriod TIME_PERIOD_FOLD_HEIGHT( 0.0f, 0.336f ); ///< Start at 0ms, duration 336ms | |
| 74 | +const TimePeriod TIME_PERIOD_FOLD_NAME_OPACITY( 0.08f, 0.08f ); ///< Start at 80ms, duration 80ms | |
| 75 | +const TimePeriod TIME_PERIOD_FOLD_DETAIL_OPACITY( 0.0f, 0.08f ); ///< Start at 0ms, duration 80ms | |
| 76 | +const TimePeriod TIME_PERIOD_FOLD_SIBLING_OPACITY( 0.32f, 0.08f ); ///< Start at 320ms, duration 80ms | |
| 77 | +const TimePeriod TIME_PERIOD_FOLD_MESH_MORPH( 0.0f, 0.4f ); ///< Start at 0ms, duration 400ms | |
| 78 | + | |
| 79 | +AlphaFunction ALPHA_FUNCTION_UNFOLD( AlphaFunction::DEFAULT ); ///< Alpha function used for the Unfold Animation | |
| 80 | +AlphaFunction ALPHA_FUNCTION_FOLD( AlphaFunction::EASE_IN_OUT ); ///< Alpha function used for the Fold Animation | |
| 81 | + | |
| 82 | +const Vector4 HEADER_COLOR( 231.0f/255.0f, 231.0f/255.0f, 231.0f/255.0f, 1.0f ); ///< The color of the header | |
| 83 | + | |
| 84 | +} // unnamed namespace | |
| 85 | + | |
| 86 | +ContactCard::ContactCard( | |
| 87 | + const ContactCardLayoutInfo& contactCardLayoutInfo, | |
| 88 | + const std::string& contactName, | |
| 89 | + const std::string& contactAddress, | |
| 90 | + const std::string& imagePath, | |
| 91 | + const Vector2& position ) | |
| 92 | +: mTapDetector(), | |
| 93 | + mContactCard(), | |
| 94 | + mHeader(), | |
| 95 | + mClippedImage(), | |
| 96 | + mNameText(), | |
| 97 | + mDetailText(), | |
| 98 | + mSlotDelegate( this ), | |
| 99 | + mContactCardLayoutInfo( contactCardLayoutInfo ), | |
| 100 | + foldedPosition( position ), | |
| 101 | + mClippedImagePropertyIndex( Property::INVALID_INDEX ), | |
| 102 | + mFolded( true ) | |
| 103 | +{ | |
| 104 | + // Create a control which will be used for the background and to clip the contents | |
| 105 | + mContactCard = Control::New(); | |
| 106 | + mContactCard.SetProperty( Control::Property::BACKGROUND, | |
| 107 | + Property::Map().Add( Visual::Property::TYPE, Visual::COLOR ) | |
| 108 | + .Add( ColorVisual::Property::MIX_COLOR, Color::WHITE ) ); | |
| 109 | + mContactCard.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); | |
| 110 | + mContactCard.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 111 | + mContactCard.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 112 | + mContactCard.SetPosition( foldedPosition.x, foldedPosition.y ); | |
| 113 | + mContactCard.SetSize( mContactCardLayoutInfo.foldedSize ); | |
| 114 | + Stage::GetCurrent().Add( mContactCard ); | |
| 115 | + | |
| 116 | + // Create the header which will be shown only when the contact is unfolded | |
| 117 | + mHeader = Control::New(); | |
| 118 | + mHeader.SetSize( mContactCardLayoutInfo.headerSize ); | |
| 119 | + mHeader.SetProperty( Control::Property::BACKGROUND, | |
| 120 | + Property::Map().Add( Visual::Property::TYPE, Visual::COLOR ) | |
| 121 | + .Add( ColorVisual::Property::MIX_COLOR, HEADER_COLOR ) ); | |
| 122 | + mHeader.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 123 | + mHeader.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 124 | + mHeader.SetPosition( mContactCardLayoutInfo.headerFoldedPosition.x, mContactCardLayoutInfo.headerFoldedPosition.y ); | |
| 125 | + | |
| 126 | + // Create a clipped image (whose clipping can be animated) | |
| 127 | + mClippedImage = ClippedImage::Create( imagePath, mClippedImagePropertyIndex ); | |
| 128 | + mClippedImage.SetSize( mContactCardLayoutInfo.imageSize ); | |
| 129 | + mClippedImage.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 130 | + mClippedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 131 | + mClippedImage.SetPosition( mContactCardLayoutInfo.imageFoldedPosition.x, mContactCardLayoutInfo.imageFoldedPosition.y ); | |
| 132 | + mContactCard.Add( mClippedImage ); | |
| 133 | + | |
| 134 | + // Add the text label for just the name | |
| 135 | + mNameText = TextLabel::New( contactName ); | |
| 136 | + mNameText.SetStyleName( "ContactNameTextLabel" ); | |
| 137 | + mNameText.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 138 | + mNameText.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 139 | + mNameText.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 140 | + mNameText.SetPosition( mContactCardLayoutInfo.textFoldedPosition.x, mContactCardLayoutInfo.textFoldedPosition.y ); | |
| 141 | + mContactCard.Add( mNameText ); | |
| 142 | + | |
| 143 | + // Create the detail text-label | |
| 144 | + std::string detailString( contactName ); | |
| 145 | + detailString += "\n\n"; | |
| 146 | + detailString += contactAddress; | |
| 147 | + | |
| 148 | + mDetailText = TextLabel::New( detailString ); | |
| 149 | + mDetailText.SetStyleName( "ContactDetailTextLabel" ); | |
| 150 | + mDetailText.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 151 | + mDetailText.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 152 | + mDetailText.SetPosition( mContactCardLayoutInfo.textFoldedPosition.x, mContactCardLayoutInfo.textFoldedPosition.y ); | |
| 153 | + mDetailText.SetSize( Vector2( mContactCardLayoutInfo.unfoldedSize.width - mContactCardLayoutInfo.textFoldedPosition.x * 2.0f, 0.0f ) ); | |
| 154 | + mDetailText.SetOpacity( 0.0f ); | |
| 155 | + | |
| 156 | + // Attach tap detection to the overall clip control | |
| 157 | + mTapDetector = TapGestureDetector::New(); | |
| 158 | + mTapDetector.Attach( mContactCard ); | |
| 159 | + mTapDetector.DetectedSignal().Connect( mSlotDelegate, &ContactCard::OnTap ); | |
| 160 | +} | |
| 161 | + | |
| 162 | +ContactCard::~ContactCard() | |
| 163 | +{ | |
| 164 | + if( mContactCard ) | |
| 165 | + { | |
| 166 | + mContactCard.Unparent(); | |
| 167 | + } | |
| 168 | +} | |
| 169 | + | |
| 170 | +void ContactCard::OnTap( Actor actor, const TapGesture& gesture ) | |
| 171 | +{ | |
| 172 | + if( mFolded ) | |
| 173 | + { | |
| 174 | + mContactCard.Add( mHeader ); | |
| 175 | + mContactCard.Add( mDetailText ); | |
| 176 | + | |
| 177 | + // Animate the size of the control (and clipping area) | |
| 178 | + Animation animation = Animation::New( 0.0f ); // Overall duration is unimportant as superseded by TimePeriods set later | |
| 179 | + animation.AnimateTo( Property( mContactCard, Actor::Property::POSITION_X ), mContactCardLayoutInfo.unfoldedPosition.x, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_X ); | |
| 180 | + animation.AnimateTo( Property( mContactCard, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.unfoldedPosition.y, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_Y ); | |
| 181 | + animation.AnimateTo( Property( mContactCard, Actor::Property::SIZE_WIDTH ), mContactCardLayoutInfo.unfoldedSize.width, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_WIDTH ); | |
| 182 | + animation.AnimateTo( Property( mContactCard, Actor::Property::SIZE_HEIGHT ), mContactCardLayoutInfo.unfoldedSize.height, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_HEIGHT ); | |
| 183 | + | |
| 184 | + // Animate the header area into position | |
| 185 | + animation.AnimateTo( Property( mHeader, Actor::Property::POSITION_X ), mContactCardLayoutInfo.headerUnfoldedPosition.x, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_X ); | |
| 186 | + animation.AnimateTo( Property( mHeader, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.headerUnfoldedPosition.y, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_Y ); | |
| 187 | + | |
| 188 | + // Animate the clipped image into the unfolded position and into a quad | |
| 189 | + animation.AnimateTo( Property( mClippedImage, Actor::Property::POSITION_X ), mContactCardLayoutInfo.imageUnfoldedPosition.x, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_X ); | |
| 190 | + animation.AnimateTo( Property( mClippedImage, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.imageUnfoldedPosition.y, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_Y ); | |
| 191 | + animation.AnimateTo( Property( mClippedImage, mClippedImagePropertyIndex ), ClippedImage::QUAD_GEOMETRY, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_MESH_MORPH ); | |
| 192 | + | |
| 193 | + // Fade out the opacity of the name, and animate into the unfolded position | |
| 194 | + animation.AnimateTo( Property( mNameText, Actor::Property::COLOR_ALPHA ), 0.0f, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_NAME_OPACITY ); | |
| 195 | + animation.AnimateTo( Property( mNameText, Actor::Property::POSITION_X ), mContactCardLayoutInfo.textUnfoldedPosition.x, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_X ); | |
| 196 | + animation.AnimateTo( Property( mNameText, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.textUnfoldedPosition.y, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_Y ); | |
| 197 | + | |
| 198 | + // Fade in the opacity of the detail, and animate into the unfolded position | |
| 199 | + animation.AnimateTo( Property( mDetailText, Actor::Property::COLOR_ALPHA ), 1.0f, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_DETAIL_OPACITY ); | |
| 200 | + animation.AnimateTo( Property( mDetailText, Actor::Property::POSITION_X ), mContactCardLayoutInfo.textUnfoldedPosition.x, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_X ); | |
| 201 | + animation.AnimateTo( Property( mDetailText, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.textUnfoldedPosition.y, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_Y ); | |
| 202 | + | |
| 203 | + // Fade out all the siblings | |
| 204 | + Actor parent = actor.GetParent(); | |
| 205 | + for( size_t i = 0; i < parent.GetChildCount(); ++i ) | |
| 206 | + { | |
| 207 | + Actor sibling = parent.GetChildAt( i ); | |
| 208 | + if( sibling != actor ) | |
| 209 | + { | |
| 210 | + animation.AnimateTo( Property( sibling, Actor::Property::COLOR_ALPHA ), 0.0f, ALPHA_FUNCTION_UNFOLD, TIME_PERIOD_UNFOLD_SIBLING_OPACITY ); | |
| 211 | + sibling.SetSensitive( false ); | |
| 212 | + } | |
| 213 | + } | |
| 214 | + | |
| 215 | + animation.FinishedSignal().Connect( mSlotDelegate, &ContactCard::OnAnimationFinished ); | |
| 216 | + animation.Play(); | |
| 217 | + } | |
| 218 | + else | |
| 219 | + { | |
| 220 | + mContactCard.Add( mNameText ); | |
| 221 | + | |
| 222 | + // Animate the size of the control (and clipping area) | |
| 223 | + Animation animation = Animation::New( 0.0f ); // Overall duration is unimportant as superseded by TimePeriods set later | |
| 224 | + animation.AnimateTo( Property( mContactCard, Actor::Property::POSITION_X ), foldedPosition.x, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_X ); | |
| 225 | + animation.AnimateTo( Property( mContactCard, Actor::Property::POSITION_Y ), foldedPosition.y, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_Y ); | |
| 226 | + animation.AnimateTo( Property( mContactCard, Actor::Property::SIZE_WIDTH ), mContactCardLayoutInfo.foldedSize.width, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_WIDTH ); | |
| 227 | + animation.AnimateTo( Property( mContactCard, Actor::Property::SIZE_HEIGHT ), mContactCardLayoutInfo.foldedSize.height, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_HEIGHT ); | |
| 228 | + | |
| 229 | + // Animate the header area out of position | |
| 230 | + animation.AnimateTo( Property( mHeader, Actor::Property::POSITION_X ), mContactCardLayoutInfo.headerFoldedPosition.x, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_X ); | |
| 231 | + animation.AnimateTo( Property( mHeader, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.headerFoldedPosition.y, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_Y ); | |
| 232 | + | |
| 233 | + // Animate the clipped image into the folded position and into a circle | |
| 234 | + animation.AnimateTo( Property( mClippedImage, Actor::Property::POSITION_X ), mContactCardLayoutInfo.imageFoldedPosition.x, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_X ); | |
| 235 | + animation.AnimateTo( Property( mClippedImage, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.imageFoldedPosition.y, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_Y ); | |
| 236 | + animation.AnimateTo( Property( mClippedImage, mClippedImagePropertyIndex ), ClippedImage::CIRCLE_GEOMETRY, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_MESH_MORPH ); | |
| 237 | + | |
| 238 | + // Fade in the opacity of the name, and animate into the folded position | |
| 239 | + animation.AnimateTo( Property( mNameText, Actor::Property::COLOR_ALPHA ), 1.0f, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_NAME_OPACITY ); | |
| 240 | + animation.AnimateTo( Property( mNameText, Actor::Property::POSITION_X ), mContactCardLayoutInfo.textFoldedPosition.x, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_X ); | |
| 241 | + animation.AnimateTo( Property( mNameText, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.textFoldedPosition.y, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_Y ); | |
| 242 | + | |
| 243 | + // Fade out the opacity of the detail, and animate into the folded position | |
| 244 | + animation.AnimateTo( Property( mDetailText, Actor::Property::COLOR_ALPHA ), 0.0f, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_DETAIL_OPACITY ); | |
| 245 | + animation.AnimateTo( Property( mDetailText, Actor::Property::POSITION_X ), mContactCardLayoutInfo.textFoldedPosition.x, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_X ); | |
| 246 | + animation.AnimateTo( Property( mDetailText, Actor::Property::POSITION_Y ), mContactCardLayoutInfo.textFoldedPosition.y, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_Y ); | |
| 247 | + | |
| 248 | + // Slowly fade in all the siblings | |
| 249 | + Actor parent = actor.GetParent(); | |
| 250 | + for( size_t i = 0; i < parent.GetChildCount(); ++i ) | |
| 251 | + { | |
| 252 | + Actor sibling = parent.GetChildAt( i ); | |
| 253 | + if( sibling != actor ) | |
| 254 | + { | |
| 255 | + animation.AnimateTo( Property( sibling, Actor::Property::COLOR_ALPHA ), 1.0f, ALPHA_FUNCTION_FOLD, TIME_PERIOD_FOLD_SIBLING_OPACITY ); | |
| 256 | + sibling.SetSensitive( true ); | |
| 257 | + } | |
| 258 | + } | |
| 259 | + | |
| 260 | + animation.FinishedSignal().Connect( mSlotDelegate, &ContactCard::OnAnimationFinished ); | |
| 261 | + animation.Play(); | |
| 262 | + } | |
| 263 | + | |
| 264 | + mFolded = !mFolded; | |
| 265 | +} | |
| 266 | + | |
| 267 | +void ContactCard::OnAnimationFinished( Dali::Animation& animation ) | |
| 268 | +{ | |
| 269 | + if( mFolded ) | |
| 270 | + { | |
| 271 | + mHeader.Unparent(); | |
| 272 | + mDetailText.Unparent(); | |
| 273 | + } | |
| 274 | + else | |
| 275 | + { | |
| 276 | + mNameText.Unparent(); | |
| 277 | + } | |
| 278 | +} | ... | ... |
examples/contact-cards/contact-card.h
0 → 100644
| 1 | +#ifndef CONTACT_CARD_H | |
| 2 | +#define CONTACT_CARD_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2016 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 <string> | |
| 23 | +#include <dali/public-api/actors/actor.h> | |
| 24 | +#include <dali/public-api/events/tap-gesture-detector.h> | |
| 25 | +#include <dali/public-api/object/ref-object.h> | |
| 26 | +#include <dali-toolkit/public-api/controls/control.h> | |
| 27 | + | |
| 28 | +class ContactCardLayoutInfo; | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * @brief Creates and sets up animations for a contact card | |
| 32 | + * | |
| 33 | + * Each contact card has two states, folded and unfolded. | |
| 34 | + * In this context, "unfolded" means when all the details, including the name, address and image are shown. | |
| 35 | + * In this scenario, the control takes up most of the screen. | |
| 36 | + * | |
| 37 | + * When the contact card is "folded", this means when only brief information is shown to the user, i.e. the image and name. | |
| 38 | + * In this scenario, the control is small and there should be several of these contact cards visible on the screen. | |
| 39 | + * | |
| 40 | + * The contact card creates several controls that it requires to appropriately display itself in both of these states. | |
| 41 | + */ | |
| 42 | +class ContactCard : public Dali::RefObject | |
| 43 | +{ | |
| 44 | +public: | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * @brief Constructor. | |
| 48 | + * | |
| 49 | + * This will create all the controls and add them to the stage so should only be called after the init-signal from the Application has been received. | |
| 50 | + * | |
| 51 | + * @param[in] contactCardLayoutInfo Reference to the common data used by all contact cards. | |
| 52 | + * @param[in] contactName The name of the contact to display. | |
| 53 | + * @param[in] contactAddress The address of the contact to display. | |
| 54 | + * @param[in] imagePath The path to the image to display. | |
| 55 | + * @param[in] position The unique folded position of this particular contact-card. | |
| 56 | + */ | |
| 57 | + ContactCard( const ContactCardLayoutInfo& contactCardLayoutInfo, const std::string& contactName, const std::string& contactAddress, const std::string& imagePath, const Dali::Vector2& position ); | |
| 58 | + | |
| 59 | +private: | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * @brief Private Destructor. Will only be deleted when ref-count goes to 0. | |
| 63 | + * | |
| 64 | + * Unparent the created contact card (i.e. remove from stage). | |
| 65 | + */ | |
| 66 | + ~ContactCard(); | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * @brief Called when this contact card is tapped. | |
| 70 | + * @param[in] actor The tapped actor. | |
| 71 | + * @param[in] gesture The tap gesture. | |
| 72 | + */ | |
| 73 | + void OnTap( Dali::Actor actor, const Dali::TapGesture& gesture ); | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * @brief Called when the animation finishes. | |
| 77 | + * @param[in] animation The animation which has just finished. | |
| 78 | + */ | |
| 79 | + void OnAnimationFinished( Dali::Animation& animation ); | |
| 80 | + | |
| 81 | + Dali::TapGestureDetector mTapDetector; ///< Used for tap detection. | |
| 82 | + Dali::Toolkit::Control mContactCard; ///< Used for the background and to clip the contents. | |
| 83 | + Dali::Toolkit::Control mHeader; ///< Header shown when unfolded. | |
| 84 | + Dali::Toolkit::Control mClippedImage; ///< The image representing the contact (whose clipping can be animated). | |
| 85 | + Dali::Toolkit::Control mNameText; ///< The text shown when folded. | |
| 86 | + Dali::Toolkit::Control mDetailText; ///< The text shown when unfolded. | |
| 87 | + | |
| 88 | + Dali::SlotDelegate< ContactCard > mSlotDelegate; ///< Used to automatically disconnect our member functions from signals that this class connects to upon destruction. Can be used instead of inheriting from ConnectionTracker. | |
| 89 | + | |
| 90 | + const ContactCardLayoutInfo& mContactCardLayoutInfo; ///< Reference to the common data used by all contact cards. | |
| 91 | + const Dali::Vector2 foldedPosition; ///< The unique position of this card when it is folded. | |
| 92 | + Dali::Property::Index mClippedImagePropertyIndex; ///< Index used to animate the clipping of mClippedImage. | |
| 93 | + bool mFolded; ///< Whether the contact card is folded or not. | |
| 94 | +}; | |
| 95 | + | |
| 96 | +#endif // CONTACT_CARD_H | ... | ... |
examples/contact-cards/contact-cards-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 <vector> | |
| 20 | +#include <dali/public-api/adaptor-framework/application.h> | |
| 21 | +#include <dali/public-api/adaptor-framework/key.h> | |
| 22 | +#include <dali/public-api/common/stage.h> | |
| 23 | +#include <dali/public-api/events/key-event.h> | |
| 24 | + | |
| 25 | +// INTERNAL INCLUDES | |
| 26 | +#include "contact-card-layouter.h" | |
| 27 | +#include "contact-data.h" | |
| 28 | + | |
| 29 | +using namespace Dali; | |
| 30 | + | |
| 31 | +namespace | |
| 32 | +{ | |
| 33 | +const Vector4 STAGE_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the stage | |
| 34 | +const char * const THEME_PATH( DEMO_STYLE_DIR "contact-cards-example-theme.json" ); ///< The theme used for this example | |
| 35 | +} // unnamed namespace | |
| 36 | + | |
| 37 | +/** | |
| 38 | + * @brief Creates several contact cards that animate between a folded and unfolded state. | |
| 39 | + * | |
| 40 | + * This demonstrates how different animations can start and stop at different times within the same Animation function. | |
| 41 | + * Additionally, this also shows how to morph between two different geometries. | |
| 42 | + * | |
| 43 | + * ContactCardLayouter: This class is used to lay out the different contact cards on the screen. | |
| 44 | + * This takes stage size into account but does not support relayouting. | |
| 45 | + * ContactCard: This class represents each contact card on the screen. | |
| 46 | + * Two animations are set up in this class which animate several properties with multiple start and stop times. | |
| 47 | + * An overview of the two animations can be found in contact-card.cpp. | |
| 48 | + * ContactCardLayoutInfo: This is a structure to store common layout information and is created by the ContactCardLayouter and used by each ContactCard. | |
| 49 | + * ContactData: This namespace contains a table which has the contact information we use to populate the contact cards. | |
| 50 | + * ClippedImage: This namespace provides a helper function which creates an ImageView which is added to a control that has clipping. | |
| 51 | + * This clipping comes in the form of a Circle or Quad. | |
| 52 | + * The Vertex shader mixes in the Circle and Quad geometry depending on the value of a uniform float. | |
| 53 | + * Animating this float between CIRCLE_GEOMETRY and QUAD_GEOMETRY is what enables the morphing between the two geometries. | |
| 54 | + */ | |
| 55 | +class ContactCardController : public ConnectionTracker // Inherit from ConnectionTracker so that our signals can be automatically disconnected upon our destruction. | |
| 56 | +{ | |
| 57 | +public: | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * @brief Constructor. | |
| 61 | + * @param[in] application A reference to the Application class. | |
| 62 | + */ | |
| 63 | + ContactCardController( Application& application ) | |
| 64 | + : mApplication( application ) | |
| 65 | + { | |
| 66 | + // Connect to the Application's Init signal | |
| 67 | + mApplication.InitSignal().Connect( this, &ContactCardController::Create ); | |
| 68 | + } | |
| 69 | + | |
| 70 | +private: | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * @brief Called to initialise the application content | |
| 74 | + * @param[in] application A reference to the Application class. | |
| 75 | + */ | |
| 76 | + void Create( Application& application ) | |
| 77 | + { | |
| 78 | + // Hide the indicator bar | |
| 79 | + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); | |
| 80 | + | |
| 81 | + // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit. | |
| 82 | + Stage stage = Stage::GetCurrent(); | |
| 83 | + stage.SetBackgroundColor( STAGE_COLOR ); | |
| 84 | + stage.KeyEventSignal().Connect( this, &ContactCardController::OnKeyEvent ); | |
| 85 | + | |
| 86 | + // Add all the contacts to the layouter | |
| 87 | + for( size_t i = 0; i < ContactData::TABLE_SIZE; ++i ) | |
| 88 | + { | |
| 89 | + mContactCardLayouter.AddContact( ContactData::TABLE[ i ].name, ContactData::TABLE[ i ].address, ContactData::TABLE[ i ].imagePath ); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * @brief Called when any key event is received | |
| 95 | + * | |
| 96 | + * Will use this to quit the application if Back or the Escape key is received | |
| 97 | + * @param[in] event The key event information | |
| 98 | + */ | |
| 99 | + void OnKeyEvent( const KeyEvent& event ) | |
| 100 | + { | |
| 101 | + if( event.state == KeyEvent::Down ) | |
| 102 | + { | |
| 103 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 104 | + { | |
| 105 | + mApplication.Quit(); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 110 | + Application& mApplication; ///< Reference to the application class. | |
| 111 | + ContactCardLayouter mContactCardLayouter; ///< The contact card layouter. | |
| 112 | +}; | |
| 113 | + | |
| 114 | +int DALI_EXPORT_API main( int argc, char **argv ) | |
| 115 | +{ | |
| 116 | + Application application = Application::New( &argc, &argv, THEME_PATH ); | |
| 117 | + ContactCardController contactCardController( application ); | |
| 118 | + application.MainLoop(); | |
| 119 | + return 0; | |
| 120 | +} | ... | ... |
examples/contact-cards/contact-data.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 | +// HEADER | |
| 19 | +#include "contact-data.h" | |
| 20 | + | |
| 21 | +namespace ContactData | |
| 22 | +{ | |
| 23 | + | |
| 24 | +const Item TABLE[] = | |
| 25 | +{ | |
| 26 | + { "Shelia Ramos", "19 Wormley Ct\nWinters Way\nWaltham Abbey\nEN9 3HW", DEMO_IMAGE_DIR "gallery-small-19.jpg" }, | |
| 27 | + { "Walter Jensen", "32 Upper Fant Rd\nMaidstone\nME16 8DN", DEMO_IMAGE_DIR "gallery-small-2.jpg" }, | |
| 28 | + { "Randal Parks", "8 Rymill St\nLondon\nE16 2JF", DEMO_IMAGE_DIR "gallery-small-3.jpg" }, | |
| 29 | + { "Tasha Cooper", "2 Kyles View\nColintraive\nPA22 3AS", DEMO_IMAGE_DIR "gallery-small-4.jpg" }, | |
| 30 | + { "Domingo Lynch", "Red Lion Farm\nWatlington\nOX49 5LG", DEMO_IMAGE_DIR "gallery-small-5.jpg" }, | |
| 31 | + { "Dan Haynes", "239 Whitefield Dr\nLiverpool\nL32 0RD", DEMO_IMAGE_DIR "gallery-small-6.jpg" }, | |
| 32 | + { "Leslie Wong", "1 Tullyvar Rd\nAughnacloy\nBT69 6BQ", DEMO_IMAGE_DIR "gallery-small-7.jpg" }, | |
| 33 | + { "Mable Hodges", "5 Mortimer Rd\nGrazeley\nReading\nRG7 1LA", DEMO_IMAGE_DIR "gallery-small-8.jpg" }, | |
| 34 | + { "Kristi Riley", "10 Jura Dr\nOld Kilpatrick\nGlasgow\nG60 5EH", DEMO_IMAGE_DIR "gallery-small-17.jpg" }, | |
| 35 | + { "Terry Clark", "142 Raeberry St\nGlasgow\nG20 6EA", DEMO_IMAGE_DIR "gallery-small-18.jpg" }, | |
| 36 | + { "Horace Bailey", "11 Assembly St\nNormanton\nWF6 2DB", DEMO_IMAGE_DIR "gallery-small-11.jpg" }, | |
| 37 | + { "Suzanne Delgado", "6 Grange Rd\nDownpatrick\nBT30 7DB", DEMO_IMAGE_DIR "gallery-small-12.jpg" }, | |
| 38 | + { "Jamie Bennett", "117 Potter St\nNorthwood\nHA6 1QF", DEMO_IMAGE_DIR "gallery-small-13.jpg" }, | |
| 39 | + { "Emmett Yates", "18 Renfrew Way\nBletchley\nMilton Keynes\nMK3 7NY", DEMO_IMAGE_DIR "gallery-small-14.jpg" }, | |
| 40 | + { "Glen Vaughn", "5 Hasman Terrace\nCove Bay\nAberdeen\nAB12 3GD", DEMO_IMAGE_DIR "gallery-small-15.jpg" }, | |
| 41 | +}; | |
| 42 | +const size_t TABLE_SIZE = sizeof( TABLE ) / sizeof( TABLE[ 0 ] ); | |
| 43 | + | |
| 44 | +} // namespace ContactData | ... | ... |
examples/contact-cards/contact-data.h
0 → 100644
| 1 | +#ifndef CONTACT_DATA_H | |
| 2 | +#define CONTACT_DATA_H | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2016 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 <cstddef> | |
| 23 | + | |
| 24 | +namespace ContactData | |
| 25 | +{ | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * @brief The information for an individual contact. | |
| 29 | + */ | |
| 30 | +struct Item | |
| 31 | +{ | |
| 32 | + const char * const name; ///< The name of the contact. | |
| 33 | + const char * const address; ///< The address of the contact. | |
| 34 | + const char * const imagePath; ///< The path to the image that represents the contact. | |
| 35 | +}; | |
| 36 | + | |
| 37 | +extern const Item TABLE[]; ///< The table that has the information for all the contacts. | |
| 38 | +extern const size_t TABLE_SIZE; ///< The size of TABLE. Can use this to iterate through TABLE. | |
| 39 | + | |
| 40 | +} // namespace ContactData | |
| 41 | + | |
| 42 | +#endif // CONTACT_DATA_H | ... | ... |
resources/po/as.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "ক্লিক্" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "ঝুৰ্" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "অঁপইতা " | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "ঘনক পৰিৱৰ্তনীয় প্ৰভাৱ" |
| 18 | 21 | ... | ... |
resources/po/de.po
| ... | ... | @@ -11,7 +11,10 @@ msgid "DALI_DEMO_STR_TITLE_BUTTONS" |
| 11 | 11 | msgstr "Tasten" |
| 12 | 12 | |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | -msgstr "Farbverlauf " | |
| 14 | +msgstr "Farbverlauf" | |
| 15 | + | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "Kontakt" | |
| 15 | 18 | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "Würfel Übergangseffekt" | ... | ... |
resources/po/en_GB.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "Buttons" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "Colour Gradient" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "Contact Cards" | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "Cube Effect" |
| 18 | 21 | ... | ... |
resources/po/en_US.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "Buttons" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "Color Gradient" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "Contact Cards" | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "Cube Effect" |
| 18 | 21 | ... | ... |
resources/po/es.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "Botones" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "Gradiente de color" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "Contactos" | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "Transición cubos" |
| 18 | 21 | ... | ... |
resources/po/fi.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "Painikkeet" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "Liukuväri" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "Yhteystietokortit" | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "Kuutioefekti" |
| 18 | 21 | ... | ... |
resources/po/ko.po
resources/po/ml.po
| ... | ... | @@ -13,6 +13,9 @@ msgstr "ബട്ടണുകൾ" |
| 13 | 13 | msgid "DALI_DEMO_STR_TITLE_COLOR_GRADIENT" |
| 14 | 14 | msgstr "വർണ്ണ ഗ്രേഡിയന്റ്" |
| 15 | 15 | |
| 16 | +msgid "DALI_DEMO_STR_TITLE_CONTACT_CARDS" | |
| 17 | +msgstr "ബന്ധങ്ങൾ" | |
| 18 | + | |
| 16 | 19 | msgid "DALI_DEMO_STR_TITLE_CUBE_TRANSITION" |
| 17 | 20 | msgstr "സമചതുരക്കട്ട സംക്രമണ ഇഫക്ട്" |
| 18 | 21 | ... | ... |
resources/po/ur.po
resources/po/zn_CH.po
resources/style/.gitignore
resources/style/contact-cards-example-theme.json.in
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 | +{ | |
| 19 | + "styles": | |
| 20 | + { | |
| 21 | + "ContactNameTextLabel": | |
| 22 | + { | |
| 23 | + "textColor": [ 0, 0, 0, 1 ], | |
| 24 | + "horizontalAlignment": "CENTER", | |
| 25 | + "pointSize": 14 | |
| 26 | + }, | |
| 27 | + | |
| 28 | + "ContactDetailTextLabel": | |
| 29 | + { | |
| 30 | + "textColor": [ 0, 0, 0, 1 ], | |
| 31 | + "multiLine": true, | |
| 32 | + "pointSize": 20 | |
| 33 | + } | |
| 34 | + } | |
| 35 | +} | ... | ... |
resources/style/mobile/contact-cards-example-theme.json.in
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 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 | +{ | |
| 19 | + "styles": | |
| 20 | + { | |
| 21 | + "ContactNameTextLabel": | |
| 22 | + { | |
| 23 | + "textColor": [ 0, 0, 0, 1 ], | |
| 24 | + "horizontalAlignment": "CENTER", | |
| 25 | + "pointSize": 7 | |
| 26 | + }, | |
| 27 | + | |
| 28 | + "ContactDetailTextLabel": | |
| 29 | + { | |
| 30 | + "textColor": [ 0, 0, 0, 1 ], | |
| 31 | + "multiLine": true, | |
| 32 | + "pointSize": 13 | |
| 33 | + } | |
| 34 | + } | |
| 35 | +} | ... | ... |
shared/dali-demo-strings.h
| ... | ... | @@ -37,6 +37,7 @@ extern "C" |
| 37 | 37 | #define DALI_DEMO_STR_TITLE_BUBBLES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUBBLES") |
| 38 | 38 | #define DALI_DEMO_STR_TITLE_BUTTONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUTTONS") |
| 39 | 39 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_COLOR_GRADIENT") |
| 40 | +#define DALI_DEMO_STR_TITLE_CONTACT_CARDS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CONTACT_CARDS") | |
| 40 | 41 | #define DALI_DEMO_STR_TITLE_CUBE_TRANSITION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_CUBE_TRANSITION") |
| 41 | 42 | #define DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION") |
| 42 | 43 | #define DALI_DEMO_STR_TITLE_EFFECTS_VIEW dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_EFFECTS_VIEW") |
| ... | ... | @@ -87,6 +88,7 @@ extern "C" |
| 87 | 88 | #define DALI_DEMO_STR_TITLE_BUBBLES "Bubbles" |
| 88 | 89 | #define DALI_DEMO_STR_TITLE_BUTTONS "Buttons" |
| 89 | 90 | #define DALI_DEMO_STR_TITLE_COLOR_GRADIENT "Color Gradient" |
| 91 | +#define DALI_DEMO_STR_TITLE_CONTACT_CARDS "Contact Cards" | |
| 90 | 92 | #define DALI_DEMO_STR_TITLE_CUBE_TRANSITION "Cube Effect" |
| 91 | 93 | #define DALI_DEMO_STR_TITLE_DISSOLVE_TRANSITION "Dissolve Effect" |
| 92 | 94 | #define DALI_DEMO_STR_TITLE_EFFECTS_VIEW "Effects View" | ... | ... |