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