Added mouse control over sun and moon positions
This commit is contained in:
parent
c1d6a3261c
commit
c99973a42b
5 changed files with 54 additions and 15 deletions
|
@ -11,7 +11,7 @@ BaseSection {
|
|||
id: tool_daytime
|
||||
checked: true
|
||||
picture: "images/icon_atmosphere_daytime.png"
|
||||
hovertext: qsTr("Change the time of day")
|
||||
hovertext: qsTr("Control the sun and moon")
|
||||
}
|
||||
|
||||
ToolbarButton {
|
||||
|
|
|
@ -4,8 +4,18 @@ BaseRectangle {
|
|||
id: panel
|
||||
width: 200
|
||||
height: parent.height
|
||||
property string title: ""
|
||||
|
||||
anchors.top: parent.top
|
||||
|
||||
color: "#40909090"
|
||||
|
||||
Text {
|
||||
text: title
|
||||
visible: title != ""
|
||||
font.bold: true
|
||||
font.pixelSize: 12
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
BasePanel {
|
||||
width: 200
|
||||
width: 320
|
||||
title: tool_daytime.hovertext
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
|
@ -9,7 +10,7 @@ BasePanel {
|
|||
spacing: 30
|
||||
|
||||
Text {
|
||||
text: "Sun location in the sky"
|
||||
text: qsTr("Sun location in the sky")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
|
@ -19,10 +20,11 @@ BasePanel {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
icon: "images/icon_atmosphere_day.png"
|
||||
width: parent.width
|
||||
onThetaChanged: atmosphere_daytime.value = (atmosphere_sun_direction.theta / (Math.PI * 2.0)) - 0.75
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "Time of day"
|
||||
text: qsTr("Time of day")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
|
@ -34,7 +36,7 @@ BasePanel {
|
|||
}
|
||||
|
||||
Text {
|
||||
text: "Moon location in the sky"
|
||||
text: qsTr("Moon location in the sky")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@ Grid {
|
|||
id: clock
|
||||
|
||||
property real value
|
||||
property real modvalue: value - Math.floor(value)
|
||||
|
||||
property int hour: value * 86400 / 3600
|
||||
property int minute: (value * 86400 - 3600 * hour) / 60
|
||||
property int second: value * 86400 - 3600 * hour - 60 * minute
|
||||
property int hour: Math.floor(86400.0 * modvalue / 3600.0)
|
||||
property int minute: Math.floor((86400.0 * modvalue - 3600.0 * hour) / 60.0)
|
||||
property int second: Math.floor(86400.0 * modvalue - 3600.0 * hour - 60.0 * minute)
|
||||
rows: 3
|
||||
columns: 5
|
||||
rowSpacing: 4
|
||||
|
@ -16,21 +17,21 @@ Grid {
|
|||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_up.png"
|
||||
onClicked: value += 1.0 / 24.0
|
||||
onClicked: value = modvalue + 1.0 / 24.0
|
||||
}
|
||||
Item {width: 1; height: 1}
|
||||
ClickableImage {
|
||||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_up.png"
|
||||
onClicked: value += 1.0 / 1440.0
|
||||
onClicked: value = modvalue + 1.0 / 1440.0
|
||||
}
|
||||
Item {width: 1; height: 1}
|
||||
ClickableImage {
|
||||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_up.png"
|
||||
onClicked: value += 1.0 / 86400.0
|
||||
onClicked: value = modvalue + 1.0 / 86400.0
|
||||
}
|
||||
|
||||
Text {
|
||||
|
@ -58,20 +59,20 @@ Grid {
|
|||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_down.png"
|
||||
onClicked: value -= 1.0 / 24.0
|
||||
onClicked: value = modvalue - 1.0 / 24.0
|
||||
}
|
||||
Item {width: 1; height: 1}
|
||||
ClickableImage {
|
||||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_down.png"
|
||||
onClicked: value -= 1.0 / 1440.0
|
||||
onClicked: value = modvalue - 1.0 / 1440.0
|
||||
}
|
||||
Item {width: 1; height: 1}
|
||||
ClickableImage {
|
||||
width: 20
|
||||
height: 10
|
||||
source: "images/arrow_down.png"
|
||||
onClicked: value -= 1.0 / 86400.0
|
||||
onClicked: value = modvalue - 1.0 / 86400.0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,20 @@ Row {
|
|||
height: parent.width / 10
|
||||
anchors.centerIn: parent
|
||||
anchors.horizontalCenterOffset: width * 4 * Math.cos(phi) * Math.cos(theta)
|
||||
anchors.verticalCenterOffset: -width * 4 * Math.sin(phi) * Math.cos(theta)
|
||||
anchors.verticalCenterOffset: width * 4 * Math.sin(phi) * Math.cos(theta)
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
property real oldval: 0
|
||||
|
||||
onPositionChanged: {
|
||||
var newval = Math.atan2(mouseY - height / 2, mouseX - width / 2);
|
||||
if (pressedButtons & Qt.LeftButton) {
|
||||
phi += newval - oldval;
|
||||
}
|
||||
oldval = newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,5 +54,18 @@ Row {
|
|||
anchors.horizontalCenterOffset: width * 4.5 * Math.cos(theta)
|
||||
anchors.verticalCenterOffset: -width * 4.5 * Math.sin(theta)
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
property real oldval: 0
|
||||
|
||||
onPositionChanged: {
|
||||
var newval = Math.atan2(height / 2 - mouseY, mouseX - width / 2);
|
||||
if (pressedButtons & Qt.LeftButton) {
|
||||
theta += newval - oldval;
|
||||
}
|
||||
oldval = newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue