]> git.vomp.tv Git - vompclient.git/blob - wwinaudiofilter.cc
Fix black background for 16:9 live TV on 4:3 screen
[vompclient.git] / wwinaudiofilter.cc
1 /*
2     Copyright 2004-2007 Chris Tallon, Marten Richter
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 "wwinaudiofilter.h"
21 #include "audiowin.h"
22 #include "i18n.h"
23 #include "input.h"
24 #include "boxstack.h"
25
26 WWinAudioFilter::WWinAudioFilter()
27 {
28   add(&sl);
29   initSelectList(true);
30   sl.setShowSelOption(false);
31   sl.setPosition(15,30+15);
32 }
33
34 WWinAudioFilter::~WWinAudioFilter()
35 {
36   
37 }
38
39 void WWinAudioFilter::initSelectList(bool startup)
40 {
41     ULONG selection=0;
42     ULONG top=0;
43     if (!startup)
44     {
45         selection=sl.getCurrentOption();
46         top=sl.getTopOption();
47         
48     }
49     sl.addColumn(0);
50     
51     ULONG i;
52     AudioWin *aw=(AudioWin*) Audio::getInstance();
53     int filselected;
54     const AudioFilterDescList *list=aw->getAudioFilterList(filselected);
55     for (i = 0; i < list->size();i++)
56     {
57       const char * name = (*list)[i].friendlyname;
58       if (name!=NULL)
59       {
60         char * desc=new char [strlen(name)+1];
61         strcpy(desc,name);
62         sl.addOption(desc, reinterpret_cast<void*>(i), 0);
63       }
64       
65     }
66     if (!startup)
67     {
68         sl.hintSetCurrent(selection);
69         sl.hintSetTop(top);
70     }
71 }
72
73 void WWinAudioFilter::setSize(UINT w, UINT h)
74 {
75     Boxx::setSize(w, h);
76     sl.setSize(area.w - 240, area.h - 30-15-30);
77 }
78
79 void WWinAudioFilter::draw()
80 {
81     Boxx::draw();
82   
83   drawText(tr("Selected Filter:"), 15, 15, DrawStyle::LIGHTTEXT);
84   int filselected;
85   AudioWin *aw=(AudioWin*) Audio::getInstance();
86   const AudioFilterDescList *list=aw->getAudioFilterList(filselected);
87   if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,DrawStyle::LIGHTTEXT);
88   sl.draw();
89   
90 /*  if (!(*list)[sl.getCurrentOptionData()].vmr9tested)
91   {
92       rectangle(area.w - 220, 160, 200, 20, DrawStyle::YELLOW);
93       drawText(tr("VMR 9 support: ?"), area.w - 220, 160, DrawStyle::DARKTEXT);
94   }
95   else if ((*list)[sl.getCurrentOptionData()].vmr9)
96   {
97       rectangle(area.w - 220, 160, 200, 20, DrawStyle::GREEN);
98       drawText(tr("VMR 9 support: yes"), area.w - 220, 160, DrawStyle::DARKTEXT);
99   } 
100   else 
101   {
102       rectangle(area.w - 220, 160, 200, 20, DrawStyle::RED);
103       drawText(tr("VMR 9 support: no"), area.w - 220, 160, DrawStyle::DARKTEXT);
104   } */
105  
106   drawText(tr("Press [ok] to select filter! "), 15, area.h - 30, DrawStyle::LIGHTTEXT);
107
108 }
109
110
111 bool WWinAudioFilter::mouseLBDOWN(int x, int y)
112 {
113     if (sl.mouseLBDOWN(x,y))
114     {
115       BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
116       return true;
117     }
118     return false;
119 }
120
121 bool WWinAudioFilter::mouseMove(int x, int y) 
122 {
123     if (sl.mouseMove(x,y))
124     {
125       sl.setShowSelOption(true);
126       sl.draw();
127       return true;
128     }
129     return false;
130 }
131 /*
132 void WWinAudioFilter::processMessage(Message* m)
133 {
134   Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
135
136   if (m->message == Message::MOUSE_MOVE)
137   {
138     if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
139     {
140       sl.setShowSelOption(true);
141       sl.draw();
142       draw();
143       viewman->updateView(this);
144     }
145   }
146   else if (m->message == Message::MOUSE_LBDOWN)
147   {
148     if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
149     {
150       ViewMan::getInstance()->handleCommand(Input::OK); //simulate OK press
151     }
152     else
153     {
154       //check if press is outside this view! then simulate cancel
155       int x=(m->parameter>>16)-getScreenX();
156       int y=(m->parameter&0xFFFF)-getScreenY();
157       if (x<0 || y <0 || x>getWidth() || y>getHeight())
158       {
159         ViewMan::getInstance()->handleCommand(Input::BACK); //simulate cancel press
160       }
161     }
162   }
163   
164 }*/
165
166 /*
167 void WWinAudioFilter::doSave()
168 {
169     Message* m = new Message();
170     m->message = Message::CHANGED_DEVICEOPTIONS;
171     m->to = parent;
172     m->parameter = 0;
173     //Command::getInstance()->postMessage(m);
174     
175 }*/
176
177
178 int WWinAudioFilter::handleCommand(int command)
179 {
180   
181   switch(command)
182   {
183     case Input::UP:
184     {
185       if (sl.getCurrentOption() != 0)
186       {
187           sl.up();
188           sl.setShowSelOption(true);
189           return 1;
190       }
191       else
192       {
193           sl.setShowSelOption(false);
194           return 4; //Control to vopts control
195       }
196     }
197     case Input::DOWN:
198     {
199       Log::getInstance()->log("P", Log::DEBUG, "1");
200       sl.down();
201       sl.setShowSelOption(true);
202       return 1;
203     }
204     case Input::SKIPBACK:
205     {
206       sl.pageUp();
207       sl.draw();
208       return 1;
209     }
210     case Input::SKIPFORWARD:
211     {
212       sl.pageDown();
213       sl.draw();
214       return 1;
215     }
216     case Input::OK:
217     {
218       AudioWin*aw=(AudioWin*)Audio::getInstance();
219           aw->selectAudioFilter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
220      
221       return 1;
222     }
223     case Input::BACK:
224     {
225       return 0;
226       
227     }
228    
229
230     
231   }
232   // stop command getting to any more views
233   return 0;
234 }
235