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