summaryrefslogtreecommitdiffstats
path: root/amarok/src/sliderwidget.h
blob: 8965688513740d25fc20f5024b816e2b11e110b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/***************************************************************************
                       amarokslider.h  -  description
                          -------------------
 begin                : Dec 15 2003
 copyright            : (C) 2003 by Mark Kretschmann
 email                : [email protected]
 copyright            : (C) 2005 by Gábor Lehel
 email                : [email protected]
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef AMAROKSLIDER_H
#define AMAROKSLIDER_H

#include <config.h>
#include "metabundle.h"

#include <kpixmap.h>
#include <kurl.h>

#include <tqpixmap.h>
#include <tqslider.h>
#include <tqvaluevector.h>

class TQPalette;
class TQTimer;

namespace Amarok
{
    class Slider : public TQSlider
    {
        TQ_OBJECT
  

        public:
            Slider( Qt::Orientation, TQWidget*, uint max = 0 );

            virtual void setValue( int );

            //WARNING non-virtual - and thus only really intended for internal use
            //this is a major flaw in the class presently, however it suits our
            //current needs fine
            int value() const { return adjustValue( TQSlider::value() ); }

        signals:
            //we emit this when the user has specifically changed the slider
            //so connect to it if valueChanged() is too generic
            //TQt also emits valueChanged( int )
            void sliderReleased( int );

        protected:
            virtual void wheelEvent( TQWheelEvent* );
            virtual void mouseMoveEvent( TQMouseEvent* );
            virtual void mouseReleaseEvent( TQMouseEvent* );
            virtual void mousePressEvent( TQMouseEvent* );
            virtual void slideEvent( TQMouseEvent* );

            bool m_sliding;

            /// we flip the value for vertical sliders
            int adjustValue( int v ) const
            {
               int mp = (minValue() + maxValue()) / 2;
               return orientation() == Qt::Vertical ? mp - (v - mp) : v;
            }

        private:
            bool m_outside;
            int  m_prevValue;

            Slider( const Slider& ); //undefined
            Slider &operator=( const Slider& ); //undefined
    };


    class PrettySlider : public Slider
    {
        TQ_OBJECT
  

        public:
            typedef enum
            {
                Normal,  // Same behavior as Slider *unless* there's a moodbar
                Pretty
            } SliderMode;

            PrettySlider( Qt::Orientation orientation, SliderMode mode,
                          TQWidget *parent, uint max = 0 );

            virtual void newBundle( const MetaBundle &bundle );

        protected:
            virtual void paintEvent( TQPaintEvent *e );
            virtual void slideEvent( TQMouseEvent* );
            virtual void mousePressEvent( TQMouseEvent* );

        protected slots:
            void moodbarJobEvent( int newState );
            void slotMoodbarPrefs( bool show, bool moodier, int alter, bool withMusic );

        private:
            PrettySlider( const PrettySlider& ); //undefined
            PrettySlider &operator=( const PrettySlider& ); //undefined

            SliderMode m_mode;
            MetaBundle m_bundle;  // Has our moodbar data!
            bool       m_showingMoodbar;
    };

    class VolumeSlider: public Slider
    {
        TQ_OBJECT
  

        public:
            VolumeSlider( TQWidget *parent, uint max = 0 );

        protected:
            virtual void paintEvent( TQPaintEvent* );
            virtual void hideEvent( TQHideEvent* );
            virtual void showEvent( TQShowEvent* );
            virtual void enterEvent( TQEvent* );
            virtual void leaveEvent( TQEvent* );
            virtual void paletteChange( const TQPalette& );
            virtual void slideEvent( TQMouseEvent* );
            virtual void mousePressEvent( TQMouseEvent* );
            virtual void contextMenuEvent( TQContextMenuEvent* );
            virtual void wheelEvent( TQWheelEvent *e );

        private slots:
            virtual void slotAnimTimer();

        private:
            void generateGradient();

            VolumeSlider( const VolumeSlider& ); //undefined
            VolumeSlider &operator=( const VolumeSlider& ); //undefined

            ////////////////////////////////////////////////////////////////
            static const int ANIM_INTERVAL = 18;
            static const int ANIM_MAX = 18;

            bool    m_animEnter;
            int     m_animCount;
            TQTimer* m_animTimer;

            TQPixmap m_pixmapInset;
            KPixmap m_pixmapGradient;

            TQValueVector<TQPixmap> m_handlePixmaps;
    };

}

#endif