]> git.vomp.tv Git - vompclient.git/blob - vpicturebanner.cc
Fix VRecording showing graphic at bottom left when it shouldn't
[vompclient.git] / vpicturebanner.cc
1 /*
2     Copyright 2004-2005 Chris Tallon, Andreas Vogel
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 "vpicturebanner.h"
22
23 #include "wsymbol.h"
24 #include "input.h"
25 #include "colour.h"
26 #include "video.h"
27 #include "vinfo.h"
28 #include "boxstack.h"
29 #include "i18n.h"
30 #include "log.h"
31
32 VPictureBanner::VPictureBanner(bool ld, bool sl)
33 {
34   shortInfo=ld;
35   slideshow=sl;
36   Video *v=Video::getInstance();
37   setSize(v->getScreenWidth()-100, 36);
38   createBuffer();
39   setPosition(50, v->getScreenHeight()-50);
40   setTitleBarOn(0);
41   info=NULL;
42   LogNT::getInstance()->debug("VPictureBanner", "created {}", static_cast<void*>(this));
43   //TODO compute sizes from text
44   rotsize=70;
45   infsize=50;
46
47   MessageQueue::getInstance()->addReceiver(this);
48 }
49
50 VPictureBanner::~VPictureBanner()
51 {
52   MessageQueue::getInstance()->removeReceiver(this);
53   LogNT::getInstance()->debug("VPictureBanner", "deleted {}", static_cast<void*>(this));
54 }
55
56
57
58 void VPictureBanner::draw()
59 {
60 //  View::draw();
61   if (shortInfo) {
62     if (info) {
63       drawText(info,5,area.h-25,DrawStyle::LIGHTTEXT);
64       }
65     else drawText(tr("Loading"),5,3,DrawStyle::LIGHTTEXT);
66     }
67   else {
68     int x=5;
69     rectangle(x, area.h - 24, 18, 16, DrawStyle::RED);
70     x+=18+3;
71     drawText(tr("rotate"), x, area.h - 25, DrawStyle::LIGHTTEXT);
72     x+=rotsize+3;
73     rectangle(x, area.h - 24, 18, 16, DrawStyle::GREEN);
74     x+=18+3;
75     drawText(tr("info"), 5+18+3+rotsize+3+18+3, area.h - 25, DrawStyle::LIGHTTEXT);
76     x+=infsize+3;
77     WSymbol w;
78     TEMPADD(&w);
79     if (!slideshow) {
80       w.nextSymbol = WSymbol::PAUSE;
81       }
82     else {
83       w.nextSymbol = WSymbol::PLAY;
84     }
85     w.setPosition(x, area.h-24);
86     w.draw();
87     x+=20+3;
88     if (info) {
89       drawText(info,x,area.h - 25,DrawStyle::LIGHTTEXT);
90     }
91   }
92 }
93
94 int VPictureBanner::handleCommand(int /*command*/)
95 {
96   //don not handle commands - leave this to the picture viewer
97   return BoxStack::DROP_THROUGH;
98 }
99
100
101
102 void VPictureBanner::processMessage(Message* m)
103 {
104   if (m->message == Message::MOUSE_MOVE)
105   {
106     
107   }
108   else if (m->message == Message::MOUSE_LBDOWN)
109   {
110     int x = m->parameter - getScreenX();
111     int y = m->tag - getScreenY();
112
113     if (coordsOutsideBox(m))
114     {
115       Input::sendInputKey(Input::BACK);
116     }
117     else if (y >= (static_cast<int>(area.h) - 24) && y <= static_cast<int>(area.h) - 6)
118     {
119       //y coordinate is right!
120       if (x>=7 &&x<=25)
121       {
122         BoxStack::getInstance()->handleCommand(Input::RED); //simulate red press
123       }
124       else if (x>=110 &&x<=128)
125       {
126         BoxStack::getInstance()->handleCommand(Input::GREEN); //simulate red press
127       }
128     }
129   }
130 }
131
132 void VPictureBanner::setText(const char * text) {
133   if (info) delete info;
134   info=NULL;
135   if(!text) return;
136   info=new char[strlen(text)+1];
137   strcpy(info,text);
138 }
139
140
141
142
143