}
template <>
+inline bool CompareType<Extents>(Extents extents1, Extents extents2, float epsilon)
+{
+ return (extents1.start == extents2.start) &&
+ (extents1.end == extents2.end) &&
+ (extents1.top == extents2.top) &&
+ (extents1.bottom == extents2.bottom);
+}
+
+template <>
inline bool CompareType<Property::Value>(Property::Value q1, Property::Value q2, float epsilon)
{
Property::Type type = q1.GetType();
result = false;
break;
}
+ case Property::EXTENTS:
+ {
+ Extents a, b;
+ q1.Get(a);
+ q2.Get(b);
+ result = CompareType<Extents>( a, b, epsilon );
+ break;
+ }
case Property::NONE:
{
result = false;
"\"sensitive\": { \"typeCast\":\"boolean\", \"value\":false },"
"\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] },"
"\"colorMode\": { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" },"
- "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] }"
+ "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] },"
+ "\"padding\": { \"typeCast\":\"extents\", \"value\":[10,10,10,10] }"
"}]"
"}"
);
END_TEST;
}
+
+int UtcDaliControlMarginProperty(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ control.SetBackgroundColor( Color::BLUE );
+
+ control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::MARGIN ), Extents( 20, 10, 0, 0 ), TEST_LOCATION );
+
+ // Parent control has one ImageView as a Child.
+ ImageView image = ImageView::New();
+ image.SetBackgroundColor( Color::RED );
+ image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ image.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
+ control.Add( image );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( image.GetProperty<Extents>( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlPaddingProperty(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ control.SetBackgroundColor( Color::BLUE );
+
+ control.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( control.GetProperty<Extents>( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
+
+ END_TEST;
+}
ImageView imageView = ImageView::New();
imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
+ imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) );
// By default, Aysnc loading is used
// loading is not started if the actor is offStage
BACKGROUND_IMAGE = Control::Property::BACKGROUND_IMAGE,
KEY_INPUT_FOCUS = Control::Property::KEY_INPUT_FOCUS,
BACKGROUND = Control::Property::BACKGROUND,
+ MARGIN = Control::Property::MARGIN,
+ PADDING = Control::Property::PADDING,
/**
* @brief Displays a tooltip when the control is hovered over.
* @note When retrieved, a Property::MAP is returned.
* @see Toolkit::Tooltip
*/
- TOOLTIP = BACKGROUND + 1,
+ TOOLTIP = PADDING + 1,
/**
* @brief The current state of the control.
*
* @see DevelControl::State
*/
- STATE = BACKGROUND + 2,
+ STATE = PADDING + 2,
/**
* @brief The current sub state of the control.
*
* @see DevelControl::State
*/
- SUB_STATE = BACKGROUND + 3,
+ SUB_STATE = PADDING + 3,
/**
* @brief The actor ID of the left focusable control.
* @details Name "leftFocusableActorId", type Property::INTEGER.
*
*/
- LEFT_FOCUSABLE_ACTOR_ID = BACKGROUND + 4,
+ LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
/**
* @brief The actor ID of the right focusable control.
* @details Name "rightFocusableActorId", type Property::INTEGER.
*
*/
- RIGHT_FOCUSABLE_ACTOR_ID = BACKGROUND + 5,
+ RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
/**
* @brief The actor ID of the up focusable control.
* @details Name "upFocusableActorId", type Property::INTEGER.
*
*/
- UP_FOCUSABLE_ACTOR_ID = BACKGROUND + 6,
+ UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
/**
* @brief The actor ID of the down focusable control.
* @details Name "downFocusableActorId", type Property::INTEGER.
*
*/
- DOWN_FOCUSABLE_ACTOR_ID = BACKGROUND + 7
+ DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7
};
} // namespace Property
#define __DALI_TOOLKIT_BUILDER_DECLARATIONS_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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 <dali/public-api/common/extents.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
typedef OptionalValue<Dali::Matrix> OptionalMatrix;
typedef OptionalValue<Dali::Matrix3> OptionalMatrix3;
typedef OptionalValue<Dali::Rect<int> > OptionalRect;
+typedef OptionalValue<Dali::Extents> OptionalExtents;
#endif // __DALI_TOOLKIT_BUILDER_DECLARATIONS_H__
return ret;
}
+inline OptionalExtents IsExtents(const OptionalChild& node)
+{
+ OptionalExtents extents;
+ if(node && (*node).Size())
+ {
+ if((*node).Size() >= 4)
+ {
+ TreeNode::ConstIterator iter((*node).CBegin());
+ int v[4];
+ if( CopyNumbers((*node).CBegin(), 4, v) )
+ {
+ extents = OptionalExtents(Dali::Extents(v[0], v[1], v[2], v[3]));
+ }
+ }
+ }
+ return extents;
+}
+
//
//
//
return IsRect( IsChild(&parent, childName) );
}
+inline OptionalExtents IsExtents(const TreeNode &parent, const std::string& childName)
+{
+ return IsExtents( IsChild(&parent, childName) );
+}
+
//
//
//
return IsRect( OptionalChild( node ) );
}
+inline OptionalExtents IsExtents(const TreeNode &node )
+{
+ return IsExtents( OptionalChild( node ) );
+}
+
//
//
//
{
return DeterminePropertyFromNode( *childValue, Dali::Property::ARRAY, value, replacement);
}
+ else if(*childType == "extents")
+ {
+ return DeterminePropertyFromNode( *childValue, Dali::Property::EXTENTS, value, replacement);
+ }
}
// else we failed to disambiguate
}
break;
}
+ case Property::EXTENTS:
+ {
+ if( OptionalExtents v = replacer.IsExtents(node) )
+ {
+ value = *v;
+ done = true;
+ }
+ break;
+ }
case Property::NONE:
{
break;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
return ret;
}
-
+OptionalExtents Replacement::IsExtents( const TreeNode & node ) const
+{
+ OptionalExtents extents;
+ if( OptionalString replace = HasFullReplacement( node ) )
+ {
+ Property::Value value = GetFullReplacement( *replace );
+ if( Property::EXTENTS == value.GetType() )
+ {
+ extents = value.Get<Extents>();
+ }
+ }
+ else
+ {
+ extents = ::IsExtents( node );
+ }
+ return extents;
+}
OptionalFloat Replacement::IsFloat( OptionalChild child ) const
{
return ret;
}
+OptionalExtents Replacement::IsExtents( OptionalChild child ) const
+{
+ if( child )
+ {
+ return IsExtents( *child );
+ }
+ else
+ {
+ return OptionalExtents();
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
#define __DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
/* @brief Check node for a type
*
+ * @param node The TreeNode to check
+ * @return Optional value
+ */
+ OptionalExtents IsExtents( const TreeNode & node ) const;
+
+ /* @brief Check node for a type
+ *
* @param child The optional child TreeNode
* @return Optional value
*/
*/
bool IsArray( OptionalChild child, Property::Value& out ) const;
+ /* @brief Check node for a type
+ *
+ * @param child The optional child TreeNode
+ * @return Optional value
+ */
+ OptionalExtents IsExtents( OptionalChild child ) const;
+
private:
// Overriding map (overrides the default map). The map is not owned.
const Property::Map* const mOverrideMap;
const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-
+const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin", Toolkit::Control::Property::MARGIN, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "padding", Toolkit::Control::Property::PADDING, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
Control::Impl::Impl( Control& controlImpl )
mStyleName(""),
mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale( NULL ),
+ mMargin( 0, 0, 0, 0 ),
+ mPadding( 0, 0, 0, 0 ),
mKeyEventSignal(),
mPinchGestureDetector(),
mPanGestureDetector(),
break;
}
+ case Toolkit::Control::Property::MARGIN:
+ {
+ Extents margin;
+ if( value.Get( margin ) )
+ {
+ controlImpl.mImpl->SetMargin( margin );
+ }
+ break;
+ }
+
+ case Toolkit::Control::Property::PADDING:
+ {
+ Extents padding;
+ if( value.Get( padding ) )
+ {
+ controlImpl.mImpl->SetPadding( padding );
+ }
+ break;
+ }
+
case Toolkit::DevelControl::Property::TOOLTIP:
{
TooltipPtr& tooltipPtr = controlImpl.mImpl->mTooltip;
tooltipPtr = Tooltip::New( control );
}
tooltipPtr->SetProperties( value );
+ break;
}
+
}
}
}
break;
}
+ case Toolkit::Control::Property::MARGIN:
+ {
+ value = controlImpl.mImpl->GetMargin();
+ break;
+ }
+
+ case Toolkit::Control::Property::PADDING:
+ {
+ value = controlImpl.mImpl->GetPadding();
+ break;
+ }
+
case Toolkit::DevelControl::Property::TOOLTIP:
{
Property::Map map;
value = map;
break;
}
-
}
}
mRemoveVisuals.Clear();
}
+void Control::Impl::SetMargin( Extents margin )
+{
+ mControlImpl.mImpl->mMargin = margin;
+}
+
+Extents Control::Impl::GetMargin() const
+{
+ return mControlImpl.mImpl->mMargin;
+}
+
+void Control::Impl::SetPadding( Extents padding )
+{
+ mControlImpl.mImpl->mPadding = padding;
+}
+
+Extents Control::Impl::GetPadding() const
+{
+ return mControlImpl.mImpl->mPadding;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void OnStageDisconnection();
+ /**
+ * @brief Sets the margin.
+ * @param[in] margin Margin is a collections of extent ( start, end, top, bottom )
+ */
+ void SetMargin( Extents margin );
+
+ /**
+ * @brief Returns the value of margin
+ * @return The value of margin
+ */
+ Extents GetMargin() const;
+
+ /**
+ * @brief Sets the padding.
+ * @param[in] padding Padding is a collections of extent ( start, end, top, bottom ).
+ */
+ void SetPadding( Extents padding );
+
+ /**
+ * @brief Returns the value of padding
+ * @return The value of padding
+ */
+ Extents GetPadding() const;
+
private:
/**
std::string mStyleName;
Vector4 mBackgroundColor; ///< The color of the background visual
Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
+ Extents mMargin; ///< The margin values
+ Extents mPadding; ///< The padding values
Toolkit::Control::KeyEventSignalType mKeyEventSignal;
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
static const PropertyRegistration PROPERTY_10;
static const PropertyRegistration PROPERTY_11;
static const PropertyRegistration PROPERTY_12;
+ static const PropertyRegistration PROPERTY_13;
+ static const PropertyRegistration PROPERTY_14;
};
{
Vector2 rendererNaturalSize;
mVisual.GetNaturalSize( rendererNaturalSize );
+
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ rendererNaturalSize.width += ( padding.start + padding.end );
+ rendererNaturalSize.height += ( padding.top + padding.bottom );
return Vector3( rendererNaturalSize );
}
float ImageView::GetHeightForWidth( float width )
{
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
if( mVisual )
{
- return mVisual.GetHeightForWidth( width );
+ return mVisual.GetHeightForWidth( width ) + padding.top + padding.bottom;
}
else
{
- return Control::GetHeightForWidth( width );
+ return Control::GetHeightForWidth( width ) + padding.top + padding.bottom;
}
}
float ImageView::GetWidthForHeight( float height )
{
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
if( mVisual )
{
- return mVisual.GetWidthForHeight( height );
+ return mVisual.GetWidthForHeight( height ) + padding.start + padding.end;
}
else
{
- return Control::GetWidthForHeight( height );
+ return Control::GetWidthForHeight( height ) + padding.start + padding.end;
}
}
if( mVisual )
{
- // Pass in an empty map which uses default transform values meaning our visual fills the control
+ Extents margin;
+ margin = Self().GetProperty<Extents>( Toolkit::Control::Property::MARGIN );
+
+ Extents padding;
+ padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Property::Map transformMap = Property::Map();
+
+ if( ( padding.start != 0 ) || ( padding.end != 0 ) || ( padding.top != 0 ) || ( padding.bottom != 0 ) ||
+ ( margin.start != 0 ) || ( margin.end != 0 ) || ( margin.top != 0 ) || ( margin.bottom != 0 ) )
+ {
+ transformMap.Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( margin.start + padding.start, margin.top + padding.top ) )
+ .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+ .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
+ }
+
// Should provide a transform that handles aspect ratio according to image size
- mVisual.SetTransformAndSize( Property::Map(), size );
+ mVisual.SetTransformAndSize( transformMap, size );
}
}
}
}
+/**
+ * @brief Sets Control::Property::BACKGROUND visual
+ * @param[in] controlImpl The control implementation
+ * @param[in] visual The control background visual
+ * @param[in] size The current size
+ */
+void SetBackgroundVisual( Control::Impl& controlImpl, Toolkit::Visual::Base& visual, const Vector2& size )
+{
+ Property::Map transformMap = Property::Map();
+
+ Vector2 newSize( 0.f, 0.f );
+ newSize.width = size.width + ( controlImpl.mPadding.start + controlImpl.mPadding.end );
+ newSize.height = size.height + ( controlImpl.mPadding.top + controlImpl.mPadding.bottom );
+
+ if( ( controlImpl.mMargin.start != 0 ) ||
+ ( controlImpl.mMargin.end != 0 ) ||
+ ( controlImpl.mMargin.top != 0 ) ||
+ ( controlImpl.mMargin.bottom != 0 ) )
+ {
+ transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
+ .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( controlImpl.mMargin.start, controlImpl.mMargin.top ) )
+ .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+ .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
+ }
+ else if( ( controlImpl.mPadding.start != 0 ) ||
+ ( controlImpl.mPadding.end != 0 ) ||
+ ( controlImpl.mPadding.top != 0 ) ||
+ ( controlImpl.mPadding.bottom != 0 ) )
+ {
+ transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
+ .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+ .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
+ }
+
+ visual.SetTransformAndSize( transformMap, newSize ); // Send an empty map as we do not want to modify the visual's set transform
+}
+
} // unnamed namespace
if( visual )
{
Vector2 size( targetSize );
- visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
+ SetBackgroundVisual( *mImpl, visual, size );
+
}
}
{
for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
{
- container.Add( Self().GetChildAt( i ), size );
+ Actor child = Self().GetChildAt( i );
+ Vector2 newChildSize( size );
+
+ // When set the padding or margin on the control, child should be resized and repositioned.
+ if( ( mImpl->mPadding.start != 0 ) || ( mImpl->mPadding.end != 0 ) || ( mImpl->mPadding.top != 0 ) || ( mImpl->mPadding.bottom != 0 ) ||
+ ( mImpl->mMargin.start != 0 ) || ( mImpl->mMargin.end != 0 ) || ( mImpl->mMargin.top != 0 ) || ( mImpl->mMargin.bottom != 0 ) )
+ {
+ newChildSize.width = size.width - ( mImpl->mPadding.start + mImpl->mPadding.end );
+ newChildSize.height = size.height - ( mImpl->mPadding.top + mImpl->mPadding.bottom );
+
+ Vector3 childPosition = child.GetTargetSize();
+ childPosition.x += ( mImpl->mMargin.start + mImpl->mPadding.start );
+ childPosition.y += ( mImpl->mMargin.top + mImpl->mPadding.top );
+
+ child.SetPosition( childPosition );
+ }
+
+ container.Add( child, newChildSize );
}
Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
- visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
+ SetBackgroundVisual( *mImpl, visual, size );
}
}
{
Vector2 naturalSize;
visual.GetNaturalSize( naturalSize );
+ naturalSize.width += ( mImpl->mPadding.start + mImpl->mPadding.end );
+ naturalSize.height += ( mImpl->mPadding.top + mImpl->mPadding.bottom );
return Vector3( naturalSize );
}
return Vector3::ZERO;
enum
{
/**
- * @brief name "styleName", type std::string.
+ * @brief The name of the style to be applied to the control.
+ * @details Name "styleName", type Property::STRING.
+ * @see Toolkit::Control::SetStyleName()
* @SINCE_1_0.0
- * @see SetStyleName
*/
STYLE_NAME = PROPERTY_START_INDEX,
+
/**
* @DEPRECATED_1_1.3
- * @brief name "backgroundColor", mutually exclusive with BACKGROUND_IMAGE & BACKGROUND, type Vector4.
+ * @brief The background color of the control.
+ *
+ * Mutually exclusive with BACKGROUND_IMAGE & BACKGROUND.
+ * @details Name "backgroundColor", type Property::VECTOR4.
+ * @see Toolkit::Control::SetStyleName()
* @SINCE_1_0.0
- * @see SetStyleName
*/
BACKGROUND_COLOR,
+
/**
* @DEPRECATED_1_1.3
- * @brief name "backgroundImage", mutually exclusive with BACKGROUND_COLOR & BACKGROUND, type Map.
+ * @brief The background image of the control.
+ *
+ * Mutually exclusive with BACKGROUND_COLOR & BACKGROUND.
+ * @details Name "backgroundImage", type Property::MAP.
* @SINCE_1_0.0
*/
BACKGROUND_IMAGE,
+
/**
- * @brief name "keyInputFocus", type bool.
+ * @brief Receives key events to the control.
+ * @details Name "keyInputFocus", type Property::BOOLEAN.
+ * @see Toolkit::Control::SetKeyInputFocus()
* @SINCE_1_0.0
- * @see SetKeyInputFocus
*/
KEY_INPUT_FOCUS,
+
/**
- * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or std::string for URL or Vector4 for Color.
+ * @brief The background of the control.
+ *
+ * Mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE.
+ * @details Name "background", type Property::MAP or std::string for URL or Property::VECTOR4 for Color.
* @SINCE_1_1.3
*/
BACKGROUND,
+
+ /**
+ * @brief The outer space around the control.
+ * @details Name "margin", type Property::EXTENTS.
+ * @SINCE_1_2.62
+ */
+ MARGIN,
+
+ /**
+ * @brief The inner space of the control.
+ * @details Name "padding", type Property::EXTENTS.
+ * @SINCE_1_2.62
+ */
+ PADDING
};
};
* @details Name "transform", type Property::MAP.
* @SINCE_1_2.60
* @note Optional.
- * @see DevelVisual::Transform::Property
+ * @see Toolkit::Visual::Transform::Property
*/
TRANSFORM,
* control.SetProperty( ..., // Some visual based property
* Property::Map().Add( ... ) // Properties to set up visual
* .Add( Visual::Property::TRANSFORM,
- * Property::Array().Add( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) )
- * .Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) );
+ * Property::Array().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) )
+ * .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) );
* @endcode
*
* JSON: