diff options
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 15 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbfont.h | 5 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbscreen.cpp | 6 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbscreen.h | 4 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 28 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 10 |
6 files changed, 60 insertions, 8 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index 48e0f304be..71c6ff3fc1 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp | |||
@@ -21,6 +21,9 @@ | |||
21 | 21 | ||
22 | #include "rbfont.h" | 22 | #include "rbfont.h" |
23 | 23 | ||
24 | #include <QFont> | ||
25 | #include <QBrush> | ||
26 | |||
24 | RBFont::RBFont(QString file): filename(file) | 27 | RBFont::RBFont(QString file): filename(file) |
25 | { | 28 | { |
26 | } | 29 | } |
@@ -28,3 +31,15 @@ RBFont::RBFont(QString file): filename(file) | |||
28 | RBFont::~RBFont() | 31 | RBFont::~RBFont() |
29 | { | 32 | { |
30 | } | 33 | } |
34 | |||
35 | QGraphicsSimpleTextItem* RBFont::renderText(QString text, QColor color, | ||
36 | QGraphicsItem *parent) | ||
37 | { | ||
38 | QGraphicsSimpleTextItem* retval = new QGraphicsSimpleTextItem(text, parent); | ||
39 | QFont font; | ||
40 | font.setFixedPitch(true); | ||
41 | font.setPixelSize(8); | ||
42 | retval->setFont(font); | ||
43 | retval->setBrush(QBrush(color)); | ||
44 | return retval; | ||
45 | } | ||
diff --git a/utils/themeeditor/graphics/rbfont.h b/utils/themeeditor/graphics/rbfont.h index a1d66f22d4..61a171e081 100644 --- a/utils/themeeditor/graphics/rbfont.h +++ b/utils/themeeditor/graphics/rbfont.h | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <QString> | 25 | #include <QString> |
26 | #include <QFile> | 26 | #include <QFile> |
27 | #include <QGraphicsSimpleTextItem> | ||
27 | 28 | ||
28 | class RBFont | 29 | class RBFont |
29 | { | 30 | { |
@@ -31,6 +32,10 @@ public: | |||
31 | RBFont(QString file); | 32 | RBFont(QString file); |
32 | virtual ~RBFont(); | 33 | virtual ~RBFont(); |
33 | 34 | ||
35 | QGraphicsSimpleTextItem* renderText(QString text, QColor color, | ||
36 | QGraphicsItem* parent = 0); | ||
37 | int lineHeight(){ return 8; } | ||
38 | |||
34 | private: | 39 | private: |
35 | QString filename; | 40 | QString filename; |
36 | }; | 41 | }; |
diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp index d37050b0b5..d6a9aa6240 100644 --- a/utils/themeeditor/graphics/rbscreen.cpp +++ b/utils/themeeditor/graphics/rbscreen.cpp | |||
@@ -32,10 +32,10 @@ RBScreen::RBScreen(const RBRenderInfo& info, QGraphicsItem *parent) : | |||
32 | width = info.settings()->value("#screenwidth", "300").toInt(); | 32 | width = info.settings()->value("#screenwidth", "300").toInt(); |
33 | height = info.settings()->value("#screenheight", "200").toInt(); | 33 | height = info.settings()->value("#screenheight", "200").toInt(); |
34 | 34 | ||
35 | QString bg = info.settings()->value("background color", "000000"); | 35 | QString bg = info.settings()->value("background color", "FFFFFF"); |
36 | bgColor = stringToColor(bg, Qt::white); | 36 | bgColor = stringToColor(bg, Qt::white); |
37 | 37 | ||
38 | QString fg = info.settings()->value("foreground color", "FFFFFF"); | 38 | QString fg = info.settings()->value("foreground color", "000000"); |
39 | fgColor = stringToColor(fg, Qt::black); | 39 | fgColor = stringToColor(fg, Qt::black); |
40 | 40 | ||
41 | settings = info.settings(); | 41 | settings = info.settings(); |
@@ -61,6 +61,8 @@ RBScreen::RBScreen(const RBRenderInfo& info, QGraphicsItem *parent) : | |||
61 | backdrop = 0; | 61 | backdrop = 0; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | |||
65 | fonts.insert(0, new RBFont("Nothin'")); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | RBScreen::~RBScreen() | 68 | RBScreen::~RBScreen() |
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h index f35aef680b..8b5f2f4a16 100644 --- a/utils/themeeditor/graphics/rbscreen.h +++ b/utils/themeeditor/graphics/rbscreen.h | |||
@@ -60,10 +60,14 @@ public: | |||
60 | RBFont* getFont(int id); | 60 | RBFont* getFont(int id); |
61 | 61 | ||
62 | void setBackdrop(QString filename); | 62 | void setBackdrop(QString filename); |
63 | bool hasBackdrop(){ return backdrop != 0; } | ||
63 | void makeCustomUI(QString id); | 64 | void makeCustomUI(QString id); |
64 | 65 | ||
65 | static QColor stringToColor(QString str, QColor fallback); | 66 | static QColor stringToColor(QString str, QColor fallback); |
66 | 67 | ||
68 | QColor foreground(){ return fgColor; } | ||
69 | QColor background(){ return bgColor; } | ||
70 | |||
67 | 71 | ||
68 | private: | 72 | private: |
69 | int width; | 73 | int width; |
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index c5b88b3afd..03a7604804 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp | |||
@@ -30,7 +30,10 @@ | |||
30 | #include "skin_parser.h" | 30 | #include "skin_parser.h" |
31 | 31 | ||
32 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | 32 | RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) |
33 | : QGraphicsItem(info.screen()) | 33 | : QGraphicsItem(info.screen()), font(info.screen()->getFont(0)), |
34 | foreground(info.screen()->foreground()), | ||
35 | background(info.screen()->background()), textOffset(0,0), | ||
36 | screen(info.screen()) | ||
34 | { | 37 | { |
35 | if(!node->tag) | 38 | if(!node->tag) |
36 | { | 39 | { |
@@ -51,7 +54,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
51 | } | 54 | } |
52 | else | 55 | else |
53 | { | 56 | { |
54 | int param; | 57 | int param = 0; |
55 | QString ident; | 58 | QString ident; |
56 | int x,y,w,h; | 59 | int x,y,w,h; |
57 | /* Rendering one of the other types of viewport */ | 60 | /* Rendering one of the other types of viewport */ |
@@ -102,6 +105,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) | |||
102 | 105 | ||
103 | setPos(x, y); | 106 | setPos(x, y); |
104 | size = QRectF(0, 0, w, h); | 107 | size = QRectF(0, 0, w, h); |
108 | |||
105 | } | 109 | } |
106 | } | 110 | } |
107 | 111 | ||
@@ -124,13 +128,29 @@ QRectF RBViewport::boundingRect() const | |||
124 | void RBViewport::paint(QPainter *painter, | 128 | void RBViewport::paint(QPainter *painter, |
125 | const QStyleOptionGraphicsItem *option, QWidget *widget) | 129 | const QStyleOptionGraphicsItem *option, QWidget *widget) |
126 | { | 130 | { |
131 | if(!screen->hasBackdrop() && background != screen->background()) | ||
132 | { | ||
133 | painter->fillRect(size, QBrush(background)); | ||
134 | } | ||
135 | |||
127 | painter->setBrush(Qt::NoBrush); | 136 | painter->setBrush(Qt::NoBrush); |
128 | painter->setPen(customUI ? Qt::blue : Qt::red); | 137 | painter->setPen(customUI ? Qt::blue : Qt::red); |
129 | painter->drawRect(size); | 138 | painter->drawRect(size); |
130 | } | 139 | } |
131 | 140 | ||
132 | /* Called at the end of a logical line */ | 141 | void RBViewport::newLine() |
133 | void RBViewport::newline() | ||
134 | { | 142 | { |
143 | if(textOffset.x() > 0) | ||
144 | { | ||
145 | textOffset.setY(textOffset.y() + lineHeight); | ||
146 | textOffset.setX(0); | ||
147 | } | ||
148 | } | ||
135 | 149 | ||
150 | void RBViewport::write(QString text) | ||
151 | { | ||
152 | QGraphicsItem* graphic = font->renderText(text, foreground, this); | ||
153 | graphic->setPos(textOffset.x(), textOffset.y()); | ||
154 | textOffset.setX(textOffset.x() + graphic->boundingRect().width()); | ||
155 | lineHeight = font->lineHeight(); | ||
136 | } | 156 | } |
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 29d0b0a373..5726c5c256 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #define RBVIEWPORT_H | 23 | #define RBVIEWPORT_H |
24 | 24 | ||
25 | #include "skin_parser.h" | 25 | #include "skin_parser.h" |
26 | #include "rbfont.h" | ||
26 | 27 | ||
27 | class RBScreen; | 28 | class RBScreen; |
28 | class RBRenderInfo; | 29 | class RBRenderInfo; |
@@ -45,16 +46,21 @@ public: | |||
45 | void makeCustomUI(){ customUI = true; } | 46 | void makeCustomUI(){ customUI = true; } |
46 | void clearCustomUI(){ customUI = false; } | 47 | void clearCustomUI(){ customUI = false; } |
47 | 48 | ||
48 | 49 | void newLine(); | |
49 | void newline(); | 50 | void write(QString text); |
50 | 51 | ||
51 | private: | 52 | private: |
53 | |||
52 | QRectF size; | 54 | QRectF size; |
53 | QColor background; | 55 | QColor background; |
54 | QColor foreground; | 56 | QColor foreground; |
57 | RBFont* font; | ||
55 | 58 | ||
56 | bool customUI; | 59 | bool customUI; |
60 | QPoint textOffset; | ||
61 | int lineHeight; | ||
57 | 62 | ||
63 | RBScreen* screen; | ||
58 | }; | 64 | }; |
59 | 65 | ||
60 | #endif // RBVIEWPORT_H | 66 | #endif // RBVIEWPORT_H |