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,12 +68,28 @@ void MainModelerWindow::setQmlProperty(const QString &objectName, const QString
}
}
QString MainModelerWindow::getState() const
{
return rootObject()->property("state").toString();
}
void MainModelerWindow::setState(const QString &stateName)
{
rootObject()->setProperty("state", stateName);
}
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)
{
@ -91,12 +107,6 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
{
render_process->showPreviousRender();
}
else if (event->key() == Qt::Key_Escape)
{
render_process->stopRender();
setState("Init");
}
else if (event->key() == Qt::Key_Q)
{
if (event->modifiers() & Qt::ControlModifier)
@ -126,3 +136,4 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
}
}
}
}

View file

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

View file

@ -59,23 +59,43 @@ void OpenGLView::paint()
void OpenGLView::wheelEvent(QWheelEvent *event)
{
if (not acceptInputs())
{
return;
}
double factor = getSpeedFactor(event);
window->getCamera()->processZoom(0.1 * factor * (double)event->angleDelta().y());
}
void OpenGLView::mousePressEvent(QMouseEvent *event)
{
if (not acceptInputs())
{
return;
}
mouse_button = event->button();
mouse_pos = event->windowPos();
}
void OpenGLView::mouseReleaseEvent(QMouseEvent *)
{
if (not acceptInputs())
{
return;
}
mouse_button = Qt::NoButton;
}
void OpenGLView::mouseMoveEvent(QMouseEvent *event)
{
if (not acceptInputs())
{
return;
}
double factor = getSpeedFactor(event);
QPointF diff = event->windowPos() - mouse_pos;
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)
{
if (event->modifiers() & Qt::ControlModifier)

View file

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

View file

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

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
Rectangle {
BaseRectangle {
id: camera_choice
width: 200
height: 50

View file

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

View file

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

View file

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

View file

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

View file

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