darrenc182
Topic Author
Posts: 6
Joined: 23 May 2015, 04:05

Re: Creating a Storyboard using C++

18 Jun 2015, 01:02

Has there been any update?
 
User avatar
sfernandez
Site Admin
Posts: 1920
Joined: 22 Dec 2011, 19:20

Re: Creating a Storyboard using C++

18 Jun 2015, 18:59

I answered in the ticket you opened in our bugtracker ;)
 
User avatar
jsantos
Site Admin
Posts: 2908
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a Storyboard using C++

03 Jul 2015, 13:17

The reason of the problem could be interesting to other MFC users. It was related to redefining the new keyword:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
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.
 
User avatar
jsantos
Site Admin
Posts: 2908
Joined: 20 Jan 2012, 17:18
Contact:

Re: Creating a Storyboard using C++

03 Jul 2015, 13:25

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:
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());
 
ZanAlex
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: Creating a Storyboard using C++

07 Dec 2015, 14:26

Hi,

I'm trying to do roughly the same as the initial poster.

Here is my code, written in a Control deriving from Grid:
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();
The application crashes at Begin, the error is: "Target cannot be found". What am I doing wrong?
 
User avatar
sfernandez
Site Admin
Posts: 1920
Joined: 22 Dec 2011, 19:20

Re: Creating a Storyboard using C++

10 Dec 2015, 10:27

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):
Core::Ptr<Gui::PropertyPath> bgProperty = *new Gui::PropertyPath("Background.Color"); 
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:
storyboard->Begin(this); 
 
ZanAlex
Posts: 66
Joined: 16 Jan 2015, 17:46

Re: Creating a Storyboard using C++

11 Dec 2015, 14:01

That fixed the problem, thank you very much!

Who is online

Users browsing this forum: jsantos and 0 guests