Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 26 | #include "rbfont.h" |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 27 | #include "rbmovable.h" |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 28 | |
| 29 | class RBScreen; |
| 30 | class RBRenderInfo; |
Robert Bieber | 49865b2 | 2010-08-04 09:16:52 +0000 | [diff] [blame] | 31 | class ParseTreeNode; |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 32 | |
| 33 | #include <QGraphicsItem> |
| 34 | |
Robert Bieber | 49865b2 | 2010-08-04 09:16:52 +0000 | [diff] [blame] | 35 | class SkinDocument; |
| 36 | |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 37 | class RBViewport : public RBMovable |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 38 | { |
| 39 | public: |
Robert Bieber | d2ed594 | 2010-06-30 07:00:05 +0000 | [diff] [blame] | 40 | enum Alignment |
| 41 | { |
| 42 | Left, |
| 43 | Center, |
| 44 | Right |
| 45 | }; |
| 46 | |
Robert Bieber | 13e97cd | 2010-07-07 22:25:42 +0000 | [diff] [blame] | 47 | static const double scrollRate; |
Robert Bieber | 13e97cd | 2010-07-07 22:25:42 +0000 | [diff] [blame] | 48 | |
Robert Bieber | 49865b2 | 2010-08-04 09:16:52 +0000 | [diff] [blame] | 49 | RBViewport(skin_element* node, const RBRenderInfo& info, |
| 50 | ParseTreeNode* pNode); |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 51 | virtual ~RBViewport(); |
| 52 | |
| 53 | QPainterPath shape() const; |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 54 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
| 55 | QWidget *widget); |
| 56 | |
Robert Bieber | deab1bb | 2010-06-23 19:41:30 +0000 | [diff] [blame] | 57 | void setBGColor(QColor color){ background = color; } |
Robert Bieber | 9742704 | 2010-07-02 00:20:36 +0000 | [diff] [blame] | 58 | QColor getBGColor(){ return background; } |
Robert Bieber | deab1bb | 2010-06-23 19:41:30 +0000 | [diff] [blame] | 59 | void setFGColor(QColor color){ foreground = color; } |
Robert Bieber | 9742704 | 2010-07-02 00:20:36 +0000 | [diff] [blame] | 60 | QColor getFGColor(){ return foreground; } |
Robert Bieber | deab1bb | 2010-06-23 19:41:30 +0000 | [diff] [blame] | 61 | void makeCustomUI(){ customUI = true; } |
| 62 | void clearCustomUI(){ customUI = false; } |
| 63 | |
Robert Bieber | a54bfaa | 2010-07-01 20:30:19 +0000 | [diff] [blame] | 64 | void newLine(); |
Robert Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 65 | void write(QString text); |
Robert Bieber | d2ed594 | 2010-06-30 07:00:05 +0000 | [diff] [blame] | 66 | void alignText(Alignment align){ textAlign = align; } |
Robert Bieber | 9742704 | 2010-07-02 00:20:36 +0000 | [diff] [blame] | 67 | int getTextOffset(){ return textOffset.y(); } |
| 68 | void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); } |
Robert Bieber | 6f06793 | 2010-07-07 08:41:36 +0000 | [diff] [blame] | 69 | void flushText() |
| 70 | { |
Robert Bieber | 364af4f | 2010-07-11 04:36:05 +0000 | [diff] [blame] | 71 | if(textOffset.x() < 0) |
| 72 | return; |
Robert Bieber | 6f06793 | 2010-07-07 08:41:36 +0000 | [diff] [blame] | 73 | alignLeft(); |
| 74 | alignRight(); |
| 75 | alignCenter(); |
| 76 | } |
Robert Bieber | 13e97cd | 2010-07-07 22:25:42 +0000 | [diff] [blame] | 77 | void scrollText(double time){ scrollTime = time; } |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 78 | |
Robert Bieber | 35150b6 | 2010-06-30 21:28:11 +0000 | [diff] [blame] | 79 | void enableStatusBar(){ showStatusBar = true; } |
| 80 | |
Robert Bieber | b413169 | 2010-08-15 02:04:06 +0000 | [diff] [blame] | 81 | void showPlaylist(const RBRenderInfo& info, int start, |
| 82 | ParseTreeNode* lines); |
Robert Bieber | 26a2f81 | 2010-07-01 21:49:55 +0000 | [diff] [blame] | 83 | |
Robert Bieber | d1a392a | 2010-08-09 19:37:23 +0000 | [diff] [blame] | 84 | void makeFullScreen(); |
| 85 | |
Robert Bieber | a83adc7 | 2010-08-03 08:42:30 +0000 | [diff] [blame] | 86 | protected: |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 87 | void saveGeometry(); |
Robert Bieber | a83adc7 | 2010-08-03 08:42:30 +0000 | [diff] [blame] | 88 | |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 89 | private: |
Robert Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 90 | |
Robert Bieber | d2ed594 | 2010-06-30 07:00:05 +0000 | [diff] [blame] | 91 | void alignLeft(); |
| 92 | void alignCenter(); |
| 93 | void alignRight(); |
| 94 | |
Robert Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 95 | RBFont* font; |
Robert Bieber | c32728c | 2010-06-26 05:18:21 +0000 | [diff] [blame] | 96 | QColor foreground; |
| 97 | QColor background; |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 98 | |
Robert Bieber | 5300c70 | 2010-06-26 05:51:07 +0000 | [diff] [blame] | 99 | bool debug; |
Robert Bieber | e1d8a3d | 2010-06-21 20:11:58 +0000 | [diff] [blame] | 100 | bool customUI; |
Robert Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 101 | QPoint textOffset; |
| 102 | int lineHeight; |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 103 | |
Robert Bieber | 273b9d6 | 2010-06-25 05:14:13 +0000 | [diff] [blame] | 104 | RBScreen* screen; |
Robert Bieber | d2ed594 | 2010-06-30 07:00:05 +0000 | [diff] [blame] | 105 | |
Robert Bieber | 3214e37 | 2010-07-07 06:50:30 +0000 | [diff] [blame] | 106 | QString leftText; |
| 107 | QString centerText; |
| 108 | QString rightText; |
Robert Bieber | d2ed594 | 2010-06-30 07:00:05 +0000 | [diff] [blame] | 109 | Alignment textAlign; |
Robert Bieber | 35150b6 | 2010-06-30 21:28:11 +0000 | [diff] [blame] | 110 | |
| 111 | bool showStatusBar; |
| 112 | QPixmap statusBarTexture; |
Robert Bieber | 3214e37 | 2010-07-07 06:50:30 +0000 | [diff] [blame] | 113 | |
| 114 | RBText* leftGraphic; |
| 115 | RBText* centerGraphic; |
| 116 | RBText* rightGraphic; |
Robert Bieber | 13e97cd | 2010-07-07 22:25:42 +0000 | [diff] [blame] | 117 | |
| 118 | double scrollTime; |
Robert Bieber | 49865b2 | 2010-08-04 09:16:52 +0000 | [diff] [blame] | 119 | |
| 120 | int baseParam; |
| 121 | ParseTreeNode* node; |
| 122 | SkinDocument* doc; |
Robert Bieber | 1ee2cdd | 2010-08-12 23:05:53 +0000 | [diff] [blame] | 123 | |
| 124 | bool mirrored; |
Robert Bieber | d8827b5 | 2010-06-18 21:10:01 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | #endif // RBVIEWPORT_H |