当前位置: 首页>>代码示例>>C++>>正文


C++ CComPtr::AddTransition方法代码示例

本文整理汇总了C++中CComPtr::AddTransition方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AddTransition方法的具体用法?C++ CComPtr::AddTransition怎么用?C++ CComPtr::AddTransition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CComPtr的用法示例。


在下文中一共展示了CComPtr::AddTransition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Reset

void Timer::Reset(double seconds)
{
	m_duration = seconds;
	DOUBLE currentVal;
	m_pVariable->GetValue(&currentVal);

	if(currentVal == seconds)
		return;

	// Instant transition to 'seconds'
	CComPtr<IUIAnimationTransition> instant;
	CORt(g_manager->get_IUIAnimationTransitionLibrary()->CreateInstantaneousTransition(seconds, &instant));

	// Linear transition to zero
	CComPtr<IUIAnimationTransition> linear;
	if(seconds != 0.0)
	{
		CORt(g_manager->get_IUIAnimationTransitionLibrary()->CreateLinearTransition(seconds, 0.0, &linear));
	}

	// Build up storyboard
	CComPtr<IUIAnimationStoryboard> sb;
	CORt(g_manager->get_IUIAnimationManager()->CreateStoryboard(&sb));

	sb->AddTransition(m_pVariable, instant);
	if(linear)
		sb->AddTransition(m_pVariable, linear);

	UI_ANIMATION_SECONDS secondsNow;
	CORt(g_manager->get_IUIAnimationTimer()->GetTime(&secondsNow));
	CORt(sb->Schedule(secondsNow));

	g_manager->Update();
}
开发者ID:terrymah,项目名称:AnimatedVar,代码行数:34,代码来源:AnimatedVar.cpp

示例2: AnimateSweepTo

void CAnimatedAlphaWindow::AnimateSweepTo( double newSweep_I )
{
	// Create a storyboard
	CComPtr<IUIAnimationStoryboard> storyboard;
	ASSERT_SUCCEEDED(mAnimMgr->CreateStoryboard(&storyboard));

	// Create transitions
	CComPtr<IUIAnimationTransition> stopTransition;
	ASSERT_SUCCEEDED(mTransLib->CreateSmoothStopTransition(0.25,
		newSweep_I, &stopTransition));

	// Add the stopTransition
	ASSERT_SUCCEEDED(storyboard->AddTransition(mSweepVar, stopTransition));

	// Schedule the storyboard to animate now
	UI_ANIMATION_SECONDS timeNow;
	ASSERT_SUCCEEDED(mAnimTimer->GetTime(&timeNow));
	ASSERT_SUCCEEDED(storyboard->Schedule(timeNow));
}
开发者ID:ben,项目名称:WTLAlphaTest,代码行数:19,代码来源:AnimatedAlphaWindow.cpp

示例3: OnLButtonUp

void CAnimatedAlphaWindow::OnLButtonUp( UINT nFlags, CPoint point )
{
	// Create a storyboard
	CComPtr<IUIAnimationStoryboard> storyboard;
	ASSERT_SUCCEEDED(mAnimMgr->CreateStoryboard(&storyboard));

	// Create transitions
	CComPtr<IUIAnimationTransition> stopTransition;
	//ATLTRACE("Animating to %.0f\n", mNextAlphaValue);
	ASSERT_SUCCEEDED(mTransLib->CreateSmoothStopTransition(0.5,
		mNextAlphaValue, &stopTransition));
	mNextAlphaValue = (mNextAlphaValue == LARGE ? SMALL : LARGE);

	// Add the stopTransition
	ASSERT_SUCCEEDED(storyboard->AddTransition(mAlphaVar, stopTransition));

	// Schedule the storyboard to animate now
	UI_ANIMATION_SECONDS timeNow;
	ASSERT_SUCCEEDED(mAnimTimer->GetTime(&timeNow));
	ASSERT_SUCCEEDED(storyboard->Schedule(timeNow));
}
开发者ID:ben,项目名称:WTLAlphaTest,代码行数:21,代码来源:AnimatedAlphaWindow.cpp

