summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-07 08:41:36 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-07 08:41:36 +0000
commit6f06793f58f520ec7d44683f6447c0b540a265b3 (patch)
tree94b76580cfc13903a55c10dc92318551eebf9788 /utils
parent88145656fb9b3276893e617b21bc590bc49fe96a (diff)
downloadrockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.tar.gz
rockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.tar.bz2
rockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.zip
Theme Editor: Fixed rendering bug that caused text in sublines not to appear, implemented a global font cache
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27331 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/graphics/rbfont.cpp29
-rw-r--r--utils/themeeditor/graphics/rbfontcache.cpp24
-rw-r--r--utils/themeeditor/graphics/rbfontcache.h48
-rw-r--r--utils/themeeditor/graphics/rbviewport.h6
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp2
-rw-r--r--utils/themeeditor/themeeditor.pro37
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 @@
****************************************************************************/
#include "rbfont.h"
+#include "rbfontcache.h"
#include <QFont>
#include <QBrush>
@@ -29,6 +30,8 @@
#include <QImage>
#include <QSettings>
+#include <QDebug>
+
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
RBFont::RBFont(QString file)
@@ -52,6 +55,18 @@ RBFont::RBFont(QString file)
}
header.insert("filename", file);
+ /* Checking for a cache entry */
+ RBFontCache::CacheInfo* cache = RBFontCache::lookup(file);
+ if(cache)
+ {
+ imageData = cache->imageData;
+ offsetData = cache->offsetData;
+ widthData = cache->widthData;
+ header = cache->header;
+
+ return;
+ }
+
/* Opening the file */
QFile fin(file);
fin.open(QFile::ReadOnly);
@@ -134,16 +149,18 @@ RBFont::RBFont(QString file)
fin.close();
+ /* Caching the font data */
+ cache = new RBFontCache::CacheInfo;
+ cache->imageData = imageData;
+ cache->offsetData = offsetData;
+ cache->widthData = widthData;
+ cache->header = header;
+ RBFontCache::insert(file, cache);
+
}
RBFont::~RBFont()
{
- if(imageData)
- delete[] imageData;
- if(offsetData)
- delete[] offsetData;
- if(widthData)
- delete[] widthData;
}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "rbfontcache.h"
+
+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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef RBFONTCACHE_H
+#define RBFONTCACHE_H
+
+#include <QHash>
+
+class RBFontCache
+{
+
+public:
+ struct CacheInfo
+ {
+ quint8* imageData;
+ quint16* offsetData;
+ quint8* widthData;
+
+ QHash<QString, QVariant> header;
+ };
+
+ static CacheInfo* lookup(QString key){ return cache.value(key, 0); }
+ static void insert(QString key, CacheInfo* data){ cache.insert(key, data); }
+
+private:
+ static QHash<QString, CacheInfo*> cache;
+
+};
+
+#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:
void alignText(Alignment align){ textAlign = align; }
int getTextOffset(){ return textOffset.y(); }
void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
+ void flushText()
+ {
+ alignLeft();
+ alignRight();
+ alignCenter();
+ }
void enableStatusBar(){ showStatusBar = true; }
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,
children[i]->render(info, viewport);
if(!noBreak && !breakFlag)
viewport->newLine();
+ else
+ viewport->flushText();
if(breakFlag)
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
# Stuff for the parse lib
libskin_parser.commands = @$(MAKE) \
- TARGET_DIR=$$MYBUILDDIR CC=\"$$QMAKE_CC\" \
+ TARGET_DIR=$$MYBUILDDIR \
+ CC=\"$$QMAKE_CC\" \
BUILDDIR=$$OBJECTS_DIR \
- -C $$RBBASE_DIR/lib/skin_parser \
+ -C \
+ $$RBBASE_DIR/lib/skin_parser \
libskin_parser.a
-
QMAKE_EXTRA_TARGETS += libskin_parser
PRE_TARGETDEPS += libskin_parser
INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser
-LIBS += -L$$MYBUILDDIR -lskin_parser
+LIBS += -L$$MYBUILDDIR \
+ -lskin_parser
DEPENDPATH = $$INCLUDEPATH
HEADERS += models/parsetreemodel.h \
models/parsetreenode.h \
@@ -44,7 +46,8 @@ HEADERS += models/parsetreemodel.h \
graphics/rbalbumart.h \
graphics/rbprogressbar.h \
gui/findreplacedialog.h \
- graphics/rbtext.h
+ graphics/rbtext.h \
+ graphics/rbfontcache.h
SOURCES += main.cpp \
models/parsetreemodel.cpp \
models/parsetreenode.cpp \
@@ -65,7 +68,8 @@ SOURCES += main.cpp \
graphics/rbalbumart.cpp \
graphics/rbprogressbar.cpp \
gui/findreplacedialog.cpp \
- graphics/rbtext.cpp
+ graphics/rbtext.cpp \
+ graphics/rbfontcache.cpp
OTHER_FILES += README \
resources/windowicon.png \
resources/appicon.xcf \
@@ -82,16 +86,17 @@ FORMS += gui/editorwindow.ui \
gui/skinviewer.ui \
gui/findreplacedialog.ui
RESOURCES += resources.qrc
-
-win32 {
- RC_FILE = themeeditor.rc
-}
-macx {
- QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
- QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc
- QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386
- CONFIG+=x86 ppc
+win32:RC_FILE = themeeditor.rc
+macx {
+ QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.4u.sdk
+ QMAKE_LFLAGS_PPC = -mmacosx-version-min=10.4 \
+ -arch \
+ ppc
+ QMAKE_LFLAGS_X86 = -mmacosx-version-min=10.4 \
+ -arch \
+ i386
+ CONFIG += x86 \
+ ppc
QMAKE_INFO_PLIST = Info.plist
RC_FILE = resources/windowicon.icns
}
-