diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-07-09 16:24:26 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-07-14 13:16:08 +0000 |
commit | 5c121fa1a398d475b7b734b112b8886901d3ba0f (patch) | |
tree | 55e92b6b99383a45ed587c2bd510be2523757c1e /src/imports/controls | |
parent | ab0d7859496e4c36b8ee83e1cacda83ca4533b59 (diff) |
Material: implement ripple effect for ToolButton
Task-number: QTBUG-54764
Change-Id: I0f7a20db39ea02772482c9c0d8bea505c42a6944
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/controls')
-rw-r--r-- | src/imports/controls/material/ToolButton.qml | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml index 70b9224f..fe0e75c8 100644 --- a/src/imports/controls/material/ToolButton.qml +++ b/src/imports/controls/material/ToolButton.qml @@ -37,6 +37,7 @@ import QtQuick 2.6 import QtQuick.Templates 2.1 as T import QtQuick.Controls.Material 2.1 +import QtQuick.Controls.Material.impl 2.1 T.ToolButton { id: control @@ -58,11 +59,21 @@ T.ToolButton { verticalAlignment: Text.AlignVCenter } - background: Rectangle { + background: Ripple { implicitWidth: 48 implicitHeight: 48 - color: control.down ? control.Material.buttonPressColor : control.Material.buttonHoverColor - visible: control.enabled && (control.down || control.visualFocus || control.checked || control.highlighted) + readonly property bool square: parent.width === parent.height + + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + clip: !square + width: square ? parent.height / 2 : parent.width + height: square ? parent.height / 2 : parent.height + trigger: square ? Ripple.Press : Ripple.Release + pressed: control.pressed + anchor: control + active: control.enabled && (control.down || control.visualFocus || control.hovered) + color: control.checked ? control.Material.checkBoxCheckedRippleColor : control.Material.checkBoxUncheckedRippleColor } } |