1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_USEREVENTQUEUE_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_USEREVENTQUEUE_HXX
23 #include <com/sun/star/animations/XAnimationNode.hpp>
25 #include "eventmultiplexer.hxx"
26 #include "eventqueue.hxx"
29 #include <boost/noncopyable.hpp>
31 /* Definition of UserEventQueue class */
36 class AllAnimationEventHandler
;
37 class ShapeClickEventHandler
;
38 class ClickEventHandler
;
40 class SkipEffectEventHandler
;
41 class RewindEffectEventHandler
;
42 class MouseEnterHandler
;
43 class MouseLeaveHandler
;
45 /** This class schedules user-activated events.
47 This class registeres at the EventMultiplexer and fires
48 events registered for certain user actions. Note that all
49 events will not be fired immediately after the user action
50 occurred, but always added to the EventQueue (and fired the
51 next time that queue is processed). Which is actually a
54 Conceptually, an event is an object that typically is
55 fired only once. After that, the event is exhausted, and
56 should be discarded. Therefore, all events registered on
57 this object are fired and then all references to them are
60 class UserEventQueue
: private ::boost::noncopyable
63 /** Create a user event queue
65 @param rEventMultiplexer
66 The slideshow-global event source, where this class
67 registeres its event handlers.
70 Reference to the main event queue. Since we hold this
71 object by plain reference, it must live longer than we
72 do. On the other hand, that queue must not fire events
73 after this object is destroyed, since we might
74 schedule events there which itself contain plain
75 references to this object. Basically, EventQueue and
76 UserEventQueue should have the same lifetime, and since
77 this is not possible, both must be destructed in a
78 phased mode: first clear both of any remaining events,
81 UserEventQueue( EventMultiplexer
& rMultiplexer
,
82 EventQueue
& rEventQueue
,
83 CursorManager
& rCursorManager
);
86 /** Clear all registered events.
88 This method clears all registered, but
89 not-yet-executed events. This comes in handy when
90 force-ending a slide, to avoid interference with the
91 next slide's event registration.
95 /** Set advance on click behaviour.
97 @param bAdvanceOnClick
98 When true, a click somewhere on the slide will also
99 generate next effect event. In this case, it is
100 irrelevant where on the slide the mouse is clicked,
101 i.e. the shape need not be hit by the mouse.
103 void setAdvanceOnClick( bool bAdvanceOnClick
);
105 /** Register an event that will be fired when the given
106 animation node starts.
108 Note that <em>all</em> registered events will be fired
109 when the animation start occurs. This is in contrast to
110 the mouse events below.
112 void registerAnimationStartEvent(
113 const EventSharedPtr
& rEvent
,
114 const ::com::sun::star::uno::Reference
<
115 ::com::sun::star::animations::XAnimationNode
>& xNode
);
117 /** Register an event that will be fired when the given
118 animation node ends its active duration.
120 Note that <em>all</em> registered events will be fired
121 when the animation end occurs. This is in contrast to
122 the mouse events below.
124 void registerAnimationEndEvent(
125 const EventSharedPtr
& rEvent
,
126 const ::com::sun::star::uno::Reference
<
127 ::com::sun::star::animations::XAnimationNode
>& xNode
);
129 /** Register an event that will be fired when audio output
130 stopped for the given animation node.
132 Note that <em>all</em> registered events will be fired
133 when the audio stopping occurs. This is in contrast to
134 the mouse events below.
136 void registerAudioStoppedEvent(
137 const EventSharedPtr
& rEvent
,
138 const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::animations::XAnimationNode
>& xNode
);
141 /** Register an event that is fired when a shape is clicked
143 For every mouse click, only one of the events
144 registered here is fired. The order of fired events is
145 the order of registration, i.e. the first event
146 registered will be the one fired for the first mouse
147 click on the given shape.
149 void registerShapeClickEvent( const EventSharedPtr
& rEvent
,
150 const ShapeSharedPtr
& rShape
);
152 /** Registes an event that is fired when the current effects(s)
153 are skipped, .e.g. when the left mouse button is pressed.
154 Then, all registered events are fired and removed from this
155 queue. After firing, a next effect event is issued to this
156 queue to start the next effect.
158 The event to execute when skipping the current effect.
159 @param bSkipTriggersNextEffect
160 When <TRUE/> then after skipping the current effect the next
161 effect is triggered. When <FALSE/> then the next effect is not
164 void registerSkipEffectEvent(
165 EventSharedPtr
const& pEvent
,
166 const bool bSkipTriggersNextEffect
);
168 /** Register an event that is fired to show the next event
170 For every next effect event, only one of the events
171 registered here is fired. The order of fired events is
172 the order of registration, i.e. the first event
173 registered will be the one fired for the first mouse
174 click. When advance-on-click (see method
175 setAdvanceOnClick()) is enabled, a mouse click
176 somewhere on the slide will also generate a next
177 effect event. In this case, it is irrelevant where on
178 the slide the mouse is clicked, i.e. the shape need
179 not be hit by the mouse.
181 void registerNextEffectEvent( const EventSharedPtr
& rEvent
);
183 /** Register an event that is fired on a double mouse
186 For every mouse double click, only one of the events
187 registered here is fired. The order of fired events is
188 the order of registration, i.e. the first event
189 registered will be the one fired for the first mouse
190 double click. It is irrelevant where on the slide the
191 mouse is clicked, i.e. the shape need not be hit by
194 void registerShapeDoubleClickEvent( const EventSharedPtr
& rEvent
,
195 const ShapeSharedPtr
& rShape
);
197 /** Register an event that is fired when the mouse enters
198 the area of the given shape
200 For every enter, only one of the events registered
201 here is fired. The order of fired events is the order
202 of registration, i.e. the first event registered will
203 be the one fired for the first time the mouse enters
206 void registerMouseEnterEvent( const EventSharedPtr
& rEvent
,
207 const ShapeSharedPtr
& rShape
);
209 /** Register an event that is fired when the mouse leaves
210 the area of the given shape
212 For every leave, only one of the events registered
213 here is fired. The order of fired events is the order
214 of registration, i.e. the first event registered will
215 be the one fired for the first time the mouse leaves
216 the given shape area.
218 void registerMouseLeaveEvent( const EventSharedPtr
& rEvent
,
219 const ShapeSharedPtr
& rShape
);
221 /** Typically skipping the current effect is triggered by mouse clicks
222 or key presses that trigger the next effect. This method allows the
223 skipping of effects to be triggered programatically.
225 void callSkipEffectEventHandler();
228 /** Generically register an event on one of the handlers.
230 If the handler is not yet created, do that and
231 register it via the Functor
233 template< typename Handler
, typename Functor
>
234 void registerEvent( ::boost::shared_ptr
< Handler
>& rHandler
,
235 const EventSharedPtr
& rEvent
,
236 const Functor
& rRegistrationFunctor
);
238 /** Generically register an event on one of the handlers.
240 If the handler is not yet created, do that and
241 register it via the Functor. This version of the
242 registerEvent method takes an additional parameter
243 rArg, which is passed as the second argument to
244 rHandler's addEvent() method.
246 template< typename Handler
, typename Arg
, typename Functor
>
247 void registerEvent( ::boost::shared_ptr
< Handler
>& rHandler
,
248 const EventSharedPtr
& rEvent
,
250 const Functor
& rRegistrationFunctor
);
252 EventMultiplexer
& mrMultiplexer
;
253 EventQueue
& mrEventQueue
;
254 CursorManager
& mrCursorManager
;
256 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAnimationStartEventHandler
;
257 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAnimationEndEventHandler
;
258 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAudioStoppedEventHandler
;
259 ::boost::shared_ptr
<ShapeClickEventHandler
> mpShapeClickEventHandler
;
260 ::boost::shared_ptr
<ClickEventHandler
> mpClickEventHandler
;
261 ::boost::shared_ptr
<SkipEffectEventHandler
> mpSkipEffectEventHandler
;
262 ::boost::shared_ptr
<ShapeClickEventHandler
> mpShapeDoubleClickEventHandler
;
263 ::boost::shared_ptr
<ClickEventHandler
> mpDoubleClickEventHandler
;
264 ::boost::shared_ptr
<MouseEnterHandler
> mpMouseEnterHandler
;
265 ::boost::shared_ptr
<MouseLeaveHandler
> mpMouseLeaveHandler
;
267 bool mbAdvanceOnClick
;
270 } // namespace internal
271 } // namespace presentation
273 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_USEREVENTQUEUE_HXX
275 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */