diff options
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 29 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbfontcache.cpp | 24 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbfontcache.h | 48 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 6 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 2 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 37 |
6 files changed, 124 insertions, 22 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index 07308fac7e..cd68af99fe 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "rbfont.h" | 22 | #include "rbfont.h" |
23 | #include "rbfontcache.h" | ||
23 | 24 | ||
24 | #include <QFont> | 25 | #include <QFont> |
25 | #include <QBrush> | 26 | #include <QBrush> |
@@ -29,6 +30,8 @@ | |||
29 | #include <QImage> | 30 | #include <QImage> |
30 | #include <QSettings> | 31 | #include <QSettings> |
31 | 32 | ||
33 | #include <QDebug> | ||
34 | |||
32 | quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; | 35 | quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB; |
33 | 36 | ||
34 | RBFont::RBFont(QString file) | 37 | RBFont::RBFont(QString file) |
@@ -52,6 +55,18 @@ RBFont::RBFont(QString file) | |||
52 | } | 55 | } |
53 | header.insert("filename", file); | 56 | header.insert("filename", file); |
54 | 57 | ||
58 | /* Checking for a cache entry */ | ||
59 | RBFontCache::CacheInfo* cache = RBFontCache::lookup(file); | ||
60 | if(cache) | ||
61 | { | ||
62 | imageData = cache->imageData; | ||
63 | offsetData = cache->offsetData; | ||
64 | widthData = cache->widthData; | ||
65 | header = cache->header; | ||
66 | |||
67 | return; | ||
68 | } | ||
69 | |||
55 | /* Opening the file */ | 70 | /* Opening the file */ |
56 | QFile fin(file); | 71 | QFile fin(file); |
57 | fin.open(QFile::ReadOnly); | 72 | fin.open(QFile::ReadOnly); |
@@ -134,16 +149,18 @@ RBFont::RBFont(QString file) | |||
134 | 149 | ||
135 | fin.close(); | 150 | fin.close(); |
136 | 151 | ||
152 | /* Caching the font data */ | ||
153 | cache = new RBFontCache::CacheInfo; | ||
154 | cache->imageData = imageData; | ||
155 | cache->offsetData = offsetData; | ||
156 | cache->widthData = widthData; | ||
157 | cache->header = header; | ||
158 | RBFontCache::insert(file, cache); | ||
159 | |||
137 | } | 160 | } |
138 | 161 | ||
139 | RBFont::~RBFont() | 162 | RBFont::~RBFont() |
140 | { | 163 | { |
141 | if(imageData) | ||
142 | delete[] imageData; | ||
143 | if(offsetData) | ||
144 | delete[] offsetData; | ||
145 | if(widthData) | ||
146 | delete[] widthData; | ||
147 | } | 164 | } |
148 | 165 | ||
149 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, | 166 | RBText* RBFont::renderText(QString text, QColor color, int viewWidth, |
diff --git a/utils/themeeditor/graphics/rbfontcache.cpp b/utils/themeeditor/graphics/rbfontcache.cpp new file mode 100644 index 0000000000..3b6d56fd58 --- /dev/null +++ b/utils/themeeditor/graphics/rbfontcache.cpp | |||
@@ -0,0 +1,24 @@ | |||
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 | #include "rbfontcache.h" | ||
23 | |||
24 | QHash<QString, RBFontCache::CacheInfo*> RBFontCache::cache; | ||
diff --git a/utils/themeeditor/graphics/rbfontcache.h b/utils/themeeditor/graphics/rbfontcache.h new file mode 100644 index 0000000000..50a6d2ec48 --- /dev/null +++ b/utils/themeeditor/graphics/rbfontcache.h | |||
@@ -0,0 +1,48 @@ | |||
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 RBFONTCACHE_H | ||
23 | #define RBFONTCACHE_H | ||
24 | |||
25 | #include <QHash> | ||
26 | |||
27 | class RBFontCache | ||
28 | { | ||
29 | |||
30 | public: | ||
31 | struct CacheInfo | ||
32 | { | ||
33 | quint8* imageData; | ||
34 | quint16* offsetData; | ||
35 | quint8* widthData; | ||
36 | |||
37 | QHash<QString, QVariant> header; | ||
38 | }; | ||
39 | |||
40 | static CacheInfo* lookup(QString key){ return cache.value(key, 0); } | ||
41 | static void insert(QString key, CacheInfo* data){ cache.insert(key, data); } | ||
42 | |||
43 | private: | ||
44 | static QHash<QString, CacheInfo*> cache; | ||
45 | |||
46 | }; | ||
47 | |||
48 | #endif // RBFONTCACHE_H | ||
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 81841d5cfa..c557632a40 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -60,6 +60,12 @@ public: | |||
60 | void alignText(Alignment align){ textAlign = align; } | 60 | void alignText(Alignment align){ textAlign = align; } |
61 | int getTextOffset(){ return textOffset.y(); } | 61 | int getTextOffset(){ return textOffset.y(); } |
62 | void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); } | 62 | void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); } |
63 | void flushText() | ||
64 | { | ||
65 | alignLeft(); | ||
66 | alignRight(); | ||
67 | alignCenter(); | ||
68 | } | ||
63 | 69 | ||
64 | void enableStatusBar(){ showStatusBar = true; } | 70 | void enableStatusBar(){ showStatusBar = true; } |
65 | 71 | ||
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index f5a7e81166..c284b16d6c 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp | |||
@@ -523,6 +523,8 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport, | |||
523 | children[i]->render(info, viewport); | 523 | children[i]->render(info, viewport); |
524 | if(!noBreak && !breakFlag) | 524 | if(!noBreak && !breakFlag) |
525 | viewport->newLine(); | 525 | viewport->newLine(); |
526 | else | ||
527 | viewport->flushText(); | ||
526 | 528 | ||
527 | if(breakFlag) | 529 | if(breakFlag) |
528 | breakFlag = false; | 530 | breakFlag = false; |
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index 1670b960bd..b0824cfe84 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -14,15 +14,17 @@ INCLUDEPATH += graphics | |||
14 | 14 | ||
15 | # Stuff for the parse lib | 15 | # Stuff for the parse lib |
16 | libskin_parser.commands = @$(MAKE) \ | 16 | libskin_parser.commands = @$(MAKE) \ |
17 | TARGET_DIR=$$MYBUILDDIR CC=\"$$QMAKE_CC\" \ | 17 | TARGET_DIR=$$MYBUILDDIR \ |
18 | CC=\"$$QMAKE_CC\" \ | ||
18 | BUILDDIR=$$OBJECTS_DIR \ | 19 | BUILDDIR=$$OBJECTS_DIR \ |
19 | -C $$RBBASE_DIR/lib/skin_parser \ | 20 | -C \ |
21 | $$RBBASE_DIR/lib/skin_parser \ | ||
20 | libskin_parser.a | 22 | libskin_parser.a |
21 | |||
22 | QMAKE_EXTRA_TARGETS += libskin_parser | 23 | QMAKE_EXTRA_TARGETS += libskin_parser |
23 | PRE_TARGETDEPS += libskin_parser | 24 | PRE_TARGETDEPS += libskin_parser |
24 | INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser | 25 | INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser |
25 | LIBS += -L$$MYBUILDDIR -lskin_parser | 26 | LIBS += -L$$MYBUILDDIR \ |
27 | -lskin_parser | ||
26 | DEPENDPATH = $$INCLUDEPATH | 28 | DEPENDPATH = $$INCLUDEPATH |
27 | HEADERS += models/parsetreemodel.h \ | 29 | HEADERS += models/parsetreemodel.h \ |
28 | models/parsetreenode.h \ | 30 | models/parsetreenode.h \ |
@@ -44,7 +46,8 @@ HEADERS += models/parsetreemodel.h \ | |||
44 | graphics/rbalbumart.h \ | 46 | graphics/rbalbumart.h \ |
45 | graphics/rbprogressbar.h \ | 47 | graphics/rbprogressbar.h \ |
46 | gui/findreplacedialog.h \ | 48 | gui/findreplacedialog.h \ |
47 | graphics/rbtext.h | 49 | graphics/rbtext.h \ |
50 | graphics/rbfontcache.h | ||
48 | SOURCES += main.cpp \ | 51 | SOURCES += main.cpp \ |
49 | models/parsetreemodel.cpp \ | 52 | models/parsetreemodel.cpp \ |
50 | models/parsetreenode.cpp \ | 53 | models/parsetreenode.cpp \ |
@@ -65,7 +68,8 @@ SOURCES += main.cpp \ | |||
65 | graphics/rbalbumart.cpp \ | 68 | graphics/rbalbumart.cpp \ |
66 | graphics/rbprogressbar.cpp \ | 69 | graphics/rbprogressbar.cpp \ |
67 | gui/findreplacedialog.cpp \ | 70 | gui/findreplacedialog.cpp \ |
68 | graphics/rbtext.cpp | 71 | graphics/rbtext.cpp \ |
72 | graphics/rbfontcache.cpp | ||
69 | OTHER_FILES += README \ | 73 | OTHER_FILES += README \ |
70 | resources/windowicon.png \ | 74 | resources/windowicon.png \ |
71 | resources/appicon.xcf \ | 75 | resources/appicon.xcf \ |
@@ -82,16 +86,17 @@ FORMS += gui/editorwindow.ui \ | |||
82 | gui/skinviewer.ui \ | 86 | gui/skinviewer.ui \ |
83 | gui/findreplacedialog.ui | 87 | gui/findreplacedialog.ui |
84 | RESOURCES += resources.qrc | 88 | RESOURCES += resources.qrc |
85 | 89 | win32:RC_FILE = themeeditor.rc | |
86 | win32 { | 90 | macx { |
87 | RC_FILE = themeeditor.rc | 91 | QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.4u.sdk |
88 | } | 92 | QMAKE_LFLAGS_PPC = -mmacosx-version-min=10.4 \ |
89 | macx { | 93 | -arch \ |
90 | QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk | 94 | ppc |
91 | QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc | 95 | QMAKE_LFLAGS_X86 = -mmacosx-version-min=10.4 \ |
92 | QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386 | 96 | -arch \ |
93 | CONFIG+=x86 ppc | 97 | i386 |
98 | CONFIG += x86 \ | ||
99 | ppc | ||
94 | QMAKE_INFO_PLIST = Info.plist | 100 | QMAKE_INFO_PLIST = Info.plist |
95 | RC_FILE = resources/windowicon.icns | 101 | RC_FILE = resources/windowicon.icns |
96 | } | 102 | } |
97 | |||