#define DALI_TOOLKIT_LAYOUTING_FLEX_NODE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
-#include <memory>
-#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-common.h>
+#include <memory>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/dali-toolkit-common.h>
{
namespace Toolkit
{
-
namespace Flex
{
-
class Node;
/**
*/
enum class FlexDirection
{
- COLUMN, ///< The flexible items are displayed vertically as a column
- COLUMN_REVERSE, ///< The flexible items are displayed vertically as a column, but in reverse order
- ROW, ///< The flexible items are displayed horizontally as a row
- ROW_REVERSE ///< The flexible items are displayed horizontally as a row, but in reverse order
+ COLUMN, ///< The flexible items are displayed vertically as a column
+ COLUMN_REVERSE, ///< The flexible items are displayed vertically as a column, but in reverse order
+ ROW, ///< The flexible items are displayed horizontally as a row
+ ROW_REVERSE ///< The flexible items are displayed horizontally as a row, but in reverse order
};
/**
*/
enum class Justification
{
- FLEX_START, ///< Items are positioned at the beginning of the container
- CENTER, ///< Items are positioned at the center of the container
- FLEX_END, ///< Items are positioned at the end of the container
- SPACE_BETWEEN, ///< Items are positioned with equal space between the items
- SPACE_AROUND ///< Items are positioned with equal space before, between, and after the items
+ FLEX_START, ///< Items are positioned at the beginning of the container
+ CENTER, ///< Items are positioned at the center of the container
+ FLEX_END, ///< Items are positioned at the end of the container
+ SPACE_BETWEEN, ///< Items are positioned with equal space between the items
+ SPACE_AROUND, ///< Items are positioned with equal space before, and after the items
+ SPACE_EVENLY ///< Items are positioned with equal space before, between, and after the items
};
/**
*/
enum class WrapType
{
- NO_WRAP, ///< Flex items laid out in single line (shrunk to fit the flex container along the main axis)
- WRAP ///< Flex items laid out in multiple lines if needed
+ NO_WRAP, ///< Flex items laid out in single line (shrunk to fit the flex container along the main axis)
+ WRAP ///< Flex items laid out in multiple lines if needed
};
/**
*/
enum class Alignment
{
- AUTO, ///< Currently unsupported, placeholder for inheritance of parent alignment.
+ AUTO, ///< Currently unsupported, placeholder for inheritance of parent alignment.
- FLEX_START, ///< At the beginning of the container
- CENTER, ///< At the center of the container
- FLEX_END, ///< At the end of the container
- STRETCH ///< Stretch to fit the container
+ FLEX_START, ///< At the beginning of the container
+ CENTER, ///< At the center of the container
+ FLEX_END, ///< At the end of the container
+ STRETCH ///< Stretch to fit the container
};
/**
*/
enum class PositionType
{
- RELATIVE, ///< Flex items laid out relatively
- ABSOLUTE ///< Flex items laid out absolutely
+ RELATIVE, ///< Flex items laid out relatively
+ ABSOLUTE ///< Flex items laid out absolutely
};
/**
*/
struct SizeTuple
{
- SizeTuple( float x, float y ) : width( x ), height( y ){}
+ SizeTuple(float x, float y)
+ : width(x),
+ height(y)
+ {
+ }
float width;
float height;
* @note int, width measure specifcation mode
* @note float, available height for child
* @note int, height measure specification mode
+ * @note SizeTuple, return value
*/
-using MeasureCallback = SizeTuple (*)( Dali::Actor, float , int , float , int );
+using MeasureCallback = void (*)(Dali::Actor, float, int, float, int, SizeTuple*);
/**
* This class provides the API for calling into the Flex layout implementation.
~Node();
Node& operator=(Node&&) = default;
- Node(Node&&) = default;
- Node(const Node&) = delete;
+ Node(Node&&) = default;
+ Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
/**
* @param[in] index to insert at.
* @return child node pointer
*/
- Node* AddChild( Actor child, Extents margin, MeasureCallback measureFunction, int index );
+ Node* AddChild(Actor child, Extents margin, MeasureCallback measureFunction, int index);
/**
* @brief Remove child from the FlexLayout at the given index.
* @param[in] child child to be removed.
*/
- void RemoveChild( Actor child );
+ void RemoveChild(Actor child);
/**
* @brief Return the dimensions of the node.
* @param[in] heightMode height specification mode
* @return Size tuple representing the width and height of the node
*/
- SizeTuple MeasureNode( float width, int widthMode, float height, int heightMode );
+ SizeTuple MeasureNode(float width, int widthMode, float height, int heightMode);
/**
* @brief Perform the layout measure calculations.
* @param[in] availableHeight Amount of space available for layout, height.
* @param[in] isRTL Is the direction of the layout right to left.
*/
- void CalculateLayout( float availableWidth, float availableHeight, bool isRTL );
+ void CalculateLayout(float availableWidth, float availableHeight, bool isRTL);
/**
* @brief Get the calculated width of the given node.
* @param[in] index of the child
* @return Frame structure left x, top y, right z, bottom w
*/
- Vector4 GetNodeFrame(int index ) const;
+ Vector4 GetNodeFrame(int index) const;
/**
* @brief Set the flex direction in the layout.
* The direction of the main-axis which determines the direction that flex items are laid out.
* @param[in] flexDirection The flex direction.
*/
- void SetFlexDirection( FlexDirection flexDirection );
+ void SetFlexDirection(FlexDirection flexDirection);
/**
* @brief Get the flex direction in the layout.
* @brief Set the justification in the layout.
* @param[in] flexJustification The flex justification.
*/
- void SetFlexJustification( Justification flexJustification );
+ void SetFlexJustification(Justification flexJustification);
/**
* @brief Get the flex justification in the layout.
* @brief Set the wrap in the layout.
* @param[in] flexWrap The flex wrap.
*/
- void SetFlexWrap(WrapType flexWrap );
+ void SetFlexWrap(WrapType flexWrap);
/**
* @brief Get the flex wrap in the layout.
* @brief Set the alignment of the layout content.
* @param[in] flexAlignment The alignment of the content.
*/
- void SetFlexAlignment( Alignment flexAlignment );
+ void SetFlexAlignment(Alignment flexAlignment);
/**
* @brief Get the alignment of the layout content.
* @brief Set the alignment of the layout items.
* @param[in] flexAlignment The alignment of the items.
*/
- void SetFlexItemsAlignment( Alignment flexAlignment );
+ void SetFlexItemsAlignment(Alignment flexAlignment);
/**
* @brief Get the alignment of the layout items.
* @brief Set the alignment self of the layout items.
* @param[in] flexAlignmentSelf The alignment self of the items.
*/
- void SetFlexAlignmentSelf( Alignment flexAlignmentSelf );
+ void SetFlexAlignmentSelf(Alignment flexAlignmentSelf);
/**
* @brief Get the alignment self of the layout items.
* @brief Set the position type of the layout items.
* @param[in] flexPositionType The position type of the items.
*/
- void SetFlexPositionType( PositionType flexPositionType );
+ void SetFlexPositionType(PositionType flexPositionType);
/**
* @brief Get the position type of the layout items.
* @brief Set the aspect ratio of the layout items.
* @param[in] flexAspectRatio The aspect ratio of the items.
*/
- void SetFlexAspectRatio( float flexAspectRatio );
+ void SetFlexAspectRatio(float flexAspectRatio);
/**
* @brief Get the aspect ratio of the layout items.
* @brief Set the basis of the layout items.
* @param[in] flexBasis The basis of the items.
*/
- void SetFlexBasis( float flexBasis );
+ void SetFlexBasis(float flexBasis);
/**
* @brief Get the basis of the layout items.
* @brief Set the shrink of the layout items.
* @param[in] flexShrink The shrink of the items.
*/
- void SetFlexShrink( float flexShrink );
+ void SetFlexShrink(float flexShrink);
/**
* @brief Get the shrink of the layout items.
* @brief Set the grow of the layout items.
* @param[in] flexGrow The grow of the items.
*/
- void SetFlexGrow( float flexGrow );
+ void SetFlexGrow(float flexGrow);
/**
* @brief Get the grow of the layout items.
* @brief Set the margin.
* @param[in] margin The margin value.
*/
- void SetMargin( Extents margin );
+ void SetMargin(Extents margin);
/**
* @brief Set the padding.
* @param[in] padding The padding value.
*/
- void SetPadding( Extents padding );
+ void SetPadding(Extents padding);
private:
struct Impl;
- std::unique_ptr< Impl > mImpl;
-
+ std::unique_ptr<Impl> mImpl;
}; // Node
-
} // namespace Flex
} // namespace Toolkit
} // namespace Dali