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
|
// ----------------------------------------------------------------------------
//
// Copyright (C) 2010-2023 Fons Adriaensen <fons@linuxaudio.org>
//
// 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, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "styles.h"
#include "global.h"
#include "mainwin.h"
Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient) :
A_thread ("Main"),
X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel),
_stop (false),
_xres (xres),
_jclient (jclient)
{
X_hints H;
char s [1024];
_atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
XSetWMProtocols (dpy (), win (), &_atom, 1);
_atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
sprintf (s, "%s - %s [%s]", PROGNAME, VERSION, jclient->jname ());
x_set_title (s);
H.position (xp, yp);
H.minsize (XSIZE, YSIZE);
H.maxsize (XSIZE, YSIZE);
H.rname (xres->rname ());
H.rclas (xres->rclas ());
x_apply (&H);
_ebudisp = new Ebu_r128_disp (this, this, 0, 0, XftColors [C_DISP_BG]);
_ebudisp->x_map ();
x_add_events (ExposureMask);
x_map ();
set_time (0);
inc_time (100000);
}
Mainwin::~Mainwin (void)
{
}
int Mainwin::process (void)
{
int e;
if (_stop) handle_stop ();
e = get_event_timed ();
switch (e)
{
case EV_TIME:
handle_time ();
break;
}
return e;
}
void Mainwin::handle_event (XEvent *E)
{
switch (E->type)
{
case Expose:
expose ((XExposeEvent *) E);
break;
case ClientMessage:
clmesg ((XClientMessageEvent *) E);
break;
}
}
void Mainwin::expose (XExposeEvent *E)
{
if (E->count) return;
redraw ();
}
void Mainwin::clmesg (XClientMessageEvent *E)
{
if (E->message_type == _atom) _stop = true;
}
void Mainwin::handle_time (void)
{
const Ebu_r128_proc *P = _jclient->ebu_r128 ();
_ebudisp->set_level (P->loudness_M (), P->maxloudn_M (), P->loudness_S (), P->maxloudn_S ());
_ebudisp->set_integ (P->integrated ());
_ebudisp->set_range (P->range_min (), P->range_max ());
_ebudisp->set_peak (_jclient->peakproc ()->readpeak ());
inc_time (100000);
XFlush (dpy ());
}
void Mainwin::handle_stop (void)
{
put_event (EV_EXIT, 1);
}
void Mainwin::handle_callb (int type, X_window *W, XEvent *E)
{
switch (type)
{
case Ebu_r128_disp::PAUSE:
_jclient->ebu_r128 ()->integr_pause ();
break;
case Ebu_r128_disp::START:
_jclient->ebu_r128 ()->integr_start ();
break;
case Ebu_r128_disp::RESET:
_jclient->ebu_r128 ()->integr_reset ();
break;
}
}
void Mainwin::redraw (void)
{
XPutImage (dpy (), win (), dgc (), redzita, 0, 0, XSIZE - 35, 0, 35, 75);
}
|