]> git.vomp.tv Git - vompclient.git/blob - wwinvideoh264filter.cc
Rename Command class to Control
[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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "wwinvideoh264filter.h"
21 #include "videowin.h"
22 #include "i18n.h"
23 #include "input.h"
24 #include "boxstack.h"
25
26 WWinVideoH264Filter::WWinVideoH264Filter()
27 {  
28   add(&sl);
29   initSelectList(true);
30   sl.setShowSelOption(false);
31   sl.setPosition(15,30+15);
32 }
33
34 WWinVideoH264Filter::~WWinVideoH264Filter()
35 {
36   
37 }
38
39 void WWinVideoH264Filter::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     VideoWin *vw=(VideoWin*) Video::getInstance();
53     int filselected;
54     const VideoFilterDescList *list=vw->getVideoH264FilterList(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 WWinVideoH264Filter::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 WWinVideoH264Filter::draw()
80 {
81   Boxx::draw();
82   
83   drawText(tr("Selected Filter:"), 15, 15, DrawStyle::LIGHTTEXT);
84   int filselected;
85   VideoWin *vw=(VideoWin*) Video::getInstance();
86   const VideoFilterDescList *list=vw->getVideoH264FilterList(filselected);
87   if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,DrawStyle::LIGHTTEXT);
88   sl.draw();
89   
90   if (!(*list)[reinterpret_cast<ULONG>(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)[reinterpret_cast<ULONG>(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 bool WWinVideoH264Filter::mouseLBDOWN(int x, int y)
111 {
112     if (sl.mouseLBDOWN(x,y))
113     {
114       BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
115       return true;
116     }
117     return false;
118 }
119
120 bool WWinVideoH264Filter::mouseMove(int x, int y) 
121 {
122     if (sl.mouseMove(x,y))
123     {
124       sl.setShowSelOption(true);
125       sl.draw();
126       return true;
127     }
128     return false;
129 }
130
131 /*
132 void WWinVideoH264Filter::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 WWinVideoH264Filter::doSave()
168 {
169     Message* m = new Message();
170     m->message = Message::CHANGED_DEVICEOPTIONS;
171     m->to = parent;
172     m->parameter = 0;
173     //Control::getInstance()->postMessage(m);
174     
175 }*/
176
177
178 int WWinVideoH264Filter::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       sl.down();
200       sl.setShowSelOption(true);
201       return 1;
202     }
203     case Input::SKIPBACK:
204     {
205       sl.pageUp();
206       return 1;
207     }
208     case Input::SKIPFORWARD:
209     {
210       sl.pageDown();
211       return 1;
212     }
213     case Input::OK:
214     {
215         VideoWin*vw=(VideoWin*)Video::getInstance();
216         vw->selectVideoH264Filter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
217       return 1;
218     }
219     case Input::BACK:
220     {
221       return 0;
222       
223     }
224     
225   }
226
227   return 0;
228 }
229