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