Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / sdr / animation / scheduler.hxx
blob1feda3ae0ccc2ad024cec2fbe7629a0e03c6c9f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SVX_SDR_ANIMATION_SCHEDULER_HXX
21 #define INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
23 #include <sal/types.h>
24 #include <vcl/timer.hxx>
25 #include <svx/svxdllapi.h>
28 // event class
30 namespace sdr
32 namespace animation
34 class SVX_DLLPUBLIC Event
36 // time of event in ms
37 sal_uInt32 mnTime;
39 // pointer for linked list sorted by mnTime
40 Event* mpNext;
42 public:
43 // constructor/destructor
44 SAL_DLLPRIVATE explicit Event(sal_uInt32 nTime);
45 virtual ~Event();
47 // access to mpNext
48 SAL_DLLPRIVATE Event* GetNext() const { return mpNext; }
49 SAL_DLLPRIVATE void SetNext(Event* pNew);
51 // get/set time
52 SAL_DLLPRIVATE sal_uInt32 GetTime() const { return mnTime; }
53 void SetTime(sal_uInt32 nNew);
55 // execute event
56 virtual void Trigger(sal_uInt32 nTime) = 0;
58 } // end of namespace animation
59 } // end of namespace sdr
62 // eventlist class
64 namespace sdr
66 namespace animation
68 class SVX_DLLPUBLIC EventList
70 // pointer to first entry
71 Event* mpHead;
73 public:
74 // constructor/destructor
75 SAL_DLLPRIVATE EventList();
76 virtual ~EventList();
78 // insert/remove time dependent
79 SAL_DLLPRIVATE void Insert(Event* pNew);
80 SAL_DLLPRIVATE void Remove(Event* pOld);
82 // clear list
83 SAL_DLLPRIVATE void Clear();
85 // get first
86 SAL_DLLPRIVATE Event* GetFirst() { return mpHead; }
88 } // end of namespace animation
89 } // end of namespace sdr
92 // scheduler class
94 namespace sdr
96 namespace animation
98 class SVX_DLLPUBLIC Scheduler : public Timer
100 // time in ms
101 sal_uInt32 mnTime;
103 // next delta time
104 sal_uInt32 mnDeltaTime;
106 // list of events
107 EventList maList;
109 // Flag which remembers if this timer is paused. Default
110 // is false.
111 bool mbIsPaused;
113 public:
114 // constructor/destructor
115 SAL_DLLPRIVATE Scheduler();
116 virtual ~Scheduler();
118 // From baseclass Timer, the timeout call
119 virtual void Invoke() SAL_OVERRIDE;
121 // get time
122 SAL_DLLPRIVATE sal_uInt32 GetTime() { return mnTime; }
124 // #i38135#
125 SAL_DLLPRIVATE void SetTime(sal_uInt32 nTime);
127 // execute all ripe events, removes executed ones from the scheduler
128 SAL_DLLPRIVATE void triggerEvents();
130 // re-start or stop timer according to event list
131 SAL_DLLPRIVATE void checkTimeout();
133 // insert/remove events, wrapper to EventList methods
134 void InsertEvent(Event* pNew);
135 SAL_DLLPRIVATE void RemoveEvent(Event* pOld);
137 // get/set pause
138 SAL_DLLPRIVATE bool IsPaused() const { return mbIsPaused; }
139 SAL_DLLPRIVATE void SetPaused(bool bNew);
141 } // end of namespace animation
142 } // end of namespace sdr
146 #endif // INCLUDED_SVX_SDR_ANIMATION_SCHEDULER_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */