Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / animate.hxx
blob119499629d369cb96ffaded5434cfe2ee33450ed
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_VCL_ANIMATE_HXX
21 #define INCLUDED_VCL_ANIMATE_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/timer.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <vcl/vclptr.hxx>
28 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
30 enum class Disposal
32 Not,
33 Back,
34 Previous
37 struct VCL_DLLPUBLIC AnimationBitmap
39 BitmapEx aBmpEx;
40 Point aPosPix;
41 Size aSizePix;
42 long nWait;
43 Disposal eDisposal;
44 bool bUserInput;
46 AnimationBitmap()
47 : nWait(0)
48 , eDisposal(Disposal::Not)
49 , bUserInput(false)
52 AnimationBitmap(
53 const BitmapEx& rBmpEx,
54 const Point& rPosPix,
55 const Size& rSizePix,
56 long _nWait = 0L,
57 Disposal _eDisposal = Disposal::Not
58 ) :
59 aBmpEx ( rBmpEx ),
60 aPosPix ( rPosPix ),
61 aSizePix ( rSizePix ),
62 nWait ( _nWait ),
63 eDisposal ( _eDisposal ),
64 bUserInput ( false )
67 bool operator==( const AnimationBitmap& rAnimBmp ) const
69 return( rAnimBmp.aBmpEx == aBmpEx &&
70 rAnimBmp.aPosPix == aPosPix &&
71 rAnimBmp.aSizePix == aSizePix &&
72 rAnimBmp.nWait == nWait &&
73 rAnimBmp.eDisposal == eDisposal &&
74 rAnimBmp.bUserInput == bUserInput );
77 bool operator!=( const AnimationBitmap& rAnimBmp ) const
78 { return !( *this == rAnimBmp ); }
81 BitmapChecksum GetChecksum() const;
84 class ImplAnimView;
86 class VCL_DLLPUBLIC Animation
88 public:
89 Animation();
90 Animation( const Animation& rAnimation );
91 ~Animation();
93 Animation& operator=( const Animation& rAnimation );
94 bool operator==( const Animation& rAnimation ) const;
95 bool operator!=( const Animation& rAnimation ) const
96 { return !(*this==rAnimation); }
98 void Clear();
100 bool Start(
101 OutputDevice* pOutDev,
102 const Point& rDestPt,
103 const Size& rDestSz,
104 long nExtraData,
105 OutputDevice* pFirstFrameOutDev);
107 void Stop( OutputDevice* pOutDev = nullptr, long nExtraData = 0 );
109 void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const;
110 void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const;
112 bool IsInAnimation() const { return mbIsInAnimation; }
113 bool IsTransparent() const;
115 const Size& GetDisplaySizePixel() const { return maGlobalSize; }
116 void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; }
118 const BitmapEx& GetBitmapEx() const { return maBitmapEx; }
119 void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; }
121 sal_uLong GetLoopCount() const { return mnLoopCount; }
122 void SetLoopCount( const sal_uLong nLoopCount );
123 void ResetLoopCount();
125 void SetNotifyHdl( const Link<Animation*,void>& rLink ) { maNotifyLink = rLink; }
126 const Link<Animation*,void>& GetNotifyHdl() const { return maNotifyLink; }
128 size_t Count() const { return maList.size(); }
129 bool Insert( const AnimationBitmap& rAnimationBitmap );
130 const AnimationBitmap&
131 Get( sal_uInt16 nAnimation ) const;
132 void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation );
134 sal_uLong GetSizeBytes() const;
135 BitmapChecksum GetChecksum() const;
137 public:
139 bool Convert( BmpConversion eConversion );
140 bool ReduceColors( sal_uInt16 nNewColorCount );
142 bool Invert();
143 bool Mirror( BmpMirrorFlags nMirrorFlags );
144 bool Adjust(
145 short nLuminancePercent,
146 short nContrastPercent,
147 short nChannelRPercent,
148 short nChannelGPercent,
149 short nChannelBPercent,
150 double fGamma = 1.0,
151 bool bInvert = false );
153 bool Filter(
154 BmpFilter eFilter,
155 const BmpFilterParam* pFilterParam = nullptr );
157 friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation );
158 friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation );
160 public:
162 SAL_DLLPRIVATE static void
163 ImplIncAnimCount() { mnAnimCount++; }
164 SAL_DLLPRIVATE static void
165 ImplDecAnimCount() { mnAnimCount--; }
166 SAL_DLLPRIVATE sal_uLong
167 ImplGetCurPos() const { return mnPos; }
169 private:
170 SAL_DLLPRIVATE static sal_uLong mnAnimCount;
172 std::vector< AnimationBitmap* > maList;
173 std::vector< ImplAnimView* > maViewList;
175 Link<Animation*,void> maNotifyLink;
176 BitmapEx maBitmapEx;
177 Timer maTimer;
178 Size maGlobalSize;
179 long mnLoopCount;
180 long mnLoops;
181 size_t mnPos;
182 bool mbIsInAnimation;
183 bool mbLoopTerminated;
185 SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout );
186 DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer*, void );
190 #endif // INCLUDED_VCL_ANIMATE_HXX
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */