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
...@@ -12,4 +12,5 @@ documentation.list ...@@ -12,4 +12,5 @@ documentation.list
examples/touch/glacier-components examples/touch/glacier-components
Makefile Makefile
installroot/ installroot/
RPMS/ RPMS/
\ No newline at end of file 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 ...@@ -35,6 +35,17 @@ import QtQuick.Controls.Nemo 1.0
Item { Item {
id: container id: container
function stop() {
if(state=="enabled") {
state=""
}
}
function start() {
if(state!="enabled") {
state="enabled"
}
}
states: [ states: [
State { name: "enabled"; when: enabled } State { name: "enabled"; when: enabled }
] ]
...@@ -49,7 +60,7 @@ Item { ...@@ -49,7 +60,7 @@ Item {
targets: [circle0, circle1, circle2, circle3] targets: [circle0, circle1, circle2, circle3]
property: "opacity" property: "opacity"
to: 1 to: 1
duration: 1500 duration: 700
} }
PropertyAction { target: animations; property: "running"; value: true } PropertyAction { target: animations; property: "running"; value: true }
} }
...@@ -64,13 +75,13 @@ Item { ...@@ -64,13 +75,13 @@ Item {
targets: [circle0, circle1, circle2, circle3] targets: [circle0, circle1, circle2, circle3]
property: "color"; property: "color";
to: Theme.backgroundAccentColor to: Theme.backgroundAccentColor
duration: 500 duration: 400
} }
NumberAnimation { NumberAnimation {
targets: [circle0, circle1, circle2, circle3] targets: [circle0, circle1, circle2, circle3]
property: "opacity" property: "opacity"
to: 0 to: 0
duration: 1500 duration: 700
} }
} }
} }
...@@ -140,13 +151,13 @@ Item { ...@@ -140,13 +151,13 @@ Item {
target: circle0 target: circle0
property: "color" property: "color"
to: Theme.accentColor to: Theme.accentColor
duration: 500 duration: 400
} }
PropertyAnimation { PropertyAnimation {
target: circle3 target: circle3
property: "color" property: "color"
to: Theme.backgroundAccentColor to: Theme.backgroundAccentColor
duration: 500 duration: 400
} }
} }
...@@ -155,13 +166,13 @@ Item { ...@@ -155,13 +166,13 @@ Item {
target: circle1 target: circle1
property: "color" property: "color"
to: Theme.accentColor to: Theme.accentColor
duration: 500 duration: 400
} }
PropertyAnimation { PropertyAnimation {
target: circle0 target: circle0
property: "color" property: "color"
to: Theme.backgroundAccentColor to: Theme.backgroundAccentColor
duration: 500 duration: 400
} }
} }
...@@ -170,13 +181,13 @@ Item { ...@@ -170,13 +181,13 @@ Item {
target: circle2 target: circle2
property: "color" property: "color"
to: Theme.accentColor to: Theme.accentColor
duration: 500 duration: 400
} }
PropertyAnimation { PropertyAnimation {
target: circle1 target: circle1
property: "color" property: "color"
to: Theme.backgroundAccentColor to: Theme.backgroundAccentColor
duration: 500 duration: 400
} }
} }
...@@ -185,13 +196,13 @@ Item { ...@@ -185,13 +196,13 @@ Item {
target: circle3 target: circle3
property: "color" property: "color"
to: Theme.accentColor to: Theme.accentColor
duration: 500 duration: 400
} }
PropertyAnimation { PropertyAnimation {
target: circle2 target: circle2
property: "color" property: "color"
to: Theme.backgroundAccentColor to: Theme.backgroundAccentColor
duration: 500 duration: 400
} }
} }
} }
......
...@@ -22,6 +22,7 @@ QML_FILES += \ ...@@ -22,6 +22,7 @@ QML_FILES += \
ListViewItemWithActions.qml\ ListViewItemWithActions.qml\
GlacierRoller.qml \ GlacierRoller.qml \
GlacierRollerItem.qml \ GlacierRollerItem.qml \
InverseMouseArea.qml \
IconButton.qml IconButton.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
......
...@@ -23,6 +23,7 @@ ListView 1.0 ListView.qml ...@@ -23,6 +23,7 @@ ListView 1.0 ListView.qml
ListViewItemWithActions 1.0 ListViewItemWithActions.qml ListViewItemWithActions 1.0 ListViewItemWithActions.qml
GlacierRoller 1.0 GlacierRoller.qml GlacierRoller 1.0 GlacierRoller.qml
GlacierRollerItem 1.0 GlacierRollerItem.qml GlacierRollerItem 1.0 GlacierRollerItem.qml
InverseMouseArea 1.0 InverseMouseArea.qml
IconButton 1.0 IconButton.qml IconButton 1.0 IconButton.qml
# MIRRORED CONTROLS: # 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