WIP on QtQuick toolbars
This commit is contained in:
parent
d909ff380f
commit
2251db361c
18 changed files with 282 additions and 39 deletions
BIN
graphics/icons.png
Normal file
BIN
graphics/icons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
99
graphics/icons.svg
Normal file
99
graphics/icons.svg
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="icons.svg"
|
||||
inkscape:export-filename="/home/michael/workspace/paysages3d/graphics/icons.png"
|
||||
inkscape:export-xdpi="154.89854"
|
||||
inkscape:export-ydpi="154.89854">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="3.959798"
|
||||
inkscape:cx="170.49504"
|
||||
inkscape:cy="957.94588"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1030"
|
||||
inkscape:window-x="1440"
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="1"
|
||||
showguides="true">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3004" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="fill:#000000;stroke:#000000;stroke-width:3.7;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 55,32.362183 c -10,35 -25,40 -25,50 0,10 5.355339,25.254827 23.790623,25.254827 C 72.225907,107.61701 80,92.362183 80,82.362183 c 0,-10 -15,-15 -25,-50 z"
|
||||
id="path3006"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="czzzc" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 46.711902,68.575386 c -4.70494,1.249464 -15,15 -10,15 5,0 10,5 10,5 -1.6011,-6.345755 4.41534,-10.613999 10,-15 0,0 -5.29506,-6.249464 -10,-5 z"
|
||||
id="path3776"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="zzccz" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:4.319;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 140.61815,83.142861 c 0,0 10.6138,-9.86109 20.06933,-9.708785 17.76848,0.286206 17.35284,19.13136 35.12131,19.417571 18.91107,0.304603 21.21711,-19.417571 40.13865,-19.417571 18.92154,0 21.2171,19.417571 40.13864,19.417571 9.46077,0 20.06933,-9.708786 20.06933,-9.708786"
|
||||
id="path3780"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="caaaac" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:4.319;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 153.97268,88.56225 c 0,0 10.6138,-9.861089 20.06933,-9.708784 17.76847,0.286206 17.35284,19.13136 35.12131,19.417571 18.91106,0.304603 21.21711,-19.417571 40.13865,-19.417571 18.92153,0 21.2171,19.417571 40.13864,19.417571 9.46077,0 20.06933,-9.708787 20.06933,-9.708787"
|
||||
id="path3780-5"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="caaaac" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:4.319;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 167.88393,94.110016 c 0,0 10.6138,-9.86109 20.06933,-9.708785 17.76847,0.286206 17.35284,19.131359 35.12131,19.417569 18.91106,0.30461 21.21711,-19.417569 40.13865,-19.417569 18.92153,0 21.2171,19.417569 40.13864,19.417569 9.46077,0 20.06933,-9.708784 20.06933,-9.708784"
|
||||
id="path3780-3"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="caaaac" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:3.58400011;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 185.73773,125.20138 0,-77.092101 -25.69737,0 38.54605,-32.121711 38.54605,32.121711 -25.69736,0 0,77.092101 25.69736,0 -38.54605,32.12171 -38.54605,-32.12171 z"
|
||||
id="path3807"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccccccccc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
24
src/interface/modeler/quickapp/MainModelerWindow.cpp
Normal file
24
src/interface/modeler/quickapp/MainModelerWindow.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "MainModelerWindow.h"
|
||||
|
||||
#include "OpenGLView.h"
|
||||
#include "Scenery.h"
|
||||
#include "OpenGLRenderer.h"
|
||||
|
||||
MainModelerWindow::MainModelerWindow()
|
||||
{
|
||||
scenery = new Scenery();
|
||||
scenery->autoPreset();
|
||||
renderer = new OpenGLRenderer(scenery);
|
||||
|
||||
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
|
||||
|
||||
setTitle(QObject::tr("Paysages 3D"));
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
setSource(QUrl("qrc:///main.qml"));
|
||||
}
|
||||
|
||||
MainModelerWindow::~MainModelerWindow()
|
||||
{
|
||||
delete renderer;
|
||||
delete scenery;
|
||||
}
|
28
src/interface/modeler/quickapp/MainModelerWindow.h
Normal file
28
src/interface/modeler/quickapp/MainModelerWindow.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MAINMODELERWINDOW_H
|
||||
#define MAINMODELERWINDOW_H
|
||||
|
||||
#include "modeler_global.h"
|
||||
|
||||
#include <QQuickView>
|
||||
|
||||
namespace paysages {
|
||||
namespace modeler {
|
||||
|
||||
class MainModelerWindow: public QQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainModelerWindow();
|
||||
virtual ~MainModelerWindow();
|
||||
|
||||
inline OpenGLRenderer *getRenderer() const {return renderer;}
|
||||
|
||||
private:
|
||||
OpenGLRenderer *renderer;
|
||||
Scenery *scenery;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAINMODELERWINDOW_H
|
|
@ -2,27 +2,22 @@
|
|||
|
||||
#include <QQuickWindow>
|
||||
#include <QHoverEvent>
|
||||
|
||||
// TEMP
|
||||
#include "MainModelerWindow.h"
|
||||
#include "CameraDefinition.h"
|
||||
#include "OpenGLRenderer.h"
|
||||
#include "Scenery.h"
|
||||
#include "CameraDefinition.h"
|
||||
static OpenGLRenderer renderer;
|
||||
static Scenery scenery;
|
||||
|
||||
OpenGLView::OpenGLView(QQuickItem *parent) :
|
||||
QQuickItem(parent)
|
||||
{
|
||||
initialized = false;
|
||||
window = NULL;
|
||||
renderer = NULL;
|
||||
|
||||
setAcceptedMouseButtons(Qt::AllButtons);
|
||||
setAcceptHoverEvents(true);
|
||||
setKeepMouseGrab(true);
|
||||
|
||||
scenery.autoPreset();
|
||||
renderer.setScenery(&scenery);
|
||||
|
||||
connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
|
||||
startTimer(250);
|
||||
}
|
||||
|
@ -31,27 +26,31 @@ void OpenGLView::handleWindowChanged(QQuickWindow *win)
|
|||
{
|
||||
if (win)
|
||||
{
|
||||
window = win;
|
||||
window = qobject_cast<MainModelerWindow *>(win);
|
||||
if (window)
|
||||
{
|
||||
renderer = window->getRenderer();
|
||||
|
||||
connect(window, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
|
||||
connect(win, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
|
||||
|
||||
win->setClearBeforeRendering(false);
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLView::paint()
|
||||
{
|
||||
if (not initialized)
|
||||
{
|
||||
renderer.initialize();
|
||||
renderer->initialize();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
renderer.resize(width(), height());
|
||||
renderer.prepareOpenGLState();
|
||||
renderer.paint();
|
||||
renderer->resize(width(), height());
|
||||
renderer->prepareOpenGLState();
|
||||
renderer->paint();
|
||||
|
||||
if (window)
|
||||
{
|
||||
|
@ -61,18 +60,23 @@ void OpenGLView::paint()
|
|||
|
||||
void OpenGLView::hoverMoveEvent(QHoverEvent *event)
|
||||
{
|
||||
if (!renderer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CameraDefinition camera;
|
||||
renderer.getScenery()->getCamera(&camera);
|
||||
renderer->getScenery()->getCamera(&camera);
|
||||
|
||||
QPointF diff = event->posF() - event->oldPosF();
|
||||
camera.strafeRight(diff.x() * 0.1);
|
||||
camera.strafeUp(diff.y() * 0.1);
|
||||
camera.validate();
|
||||
|
||||
camera.copy(renderer.render_camera);
|
||||
renderer.getScenery()->setCamera(&camera);
|
||||
renderer.getScenery()->getCamera(&camera);
|
||||
renderer.cameraChangeEvent(&camera);
|
||||
camera.copy(renderer->render_camera);
|
||||
renderer->getScenery()->setCamera(&camera);
|
||||
renderer->getScenery()->getCamera(&camera);
|
||||
renderer->cameraChangeEvent(&camera);
|
||||
if (window)
|
||||
{
|
||||
window->update();
|
||||
|
|
|
@ -24,7 +24,8 @@ protected:
|
|||
|
||||
private:
|
||||
bool initialized;
|
||||
QQuickWindow *window;
|
||||
MainModelerWindow *window;
|
||||
OpenGLRenderer *renderer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
#include <QGuiApplication>
|
||||
#include <QQuickView>
|
||||
#include <QtQml>
|
||||
|
||||
#include "OpenGLView.h"
|
||||
#include "MainModelerWindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
qmlRegisterType<OpenGLView>("Paysages", 1, 0, "OpenGLView");
|
||||
|
||||
QQuickView view;
|
||||
view.setTitle(QObject::tr("Paysages 3D"));
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view.setSource(QUrl("qrc:///main.qml"));
|
||||
MainModelerWindow view;
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
namespace paysages {
|
||||
namespace modeler {
|
||||
class ItemOpenGLView;
|
||||
class MainModelerWindow;
|
||||
class OpenGLView;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/interface/modeler/quickapp/qml/BasePanel.qml
Normal file
27
src/interface/modeler/quickapp/qml/BasePanel.qml
Normal file
|
@ -0,0 +1,27 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
property ToolbarButton tool
|
||||
id: panel
|
||||
|
||||
width: 200
|
||||
height: parent.height - 100
|
||||
color: "red"
|
||||
enabled: visible
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "Active"
|
||||
when: tool.selected
|
||||
|
||||
PropertyChanges {
|
||||
target: panel
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
11
src/interface/modeler/quickapp/qml/PanelWaterLevel.qml
Normal file
11
src/interface/modeler/quickapp/qml/PanelWaterLevel.qml
Normal file
|
@ -0,0 +1,11 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
|
||||
BasePanel {
|
||||
width: 20
|
||||
|
||||
Slider {
|
||||
orientation: Qt.Vertical
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
|
@ -5,7 +5,8 @@ Rectangle {
|
|||
default property alias children : inner_space.children
|
||||
width: 70
|
||||
height: parent.height
|
||||
color: "#50000000"
|
||||
color: "#50888888"
|
||||
enabled: opacity > 0
|
||||
|
||||
Column {
|
||||
id: inner_space
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
Item {
|
||||
property string picture
|
||||
|
@ -13,7 +14,7 @@ Item {
|
|||
Rectangle {
|
||||
id: glow
|
||||
anchors.fill: parent
|
||||
color: "white"
|
||||
color: "#cccccc"
|
||||
radius: 8
|
||||
|
||||
opacity: parent.selected ? 1.0 : (parent.hovered ? 0.5 : 0.0)
|
||||
|
@ -22,6 +23,13 @@ Item {
|
|||
duration: 200
|
||||
}
|
||||
}
|
||||
RectangularGlow {
|
||||
anchors.fill: glow
|
||||
glowRadius: 8
|
||||
spread: 0.2
|
||||
color: "white"
|
||||
cornerRadius: glow.radius + glowRadius
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
|
@ -30,6 +38,16 @@ Item {
|
|||
anchors.centerIn: parent
|
||||
width: 32
|
||||
height: 32
|
||||
antialiasing: true
|
||||
}
|
||||
DropShadow {
|
||||
anchors.fill: image
|
||||
horizontalOffset: 2
|
||||
verticalOffset: 2
|
||||
radius: 4.0
|
||||
samples: 16
|
||||
color: "#80000000"
|
||||
source: image
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
|
|
@ -13,5 +13,9 @@
|
|||
<file>images/display_topdown.png</file>
|
||||
<file>images/help.png</file>
|
||||
<file>Tooltip.qml</file>
|
||||
<file>images/icon_water.png</file>
|
||||
<file>images/icon_water_level.png</file>
|
||||
<file>BasePanel.qml</file>
|
||||
<file>PanelWaterLevel.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/interface/modeler/quickapp/qml/images/icon_water.png
Normal file
BIN
src/interface/modeler/quickapp/qml/images/icon_water.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 875 B |
BIN
src/interface/modeler/quickapp/qml/images/icon_water_level.png
Normal file
BIN
src/interface/modeler/quickapp/qml/images/icon_water_level.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -17,7 +17,7 @@ OpenGLView {
|
|||
|
||||
Toolbar {
|
||||
id: primary_toolbar
|
||||
color: "#90000000"
|
||||
color: "#90888888"
|
||||
|
||||
anchors.left: parent.left
|
||||
|
||||
|
@ -36,7 +36,8 @@ OpenGLView {
|
|||
}
|
||||
ToolbarButton {
|
||||
id: tool_water
|
||||
picture: "images/tab_water.png"
|
||||
picture: "images/icon_water.png"
|
||||
hovertext: "Water tools"
|
||||
}
|
||||
ToolbarButton {
|
||||
id: tool_atmosphere
|
||||
|
@ -65,6 +66,24 @@ OpenGLView {
|
|||
}
|
||||
}
|
||||
|
||||
Toolbar {
|
||||
id: water_toolbar
|
||||
opacity: 0
|
||||
anchors.left: primary_toolbar.right
|
||||
|
||||
ToolbarButton {
|
||||
id: tool_water_level
|
||||
picture: "images/icon_water_level.png"
|
||||
hovertext: qsTr("Change the water altitude")
|
||||
}
|
||||
}
|
||||
|
||||
PanelWaterLevel {
|
||||
id: panel_water_level
|
||||
visible: false
|
||||
tool: tool_water_level
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "Display Mode"
|
||||
|
@ -74,6 +93,15 @@ OpenGLView {
|
|||
target: display_toolbar
|
||||
opacity: 1
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "Water Mode"
|
||||
when: tool_water.selected
|
||||
|
||||
PropertyChanges {
|
||||
target: water_toolbar
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ QT += qml quick widgets
|
|||
include(../../../common.pri)
|
||||
|
||||
SOURCES += main.cpp \
|
||||
OpenGLView.cpp
|
||||
OpenGLView.cpp \
|
||||
MainModelerWindow.cpp
|
||||
|
||||
RESOURCES += \
|
||||
qml/app.qrc
|
||||
|
@ -20,7 +21,8 @@ include(deployment.pri)
|
|||
|
||||
HEADERS += \
|
||||
OpenGLView.h \
|
||||
modeler_global.h
|
||||
modeler_global.h \
|
||||
MainModelerWindow.h
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../system/release/ -lpaysages_system
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../system/debug/ -lpaysages_system
|
||||
|
@ -57,4 +59,6 @@ OTHER_FILES += \
|
|||
qml/ToolbarButton.qml \
|
||||
qml/OpenGLView.qml \
|
||||
qml/Toolbar.qml \
|
||||
qml/Tooltip.qml
|
||||
qml/Tooltip.qml \
|
||||
qml/BasePanel.qml \
|
||||
qml/PanelWaterLevel.qml
|
||||
|
|
Loading…
Reference in a new issue