paysages : Added a tooltip for preview OSD items.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@363 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
b1ae9394d2
commit
f5d2396256
7 changed files with 110 additions and 29 deletions
1
TODO
1
TODO
|
@ -17,7 +17,6 @@ Technology Preview 2 :
|
||||||
- Improve previews.
|
- Improve previews.
|
||||||
=> Add a right click menu for toggles and modes
|
=> Add a right click menu for toggles and modes
|
||||||
=> Add user markers on OSD
|
=> Add user markers on OSD
|
||||||
=> Add a tooltip for OSD items
|
|
||||||
- Add a zone editor dialog for localized textures.
|
- Add a zone editor dialog for localized textures.
|
||||||
- Add a terrain modifier dialog with zones.
|
- Add a terrain modifier dialog with zones.
|
||||||
- Use the curve editor in noise editor
|
- Use the curve editor in noise editor
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
#include <qt4/QtGui/qlabel.h>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
/*************** PreviewChunk ***************/
|
/*************** PreviewChunk ***************/
|
||||||
|
@ -277,6 +278,10 @@ QWidget(parent)
|
||||||
_height = height();
|
_height = height();
|
||||||
_revision = 0;
|
_revision = 0;
|
||||||
|
|
||||||
|
_info = new QLabel(this);
|
||||||
|
_info->setVisible(false);
|
||||||
|
_info->setStyleSheet("QLabel { background-color: white; color: black; }");
|
||||||
|
|
||||||
this->alive = true;
|
this->alive = true;
|
||||||
|
|
||||||
QObject::connect(this, SIGNAL(contentChange()), this, SLOT(update()));
|
QObject::connect(this, SIGNAL(contentChange()), this, SLOT(update()));
|
||||||
|
@ -293,6 +298,7 @@ BasePreview::~BasePreview()
|
||||||
|
|
||||||
_drawing_manager->removeChunks(this);
|
_drawing_manager->removeChunks(this);
|
||||||
|
|
||||||
|
delete _info;
|
||||||
delete pixbuf;
|
delete pixbuf;
|
||||||
delete lock_drawing;
|
delete lock_drawing;
|
||||||
}
|
}
|
||||||
|
@ -300,6 +306,7 @@ BasePreview::~BasePreview()
|
||||||
void BasePreview::addOsd(QString name)
|
void BasePreview::addOsd(QString name)
|
||||||
{
|
{
|
||||||
_osd.append(PreviewOsd::getInstance(name));
|
_osd.append(PreviewOsd::getInstance(name));
|
||||||
|
setMouseTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::initDrawers()
|
void BasePreview::initDrawers()
|
||||||
|
@ -502,12 +509,16 @@ void BasePreview::mousePressEvent(QMouseEvent* event)
|
||||||
|
|
||||||
void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
int dx, dy;
|
|
||||||
int ndx, ndy;
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
width = this->width();
|
||||||
|
height = this->height();
|
||||||
|
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
|
int dx, dy;
|
||||||
|
int ndx, ndy;
|
||||||
|
|
||||||
dx = event->x() - mousex;
|
dx = event->x() - mousex;
|
||||||
dy = event->y() - mousey;
|
dy = event->y() - mousey;
|
||||||
|
|
||||||
|
@ -531,9 +542,6 @@ void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
||||||
}
|
}
|
||||||
if (ndx != 0 || ndy != 0)
|
if (ndx != 0 || ndy != 0)
|
||||||
{
|
{
|
||||||
width = this->width();
|
|
||||||
height = this->height();
|
|
||||||
|
|
||||||
if (ndx <= -width || ndx >= width || ndy <= -height || ndy >= height)
|
if (ndx <= -width || ndx >= width || ndy <= -height || ndy >= height)
|
||||||
{
|
{
|
||||||
xoffset -= (double) ndx * scaling;
|
xoffset -= (double) ndx * scaling;
|
||||||
|
@ -589,6 +597,28 @@ void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
||||||
mousex = event->x();
|
mousex = event->x();
|
||||||
mousey = event->y();
|
mousey = event->y();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get text info from OSD
|
||||||
|
bool found = false;
|
||||||
|
for (int i = 0; i < _osd.size(); i++)
|
||||||
|
{
|
||||||
|
double x = xoffset + (event->x() - width / 2) * scaling;
|
||||||
|
double y = yoffset + (event->y() - height / 2) * scaling;
|
||||||
|
QString info = _osd[i]->getToolTip(x, y, scaling);
|
||||||
|
if (not info.isEmpty())
|
||||||
|
{
|
||||||
|
_info->setText(info);
|
||||||
|
_info->setVisible(true);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (not found)
|
||||||
|
{
|
||||||
|
_info->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePreview::wheelEvent(QWheelEvent* event)
|
void BasePreview::wheelEvent(QWheelEvent* event)
|
||||||
|
@ -676,3 +706,8 @@ void BasePreview::wheelEvent(QWheelEvent* event)
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasePreview::leaveEvent(QEvent* event)
|
||||||
|
{
|
||||||
|
_info->setVisible(false);
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QLabel>
|
||||||
#include "previewosd.h"
|
#include "previewosd.h"
|
||||||
|
|
||||||
class BasePreview : public QWidget {
|
class BasePreview : public QWidget {
|
||||||
|
@ -52,11 +53,14 @@ private:
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
void wheelEvent(QWheelEvent* event);
|
void wheelEvent(QWheelEvent* event);
|
||||||
|
void leaveEvent(QEvent* event);
|
||||||
|
|
||||||
QMutex* lock_drawing;
|
QMutex* lock_drawing;
|
||||||
QImage* pixbuf;
|
QImage* pixbuf;
|
||||||
QVector<PreviewOsd*> _osd;
|
QVector<PreviewOsd*> _osd;
|
||||||
|
|
||||||
|
QLabel* _info;
|
||||||
|
|
||||||
int _width;
|
int _width;
|
||||||
int _height;
|
int _height;
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,9 @@ void MainWindow::refreshAll()
|
||||||
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
|
PreviewOsd* osd = PreviewOsd::getInstance(QString("geolocation"));
|
||||||
osd->clearItems();
|
osd->clearItems();
|
||||||
sceneryGetCamera(&camera);
|
sceneryGetCamera(&camera);
|
||||||
osd->newItem(50, 50)->drawCamera(&camera);
|
PreviewOsdItem* item = osd->newItem(50, 50);
|
||||||
|
item->drawCamera(&camera);
|
||||||
|
item->setToolTip(QString(tr("Camera")));
|
||||||
cameraDeleteDefinition(&camera);
|
cameraDeleteDefinition(&camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,23 @@ void PreviewOsdItem::drawCamera(CameraDefinition* camera)
|
||||||
painter.drawLine(w2, h2, w2 + w2 * cos(camera->yaw + M_PI_4), h2 - h2 * sin(camera->yaw + M_PI_4));
|
painter.drawLine(w2, h2, w2 + w2 * cos(camera->yaw + M_PI_4), h2 - h2 * sin(camera->yaw + M_PI_4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewOsdItem::setToolTip(QString text)
|
||||||
|
{
|
||||||
|
_tooltip = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PreviewOsdItem::getToolTip(double x, double y, double scaling)
|
||||||
|
{
|
||||||
|
if (_tooltip.isEmpty() or (x > _xlocation - (width() / 2) * scaling and x < _xlocation + (width() / 2) * scaling and y > _ylocation - (height() / 2) * scaling and y < _ylocation + (height() / 2) * scaling))
|
||||||
|
{
|
||||||
|
return _tooltip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************** PreviewOsd ***************/
|
/*************** PreviewOsd ***************/
|
||||||
PreviewOsd::PreviewOsd()
|
PreviewOsd::PreviewOsd()
|
||||||
{
|
{
|
||||||
|
@ -98,3 +115,17 @@ void PreviewOsd::apply(QImage* mask, double xoffset, double yoffset, double scal
|
||||||
painter.drawImage(x, y, *item);
|
painter.drawImage(x, y, *item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PreviewOsd::getToolTip(double x, double y, double scaling)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _items.size(); i++)
|
||||||
|
{
|
||||||
|
PreviewOsdItem* item = _items[i];
|
||||||
|
QString tooltip = item->getToolTip(x, y, scaling);
|
||||||
|
if (not tooltip.isEmpty())
|
||||||
|
{
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
|
@ -13,11 +13,15 @@ public:
|
||||||
inline double xlocation() {return _xlocation;};
|
inline double xlocation() {return _xlocation;};
|
||||||
inline double ylocation() {return _ylocation;};
|
inline double ylocation() {return _ylocation;};
|
||||||
|
|
||||||
|
void setToolTip(QString text);
|
||||||
|
QString getToolTip(double x, double y, double scaling);
|
||||||
|
|
||||||
void drawCamera(CameraDefinition* camera);
|
void drawCamera(CameraDefinition* camera);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double _xlocation;
|
double _xlocation;
|
||||||
double _ylocation;
|
double _ylocation;
|
||||||
|
QString _tooltip;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreviewOsd
|
class PreviewOsd
|
||||||
|
@ -32,6 +36,7 @@ public:
|
||||||
PreviewOsdItem* newItem(int width, int height);
|
PreviewOsdItem* newItem(int width, int height);
|
||||||
PreviewOsdItem* newItem(QImage image);
|
PreviewOsdItem* newItem(QImage image);
|
||||||
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
|
void apply(QImage* mask, double xoffset, double yoffset, double scaling);
|
||||||
|
QString getToolTip(double x, double y, double scaling);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<PreviewOsdItem*> _items;
|
QVector<PreviewOsdItem*> _items;
|
||||||
|
|
|
@ -1007,87 +1007,92 @@ rapide (F5)</translation>
|
||||||
<translation>F5</translation>
|
<translation>F5</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="166"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="162"/>
|
||||||
|
<source>Camera</source>
|
||||||
|
<translation type="unfinished">Caméra</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../gui_qt/mainwindow.cpp" line="168"/>
|
||||||
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
|
<source>Do you want to start a new scenery ? Any unsaved changes will be lost.</source>
|
||||||
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
|
<translation>Voulez-vous commencer un nouveau paysage ? Les modifications non sauvegardées seront perdues.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="166"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="168"/>
|
||||||
<source>Paysages 3D - New scenery</source>
|
<source>Paysages 3D - New scenery</source>
|
||||||
<translation>Paysages 3D - Nouvelle scène</translation>
|
<translation>Paysages 3D - Nouvelle scène</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="176"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="178"/>
|
||||||
<source>Paysages 3D - Choose a file to save the scenery</source>
|
<source>Paysages 3D - Choose a file to save the scenery</source>
|
||||||
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
|
<translation>Paysages 3D - Choisissez un fichier pour enregistrer la scène</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="176"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="178"/>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="202"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="204"/>
|
||||||
<source>Paysages 3D Scenery (*.p3d)</source>
|
<source>Paysages 3D Scenery (*.p3d)</source>
|
||||||
<translation>Scène Paysages 3D (*.p3d)</translation>
|
<translation>Scène Paysages 3D (*.p3d)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="190"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="193"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
|
||||||
<source>Paysages 3D - File saving error</source>
|
<source>Paysages 3D - File saving error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="190"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="192"/>
|
||||||
<source>Can't write specified file : %1</source>
|
<source>Can't write specified file : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="193"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="195"/>
|
||||||
<source>Unexpected error while saving file : %1</source>
|
<source>Unexpected error while saving file : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="200"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="202"/>
|
||||||
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
|
<source>Do you want to load a scenery from file ? Any unsaved changes will be lost.</source>
|
||||||
<translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation>
|
<translation>Voulez-vous charger une scène ? Les modifications non sauvegardées seront perdues.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="200"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="202"/>
|
||||||
<source>Paysages 3D - Load scenery</source>
|
<source>Paysages 3D - Load scenery</source>
|
||||||
<translation>Paysages 3D - Charger une scène</translation>
|
<translation>Paysages 3D - Charger une scène</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="202"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="204"/>
|
||||||
<source>Paysages 3D - Choose a scenery file to load</source>
|
<source>Paysages 3D - Choose a scenery file to load</source>
|
||||||
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
|
<translation>Paysages 3D - Choisissez un fichier de scène à charger</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="212"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="214"/>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="215"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="217"/>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="218"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="220"/>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="221"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="223"/>
|
||||||
<source>Paysages 3D - File loading error</source>
|
<source>Paysages 3D - File loading error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="212"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="214"/>
|
||||||
<source>Can't read specified file : %1</source>
|
<source>Can't read specified file : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="215"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="217"/>
|
||||||
<source>This file doesn't look like a Paysages 3D file : %1</source>
|
<source>This file doesn't look like a Paysages 3D file : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="218"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="220"/>
|
||||||
<source>This file was created with an incompatible Paysages 3D version : %1</source>
|
<source>This file was created with an incompatible Paysages 3D version : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="221"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="223"/>
|
||||||
<source>Unexpected error while loading file : %1</source>
|
<source>Unexpected error while loading file : %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="229"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="231"/>
|
||||||
<source>A 3D landscape editing and rendering software.
|
<source>A 3D landscape editing and rendering software.
|
||||||
|
|
||||||
Authors :
|
Authors :
|
||||||
|
@ -1197,7 +1202,7 @@ GLib - http://www.gtk.org/
|
||||||
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
|
<translation type="obsolete">Voulez-vous charger un paysage ? Les modifications nons sauvegardées seront perdues.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui_qt/mainwindow.cpp" line="229"/>
|
<location filename="../gui_qt/mainwindow.cpp" line="231"/>
|
||||||
<source>Paysages 3D</source>
|
<source>Paysages 3D</source>
|
||||||
<translation>Paysages 3D</translation>
|
<translation>Paysages 3D</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Loading…
Reference in a new issue