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