4pragma ComponentBehavior: Bound
7import QtQuick.Templates as T
9import "../core/UiMetrics.js" as UiMetrics
10import "../internal/MotionAnimation.js" as MotionAnimation
42 property MD.FabMenu menu: null
50 property int staggerIndex: 0
53 property color containerColor: control.menu ? control.menu.itemContainerColor : control.MD.Style.primaryContainerColor
56 property color contentColor: control.menu ? control.menu.itemContentColor : control.MD.Style.onPrimaryContainerColor
59 readonly
property color effectiveContainerColor: control.containerColor
62 readonly
property color effectiveContentColor: control.contentColor
65 readonly
property bool _hasNamedIcon: icon.name.length > 0
68 readonly
property bool _hasSourceIcon: icon.source.toString().length > 0
71 readonly
property bool _hasIcon: _hasNamedIcon || _hasSourceIcon
74 readonly
property real _contentOpacity: enabled ? 1 : MD.Tokens.fabMenu.disabledContentOpacity
77 readonly
property bool _animated: menu !== null
88 readonly
property int _entranceOrder: control._animated && control.menu._entranceDirection > 0 ? Math.max(0, control.menu.contentChildren.length - 1 - control.staggerIndex) : control.staggerIndex
91 readonly
property real _collapsedScale: 0.8
94 readonly
property real _collapsedOffsetFactor: 0.5
97 readonly
property real _collapsedOffset: _animated ? control.height * control._collapsedOffsetFactor * control.menu._entranceDirection : 0
100 property real _entranceOffset: 0
102 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
103 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
109 leftPadding: mirrored ? MD.Tokens.fabMenu.listItemTrailingSpace : MD.Tokens.fabMenu.listItemLeadingSpace
110 rightPadding: mirrored ? MD.Tokens.fabMenu.listItemLeadingSpace : MD.Tokens.fabMenu.listItemTrailingSpace
113 spacing: MD.Tokens.fabMenu.listItemIconLabelSpace
116 focusPolicy: menu ? Qt.ClickFocus : Qt.StrongFocus
117 LayoutMirroring.childrenInherit:
true
119 transform: Translate {
120 y: control._entranceOffset
126 when: control._animated && control.menu.expanded
130 when: control._animated && !control.menu.expanded
134 control.scale: control._collapsedScale
135 control._entranceOffset: control._collapsedOffset
136 control.visible:
false
146 SequentialAnimation {
148 duration: control._entranceOrder * MD.Tokens.fabMenu.listItemStaggerDelay
153 properties:
"scale,_entranceOffset"
155 easing.type: Easing.BezierSpline
156 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
157 duration: MotionAnimation.expressiveFastSpatialDuration
164 easing.type: Easing.BezierSpline
165 easing.bezierCurve: MotionAnimation.expressiveFastEffectsCurve
166 duration: MotionAnimation.expressiveFastEffectsDuration
180 SequentialAnimation {
186 duration: control._entranceOrder * MD.Tokens.fabMenu.listItemStaggerDelay
191 properties:
"scale,_entranceOffset"
193 easing.type: Easing.BezierSpline
194 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
195 duration: MotionAnimation.expressiveFastSpatialDuration
202 easing.type: Easing.BezierSpline
203 easing.bezierCurve: MotionAnimation.expressiveFastEffectsCurve
204 duration: MotionAnimation.expressiveFastEffectsDuration
215 readonly
property real leadingWidth: iconSlot.visible ? iconSlot.width + control.spacing : 0
217 implicitWidth: leadingWidth + label.implicitWidth
218 implicitHeight: Math.max(MD.Tokens.fabMenu.listItemIconSize, label.implicitHeight)
222 spacing: control.spacing
223 LayoutMirroring.enabled: control.mirrored
224 LayoutMirroring.childrenInherit:
true
228 objectName:
"fabMenuItemIcon"
230 anchors.verticalCenter: parent.verticalCenter
231 width: MD.Tokens.fabMenu.listItemIconSize
232 height: MD.Tokens.fabMenu.listItemIconSize
233 visible: control._hasIcon
237 source: control.icon.source
238 sourceSize: Qt.size(width, height)
239 fillMode: Image.PreserveAspectFit
240 opacity: control._contentOpacity
241 visible: control._hasSourceIcon
245 anchors.centerIn: parent
246 name: control.icon.name
247 iconWidth: MD.Tokens.fabMenu.listItemIconSize
248 iconHeight: MD.Tokens.fabMenu.listItemIconSize
249 color: control.effectiveContentColor
250 opacity: control._contentOpacity
251 visible: !control._hasSourceIcon && control._hasNamedIcon
257 objectName:
"fabMenuItemLabel"
259 width: Math.max(0, itemContent.width - itemContent.leadingWidth)
260 anchors.verticalCenter: parent.verticalCenter
263 typescale: MD.Tokens.typescale.titleMedium
265 color: control.effectiveContentColor
266 opacity: control._contentOpacity
267 horizontalAlignment: control.mirrored ? Text.AlignRight : Text.AlignLeft
268 elide: Text.ElideRight
273 background: MD.ElevationRectangle {
274 implicitHeight: MD.Tokens.fabMenu.listItemContainerHeight
275 topLeftRadius: UiMetrics.resolveShapeRadius(
276 MD.Tokens.fabMenu.listItemContainerShape.topLeft, width, height)
277 topRightRadius: UiMetrics.resolveShapeRadius(
278 MD.Tokens.fabMenu.listItemContainerShape.topRight, width, height)
279 bottomLeftRadius: UiMetrics.resolveShapeRadius(
280 MD.Tokens.fabMenu.listItemContainerShape.bottomLeft, width, height)
281 bottomRightRadius: UiMetrics.resolveShapeRadius(
282 MD.Tokens.fabMenu.listItemContainerShape.bottomRight, width,
284 color: control.effectiveContainerColor
285 elevation: MD.Tokens.fabMenu.listItemContainerElevation
288 objectName:
"fabMenuItemRipple"
291 topLeftRadius: parent.topLeftRadius
292 topRightRadius: parent.topRightRadius
293 bottomLeftRadius: parent.bottomLeftRadius
294 bottomRightRadius: parent.bottomRightRadius
295 pressed: control.pressed
296 pressX: control.pressX
297 pressY: control.pressY
298 color: control.effectiveContentColor
300 if (!control.enabled)
303 return MD.Tokens.fabMenu.pressedStateLayerOpacity;
304 if (control.visualFocus)
305 return MD.Tokens.fabMenu.focusStateLayerOpacity;
307 return MD.Tokens.fabMenu.hoverStateLayerOpacity;