LibreOffice Module vcl (master)  1
Animation.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_VCL_ANIMATE_ANIMATION_HXX
21 #define INCLUDED_VCL_ANIMATE_ANIMATION_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/timer.hxx>
26 
27 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
28 
29 class ImplAnimView;
30 
32 {
33 public:
34  Animation();
35  Animation(const Animation& rAnimation);
36  ~Animation();
37 
38  Animation& operator=(const Animation& rAnimation);
39  bool operator==(const Animation& rAnimation) const;
40  bool operator!=(const Animation& rAnimation) const { return !(*this == rAnimation); }
41 
42  void Clear();
43 
44  bool Start(OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz, long nExtraData,
45  OutputDevice* pFirstFrameOutDev);
46 
47  void Stop(OutputDevice* pOutDev = nullptr, long nExtraData = 0);
48 
49  void Draw(OutputDevice* pOutDev, const Point& rDestPt) const;
50  void Draw(OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz) const;
51 
52  bool IsInAnimation() const { return mbIsInAnimation; }
53  bool IsTransparent() const;
54 
55  const Size& GetDisplaySizePixel() const { return maGlobalSize; }
56  void SetDisplaySizePixel(const Size& rSize) { maGlobalSize = rSize; }
57 
58  const BitmapEx& GetBitmapEx() const { return maBitmapEx; }
59  void SetBitmapEx(const BitmapEx& rBmpEx) { maBitmapEx = rBmpEx; }
60 
61  sal_uInt32 GetLoopCount() const { return mnLoopCount; }
62  void SetLoopCount(const sal_uInt32 nLoopCount);
63  void ResetLoopCount();
64 
65  void SetNotifyHdl(const Link<Animation*, void>& rLink) { maNotifyLink = rLink; }
66  const Link<Animation*, void>& GetNotifyHdl() const { return maNotifyLink; }
67 
68  std::vector<std::unique_ptr<AnimationBitmap>>& GetAnimationFrames() { return maList; }
69  size_t Count() const { return maList.size(); }
70  bool Insert(const AnimationBitmap& rAnimationBitmap);
71  const AnimationBitmap& Get(sal_uInt16 nAnimation) const;
72  void Replace(const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation);
73 
74  sal_uLong GetSizeBytes() const;
75  BitmapChecksum GetChecksum() const;
76 
77 public:
78  void Convert(BmpConversion eConversion);
79  bool ReduceColors(sal_uInt16 nNewColorCount);
80 
81  bool Invert();
82  void Mirror(BmpMirrorFlags nMirrorFlags);
83  void Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent,
84  short nChannelGPercent, short nChannelBPercent, double fGamma = 1.0,
85  bool bInvert = false);
86 
87  friend SvStream& ReadAnimation(SvStream& rIStream, Animation& rAnimation);
88  friend SvStream& WriteAnimation(SvStream& rOStream, const Animation& rAnimation);
89 
90 public:
91  SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; }
92  SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; }
93  SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnPos; }
94 
95 private:
96  SAL_DLLPRIVATE static sal_uLong mnAnimCount;
97 
98  std::vector<std::unique_ptr<AnimationBitmap>> maList;
99  std::vector<std::unique_ptr<ImplAnimView>> maViewList;
100 
105  sal_uInt32 mnLoopCount;
106  sal_uInt32 mnLoops;
107  size_t mnPos;
110 
111  SAL_DLLPRIVATE void ImplRestartTimer(sal_uLong nTimeout);
112  DECL_DLLPRIVATE_LINK(ImplTimeoutHdl, Timer*, void);
113 };
114 
115 #endif // INCLUDED_VCL_ANIMATE_ANIMATION_HXX
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SAL_DLLPRIVATE void ImplDecAnimCount()
Definition: Animation.hxx:92
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
std::vector< std::unique_ptr< AnimationBitmap > > & GetAnimationFrames()
Definition: Animation.hxx:68
Link< Animation *, void > maNotifyLink
Definition: Animation.hxx:101
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uIntPtr sal_uLong
const BitmapEx & GetBitmapEx() const
Definition: Animation.hxx:58
SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const
Definition: Animation.hxx:93
sal_uInt32 mnLoopCount
Definition: Animation.hxx:105
void SetBitmapEx(const BitmapEx &rBmpEx)
Definition: Animation.hxx:59
SvStream & ReadAnimation(SvStream &rIStm, Animation &rAnimation)
Definition: Animation.cxx:616
const Link< Animation *, void > & GetNotifyHdl() const
Definition: Animation.hxx:66
Size maGlobalSize
Definition: Animation.hxx:104
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:203
static SAL_DLLPRIVATE void ImplIncAnimCount()
Definition: Animation.hxx:91
SvStream & WriteAnimation(SvStream &rOStm, const Animation &rAnimation)
Definition: Animation.cxx:570
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::vector< std::unique_ptr< AnimationBitmap > > maList
Definition: Animation.hxx:98
BmpMirrorFlags
Definition: bitmap.hxx:36
void SetNotifyHdl(const Link< Animation *, void > &rLink)
Definition: Animation.hxx:65
std::vector< std::unique_ptr< ImplAnimView > > maViewList
Definition: Animation.hxx:99
const Size & GetDisplaySizePixel() const
Definition: Animation.hxx:55
BmpConversion
Definition: bitmap.hxx:65
bool mbIsInAnimation
Definition: Animation.hxx:108
void SetDisplaySizePixel(const Size &rSize)
Definition: Animation.hxx:56
size_t mnPos
Definition: Animation.hxx:107
bool IsInAnimation() const
Definition: Animation.hxx:52
bool mbLoopTerminated
Definition: Animation.hxx:109
bool operator!=(const Animation &rAnimation) const
Definition: Animation.hxx:40
sal_uInt32 GetLoopCount() const
Definition: Animation.hxx:61
size_t Count() const
Definition: Animation.hxx:69
SVX_DLLPUBLIC MSO_SPT Get(const OUString &)
aCursorMoveIdle Stop()
Definition: timer.hxx:26
sal_uInt32 mnLoops
Definition: Animation.hxx:106
BitmapEx maBitmapEx
Definition: Animation.hxx:102
Timer maTimer
Definition: Animation.hxx:103
static SAL_DLLPRIVATE sal_uLong mnAnimCount
Definition: Animation.hxx:96