File indexing completed on 2024-05-19 05:35:20
0001 #ifndef oxygenmdiwindow_data_h 0002 #define oxygenmdiwindow_data_h 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // oxygenmdiwindowdata.h 0006 // mdi window data container for window titlebar buttons 0007 // ------------------- 0008 // 0009 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0010 // 0011 // SPDX-License-Identifier: MIT 0012 ////////////////////////////////////////////////////////////////////////////// 0013 0014 #include "oxygenanimationdata.h" 0015 0016 #include <QStyle> 0017 0018 namespace Oxygen 0019 { 0020 //* handles mdiwindow arrows hover 0021 class MdiWindowData : public AnimationData 0022 { 0023 Q_OBJECT 0024 0025 //* declare opacity property 0026 Q_PROPERTY(qreal currentOpacity READ currentOpacity WRITE setCurrentOpacity) 0027 Q_PROPERTY(qreal previousOpacity READ previousOpacity WRITE setPreviousOpacity) 0028 0029 public: 0030 //* constructor 0031 MdiWindowData(QObject *, QWidget *, int); 0032 0033 //* animation state 0034 bool updateState(int primitive, bool value); 0035 0036 //* animation state 0037 bool isAnimated(int primitive) const 0038 { 0039 return ((primitive == _currentData._primitive && currentAnimation().data()->isRunning()) 0040 || (primitive == _previousData._primitive && previousAnimation().data()->isRunning())); 0041 } 0042 0043 //* opacity 0044 qreal opacity(int primitive) const 0045 { 0046 if (primitive == _currentData._primitive) 0047 return currentOpacity(); 0048 else if (primitive == _previousData._primitive) 0049 return previousOpacity(); 0050 else 0051 return OpacityInvalid; 0052 } 0053 0054 //* duration 0055 void setDuration(int duration) override 0056 { 0057 currentAnimation().data()->setDuration(duration); 0058 previousAnimation().data()->setDuration(duration); 0059 } 0060 0061 //*@name current animation 0062 //@{ 0063 0064 //* opacity 0065 qreal currentOpacity(void) const 0066 { 0067 return _currentData._opacity; 0068 } 0069 0070 //* opacity 0071 void setCurrentOpacity(qreal value) 0072 { 0073 value = digitize(value); 0074 if (_currentData._opacity == value) 0075 return; 0076 _currentData._opacity = value; 0077 setDirty(); 0078 } 0079 0080 //* animation 0081 Animation::Pointer currentAnimation(void) const 0082 { 0083 return _currentData._animation; 0084 } 0085 0086 //@} 0087 //*@name previous animation 0088 //@{ 0089 0090 //* opacity 0091 qreal previousOpacity(void) const 0092 { 0093 return _previousData._opacity; 0094 } 0095 0096 //* opacity 0097 void setPreviousOpacity(qreal value) 0098 { 0099 value = digitize(value); 0100 if (_previousData._opacity == value) 0101 return; 0102 _previousData._opacity = value; 0103 setDirty(); 0104 } 0105 0106 //* animation 0107 Animation::Pointer previousAnimation(void) const 0108 { 0109 return _previousData._animation; 0110 } 0111 0112 //@} 0113 0114 private: 0115 //* container for needed animation data 0116 class Data 0117 { 0118 public: 0119 //* default constructor 0120 Data() = default; 0121 0122 //* subcontrol 0123 bool updateSubControl(int); 0124 0125 //* subcontrol 0126 int _primitive = 0; 0127 0128 //* animation 0129 Animation::Pointer _animation; 0130 0131 //* opacity 0132 qreal _opacity = 0; 0133 }; 0134 0135 //* current data 0136 Data _currentData; 0137 0138 //* previous data 0139 Data _previousData; 0140 }; 0141 } 0142 0143 #endif