コード例 #1
0
void PathConstrainer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
{
  if( index == Dali::PathConstrainer::Property::FORWARD )
  {
    propertyValue.Get(mForward);
  }
  else if( index == Dali::PathConstrainer::Property::POINTS  )
  {
    const Property::Array* array = propertyValue.GetArray();
    mPath->ClearPoints();
    if( array )
    {
      for( Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i )
      {
        Vector3 point;
        array->GetElementAt( i ).Get( point );
        mPath->AddPoint( point );
      }
    }
  }
  else if( index == Dali::PathConstrainer::Property::CONTROL_POINTS )
  {
    const Property::Array* array = propertyValue.GetArray();
    mPath->ClearControlPoints();
    if( array )
    {
      for( Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i )
      {
        Vector3 point;
        array->GetElementAt( i ).Get( point );
        mPath->AddControlPoint( point );
      }
    }
  }
}
コード例 #2
0
ファイル: image-view-impl.cpp プロジェクト: mettalla/dali
void ImageView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
  Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( Dali::BaseHandle( object ) );

  if ( imageView )
  {
    switch ( index )
    {
      case Toolkit::ImageView::Property::IMAGE:
      {
        std::string imageUrl;
        if( value.Get( imageUrl ) )
        {
          ImageView& impl = GetImpl( imageView );
          impl.SetImage( imageUrl );
        }

        // if its not a string then get a Property::Map from the property if possible.
        Property::Map map;
        if( value.Get( map ) )
        {
          ImageView& impl = GetImpl( imageView );
          impl.SetImage( map );
        }

        break;
      }
    }
  }
}
コード例 #3
0
int UtcDaliVideoViewProperty4(void)
{
  ToolkitTestApplication application;
  tet_infoline(" UtcDaliVideoViewProperty4");

  Toolkit::VideoView view = Toolkit::VideoView::New();
  DALI_TEST_CHECK( view );

  float left, right;
  left = right = 0.f;

  Property::Map map;
  map.Insert( VOLUME_LEFT, 1.0f );
  map.Insert( VOLUME_RIGHT, 0.5f );

  Property::Map map2;
  view.SetProperty( VideoView::Property::VOLUME, map );
  Property::Value val4 = view.GetProperty( VideoView::Property::VOLUME );
  DALI_TEST_CHECK( val4.Get( map2 ) );

  Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
  Property::Value* volumeRight = map.Find( VOLUME_RIGHT );

  DALI_TEST_CHECK( volumeLeft && volumeLeft->Get( left ) );
  DALI_TEST_CHECK( volumeRight && volumeRight->Get( right ) );
  DALI_TEST_CHECK( left == 1.0f );
  DALI_TEST_CHECK( right == 0.5f );

  END_TEST;
}
コード例 #4
0
// Positive test case for a method
int UtcDaliVideoViewProperty1(void)
{
  ToolkitTestApplication application;
  tet_infoline(" UtcDaliVideoViewProperty1");

  Toolkit::VideoView view = Toolkit::VideoView::New();
  DALI_TEST_CHECK( view );

  std::string file;
  view.SetProperty( VideoView::Property::VIDEO, TEST_FILE );
  Property::Value val = view.GetProperty( VideoView::Property::VIDEO );
  DALI_TEST_CHECK( val.Get( file ) );
  DALI_TEST_CHECK( file == TEST_FILE );
  END_TEST;
}
コード例 #5
0
int UtcDaliImageActorImageProperty(void)
{
  TestApplication application;
  Image image = Image::New( "MY_PATH" );
  ImageActor imageActor = ImageActor::New( image );

  Stage::GetCurrent().Add( imageActor );
  application.SendNotification();
  application.Render();

  Property::Value imageMap = imageActor.GetProperty( ImageActor::IMAGE );
  DALI_TEST_CHECK( imageMap.HasKey( "filename" ) );
  DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
  END_TEST;
}
コード例 #6
0
void LinearConstrainer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
{
  const Property::Array* array = propertyValue.GetArray();
  if( array )
  {
    size_t propertyArrayCount = array->Count();
    if( index == Dali::LinearConstrainer::Property::VALUE  )
    {
      mValue.Clear(); // remove old values
      mValue.Resize( propertyArrayCount );
      for( size_t i(0); i != propertyArrayCount; ++i )
      {
        array->GetElementAt( i ).Get( mValue[ i ] );
      }
    }
    else if( index == Dali::LinearConstrainer::Property::PROGRESS  )
    {
      mProgress.Clear(); // remove old values
      mProgress.Resize( propertyArrayCount );
      for( size_t i(0); i != propertyArrayCount; ++i )
      {
        array->GetElementAt( i ).Get( mProgress[ i ] );
      }
    }
  }
}
コード例 #7
0
ファイル: utc-Dali-TextField.cpp プロジェクト: mettalla/dali
bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
{
  bool result = false;
  Property::Map imageMap;
  imageMap[mapKey] =mapValue;

  field.SetProperty( property , imageMap );
  Property::Value propValue = field.GetProperty( property );
  Property::Map* resultMap = propValue.GetMap();

  if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
  {
    result = true;
  }

  return result;
}
コード例 #8
0
void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
{
  if( renderer )
  {
    Property::Value* type = propertyMap.Find( RENDERER_TYPE_NAME );
    std::string typeValue ;
    if( type && type->Get( typeValue ))
    {
      //If there's been a renderer type change then we have to return a new shader
      if( typeValue ==  COLOR_RENDERER && typeid( renderer ) != typeid( ColorRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  GRADIENT_RENDERER && typeid( renderer ) != typeid( GradientRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  IMAGE_RENDERER && typeid( renderer ) != typeid( ImageRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  N_PATCH_RENDERER && typeid( renderer ) != typeid( NPatchRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  BORDER_RENDERER && typeid( renderer ) != typeid( BorderRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
    }

    GetImplementation( renderer ).Initialize( actor, propertyMap );
  }
  else
  {
    renderer = GetControlRenderer( propertyMap );
  }

}
コード例 #9
0
int UtcDaliVideoViewProperty3(void)
{
  ToolkitTestApplication application;
  tet_infoline(" UtcDaliVideoViewProperty3");

  Toolkit::VideoView view = Toolkit::VideoView::New();
  DALI_TEST_CHECK( view );

  bool muted;
  Property::Value val = view.GetProperty( VideoView::Property::MUTED );
  DALI_TEST_CHECK( val.Get( muted ) );
  DALI_TEST_CHECK( !muted );

  view.SetProperty( VideoView::Property::MUTED, true );
  val = view.GetProperty( VideoView::Property::MUTED );
  DALI_TEST_CHECK( val.Get( muted ) );
  DALI_TEST_CHECK( muted );
  END_TEST;
}
コード例 #10
0
int UtcDaliVideoViewProperty2(void)
{
  ToolkitTestApplication application;
  tet_infoline(" UtcDaliVideoViewProperty2");

  Toolkit::VideoView view = Toolkit::VideoView::New();
  DALI_TEST_CHECK( view );

  bool looping;
  Property::Value val = view.GetProperty( VideoView::Property::LOOPING );
  DALI_TEST_CHECK( val.Get( looping ) );
  DALI_TEST_CHECK( !looping );

  view.SetProperty( VideoView::Property::LOOPING, true );
  val = view.GetProperty( VideoView::Property::LOOPING );
  DALI_TEST_CHECK( val.Get( looping ) );
  DALI_TEST_CHECK( looping );
  END_TEST;
}
コード例 #11
0
void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
{
  if( mImpl->mCustomShader )
  {
    mImpl->mCustomShader->SetPropertyMap( propertyMap );
  }
  else
  {
    Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
    if( customShaderValue )
    {
      Property::Map customShader;
      if( customShaderValue->Get( customShader ) )
      {
        mImpl->mCustomShader = new Impl::CustomShader( propertyMap );
      }
    }
  }
  DoInitialize( actor, propertyMap );
}
コード例 #12
0
bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
                          const Replacement& replacer )
{
  bool done = false;

  // some values are ambiguous as we have no Property::Type but can be disambiguated in the json

  // Currently Rotations and Rectangle must always be disambiguated when a type isnt available
  if( Disambiguated( node, value, replacer ) )
  {
    done = true;
  }
  else
  {
    if( node.Size() )
    {
      // our current heuristic for deciding an array is actually a vector and not say a map
      // is to check if the values are all floats
      bool allNumbers = true;
      for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
      {
        OptionalFloat f = IsFloat((*iter).second);
        if(!f)
        {
          allNumbers = false;
          break;
        }
      }

      if( allNumbers )
      {
        // prefer finding vectors over presuming composite Property::Array...
        if( OptionalMatrix v = IsMatrix(node) )
        {
          value = *v;
          done = true;
        }
        else if( OptionalMatrix3 v = IsMatrix3(node) )
        {
          value = *v;
          done = true;
        }
        else if( OptionalVector4 v = IsVector4(node) )
        {
          value = *v;
          done = true;
        }
        else if( OptionalVector3 v = IsVector3(node) )
        {
          value = *v;
          done = true;
        }
        else if( OptionalVector2 v = IsVector2(node) )
        {
          value = *v;
          done = true;
        }
        else if( 4 == node.Size() )
        {
          if( OptionalVector4 v = IsVector4(node) )
          {
            value = *v;
            done = true;
          }
        }
        else
        {
          value = Property::Value(Property::ARRAY);
          Property::Array* array = value.GetArray();

          if( array )
          {
            for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
            {
              Property::Value childValue;
              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
              {
                array->PushBack( childValue );
                done = true;
              }
            }
          }
        }
      }

      if(!done)
      {
        // presume an array or map
        // container of size 1
        TreeNode::ConstIterator iter = node.CBegin();

        // its seems legal with current json parser for a map to have an empty key
        // but here we take that to mean the structure is a list
        if( ((*iter).first) == 0 )
        {
          value = Property::Value(Property::ARRAY);
          Property::Array* array = value.GetArray();

          if( array )
          {
            for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
            {
              Property::Value childValue;
              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
              {
                array->PushBack( childValue );
                done = true;
              }
            }
          }
        }
        else
        {
          value = Property::Value(Property::MAP);
          Property::Map* map = value.GetMap();

          if( map )
          {
            for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
            {
              Property::Value childValue;
              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
              {
                map->Insert( (*iter).first, childValue );
                done = true;
              }
            }
          }
        }
      } // if!done
    } // if node.size()
    else // if( 0 == node.size() )
    {
      // no children so either one of bool, float, integer, string
      OptionalBoolean aBool    = replacer.IsBoolean(node);
      OptionalInteger anInt    = replacer.IsInteger(node);
      OptionalFloat   aFloat   = replacer.IsFloat(node);
      OptionalString  aString  = replacer.IsString(node);

      if(aBool)
      {
        // a bool is also an int but here we presume int
        if(anInt)
        {
          value = *anInt;
          done = true;
        }
        else
        {
          value = *aBool;
          done = true;
        }
      }
      else
      {
        // Note: These are both floats and strings
        // {"value":"123"}
        // {"value":123}
        // This means we can't have a string with purely numeric content without disambiguation.
        if(aFloat)
        {
          value = *aFloat;
          done = true;
        }
        else if(anInt)
        {
          value = *anInt;
          done = true;
        }
        else
        {
          // string always succeeds with the current json parser so its last
          value = *aString;
          done = true;
        }

      } // if aBool

    } // if( node.size() )

  } // if Disambiguated()

  return done;
} // bool SetPropertyFromNode( const TreeNode& node, Property::Value& value )
コード例 #13
0
bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value,
                          const Replacement& replacer )
{
  bool done = false;

  switch(type)
  {
    case Property::BOOLEAN:
    {
      if( OptionalBoolean v = replacer.IsBoolean(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::FLOAT:
    {
      if( OptionalFloat v = replacer.IsFloat(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::INTEGER:
    {
      if( OptionalInteger v = replacer.IsInteger(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::VECTOR2:
    {
      if( OptionalVector2 v = replacer.IsVector2(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::VECTOR3:
    {
      if( OptionalVector3 v = replacer.IsVector3(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::VECTOR4:
    {
      if( OptionalVector4 v = replacer.IsVector4(node) )
      {
        value = *v;
        done = true;
      }
      else if( OptionalString s = replacer.IsString(node) )
      {
        if( (*s)[0] == '#' && 7 == (*s).size() )
        {
          value = HexStringToVector4( &(*s)[1] );
          done = true;
        }
        else if( Dali::ColorController::Get() )
        {
          Vector4 color;
          done = Dali::ColorController::Get().RetrieveColor( *s, color );
          value = color;
        }
      }
      else if( TreeNode::OBJECT == node.GetType() )
      {
        // check for "r", "g" and "b" child color component nodes
        OptionalInteger r = replacer.IsInteger( IsChild(node, "r") );
        OptionalInteger g = replacer.IsInteger( IsChild(node, "g") );
        OptionalInteger b = replacer.IsInteger( IsChild(node, "b") );
        if( r && g && b )
        {
          float red( (*r) * (1.0f/255.0f) );
          float green( (*g) * (1.0f/255.0f) );
          float blue( (*b) * (1.0f/255.0f) );
          // check for optional "a" (alpha) node, default to fully opaque if it is not found.
          float alpha( 1.0f );
          OptionalInteger a = replacer.IsInteger( IsChild(node, "a") );
          if( a )
          {
            alpha = (*a) * (1.0f/255.0f);
          }
          value = Vector4( red, green, blue, alpha );
          done = true;
        }
      }
      break;
    }
    case Property::MATRIX3:
    {
      if( OptionalMatrix3 v = replacer.IsMatrix3(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::MATRIX:
    {
      if( OptionalMatrix v = replacer.IsMatrix(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::RECTANGLE:
    {
      if( OptionalRect v = replacer.IsRect(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::ROTATION:
    {
      if(4 == node.Size())
      {
        if( OptionalVector4 ov = replacer.IsVector4(node) )
        {
          const Vector4& v = *ov;
          // angle, axis as per spec
          value = Quaternion(Radian(Degree(v[3])),
                             Vector3(v[0],v[1],v[2]));
          done = true;
        }
      }
      else
      {
        // degrees Euler as per spec
        if( OptionalVector3 v = replacer.IsVector3(node) )
        {
          value = Quaternion(Radian(Degree((*v).x)),
                             Radian(Degree((*v).y)),
                             Radian(Degree((*v).z)));
          done = true;
        }
      }
      break;
    }
    case Property::STRING:
    {
      if( OptionalString v = replacer.IsString(node) )
      {
        value = *v;
        done = true;
      }
      break;
    }
    case Property::ARRAY:
    {
      if( replacer.IsArray( node, value ) )
      {
        done = true;
      }
      else if(node.Size())
      {
        value = Property::Value(Property::ARRAY);
        Property::Array* array = value.GetArray();

        unsigned int i = 0;
        TreeNode::ConstIterator iter(node.CBegin());

        if( array )
        {
          for( ; i < node.Size(); ++i, ++iter)
          {
            Property::Value childValue;
            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
            {
              array->PushBack( childValue );
            }
          }

          if( array->Count() == node.Size() )
          {
            done = true;
          }
          else
          {
            done = false;
          }
        }
      }
      break;
    }
    case Property::MAP:
    {
      if( replacer.IsMap( node, value ) )
      {
        done = true;
      }
      else if(node.Size())
      {
        value = Property::Value(Property::MAP);
        Property::Map* map = value.GetMap();

        unsigned int i = 0;
        TreeNode::ConstIterator iter(node.CBegin());

        if( map )
        {
          for( ; i < node.Size(); ++i, ++iter)
          {
            Property::Value childValue;
            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
            {
              map->Insert( (*iter).first, childValue );
            }
          }

          if( map->Count() == node.Size() )
          {
            done = true;
          }
          else
          {
            done = false;
          }
        }
      }
      break;
    }
    case Property::NONE:
    {
      break;
    }
  } // switch type

  return done;
}
コード例 #14
0
Image NewImage( const Property::Value& property )
{
  Image ret;

  std::string filename;
  Internal::ImageAttributes attributes = Internal::ImageAttributes::New();

  const Property::Map* map = property.GetMap();
  ImageType imageType = RESOURCE_IMAGE; // default to resource image
  if( map )
  {
    // first check the type as it determines, which other parameters are needed
    const Property::Value* value = map->Find( "type" );
    if( value )
    {
      std::string type;
      value->Get( type );
      for( unsigned int i = 0; i < imageTypeCount; ++i )
      {
        if( 0 == type.compare( ImageTypeName[ i ] ) )
        {
          imageType = static_cast<ImageType>( i );
          break;
        }
      }
    }

    // filename is only needed for resource images
    if( RESOURCE_IMAGE == imageType )
    {
      const Property::Value* value = map->Find( "filename" );
      if( value )
      {
        value->Get( filename );
      }
      // if empty file, no need to go further
      if( filename.size() == 0 )
      {
        DALI_LOG_ERROR( "No filename\n" );
        return Image();
      }
    }

    // Width and height can be set individually. Dali derives the unspecified
    // dimension from the aspect ratio of the raw image.
    int width = 0, height = 0;

    value = map->Find( "width" );
    if( value )
    {
      // handle floats and integer the same for json script
      if( value->GetType() == Property::FLOAT )
      {
        width = static_cast<unsigned int>( value->Get<float>() );
      }
      else
      {
        value->Get( width );
      }
    }
    value = map->Find( "height" );
    if( value )
    {
      if( value->GetType() == Property::FLOAT )
      {
        height = static_cast<int>( value->Get<float>() );
      }
      else
      {
        value->Get( height );
      }
    }
    attributes.SetSize( width, height );

    Pixel::Format pixelFormat = Pixel::RGBA8888;
    value = map->Find( "pixelFormat" );
    if( value )
    {
      std::string format;
      value->Get( format );
      GetEnumeration< Pixel::Format >( format.c_str(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT, pixelFormat );
    }

    value = map->Find( "fittingMode" );
    if( value )
    {
      std::string fitting;
      value->Get( fitting );
      FittingMode::Type mode;
      if( GetEnumeration< FittingMode::Type >( fitting.c_str(), IMAGE_FITTING_MODE_TABLE, IMAGE_FITTING_MODE_TABLE_COUNT, mode ) )
      {
        attributes.SetScalingMode( mode );
      }
    }

    value = map->Find( "samplingMode" );
    if( value )
    {
      std::string sampling;
      value->Get( sampling );
      SamplingMode::Type mode;
      if( GetEnumeration< SamplingMode::Type >( sampling.c_str(), IMAGE_SAMPLING_MODE_TABLE, IMAGE_SAMPLING_MODE_TABLE_COUNT, mode ) )
      {
        attributes.SetFilterMode( mode );
      }
    }

    value = map->Find( "orientation" );
    if( value )
    {
      bool b = value->Get<bool>();
      attributes.SetOrientationCorrection( b );
    }

    switch( imageType )
    {
      case RESOURCE_IMAGE :
      {
        ret = ResourceImage::New( filename, ImageDimensions( attributes.GetSize().x, attributes.GetSize().y ),
                                  attributes.GetScalingMode(), attributes.GetFilterMode(), attributes.GetOrientationCorrection() );
        break;
      }
      case BUFFER_IMAGE :
      {
        ret = BufferImage::New( attributes.GetWidth(),
                                attributes.GetHeight(),
                                pixelFormat );
        break;
      }
      case FRAME_BUFFER_IMAGE :
      {
        ret = FrameBufferImage::New( attributes.GetWidth(),
                                     attributes.GetHeight(),
                                     pixelFormat );
        break;
      }
    }
  }

  return ret;

} // Image NewImage( Property::Value map )
コード例 #15
0
int UtcDaliControlRendererGetPropertyMap3(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererGetPropertyMap3: linear GradientRenderer" );

  RendererFactory factory = RendererFactory::Get();
  DALI_TEST_CHECK( factory );

  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "gradient-renderer");

  Vector2 start(-1.f, -1.f);
  Vector2 end(1.f, 1.f);
  propertyMap.Insert("gradient-start-position", start);
  propertyMap.Insert("gradient-end-position", end);
  propertyMap.Insert("gradient-spread-method", "repeat");

  propertyMap.Insert("gradient-stop-offset", Vector2(0.2f, 0.8f));

  Property::Array stopColors;
  stopColors.PushBack( Color::RED );
  stopColors.PushBack( Color::GREEN );
  propertyMap.Insert("gradient-stop-color", stopColors);

  ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);

  Property::Map resultMap;
  gradientRenderer.CreatePropertyMap( resultMap );

  // check the property values from the returned map from control renderer
  Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "gradient-renderer" );

  value = resultMap.Find( "gradient-units", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "object-bounding-box" );

  value = resultMap.Find( "gradient-spread-method", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "repeat" );

  value = resultMap.Find( "gradient-start-position", Property::VECTOR2 );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( value->Get<Vector2>(), start , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-end-position", Property::VECTOR2 );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( value->Get<Vector2>(), end , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-stop-offset", Property::ARRAY );
  DALI_TEST_CHECK( value );
  Property::Array* offsetArray = value->GetArray();
  DALI_TEST_CHECK( offsetArray->Count() == 2 );
  DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.2f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.8f , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-stop-color", Property::ARRAY );
  DALI_TEST_CHECK( value );
  Property::Array* colorArray = value->GetArray();
  DALI_TEST_CHECK( colorArray->Count() == 2 );
  DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  END_TEST;
}
コード例 #16
0
int UtcDaliControlRendererGetPropertyMap4(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererGetPropertyMap4: radial GradientRenderer" );

  RendererFactory factory = RendererFactory::Get();
  DALI_TEST_CHECK( factory );

  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "gradient-renderer");

  Vector2 center(100.f, 100.f);
  float radius = 100.f;
  propertyMap.Insert("gradient-units", "user-space");
  propertyMap.Insert("gradient-center", center);
  propertyMap.Insert("gradient-radius", radius);
  propertyMap.Insert("gradient-stop-offset", Vector3(0.1f, 0.3f, 1.1f));

  Property::Array stopColors;
  stopColors.PushBack( Color::RED );
  stopColors.PushBack( Color::BLACK );
  stopColors.PushBack( Color::GREEN );
  propertyMap.Insert("gradient-stop-color", stopColors);

  ControlRenderer gradientRenderer = factory.GetControlRenderer(propertyMap);
  DALI_TEST_CHECK( gradientRenderer );

  Property::Map resultMap;
  gradientRenderer.CreatePropertyMap( resultMap );

  // check the property values from the returned map from control renderer
  Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "gradient-renderer" );

  value = resultMap.Find( "gradient-units", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "user-space" );

  value = resultMap.Find( "gradient-spread-method", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "pad" );

  value = resultMap.Find( "gradient-center", Property::VECTOR2 );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( value->Get<Vector2>(), center , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-radius", Property::FLOAT );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( value->Get<float>(), radius , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-stop-offset", Property::ARRAY );
  DALI_TEST_CHECK( value );
  Property::Array* offsetArray = value->GetArray();
  DALI_TEST_CHECK( offsetArray->Count() == 3 );
  DALI_TEST_EQUALS( offsetArray->GetElementAt(0).Get<float>(), 0.1f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  DALI_TEST_EQUALS( offsetArray->GetElementAt(1).Get<float>(), 0.3f , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  // any stop value will be clamped to [0.0, 1.0];
  DALI_TEST_EQUALS( offsetArray->GetElementAt(2).Get<float>(), 1.0f , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  value = resultMap.Find( "gradient-stop-color", Property::ARRAY );
  DALI_TEST_CHECK( value );
  Property::Array* colorArray = value->GetArray();
  DALI_TEST_CHECK( colorArray->Count() == 3 );
  DALI_TEST_EQUALS( colorArray->GetElementAt(0).Get<Vector4>(), Color::RED , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  DALI_TEST_EQUALS( colorArray->GetElementAt(1).Get<Vector4>(), Color::BLACK , Math::MACHINE_EPSILON_100, TEST_LOCATION );
  DALI_TEST_EQUALS( colorArray->GetElementAt(2).Get<Vector4>(), Color::GREEN , Math::MACHINE_EPSILON_100, TEST_LOCATION );

  END_TEST;
}
コード例 #17
0
ファイル: key-frames-impl.cpp プロジェクト: mettalla/dali
void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
{
  if(mType == Property::NONE)
  {
    CreateKeyFramesSpec(value.GetType());
  }

  // Once we have created a type, can only add values of the same type
  DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );

  DALI_ASSERT_DEBUG(mKeyFrames);

  switch(mType)
  {
    case Property::BOOLEAN:
    {
      Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<bool>(), alpha);
      break;
    }
    case Property::INTEGER:
    {
      Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<int>(), alpha);
      break;
    }
    case Property::FLOAT:
    {
      Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<float>(), alpha);
      break;
    }
    case Property::VECTOR2:
    {
      Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
      break;
    }
    case Property::VECTOR3:
    {
      Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
      break;
    }
    case Property::VECTOR4:
    {
      Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
      break;
    }
    case Property::ROTATION:
    {
      Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
      kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
      break;
    }
    default:
      DALI_ASSERT_DEBUG(!"Type not supported");
      break;
  }
}