forked from len0rd/rockbox
Theme Editor: Added coordinate display when moving mouse around preview window
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27738 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
76d1377d04
commit
df1ff115f5
10 changed files with 130 additions and 9 deletions
36
utils/themeeditor/graphics/rbscene.cpp
Normal file
36
utils/themeeditor/graphics/rbscene.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* 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 <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "rbscene.h"
|
||||||
|
|
||||||
|
RBScene::RBScene(QObject* parent)
|
||||||
|
: QGraphicsScene(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RBScene::~RBScene()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
41
utils/themeeditor/graphics/rbscene.h
Normal file
41
utils/themeeditor/graphics/rbscene.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* 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 RBSCENE_H
|
||||||
|
#define RBSCENE_H
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
|
class RBScene : public QGraphicsScene
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
RBScene(QObject* parent = 0);
|
||||||
|
~RBScene();
|
||||||
|
|
||||||
|
void moveMouse(QString position){ emit mouseMoved(position); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mouseMoved(QString position);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RBSCENE_H
|
|
@ -19,12 +19,15 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "rbscene.h"
|
||||||
#include "rbscreen.h"
|
#include "rbscreen.h"
|
||||||
#include "rbviewport.h"
|
#include "rbviewport.h"
|
||||||
#include "devicestate.h"
|
#include "devicestate.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QGraphicsSceneHoverEvent>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
|
@ -32,6 +35,8 @@ RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
|
||||||
albumArt(0), customUI(0)
|
albumArt(0), customUI(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
if(remote)
|
if(remote)
|
||||||
{
|
{
|
||||||
fullWidth = info.device()->data("remotewidth").toInt();
|
fullWidth = info.device()->data("remotewidth").toInt();
|
||||||
|
@ -265,3 +270,13 @@ QColor RBScreen::stringToColor(QString str, QColor fallback)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RBScreen::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
RBScene* s = dynamic_cast<RBScene*>(scene());
|
||||||
|
QPoint p = event->scenePos().toPoint();
|
||||||
|
s->moveMouse("(" + QString::number(p.x()) + ", "
|
||||||
|
+ QString::number(p.y()) + ")");
|
||||||
|
|
||||||
|
QGraphicsItem::hoverMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
|
@ -88,6 +88,9 @@ public:
|
||||||
|
|
||||||
void breakSBS();
|
void breakSBS();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
TabType type() const{ return Skin; }
|
TabType type() const{ return Skin; }
|
||||||
|
|
||||||
QGraphicsScene* scene()
|
RBScene* scene()
|
||||||
{
|
{
|
||||||
return model->render(project, device, this, &fileName);
|
return model->render(project, device, this, &fileName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,11 +69,15 @@ void SkinViewer::connectSkin(SkinDocument *skin)
|
||||||
QObject::connect(ui->codeUndoButton, SIGNAL(pressed()),
|
QObject::connect(ui->codeUndoButton, SIGNAL(pressed()),
|
||||||
skin, SLOT(parseCode()));
|
skin, SLOT(parseCode()));
|
||||||
|
|
||||||
|
QObject::connect(skin->scene(), SIGNAL(mouseMoved(QString)),
|
||||||
|
ui->coordinateLabel, SLOT(setText(QString)));
|
||||||
|
|
||||||
doc = skin;
|
doc = skin;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->viewer->setScene(0);
|
ui->viewer->setScene(0);
|
||||||
|
ui->coordinateLabel->setText("");
|
||||||
|
|
||||||
doc = 0;
|
doc = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,26 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="coordinateLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -44,7 +44,7 @@ ParseTreeModel::ParseTreeModel(const char* document, QObject* parent):
|
||||||
else
|
else
|
||||||
this->root = 0;
|
this->root = 0;
|
||||||
|
|
||||||
scene = new QGraphicsScene();
|
scene = new RBScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsScene* ParseTreeModel::render(ProjectModel* project,
|
RBScene* ParseTreeModel::render(ProjectModel* project,
|
||||||
DeviceState* device,
|
DeviceState* device,
|
||||||
SkinDocument* doc, const QString* file)
|
SkinDocument* doc, const QString* file)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QGraphicsScene>
|
|
||||||
|
|
||||||
#include "parsetreenode.h"
|
#include "parsetreenode.h"
|
||||||
#include "devicestate.h"
|
#include "devicestate.h"
|
||||||
|
#include "rbscene.h"
|
||||||
|
|
||||||
class ParseTreeModel : public QAbstractItemModel
|
class ParseTreeModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
|
@ -64,8 +64,8 @@ public:
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
|
||||||
QGraphicsScene* render(ProjectModel* project, DeviceState* device,
|
RBScene* render(ProjectModel* project, DeviceState* device,
|
||||||
SkinDocument* doc, const QString* file = 0);
|
SkinDocument* doc, const QString* file = 0);
|
||||||
|
|
||||||
static QString safeSetting(ProjectModel* project, QString key,
|
static QString safeSetting(ProjectModel* project, QString key,
|
||||||
QString fallback)
|
QString fallback)
|
||||||
|
@ -85,7 +85,7 @@ private:
|
||||||
ParseTreeNode* root;
|
ParseTreeNode* root;
|
||||||
ParseTreeModel* sbsModel;
|
ParseTreeModel* sbsModel;
|
||||||
struct skin_element* tree;
|
struct skin_element* tree;
|
||||||
QGraphicsScene* scene;
|
RBScene* scene;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,8 @@ HEADERS += models/parsetreemodel.h \
|
||||||
gui/projectexporter.h \
|
gui/projectexporter.h \
|
||||||
gui/targetdownloader.h \
|
gui/targetdownloader.h \
|
||||||
gui/syntaxcompleter.h \
|
gui/syntaxcompleter.h \
|
||||||
graphics/rbmovable.h
|
graphics/rbmovable.h \
|
||||||
|
graphics/rbscene.h
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
models/parsetreemodel.cpp \
|
models/parsetreemodel.cpp \
|
||||||
models/parsetreenode.cpp \
|
models/parsetreenode.cpp \
|
||||||
|
@ -149,7 +150,8 @@ SOURCES += main.cpp \
|
||||||
gui/projectexporter.cpp \
|
gui/projectexporter.cpp \
|
||||||
gui/targetdownloader.cpp \
|
gui/targetdownloader.cpp \
|
||||||
gui/syntaxcompleter.cpp \
|
gui/syntaxcompleter.cpp \
|
||||||
graphics/rbmovable.cpp
|
graphics/rbmovable.cpp \
|
||||||
|
graphics/rbscene.cpp
|
||||||
OTHER_FILES += README \
|
OTHER_FILES += README \
|
||||||
resources/windowicon.png \
|
resources/windowicon.png \
|
||||||
resources/appicon.xcf \
|
resources/appicon.xcf \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue