}
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;
////////////////////////////////////////////////////////////////////////////////////////////////////
+bool ToolkitApplication::DECODED_IMAGES_SUPPORTED;
+
ToolkitApplication::ToolkitApplication()
: mApplicationStub(new Application(*this))
{
// The Application Stub
Application* mApplicationStub;
friend class Application;
+
+public: // Test static member
+ static bool DECODED_IMAGES_SUPPORTED;
};
} // namespace Dali
*
*/
-// CLASS HEADER
-#include "toolkit-video-player.h"
-
-// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/video-player.h>
#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/base-object.h>
+#include <toolkit-application.h>
namespace Dali
{
{
}
+bool VideoPlayer::IsVideoTextureSupported() const
+{
+ return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
+}
+
} // namespace Dali;
+++ /dev/null
-#ifndef __DALI_TOOLKIT_VIDEO_PLAYER_H__
-#define __DALI_TOOLKIT_VIDEO_PLAYER_H__
-
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/object/base-object.h>
-
-#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
-
-namespace Dali
-{
-
-class Any;
-
-namespace Internal
-{
-namespace Adaptor
-{
-
-class VideoPlayer;
-
-}
-}
-
-/**
- * @brief VideoPlayer class is used for video playback.
- * @SINCE_1_1.38
- */
-class VideoPlayer: public BaseHandle
-{
-public:
-
- VideoPlayer();
-
- ~VideoPlayer();
-
- static VideoPlayer New();
-
- VideoPlayer( const VideoPlayer& player );
-
- VideoPlayer& operator=( const VideoPlayer& player );
-
- static VideoPlayer DownCast( BaseHandle handle );
-
- void SetUrl( const std::string& url );
-
- std::string GetUrl();
-
- void SetLooping(bool looping);
-
- bool IsLooping();
-
- void Play();
-
- void Pause();
-
- void Stop();
-
- void SetMute( bool mute );
-
- bool IsMuted();
-
- void SetVolume( float left, float right );
-
- void GetVolume( float& left, float& right );
-
- void SetRenderingTarget( Any target );
-
- void SetPlayPosition( int millisecond );
-
- int GetPlayPosition();
-
- void SetDisplayArea( DisplayArea area );
-
- void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
-
- Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
-
- Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
-
- void Forward( int millisecond );
-
- void Backward( int millisecond );
-
-private:
-
- VideoPlayer( Internal::Adaptor::VideoPlayer* internal );
-
-};
-
-} // namespace Dali;
-
-#endif
"\"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
END_TEST;
}
+
+int UtcDaliVideoViewPropertyUnderlay(void)
+{
+ ToolkitTestApplication application;
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+ VideoView view = VideoView::New();
+ DALI_TEST_CHECK( view );
+
+ Stage::GetCurrent().Add( view );
+
+ application.SendNotification();
+ application.Render();
+
+ bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( !isUnderlay );
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ // If platform api doesn't provide any API or feature for decoded images of video,
+ // UNDERLAY should be true
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = false;
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ END_TEST;
+}
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 );
}
}
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING )
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED )
DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME )
+DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY )
DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL )
const char* const VOLUME_LEFT( "volumeLeft" );
const char* const VOLUME_RIGHT( "volumeRight" );
+
+// 3.0 TC uses RENDERING_TARGET. It should be removed in next release
const char* const RENDERING_TARGET( "renderingTarget" );
const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
mUpdateTriggerPropertyIndex( Property::INVALID_INDEX),
mNotification( NULL ),
mCurrentVideoPlayPosition( 0 ),
- mIsNativeImageTarget( true ),
mIsPlay( false ),
- mIsPause( false )
+ mIsPause( false ),
+ mIsUnderlay( true )
{
mVideoPlayer = Dali::VideoPlayer::New();
void VideoView::OnInitialize()
{
- Any source;
- Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
- mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
-
- mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
- mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
-
mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true );
+ mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+ SetWindowSurfaceTarget();
}
void VideoView::SetUrl( const std::string& url )
mPropertyMap.Clear();
}
- if( mIsNativeImageTarget )
+ if( !mIsUnderlay )
{
Actor self( Self() );
Internal::InitializeVisual( self, mVisual, mNativeImage );
if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET )
{
- this->SetWindowSurfaceTarget();
+ mIsUnderlay = true;
+ SetWindowSurfaceTarget();
}
else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET )
{
- this->SetNativeImageTarget();
+ mIsUnderlay = false;
+ SetNativeImageTarget();
}
RelayoutRequest();
}
break;
}
+ case Toolkit::VideoView::Property::UNDERLAY:
+ {
+ bool underlay;
+ if( value.Get( underlay ) )
+ {
+ impl.SetUnderlay( underlay );
+ }
+ break;
+ }
}
}
}
value = map;
break;
}
+ case Toolkit::VideoView::Property::UNDERLAY:
+ {
+ value = impl.IsUnderlay();
+ break;
+ }
}
}
mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
mVideoPlayer.SetUrl( mUrl );
- mIsNativeImageTarget = false;
+ if( !mRenderer )
+ {
+ // For underlay rendering mode, video display area have to be transparent.
+ Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
+ Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mRenderer = Renderer::New( geometry, shader );
+
+ mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
+ mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
+ }
+ self.AddRenderer( mRenderer );
+
+ UpdateDisplayArea();
if( mIsPlay )
{
{
mVideoPlayer.SetPlayPosition( curPos );
}
-
- // For underlay rendering mode, video display area have to be transparent.
- Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- Renderer renderer = Renderer::New( geometry, shader );
-
- renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
- renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
- self.AddRenderer( renderer );
}
void VideoView::SetNativeImageTarget()
{
+ if( mVideoPlayer.IsVideoTextureSupported() == false )
+ {
+ DALI_LOG_ERROR( "Platform doesn't support decoded video frame images\n" );
+ mIsUnderlay = true;
+ return;
+ }
+
Actor self( Self() );
int curPos = mVideoPlayer.GetPlayPosition();
mVideoPlayer.SetUrl( mUrl );
Internal::InitializeVisual( self, mVisual, mNativeImage );
- mIsNativeImageTarget = true;
+ Self().RemoveRenderer( mRenderer );
if( mIsPlay )
{
void VideoView::UpdateDisplayArea()
{
+ if( !mIsUnderlay )
+ {
+ return;
+ }
+
Actor self( Self() );
bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >();
mVideoPlayer.SetDisplayArea( mDisplayArea );
}
+void VideoView::SetUnderlay( bool set )
+{
+ if( set != mIsUnderlay )
+ {
+ mIsUnderlay = set;
+
+ if( mIsUnderlay )
+ {
+ SetWindowSurfaceTarget();
+ }
+ else
+ {
+ SetNativeImageTarget();
+ }
+ }
+}
+
+bool VideoView::IsUnderlay()
+{
+ return mIsUnderlay;
+}
+
} // namespace Internal
} // namespace toolkit
*/
static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
- /*
+ /**
* @brief Updates video display area for window rendering target
*/
void UpdateDisplayArea();
+ /**
+ * @brief Sets underlay flag and initializes new rendering target by flag.
+ */
+ void SetUnderlay( bool set );
+
+ /**
+ * @brief Checks underlay flag.
+ */
+ bool IsUnderlay();
+
private: // From Control
/**
Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal;
std::string mUrl;
Dali::DisplayArea mDisplayArea;
+ Dali::Renderer mRenderer;
Property::Index mUpdateTriggerPropertyIndex;
TriggerEventInterface* mNotification;
int mCurrentVideoPlayPosition;
- bool mIsNativeImageTarget;
bool mIsPlay;
bool mIsPause;
+ bool mIsUnderlay;
};
} // namespace Internal
}
}
+/**
+ * @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
};
};
// Signal
typedef Signal< void (VideoView&) > VideoViewSignalType; ///< Video playback finished signal type @ SINCE_1_1.38
+public:
+
/**
* @brief Enumeration for the start and end property ranges for this control.
* @SINCE_1_0.0
* @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ).
* @SINCE_1_1.38
*/
- VOLUME
+ VOLUME,
+
+ /**
+ * @brief name "underlay", Video rendering by underlay, true or false
+ * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view
+ * If false, video-view shows decoded frame images sequentially.
+ * If Platform or video plugin doesn't support decoded frame images, this should always be true.
+ * @SINCE_1_2.62
+ */
+ UNDERLAY
};
};
* @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: