blob: 3a9a6ddeb3de6298c8ddcd0860f11e622ab81822 [file] [log] [blame]
Robert Bieber02c37742010-06-17 20:44:11 +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 RBSCREEN_H
23#define RBSCREEN_H
24
25#include <QGraphicsItem>
26
27#include "projectmodel.h"
Robert Biebere1d8a3d2010-06-21 20:11:58 +000028#include "rbrenderinfo.h"
Robert Bieberac9287b2010-06-22 07:55:50 +000029#include "rbimage.h"
Robert Bieber6d615662010-06-23 20:18:31 +000030#include "rbfont.h"
Robert Bieber81149792010-06-30 19:35:00 +000031#include "rbalbumart.h"
32#include "rbviewport.h"
Robert Bieber02c37742010-06-17 20:44:11 +000033
34class RBScreen : public QGraphicsItem
35{
36
37public:
Robert Bieber5300c702010-06-26 05:51:07 +000038 RBScreen(const RBRenderInfo& info, bool remote = false,
39 QGraphicsItem *parent = 0);
Robert Bieber02c37742010-06-17 20:44:11 +000040 virtual ~RBScreen();
41
42 QPainterPath shape() const;
43 QRectF boundingRect() const;
44 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
45 QWidget *widget);
46
Robert Bieberd8827b52010-06-18 21:10:01 +000047 int getWidth() const{ return width; }
48 int getHeight() const{ return height; }
49
Robert Bieber481bcf22010-06-24 18:55:04 +000050 void loadViewport(QString name, RBViewport* view);
Robert Biebere1d8a3d2010-06-21 20:11:58 +000051 void showViewport(QString name);
Robert Bieber1fbea622010-06-29 21:09:29 +000052 bool viewPortDisplayed(QString name)
53 {
54 return displayedViewports.contains(name);
55 }
Robert Bieber02c37742010-06-17 20:44:11 +000056
Robert Bieberac9287b2010-06-22 07:55:50 +000057 void loadImage(QString name, RBImage* image)
58 {
59 images.insert(name, image);
Robert Bieberd3027052010-06-23 07:18:22 +000060 image->hide();
Robert Bieberac9287b2010-06-22 07:55:50 +000061 }
62 RBImage* getImage(QString name){ return images.value(name, 0); }
63
Robert Bieber6d615662010-06-23 20:18:31 +000064 void loadFont(int id, RBFont* font);
65 RBFont* getFont(int id);
66
Robert Bieberac9287b2010-06-22 07:55:50 +000067 void setBackdrop(QString filename);
Robert Bieber273b9d62010-06-25 05:14:13 +000068 bool hasBackdrop(){ return backdrop != 0; }
Robert Bieberdeab1bb2010-06-23 19:41:30 +000069 void makeCustomUI(QString id);
Robert Bieber2f68e5b2010-07-03 22:57:42 +000070 void setCustomUI(RBViewport* viewport){ customUI = viewport; }
71 RBViewport* getCustomUI(){ return customUI; }
Robert Bieberac9287b2010-06-22 07:55:50 +000072
Robert Bieber02c37742010-06-17 20:44:11 +000073 static QColor stringToColor(QString str, QColor fallback);
74
Robert Bieber273b9d62010-06-25 05:14:13 +000075 QColor foreground(){ return fgColor; }
76 QColor background(){ return bgColor; }
77
Robert Bieber81149792010-06-30 19:35:00 +000078 void setAlbumArt(RBAlbumArt* art){ albumArt = art; }
79 void showAlbumArt(RBViewport* view)
80 {
81 if(albumArt)
82 {
83 albumArt->setParentItem(view);
84 albumArt->show();
Robert Bieber265ee152010-08-05 08:03:32 +000085 albumArt->enableMove();
Robert Bieber81149792010-06-30 19:35:00 +000086 }
87 }
88
Robert Bieberd1a392a2010-08-09 19:37:23 +000089 void setDefault(RBViewport* view){ defaultView = view; }
90 void endSbsRender();
Robert Bieber2f68e5b2010-07-03 22:57:42 +000091 void breakSBS();
Robert Bieberd8827b52010-06-18 21:10:01 +000092
Robert Bieber1ee2cdd2010-08-12 23:05:53 +000093 void RtlMirror(){ ax = true; }
94 bool isRtlMirrored(){ bool ret = ax; ax = false; return ret; }
95
Robert Bieberdf1ff112010-08-06 20:53:50 +000096protected:
97 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
98
Robert Bieber02c37742010-06-17 20:44:11 +000099private:
100 int width;
101 int height;
Robert Bieber2f68e5b2010-07-03 22:57:42 +0000102 int fullWidth;
103 int fullHeight;
Robert Bieber02c37742010-06-17 20:44:11 +0000104 QColor bgColor;
105 QColor fgColor;
106 QPixmap* backdrop;
Robert Bieberac9287b2010-06-22 07:55:50 +0000107 QString themeBase;
Robert Bieber02c37742010-06-17 20:44:11 +0000108
109 ProjectModel* project;
110
Robert Bieber481bcf22010-06-24 18:55:04 +0000111 QMap<QString, QList<RBViewport*>*> namedViewports;
Robert Bieberac9287b2010-06-22 07:55:50 +0000112 QMap<QString, RBImage*> images;
113 QMap<QString, QString>* settings;
Robert Bieber6d615662010-06-23 20:18:31 +0000114 QMap<int, RBFont*> fonts;
Robert Bieber1fbea622010-06-29 21:09:29 +0000115 QList<QString> displayedViewports;
Robert Biebere1d8a3d2010-06-21 20:11:58 +0000116
Robert Bieber81149792010-06-30 19:35:00 +0000117 RBAlbumArt* albumArt;
Robert Bieber2f68e5b2010-07-03 22:57:42 +0000118 RBViewport* customUI;
Robert Bieberd1a392a2010-08-09 19:37:23 +0000119 RBViewport* defaultView;
120
121 QList<QGraphicsItem*> sbsChildren;
Robert Bieber1ee2cdd2010-08-12 23:05:53 +0000122
123 bool ax;
Robert Bieber02c37742010-06-17 20:44:11 +0000124};
125
126#endif // RBSCREEN_H