Rubberband.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Rubberband.h - rubberband - either own implementation for Qt3 or wrapper for
  3. * Qt4
  4. *
  5. * Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef RUBBERBAND_H
  26. #define RUBBERBAND_H
  27. #include <QRubberBand>
  28. #include <QtCore/QVector>
  29. class selectableObject : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. selectableObject( QWidget * _parent ) :
  34. QWidget( _parent ),
  35. m_selected( false )
  36. {
  37. }
  38. virtual ~selectableObject()
  39. {
  40. }
  41. inline void setSelected(bool selected)
  42. {
  43. if (m_selected == selected) { return; }
  44. m_selected = selected;
  45. update();
  46. }
  47. inline bool isSelected() const
  48. {
  49. return( m_selected );
  50. }
  51. public slots:
  52. virtual void update()
  53. {
  54. QWidget::update();
  55. }
  56. private:
  57. bool m_selected;
  58. } ;
  59. class RubberBand : public QRubberBand
  60. {
  61. public:
  62. RubberBand( QWidget * _parent );
  63. virtual ~RubberBand();
  64. QVector<selectableObject *> selectedObjects() const;
  65. QVector<selectableObject *> selectableObjects() const;
  66. protected:
  67. void resizeEvent( QResizeEvent * _re ) override;
  68. private:
  69. };
  70. #endif