1
#ifndef oxygenclientgroupitemdata_h
2
#define oxygenclientgroupitemdata_h
4
//////////////////////////////////////////////////////////////////////////////
5
// oxygenclientgroupitemdata.h
6
// handles tabs' geometry and animations
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
12
// of this software and associated documentation files (the "Software"), to
13
// deal in the Software without restriction, including without limitation the
14
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15
// sell copies of the Software, and to permit persons to whom the Software is
16
// furnished to do so, subject to the following conditions:
18
// The above copyright notice and this permission notice shall be included in
19
// all copies or substantial portions of the Software.
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
//////////////////////////////////////////////////////////////////////////////
30
#include "oxygenbutton.h"
31
#include "oxygenanimation.h"
33
#include <QtCore/QList>
34
#include <QtCore/QWeakPointer>
35
#include <QtCore/QRect>
45
AnimationEnter = 1<<0,
47
AnimationLeave = 1<<2,
48
AnimationSameTarget = 1<<3
51
Q_DECLARE_FLAGS(AnimationTypes, AnimationType)
54
class ClientGroupItemData
60
explicit ClientGroupItemData( void )
64
virtual ~ClientGroupItemData( void )
67
//! reset all rects to argument
68
void reset( const QRect& rect )
70
_refBoundingRect = rect;
71
_startBoundingRect = rect;
72
_endBoundingRect = rect;
79
//! reference bounding rect
80
/*! it is usually identical to activeRect unless there is only one tab in window */
81
QRect _refBoundingRect;
84
QRect _startBoundingRect;
87
QRect _endBoundingRect;
93
typedef QWeakPointer<Button> ButtonPointer;
94
ButtonPointer _closeButton;
98
class ClientGroupItemDataList: public QObject, public QList<ClientGroupItemData>
103
//! declare animation progress property
104
Q_PROPERTY( qreal progress READ progress WRITE setProgress )
108
//! invalid item index
109
enum { NoItem = -1 };
112
ClientGroupItemDataList( Client* parent );
115
void setDirty( const bool& value )
119
bool isDirty( void ) const
122
//! enable animations
123
void setAnimationsEnabled( bool value )
124
{ animationsEnabled_ = value; }
126
//! animations enabled
127
bool animationsEnabled( void ) const
128
{ return animationsEnabled_; }
130
//! true if being animated
131
bool isAnimated( void ) const
132
{ return animationType_ != AnimationNone; }
135
AnimationTypes animationType( void ) const
136
{ return animationType_; }
138
//! return item index matching QPoint, or -1 if none
139
int itemAt( const QPoint&, bool ) const;
141
//! returns true if index is target
142
bool isTarget( int index ) const
143
{ return index == targetItem_; }
146
/* might need to add the side of the target here */
147
void animate( AnimationTypes, int = NoItem );
149
//! true if animation is in progress
150
bool isAnimationRunning( void ) const
151
{ return animation().data()->isRunning(); }
153
//! update button activity
154
void updateButtonActivity( int visibleItem ) const;
157
void updateButtons( bool alsoUpdate ) const;
160
const QRect& targetRect( void ) const
161
{ return targetRect_; }
163
//!@name animation progress
166
//! return animation object
167
virtual const Animation::Pointer& animation() const
168
{ return _animation; }
170
void setProgress( qreal value )
172
if( progress_ == value ) return;
174
updateBoundingRects();
177
qreal progress( void ) const
178
{ return progress_; }
184
//! update bounding rects
185
void updateBoundingRects( bool alsoUpdate = true );
193
/* used to trigger update at next paintEvent */
196
//! true if animations are enabled
197
bool animationsEnabled_;
200
Animation::Pointer _animation;
202
//! last animation type
203
AnimationTypes animationType_;
205
//! animation progress
219
Q_DECLARE_OPERATORS_FOR_FLAGS(Oxygen::AnimationTypes)