#include <dali-toolkit/dali-toolkit.h>
#include <dali/public-api/object/property-map.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
using namespace Dali;
using namespace Dali::Toolkit;
//Create mesh property map
Property::Map map;
map.Insert( Visual::Property::TYPE, Visual::MESH );
+ map.Insert( DevelVisual::Property::TRANSFORM,
+ Property::Map().Add( DevelVisual::Transform::Property::ORIGIN, Align::CENTER )
+ .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::CENTER ) );
map.Insert( MeshVisual::Property::OBJECT_URL, MODEL_FILE_TABLE[mModelIndex] );
map.Insert( MeshVisual::Property::MATERIAL_URL, MATERIAL_FILE_TABLE[mModelIndex] );
map.Insert( MeshVisual::Property::TEXTURES_PATH, TEXTURES_PATH );
#include <dali-toolkit/dali-toolkit.h>
#include <dali/public-api/object/property-map.h>
+#include <dali-toolkit/devel-api/align-enums.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/public-api/controls/slider/slider.h>
using namespace Dali;
mVisualMap.Clear();
mVisualMap[ Visual::Property::TYPE ] = Visual::PRIMITIVE;
mVisualMap[ PrimitiveVisual::Property::MIX_COLOR ] = mColor;
+ mVisualMap[ DevelVisual::Property::TRANSFORM ] =
+ Property::Map().Add( DevelVisual::Transform::Property::ORIGIN, Align::CENTER )
+ .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::CENTER );
}
//Sets the 3D model to a sphere and modifies the sliders appropriately.
#include "beat-control-impl.h"
#include <dali-toolkit/dali-toolkit.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali-toolkit/devel-api/align-enums.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
-#include <cstdio>
-
using namespace Dali; // Needed for macros
using namespace Dali::Toolkit;
{
Toolkit::TransitionData transitionData;
- if( value.GetType() == Property::ARRAY )
+ const Property::Array* array = value.GetArray();
+ if( array )
{
- transitionData = Toolkit::TransitionData::New( *value.GetArray());
+ transitionData = Toolkit::TransitionData::New( *array );
}
- else if( value.GetType() == Property::MAP )
+ else
{
- transitionData = Toolkit::TransitionData::New( *value.GetMap() );
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ transitionData = Toolkit::TransitionData::New( *map );
+ }
}
return transitionData;
}
Internal::BeatControl::BeatControl()
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mTransformSize(1.0f, 1.0f),
+ mTransformOrigin(Align::CENTER),
+ mTransformAnchorPoint(Align::CENTER),
mAnimationPlaying(0)
{
}
// Make the visual half the size of the control, but leave
// origin and anchor point at center, position is relative, but Zer0
transformMap[ DevelVisual::Transform::Property::SIZE ] = mTransformSize;
+ transformMap[ DevelVisual::Transform::Property::ORIGIN ] = mTransformOrigin;
+ transformMap[ DevelVisual::Transform::Property::ANCHOR_POINT ] = mTransformAnchorPoint;
mVisual.SetTransformAndSize( transformMap, size );
}
}
{
case Demo::BeatControl::Property::BEAT_VISUAL:
{
- bool sizeOnly = false;
+ bool sizeAndPositionOnly = false;
// Determine if a transform.size property exists in the map, and
// save it.
Property::Map* transformMap = value->GetMap();
if( transformMap )
{
+ // We'll increment this whenever SIZE, ORIGIN or ANCHOR_POINT's are modified as we won't need to create a new visual if only these properties are used
+ // If there are more properties in the transform map, then we need to create a new visual
+ unsigned int sizeAndPositionPropertyCount = 0;
+
Property::Value* sizeValue = transformMap->Find( DevelVisual::Transform::Property::SIZE, "size" );
if( sizeValue )
{
sizeValue->Get( impl.mTransformSize );
- if( map->Count() == 1 && transformMap->Count() == 1 )
+ ++sizeAndPositionPropertyCount;
+ }
+
+ Property::Value* originValue = transformMap->Find( DevelVisual::Transform::Property::ORIGIN, "origin" );
+ if( originValue )
+ {
+ int intValue = 0;
+ if( originValue->Get( intValue ) )
{
- sizeOnly = true;
+ impl.mTransformOrigin = static_cast< Toolkit::Align::Type >( intValue );
+ ++sizeAndPositionPropertyCount;
}
}
+
+ Property::Value* anchorPointValue = transformMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT, "anchorPoint" );
+ if( anchorPointValue )
+ {
+ int intValue = 0;
+ if( anchorPointValue->Get( intValue ) )
+ {
+ impl.mTransformAnchorPoint = static_cast< Toolkit::Align::Type >( intValue );
+ ++sizeAndPositionPropertyCount;
+ }
+ }
+
+ // If the only properties that the application is overriding are the size and the position properties, then we do not need to create another visual.
+ if( map->Count() == 1 && transformMap->Count() == sizeAndPositionPropertyCount )
+ {
+ sizeAndPositionOnly = true;
+ }
}
}
- if( ! sizeOnly )
+ if( ! sizeAndPositionOnly )
{
// Only register a visual if there is more than just a size setting
impl.mVisual = Toolkit::VisualFactory::Get().CreateVisual( *map );
#define DALI_DEMO_INTERNAL_BEAT_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.
#include "beat-control.h"
#include <dali/public-api/animation/animation.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/align-enums.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
Dali::Animation mYAnimation;
Dali::Animation mFadeAnimation;
Dali::Vector2 mTransformSize;
+ Dali::Toolkit::Align::Type mTransformOrigin;
+ Dali::Toolkit::Align::Type mTransformAnchorPoint;
int mAnimationPlaying;
};
/*
- * 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.
Property::Map map;
CreateVisualMap( i, map );
map.Add( DevelVisual::Property::TRANSFORM, Property::Map()
- .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) );
+ .Add( DevelVisual::Transform::Property::SIZE, Vector2(0.8f, 0.8f) ) );
mVisualButtons[i] = BeatControl::New();
mVisualButtons[i].SetProperty( BeatControl::Property::BEAT_VISUAL, map );
mVisualButtons[i].SetName("VisualButton");