qt-material-widgets/components/qtmaterialtabs_internal.h

92 lines
1.6 KiB
C
Raw Normal View History

2017-09-29 17:25:42 +00:00
#ifndef QTMATERIALTABS_INTERNAL_H
#define QTMATERIALTABS_INTERNAL_H
#include "lib/qtmaterialoverlaywidget.h"
#include "qtmaterialflatbutton.h"
2022-02-17 03:03:49 +00:00
namespace md
{
2017-09-29 17:25:42 +00:00
class QPropertyAnimation;
2022-02-17 03:03:49 +00:00
class Tabs;
2017-09-29 17:25:42 +00:00
2022-02-17 03:03:49 +00:00
class TabsInkBar : public OverlayWidget
2017-09-29 17:25:42 +00:00
{
Q_OBJECT
Q_PROPERTY(qreal tweenValue WRITE setTweenValue READ tweenValue)
public:
2022-02-17 03:03:49 +00:00
TabsInkBar(Tabs *parent);
~TabsInkBar();
2017-09-29 17:25:42 +00:00
inline void setTweenValue(qreal value);
inline qreal tweenValue() const;
void refreshGeometry();
void animate();
protected:
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
2022-02-17 03:03:49 +00:00
Q_DISABLE_COPY(TabsInkBar)
2017-09-29 17:25:42 +00:00
2022-02-17 03:03:49 +00:00
Tabs *const m_tabs;
2017-09-29 17:25:42 +00:00
QPropertyAnimation *const m_animation;
QRect m_geometry;
QRect m_previousGeometry;
qreal m_tween;
};
2022-02-17 03:03:49 +00:00
inline void TabsInkBar::setTweenValue(qreal value)
2017-09-29 17:25:42 +00:00
{
m_tween = value;
refreshGeometry();
}
2022-02-17 03:03:49 +00:00
inline qreal TabsInkBar::tweenValue() const
2017-09-29 17:25:42 +00:00
{
return m_tween;
}
2022-02-17 03:03:49 +00:00
class Tab : public FlatButton
2017-09-29 17:25:42 +00:00
{
Q_OBJECT
public:
2022-02-17 03:03:49 +00:00
explicit Tab(Tabs *parent);
~Tab();
2017-09-29 17:25:42 +00:00
inline void setActive(bool state);
inline bool isActive() const;
QSize sizeHint() const Q_DECL_OVERRIDE;
protected slots:
void activateTab();
protected:
void paintForeground(QPainter *painter) Q_DECL_OVERRIDE;
private:
2022-02-17 03:03:49 +00:00
Q_DISABLE_COPY(Tab)
2017-09-29 17:25:42 +00:00
2022-02-17 03:03:49 +00:00
Tabs *const m_tabs;
2017-09-29 17:25:42 +00:00
bool m_active;
};
2022-02-17 03:03:49 +00:00
inline void Tab::setActive(bool state)
2017-09-29 17:25:42 +00:00
{
m_active = state;
update();
}
2022-02-17 03:03:49 +00:00
inline bool Tab::isActive() const
2017-09-29 17:25:42 +00:00
{
return m_active;
}
2022-02-17 03:03:49 +00:00
}
2017-09-29 17:25:42 +00:00
#endif // QTMATERIALTABS_INTERNAL_H