-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Creating a Storyboard using C++
I answered in the ticket you opened in our bugtracker
Re: Creating a Storyboard using C++
The reason of the problem could be interesting to other MFC users. It was related to redefining the new keyword:
This way, the new operator is redirected to the debug MFC allocator. This is problematic because NoesisGUI objects are automatically destroyed whenever the reference counter reaches 0 using the installed memory allocator (passed at Initialization time). Being different to the MFC one, this was causing the crash at delete time.
Code: Select all
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
Re: Creating a Storyboard using C++
Another important thing. Since NoesisGUI v1.2 all the API is provided in a single header, NoesisGUI.h (to be used as a precompiled header) and under the Noesis namespace. This simplifies a lot the usage of NoesisGUI in C++ applications.
Following it, your code would simplify to:
Following it, your code would simplify to:
Code: Select all
Noesis::Ptr<Noesis::DoubleAnimation> anim = *new Noesis::DoubleAnimation();
anim->SetFrom(1.0f);
anim->SetTo(0.0f);
anim->SetDuration(Noesis::TimeSpan(0, 0, 0, 0, 500));
Noesis::SetTarget(anim.GetPtr(), m_cCanvas);
Noesis::Ptr<Noesis::PropertyPath> path = *new Noesis::PropertyPath("Opacity");
Noesis::SetTargetProperty(anim.GetPtr(), path.GetPtr());
Noesis::Ptr<Noesis::Storyboard> pStoryboard = *new Noesis::Storyboard();
pStoryboard->GetChildren()->Add(anim.GetPtr());
Re: Creating a Storyboard using C++
Hi,
I'm trying to do roughly the same as the initial poster.
Here is my code, written in a Control deriving from Grid:
The application crashes at Begin, the error is: "Target cannot be found". What am I doing wrong?
I'm trying to do roughly the same as the initial poster.
Here is my code, written in a Control deriving from Grid:
Code: Select all
using namespace Noesis;
Drawing::Color transparent(0.0f, 0.0f, 0.0f, 0.0f);
Drawing::Color black = Drawing::Color::Black;
NsFloat64 halfDuration = static_cast<NsFloat64>(duration * 0.5f);
// Fade in
Core::Ptr<Gui::PropertyPath> bgProperty = *new Gui::PropertyPath(Gui::Panel::BackgroundProperty);
Core::Ptr<Gui::ColorAnimation> pAnimIn = *new Gui::ColorAnimation();
pAnimIn->SetFrom(Core::Nullable<Drawing::Color>(transparent));
pAnimIn->SetTo(Core::Nullable<Drawing::Color>(black));
pAnimIn->SetDuration(Gui::TimeSpan(static_cast<NsFloat64>(halfDuration)));
Gui::Storyboard::SetTarget(pAnimIn.GetPtr(), this);
Gui::Storyboard::SetTargetProperty(pAnimIn.GetPtr(), bgProperty.GetPtr());
Core::Ptr<Gui::Storyboard> pStoryboard = *new Gui::Storyboard();
pStoryboard->GetChildren()->Add(pAnimIn.GetPtr());
pStoryboard->Begin();
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Creating a Storyboard using C++
Hi,
First of all there is something wrong in your code, you are creating a Color animation, but your PropertyPath points to a Brush property. I think you should create the property path like this (assuming you have a SolidColorBrush set in the Background property of the element firing this animation):
About the error, it seems we don't support to Begin a Storyboard, without specifying a target, if it is created dynamically (when it's not defined in a xaml file). We will solve this for a future release. Meanwhile you can use in this case the version that receives a target:
First of all there is something wrong in your code, you are creating a Color animation, but your PropertyPath points to a Brush property. I think you should create the property path like this (assuming you have a SolidColorBrush set in the Background property of the element firing this animation):
Code: Select all
Core::Ptr<Gui::PropertyPath> bgProperty = *new Gui::PropertyPath("Background.Color");
Code: Select all
storyboard->Begin(this);
Re: Creating a Storyboard using C++
That fixed the problem, thank you very much!
Who is online
Users browsing this forum: No registered users and 1 guest