1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_REHEARSETIMINGSACTIVITY_HXX 21 #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_REHEARSETIMINGSACTIVITY_HXX 22 23 #include <activity.hxx> 24 25 #include <basegfx/range/b2drange.hxx> 26 27 #include <vector> 28 #include <utility> 29 #include <memory> 30 31 namespace vcl { class Font; } 32 namespace canvas{ namespace tools{ class ElapsedTime; }} 33 namespace cppcanvas{ class CustomSprite; } 34 namespace basegfx 35 { 36 class B2IVector; 37 class B2DRange; 38 } 39 40 namespace slideshow { 41 namespace internal { 42 43 struct SlideShowContext; 44 class EventMultiplexer; 45 class ScreenUpdater; 46 class RehearseTimingsActivity : public Activity, 47 public ViewEventHandler 48 { 49 public: 50 /** Creates the activity. 51 */ 52 static std::shared_ptr<RehearseTimingsActivity> create( 53 const SlideShowContext& rContext ); 54 55 virtual ~RehearseTimingsActivity() override; 56 RehearseTimingsActivity(const RehearseTimingsActivity&) = delete; 57 RehearseTimingsActivity& operator=(const RehearseTimingsActivity&) = delete; 58 59 /** Starts and shows the timer; adds to activity queue. 60 */ 61 void start(); 62 63 /** Stops and hides the timer. 64 @return elapsed time 65 */ 66 double stop(); 67 68 /** Determines whether the timer button has been clicked. 69 */ 70 bool hasBeenClicked() const; 71 72 // ViewEventHandler interface 73 virtual void viewAdded( const UnoViewSharedPtr& rView ) override; 74 virtual void viewRemoved( const UnoViewSharedPtr& rView ) override; 75 virtual void viewChanged( const UnoViewSharedPtr& rView ) override; 76 virtual void viewsChanged() override; 77 78 // Disposable: 79 virtual void dispose() override; 80 // Activity: 81 virtual double calcTimeLag() const override; 82 virtual bool perform() override; 83 virtual bool isActive() const override; 84 virtual void dequeued() override; 85 virtual void end() override; 86 87 private: 88 class WakeupEvent; 89 90 explicit RehearseTimingsActivity( const SlideShowContext& rContext ); 91 92 void paint( ::cppcanvas::CanvasSharedPtr const & canvas ) const; 93 void paintAllSprites() const; 94 95 class MouseHandler; 96 friend class MouseHandler; 97 98 typedef std::vector< 99 std::pair<UnoViewSharedPtr, 100 std::shared_ptr<cppcanvas::CustomSprite> > > ViewsVecT; 101 102 template <typename func_type> for_each_sprite(func_type const & func) const103 void for_each_sprite( func_type const & func ) const 104 { 105 ViewsVecT::const_iterator iPos( maViews.begin() ); 106 const ViewsVecT::const_iterator iEnd( maViews.end() ); 107 for ( ; iPos != iEnd; ++iPos ) 108 func( iPos->second ); 109 } 110 111 ::basegfx::B2DRange calcSpriteRectangle( 112 UnoViewSharedPtr const & rView ) const; 113 114 EventQueue& mrEventQueue; 115 ScreenUpdater& mrScreenUpdater; 116 EventMultiplexer& mrEventMultiplexer; 117 ActivitiesQueue& mrActivitiesQueue; 118 canvas::tools::ElapsedTime maElapsedTime; 119 120 ViewsVecT maViews; 121 122 /// screen rect of sprite (in view coordinates!) 123 ::basegfx::B2DRange maSpriteRectangle; 124 125 vcl::Font maFont; 126 std::shared_ptr<WakeupEvent> mpWakeUpEvent; 127 std::shared_ptr<MouseHandler> mpMouseHandler; 128 ::basegfx::B2IVector maSpriteSizePixel; 129 sal_Int32 mnYOffset; 130 bool mbActive; 131 bool mbDrawPressed; 132 }; 133 134 } // namespace internal 135 } // namespace presentation 136 137 #endif // INCLUDED_SLIDESHOW_SOURCE_ENGINE_REHEARSETIMINGSACTIVITY_HXX 138 139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 140