/*
- * 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.
void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
-void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
+void DummyControlImplOverride::OnStageConnection( int depth ) { stageConnectionCalled = true; Control::OnStageConnection( depth ); }
void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
-void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
-void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
-void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
-void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
+void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; Control::OnChildAdd( child ); }
+void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; Control::OnChildRemove( child ); }
+void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; Control::OnSizeSet( targetSize ); }
+void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; Control::OnSizeAnimation( animation, targetSize ); }
bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
/*
- * Copyright (c) 2016 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.
END_TEST;
}
+
+int UtcDaliControlAutoClipping(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+
+ tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlAutoClippingN(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+ control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
+ .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
+
+ tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
+
+ // Ensure the background color is still RED rather than what's set by the automatic clipping
+ Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK( map );
+ Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+
+ tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+ control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
+ .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
+
+ tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals and when already on stage" );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
+
+ // Ensure the background color is still RED rather than what's set by the automatic clipping
+ Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK( map );
+ Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
+ DALI_TEST_CHECK( colorValue );
+ DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
+
+ END_TEST;
+}
/*
- * Copyright (c) 2015 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.
END_TEST;
}
+int UtcDaliControlImplAutoClippingWithVisuals(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled" );
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplAutoClippingWithVisualsAlreadyOnStage(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled and we're already on the stage" );
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false );
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
+
+ END_TEST;
+}
/*
- * Copyright (c) 2016 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.
void BloomView::OnSizeSet(const Vector3& targetSize)
{
- Control::OnSizeSet( targetSize );
-
mTargetSize = Vector2(targetSize);
mChildrenRoot.SetSize(targetSize);
mCompositeImageView.SetSize(targetSize);
Deactivate();
Activate();
}
+
+ Control::OnSizeSet( targetSize );
}
void BloomView::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
if( child != mChildrenRoot && child != mInternalRoot)
{
mChildrenRoot.Add( child );
}
+
+ Control::OnChildAdd( child );
}
void BloomView::OnChildRemove( Actor& child )
/*
- * Copyright (c) 2016 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.
void EffectsView::OnSizeSet(const Vector3& targetSize)
{
- Control::OnSizeSet( targetSize );
-
mTargetSize = Vector2(targetSize);
// if we are already on stage, need to update render target sizes now to reflect the new size of this actor
}
mChildrenRoot.SetSize( targetSize );
+
+ Control::OnSizeSet( targetSize );
}
void EffectsView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
Enable();
+
+ Control::OnStageConnection( depth );
}
void EffectsView::OnStageDisconnection()
void EffectsView::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
if( child != mChildrenRoot && child != mCameraForChildren )
{
mChildrenRoot.Add( child );
}
+
+ Control::OnChildAdd( child );
}
void EffectsView::OnChildRemove( Actor& child )
/*
- * Copyright (c) 2016 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.
void FlexContainer::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
// Anchor actor to top left of the container
child.SetAnchorPoint( AnchorPoint::TOP_LEFT );
child.SetParentOrigin( ParentOrigin::TOP_LEFT );
childNode.node->get_child = GetChildNodeAtIndex;
childNode.node->is_dirty = IsNodeDirty;
mChildrenNodes.push_back(childNode);
+
+ Control::OnChildAdd( child );
}
void FlexContainer::OnChildRemove( Actor& child )
RelayoutRequest();
}
-}
-void FlexContainer::OnSizeAnimation( Animation& animation, const Vector3& targetSize )
-{
- // @todo Animate the children to their target size and position
+ Control::OnSizeSet( size );
}
void FlexContainer::ComputeLayout()
#define __DALI_TOOLKIT_INTERNAL_FLEX_CONTAINER_H__
/*
- * Copyright (c) 2016 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.
*/
virtual void OnSizeSet( const Vector3& size );
- /**
- * @copydoc CustomActorImpl::OnSizeAnimation(Animation&, const Vector3&)
- */
- virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
-
private: // Implementation
/**
/*
- * Copyright (c) 2016 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.
void GaussianBlurView::OnSizeSet(const Vector3& targetSize)
{
- Control::OnSizeSet( targetSize );
-
mTargetSize = Vector2(targetSize);
mChildrenRoot.SetSize(targetSize);
Deactivate();
Activate();
}
+
+ Control::OnSizeSet( targetSize );
}
void GaussianBlurView::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
if( child != mChildrenRoot && child != mInternalRoot)
{
mChildrenRoot.Add( child );
}
+
+ Control::OnChildAdd( child );
}
void GaussianBlurView::OnChildRemove( Actor& child )
/*
- * Copyright (c) 2016 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.
void Magnifier::OnSizeSet(const Vector3& targetSize)
{
- Control::OnSizeSet( targetSize );
-
// TODO: Once Camera/CameraActor properties function as proper animatable properties
// this code can disappear.
// whenever the size of the magnifier changes, the field of view needs to change
// a constraint yet as Camera/CameraActor properties are not animatable/constrainable.
mActorSize = targetSize;
Update();
+
+ Control::OnSizeSet( targetSize );
}
float Magnifier::GetMagnificationFactor() const
/*
- * Copyright (c) 2016 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.
void Model3dView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
CustomActor self = Self();
self.AddRenderer( mRenderer );
constraint.AddSource( Source( self, Toolkit::Model3dView::Property::LIGHT_POSITION ) );
constraint.Apply();
}
+
+ Control::OnStageConnection( depth );
}
///////////////////////////////////////////////////////////
/*
- * Copyright (c) 2016 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.
void NavigationView::OnStageConnection( int depth )
{
Self().SetSensitive(true);
+
+ Control::OnStageConnection( depth );
}
void NavigationView::Push( Actor& actor )
/*
- * Copyright (c) 2016 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.
void PageTurnView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
SetupShadowView();
+
+ Control::OnStageConnection( depth );
}
void PageTurnView::OnStageDisconnection()
/*
- * Copyright (c) 2016 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.
void Popup::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
mLayoutDirty = true;
RelayoutRequest();
+
+ Control::OnStageConnection( depth );
}
void Popup::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
// Re-parent any children added by user to the body layer.
if( mAlterAddedChild )
{
mLayoutDirty = true;
RelayoutRequest();
}
+
+ Control::OnChildAdd( child );
}
void Popup::LayoutContext( const Vector2& size )
/*
- * Copyright (c) 2016 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.
{
mIndicator.SetSize(size.width, mIndicatorFixedHeight);
}
+
+ Control::OnSizeSet( size );
}
void ScrollBar::SetScrollDirection( Toolkit::ScrollBar::Direction direction )
/*
- * Copyright (c) 2016 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.
Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE);
}
}
+
+ Scrollable::OnChildAdd( child );
}
bool ItemView::OnWheelEvent(const WheelEvent& event)
/*
- * Copyright (c) 2015 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.
void ScrollView::OnStageConnection( int depth )
{
- ScrollBase::OnStageConnection( depth );
-
DALI_LOG_SCROLL_STATE("[0x%X]", this);
if ( mSensitive )
SetScrollSensitive( false );
SetScrollSensitive( true );
}
+
if(IsOvershootEnabled())
{
// try and make sure property notifications are set
EnableScrollOvershoot(true);
}
+
+ ScrollBase::OnStageConnection( depth );
}
void ScrollView::OnStageDisconnection()
{
mOvershootIndicator->Reset();
}
+
+ ScrollBase::OnSizeSet( size );
}
void ScrollView::OnChildAdd(Actor& child)
/*
- * Copyright (c) 2016 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.
void ShadowView::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
if( child != mChildrenRoot && child != mBlurRootActor)
{
mChildrenRoot.Add( child );
}
+
+ Control::OnChildAdd( child );
}
void ShadowView::OnChildRemove( Actor& child )
/*
- * 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.
self.TouchSignal().Connect( this, &Slider::OnTouch );
}
-void Slider::OnSizeSet( const Vector3& size )
-{
-}
-
void Slider::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
SetHitRegion( Vector2( size.x, GetHitRegion().y ) );
#define __DALI_TOOLKIT_INTERNAL_SLIDER_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.
virtual ~Slider();
/**
- * @copydoc CustomActorImpl::OnSizeSet( const Vector3& size )
- */
- virtual void OnSizeSet( const Vector3& size );
-
- /**
* @copydoc CustomActorImpl::OnRelayout
*/
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
/*
- * Copyright (c) 2016 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.
SetImage( mInputImage );
}
}
+
+ Control::OnSizeSet( targetSize );
}
void SuperBlurView::OnStageConnection( int depth )
return;
}
- // Chaining up first ensures visuals have SetOnStage called to create their renderers
+ // Exception to the rule, chaining up first ensures visuals have SetOnStage called to create their renderers
Control::OnStageConnection( depth );
Actor self = Self();
// Note that the renderer indices are depending on the order they been added to the actor
// which might be different from the blur level of its texture.
// We can check the depth index of the renderer to know which blurred image it renders.
+ // All visuals WILL have renderers at this point as we are simply creating visuals with an Image handle.
Renderer renderer = self.GetRendererAt( i );
int depthIndex = renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX);
if( depthIndex > 0 )
}
}
-void SuperBlurView::OnStageDisconnection( )
-{
- Control::OnStageDisconnection();
-}
-
Vector3 SuperBlurView::GetNaturalSize()
{
if( mInputImage )
#define __DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H__
/*
- * Copyright (c) 2016 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.
virtual void OnStageConnection( int depth );
/**
- * @copydoc CustomActorImpl::OnStageDisconnection()
- */
- virtual void OnStageDisconnection();
-
- /**
* @copydoc CustomActorImpl::GetNaturalSize()
*/
virtual Vector3 GetNaturalSize();
/*
- * 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.
// rows and columns must be recalculated or the new size will not take effect.
mRowDirty = mColumnDirty = true;
RelayoutRequest();
+
+ Control::OnSizeSet( size );
}
void TableView::OnRelayout( const Vector2& size, RelayoutContainer& container )
void TableView::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
- if( mLayoutingChild )
+ if( ! mLayoutingChild )
{
- // we're in the middle of laying out children so no point doing anything here
- return;
- }
+ // Ensure we're not in the middle of laying out children
- // Check child properties on actor to decide its position inside the table
- HorizontalAlignment::Type horizontalAlignment = HorizontalAlignment::LEFT;
- VerticalAlignment::Type verticalAlignment = VerticalAlignment::TOP;
+ // Check child properties on actor to decide its position inside the table
+ HorizontalAlignment::Type horizontalAlignment = HorizontalAlignment::LEFT;
+ VerticalAlignment::Type verticalAlignment = VerticalAlignment::TOP;
- if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_HORIZONTAL_ALIGNMENT ) != Property::NONE )
- {
- std::string value = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_HORIZONTAL_ALIGNMENT ).Get<std::string >();
- Scripting::GetEnumeration< HorizontalAlignment::Type >( value.c_str(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
- horizontalAlignment );
- }
+ if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_HORIZONTAL_ALIGNMENT ) != Property::NONE )
+ {
+ std::string value = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_HORIZONTAL_ALIGNMENT ).Get<std::string >();
+ Scripting::GetEnumeration< HorizontalAlignment::Type >( value.c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ horizontalAlignment );
+ }
- if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_VERTICAL_ALIGNMENT ) != Property::NONE )
- {
- std::string value = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_VERTICAL_ALIGNMENT ).Get<std::string >();
- Scripting::GetEnumeration< VerticalAlignment::Type >( value.c_str(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
- verticalAlignment );
- }
+ if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_VERTICAL_ALIGNMENT ) != Property::NONE )
+ {
+ std::string value = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_VERTICAL_ALIGNMENT ).Get<std::string >();
+ Scripting::GetEnumeration< VerticalAlignment::Type >( value.c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+ verticalAlignment );
+ }
- Toolkit::TableView::CellPosition cellPosition;
- if( child.GetPropertyType( Toolkit::TableView::ChildProperty::ROW_SPAN ) != Property::NONE )
- {
- cellPosition.rowSpan = static_cast<unsigned int>( child.GetProperty( Toolkit::TableView::ChildProperty::ROW_SPAN ).Get<float>() );
- }
+ Toolkit::TableView::CellPosition cellPosition;
+ if( child.GetPropertyType( Toolkit::TableView::ChildProperty::ROW_SPAN ) != Property::NONE )
+ {
+ cellPosition.rowSpan = static_cast<unsigned int>( child.GetProperty( Toolkit::TableView::ChildProperty::ROW_SPAN ).Get<float>() );
+ }
- if( child.GetPropertyType( Toolkit::TableView::ChildProperty::COLUMN_SPAN ) != Property::NONE )
- {
- cellPosition.columnSpan = static_cast<unsigned int>( child.GetProperty( Toolkit::TableView::ChildProperty::COLUMN_SPAN ).Get<float>() );
- }
+ if( child.GetPropertyType( Toolkit::TableView::ChildProperty::COLUMN_SPAN ) != Property::NONE )
+ {
+ cellPosition.columnSpan = static_cast<unsigned int>( child.GetProperty( Toolkit::TableView::ChildProperty::COLUMN_SPAN ).Get<float>() );
+ }
- if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_INDEX ) != Property::NONE )
- {
- Vector2 indices = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_INDEX ).Get<Vector2 >();
- cellPosition.rowIndex = static_cast<unsigned int>( indices.x );
- cellPosition.columnIndex = static_cast<unsigned int>( indices.y );
+ if( child.GetPropertyType( Toolkit::TableView::ChildProperty::CELL_INDEX ) != Property::NONE )
+ {
+ Vector2 indices = child.GetProperty( Toolkit::TableView::ChildProperty::CELL_INDEX ).Get<Vector2 >();
+ cellPosition.rowIndex = static_cast<unsigned int>( indices.x );
+ cellPosition.columnIndex = static_cast<unsigned int>( indices.y );
- AddChild( child, cellPosition );
- SetCellAlignment(cellPosition, horizontalAlignment, verticalAlignment);
+ AddChild( child, cellPosition );
+ SetCellAlignment(cellPosition, horizontalAlignment, verticalAlignment);
+ }
+ else
+ {
+ bool availableCellFound = false;
- // Do not continue
- return;
- }
+ // Find the first available cell to store the actor in
+ const unsigned int rowCount = mCellData.GetRows();
+ const unsigned int columnCount = mCellData.GetColumns();
+ for( unsigned int row = 0; row < rowCount && !availableCellFound; ++row )
+ {
+ for( unsigned int column = 0; column < columnCount && !availableCellFound; ++column )
+ {
+ if( !(mCellData[ row ][ column ].actor) )
+ {
+ // Put the actor in the cell
+ CellData data;
+ data.actor = child;
+ data.position.columnIndex = column;
+ data.position.rowIndex = row;
+ data.horizontalAlignment = horizontalAlignment;
+ data.verticalAlignment = verticalAlignment;
+ mCellData[ row ][ column ] = data;
+
+ availableCellFound = true;
+ break;
+ }
+ }
+ }
- // Find the first available cell to store the actor in
- const unsigned int rowCount = mCellData.GetRows();
- const unsigned int columnCount = mCellData.GetColumns();
- for( unsigned int row = 0; row < rowCount; ++row )
- {
- for( unsigned int column = 0; column < columnCount; ++column )
- {
- if( !(mCellData[ row ][ column ].actor) )
+ if( ! availableCellFound )
{
- // Put the actor in the cell
+ // No empty cells, so increase size of the table
+ unsigned int newColumnCount = ( columnCount > 0 ) ? columnCount : 1;
+ ResizeContainers( rowCount + 1, newColumnCount );
+
+ // Put the actor in the first cell of the new row
CellData data;
data.actor = child;
- data.position.columnIndex = column;
- data.position.rowIndex = row;
+ data.position.rowIndex = rowCount;
+ data.position.columnIndex = 0;
data.horizontalAlignment = horizontalAlignment;
data.verticalAlignment = verticalAlignment;
- mCellData[ row ][ column ] = data;
-
- // Don't continue
- RelayoutRequest();
- return;
+ mCellData[ rowCount ][ 0 ] = data;
}
+
+ RelayoutRequest();
}
}
- // No empty cells, so increase size of the table
- unsigned int newColumnCount = ( columnCount > 0 ) ? columnCount : 1;
- ResizeContainers( rowCount + 1, newColumnCount );
-
- // Put the actor in the first cell of the new row
- CellData data;
- data.actor = child;
- data.position.rowIndex = rowCount;
- data.position.columnIndex = 0;
- data.horizontalAlignment = horizontalAlignment;
- data.verticalAlignment = verticalAlignment;
- mCellData[ rowCount ][ 0 ] = data;
- RelayoutRequest();
+ Control::OnChildAdd( child );
}
void TableView::OnChildRemove( Actor& child )
/*
- * Copyright (c) 2016 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.
void TextEditor::OnStageConnection( int depth )
{
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
-
// Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
+
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
}
bool TextEditor::OnTouched( Actor actor, const TouchData& touch )
/*
- * Copyright (c) 2016 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.
void TextField::OnStageConnection( int depth )
{
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
-
// Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
+
+ // Call the Control::OnStageConnection() to set the depth of the background.
+ Control::OnStageConnection( depth );
}
bool TextField::OnTouched( Actor actor, const TouchData& touch )
/*
- * Copyright (c) 2016 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.
}
}
-void TextLabel::OnStageConnection( int depth )
-{
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
-
- // The depth of the text renderer is set in the RenderText() called from OnRelayout().
-}
-
void TextLabel::ScrollingFinished()
{
// Pure Virtual from TextScroller Interface
#define DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
/*
- * Copyright (c) 2016 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.
*/
virtual float GetHeightForWidth( float width );
- /**
- * @copydoc Control::OnStageConnection()
- */
- virtual void OnStageConnection( int depth );
-
// From ControlInterface
/**
/*
- * Copyright (c) 2016 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.
self.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
}
-void TextSelectionPopup::OnStageConnection( int depth )
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextSelectionPopup::OnStageConnection\n" );
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
-
- // TextSelectionToolbar::OnStageConnection() will set the depths of all the popup's components.
-}
-
void TextSelectionPopup::HideAnimationFinished( Animation& animation )
{
Actor self = Self();
#define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
/*
- * Copyright (c) 2015 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.
*/
virtual void OnInitialize();
- /**
- * @copydoc Control::OnStageConnection()
- */
- virtual void OnStageConnection( int depth );
-
private: // Implementation
void HideAnimationFinished( Animation& animation );
/*
- * Copyright (c) 2016 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.
mScrollView.SetRulerX( mRulerX );
}
-void TextSelectionToolbar::OnStageConnection( int depth )
-{
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
-
- // Texts are controls, they have their own OnStageConnection() implementation.
- // Icons are inside a TableView. It has it's own OnStageConnection() implementation.
-}
-
void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
{
mMaxSize = maxSize;
#define DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
/*
- * Copyright (c) 2016 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.
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
/**
- * @copydoc Control::OnStageConnection()
- */
- virtual void OnStageConnection( int depth );
-
- /**
* @brief Set max size of Popup
* @param[in] maxSize Size (Vector2)
*/
/*
- * 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.
void ToolBar::OnChildAdd(Actor& child)
{
- Control::OnChildAdd( child );
-
if( !mInitializing )
{
// An actor is being added through the Actor's API.
// No OnChildRemove method required because Actors are added to the mLayout table view, so if an
// actor is removed using the Actor::RemoveChild method it will not remove anything because the
// actor is in mLayout not in Self().
+
+ Control::OnChildAdd( child );
}
} // namespace Internal
/*
- * Copyright (c) 2016 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.
void VideoView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
if( mVisual )
{
CustomActor self = Self();
Toolkit::GetImplementation(mVisual).SetOnStage( self );
}
+
+ Control::OnStageConnection( depth );
}
void VideoView::OnStageDisconnection()
/*
- * 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.
void CubeTransitionEffect::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
mCurrentRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, depth );
Self().AddRenderer( mCurrentRenderer );
+
+ Control::OnStageConnection( depth );
}
void CubeTransitionEffect::OnStageDisconnection()
/*
- * Copyright (c) 2016 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.
#include <dali/public-api/size-negotiation/relayout-container.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/devel-api/object/handle-devel.h>
+#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
#endif
+DALI_ENUM_TO_STRING_TABLE_BEGIN( CLIPPING_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, DISABLED )
+DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN )
+DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE )
+
/**
* Struct used to store Visual within the control, index is a unique key for each visual.
*/
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n", mImpl->mVisuals.Size() );
+ Actor self( Self() );
+
for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
{
// Check whether the visual is empty and enabled
if( (*iter)->visual && (*iter)->enabled )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection Setting visual(%d) on stage\n", (*iter)->index );
- Actor self( Self() );
Toolkit::GetImplementation((*iter)->visual).SetOnStage( self );
}
}
+
+ if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() )
+ {
+ Property::Value clippingValue = self.GetProperty( Actor::Property::CLIPPING_MODE );
+ int clippingMode = ClippingMode::DISABLED;
+ if( clippingValue.Get( clippingMode ) )
+ {
+ // Add a transparent background if we do not have any renderers or visuals so we clip our children
+
+ if( clippingMode == ClippingMode::CLIP_CHILDREN )
+ {
+ // Create a transparent background visual which will also get staged.
+ SetBackgroundColor( Color::TRANSPARENT );
+ }
+ }
+ }
}
void Control::OnStageDisconnection()
OnControlChildRemove( child );
}
+void Control::OnPropertySet( Property::Index index, Property::Value propertyValue )
+{
+ Actor self( Self() );
+ if( index == Actor::Property::CLIPPING_MODE )
+ {
+ // Only set the background if we're already on the stage and have no renderers or visuals
+
+ if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() && self.OnStage() )
+ {
+ ClippingMode::Type clippingMode = ClippingMode::DISABLED;
+ if( Scripting::GetEnumerationProperty< ClippingMode::Type >( propertyValue, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, clippingMode ) )
+ {
+ // Add a transparent background if we do not have one so we clip children
+
+ if( clippingMode == ClippingMode::CLIP_CHILDREN )
+ {
+ SetBackgroundColor( Color::TRANSPARENT );
+ }
+ }
+ }
+ }
+}
+
void Control::OnSizeSet(const Vector3& targetSize)
{
Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
#define DALI_TOOLKIT_CONTROL_IMPL_H
/*
- * Copyright (c) 2016 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.
/**
* @copydoc CustomActorImpl::OnStageConnection()
- * @note If overridden, then an up-call to Control::OnStageConnection MUST be made at the start.
+ * @note If overridden, then an up-call to Control::OnStageConnection MUST be made at the end.
*/
virtual void OnStageConnection( int depth );
/**
* @copydoc CustomActorImpl::OnChildAdd()
- * @note If overridden, then an up-call to Control::OnChildAdd MUST be made at the start.
+ * @note If overridden, then an up-call to Control::OnChildAdd MUST be made at the end.
*/
virtual void OnChildAdd( Actor& child );
virtual void OnChildRemove( Actor& child );
/**
+ * @copydoc CustomActorImpl::OnPropertySet()
+ * @note If overridden, then an up-call to Control::OnChildRemove MUST be made at the end.
+ */
+ virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
+
+ /**
* @copydoc CustomActorImpl::OnSizeSet()
- * @note If overridden, then an up-call to Control::OnSizeSet MUST be made at the start.
+ * @note If overridden, then an up-call to Control::OnSizeSet MUST be made at the end.
*/
virtual void OnSizeSet( const Vector3& targetSize );
/**
* @copydoc CustomActorImpl::OnSizeAnimation()
- * @note If overridden, then an up-call to Control::OnSizeAnimation MUST be made at the start.
+ * @note If overridden, then an up-call to Control::OnSizeAnimation MUST be made at the end.
*/
virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize );
// C++
void MyUIControlImpl::OnChildAdd( Actor& child );
{
- // Up call to Control first
- Control::OnChildAdd( child );
-
// Do any other operations required upon child addition
+
+ // Up call to Control at the end
+ Control::OnChildAdd( child );
}
~~~
~~~{.cpp}
// C++
void MyUIControlImpl::OnStageConnection( int depth )
{
- // Up call to Control first
- Control::OnStageConnection( depth );
-
// Do any other operations required upon stage connection
+
+ // Up call to Control at the end
+ Control::OnStageConnection( depth );
}
~~~
~~~{.cpp}
___________________________________________________________________________________________________
+### Clipping Support {#creating-controls-clipping}
+
+When an Actor is set to clip its children, the renderers have to be added manually in order to specify what its children need to clip to.
+The Control base class automates the creation of the renderers/visuals when it is set to clip its children.
+
+This is only done if the application or custom control writer has not added any renderers to the Control or registered any visuals
+(regardless of whether these visuals are enabled or not).
+
+If custom control writers want to define the clipping visuals themselves, then they should register all required visuals before the control is staged.
+
+___________________________________________________________________________________________________
+
### Other Features {#creating-controls-other}
+ [Background](@ref background)
hasChildProperties = true
end
- property.csharpGetter =" public #{propertyType} #{property.name} \n"\
- " { \n"\
- " get \n" \
+ property.csharpGetter =" public #{propertyType} #{property.name}\n"\
+ " {\n"\
+ " get\n" \
" {\n"\
" #{tempDeclaration}\n"\
" GetProperty( #{propertyName}).Get( #{propertyArg} temp );\n"\
if property.writable
#text.SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Property.Value("CENTER"));
- property.csharpSetter = " set \n" \
- " { \n"\
+ property.csharpSetter = " set\n" \
+ " {\n"\
" SetProperty( #{propertyName}, new Dali.Property.Value( value ) );\n" \
" }\n"\
" }\n"