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 */
31 namespace slideshow::internal
{
33 class AllAnimationEventHandler
;
34 class ShapeClickEventHandler
;
35 class ClickEventHandler
;
37 class SkipEffectEventHandler
;
38 class RewindEffectEventHandler
;
39 class MouseEnterHandler
;
40 class MouseLeaveHandler
;
42 /** This class schedules user-activated events.
44 This class registers at the EventMultiplexer and fires
45 events registered for certain user actions. Note that all
46 events will not be fired immediately after the user action
47 occurred, but always added to the EventQueue (and fired the
48 next time that queue is processed). Which is actually a
51 Conceptually, an event is an object that typically is
52 fired only once. After that, the event is exhausted, and
53 should be discarded. Therefore, all events registered on
54 this object are fired and then all references to them are
60 /** Create a user event queue
62 @param rEventMultiplexer
63 The slideshow-global event source, where this class
64 registers its event handlers.
67 Reference to the main event queue. Since we hold this
68 object by plain reference, it must live longer than we
69 do. On the other hand, that queue must not fire events
70 after this object is destroyed, since we might
71 schedule events there which itself contain plain
72 references to this object. Basically, EventQueue and
73 UserEventQueue should have the same lifetime, and since
74 this is not possible, both must be destructed in a
75 phased mode: first clear both of any remaining events,
78 UserEventQueue( EventMultiplexer
& rMultiplexer
,
79 EventQueue
& rEventQueue
,
80 CursorManager
& rCursorManager
);
82 UserEventQueue(const UserEventQueue
&) = delete;
83 UserEventQueue
& operator=(const UserEventQueue
&) = delete;
85 /** Clear all registered events.
87 This method clears all registered, but
88 not-yet-executed events. This comes in handy when
89 force-ending a slide, to avoid interference with the
90 next slide's event registration.
94 /** Set advance on click behaviour.
96 @param bAdvanceOnClick
97 When true, a click somewhere on the slide will also
98 generate next effect event. In this case, it is
99 irrelevant where on the slide the mouse is clicked,
100 i.e. the shape need not be hit by the mouse.
102 void setAdvanceOnClick( bool bAdvanceOnClick
);
104 /** Register an event that will be fired when the given
105 animation node starts.
107 Note that <em>all</em> registered events will be fired
108 when the animation start occurs. This is in contrast to
109 the mouse events below.
111 void registerAnimationStartEvent(
112 const EventSharedPtr
& rEvent
,
113 const css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
115 /** Register an event that will be fired when the given
116 animation node ends its active duration.
118 Note that <em>all</em> registered events will be fired
119 when the animation end occurs. This is in contrast to
120 the mouse events below.
122 void registerAnimationEndEvent(
123 const EventSharedPtr
& rEvent
,
124 const css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
126 /** Register an event that will be fired when audio output
127 stopped for the given animation node.
129 Note that <em>all</em> registered events will be fired
130 when the audio stopping occurs. This is in contrast to
131 the mouse events below.
133 void registerAudioStoppedEvent(
134 const EventSharedPtr
& rEvent
,
135 const css::uno::Reference
<css::animations::XAnimationNode
>& xNode
);
137 /** Register an event that is fired when a shape is clicked
139 For every mouse click, only one of the events
140 registered here is fired. The order of fired events is
141 the order of registration, i.e. the first event
142 registered will be the one fired for the first mouse
143 click on the given shape.
145 void registerShapeClickEvent( const EventSharedPtr
& rEvent
,
146 const ShapeSharedPtr
& rShape
);
148 /** Registers an event that is fired when the current effects(s)
149 are skipped, .e.g. when the left mouse button is pressed.
150 Then, all registered events are fired and removed from this
151 queue. After firing, a next effect event is issued to this
152 queue to start the next effect.
154 The event to execute when skipping the current effect.
155 @param bSkipTriggersNextEffect
156 When <TRUE/> then after skipping the current effect the next
157 effect is triggered. When <FALSE/> then the next effect is not
160 void registerSkipEffectEvent(
161 EventSharedPtr
const& pEvent
,
162 const bool bSkipTriggersNextEffect
);
164 /** Register an event that is fired to show the next event
166 For every next effect event, only one of the events
167 registered here is fired. The order of fired events is
168 the order of registration, i.e. the first event
169 registered will be the one fired for the first mouse
170 click. When advance-on-click (see method
171 setAdvanceOnClick()) is enabled, a mouse click
172 somewhere on the slide will also generate a next
173 effect event. In this case, it is irrelevant where on
174 the slide the mouse is clicked, i.e. the shape need
175 not be hit by the mouse.
177 void registerNextEffectEvent( const EventSharedPtr
& rEvent
);
179 /** Register an event that is fired on a double mouse
182 For every mouse double click, only one of the events
183 registered here is fired. The order of fired events is
184 the order of registration, i.e. the first event
185 registered will be the one fired for the first mouse
186 double click. It is irrelevant where on the slide the
187 mouse is clicked, i.e. the shape need not be hit by
190 void registerShapeDoubleClickEvent( const EventSharedPtr
& rEvent
,
191 const ShapeSharedPtr
& rShape
);
193 /** Register an event that is fired when the mouse enters
194 the area of the given shape
196 For every enter, only one of the events registered
197 here is fired. The order of fired events is the order
198 of registration, i.e. the first event registered will
199 be the one fired for the first time the mouse enters
202 void registerMouseEnterEvent( const EventSharedPtr
& rEvent
,
203 const ShapeSharedPtr
& rShape
);
205 /** Register an event that is fired when the mouse leaves
206 the area of the given shape
208 For every leave, 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 leaves
212 the given shape area.
214 void registerMouseLeaveEvent( const EventSharedPtr
& rEvent
,
215 const ShapeSharedPtr
& rShape
);
217 /** Typically skipping the current effect is triggered by mouse clicks
218 or key presses that trigger the next effect. This method allows the
219 skipping of effects to be triggered programmatically.
221 void callSkipEffectEventHandler();
224 /** Generically register an event on one of the handlers.
226 If the handler is not yet created, do that and
227 register it via the Functor
229 template< typename Handler
, typename Functor
>
230 void registerEvent( ::std::shared_ptr
< Handler
>& rHandler
,
231 const EventSharedPtr
& rEvent
,
232 const Functor
& rRegistrationFunctor
);
234 /** Generically register an event on one of the handlers.
236 If the handler is not yet created, do that and
237 register it via the Functor. This version of the
238 registerEvent method takes an additional parameter
239 rArg, which is passed as the second argument to
240 rHandler's addEvent() method.
242 template< typename Handler
, typename Arg
, typename Functor
>
243 void registerEvent( ::std::shared_ptr
< Handler
>& rHandler
,
244 const EventSharedPtr
& rEvent
,
246 const Functor
& rRegistrationFunctor
);
248 EventMultiplexer
& mrMultiplexer
;
249 EventQueue
& mrEventQueue
;
250 CursorManager
& mrCursorManager
;
252 ::std::shared_ptr
<AllAnimationEventHandler
> mpAnimationStartEventHandler
;
253 ::std::shared_ptr
<AllAnimationEventHandler
> mpAnimationEndEventHandler
;
254 ::std::shared_ptr
<AllAnimationEventHandler
> mpAudioStoppedEventHandler
;
255 ::std::shared_ptr
<ShapeClickEventHandler
> mpShapeClickEventHandler
;
256 ::std::shared_ptr
<ClickEventHandler
> mpClickEventHandler
;
257 ::std::shared_ptr
<SkipEffectEventHandler
> mpSkipEffectEventHandler
;
258 ::std::shared_ptr
<ShapeClickEventHandler
> mpShapeDoubleClickEventHandler
;
259 ::std::shared_ptr
<MouseEnterHandler
> mpMouseEnterHandler
;
260 ::std::shared_ptr
<MouseLeaveHandler
> mpMouseLeaveHandler
;
262 bool mbAdvanceOnClick
;
265 } // namespace presentation::internal
267 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_USEREVENTQUEUE_HXX
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */