Index: sources/gui/qml/components/TouchRect.qml =================================================================== diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd --- sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision fee7fabf49befb065c89248c19e15efc9ca194e4) +++ sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd) @@ -25,15 +25,54 @@ * which is used a general default round rect button */ Rectangle { id : _root - property alias text : _text - property alias button : _mouseArea + property alias text : _text + property alias button : _mouseArea - property bool animate : false + property bool animated : false + property alias loops : _clickAnimation.loops + property int duration : 200 + property bool disabled : false + + property color textColor : Colors.textButton + property color borderColor : Colors.borderButton + property color backgroungColor : Colors.backgroundButtonNormal + + onDurationChanged: { + _colorAnimationOn .duration = duration; + _colorAnimationOff.duration = duration; + } + + function animate(vAnimate) { + if (vAnimate) { + if ( disabled ) { return } + if ( animated ) { + _clickAnimation.restart() + } + } else { + _clickAnimation.stop() + _root.color = backgroungColor + } + } + + onBackgroungColorChanged: { + _root.color = backgroungColor + } + + onDisabledChanged: { + if (disabled) { + text.color = Colors.textDisableButton + border.color = Colors.borderDisableButton + } else { + text.color = textColor + border.color = borderColor + } + } + width : Variables.touchRectWidth height : Variables.touchRectHeight radius : Variables.touchRectRadius - color : "Transparent" + color : backgroungColor border { color: Colors.borderButton width: Variables.borderWidth @@ -46,15 +85,20 @@ MouseArea { id: _mouseArea anchors.fill: parent onPressed: { - if ( animate ) { - _clickAnimation.running = true - } + if ( disabled ) { return } + animate(true) } } SequentialAnimation { id: _clickAnimation running: false - PropertyAnimation { target: _root; property: "color"; to: _root.border.color; duration: 50; } - PropertyAnimation { target: _root; property: "color"; to: _root.color ; duration: 50; } + onStopped: { + _root.color = backgroungColor + } + onFinished: { + _root.color = backgroungColor + } + PropertyAnimation { id: _colorAnimationOn ; target: _root; property: "color"; to: _root.border.color; duration: duration; } + PropertyAnimation { id: _colorAnimationOff; target: _root; property: "color"; to: _root.color ; duration: duration; } } }