blob: 8e17ac15ded09cef005e3e00ce5e40f6c7e5e893 [file] [log] [blame]
Robert Bieberd8827b52010-06-18 21:10:01 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef RBVIEWPORT_H
23#define RBVIEWPORT_H
24
25#include "skin_parser.h"
Robert Bieber273b9d62010-06-25 05:14:13 +000026#include "rbfont.h"
Robert Bieber83c60a12010-08-03 22:29:26 +000027#include "rbmovable.h"
Robert Bieberd8827b52010-06-18 21:10:01 +000028
29class RBScreen;
30class RBRenderInfo;
Robert Bieber49865b22010-08-04 09:16:52 +000031class ParseTreeNode;
Robert Bieberd8827b52010-06-18 21:10:01 +000032
33#include <QGraphicsItem>
34
Robert Bieber49865b22010-08-04 09:16:52 +000035class SkinDocument;
36
Robert Bieber83c60a12010-08-03 22:29:26 +000037class RBViewport : public RBMovable
Robert Bieberd8827b52010-06-18 21:10:01 +000038{
39public:
Robert Bieberd2ed5942010-06-30 07:00:05 +000040 enum Alignment
41 {
42 Left,
43 Center,
44 Right
45 };
46
Robert Bieber13e97cd2010-07-07 22:25:42 +000047 static const double scrollRate;
Robert Bieber13e97cd2010-07-07 22:25:42 +000048
Robert Bieber49865b22010-08-04 09:16:52 +000049 RBViewport(skin_element* node, const RBRenderInfo& info,
50 ParseTreeNode* pNode);
Robert Bieberd8827b52010-06-18 21:10:01 +000051 virtual ~RBViewport();
52
53 QPainterPath shape() const;
Robert Bieberd8827b52010-06-18 21:10:01 +000054 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
55 QWidget *widget);
56
Robert Bieberdeab1bb2010-06-23 19:41:30 +000057 void setBGColor(QColor color){ background = color; }
Robert Bieber97427042010-07-02 00:20:36 +000058 QColor getBGColor(){ return background; }
Robert Bieberdeab1bb2010-06-23 19:41:30 +000059 void setFGColor(QColor color){ foreground = color; }
Robert Bieber97427042010-07-02 00:20:36 +000060 QColor getFGColor(){ return foreground; }
Robert Bieberdeab1bb2010-06-23 19:41:30 +000061 void makeCustomUI(){ customUI = true; }
62 void clearCustomUI(){ customUI = false; }
63
Robert Biebera54bfaa2010-07-01 20:30:19 +000064 void newLine();
Robert Bieber273b9d62010-06-25 05:14:13 +000065 void write(QString text);
Robert Bieberd2ed5942010-06-30 07:00:05 +000066 void alignText(Alignment align){ textAlign = align; }
Robert Bieber97427042010-07-02 00:20:36 +000067 int getTextOffset(){ return textOffset.y(); }
68 void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
Robert Bieber6f067932010-07-07 08:41:36 +000069 void flushText()
70 {
Robert Bieber364af4f2010-07-11 04:36:05 +000071 if(textOffset.x() < 0)
72 return;
Robert Bieber6f067932010-07-07 08:41:36 +000073 alignLeft();
74 alignRight();
75 alignCenter();
76 }
Robert Bieber13e97cd2010-07-07 22:25:42 +000077 void scrollText(double time){ scrollTime = time; }
Robert Bieberd8827b52010-06-18 21:10:01 +000078
Robert Bieber35150b62010-06-30 21:28:11 +000079 void enableStatusBar(){ showStatusBar = true; }
80
Robert Bieberb4131692010-08-15 02:04:06 +000081 void showPlaylist(const RBRenderInfo& info, int start,
82 ParseTreeNode* lines);
Robert Bieber26a2f812010-07-01 21:49:55 +000083
Robert Bieberd1a392a2010-08-09 19:37:23 +000084 void makeFullScreen();
85
Robert Biebera83adc72010-08-03 08:42:30 +000086protected:
Robert Bieber83c60a12010-08-03 22:29:26 +000087 void saveGeometry();
Robert Biebera83adc72010-08-03 08:42:30 +000088
Robert Bieberd8827b52010-06-18 21:10:01 +000089private:
Robert Bieber273b9d62010-06-25 05:14:13 +000090
Robert Bieberd2ed5942010-06-30 07:00:05 +000091 void alignLeft();
92 void alignCenter();
93 void alignRight();
94
Robert Bieber273b9d62010-06-25 05:14:13 +000095 RBFont* font;
Robert Bieberc32728c2010-06-26 05:18:21 +000096 QColor foreground;
97 QColor background;
Robert Bieberd8827b52010-06-18 21:10:01 +000098
Robert Bieber5300c702010-06-26 05:51:07 +000099 bool debug;
Robert Biebere1d8a3d2010-06-21 20:11:58 +0000100 bool customUI;
Robert Bieber273b9d62010-06-25 05:14:13 +0000101 QPoint textOffset;
102 int lineHeight;
Robert Bieberd8827b52010-06-18 21:10:01 +0000103
Robert Bieber273b9d62010-06-25 05:14:13 +0000104 RBScreen* screen;
Robert Bieberd2ed5942010-06-30 07:00:05 +0000105
Robert Bieber3214e372010-07-07 06:50:30 +0000106 QString leftText;
107 QString centerText;
108 QString rightText;
Robert Bieberd2ed5942010-06-30 07:00:05 +0000109 Alignment textAlign;
Robert Bieber35150b62010-06-30 21:28:11 +0000110
111 bool showStatusBar;
112 QPixmap statusBarTexture;
Robert Bieber3214e372010-07-07 06:50:30 +0000113
114 RBText* leftGraphic;
115 RBText* centerGraphic;
116 RBText* rightGraphic;
Robert Bieber13e97cd2010-07-07 22:25:42 +0000117
118 double scrollTime;
Robert Bieber49865b22010-08-04 09:16:52 +0000119
120 int baseParam;
121 ParseTreeNode* node;
122 SkinDocument* doc;
Robert Bieber1ee2cdd2010-08-12 23:05:53 +0000123
124 bool mirrored;
Robert Bieberd8827b52010-06-18 21:10:01 +0000125};
126
127#endif // RBVIEWPORT_H