Fixed UI elements visibility and input issues
This commit is contained in:
parent
8fa0d8af29
commit
0cf2add322
12 changed files with 110 additions and 69 deletions
|
@ -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)
|
||||
{
|
||||
rootObject()->setProperty("state", stateName);
|
||||
|
@ -75,6 +80,17 @@ void MainModelerWindow::setState(const QString &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)
|
||||
{
|
||||
// Start render in a thread
|
||||
|
@ -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)
|
||||
|
@ -125,4 +135,5 @@ void MainModelerWindow::keyReleaseEvent(QKeyEvent *event)
|
|||
scenery->getDiffManager()->undo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -26,6 +26,7 @@ protected:
|
|||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
bool acceptInputs() const;
|
||||
double getSpeedFactor(QInputEvent *event);
|
||||
|
||||
private:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
src/interface/modeler/quickapp/qml/BaseRectangle.qml
Normal file
13
src/interface/modeler/quickapp/qml/BaseRectangle.qml
Normal file
|
@ -0,0 +1,13 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
opacity: enabled ? 1 : 0
|
||||
enabled: true
|
||||
|
||||
Behavior on opacity {
|
||||
PropertyAnimation {
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
BaseRectangle {
|
||||
id: camera_choice
|
||||
width: 200
|
||||
height: 50
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.2
|
||||
|
||||
Rectangle {
|
||||
BaseRectangle {
|
||||
width: 400
|
||||
height: 300
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Rectangle {
|
||||
BaseRectangle {
|
||||
property string helptext
|
||||
property string hovertext
|
||||
width: content.width
|
||||
|
|
|
@ -27,5 +27,6 @@
|
|||
<file>BaseChoiceItem.qml</file>
|
||||
<file>RenderDialog.qml</file>
|
||||
<file>CameraChoice.qml</file>
|
||||
<file>BaseRectangle.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue