Commit 3a5753db authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #45 from eekkelund/inversemousearea

Add new component: InverseMouseArea.qml
parents d5b5ecee 7a03018b
......@@ -13,3 +13,4 @@ examples/touch/glacier-components
Makefile
installroot/
RPMS/
debug*.list
This diff is collapsed.
/**
Author : Ben Lau (@benlau)
License: Apache
*/
import QtQuick 2.6
Item {
id : component
property Item sensingArea : null
signal pressed
property var _mouseArea : null
function _setupMouseArea() {
if (!_mouseArea) {
_mouseArea = mouseAreaBuilder.createObject(component);
}
var p = sensingArea;
if (!p)
p = _topMostItem();
_mouseArea.parent = p;
}
function _destroyMouseArea() {
if (_mouseArea) {
_mouseArea.destroy();
_mouseArea = null;
}
}
function _inBound(pt) {
var ret = false;
if (pt.x >= component.x &&
pt.y >= component.y &&
pt.x <= component.x + component.width &&
pt.y <= component.y + component.height) {
ret = true;
}
return ret;
}
function _topMostItem() {
var p = component;
while (p.parent) {
p = p.parent;
}
return p;
}
Component {
id : mouseAreaBuilder
MouseArea {
propagateComposedEvents : true
anchors.fill: parent
z: 200000000
onPressed: {
mouse.accepted = false;
var pt = mapToItem(component.parent,mouse.x,mouse.y)
if (!_inBound(pt))
component.pressed();
}
}
}
onEnabledChanged: {
_destroyMouseArea();
if (enabled) {
_setupMouseArea();
}
}
Component.onCompleted: {
if (enabled)
_setupMouseArea();
}
Component.onDestruction: {
_destroyMouseArea();
}
}
......@@ -35,6 +35,17 @@ import QtQuick.Controls.Nemo 1.0
Item {
id: container
function stop() {
if(state=="enabled") {
state=""
}
}
function start() {
if(state!="enabled") {
state="enabled"
}
}
states: [
State { name: "enabled"; when: enabled }
]
......@@ -49,7 +60,7 @@ Item {
targets: [circle0, circle1, circle2, circle3]
property: "opacity"
to: 1
duration: 1500
duration: 700
}
PropertyAction { target: animations; property: "running"; value: true }
}
......@@ -64,13 +75,13 @@ Item {
targets: [circle0, circle1, circle2, circle3]
property: "color";
to: Theme.backgroundAccentColor
duration: 500
duration: 400
}
NumberAnimation {
targets: [circle0, circle1, circle2, circle3]
property: "opacity"
to: 0
duration: 1500
duration: 700
}
}
}
......@@ -140,13 +151,13 @@ Item {
target: circle0
property: "color"
to: Theme.accentColor
duration: 500
duration: 400
}
PropertyAnimation {
target: circle3
property: "color"
to: Theme.backgroundAccentColor
duration: 500
duration: 400
}
}
......@@ -155,13 +166,13 @@ Item {
target: circle1
property: "color"
to: Theme.accentColor
duration: 500
duration: 400
}
PropertyAnimation {
target: circle0
property: "color"
to: Theme.backgroundAccentColor
duration: 500
duration: 400
}
}
......@@ -170,13 +181,13 @@ Item {
target: circle2
property: "color"
to: Theme.accentColor
duration: 500
duration: 400
}
PropertyAnimation {
target: circle1
property: "color"
to: Theme.backgroundAccentColor
duration: 500
duration: 400
}
}
......@@ -185,13 +196,13 @@ Item {
target: circle3
property: "color"
to: Theme.accentColor
duration: 500
duration: 400
}
PropertyAnimation {
target: circle2
property: "color"
to: Theme.backgroundAccentColor
duration: 500
duration: 400
}
}
}
......
......@@ -22,6 +22,7 @@ QML_FILES += \
ListViewItemWithActions.qml\
GlacierRoller.qml \
GlacierRollerItem.qml \
InverseMouseArea.qml \
IconButton.qml
OTHER_FILES += qmldir \
......
......@@ -23,6 +23,7 @@ ListView 1.0 ListView.qml
ListViewItemWithActions 1.0 ListViewItemWithActions.qml
GlacierRoller 1.0 GlacierRoller.qml
GlacierRollerItem 1.0 GlacierRollerItem.qml
InverseMouseArea 1.0 InverseMouseArea.qml
IconButton 1.0 IconButton.qml
# MIRRORED CONTROLS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment