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