aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Ui/qsui/popupwidget.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2020-02-20 21:50:33 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2020-02-20 21:50:33 +0000
commit94d94622cb6067a073833b1e4afe306878a1e584 (patch)
tree75bf0054435ea459eff42a40bdff3007295c44de /src/plugins/Ui/qsui/popupwidget.cpp
parentde257043fd559afee78e954ac43d746c3bc4dd94 (diff)
downloadqmmp-94d94622cb6067a073833b1e4afe306878a1e584.tar.gz
qmmp-94d94622cb6067a073833b1e4afe306878a1e584.tar.bz2
qmmp-94d94622cb6067a073833b1e4afe306878a1e584.zip
fixed Qt 5.15 warnings
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9238 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Ui/qsui/popupwidget.cpp')
0 files changed, 0 insertions, 0 deletions
-0410-971d-27865f9a5e38> 2015-12-26 10:26:11 +0000 changed visual api, disabled broken plugins' href='/qmmp/commit/src/plugins/Ui/skinned/shadedvisual.cpp?id=c3b05ebdc87be03e1cce5ccc5aa9398db3054f53'>c3b05ebdc
ecc137abe
2702b572b


5e26d3a30


c3b05ebdc

c4749f20a
5e26d3a30




5e26d3a30
c4749f20a



5e26d3a30
c3b05ebdc
5e26d3a30


5e26d3a30
c4749f20a
5e26d3a30
c4749f20a
c3b05ebdc

c4749f20a
5e26d3a30
c4749f20a
c3b05ebdc
5e26d3a30
c3b05ebdc

c4749f20a
5e26d3a30



c4749f20a
5e26d3a30



2702b572b
5e26d3a30


5e26d3a30

3ffc8b54a
c4749f20a
5e26d3a30
c4749f20a

5e26d3a30

c4749f20a

c3b05ebdc

5e26d3a30

c4749f20a
5e26d3a30


c3b05ebdc
5e26d3a30
c4749f20a
5e26d3a30







10923b3e9
c4749f20a
10923b3e9
c3b05ebdc
10923b3e9




c4749f20a
10923b3e9
c3b05ebdc
10923b3e9



5e26d3a30

c3b05ebdc
5e26d3a30
c3b05ebdc
5e26d3a30



10923b3e9
5e26d3a30
2702b572b
5e26d3a30
10923b3e9
5e26d3a30
2702b572b
5e26d3a30




















2702b572b


5e26d3a30

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
165
166
167
168
169
170
171
172
                                                                            
                                                                            














                                                                            
                                                                            






                                                                             

                         


                                               
                                                            
 
                              


                                              


                                                                     

                                                   
                    




                             
                             



                             
 
                                                             


                              
 
                                         
     
                                        

                                                                                                
               
     
 
                                                                           
 

                                                                                 
                          



                          
                    



                                          
 


                            

                                          
                     
                                      
     

                           

     

                                            

                                                                                            

                          
                       


             
                                                      
 
                                          







                                
 
                 
         
                                            




                             
                  
         
                                             



                             

               
                               
               
                               



                                     
                                 
     
                                                                                               
     
                                 
     
                                                                                                       




















                                             


                                              

            
/***************************************************************************
 *   Copyright (C) 2007-2015 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <QTimer>
#include <math.h>
#include "skin.h"
#include "mainvisual.h"
#include "inlines.h"
#include "shadedvisual.h"

#define VISUAL_NODE_SIZE 512 //samples
#define VISUAL_BUFFER_SIZE (5*VISUAL_NODE_SIZE)

ShadedVisual::ShadedVisual(QWidget *parent) : Visual(parent)
{
    m_skin = Skin::instance();
    m_ratio = m_skin->ratio();
    resize(m_ratio*38,m_ratio*5);
    m_pixmap = QPixmap (m_ratio*38,m_ratio*5);
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL (timeout()), this, SLOT (timeout()));
    connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSkin()));
    m_left_buffer = new float[VISUAL_BUFFER_SIZE];
    m_right_buffer = new float[VISUAL_BUFFER_SIZE];
    m_buffer_at = 0;
    m_timer->setInterval(50);
    m_timer->start();
    clear();
}

ShadedVisual::~ShadedVisual()
{
    delete [] m_left_buffer;
    delete [] m_right_buffer;
}

void ShadedVisual::add(float *data, size_t samples, int chan)
{
    if (!m_timer->isActive ())
        return;

    if(VISUAL_BUFFER_SIZE == m_buffer_at)
    {
        m_buffer_at -= VISUAL_NODE_SIZE;
        memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float));
        memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float));
        return;
    }

    int frames = qMin(int(samples/chan), VISUAL_BUFFER_SIZE - m_buffer_at);

    stereo16_from_multichannel(m_left_buffer + m_buffer_at,
                               m_right_buffer + m_buffer_at, data, frames, chan);
    m_buffer_at += frames;
}

void ShadedVisual::clear()
{
    m_buffer_at = 0;
    m_l = 0;
    m_r = 0;
    m_pixmap.fill(m_skin->getVisColor(0));
    update();
}

void ShadedVisual::timeout()
{
    m_pixmap.fill(m_skin->getVisColor(0));

    mutex()->lock ();
    if(m_buffer_at < VISUAL_NODE_SIZE)
    {
        mutex()->unlock ();
        return;
    }

    process (m_left_buffer, m_right_buffer);
    m_buffer_at -= VISUAL_NODE_SIZE;
    memmove(m_left_buffer, m_left_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float));
    memmove(m_right_buffer, m_right_buffer + VISUAL_NODE_SIZE, m_buffer_at * sizeof(float));
    QPainter p(&m_pixmap);
    draw (&p);
    mutex()->unlock ();
    update();
}

void ShadedVisual::process (float *left, float *right)
{
    int step = (VISUAL_NODE_SIZE << 8)/74;
    int pos = 0;
    int l = 0;
    int r = 0;
    int j_l = 0, j_r = 0;

    for (int i = 0; i < 75; ++i)
    {
        pos += step;

        if (left)
        {
            j_l = abs(left[pos >> 8] * 8.0);

            if (j_l > 15)
                j_l = 15;
            l = qMax(l, j_l);
        }
        if (right)
        {
            j_r = abs(right[pos >> 8] * 8.0);
            if (j_r > 15)
                j_r = 15;
            r = qMax(r, j_r);
        }
    }
    m_l -= 0.5;
    m_l = qMax(m_l, (double)l);
    m_r -= 0.5;
    m_r = qMax(m_r, (double)r);
}

void ShadedVisual::draw (QPainter *p)
{
    for (int i = 0; i < m_l; ++i)
    {
        p->fillRect (i*3*m_ratio, 0, 3*m_ratio, 2*m_ratio, QBrush(m_skin->getVisColor (17-i)));
    }
    for (int i = 0; i < m_r; ++i)
    {
        p->fillRect (i*3*m_ratio, 3*m_ratio, 3*m_ratio, 2*m_ratio, QBrush(m_skin->getVisColor (17-i)));
    }
}

void ShadedVisual::paintEvent (QPaintEvent *)
{
    QPainter painter (this);
    painter.drawPixmap (0,0,m_pixmap);
}

void ShadedVisual::hideEvent (QHideEvent *)
{
    m_timer->stop();
}

void ShadedVisual::showEvent (QShowEvent *)
{
    m_timer->start();
}

void ShadedVisual::updateSkin()
{
    m_ratio = m_skin->ratio();
    resize(m_ratio*38,m_ratio*5);
    m_pixmap = QPixmap (m_ratio*38,m_ratio*5);
    clear();
}