Fixed UI elements visibility and input issues

This commit is contained in:
Michaël Lemaire 2015-08-18 18:22:16 +02:00
parent 8fa0d8af29
commit 0cf2add322
12 changed files with 110 additions and 69 deletions

View file

@ -68,6 +68,11 @@ void MainModelerWindow::setQmlProperty(const QString &objectName, const QString
} }
} }
QString MainModelerWindow::getState() const
{
return rootObject()->property("state").toString();
}
void MainModelerWindow::setState(const QString &stateName) void MainModelerWindow::setState(const QString &stateName)
{ {
rootObject()->setProperty("state", stateName); rootObject()->setProperty("state", stateName);
@ -75,6 +80,17 @@ void MainModelerWindow::setState(const QString &stateName)
void MainModelerWindow::keyReleaseEvent(QKeyEvent *event) void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
{ {
if (getState() == "Render Dialog")
{
if (event->key() == Qt::Key_Escape)
{
render_process->stopRender();
setState("Init");
}
}
else
{
if (event->key() == Qt::Key_F5) if (event->key() == Qt::Key_F5)
{ {
// Start render in a thread // Start render in a thread
@ -91,12 +107,6 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
{ {
render_process->showPreviousRender(); render_process->showPreviousRender();
} }
else if (event->key() == Qt::Key_Escape)
{
render_process->stopRender();
setState("Init");
}
else if (event->key() == Qt::Key_Q) else if (event->key() == Qt::Key_Q)
{ {
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)
@ -125,4 +135,5 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
scenery->getDiffManager()->undo(); scenery->getDiffManager()->undo();
} }
} }
}
} }

View file

@ -17,6 +17,8 @@ public:
QObject *findQmlObject(const QString &objectName); QObject *findQmlObject(const QString &objectName);
void setQmlProperty(const QString &objectName, const QString &propertyName, const QVariant &value); void setQmlProperty(const QString &objectName, const QString &propertyName, const QVariant &value);
QString getState() const;
void setState(const QString &stateName); void setState(const QString &stateName);
inline Scenery *getScenery() const {return scenery;} inline Scenery *getScenery() const {return scenery;}

View file

@ -59,23 +59,43 @@ void OpenGLView::paint()
void OpenGLView::wheelEvent(QWheelEvent *event) void OpenGLView::wheelEvent(QWheelEvent *event)
{ {
if (not acceptInputs())
{
return;
}
double factor = getSpeedFactor(event); double factor = getSpeedFactor(event);
window->getCamera()->processZoom(0.1 * factor * (double)event->angleDelta().y()); window->getCamera()->processZoom(0.1 * factor * (double)event->angleDelta().y());
} }
void OpenGLView::mousePressEvent(QMouseEvent *event) void OpenGLView::mousePressEvent(QMouseEvent *event)
{ {
if (not acceptInputs())
{
return;
}
mouse_button = event->button(); mouse_button = event->button();
mouse_pos = event->windowPos(); mouse_pos = event->windowPos();
} }
void OpenGLView::mouseReleaseEvent(QMouseEvent *) void OpenGLView::mouseReleaseEvent(QMouseEvent *)
{ {
if (not acceptInputs())
{
return;
}
mouse_button = Qt::NoButton; mouse_button = Qt::NoButton;
} }
void OpenGLView::mouseMoveEvent(QMouseEvent *event) void OpenGLView::mouseMoveEvent(QMouseEvent *event)
{ {
if (not acceptInputs())
{
return;
}
double factor = getSpeedFactor(event); double factor = getSpeedFactor(event);
QPointF diff = event->windowPos() - mouse_pos; QPointF diff = event->windowPos() - mouse_pos;
if (mouse_button == Qt::LeftButton) if (mouse_button == Qt::LeftButton)
@ -97,6 +117,11 @@ void OpenGLView::timerEvent(QTimerEvent *)
} }
} }
bool OpenGLView::acceptInputs() const
{
return window->getState() != "Render Dialog";
}
double OpenGLView::getSpeedFactor(QInputEvent *event) double OpenGLView::getSpeedFactor(QInputEvent *event)
{ {
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)

View file

@ -26,6 +26,7 @@ protected:
virtual void timerEvent(QTimerEvent *event) override; virtual void timerEvent(QTimerEvent *event) override;
private: private:
bool acceptInputs() const;
double getSpeedFactor(QInputEvent *event); double getSpeedFactor(QInputEvent *event);
private: private:

View file

@ -1,24 +1,17 @@
import QtQuick 2.0 import QtQuick 2.0
Rectangle { BaseRectangle {
property ToolbarButton tool property ToolbarButton tool
id: panel id: panel
opacity: 0 enabled: false
width: 200 width: 200
height: parent.height - 100 height: parent.height - 100
color: "#a0909090" color: "#a0909090"
enabled: visible
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Behavior on opacity {
PropertyAnimation {
duration: 200
}
}
states: [ states: [
State { State {
name: "Active" name: "Active"
@ -26,8 +19,7 @@ Rectangle {
PropertyChanges { PropertyChanges {
target: panel target: panel
visible: true enabled: true
opacity: 1
} }
} }

View file

@ -0,0 +1,13 @@
import QtQuick 2.0
Rectangle {
opacity: enabled ? 1 : 0
enabled: true
Behavior on opacity {
PropertyAnimation {
duration: 200
}
}
}

View file

@ -1,6 +1,6 @@
import QtQuick 2.0 import QtQuick 2.0
Rectangle { BaseRectangle {
id: camera_choice id: camera_choice
width: 200 width: 200
height: 50 height: 50

View file

@ -1,7 +1,7 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
Rectangle { BaseRectangle {
width: 400 width: 400
height: 300 height: 300

View file

@ -1,12 +1,11 @@
import QtQuick 2.0 import QtQuick 2.0
Rectangle { BaseRectangle {
default property alias children : inner_space.children default property alias children : inner_space.children
width: 70 width: 70
height: parent.height height: parent.height
color: "#50888888" color: "#50888888"
enabled: opacity > 0
Column { Column {
id: inner_space id: inner_space
@ -14,12 +13,6 @@ Rectangle {
anchors.centerIn: parent anchors.centerIn: parent
} }
Behavior on opacity {
PropertyAnimation {
duration: 200
}
}
onEnabledChanged: { onEnabledChanged: {
if (!enabled) if (!enabled)
{ {

View file

@ -1,6 +1,6 @@
import QtQuick 2.0 import QtQuick 2.0
Rectangle { BaseRectangle {
property string helptext property string helptext
property string hovertext property string hovertext
width: content.width width: content.width

View file

@ -27,5 +27,6 @@
<file>BaseChoiceItem.qml</file> <file>BaseChoiceItem.qml</file>
<file>RenderDialog.qml</file> <file>RenderDialog.qml</file>
<file>CameraChoice.qml</file> <file>CameraChoice.qml</file>
<file>BaseRectangle.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -56,7 +56,7 @@ OpenGLView {
Toolbar { Toolbar {
id: display_toolbar id: display_toolbar
opacity: 0 enabled: false
anchors.left: primary_toolbar.right anchors.left: primary_toolbar.right
ToolbarButton { ToolbarButton {
@ -69,7 +69,7 @@ OpenGLView {
Toolbar { Toolbar {
id: water_toolbar id: water_toolbar
opacity: 0 enabled: false
anchors.left: primary_toolbar.right anchors.left: primary_toolbar.right
ToolbarButton { ToolbarButton {
@ -81,7 +81,7 @@ OpenGLView {
Toolbar { Toolbar {
id: atmosphere_toolbar id: atmosphere_toolbar
opacity: 0 enabled: false
anchors.left: primary_toolbar.right anchors.left: primary_toolbar.right
ToolbarButton { ToolbarButton {
@ -93,7 +93,7 @@ OpenGLView {
Toolbar { Toolbar {
id: render_toolbar id: render_toolbar
opacity: 0 enabled: false
anchors.left: primary_toolbar.right anchors.left: primary_toolbar.right
ToolbarButton { ToolbarButton {
@ -112,7 +112,7 @@ OpenGLView {
RenderDialog { RenderDialog {
id: render_dialog id: render_dialog
opacity: 0 enabled: false
anchors.fill: parent anchors.fill: parent
} }
@ -132,7 +132,7 @@ OpenGLView {
PropertyChanges { PropertyChanges {
target: display_toolbar target: display_toolbar
opacity: 1 enabled: true
} }
}, },
State { State {
@ -141,7 +141,7 @@ OpenGLView {
PropertyChanges { PropertyChanges {
target: water_toolbar target: water_toolbar
opacity: 1 enabled: true
} }
}, },
State { State {
@ -150,7 +150,7 @@ OpenGLView {
PropertyChanges { PropertyChanges {
target: atmosphere_toolbar target: atmosphere_toolbar
opacity: 1 enabled: true
} }
}, },
State { State {
@ -159,20 +159,23 @@ OpenGLView {
PropertyChanges { PropertyChanges {
target: render_toolbar target: render_toolbar
opacity: 1 enabled: true
} }
}, },
State { State {
name: "Render Dialog" name: "Render Dialog"
when: tool_display.selected
PropertyChanges { PropertyChanges {
target: primary_toolbar target: primary_toolbar
opacity: 0 enabled: false
}
PropertyChanges {
target: camera_choice
enabled: false
} }
PropertyChanges { PropertyChanges {
target: render_dialog target: render_dialog
opacity: 1 enabled: true
} }
} }
] ]