mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Theme Editor: SBS will now render underneath WPS, if both are present in project
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27265 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8da13a5d4b
commit
2f68e5be59
6 changed files with 88 additions and 10 deletions
|
@ -29,18 +29,18 @@
|
||||||
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:QGraphicsItem(parent), backdrop(0), project(project),
|
:QGraphicsItem(parent), backdrop(0), project(project),
|
||||||
albumArt(0)
|
albumArt(0), customUI(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(remote)
|
if(remote)
|
||||||
{
|
{
|
||||||
width = info.device()->data("remotewidth").toInt();
|
fullWidth = info.device()->data("remotewidth").toInt();
|
||||||
height = info.device()->data("remoteheight").toInt();
|
fullHeight = info.device()->data("remoteheight").toInt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
width = info.device()->data("screenwidth").toInt();
|
fullWidth = info.device()->data("screenwidth").toInt();
|
||||||
height = info.device()->data("screenheight").toInt();
|
fullHeight = info.device()->data("screenheight").toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString bg = info.settings()->value("background color", "FFFFFF");
|
QString bg = info.settings()->value("background color", "FFFFFF");
|
||||||
|
@ -63,8 +63,8 @@ RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
||||||
/* If a backdrop has been found, use its width and height */
|
/* If a backdrop has been found, use its width and height */
|
||||||
if(!backdrop->isNull())
|
if(!backdrop->isNull())
|
||||||
{
|
{
|
||||||
width = backdrop->width();
|
fullWidth = backdrop->width();
|
||||||
height = backdrop->height();
|
fullHeight = backdrop->height();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,17 @@ RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
||||||
}
|
}
|
||||||
|
|
||||||
fonts.insert(0, new RBFont("Nothin'"));
|
fonts.insert(0, new RBFont("Nothin'"));
|
||||||
|
|
||||||
|
if(parent == 0)
|
||||||
|
{
|
||||||
|
width = fullWidth;
|
||||||
|
height = fullHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = parent->boundingRect().width();
|
||||||
|
height = parent->boundingRect().height();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RBScreen::~RBScreen()
|
RBScreen::~RBScreen()
|
||||||
|
@ -108,6 +119,9 @@ QRectF RBScreen::boundingRect() const
|
||||||
void RBScreen::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void RBScreen::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget)
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
|
if(parentItem() != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if(backdrop)
|
if(backdrop)
|
||||||
{
|
{
|
||||||
painter->drawPixmap(0, 0, width, height, *backdrop);
|
painter->drawPixmap(0, 0, width, height, *backdrop);
|
||||||
|
@ -191,9 +205,18 @@ void RBScreen::makeCustomUI(QString id)
|
||||||
namedViewports.value(id)->at(i)->makeCustomUI();
|
namedViewports.value(id)->at(i)->makeCustomUI();
|
||||||
for(int i = 0; i < namedViewports.value(id)->count(); i++)
|
for(int i = 0; i < namedViewports.value(id)->count(); i++)
|
||||||
namedViewports.value(id)->at(i)->show();
|
namedViewports.value(id)->at(i)->show();
|
||||||
|
|
||||||
|
customUI = namedViewports.value(id)->at(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RBScreen::breakSBS()
|
||||||
|
{
|
||||||
|
width = fullWidth;
|
||||||
|
height = fullHeight;
|
||||||
|
setParentItem(0);
|
||||||
|
}
|
||||||
|
|
||||||
QColor RBScreen::stringToColor(QString str, QColor fallback)
|
QColor RBScreen::stringToColor(QString str, QColor fallback)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ public:
|
||||||
void setBackdrop(QString filename);
|
void setBackdrop(QString filename);
|
||||||
bool hasBackdrop(){ return backdrop != 0; }
|
bool hasBackdrop(){ return backdrop != 0; }
|
||||||
void makeCustomUI(QString id);
|
void makeCustomUI(QString id);
|
||||||
|
void setCustomUI(RBViewport* viewport){ customUI = viewport; }
|
||||||
|
RBViewport* getCustomUI(){ return customUI; }
|
||||||
|
|
||||||
static QColor stringToColor(QString str, QColor fallback);
|
static QColor stringToColor(QString str, QColor fallback);
|
||||||
|
|
||||||
|
@ -84,10 +86,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void breakSBS();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
int fullWidth;
|
||||||
|
int fullHeight;
|
||||||
QColor bgColor;
|
QColor bgColor;
|
||||||
QColor fgColor;
|
QColor fgColor;
|
||||||
QPixmap* backdrop;
|
QPixmap* backdrop;
|
||||||
|
@ -102,6 +107,7 @@ private:
|
||||||
QList<QString> displayedViewports;
|
QList<QString> displayedViewports;
|
||||||
|
|
||||||
RBAlbumArt* albumArt;
|
RBAlbumArt* albumArt;
|
||||||
|
RBViewport* customUI;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RBSCREEN_H
|
#endif // RBSCREEN_H
|
||||||
|
|
|
@ -113,12 +113,22 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
|
||||||
if(h < 0)
|
if(h < 0)
|
||||||
h = info.screen()->getHeight() + h - y;
|
h = info.screen()->getHeight() + h - y;
|
||||||
|
|
||||||
|
/* Adjusting to screen coordinates if necessary */
|
||||||
|
if(screen->parentItem() != 0)
|
||||||
|
{
|
||||||
|
x -= screen->parentItem()->pos().x();
|
||||||
|
y -= screen->parentItem()->pos().y();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
size = QRectF(0, 0, w, h);
|
size = QRectF(0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug = info.device()->data("showviewports").toBool();
|
debug = info.device()->data("showviewports").toBool();
|
||||||
lineHeight = font->lineHeight();
|
lineHeight = font->lineHeight();
|
||||||
|
if(customUI)
|
||||||
|
screen->setCustomUI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
RBViewport::~RBViewport()
|
RBViewport::~RBViewport()
|
||||||
|
|
|
@ -290,7 +290,9 @@ QGraphicsScene* ParseTreeModel::render(ProjectModel* project,
|
||||||
settings.insert("themebase", base.canonicalPath());
|
settings.insert("themebase", base.canonicalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Finding imagebase and determining remote/wps status */
|
||||||
bool remote = false;
|
bool remote = false;
|
||||||
|
bool wps = false;
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
QString skinFile = *file;
|
QString skinFile = *file;
|
||||||
|
@ -304,14 +306,50 @@ QGraphicsScene* ParseTreeModel::render(ProjectModel* project,
|
||||||
QString extension = decomp.last();
|
QString extension = decomp.last();
|
||||||
if(extension[0] == 'r')
|
if(extension[0] == 'r')
|
||||||
remote = true;
|
remote = true;
|
||||||
|
if(extension.right(3) == "wps")
|
||||||
|
wps = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rendering SBS, if necessary */
|
||||||
|
RBScreen* sbsScreen = 0;
|
||||||
|
if(wps && device->data("rendersbs").toBool())
|
||||||
|
{
|
||||||
|
QString sbsFile = settings.value(remote ? "rsbs" : "sbs", "");
|
||||||
|
sbsFile.replace("/.rockbox" , settings.value("themebase",""));
|
||||||
|
|
||||||
|
if(QFile::exists(sbsFile))
|
||||||
|
{
|
||||||
|
QFile sbs(sbsFile);
|
||||||
|
sbs.open(QFile::ReadOnly | QFile::Text);
|
||||||
|
ParseTreeModel sbsModel(QString(sbs.readAll()).toAscii());
|
||||||
|
|
||||||
|
if(sbsModel.root != 0)
|
||||||
|
{
|
||||||
|
RBRenderInfo sbsInfo(&sbsModel, project, &settings, device,
|
||||||
|
sbsScreen);
|
||||||
|
|
||||||
|
sbsScreen = new RBScreen(sbsInfo, remote);
|
||||||
|
scene->addItem(sbsScreen);
|
||||||
|
|
||||||
|
sbsInfo = RBRenderInfo(&sbsModel, project, &settings, device,
|
||||||
|
sbsScreen);
|
||||||
|
sbsModel.root->render(sbsInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RBScreen* screen = 0;
|
RBScreen* screen = 0;
|
||||||
RBRenderInfo info(this, project, &settings, device, screen);
|
RBRenderInfo info(this, project, &settings, device, screen);
|
||||||
|
|
||||||
/* Adding the screen */
|
/* Adding the screen */
|
||||||
screen = new RBScreen(info, remote);
|
if(sbsScreen)
|
||||||
scene->addItem(screen);
|
screen = new RBScreen(info, remote, sbsScreen->getCustomUI());
|
||||||
|
else
|
||||||
|
screen = new RBScreen(info, remote);
|
||||||
|
|
||||||
|
if(!sbsScreen)
|
||||||
|
scene->addItem(screen);
|
||||||
|
|
||||||
info = RBRenderInfo(this, project, &settings, device, screen);
|
info = RBRenderInfo(this, project, &settings, device, screen);
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
/* %wd */
|
/* %wd */
|
||||||
/* Disable SBS rendering */
|
info.screen()->breakSBS();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
|
|
|
@ -36,6 +36,7 @@ screenheight ; Screen Height ; spin(0,800) ; 200
|
||||||
remotewidth ; Remote Width ; spin(0,800) ; 100
|
remotewidth ; Remote Width ; spin(0,800) ; 100
|
||||||
remoteheight ; Remote Height ; spin(0,800); 50
|
remoteheight ; Remote Height ; spin(0,800); 50
|
||||||
showviewports ; Show Viewports ; check ; false
|
showviewports ; Show Viewports ; check ; false
|
||||||
|
rendersbs ; Render SBS If Available ; check ; true
|
||||||
|
|
||||||
[ID3 Info]
|
[ID3 Info]
|
||||||
ia ; Artist ; text ; Current Artist
|
ia ; Artist ; text ; Current Artist
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue