1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sdext.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "PresenterPaneAnimator.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "PresenterAnimation.hxx" 34*cdf0e10cSrcweir #include "PresenterAnimator.hxx" 35*cdf0e10cSrcweir #include "PresenterCanvasHelper.hxx" 36*cdf0e10cSrcweir #include "PresenterController.hxx" 37*cdf0e10cSrcweir #include "PresenterGeometryHelper.hxx" 38*cdf0e10cSrcweir #include "PresenterPaintManager.hxx" 39*cdf0e10cSrcweir #include "PresenterPaneContainer.hxx" 40*cdf0e10cSrcweir #include "PresenterPaneFactory.hxx" 41*cdf0e10cSrcweir #include "PresenterSprite.hxx" 42*cdf0e10cSrcweir #include "PresenterSpritePane.hxx" 43*cdf0e10cSrcweir #include "PresenterWindowManager.hxx" 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp> 48*cdf0e10cSrcweir #include <boost/bind.hpp> 49*cdf0e10cSrcweir #include <boost/bind/protect.hpp> 50*cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::com::sun::star; 53*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 54*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework; 55*cdf0e10cSrcweir using ::rtl::OUString; 56*cdf0e10cSrcweir using ::std::vector; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir namespace sdext { namespace presenter { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir namespace { 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir class PaneGroup; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir class PresenterPaneAnimatorBase 65*cdf0e10cSrcweir : public ::boost::enable_shared_from_this<PresenterPaneAnimatorBase>, 66*cdf0e10cSrcweir public PresenterPaneAnimator 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir public: 69*cdf0e10cSrcweir PresenterPaneAnimatorBase ( 70*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 71*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 72*cdf0e10cSrcweir const bool bAnimate, 73*cdf0e10cSrcweir const EndActions& rShowEndActions, 74*cdf0e10cSrcweir const EndActions& rEndEndActions); 75*cdf0e10cSrcweir virtual ~PresenterPaneAnimatorBase (void); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir typedef ::std::vector< ::boost::function<void()> > EndOperators; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir void ActivatePanes (void); 80*cdf0e10cSrcweir void ActivatePane ( 81*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId); 82*cdf0e10cSrcweir void RestoreFrozenWindows (void); 83*cdf0e10cSrcweir void FreezePanes (const Reference<rendering::XSpriteCanvas>& rxCanvas); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir protected: 86*cdf0e10cSrcweir ::rtl::Reference<PresenterController> mpPresenterController; 87*cdf0e10cSrcweir ::rtl::Reference<PresenterPaneContainer> mpPaneContainer; 88*cdf0e10cSrcweir ::rtl::Reference<PresenterWindowManager> mpWindowManager; 89*cdf0e10cSrcweir ::std::vector< ::boost::shared_ptr<PaneGroup> > maPaneGroups; 90*cdf0e10cSrcweir css::uno::Reference<css::drawing::framework::XResourceId> mxCenterPaneId; 91*cdf0e10cSrcweir bool mbDoAnimation; 92*cdf0e10cSrcweir EndActions maShowEndActions; 93*cdf0e10cSrcweir EndActions maHideEndActions; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void DeactivatePanes (void); 96*cdf0e10cSrcweir void ResizePane ( 97*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 98*cdf0e10cSrcweir const geometry::RealRectangle2D& rBox); 99*cdf0e10cSrcweir void DeactivatePane ( 100*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId); 101*cdf0e10cSrcweir }; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir class UnfoldInCenterAnimator : public PresenterPaneAnimatorBase 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir public: 107*cdf0e10cSrcweir UnfoldInCenterAnimator ( 108*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 109*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 110*cdf0e10cSrcweir const bool bAnimate, 111*cdf0e10cSrcweir const EndActions& rShowEndActions, 112*cdf0e10cSrcweir const EndActions& rEndEndActions); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir virtual ~UnfoldInCenterAnimator (void); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir virtual void ShowPane (void); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual void HidePane (void); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir geometry::RealRectangle2D maCenterPaneBox; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void SetupPaneGroups (void); 124*cdf0e10cSrcweir geometry::RealRectangle2D MovePanesAway ( 125*cdf0e10cSrcweir const css::geometry::RealRectangle2D& rFreeCenterArea); 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir class MoveInFromBottomAnimator : public PresenterPaneAnimatorBase 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir public: 132*cdf0e10cSrcweir MoveInFromBottomAnimator( 133*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 134*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 135*cdf0e10cSrcweir const bool bAnimate, 136*cdf0e10cSrcweir const EndActions& rShowEndActions, 137*cdf0e10cSrcweir const EndActions& rEndEndActions); 138*cdf0e10cSrcweir virtual ~MoveInFromBottomAnimator (void); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir virtual void ShowPane (void); 141*cdf0e10cSrcweir virtual void HidePane (void); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir private: 144*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> maNewPaneSprite; 145*cdf0e10cSrcweir geometry::RealRectangle2D maCenterPaneBox; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void CreateShowAnimation ( 148*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 149*cdf0e10cSrcweir const EndOperators& rpEndOperators, 150*cdf0e10cSrcweir const css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteCanvas, 151*cdf0e10cSrcweir const bool bAnimate, 152*cdf0e10cSrcweir const css::geometry::RealPoint2D& rStartLocation, 153*cdf0e10cSrcweir const css::geometry::RealPoint2D& rEndLocation); 154*cdf0e10cSrcweir }; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir class TransparentOverlayAnimator : public PresenterPaneAnimatorBase 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir public: 160*cdf0e10cSrcweir TransparentOverlayAnimator( 161*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 162*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 163*cdf0e10cSrcweir const bool bAnimate, 164*cdf0e10cSrcweir const EndActions& rShowEndActions, 165*cdf0e10cSrcweir const EndActions& rEndEndActions); 166*cdf0e10cSrcweir virtual ~TransparentOverlayAnimator (void); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir virtual void ShowPane (void); 169*cdf0e10cSrcweir virtual void HidePane (void); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir private: 172*cdf0e10cSrcweir PresenterSprite maBackgroundSprite; 173*cdf0e10cSrcweir void CreateBackgroundSprite (void); 174*cdf0e10cSrcweir }; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir class PaneDescriptor 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir public: 180*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor mpPaneDescriptor; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir PaneDescriptor (const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor); 183*cdf0e10cSrcweir void Restore (void) const; 184*cdf0e10cSrcweir private: 185*cdf0e10cSrcweir double mnLeft; 186*cdf0e10cSrcweir double mnTop; 187*cdf0e10cSrcweir double mnRight; 188*cdf0e10cSrcweir double mnBottom; 189*cdf0e10cSrcweir }; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir class MultiAnimation : public PresenterAnimation 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir public: 194*cdf0e10cSrcweir typedef ::boost::function<void(double)> Animation; 195*cdf0e10cSrcweir MultiAnimation (const sal_uInt32 nDuration); 196*cdf0e10cSrcweir void AddAnimation (const Animation& rAnimation); 197*cdf0e10cSrcweir virtual void Run (const double nProgress, const sal_uInt64 nCurrentTime); 198*cdf0e10cSrcweir private: 199*cdf0e10cSrcweir vector<Animation> maAnimations; 200*cdf0e10cSrcweir }; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir class PaneGroup 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir public: 206*cdf0e10cSrcweir PaneGroup (void); 207*cdf0e10cSrcweir ~PaneGroup (void); 208*cdf0e10cSrcweir void AddPane (const PresenterPaneContainer::SharedPaneDescriptor& rpPane); 209*cdf0e10cSrcweir void CreateSubstitution (const Reference<rendering::XSpriteCanvas>& rxCanvas); 210*cdf0e10cSrcweir void ThawPanes (void); 211*cdf0e10cSrcweir void Restore (void); 212*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> GetSubstitution (void); 213*cdf0e10cSrcweir css::geometry::RealRectangle2D GetOriginalBoundingBox (void) const; 214*cdf0e10cSrcweir css::geometry::RealRectangle2D GetCurrentBoundingBox (void) const; 215*cdf0e10cSrcweir void MovePanes ( 216*cdf0e10cSrcweir const double nXOffset, 217*cdf0e10cSrcweir const double nYOffset, 218*cdf0e10cSrcweir const ::rtl::Reference<PresenterWindowManager>& rpWindowManager); 219*cdf0e10cSrcweir void ActivatePanes (void); 220*cdf0e10cSrcweir void DeactivatePanes (void); 221*cdf0e10cSrcweir void HidePanes (void); 222*cdf0e10cSrcweir void ShowPanes (void); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir private: 225*cdf0e10cSrcweir vector<PaneDescriptor> maPanes; 226*cdf0e10cSrcweir awt::Rectangle maOriginalBoundingBox; 227*cdf0e10cSrcweir css::geometry::RealRectangle2D maCurrentBoundingBox; 228*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> mpSubstitution; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir }; 231*cdf0e10cSrcweir typedef ::boost::shared_ptr<PaneGroup> SharedPaneGroup; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir void InterpolatePosition ( 234*cdf0e10cSrcweir const ::boost::function<void(geometry::RealPoint2D)>& rSetter, 235*cdf0e10cSrcweir double nP, 236*cdf0e10cSrcweir const geometry::RealPoint2D rInitialBox, 237*cdf0e10cSrcweir const geometry::RealPoint2D rFinalBox); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir template<typename T> 240*cdf0e10cSrcweir void InterpolateValue ( 241*cdf0e10cSrcweir const ::boost::function<void(T)>& rSetter, 242*cdf0e10cSrcweir double nP, 243*cdf0e10cSrcweir const T aInitialValue, 244*cdf0e10cSrcweir const T aFinalValue); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void SpriteTransform( 247*cdf0e10cSrcweir const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 248*cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId, 249*cdf0e10cSrcweir const Reference<awt::XWindow>& rxSpriteOwnerWindow, 250*cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager, 251*cdf0e10cSrcweir const bool bAppear, 252*cdf0e10cSrcweir const double nX, 253*cdf0e10cSrcweir const double nInitialTop, 254*cdf0e10cSrcweir const double nFinalTop, 255*cdf0e10cSrcweir const double nP); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir void SpritePaneMove ( 258*cdf0e10cSrcweir const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 259*cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId, 260*cdf0e10cSrcweir const geometry::RealPoint2D& rLocation); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir geometry::RealPoint2D GetLocation (const geometry::RealRectangle2D& rBox); 263*cdf0e10cSrcweir geometry::RealSize2D GetSize (const geometry::RealRectangle2D& rBox); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir } // end of anonymous namespace 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir //============================================================================= 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir ::boost::shared_ptr<PresenterPaneAnimator> CreateUnfoldInCenterAnimator ( 275*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 276*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 277*cdf0e10cSrcweir const bool bAnimate, 278*cdf0e10cSrcweir const EndActions& rShowEndActions, 279*cdf0e10cSrcweir const EndActions& rEndEndActions) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir return ::boost::shared_ptr<PresenterPaneAnimator>( 282*cdf0e10cSrcweir new UnfoldInCenterAnimator(rxPaneId, rpPresenterController, bAnimate, 283*cdf0e10cSrcweir rShowEndActions, rEndEndActions)); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir ::boost::shared_ptr<PresenterPaneAnimator> CreateMoveInFromBottomAnimator ( 290*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 291*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 292*cdf0e10cSrcweir const bool bAnimate, 293*cdf0e10cSrcweir const EndActions& rShowEndActions, 294*cdf0e10cSrcweir const EndActions& rEndEndActions) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir return ::boost::shared_ptr<PresenterPaneAnimator>( 297*cdf0e10cSrcweir new MoveInFromBottomAnimator(rxPaneId, rpPresenterController, bAnimate, 298*cdf0e10cSrcweir rShowEndActions, rEndEndActions)); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir ::boost::shared_ptr<PresenterPaneAnimator> CreateTransparentOverlay ( 305*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 306*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 307*cdf0e10cSrcweir const bool bAnimate, 308*cdf0e10cSrcweir const EndActions& rShowEndActions, 309*cdf0e10cSrcweir const EndActions& rEndEndActions) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir return ::boost::shared_ptr<PresenterPaneAnimator>( 312*cdf0e10cSrcweir new TransparentOverlayAnimator(rxPaneId, rpPresenterController, bAnimate, 313*cdf0e10cSrcweir rShowEndActions, rEndEndActions)); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir //===== PresenterPaneAnimator ================================================= 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir namespace { 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir PresenterPaneAnimatorBase::PresenterPaneAnimatorBase ( 324*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 325*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 326*cdf0e10cSrcweir const bool bAnimate, 327*cdf0e10cSrcweir const EndActions& rShowEndActions, 328*cdf0e10cSrcweir const EndActions& rHideEndActions) 329*cdf0e10cSrcweir : mpPresenterController(rpPresenterController), 330*cdf0e10cSrcweir mpPaneContainer(rpPresenterController->GetPaneContainer()), 331*cdf0e10cSrcweir mpWindowManager(rpPresenterController->GetWindowManager()), 332*cdf0e10cSrcweir maPaneGroups(), 333*cdf0e10cSrcweir mxCenterPaneId(rxPaneId), 334*cdf0e10cSrcweir mbDoAnimation(bAnimate), 335*cdf0e10cSrcweir maShowEndActions(rShowEndActions), 336*cdf0e10cSrcweir maHideEndActions(rHideEndActions) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir PresenterPaneAnimatorBase::~PresenterPaneAnimatorBase (void) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir void PresenterPaneAnimatorBase::FreezePanes (const Reference<rendering::XSpriteCanvas>& rxCanvas) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir ::std::vector<SharedPaneGroup>::const_iterator iGroup; 353*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir (*iGroup)->CreateSubstitution(rxCanvas); 356*cdf0e10cSrcweir (*iGroup)->GetSubstitution()->MoveTo(GetLocation((*iGroup)->GetOriginalBoundingBox())); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void PresenterPaneAnimatorBase::ActivatePanes (void) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ActivatePane(mxCenterPaneId); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir ::std::vector<SharedPaneGroup>::const_iterator iGroup; 368*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir (*iGroup)->ShowPanes(); 371*cdf0e10cSrcweir (*iGroup)->ActivatePanes(); 372*cdf0e10cSrcweir (*iGroup)->GetSubstitution()->Hide(); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir mpWindowManager->Update(); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void PresenterPaneAnimatorBase::DeactivatePanes (void) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir ::std::vector<SharedPaneGroup>::const_iterator iGroup; 384*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir (*iGroup)->GetSubstitution()->Show(); 387*cdf0e10cSrcweir (*iGroup)->DeactivatePanes(); 388*cdf0e10cSrcweir (*iGroup)->HidePanes(); 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir mpWindowManager->Update(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir void PresenterPaneAnimatorBase::ResizePane ( 398*cdf0e10cSrcweir const Reference<drawing::framework::XResourceId>& rxPaneId, 399*cdf0e10cSrcweir const geometry::RealRectangle2D& rBox) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 402*cdf0e10cSrcweir mpPaneContainer->FindPaneId(rxPaneId)); 403*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir mpWindowManager->SetPanePosSizeAbsolute ( 406*cdf0e10cSrcweir rxPaneId->getResourceURL(), 407*cdf0e10cSrcweir rBox.X1, 408*cdf0e10cSrcweir rBox.Y1, 409*cdf0e10cSrcweir rBox.X2-rBox.X1, 410*cdf0e10cSrcweir rBox.Y2-rBox.Y1); 411*cdf0e10cSrcweir mpWindowManager->Layout(); 412*cdf0e10cSrcweir if ( ! pDescriptor->maSpriteProvider.empty()) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir pDescriptor->maSpriteProvider()->Resize(GetSize(rBox)); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void PresenterPaneAnimatorBase::RestoreFrozenWindows (void) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir ::std::vector<SharedPaneGroup>::const_iterator iGroup; 425*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir (*iGroup)->Restore(); 428*cdf0e10cSrcweir (*iGroup)->ShowPanes(); 429*cdf0e10cSrcweir (*iGroup)->ActivatePanes(); 430*cdf0e10cSrcweir (*iGroup)->GetSubstitution()->Hide(); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir maPaneGroups.clear(); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir ActivatePane(mxCenterPaneId); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir mpWindowManager->Update(); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir void PresenterPaneAnimatorBase::ActivatePane ( 443*cdf0e10cSrcweir const Reference<drawing::framework::XResourceId>& rxPaneId) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 446*cdf0e10cSrcweir mpPaneContainer->FindPaneId(rxPaneId)); 447*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 448*cdf0e10cSrcweir pDescriptor->SetActivationState(true); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir void PresenterPaneAnimatorBase::DeactivatePane ( 455*cdf0e10cSrcweir const Reference<drawing::framework::XResourceId>& rxPaneId) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 458*cdf0e10cSrcweir mpPaneContainer->FindPaneId(rxPaneId)); 459*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 460*cdf0e10cSrcweir pDescriptor->SetActivationState(false); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir //===== UnfoldInCenterAnimator ================================================ 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir UnfoldInCenterAnimator::UnfoldInCenterAnimator ( 469*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 470*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 471*cdf0e10cSrcweir const bool bAnimate, 472*cdf0e10cSrcweir const EndActions& rShowEndActions, 473*cdf0e10cSrcweir const EndActions& rEndEndActions) 474*cdf0e10cSrcweir : PresenterPaneAnimatorBase(rxPaneId, rpPresenterController, bAnimate, 475*cdf0e10cSrcweir rShowEndActions, rEndEndActions) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir UnfoldInCenterAnimator::~UnfoldInCenterAnimator (void) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir void UnfoldInCenterAnimator::ShowPane (void) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir OSL_ASSERT(mpWindowManager.get()!=NULL); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 494*cdf0e10cSrcweir if ( ! xParentWindow.is()) 495*cdf0e10cSrcweir return; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xCanvas (mpWindowManager->GetParentCanvas(), UNO_QUERY); 498*cdf0e10cSrcweir if ( ! xCanvas.is()) 499*cdf0e10cSrcweir return; 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir Reference<rendering::XBitmap> xParentBitmap (xCanvas, UNO_QUERY); 502*cdf0e10cSrcweir if ( ! xParentBitmap.is()) 503*cdf0e10cSrcweir return; 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir Reference<rendering::XGraphicDevice> xDevice(xCanvas->getDevice()); 506*cdf0e10cSrcweir if ( ! xDevice.is()) 507*cdf0e10cSrcweir return; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir // Create two pane groups that will be moved together. One contains the 512*cdf0e10cSrcweir // notes view, the other group contains all other panes. 513*cdf0e10cSrcweir SetupPaneGroups(); 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir // Setup the places where the two pane groups are moved to. 516*cdf0e10cSrcweir maCenterPaneBox 517*cdf0e10cSrcweir = MovePanesAway(geometry::RealRectangle2D(0,200,aWindowBox.Width, aWindowBox.Height-200)); 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir // Setup the final size of the new pane so that it fits into the space 520*cdf0e10cSrcweir // between the two pane groups. 521*cdf0e10cSrcweir ResizePane(mxCenterPaneId, maCenterPaneBox); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // Avoid that the center pane updates its previews while being animated. 524*cdf0e10cSrcweir DeactivatePane(mxCenterPaneId); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir // Replace the pane groups with sprites that look like the panes but can 527*cdf0e10cSrcweir // be moved around much faster. 528*cdf0e10cSrcweir FreezePanes(xCanvas); 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir // The vertical center of the new pane. 531*cdf0e10cSrcweir const double nY0 ((maPaneGroups[0]->GetOriginalBoundingBox().Y2 532*cdf0e10cSrcweir + maPaneGroups[1]->GetOriginalBoundingBox().Y1) / 2); 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // Make sure that the new pane is painted once before the animation starts. 535*cdf0e10cSrcweir SpriteTransform( 536*cdf0e10cSrcweir mpPaneContainer, 537*cdf0e10cSrcweir mxCenterPaneId, 538*cdf0e10cSrcweir xParentWindow, 539*cdf0e10cSrcweir mpPresenterController->GetPaintManager(), 540*cdf0e10cSrcweir true, 541*cdf0e10cSrcweir maCenterPaneBox.X1, 542*cdf0e10cSrcweir nY0, 543*cdf0e10cSrcweir maCenterPaneBox.Y1, 544*cdf0e10cSrcweir 0); 545*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 546*cdf0e10cSrcweir mpPaneContainer->FindPaneId(mxCenterPaneId)); 547*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir mpPresenterController->GetPaintManager()->Invalidate( 550*cdf0e10cSrcweir pDescriptor->mxBorderWindow, 551*cdf0e10cSrcweir true); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir // Animate the upper and lower window bitmaps. 555*cdf0e10cSrcweir ::boost::shared_ptr<MultiAnimation> pMultiAnimation ( 556*cdf0e10cSrcweir new MultiAnimation(mbDoAnimation ? 500 : 0)); 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir // Animate the pane group sprites to be moved up or down. 559*cdf0e10cSrcweir vector<SharedPaneGroup>::const_iterator iGroup; 560*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 563*cdf0e10cSrcweir ::boost::bind( 564*cdf0e10cSrcweir InterpolatePosition, 565*cdf0e10cSrcweir ::boost::protect(::boost::bind( 566*cdf0e10cSrcweir &PresenterSprite::MoveTo, (*iGroup)->GetSubstitution(), _1)), 567*cdf0e10cSrcweir _1, 568*cdf0e10cSrcweir GetLocation((*iGroup)->GetOriginalBoundingBox()), 569*cdf0e10cSrcweir GetLocation((*iGroup)->GetCurrentBoundingBox()))); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // Animate the new center pane to expand. 573*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 574*cdf0e10cSrcweir ::boost::bind( 575*cdf0e10cSrcweir SpriteTransform, 576*cdf0e10cSrcweir mpPaneContainer, 577*cdf0e10cSrcweir mxCenterPaneId, 578*cdf0e10cSrcweir xParentWindow, 579*cdf0e10cSrcweir mpPresenterController->GetPaintManager(), 580*cdf0e10cSrcweir true, 581*cdf0e10cSrcweir maCenterPaneBox.X1, 582*cdf0e10cSrcweir nY0, 583*cdf0e10cSrcweir maCenterPaneBox.Y1, 584*cdf0e10cSrcweir _1)); 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir // Call updateScreen after each animation step. 587*cdf0e10cSrcweir if (xCanvas.is()) 588*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 589*cdf0e10cSrcweir ::boost::bind(&rendering::XSpriteCanvas::updateScreen, xCanvas, sal_False)); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir // Activate the panes when the animation is over. 592*cdf0e10cSrcweir pMultiAnimation->AddEndCallback( 593*cdf0e10cSrcweir ::boost::bind(&PresenterPaneAnimatorBase::ActivatePanes, shared_from_this())); 594*cdf0e10cSrcweir EndActions::const_iterator iAction; 595*cdf0e10cSrcweir for (iAction=maShowEndActions.begin(); iAction!=maShowEndActions.end(); ++iAction) 596*cdf0e10cSrcweir pMultiAnimation->AddEndCallback(*iAction); 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir // Start the animation. 599*cdf0e10cSrcweir ::boost::shared_ptr<PresenterAnimator> pAnimator (mpPresenterController->GetAnimator()); 600*cdf0e10cSrcweir OSL_ASSERT(pAnimator.get()!=NULL); 601*cdf0e10cSrcweir pAnimator->AddAnimation(SharedPresenterAnimation(pMultiAnimation)); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir mpWindowManager->Update(); 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir void UnfoldInCenterAnimator::HidePane (void) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir OSL_ASSERT(mpWindowManager.get()!=NULL); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 614*cdf0e10cSrcweir if ( ! xParentWindow.is()) 615*cdf0e10cSrcweir return; 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir DeactivatePanes(); 618*cdf0e10cSrcweir DeactivatePane(mxCenterPaneId); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir ::boost::shared_ptr<PresenterAnimator> pAnimator (mpPresenterController->GetAnimator()); 621*cdf0e10cSrcweir const awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 622*cdf0e10cSrcweir const rendering::ViewState aViewState ( 623*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0), 624*cdf0e10cSrcweir NULL); 625*cdf0e10cSrcweir const rendering::RenderState aRenderState ( 626*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0), 627*cdf0e10cSrcweir NULL, 628*cdf0e10cSrcweir Sequence<double>(4), 629*cdf0e10cSrcweir rendering::CompositeOperation::SOURCE); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // Animate the uppder and lower window bitmaps. 632*cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xSpriteCanvas (mpWindowManager->GetParentCanvas(), UNO_QUERY); 633*cdf0e10cSrcweir ::boost::shared_ptr<MultiAnimation> pMultiAnimation (new MultiAnimation(mbDoAnimation ? 500 : 1)); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir vector<SharedPaneGroup>::const_iterator iGroup; 636*cdf0e10cSrcweir for (iGroup=maPaneGroups.begin(); iGroup!=maPaneGroups.end(); ++iGroup) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 639*cdf0e10cSrcweir ::boost::bind( 640*cdf0e10cSrcweir InterpolatePosition, 641*cdf0e10cSrcweir ::boost::protect(::boost::bind( 642*cdf0e10cSrcweir &PresenterSprite::MoveTo, (*iGroup)->GetSubstitution(), _1)), 643*cdf0e10cSrcweir _1, 644*cdf0e10cSrcweir GetLocation((*iGroup)->GetCurrentBoundingBox()), 645*cdf0e10cSrcweir GetLocation((*iGroup)->GetOriginalBoundingBox()))); 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir // Animate the new center pane to collapse. 649*cdf0e10cSrcweir const double nY0 ((maPaneGroups[0]->GetOriginalBoundingBox().Y2 650*cdf0e10cSrcweir + maPaneGroups[1]->GetOriginalBoundingBox().Y1) / 2); 651*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 652*cdf0e10cSrcweir ::boost::bind( 653*cdf0e10cSrcweir SpriteTransform, 654*cdf0e10cSrcweir mpPaneContainer, 655*cdf0e10cSrcweir mxCenterPaneId, 656*cdf0e10cSrcweir xParentWindow, 657*cdf0e10cSrcweir mpPresenterController->GetPaintManager(), 658*cdf0e10cSrcweir false, 659*cdf0e10cSrcweir maCenterPaneBox.X1, 660*cdf0e10cSrcweir nY0, 661*cdf0e10cSrcweir maCenterPaneBox.Y1, 662*cdf0e10cSrcweir _1)); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir if (mbDoAnimation) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 667*cdf0e10cSrcweir ::boost::bind(&rendering::XSpriteCanvas::updateScreen, xSpriteCanvas, sal_False)); 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir pMultiAnimation->AddEndCallback( 670*cdf0e10cSrcweir ::boost::bind(&PresenterPaneAnimatorBase::RestoreFrozenWindows, shared_from_this())); 671*cdf0e10cSrcweir EndActions::const_iterator iAction; 672*cdf0e10cSrcweir for (iAction=maHideEndActions.begin(); iAction!=maHideEndActions.end(); ++iAction) 673*cdf0e10cSrcweir pMultiAnimation->AddEndCallback(*iAction); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir pAnimator->AddAnimation(SharedPresenterAnimation(pMultiAnimation)); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir void UnfoldInCenterAnimator::SetupPaneGroups (void) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir maPaneGroups.clear(); 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir // Setup the upper pane group. 686*cdf0e10cSrcweir SharedPaneGroup pUpperPanes (new PaneGroup()); 687*cdf0e10cSrcweir pUpperPanes->AddPane(mpPaneContainer->FindPaneURL( 688*cdf0e10cSrcweir PresenterPaneFactory::msCurrentSlidePreviewPaneURL)); 689*cdf0e10cSrcweir pUpperPanes->AddPane(mpPaneContainer->FindPaneURL( 690*cdf0e10cSrcweir PresenterPaneFactory::msNextSlidePreviewPaneURL)); 691*cdf0e10cSrcweir pUpperPanes->AddPane(mpPaneContainer->FindPaneURL( 692*cdf0e10cSrcweir PresenterPaneFactory::msToolBarPaneURL)); 693*cdf0e10cSrcweir pUpperPanes->AddPane(mpPaneContainer->FindPaneURL( 694*cdf0e10cSrcweir PresenterPaneFactory::msHelpPaneURL)); 695*cdf0e10cSrcweir maPaneGroups.push_back(pUpperPanes); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir // Setup the lower pane group. 698*cdf0e10cSrcweir SharedPaneGroup pLowerPanes (new PaneGroup()); 699*cdf0e10cSrcweir pLowerPanes->AddPane(mpPaneContainer->FindPaneURL( 700*cdf0e10cSrcweir PresenterPaneFactory::msNotesPaneURL)); 701*cdf0e10cSrcweir maPaneGroups.push_back(pLowerPanes); 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir geometry::RealRectangle2D UnfoldInCenterAnimator::MovePanesAway ( 708*cdf0e10cSrcweir const geometry::RealRectangle2D& rFreeCenterArea) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir SharedPaneGroup aUpperPanes = maPaneGroups[0]; 711*cdf0e10cSrcweir SharedPaneGroup aLowerPanes = maPaneGroups[1]; 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir // Move upper pane group out of the way. 714*cdf0e10cSrcweir const double nTop (rFreeCenterArea.Y1); 715*cdf0e10cSrcweir const double nUpperVerticalOffset (nTop - aUpperPanes->GetOriginalBoundingBox().Y2); 716*cdf0e10cSrcweir aUpperPanes->MovePanes(0, nUpperVerticalOffset, mpWindowManager); 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir // Move lower pane group out of the way. 719*cdf0e10cSrcweir const double nBottom (rFreeCenterArea.Y2); 720*cdf0e10cSrcweir const double nLowerVerticalOffset (nBottom - aLowerPanes->GetOriginalBoundingBox().Y1); 721*cdf0e10cSrcweir aLowerPanes->MovePanes(0, nLowerVerticalOffset, mpWindowManager); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir return geometry::RealRectangle2D( 724*cdf0e10cSrcweir ::std::min( 725*cdf0e10cSrcweir aUpperPanes->GetOriginalBoundingBox().X1, 726*cdf0e10cSrcweir aLowerPanes->GetOriginalBoundingBox().X1), 727*cdf0e10cSrcweir nTop+20, 728*cdf0e10cSrcweir ::std::max( 729*cdf0e10cSrcweir aUpperPanes->GetOriginalBoundingBox().X2, 730*cdf0e10cSrcweir aLowerPanes->GetOriginalBoundingBox().X2), 731*cdf0e10cSrcweir nBottom-20); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir //===== MoveInFromBottomAnimator ============================================== 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir MoveInFromBottomAnimator::MoveInFromBottomAnimator ( 740*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 741*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 742*cdf0e10cSrcweir const bool bAnimate, 743*cdf0e10cSrcweir const EndActions& rShowEndActions, 744*cdf0e10cSrcweir const EndActions& rEndEndActions) 745*cdf0e10cSrcweir : PresenterPaneAnimatorBase(rxPaneId, rpPresenterController, bAnimate, 746*cdf0e10cSrcweir rShowEndActions, rEndEndActions), 747*cdf0e10cSrcweir maNewPaneSprite() 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir MoveInFromBottomAnimator::~MoveInFromBottomAnimator (void) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir void MoveInFromBottomAnimator::ShowPane (void) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir OSL_ASSERT(mpWindowManager.get()!=NULL); 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 766*cdf0e10cSrcweir if ( ! xParentWindow.is()) 767*cdf0e10cSrcweir return; 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xCanvas (mpWindowManager->GetParentCanvas(), UNO_QUERY); 770*cdf0e10cSrcweir if ( ! xCanvas.is()) 771*cdf0e10cSrcweir return; 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir Reference<rendering::XBitmap> xParentBitmap (xCanvas, UNO_QUERY); 774*cdf0e10cSrcweir if ( ! xParentBitmap.is()) 775*cdf0e10cSrcweir return; 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir Reference<rendering::XGraphicDevice> xDevice(xCanvas->getDevice()); 778*cdf0e10cSrcweir if ( ! xDevice.is()) 779*cdf0e10cSrcweir return; 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir // Create a pane group that just contains the notes view. 784*cdf0e10cSrcweir SharedPaneGroup pLowerPanes (new PaneGroup()); 785*cdf0e10cSrcweir pLowerPanes->AddPane(mpPaneContainer->FindPaneURL( 786*cdf0e10cSrcweir PresenterPaneFactory::msNotesPaneURL)); 787*cdf0e10cSrcweir maPaneGroups.push_back(pLowerPanes); 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir // Deactivate the panes that will take place in the animation. 790*cdf0e10cSrcweir pLowerPanes->DeactivatePanes(); 791*cdf0e10cSrcweir DeactivatePane(mxCenterPaneId); 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir // Set the size of the new pane. 794*cdf0e10cSrcweir maCenterPaneBox = pLowerPanes->GetOriginalBoundingBox(); 795*cdf0e10cSrcweir ResizePane(mxCenterPaneId, maCenterPaneBox); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir geometry::RealPoint2D aStartLocation (maCenterPaneBox.X1, aWindowBox.Height); 798*cdf0e10cSrcweir geometry::RealPoint2D aEndLocation (maCenterPaneBox.X1, maCenterPaneBox.Y1); 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir // Get the sprite of the new pane, make it visible and move it to the 801*cdf0e10cSrcweir // start location. 802*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 803*cdf0e10cSrcweir mpPaneContainer->FindPaneId(mxCenterPaneId)); 804*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir if (pDescriptor->mxBorderWindow.is()) 807*cdf0e10cSrcweir pDescriptor->mxBorderWindow->setVisible(sal_True); 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir maNewPaneSprite = pDescriptor->maSpriteProvider(); 810*cdf0e10cSrcweir if (maNewPaneSprite.get() != NULL) 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir maNewPaneSprite->MoveTo(aStartLocation); 813*cdf0e10cSrcweir maNewPaneSprite->Show(); 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir xCanvas->updateScreen(sal_False); 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir CreateShowAnimation( 819*cdf0e10cSrcweir mxCenterPaneId, 820*cdf0e10cSrcweir maShowEndActions, 821*cdf0e10cSrcweir xCanvas, 822*cdf0e10cSrcweir mbDoAnimation, 823*cdf0e10cSrcweir aStartLocation, 824*cdf0e10cSrcweir aEndLocation); 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir mpWindowManager->Update(); 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir void MoveInFromBottomAnimator::HidePane (void) 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir OSL_ASSERT(mpWindowManager.get()!=NULL); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 837*cdf0e10cSrcweir if ( ! xParentWindow.is()) 838*cdf0e10cSrcweir return; 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xCanvas (mpWindowManager->GetParentCanvas(), UNO_QUERY); 841*cdf0e10cSrcweir if ( ! xCanvas.is()) 842*cdf0e10cSrcweir return; 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir DeactivatePanes(); 845*cdf0e10cSrcweir DeactivatePane(mxCenterPaneId); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir SharedPaneGroup aPanes (maPaneGroups[0]); 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir aPanes->ShowPanes(); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir ::boost::shared_ptr<MultiAnimation> pMultiAnimation ( 852*cdf0e10cSrcweir new MultiAnimation(mbDoAnimation ? 500 : 0)); 853*cdf0e10cSrcweir awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir // Animate the new center pane to collapse. 856*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 857*cdf0e10cSrcweir ::boost::bind( 858*cdf0e10cSrcweir InterpolatePosition, 859*cdf0e10cSrcweir ::boost::protect(::boost::bind(&SpritePaneMove, mpPaneContainer, mxCenterPaneId, _1)), 860*cdf0e10cSrcweir _1, 861*cdf0e10cSrcweir geometry::RealPoint2D(maCenterPaneBox.X1, maCenterPaneBox.Y1), 862*cdf0e10cSrcweir geometry::RealPoint2D(maCenterPaneBox.X1, aWindowBox.Height))); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir if (mbDoAnimation) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 867*cdf0e10cSrcweir ::boost::bind(&rendering::XSpriteCanvas::updateScreen, xCanvas, sal_False)); 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir pMultiAnimation->AddEndCallback( 870*cdf0e10cSrcweir ::boost::bind(&PresenterPaneAnimatorBase::RestoreFrozenWindows, shared_from_this())); 871*cdf0e10cSrcweir EndActions::const_iterator iAction; 872*cdf0e10cSrcweir for (iAction=maHideEndActions.begin(); iAction!=maHideEndActions.end(); ++iAction) 873*cdf0e10cSrcweir pMultiAnimation->AddEndCallback(*iAction); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir ::boost::shared_ptr<PresenterAnimator> pAnimator (mpPresenterController->GetAnimator()); 876*cdf0e10cSrcweir pAnimator->AddAnimation(SharedPresenterAnimation(pMultiAnimation)); 877*cdf0e10cSrcweir } 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir void MoveInFromBottomAnimator::CreateShowAnimation ( 883*cdf0e10cSrcweir const Reference<drawing::framework::XResourceId>& rxPaneId, 884*cdf0e10cSrcweir const EndOperators& rEndOperators, 885*cdf0e10cSrcweir const Reference<rendering::XSpriteCanvas>& rxSpriteCanvas, 886*cdf0e10cSrcweir const bool bAnimate, 887*cdf0e10cSrcweir const geometry::RealPoint2D& rStartLocation, 888*cdf0e10cSrcweir const geometry::RealPoint2D& rEndLocation) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir // Animate the uppder and lower window bitmaps. 891*cdf0e10cSrcweir ::boost::shared_ptr<MultiAnimation> pMultiAnimation (new MultiAnimation(bAnimate ? 500 : 0)); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir // Animate new pane to move in from the buttom. 894*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 895*cdf0e10cSrcweir ::boost::bind( 896*cdf0e10cSrcweir InterpolatePosition, 897*cdf0e10cSrcweir ::boost::protect(::boost::bind(&SpritePaneMove, mpPaneContainer, rxPaneId, _1)), 898*cdf0e10cSrcweir _1, 899*cdf0e10cSrcweir rStartLocation, 900*cdf0e10cSrcweir rEndLocation)); 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir // Call updateScreen after each animation step. 903*cdf0e10cSrcweir if (rxSpriteCanvas.is()) 904*cdf0e10cSrcweir pMultiAnimation->AddAnimation( 905*cdf0e10cSrcweir ::boost::bind(&rendering::XSpriteCanvas::updateScreen, rxSpriteCanvas, sal_False)); 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir // Activate the panes when the animation is over. 908*cdf0e10cSrcweir pMultiAnimation->AddEndCallback( 909*cdf0e10cSrcweir ::boost::bind(&PaneGroup::HidePanes, maPaneGroups[0])); 910*cdf0e10cSrcweir pMultiAnimation->AddEndCallback( 911*cdf0e10cSrcweir ::boost::bind(&PresenterPaneAnimatorBase::ActivatePane, shared_from_this(), mxCenterPaneId)); 912*cdf0e10cSrcweir EndActions::const_iterator iAction; 913*cdf0e10cSrcweir for (iAction=rEndOperators.begin(); iAction!=rEndOperators.end(); ++iAction) 914*cdf0e10cSrcweir pMultiAnimation->AddEndCallback(*iAction); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir // Start the animation. 917*cdf0e10cSrcweir ::boost::shared_ptr<PresenterAnimator> pAnimator (mpPresenterController->GetAnimator()); 918*cdf0e10cSrcweir OSL_ASSERT(pAnimator.get()!=NULL); 919*cdf0e10cSrcweir pAnimator->AddAnimation(SharedPresenterAnimation(pMultiAnimation)); 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir //===== TransparentOverlayAnimator ============================================ 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir TransparentOverlayAnimator::TransparentOverlayAnimator ( 929*cdf0e10cSrcweir const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId, 930*cdf0e10cSrcweir const ::rtl::Reference<PresenterController>& rpPresenterController, 931*cdf0e10cSrcweir const bool bAnimate, 932*cdf0e10cSrcweir const EndActions& rShowEndActions, 933*cdf0e10cSrcweir const EndActions& rEndEndActions) 934*cdf0e10cSrcweir : PresenterPaneAnimatorBase( 935*cdf0e10cSrcweir rxPaneId, 936*cdf0e10cSrcweir rpPresenterController, 937*cdf0e10cSrcweir bAnimate, 938*cdf0e10cSrcweir rShowEndActions, 939*cdf0e10cSrcweir rEndEndActions), 940*cdf0e10cSrcweir maBackgroundSprite() 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir TransparentOverlayAnimator::~TransparentOverlayAnimator (void) 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir void TransparentOverlayAnimator::ShowPane (void) 955*cdf0e10cSrcweir { 956*cdf0e10cSrcweir EndActions::const_iterator iAction; 957*cdf0e10cSrcweir for (iAction=maShowEndActions.begin(); iAction!=maShowEndActions.end(); ++iAction) 958*cdf0e10cSrcweir (*iAction)(); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir CreateBackgroundSprite(); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 963*cdf0e10cSrcweir if (xParentWindow.is()) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir const awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 966*cdf0e10cSrcweir SharedPaneGroup pAllPanes (new PaneGroup()); 967*cdf0e10cSrcweir pAllPanes->AddPane(mpPaneContainer->FindPaneURL( 968*cdf0e10cSrcweir PresenterPaneFactory::msCurrentSlidePreviewPaneURL)); 969*cdf0e10cSrcweir pAllPanes->AddPane(mpPaneContainer->FindPaneURL( 970*cdf0e10cSrcweir PresenterPaneFactory::msNextSlidePreviewPaneURL)); 971*cdf0e10cSrcweir pAllPanes->AddPane(mpPaneContainer->FindPaneURL( 972*cdf0e10cSrcweir PresenterPaneFactory::msToolBarPaneURL)); 973*cdf0e10cSrcweir pAllPanes->AddPane(mpPaneContainer->FindPaneURL( 974*cdf0e10cSrcweir PresenterPaneFactory::msHelpPaneURL)); 975*cdf0e10cSrcweir pAllPanes->AddPane(mpPaneContainer->FindPaneURL( 976*cdf0e10cSrcweir PresenterPaneFactory::msNotesPaneURL)); 977*cdf0e10cSrcweir maPaneGroups.push_back(pAllPanes); 978*cdf0e10cSrcweir pAllPanes->DeactivatePanes(); 979*cdf0e10cSrcweir mpWindowManager->Update(); 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 983*cdf0e10cSrcweir mpPaneContainer->FindPaneId(mxCenterPaneId)); 984*cdf0e10cSrcweir if (pDescriptor.get() != NULL) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir PresenterSpritePane* pPane = dynamic_cast<PresenterSpritePane*>( 987*cdf0e10cSrcweir pDescriptor->mxPane.get()); 988*cdf0e10cSrcweir if (pPane != NULL) 989*cdf0e10cSrcweir pPane->ShowTransparentBorder(); 990*cdf0e10cSrcweir 991*cdf0e10cSrcweir pDescriptor->SetActivationState(true); 992*cdf0e10cSrcweir if (pDescriptor->mxBorderWindow.is()) 993*cdf0e10cSrcweir pDescriptor->mxBorderWindow->setVisible(sal_True); 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir } 996*cdf0e10cSrcweir 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir void TransparentOverlayAnimator::HidePane (void) 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir maPaneGroups[0]->ActivatePanes(); 1003*cdf0e10cSrcweir EndActions::const_iterator iAction; 1004*cdf0e10cSrcweir for (iAction=maHideEndActions.begin(); iAction!=maHideEndActions.end(); ++iAction) 1005*cdf0e10cSrcweir (*iAction)(); 1006*cdf0e10cSrcweir mpWindowManager->Update(); 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir void TransparentOverlayAnimator::CreateBackgroundSprite (void) 1013*cdf0e10cSrcweir { 1014*cdf0e10cSrcweir Reference<awt::XWindow> xParentWindow (mpWindowManager->GetParentWindow(), UNO_QUERY); 1015*cdf0e10cSrcweir Reference<rendering::XSpriteCanvas> xParentCanvas (mpWindowManager->GetParentCanvas(), UNO_QUERY); 1016*cdf0e10cSrcweir if (xParentWindow.is() && xParentCanvas.is()) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir const awt::Rectangle aWindowBox (xParentWindow->getPosSize()); 1019*cdf0e10cSrcweir maBackgroundSprite.SetFactory(xParentCanvas); 1020*cdf0e10cSrcweir maBackgroundSprite.Resize( 1021*cdf0e10cSrcweir geometry::RealSize2D(aWindowBox.Width, aWindowBox.Height)); 1022*cdf0e10cSrcweir maBackgroundSprite.MoveTo( 1023*cdf0e10cSrcweir geometry::RealPoint2D(aWindowBox.X, aWindowBox.Y)); 1024*cdf0e10cSrcweir maBackgroundSprite.SetAlpha(0.5); 1025*cdf0e10cSrcweir maBackgroundSprite.Show(); 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir Reference<rendering::XCanvas> xCanvas (maBackgroundSprite.GetCanvas()); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir if (xCanvas.is()) 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir rendering::ViewState aViewState( 1032*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0), 1033*cdf0e10cSrcweir NULL); 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir rendering::RenderState aRenderState( 1036*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0), 1037*cdf0e10cSrcweir NULL, 1038*cdf0e10cSrcweir Sequence<double>(4), 1039*cdf0e10cSrcweir rendering::CompositeOperation::SOURCE); 1040*cdf0e10cSrcweir PresenterCanvasHelper::SetDeviceColor(aRenderState, util::Color(0x80808080)); 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir Reference<rendering::XPolyPolygon2D> xPolygon ( 1043*cdf0e10cSrcweir PresenterGeometryHelper::CreatePolygon(aWindowBox, xCanvas->getDevice())); 1044*cdf0e10cSrcweir if (xPolygon.is()) 1045*cdf0e10cSrcweir xCanvas->fillPolyPolygon( 1046*cdf0e10cSrcweir xPolygon, 1047*cdf0e10cSrcweir aViewState, 1048*cdf0e10cSrcweir aRenderState); 1049*cdf0e10cSrcweir } 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir } 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir 1056*cdf0e10cSrcweir //===== PaneGroup ============================================================= 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir PaneGroup::PaneGroup (void) 1059*cdf0e10cSrcweir : maPanes(), 1060*cdf0e10cSrcweir maOriginalBoundingBox(), 1061*cdf0e10cSrcweir maCurrentBoundingBox(), 1062*cdf0e10cSrcweir mpSubstitution(new PresenterSprite()) 1063*cdf0e10cSrcweir { 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir PaneGroup::~PaneGroup (void) 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir mpSubstitution.reset(); 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir 1077*cdf0e10cSrcweir void PaneGroup::AddPane (const PresenterPaneContainer::SharedPaneDescriptor& rpPane) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir OSL_ASSERT(rpPane.get() != NULL); 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir if (rpPane->mxBorderWindow.is()) 1082*cdf0e10cSrcweir { 1083*cdf0e10cSrcweir PaneDescriptor aDescriptor (rpPane); 1084*cdf0e10cSrcweir maPanes.push_back(aDescriptor); 1085*cdf0e10cSrcweir maOriginalBoundingBox = PresenterGeometryHelper::Union( 1086*cdf0e10cSrcweir maOriginalBoundingBox, 1087*cdf0e10cSrcweir rpPane->mxBorderWindow->getPosSize()); 1088*cdf0e10cSrcweir } 1089*cdf0e10cSrcweir } 1090*cdf0e10cSrcweir 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir 1094*cdf0e10cSrcweir void PaneGroup::CreateSubstitution (const Reference<rendering::XSpriteCanvas>& rxCanvas) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir // Get the bitmap of the background. 1097*cdf0e10cSrcweir Reference<rendering::XBitmap> xBackgroundBitmap (rxCanvas, UNO_QUERY); 1098*cdf0e10cSrcweir if ( ! xBackgroundBitmap.is()) 1099*cdf0e10cSrcweir return; 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir // Create the sprite. 1102*cdf0e10cSrcweir mpSubstitution->SetFactory(rxCanvas); 1103*cdf0e10cSrcweir mpSubstitution->Resize( 1104*cdf0e10cSrcweir geometry::RealSize2D(maOriginalBoundingBox.Width, maOriginalBoundingBox.Height)); 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir // Fill it with the background inside the bounding box. 1107*cdf0e10cSrcweir const rendering::ViewState aViewState ( 1108*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,0, 0,1,0), 1109*cdf0e10cSrcweir NULL); 1110*cdf0e10cSrcweir const rendering::RenderState aRenderState ( 1111*cdf0e10cSrcweir geometry::AffineMatrix2D(1,0,-maOriginalBoundingBox.X, 0,1,-maOriginalBoundingBox.Y), 1112*cdf0e10cSrcweir NULL, 1113*cdf0e10cSrcweir Sequence<double>(4), 1114*cdf0e10cSrcweir rendering::CompositeOperation::SOURCE); 1115*cdf0e10cSrcweir 1116*cdf0e10cSrcweir Reference<rendering::XCanvas> xSpriteCanvas (mpSubstitution->GetCanvas()); 1117*cdf0e10cSrcweir if (xSpriteCanvas.is()) 1118*cdf0e10cSrcweir xSpriteCanvas->drawBitmap(xBackgroundBitmap, aViewState, aRenderState); 1119*cdf0e10cSrcweir } 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir void PaneGroup::Restore (void) 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1127*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir iPane->Restore(); 1130*cdf0e10cSrcweir } 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir 1136*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> PaneGroup::GetSubstitution (void) 1137*cdf0e10cSrcweir { 1138*cdf0e10cSrcweir return mpSubstitution; 1139*cdf0e10cSrcweir } 1140*cdf0e10cSrcweir 1141*cdf0e10cSrcweir 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir geometry::RealRectangle2D PaneGroup::GetOriginalBoundingBox (void) const 1145*cdf0e10cSrcweir { 1146*cdf0e10cSrcweir return geometry::RealRectangle2D( 1147*cdf0e10cSrcweir maOriginalBoundingBox.X, 1148*cdf0e10cSrcweir maOriginalBoundingBox.Y, 1149*cdf0e10cSrcweir maOriginalBoundingBox.X + maOriginalBoundingBox.Width, 1150*cdf0e10cSrcweir maOriginalBoundingBox.Y + maOriginalBoundingBox.Height); 1151*cdf0e10cSrcweir } 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir 1156*cdf0e10cSrcweir geometry::RealRectangle2D PaneGroup::GetCurrentBoundingBox (void) const 1157*cdf0e10cSrcweir { 1158*cdf0e10cSrcweir return maCurrentBoundingBox; 1159*cdf0e10cSrcweir } 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir void PaneGroup::MovePanes ( 1165*cdf0e10cSrcweir const double nXOffset, 1166*cdf0e10cSrcweir const double nYOffset, 1167*cdf0e10cSrcweir const ::rtl::Reference<PresenterWindowManager>& rpWindowManager 1168*cdf0e10cSrcweir ) 1169*cdf0e10cSrcweir { 1170*cdf0e10cSrcweir awt::Rectangle aBBox; 1171*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1172*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1173*cdf0e10cSrcweir { 1174*cdf0e10cSrcweir awt::Rectangle aBox (iPane->mpPaneDescriptor->mxBorderWindow->getPosSize()); 1175*cdf0e10cSrcweir aBox.X += sal_Int32(nXOffset); 1176*cdf0e10cSrcweir aBox.Y += sal_Int32(nYOffset); 1177*cdf0e10cSrcweir rpWindowManager->SetPanePosSizeAbsolute( 1178*cdf0e10cSrcweir iPane->mpPaneDescriptor->mxPaneId->getResourceURL(), 1179*cdf0e10cSrcweir aBox.X, 1180*cdf0e10cSrcweir aBox.Y, 1181*cdf0e10cSrcweir aBox.Width, 1182*cdf0e10cSrcweir aBox.Height); 1183*cdf0e10cSrcweir aBBox = PresenterGeometryHelper::Union(aBBox, aBox); 1184*cdf0e10cSrcweir } 1185*cdf0e10cSrcweir maCurrentBoundingBox = geometry::RealRectangle2D( 1186*cdf0e10cSrcweir aBBox.X, aBBox.Y, aBBox.X+aBBox.Width, aBBox.Y+aBBox.Height); 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir 1190*cdf0e10cSrcweir 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir void PaneGroup::ActivatePanes (void) 1193*cdf0e10cSrcweir { 1194*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1195*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1196*cdf0e10cSrcweir { 1197*cdf0e10cSrcweir iPane->mpPaneDescriptor->SetActivationState(true); 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir } 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir 1204*cdf0e10cSrcweir void PaneGroup::DeactivatePanes (void) 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1207*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir iPane->mpPaneDescriptor->SetActivationState(false); 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir } 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir 1214*cdf0e10cSrcweir 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir void PaneGroup::ShowPanes (void) 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1219*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1220*cdf0e10cSrcweir { 1221*cdf0e10cSrcweir iPane->mpPaneDescriptor->mxBorderWindow->setVisible(sal_True); 1222*cdf0e10cSrcweir iPane->mpPaneDescriptor->mxContentWindow->setVisible(sal_True); 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir } 1225*cdf0e10cSrcweir 1226*cdf0e10cSrcweir 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir void PaneGroup::HidePanes (void) 1230*cdf0e10cSrcweir { 1231*cdf0e10cSrcweir vector<PaneDescriptor>::iterator iPane; 1232*cdf0e10cSrcweir for (iPane=maPanes.begin(); iPane!=maPanes.end(); ++iPane) 1233*cdf0e10cSrcweir { 1234*cdf0e10cSrcweir iPane->mpPaneDescriptor->mxBorderWindow->setVisible(sal_False); 1235*cdf0e10cSrcweir iPane->mpPaneDescriptor->mxContentWindow->setVisible(sal_False); 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir 1240*cdf0e10cSrcweir 1241*cdf0e10cSrcweir 1242*cdf0e10cSrcweir //===== PaneDescriptor ======================================================== 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir PaneDescriptor::PaneDescriptor (const PresenterPaneContainer::SharedPaneDescriptor& rpDescriptor) 1245*cdf0e10cSrcweir : mpPaneDescriptor(rpDescriptor), 1246*cdf0e10cSrcweir mnLeft(rpDescriptor->mnLeft), 1247*cdf0e10cSrcweir mnTop(rpDescriptor->mnTop), 1248*cdf0e10cSrcweir mnRight(rpDescriptor->mnRight), 1249*cdf0e10cSrcweir mnBottom(rpDescriptor->mnBottom) 1250*cdf0e10cSrcweir { 1251*cdf0e10cSrcweir } 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir void PaneDescriptor::Restore (void) const 1257*cdf0e10cSrcweir { 1258*cdf0e10cSrcweir mpPaneDescriptor->mnLeft = mnLeft; 1259*cdf0e10cSrcweir mpPaneDescriptor->mnTop = mnTop; 1260*cdf0e10cSrcweir mpPaneDescriptor->mnRight = mnRight; 1261*cdf0e10cSrcweir mpPaneDescriptor->mnBottom = mnBottom; 1262*cdf0e10cSrcweir } 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir //===== MultiAnimation ======================================================== 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir MultiAnimation::MultiAnimation (const sal_uInt32 nDuration) 1270*cdf0e10cSrcweir : PresenterAnimation(0, nDuration, 1000/50), 1271*cdf0e10cSrcweir maAnimations() 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir } 1274*cdf0e10cSrcweir 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir void MultiAnimation::AddAnimation (const Animation& rAnimation) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir maAnimations.push_back(rAnimation); 1281*cdf0e10cSrcweir } 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir void MultiAnimation::Run (const double nProgress, const sal_uInt64 nCurrentTime) 1287*cdf0e10cSrcweir { 1288*cdf0e10cSrcweir (void)nCurrentTime; 1289*cdf0e10cSrcweir vector<Animation>::const_iterator iAnimation (maAnimations.begin()); 1290*cdf0e10cSrcweir vector<Animation>::const_iterator iEnd (maAnimations.end()); 1291*cdf0e10cSrcweir for ( ; iAnimation!=iEnd; ++iAnimation) 1292*cdf0e10cSrcweir (*iAnimation)(nProgress); 1293*cdf0e10cSrcweir } 1294*cdf0e10cSrcweir 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir //===== functors ============================================================== 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir void InterpolatePosition ( 1301*cdf0e10cSrcweir const ::boost::function<void(geometry::RealPoint2D)>& rSetter, 1302*cdf0e10cSrcweir double nP, 1303*cdf0e10cSrcweir const geometry::RealPoint2D rInitialBox, 1304*cdf0e10cSrcweir const geometry::RealPoint2D rFinalBox) 1305*cdf0e10cSrcweir { 1306*cdf0e10cSrcweir const double nQ (1 - nP); 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir OSL_TRACE("InterpolatePosition %f\n", nP); 1309*cdf0e10cSrcweir rSetter( 1310*cdf0e10cSrcweir geometry::RealPoint2D( 1311*cdf0e10cSrcweir nQ * rInitialBox.X + nP * rFinalBox.X, 1312*cdf0e10cSrcweir nQ * rInitialBox.Y + nP * rFinalBox.Y)); 1313*cdf0e10cSrcweir } 1314*cdf0e10cSrcweir 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir 1317*cdf0e10cSrcweir 1318*cdf0e10cSrcweir template<typename T> 1319*cdf0e10cSrcweir void InterpolateValue ( 1320*cdf0e10cSrcweir const ::boost::function<void(T)>& rSetter, 1321*cdf0e10cSrcweir double nP, 1322*cdf0e10cSrcweir const T aInitialValue, 1323*cdf0e10cSrcweir const T aFinalValue) 1324*cdf0e10cSrcweir { 1325*cdf0e10cSrcweir const double nQ (1 - nP); 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir rSetter(T(nQ * aInitialValue + nP * aFinalValue)); 1328*cdf0e10cSrcweir } 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir 1331*cdf0e10cSrcweir 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir void SpriteTransform( 1334*cdf0e10cSrcweir const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 1335*cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId, 1336*cdf0e10cSrcweir const Reference<awt::XWindow>& rxSpriteOwnerWindow, 1337*cdf0e10cSrcweir const ::boost::shared_ptr<PresenterPaintManager>& rpPaintManager, 1338*cdf0e10cSrcweir const bool bAppear, 1339*cdf0e10cSrcweir const double nX, 1340*cdf0e10cSrcweir const double nInitialTop, 1341*cdf0e10cSrcweir const double nFinalTop, 1342*cdf0e10cSrcweir const double nP) 1343*cdf0e10cSrcweir { 1344*cdf0e10cSrcweir OSL_ASSERT(rpPaintManager.get()!=NULL); 1345*cdf0e10cSrcweir 1346*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 1347*cdf0e10cSrcweir rpPaneContainer->FindPaneId(rxPaneId)); 1348*cdf0e10cSrcweir if (pDescriptor.get() != NULL 1349*cdf0e10cSrcweir && ! pDescriptor->maSpriteProvider.empty() 1350*cdf0e10cSrcweir && pDescriptor->mxBorderWindow.is()) 1351*cdf0e10cSrcweir { 1352*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> pSprite (pDescriptor->maSpriteProvider()); 1353*cdf0e10cSrcweir if (pSprite.get()) 1354*cdf0e10cSrcweir { 1355*cdf0e10cSrcweir // There seems to be a problem with sprites not correctly 1356*cdf0e10cSrcweir // invalidating the background when being transformed. As a 1357*cdf0e10cSrcweir // workaround invalidate the background in the bounding box of 1358*cdf0e10cSrcweir // the sprite before the transformation. 1359*cdf0e10cSrcweir rpPaintManager->Invalidate( 1360*cdf0e10cSrcweir rxSpriteOwnerWindow, 1361*cdf0e10cSrcweir awt::Rectangle( 1362*cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(pSprite->GetLocation().X), 1363*cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(pSprite->GetLocation().Y), 1364*cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(pSprite->GetSize().Width), 1365*cdf0e10cSrcweir sal::static_int_cast<sal_Int32>(pSprite->GetSize().Height))); 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir const double nYScale (bAppear ? nP : 1-nP); 1368*cdf0e10cSrcweir pSprite->Transform(geometry::AffineMatrix2D( 1369*cdf0e10cSrcweir 1, 0, 0, 1370*cdf0e10cSrcweir 0, nYScale, 0)); 1371*cdf0e10cSrcweir pSprite->MoveTo( 1372*cdf0e10cSrcweir geometry::RealPoint2D(nX, nYScale*nFinalTop + (1-nYScale)*nInitialTop)); 1373*cdf0e10cSrcweir pSprite->Show(); 1374*cdf0e10cSrcweir 1375*cdf0e10cSrcweir pDescriptor->mxBorderWindow->setVisible(sal_True); 1376*cdf0e10cSrcweir } 1377*cdf0e10cSrcweir } 1378*cdf0e10cSrcweir } 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir 1381*cdf0e10cSrcweir 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir void SpritePaneMove ( 1384*cdf0e10cSrcweir const rtl::Reference<PresenterPaneContainer>& rpPaneContainer, 1385*cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId, 1386*cdf0e10cSrcweir const geometry::RealPoint2D& rLocation) 1387*cdf0e10cSrcweir { 1388*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( 1389*cdf0e10cSrcweir rpPaneContainer->FindPaneId(rxPaneId)); 1390*cdf0e10cSrcweir if (pDescriptor.get() != NULL 1391*cdf0e10cSrcweir && ! pDescriptor->maSpriteProvider.empty() 1392*cdf0e10cSrcweir && pDescriptor->mxBorderWindow.is()) 1393*cdf0e10cSrcweir { 1394*cdf0e10cSrcweir ::boost::shared_ptr<PresenterSprite> pSprite (pDescriptor->maSpriteProvider()); 1395*cdf0e10cSrcweir if (pSprite.get() != NULL) 1396*cdf0e10cSrcweir { 1397*cdf0e10cSrcweir pDescriptor->mxBorderWindow->setVisible(sal_True); 1398*cdf0e10cSrcweir pSprite->MoveTo(rLocation); 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir } 1402*cdf0e10cSrcweir 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir 1405*cdf0e10cSrcweir 1406*cdf0e10cSrcweir geometry::RealPoint2D GetLocation (const geometry::RealRectangle2D& rBox) 1407*cdf0e10cSrcweir { 1408*cdf0e10cSrcweir return geometry::RealPoint2D(rBox.X1, rBox.Y1); 1409*cdf0e10cSrcweir } 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir 1413*cdf0e10cSrcweir 1414*cdf0e10cSrcweir geometry::RealSize2D GetSize (const geometry::RealRectangle2D& rBox) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir return geometry::RealSize2D(rBox.X2-rBox.X1, rBox.Y2-rBox.Y1); 1417*cdf0e10cSrcweir } 1418*cdf0e10cSrcweir 1419*cdf0e10cSrcweir } // end of anonymous namespace 1420*cdf0e10cSrcweir 1421*cdf0e10cSrcweir 1422*cdf0e10cSrcweir 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir } } // end of namespace ::sdext::presenter 1425