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 /* Definition of UserEventQueue class */
34 class AllAnimationEventHandler
;
35 class ShapeClickEventHandler
;
36 class ClickEventHandler
;
38 class SkipEffectEventHandler
;
39 class RewindEffectEventHandler
;
40 class MouseEnterHandler
;
41 class MouseLeaveHandler
;
43 /** This class schedules user-activated events.
45 This class registers at the EventMultiplexer and fires
46 events registered for certain user actions. Note that all
47 events will not be fired immediately after the user action
48 occurred, but always added to the EventQueue (and fired the
49 next time that queue is processed). Which is actually a
52 Conceptually, an event is an object that typically is
53 fired only once. After that, the event is exhausted, and
54 should be discarded. Therefore, all events registered on
55 this object are fired and then all references to them are
61 /** Create a user event queue
63 @param rEventMultiplexer
64 The slideshow-global event source, where this class
65 registers its event handlers.
68 Reference to the main event queue. Since we hold this
69 object by plain reference, it must live longer than we
70 do. On the other hand, that queue must not fire events
71 after this object is destroyed, since we might
72 schedule events there which itself contain plain
73 references to this object. Basically, EventQueue and
74 UserEventQueue should have the same lifetime, and since
75 this is not possible, both must be destructed in a
76 phased mode: first clear both of any remaining events,
79 UserEventQueue( EventMultiplexer
& rMultiplexer
,
80 EventQueue
& rEventQueue
,
81 CursorManager
& rCursorManager
);
83 UserEventQueue(const UserEventQueue
&) = delete;
84 UserEventQueue
& operator=(const UserEventQueue
&) = delete;
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 css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
116 /** Register an event that will be fired when the given
117 animation node ends its active duration.
119 Note that <em>all</em> registered events will be fired
120 when the animation end occurs. This is in contrast to
121 the mouse events below.
123 void registerAnimationEndEvent(
124 const EventSharedPtr
& rEvent
,
125 const css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
127 /** Register an event that will be fired when audio output
128 stopped for the given animation node.
130 Note that <em>all</em> registered events will be fired
131 when the audio stopping occurs. This is in contrast to
132 the mouse events below.
134 void registerAudioStoppedEvent(
135 const EventSharedPtr
& rEvent
,
136 const css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
138 /** Register an event that is fired when a shape is clicked
140 For every mouse click, only one of the events
141 registered here is fired. The order of fired events is
142 the order of registration, i.e. the first event
143 registered will be the one fired for the first mouse
144 click on the given shape.
146 void registerShapeClickEvent( const EventSharedPtr
& rEvent
,
147 const ShapeSharedPtr
& rShape
);
149 /** Registers an event that is fired when the current effects(s)
150 are skipped, .e.g. when the left mouse button is pressed.
151 Then, all registered events are fired and removed from this
152 queue. After firing, a next effect event is issued to this
153 queue to start the next effect.
155 The event to execute when skipping the current effect.
156 @param bSkipTriggersNextEffect
157 When <TRUE/> then after skipping the current effect the next
158 effect is triggered. When <FALSE/> then the next effect is not
161 void registerSkipEffectEvent(
162 EventSharedPtr
const& pEvent
,
163 const bool bSkipTriggersNextEffect
);
165 /** Register an event that is fired to show the next event
167 For every next effect event, only one of the events
168 registered here is fired. The order of fired events is
169 the order of registration, i.e. the first event
170 registered will be the one fired for the first mouse
171 click. When advance-on-click (see method
172 setAdvanceOnClick()) is enabled, a mouse click
173 somewhere on the slide will also generate a next
174 effect event. In this case, it is irrelevant where on
175 the slide the mouse is clicked, i.e. the shape need
176 not be hit by the mouse.
178 void registerNextEffectEvent( const EventSharedPtr
& rEvent
);
180 /** Register an event that is fired on a double mouse
183 For every mouse double click, only one of the events
184 registered here is fired. The order of fired events is
185 the order of registration, i.e. the first event
186 registered will be the one fired for the first mouse
187 double click. It is irrelevant where on the slide the
188 mouse is clicked, i.e. the shape need not be hit by
191 void registerShapeDoubleClickEvent( const EventSharedPtr
& rEvent
,
192 const ShapeSharedPtr
& rShape
);
194 /** Register an event that is fired when the mouse enters
195 the area of the given shape
197 For every enter, only one of the events registered
198 here is fired. The order of fired events is the order
199 of registration, i.e. the first event registered will
200 be the one fired for the first time the mouse enters
203 void registerMouseEnterEvent( const EventSharedPtr
& rEvent
,
204 const ShapeSharedPtr
& rShape
);
206 /** Register an event that is fired when the mouse leaves
207 the area of the given shape
209 For every leave, only one of the events registered
210 here is fired. The order of fired events is the order
211 of registration, i.e. the first event registered will
212 be the one fired for the first time the mouse leaves
213 the given shape area.
215 void registerMouseLeaveEvent( const EventSharedPtr
& rEvent
,
216 const ShapeSharedPtr
& rShape
);
218 /** Typically skipping the current effect is triggered by mouse clicks
219 or key presses that trigger the next effect. This method allows the
220 skipping of effects to be triggered programatically.
222 void callSkipEffectEventHandler();
225 /** Generically register an event on one of the handlers.
227 If the handler is not yet created, do that and
228 register it via the Functor
230 template< typename Handler
, typename Functor
>
231 void registerEvent( ::std::shared_ptr
< Handler
>& rHandler
,
232 const EventSharedPtr
& rEvent
,
233 const Functor
& rRegistrationFunctor
);
235 /** Generically register an event on one of the handlers.
237 If the handler is not yet created, do that and
238 register it via the Functor. This version of the
239 registerEvent method takes an additional parameter
240 rArg, which is passed as the second argument to
241 rHandler's addEvent() method.
243 template< typename Handler
, typename Arg
, typename Functor
>
244 void registerEvent( ::std::shared_ptr
< Handler
>& rHandler
,
245 const EventSharedPtr
& rEvent
,
247 const Functor
& rRegistrationFunctor
);
249 EventMultiplexer
& mrMultiplexer
;
250 EventQueue
& mrEventQueue
;
251 CursorManager
& mrCursorManager
;
253 ::std::shared_ptr
<AllAnimationEventHandler
> mpAnimationStartEventHandler
;
254 ::std::shared_ptr
<AllAnimationEventHandler
> mpAnimationEndEventHandler
;
255 ::std::shared_ptr
<AllAnimationEventHandler
> mpAudioStoppedEventHandler
;
256 ::std::shared_ptr
<ShapeClickEventHandler
> mpShapeClickEventHandler
;
257 ::std::shared_ptr
<ClickEventHandler
> mpClickEventHandler
;
258 ::std::shared_ptr
<SkipEffectEventHandler
> mpSkipEffectEventHandler
;
259 ::std::shared_ptr
<ShapeClickEventHandler
> mpShapeDoubleClickEventHandler
;
260 ::std::shared_ptr
<ClickEventHandler
> mpDoubleClickEventHandler
;
261 ::std::shared_ptr
<MouseEnterHandler
> mpMouseEnterHandler
;
262 ::std::shared_ptr
<MouseLeaveHandler
> mpMouseLeaveHandler
;
264 bool mbAdvanceOnClick
;
267 } // namespace internal
268 } // namespace presentation
270 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_USEREVENTQUEUE_HXX
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */