~ubuntu-branches/ubuntu/vivid/aeolus/vivid

« back to all changes in this revision

Viewing changes to audiowin.cc

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-04-19 19:12:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100419191251-hgarjfcdfl7c0ryl
Tags: 0.8.4-3
debian/patches/01-makefile.patch: Drop -march=native flag, it isn't valid
for Debian packages as the results are unpredictable, thanks to
Bastian Blank for reporting this (Closes: #578278).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (C) 2003-2008 Fons Adriaensen <fons@kokkinizita.net>
3
 
    
4
 
    This program is free software; you can redistribute it and/or modify
5
 
    it under the terms of the GNU General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or
7
 
    (at your option) any later version.
8
 
 
9
 
    This program is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
    GNU General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU General Public License
15
 
    along with this program; if not, write to the Free Software
16
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
 
*/
18
 
 
19
 
#include <math.h>
20
 
#include "audiowin.h"
21
 
#include "callbacks.h"
22
 
#include "styles.h"
23
 
 
24
 
 
25
 
Audiowin::Audiowin (X_window *parent, X_callback *callb, int xp, int yp, X_resman *xresm) :
26
 
    X_window (parent, xp, yp, 200, 100, Colors.main_bg),
27
 
    _callb (callb),
28
 
    _xresm (xresm),
29
 
    _xp (xp),
30
 
    _yp (yp)
31
 
{
32
 
    _atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
33
 
    XSetWMProtocols (dpy (), win (), &_atom, 1);
34
 
    _atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
35
 
}
36
 
 
37
 
 
38
 
Audiowin::~Audiowin (void)
39
 
{
40
 
}
41
 
 
42
 
 
43
 
void Audiowin::handle_event (XEvent *E)
44
 
{
45
 
    switch (E->type)
46
 
    {
47
 
    case ClientMessage:
48
 
        handle_xmesg ((XClientMessageEvent *) E);
49
 
        break;
50
 
    }
51
 
}
52
 
 
53
 
 
54
 
void Audiowin::handle_xmesg (XClientMessageEvent *E)
55
 
{
56
 
    if (E->message_type == _atom) x_unmap ();
57
 
}
58
 
 
59
 
 
60
 
void Audiowin::handle_callb (int k, X_window *W, XEvent *E)
61
 
{
62
 
    int c;
63
 
 
64
 
    switch (k)
65
 
    {
66
 
        case SLIDER | X_slider::MOVE: 
67
 
        case SLIDER | X_slider::STOP: 
68
 
        {
69
 
            X_slider *X = (X_slider *) W;
70
 
            c = X->cbid ();
71
 
            _asect = (c >> ASECT_BIT0) - 1;
72
 
            _parid = c & ASECT_MASK;
73
 
            _value = X->get_val (); 
74
 
            _final = k == (X_callback::SLIDER | X_slider::STOP);
75
 
            _callb->handle_callb (CB_AUDIO_ACT, this, E);
76
 
            break; 
77
 
        }
78
 
    }
79
 
}
80
 
 
81
 
 
82
 
void Audiowin::setup (M_ifc_init *M)
83
 
{
84
 
    int      i, j, k, x;
85
 
    char     s [256];
86
 
    Asect    *S; 
87
 
    X_hints  H;
88
 
    
89
 
    but1.size.x = 20;
90
 
    but1.size.y = 20;
91
 
    _nasect = M->_nasect;
92
 
    for (i = 0; i < _nasect; i++)
93
 
    {
94
 
        S = _asectd + i;
95
 
        x = XOFFS + XSTEP * i;
96
 
        k = ASECT_STEP * (i + 1);
97
 
 
98
 
        (S->_slid [0] = new  X_hslider (this, this, &sli1, &sca_azim, x,  40, 20, k + 0))->x_map ();
99
 
        (S->_slid [1] = new  X_hslider (this, this, &sli1, &sca_difg, x,  75, 20, k + 1))->x_map ();
100
 
        (S->_slid [2] = new  X_hslider (this, this, &sli1, &sca_dBsh, x, 110, 20, k + 2))->x_map ();
101
 
        (S->_slid [3] = new  X_hslider (this, this, &sli1, &sca_dBsh, x, 145, 20, k + 3))->x_map ();
102
 
        (S->_slid [4] = new  X_hslider (this, this, &sli1, &sca_dBsh, x, 180, 20, k + 4))->x_map ();
103
 
        (new X_hscale (this, &sca_azim, x,  30, 10))->x_map ();
104
 
        (new X_hscale (this, &sca_difg, x,  65, 10))->x_map ();
105
 
        (new X_hscale (this, &sca_dBsh, x, 133, 10))->x_map ();
106
 
        (new X_hscale (this, &sca_dBsh, x, 168, 10))->x_map ();
107
 
        S->_label [0] = 0;
108
 
        for (j = 0; j <  M->_ndivis; j++)
109
 
        {
110
 
            if (M->_divisd [j]._asect == i)
111
 
            {
112
 
                if (S->_label [0]) strcat (S->_label, " + ");
113
 
                strcat (S->_label, M->_divisd [j]._label);
114
 
                add_text (x, 5, 200, 20, S->_label, &text0);
115
 
            } 
116
 
        }
117
 
    }
118
 
    add_text ( 10,  40, 60, 20, "Azimuth", &text0);
119
 
    add_text ( 10,  75, 60, 20, "Width",   &text0);
120
 
    add_text ( 10, 110, 60, 20, "Direct ", &text0);
121
 
    add_text ( 10, 145, 60, 20, "Reflect", &text0);
122
 
    add_text ( 10, 180, 60, 20, "Reverb",  &text0);
123
 
 
124
 
    (_slid [0] = new  X_hslider (this, this, &sli1, &sca_dBsh, 520, 275, 20, 0))->x_map ();
125
 
    (_slid [1] = new  X_hslider (this, this, &sli1, &sca_size,  70, 240, 20, 1))->x_map ();
126
 
    (_slid [2] = new  X_hslider (this, this, &sli1, &sca_trev,  70, 275, 20, 2))->x_map ();
127
 
    (_slid [3] = new  X_hslider (this, this, &sli1, &sca_spos, 305, 275, 20, 3))->x_map ();
128
 
    (new X_hscale (this, &sca_size,  70, 230, 10))->x_map ();
129
 
    (new X_hscale (this, &sca_trev,  70, 265, 10))->x_map ();
130
 
    (new X_hscale (this, &sca_spos, 305, 265, 10))->x_map ();
131
 
    (new X_hscale (this, &sca_dBsh, 520, 265, 10))->x_map ();
132
 
    add_text ( 10, 240, 50, 20, "Delay",    &text0);
133
 
    add_text ( 10, 275, 50, 20, "Time",     &text0);
134
 
    add_text (135, 305, 60, 20, "Reverb",   &text0);
135
 
    add_text (355, 305, 80, 20, "Position", &text0);
136
 
    add_text (570, 305, 60, 20, "Volume",   &text0);
137
 
 
138
 
    sprintf (s, "%s   Aeolus-%s   Audio settings", M->_appid, VERSION);
139
 
    x_set_title (s);
140
 
 
141
 
    H.position (_xp, _yp);
142
 
    H.minsize (200, 100);
143
 
    H.maxsize (XOFFS + _nasect * XSTEP, YSIZE);
144
 
    H.rname (_xresm->rname ());
145
 
    H.rclas (_xresm->rclas ());
146
 
    x_apply (&H); 
147
 
    x_resize (XOFFS + _nasect * XSTEP, YSIZE);
148
 
}
149
 
 
150
 
 
151
 
void Audiowin::set_aupar (M_ifc_aupar *M)
152
 
{
153
 
    if (M->_asect < 0)
154
 
    {
155
 
        if ((M->_parid >= 0) && (M->_parid < 4))
156
 
        {
157
 
            _slid [M->_parid]->set_val (M->_value);
158
 
        }
159
 
    }
160
 
    else if (M->_asect < _nasect)
161
 
    {
162
 
        if ((M->_parid >= 0) && (M->_parid < 5))
163
 
        {
164
 
            _asectd [M->_asect]._slid [M->_parid]->set_val (M->_value);
165
 
        }
166
 
    }
167
 
}
168
 
 
169
 
 
170
 
void Audiowin::add_text (int xp, int yp, int xs, int ys, const char *text, X_textln_style *style)
171
 
{
172
 
    (new X_textln (this, style, xp, yp, xs, ys, text, -1))->x_map ();
173
 
}