51 lines
1.8 KiB
C++
51 lines
1.8 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#include "ui/ui_item_automated_property_provider.h"
|
|
#include "ui/ui_item.h"
|
|
|
|
using GS::Quaternion;
|
|
using namespace GS::Core;
|
|
using namespace GS::S2D::Automation;
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool ItemPropertyProvider::GetProperty(MotionChannel::Type type, float &v)
|
|
{
|
|
switch (type)
|
|
{
|
|
case MotionChannel::XPos: v = item->GetPosition().x; return true;
|
|
case MotionChannel::YPos: v = item->GetPosition().y; return true;
|
|
case MotionChannel::ZRot: v = item->GetRotation(); return true;
|
|
case MotionChannel::XScl: v = item->GetScale().x; return true;
|
|
case MotionChannel::YScl: v = item->GetScale().y; return true;
|
|
}
|
|
return false;
|
|
}
|
|
bool ItemPropertyProvider::SetProperty(MotionChannel::Type type, float v)
|
|
{
|
|
Vector2 t;
|
|
switch (type)
|
|
{
|
|
case MotionChannel::XPos: t = item->GetPosition(); item->SetPosition(v, t.y); return true;
|
|
case MotionChannel::YPos: t = item->GetPosition(); item->SetPosition(t.x, v); return true;
|
|
case MotionChannel::ZRot: item->SetRotation(v); return true;
|
|
case MotionChannel::XScl: t = item->GetScale(); item->SetScale(v, t.y); return true;
|
|
case MotionChannel::YScl: t = item->GetScale(); item->SetScale(t.x, v); return true;
|
|
}
|
|
return false;
|
|
}
|
|
Quaternion ItemPropertyProvider::GetRotation() const
|
|
{
|
|
return Quaternion::FromEuler(0, 0, item->GetRotation());
|
|
}
|
|
bool ItemPropertyProvider::SetRotation(const Quaternion &q)
|
|
{
|
|
item->SetRotation(q.AsMatrix3().AsEuler().z);
|
|
return true;
|
|
}
|
|
//------------------------------------------------------------------------------
|