forked from len0rd/rockbox
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
This commit is contained in:
parent
88145656fb
commit
6f06793f58
6 changed files with 124 additions and 22 deletions
|
@ -20,6 +20,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "rbfont.h"
|
#include "rbfont.h"
|
||||||
|
#include "rbfontcache.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
@ -29,6 +30,8 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
|
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
|
||||||
|
|
||||||
RBFont::RBFont(QString file)
|
RBFont::RBFont(QString file)
|
||||||
|
@ -52,6 +55,18 @@ RBFont::RBFont(QString file)
|
||||||
}
|
}
|
||||||
header.insert("filename", 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 */
|
/* Opening the file */
|
||||||
QFile fin(file);
|
QFile fin(file);
|
||||||
fin.open(QFile::ReadOnly);
|
fin.open(QFile::ReadOnly);
|
||||||
|
@ -134,16 +149,18 @@ RBFont::RBFont(QString file)
|
||||||
|
|
||||||
fin.close();
|
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()
|
RBFont::~RBFont()
|
||||||
{
|
{
|
||||||
if(imageData)
|
|
||||||
delete[] imageData;
|
|
||||||
if(offsetData)
|
|
||||||
delete[] offsetData;
|
|
||||||
if(widthData)
|
|
||||||
delete[] widthData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
|
RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
|
||||||
|
|
24
utils/themeeditor/graphics/rbfontcache.cpp
Normal file
24
utils/themeeditor/graphics/rbfontcache.cpp
Normal file
|
@ -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;
|
48
utils/themeeditor/graphics/rbfontcache.h
Normal file
48
utils/themeeditor/graphics/rbfontcache.h
Normal file
|
@ -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
|
|
@ -60,6 +60,12 @@ public:
|
||||||
void alignText(Alignment align){ textAlign = align; }
|
void alignText(Alignment align){ textAlign = align; }
|
||||||
int getTextOffset(){ return textOffset.y(); }
|
int getTextOffset(){ return textOffset.y(); }
|
||||||
void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
|
void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
|
||||||
|
void flushText()
|
||||||
|
{
|
||||||
|
alignLeft();
|
||||||
|
alignRight();
|
||||||
|
alignCenter();
|
||||||
|
}
|
||||||
|
|
||||||
void enableStatusBar(){ showStatusBar = true; }
|
void enableStatusBar(){ showStatusBar = true; }
|
||||||
|
|
||||||
|
|
|
@ -523,6 +523,8 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport,
|
||||||
children[i]->render(info, viewport);
|
children[i]->render(info, viewport);
|
||||||
if(!noBreak && !breakFlag)
|
if(!noBreak && !breakFlag)
|
||||||
viewport->newLine();
|
viewport->newLine();
|
||||||
|
else
|
||||||
|
viewport->flushText();
|
||||||
|
|
||||||
if(breakFlag)
|
if(breakFlag)
|
||||||
breakFlag = false;
|
breakFlag = false;
|
||||||
|
|
|
@ -14,15 +14,17 @@ INCLUDEPATH += graphics
|
||||||
|
|
||||||
# Stuff for the parse lib
|
# Stuff for the parse lib
|
||||||
libskin_parser.commands = @$(MAKE) \
|
libskin_parser.commands = @$(MAKE) \
|
||||||
TARGET_DIR=$$MYBUILDDIR CC=\"$$QMAKE_CC\" \
|
TARGET_DIR=$$MYBUILDDIR \
|
||||||
|
CC=\"$$QMAKE_CC\" \
|
||||||
BUILDDIR=$$OBJECTS_DIR \
|
BUILDDIR=$$OBJECTS_DIR \
|
||||||
-C $$RBBASE_DIR/lib/skin_parser \
|
-C \
|
||||||
|
$$RBBASE_DIR/lib/skin_parser \
|
||||||
libskin_parser.a
|
libskin_parser.a
|
||||||
|
|
||||||
QMAKE_EXTRA_TARGETS += libskin_parser
|
QMAKE_EXTRA_TARGETS += libskin_parser
|
||||||
PRE_TARGETDEPS += libskin_parser
|
PRE_TARGETDEPS += libskin_parser
|
||||||
INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser
|
INCLUDEPATH += $$RBBASE_DIR/lib/skin_parser
|
||||||
LIBS += -L$$MYBUILDDIR -lskin_parser
|
LIBS += -L$$MYBUILDDIR \
|
||||||
|
-lskin_parser
|
||||||
DEPENDPATH = $$INCLUDEPATH
|
DEPENDPATH = $$INCLUDEPATH
|
||||||
HEADERS += models/parsetreemodel.h \
|
HEADERS += models/parsetreemodel.h \
|
||||||
models/parsetreenode.h \
|
models/parsetreenode.h \
|
||||||
|
@ -44,7 +46,8 @@ HEADERS += models/parsetreemodel.h \
|
||||||
graphics/rbalbumart.h \
|
graphics/rbalbumart.h \
|
||||||
graphics/rbprogressbar.h \
|
graphics/rbprogressbar.h \
|
||||||
gui/findreplacedialog.h \
|
gui/findreplacedialog.h \
|
||||||
graphics/rbtext.h
|
graphics/rbtext.h \
|
||||||
|
graphics/rbfontcache.h
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
models/parsetreemodel.cpp \
|
models/parsetreemodel.cpp \
|
||||||
models/parsetreenode.cpp \
|
models/parsetreenode.cpp \
|
||||||
|
@ -65,7 +68,8 @@ SOURCES += main.cpp \
|
||||||
graphics/rbalbumart.cpp \
|
graphics/rbalbumart.cpp \
|
||||||
graphics/rbprogressbar.cpp \
|
graphics/rbprogressbar.cpp \
|
||||||
gui/findreplacedialog.cpp \
|
gui/findreplacedialog.cpp \
|
||||||
graphics/rbtext.cpp
|
graphics/rbtext.cpp \
|
||||||
|
graphics/rbfontcache.cpp
|
||||||
OTHER_FILES += README \
|
OTHER_FILES += README \
|
||||||
resources/windowicon.png \
|
resources/windowicon.png \
|
||||||
resources/appicon.xcf \
|
resources/appicon.xcf \
|
||||||
|
@ -82,16 +86,17 @@ FORMS += gui/editorwindow.ui \
|
||||||
gui/skinviewer.ui \
|
gui/skinviewer.ui \
|
||||||
gui/findreplacedialog.ui
|
gui/findreplacedialog.ui
|
||||||
RESOURCES += resources.qrc
|
RESOURCES += resources.qrc
|
||||||
|
win32:RC_FILE = themeeditor.rc
|
||||||
win32 {
|
macx {
|
||||||
RC_FILE = themeeditor.rc
|
QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.4u.sdk
|
||||||
}
|
QMAKE_LFLAGS_PPC = -mmacosx-version-min=10.4 \
|
||||||
macx {
|
-arch \
|
||||||
QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
|
ppc
|
||||||
QMAKE_LFLAGS_PPC=-mmacosx-version-min=10.4 -arch ppc
|
QMAKE_LFLAGS_X86 = -mmacosx-version-min=10.4 \
|
||||||
QMAKE_LFLAGS_X86=-mmacosx-version-min=10.4 -arch i386
|
-arch \
|
||||||
CONFIG+=x86 ppc
|
i386
|
||||||
|
CONFIG += x86 \
|
||||||
|
ppc
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
RC_FILE = resources/windowicon.icns
|
RC_FILE = resources/windowicon.icns
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue