File indexing completed on 2024-12-22 04:40:20

0001 /*
0002     smplayer, GUI front-end for mplayer
0003     SPDX-FileCopyrightText: 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
0004 
0005     modified for inclusion in Subtitle Composer
0006     SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef ATTACHABLEWIDGET_H
0012 #define ATTACHABLEWIDGET_H
0013 
0014 #include <QWidget>
0015 
0016 class AttachableWidget : public QWidget
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     typedef enum { Top, Bottom } Place;
0022 
0023     explicit AttachableWidget(Place place = Bottom, unsigned animStepDuration = 4);
0024     virtual ~AttachableWidget();
0025 
0026     bool isAttached() const;
0027 
0028     bool isAnimated() const;
0029     int animStepDuration() const;
0030 
0031     bool eventFilter(QObject *object, QEvent *event) override;
0032 
0033 public slots:
0034     void attach(QWidget *target);
0035     void dettach();
0036 
0037     void setAnimStepDuration(int stepDuration);
0038 
0039     void toggleVisible(bool visible);
0040 
0041 protected:
0042     void timerEvent(QTimerEvent *event) override;
0043 
0044 private:
0045     void toggleVisible(bool visible, bool force);
0046 
0047 private:
0048     QWidget *m_targetWidget;
0049     Place m_place;
0050     int m_animStepDuration;
0051 
0052     typedef enum { Upward, Downward } Direction;
0053 
0054     int m_animTID;
0055     bool m_animHiding;
0056     int m_animFinalY;
0057     int m_animCurrentY;
0058     Direction m_animDirection;
0059 };
0060 
0061 #endif