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_USEREVENTQUEUE_HXX
21 #define INCLUDED_SLIDESHOW_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 PlainEventHandler
;
37 class AllAnimationEventHandler
;
38 class ShapeClickEventHandler
;
39 class ClickEventHandler
;
41 class SkipEffectEventHandler
;
42 class RewindEffectEventHandler
;
43 class MouseEnterHandler
;
44 class MouseLeaveHandler
;
46 /** This class schedules user-activated events.
48 This class registeres at the EventMultiplexer and fires
49 events registered for certain user actions. Note that all
50 events will not be fired immediately after the user action
51 occurred, but always added to the EventQueue (and fired the
52 next time that queue is processed). Which is actually a
55 Conceptually, an event is an object that typically is
56 fired only once. After that, the event is exhausted, and
57 should be discarded. Therefore, all events registered on
58 this object are fired and then all references to them are
61 class UserEventQueue
: private ::boost::noncopyable
64 /** Create a user event queue
66 @param rEventMultiplexer
67 The slideshow-global event source, where this class
68 registeres its event handlers.
71 Reference to the main event queue. Since we hold this
72 object by plain reference, it must live longer than we
73 do. On the other hand, that queue must not fire events
74 after this object is destroyed, since we might
75 schedule events there which itself contain plain
76 references to this object. Basically, EventQueue and
77 UserEventQueue should have the same lifetime, and since
78 this is not possible, both must be destructed in a
79 phased mode: first clear both of any remaining events,
82 UserEventQueue( EventMultiplexer
& rMultiplexer
,
83 EventQueue
& rEventQueue
,
84 CursorManager
& rCursorManager
);
87 /** Clear all registered events.
89 This method clears all registered, but
90 not-yet-executed events. This comes in handy when
91 force-ending a slide, to avoid interference with the
92 next slide's event registration.
96 /** Set advance on click behaviour.
98 @param bAdvanceOnClick
99 When true, a click somewhere on the slide will also
100 generate next effect event. In this case, it is
101 irrelevant where on the slide the mouse is clicked,
102 i.e. the shape need not be hit by the mouse.
104 void setAdvanceOnClick( bool bAdvanceOnClick
);
106 /** Register an event that will be fired when the given
107 animation node starts.
109 Note that <em>all</em> registered events will be fired
110 when the animation start occurs. This is in contrast to
111 the mouse events below.
113 void registerAnimationStartEvent(
114 const EventSharedPtr
& rEvent
,
115 const ::com::sun::star::uno::Reference
<
116 ::com::sun::star::animations::XAnimationNode
>& xNode
);
118 /** Register an event that will be fired when the given
119 animation node ends its active duration.
121 Note that <em>all</em> registered events will be fired
122 when the animation end occurs. This is in contrast to
123 the mouse events below.
125 void registerAnimationEndEvent(
126 const EventSharedPtr
& rEvent
,
127 const ::com::sun::star::uno::Reference
<
128 ::com::sun::star::animations::XAnimationNode
>& xNode
);
130 /** Register an event that will be fired when audio output
131 stopped for the given animation node.
133 Note that <em>all</em> registered events will be fired
134 when the audio stopping occurs. This is in contrast to
135 the mouse events below.
137 void registerAudioStoppedEvent(
138 const EventSharedPtr
& rEvent
,
139 const ::com::sun::star::uno::Reference
<
140 ::com::sun::star::animations::XAnimationNode
>& xNode
);
142 /** Register an event that is fired when a shape is clicked
144 For every mouse click, only one of the events
145 registered here is fired. The order of fired events is
146 the order of registration, i.e. the first event
147 registered will be the one fired for the first mouse
148 click on the given shape.
150 void registerShapeClickEvent( const EventSharedPtr
& rEvent
,
151 const ShapeSharedPtr
& rShape
);
153 /** Registes an event that is fired when the current effects(s)
154 are skipped, .e.g. when the left mouse button is pressed.
155 Then, all registered events are fired and removed from this
156 queue. After firing, a next effect event is issued to this
157 queue to start the next effect.
159 The event to execute when skipping the current effect.
160 @param bSkipTriggersNextEffect
161 When <TRUE/> then after skipping the current effect the next
162 effect is triggered. When <FALSE/> then the next effect is not
165 void registerSkipEffectEvent(
166 EventSharedPtr
const& pEvent
,
167 const bool bSkipTriggersNextEffect
);
169 /** Registes an event that is fired when the current effects(s)
170 are rewound, .e.g. when the right mouse button is pressed.
171 Then, all registered events are fired and removed from this
174 void registerRewindEffectEvent( EventSharedPtr
const& rEvent
);
176 /** Register an event that is fired to show the next event
178 For every next effect event, only one of the events
179 registered here is fired. The order of fired events is
180 the order of registration, i.e. the first event
181 registered will be the one fired for the first mouse
182 click. When advance-on-click (see method
183 setAdvanceOnClick()) is enabled, a mouse click
184 somewhere on the slide will also generate a next
185 effect event. In this case, it is irrelevant where on
186 the slide the mouse is clicked, i.e. the shape need
187 not be hit by the mouse.
189 void registerNextEffectEvent( const EventSharedPtr
& rEvent
);
191 /** Register an event that is fired on a double mouse
194 For every mouse double click, only one of the events
195 registered here is fired. The order of fired events is
196 the order of registration, i.e. the first event
197 registered will be the one fired for the first mouse
198 double click. It is irrelevant where on the slide the
199 mouse is clicked, i.e. the shape need not be hit by
202 void registerShapeDoubleClickEvent( const EventSharedPtr
& rEvent
,
203 const ShapeSharedPtr
& rShape
);
205 /** Register an event that is fired when the mouse enters
206 the area of the given shape
208 For every enter, only one of the events registered
209 here is fired. The order of fired events is the order
210 of registration, i.e. the first event registered will
211 be the one fired for the first time the mouse enters
214 void registerMouseEnterEvent( const EventSharedPtr
& rEvent
,
215 const ShapeSharedPtr
& rShape
);
217 /** Register an event that is fired when the mouse leaves
218 the area of the given shape
220 For every leave, only one of the events registered
221 here is fired. The order of fired events is the order
222 of registration, i.e. the first event registered will
223 be the one fired for the first time the mouse leaves
224 the given shape area.
226 void registerMouseLeaveEvent( const EventSharedPtr
& rEvent
,
227 const ShapeSharedPtr
& rShape
);
229 /** Typically skipping the current effect is triggered by mouse clicks
230 or key presses that trigger the next effect. This method allows the
231 skipping of effects to be triggered programatically.
233 void callSkipEffectEventHandler (void);
236 /** Generically register an event on one of the handlers.
238 If the handler is not yet created, do that and
239 register it via the Functor
241 template< typename Handler
, typename Functor
>
242 void registerEvent( ::boost::shared_ptr
< Handler
>& rHandler
,
243 const EventSharedPtr
& rEvent
,
244 const Functor
& rRegistrationFunctor
);
246 /** Generically register an event on one of the handlers.
248 If the handler is not yet created, do that and
249 register it via the Functor. This version of the
250 registerEvent method takes an additional parameter
251 rArg, which is passed as the second argument to
252 rHandler's addEvent() method.
254 template< typename Handler
, typename Arg
, typename Functor
>
255 void registerEvent( ::boost::shared_ptr
< Handler
>& rHandler
,
256 const EventSharedPtr
& rEvent
,
258 const Functor
& rRegistrationFunctor
);
260 EventMultiplexer
& mrMultiplexer
;
261 EventQueue
& mrEventQueue
;
262 CursorManager
& mrCursorManager
;
264 ::boost::shared_ptr
<PlainEventHandler
> mpStartEventHandler
;
265 ::boost::shared_ptr
<PlainEventHandler
> mpEndEventHandler
;
266 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAnimationStartEventHandler
;
267 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAnimationEndEventHandler
;
268 ::boost::shared_ptr
<AllAnimationEventHandler
> mpAudioStoppedEventHandler
;
269 ::boost::shared_ptr
<ShapeClickEventHandler
> mpShapeClickEventHandler
;
270 ::boost::shared_ptr
<ClickEventHandler
> mpClickEventHandler
;
271 ::boost::shared_ptr
<SkipEffectEventHandler
> mpSkipEffectEventHandler
;
272 ::boost::shared_ptr
<RewindEffectEventHandler
> mpRewindEffectEventHandler
;
273 ::boost::shared_ptr
<ShapeClickEventHandler
> mpShapeDoubleClickEventHandler
;
274 ::boost::shared_ptr
<ClickEventHandler
> mpDoubleClickEventHandler
;
275 ::boost::shared_ptr
<MouseEnterHandler
> mpMouseEnterHandler
;
276 ::boost::shared_ptr
<MouseLeaveHandler
> mpMouseLeaveHandler
;
278 bool mbAdvanceOnClick
;
281 } // namespace internal
282 } // namespace presentation
284 #endif /* INCLUDED_SLIDESHOW_USEREVENTQUEUE_HXX */
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */