File indexing completed on 2024-05-12 05:28:38
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "breezeanimationdata.h" 0010 0011 #include <QTabBar> 0012 0013 namespace Breeze 0014 { 0015 //* tabbars 0016 class TabBarData : public AnimationData 0017 { 0018 Q_OBJECT 0019 0020 //* declare opacity property 0021 Q_PROPERTY(qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity) 0022 Q_PROPERTY(qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity) 0023 0024 public: 0025 //* constructor 0026 TabBarData(QObject *parent, QObject *target, int duration); 0027 0028 //* duration 0029 void setDuration(int duration) override 0030 { 0031 currentIndexAnimation().data()->setDuration(duration); 0032 previousIndexAnimation().data()->setDuration(duration); 0033 } 0034 0035 //* update state 0036 bool updateState(const QPoint &, bool); 0037 0038 //*@name current index handling 0039 //@{ 0040 0041 //* current opacity 0042 qreal currentOpacity() const 0043 { 0044 return _current._opacity; 0045 } 0046 0047 //* current opacity 0048 void setCurrentOpacity(qreal value) 0049 { 0050 if (_current._opacity == value) { 0051 return; 0052 } 0053 _current._opacity = value; 0054 setDirty(); 0055 } 0056 0057 //* current index 0058 int currentIndex() const 0059 { 0060 return _current._index; 0061 } 0062 0063 //* current index 0064 void setCurrentIndex(int index) 0065 { 0066 _current._index = index; 0067 } 0068 0069 //* current index animation 0070 const Animation::Pointer ¤tIndexAnimation() const 0071 { 0072 return _current._animation; 0073 } 0074 0075 //@} 0076 0077 //*@name previous index handling 0078 //@{ 0079 0080 //* previous opacity 0081 qreal previousOpacity() const 0082 { 0083 return _previous._opacity; 0084 } 0085 0086 //* previous opacity 0087 void setPreviousOpacity(qreal value) 0088 { 0089 if (_previous._opacity == value) { 0090 return; 0091 } 0092 _previous._opacity = value; 0093 setDirty(); 0094 } 0095 0096 //* previous index 0097 int previousIndex() const 0098 { 0099 return _previous._index; 0100 } 0101 0102 //* previous index 0103 void setPreviousIndex(int index) 0104 { 0105 _previous._index = index; 0106 } 0107 0108 //* previous index Animation 0109 const Animation::Pointer &previousIndexAnimation() const 0110 { 0111 return _previous._animation; 0112 } 0113 0114 //@} 0115 0116 //* return Animation associated to action at given position, if any 0117 Animation::Pointer animation(const QPoint &position) const; 0118 0119 //* return opacity associated to action at given position, if any 0120 qreal opacity(const QPoint &position) const; 0121 0122 private: 0123 //* container for needed animation data 0124 class Data 0125 { 0126 public: 0127 //* default constructor 0128 Data() 0129 : _opacity(0) 0130 , _index(-1) 0131 { 0132 } 0133 0134 Animation::Pointer _animation; 0135 qreal _opacity; 0136 int _index; 0137 }; 0138 0139 //* current tab animation data (for hover enter animations) 0140 Data _current; 0141 0142 //* previous tab animations data (for hover leave animations) 0143 Data _previous; 0144 }; 0145 0146 }