]> git.vomp.tv Git - vompclient.git/blob - vvolume.cc
Convert PlayerRadioRec to std::thread
[vompclient.git] / vvolume.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "vvolume.h"
21
22 #include "input.h"
23 #include "audio.h"
24 #include "wsymbol.h"
25 #include "colour.h"
26 #include "video.h"
27 #include "boxstack.h"
28 #include "messagequeue.h"
29
30 VVolume::VVolume()
31 {
32   displayVolume = Audio::getInstance()->getVolume();
33
34   setSize(227, 31);
35   createBuffer();
36   if (Video::getInstance()->getFormat() == Video::PAL)
37   {
38     setPosition(100, 499);
39   }
40   else
41   {
42     setPosition(90, 400);
43   }
44 }
45
46 VVolume::~VVolume()
47 {
48   // Make sure the timer is deleted
49   Timers::getInstance()->cancelTimer(this, 1);
50 }
51
52 void VVolume::draw()
53 {
54   Boxx::draw();
55
56   fillColour(DrawStyle::VIEWBACKGROUND);
57
58   WSymbol w;
59   TEMPADD(&w);
60   w.nextSymbol = WSymbol::VOLUME2;
61   w.setPosition(3, 10);
62   w.draw();
63
64   int i = 0;
65
66   for(; i < displayVolume; i++)
67   {
68     w.nextSymbol = WSymbol::VOLBAR;
69     w.setPosition(40 + (i * 9), 3);
70     w.draw();
71   }
72
73   for(; i < 20; i++)
74   {
75     w.nextSymbol = WSymbol::VOLDOT;
76     w.setPosition(40 + (i * 9), 13);
77     w.draw();
78   }
79
80   Timers::getInstance()->setTimerD(this, 1, 2);
81 }
82
83 void VVolume::timercall(int /* clientReference */)
84 {
85   // delete me!
86   Message* m = new Message(); // Delete self
87   m->message = Message::CLOSE_ME;
88   m->to = BoxStack::getInstance();
89   m->from = this;
90   MessageQueue::getInstance()->postMessage(m);
91 }
92
93 int VVolume::handleCommand(int command)
94 {
95   switch(command)
96   {
97     case Input::VOLUMEDOWN:
98     {
99       displayVolume = Audio::getInstance()->volumeDown();
100       draw();
101       BoxStack::getInstance()->update(this);
102       // handled
103       return 2;
104     }
105     case Input::VOLUMEUP:
106     {
107       displayVolume = Audio::getInstance()->volumeUp();
108       draw();
109       BoxStack::getInstance()->update(this);
110       // handled
111       return 2;
112     }
113   }
114
115   // allow command to drop through to other views
116   return 0;
117 }