示例4: CreateSlideAnimation

//-------------------------------------------------------------------------------
// Use WAM to generate and propagate the appropriate animation curves to DirectComposition when 
// keypress is detected
//-------------------------------------------------------------------------------
HRESULT CApplication::CreateSlideAnimation(DIRECTION dir, IDCompositionAnimation **slideAnimation)
{    
    HRESULT hr = (slideAnimation == nullptr) ? E_POINTER : S_OK;

    float rightMargin = 27 * TILE_SPACING * -1;  //where the tiles end. Note forward direction is represented by a negative value.
    float leftMargin = 0; // where the tiles begin

    if (SUCCEEDED(hr))
    {
        *slideAnimation = nullptr;
        hr = ((_device == nullptr) || (_animationVariable == nullptr)) ? E_UNEXPECTED : S_OK;
    }

    //WAM propagates curves to DirectComposition using the IDCompositionAnimation object
    CComPtr<IDCompositionAnimation> animation;

    if (SUCCEEDED(hr))
    {
        hr = _device->CreateAnimation(&animation);
    }

    //Create a storyboard for the slide animation
    CComPtr<IUIAnimationStoryboard2> storyboard;

    if (SUCCEEDED(hr))
    {
        hr = _manager->CreateStoryboard(&storyboard);
    }

    // Synchronizing WAM and DirectComposition time such that when WAM Update is called, 
    // the value reflects the DirectComposition value at the given time.
    DCOMPOSITION_FRAME_STATISTICS frameStatistics = { 0 };

    if (SUCCEEDED(hr))
    {
        hr = _device->GetFrameStatistics(&frameStatistics);
    }

    UI_ANIMATION_SECONDS nextEstimatedFrameTime = 0.0;

    if (SUCCEEDED(hr))
    {
        nextEstimatedFrameTime = static_cast<double>(frameStatistics.nextEstimatedFrameTime.QuadPart) / static_cast<double>(frameStatistics.timeFrequency.QuadPart);
    }

    //Upating the WAM time 
    if (SUCCEEDED(hr))
    {
        hr = _manager->Update(nextEstimatedFrameTime);
    }

    CComPtr<IUIAnimationTransition2> transition;
    double curValue = 0;    //current value of the animation variable
    int velocity = 500;     //arbitrary fix velocity for the slide animation
    
    if (SUCCEEDED(hr))
    {
        hr = _animationVariable->GetValue(&curValue);

        switch (dir)
        {
            case stopForward:
            case stopBackward:
                // Stopping the animation smoothly when key is let go
                if (curValue != leftMargin && curValue != rightMargin)
                    hr = _transitionLibrary->CreateSmoothStopTransition(0.5, curValue + dir * 50, &transition);
                break;
            case forward:
                // slide the tiles forward using a linear curve upon left button press
                hr = _transitionLibrary->CreateLinearTransition(-1 * (rightMargin - curValue)/velocity, rightMargin, &transition);
                break;
            case backward:
                // slide the tiles backward using a linear cruve upon right button press
                hr = _transitionLibrary->CreateLinearTransition(-1 * curValue/velocity, leftMargin, &transition);
                break;
         }
    }

    //Add above transition to storyboard
    if (SUCCEEDED(hr))
    {
        hr = storyboard->AddTransition(_animationVariable, transition);
    }

    //schedule the storyboard for play at the next estimate vblank
    if (SUCCEEDED(hr))
    {
        hr = storyboard->Schedule(nextEstimatedFrameTime);
    }

    //Giving WAM varialbe the IDCompositionAnimation object to recieve the animation curves
    if (SUCCEEDED(hr))
    {
        hr = _animationVariable->GetCurve(animation);
    }

//.........这里部分代码省略.........
开发者ID:9578577,项目名称:Windows-classic-samples,代码行数:101,代码来源:DirectComposition_WAM.cpp


注:本文中的CComPtr::AddTransition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。