Experiments on toolbars

This commit is contained in:
Michaël Lemaire 2014-08-27 17:23:59 +02:00
parent 0e2e0a05eb
commit 3814f63ac0
11 changed files with 141 additions and 73 deletions

1
.gitignore vendored
View file

@ -22,3 +22,4 @@ ui_*.h
/paysages3d-linux/ /paysages3d-linux/
/paysages3d-linux.tar.bz2 /paysages3d-linux.tar.bz2
/config.vim /config.vim
/callgrind.out.*

View file

@ -1,10 +0,0 @@
<RCC>
<qresource prefix="/toolbar/primary">
<file>tab_water.png</file>
<file>tab_atmosphere.png</file>
<file>tab_clouds.png</file>
<file>tab_render.png</file>
<file>tab_terrain.png</file>
<file>tab_textures.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,21 @@
import QtQuick 2.0
Rectangle {
default property alias children : inner_space.children
width: 70
height: parent.height
color: "#50000000"
Column {
id: inner_space
spacing: (parent.height - children.length * tool_terrain.height) / (children.length + 1)
anchors.centerIn: parent
}
Behavior on opacity {
PropertyAnimation {
duration: 200
}
}
}

View file

@ -4,6 +4,8 @@ Item {
property string picture property string picture
property bool selected: false property bool selected: false
property bool hovered: false property bool hovered: false
property string helptext
property string hovertext
width: image.width + 10 width: image.width + 10
height: image.height + 10 height: image.height + 10
@ -26,14 +28,42 @@ Item {
id: image id: image
source: parent.picture source: parent.picture
anchors.centerIn: parent anchors.centerIn: parent
width: 32
height: 32
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.hovered = true onEntered: {
onExited: parent.hovered = false parent.hovered = true;
onClicked: parent.selected = true tooltip_widget.hovertext = hovertext;
}
onExited: {
parent.hovered = false;
tooltip_widget.hovertext = "";
}
onClicked: {
parent.selected = !parent.selected;
if (parent.selected)
{
var toolbar = parent.parent;
for (var i = 0; i < toolbar.children.length; ++i)
{
var child = toolbar.children[i]
if (child !== parent)
{
child.selected = false;
}
}
tooltip_widget.helptext = helptext;
}
else
{
tooltip_widget.helptext = "";
}
}
} }
} }

View file

@ -0,0 +1,16 @@
import QtQuick 2.0
Rectangle {
property string helptext
property string hovertext
width: content.width
height: content.height
color: "#99000000"
Text {
id: content
color: "white"
text: parent.helptext || parent.hovertext
}
}

View file

@ -8,5 +8,10 @@
<file>images/tab_terrain.png</file> <file>images/tab_terrain.png</file>
<file>images/tab_textures.png</file> <file>images/tab_textures.png</file>
<file>images/tab_water.png</file> <file>images/tab_water.png</file>
<file>images/tab_display.png</file>
<file>Toolbar.qml</file>
<file>images/display_topdown.png</file>
<file>images/help.png</file>
<file>Tooltip.qml</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -2,76 +2,79 @@ import QtQuick 2.2
import Paysages 1.0 import Paysages 1.0
OpenGLView { OpenGLView {
id: main_ui
state: "Init"
width: 640 width: 800
height: 480 height: 600
Item { Tooltip {
id: tooltip_widget
anchors.top: parent.top
anchors.right: parent.right
}
Toolbar {
id: primary_toolbar id: primary_toolbar
x: 0 color: "#90000000"
y: 0
width: 70
height: parent.height
Rectangle { anchors.left: parent.left
width: parent.height
height: parent.width ToolbarButton {
anchors.horizontalCenter: parent.horizontalCenter id: tool_display
anchors.verticalCenter: parent.verticalCenter picture: "images/tab_display.png"
transformOrigin: Item.Center hovertext: qsTr("Display options")
rotation: -90
gradient: Gradient {
GradientStop { position: 0.0; color: "#605055FF" }
GradientStop { position: 1.0; color: "#005055FF" }
}
} }
ToolbarButton {
Column { id: tool_terrain
picture: "images/tab_terrain.png"
anchors.horizontalCenter: parent.horizontalCenter }
anchors.verticalCenter: parent.verticalCenter ToolbarButton {
spacing: (parent.height - 6 * tool_terrain.height) / 7 id: tool_textures
picture: "images/tab_textures.png"
ToolbarButton { }
id: tool_terrain ToolbarButton {
picture: "images/tab_terrain.png" id: tool_water
} picture: "images/tab_water.png"
ToolbarButton { }
id: tool_textures ToolbarButton {
picture: "images/tab_textures.png" id: tool_atmosphere
} picture: "images/tab_atmosphere.png"
ToolbarButton { }
id: tool_water ToolbarButton {
picture: "images/tab_water.png" id: tool_clouds
} picture: "images/tab_clouds.png"
ToolbarButton { }
id: tool_atmosphere ToolbarButton {
picture: "images/tab_atmosphere.png" id: tool_render
} picture: "images/tab_render.png"
ToolbarButton {
id: tool_clouds
picture: "images/tab_clouds.png"
}
ToolbarButton {
id: tool_render
picture: "images/tab_render.png"
}
} }
} }
Rectangle { Toolbar {
id: toolbar_render id: display_toolbar
anchors.top: primary_toolbar.top opacity: 0
anchors.left: primary_toolbar.right anchors.left: primary_toolbar.right
width: primary_toolbar.width
height: primary_toolbar.height
color: "#8800FF00"
SequentialAnimation on width { ToolbarButton {
loops: Animation.Infinite id: tool_display_topdown
PropertyAnimation { to: 0; duration: 1000 } picture: "images/display_topdown.png"
PropertyAnimation { to: primary_toolbar.width; duration: 1000 } hovertext: qsTr("Top-down view")
helptext: qsTr("Drag the mouse on the map to change the viewpoint.")
} }
} }
states: [
State {
name: "Display Mode"
when: tool_display.selected
PropertyChanges {
target: display_toolbar
opacity: 1
}
}
]
} }

View file

@ -53,4 +53,6 @@ DEPENDPATH += $$PWD/../../../render/opengl
OTHER_FILES += \ OTHER_FILES += \
qml/main.qml \ qml/main.qml \
qml/ToolbarButton.qml \ qml/ToolbarButton.qml \
qml/OpenGLView.qml qml/OpenGLView.qml \
qml/Toolbar.qml \
qml/Tooltip.qml