4pragma ComponentBehavior: Bound
7import QtQuick.Templates as T
9import "../core/UiMetrics.js" as UiMetrics
10import "../internal/MotionAnimation.js" as MotionAnimation
53 property bool expanded:
false
56 property color containerColor: control.MD.Style.primaryContainerColor
59 property color contentColor: control.MD.Style.onPrimaryContainerColor
62 property string collapsedIconName: MD.SymbolNames.symbolAdd
65 property string expandedIconName: MD.SymbolNames.symbolClose
68 readonly
property color effectiveContainerColor: state.containerColor
71 readonly
property color effectiveContentColor: state.contentColor
74 readonly
property real effectiveElevation: state.elevation
76 icon.width: state.iconSize
77 icon.height: state.iconSize
79 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
80 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
90 focusPolicy: Qt.StrongFocus
93 Accessible.role: Accessible.Button
94 Accessible.checkable:
true
95 Accessible.checked: expanded
100 readonly
property real collapsedContainerWidth: {
101 switch (control.size) {
103 return MD.Tokens.fab.containerWidth;
105 return MD.Tokens.fab.mediumContainerWidth;
107 return MD.Tokens.fab.largeContainerWidth;
110 readonly
property real collapsedContainerHeight: {
111 switch (control.size) {
113 return MD.Tokens.fab.containerHeight;
115 return MD.Tokens.fab.mediumContainerHeight;
117 return MD.Tokens.fab.largeContainerHeight;
120 readonly
property MD.shapeValue collapsedContainerShape: {
121 switch (control.size) {
123 return MD.Tokens.fab.containerShape;
125 return MD.Tokens.fab.mediumContainerShape;
127 return MD.Tokens.fab.largeContainerShape;
130 readonly
property real collapsedIconSize: {
131 switch (control.size) {
133 return MD.Tokens.fab.iconSize;
135 return MD.Tokens.fab.mediumIconSize;
137 return MD.Tokens.fab.largeIconSize;
141 property real containerWidth: control.expanded ? MD.Tokens.fabMenu.closeButtonContainerWidth : state.collapsedContainerWidth
142 property real containerHeight: control.expanded ? MD.Tokens.fabMenu.closeButtonContainerHeight : state.collapsedContainerHeight
143 readonly
property MD.shapeValue containerShape: control.expanded
144 ? MD.Tokens.fabMenu.closeButtonContainerShape
145 : state.collapsedContainerShape
146 property real topLeftRadius: UiMetrics.resolveShapeRadius(
147 containerShape.topLeft, containerWidth, containerHeight)
148 property real topRightRadius: UiMetrics.resolveShapeRadius(
149 containerShape.topRight, containerWidth, containerHeight)
150 property real bottomLeftRadius: UiMetrics.resolveShapeRadius(
151 containerShape.bottomLeft, containerWidth,
153 property real bottomRightRadius: UiMetrics.resolveShapeRadius(
154 containerShape.bottomRight, containerWidth,
156 property real iconSize: control.expanded ? MD.Tokens.fabMenu.closeButtonIconSize : state.collapsedIconSize
158 property color containerColor: control.containerColor
159 property color contentColor: control.contentColor
160 property color stateLayerColor:
"transparent"
162 property real elevation: control.expanded ? MD.Tokens.fabMenu.closeButtonContainerElevation : MD.Tokens.fab.containerElevation
163 property real stateLayerOpacity: 0
165 Behavior on containerWidth {
168 easing.type: Easing.BezierSpline
169 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
170 duration: MotionAnimation.expressiveFastSpatialDuration
175 Behavior on containerHeight {
178 easing.type: Easing.BezierSpline
179 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
180 duration: MotionAnimation.expressiveFastSpatialDuration
185 Behavior on topLeftRadius {
188 easing.type: Easing.BezierSpline
189 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
190 duration: MotionAnimation.expressiveFastSpatialDuration
195 Behavior on topRightRadius {
198 easing.type: Easing.BezierSpline
199 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
200 duration: MotionAnimation.expressiveFastSpatialDuration
205 Behavior on bottomLeftRadius {
208 easing.type: Easing.BezierSpline
209 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
210 duration: MotionAnimation.expressiveFastSpatialDuration
215 Behavior on bottomRightRadius {
218 easing.type: Easing.BezierSpline
219 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
220 duration: MotionAnimation.expressiveFastSpatialDuration
225 Behavior on iconSize {
228 easing.type: Easing.BezierSpline
229 easing.bezierCurve: MotionAnimation.expressiveFastSpatialCurve
230 duration: MotionAnimation.expressiveFastSpatialDuration
239 when: control.down && control.enabled
242 state.elevation: control.expanded ? MD.Tokens.fabMenu.closeButtonPressedContainerElevation : MD.Tokens.fab.pressedContainerElevation
243 state.stateLayerColor: control.effectiveContentColor
244 state.stateLayerOpacity: MD.Tokens.fabMenu.pressedStateLayerOpacity
249 when: control.visualFocus && control.enabled
252 state.elevation: control.expanded ? MD.Tokens.fabMenu.closeButtonFocusContainerElevation : MD.Tokens.fab.focusContainerElevation
253 state.stateLayerColor: control.effectiveContentColor
254 state.stateLayerOpacity: MD.Tokens.fabMenu.focusStateLayerOpacity
259 when: control.hovered && control.enabled
262 state.elevation: control.expanded ? MD.Tokens.fabMenu.closeButtonHoverContainerElevation : MD.Tokens.fab.hoverContainerElevation
263 state.stateLayerColor: control.effectiveContentColor
264 state.stateLayerOpacity: MD.Tokens.fabMenu.hoverStateLayerOpacity
270 implicitWidth: state.iconSize
271 implicitHeight: state.iconSize
274 objectName:
"fabMenuButtonCollapsedSymbol"
276 anchors.centerIn: parent
277 name: control.collapsedIconName
278 iconWidth: state.iconSize
279 iconHeight: state.iconSize
280 color: control.effectiveContentColor
281 opacity: control.expanded ? 0 : 1
284 Behavior on opacity {
286 duration: MD.Tokens.motion.duration.short4
292 objectName:
"fabMenuButtonExpandedSymbol"
294 anchors.centerIn: parent
295 name: control.expandedIconName
296 iconWidth: state.iconSize
297 iconHeight: state.iconSize
298 color: control.effectiveContentColor
299 opacity: control.expanded ? 1 : 0
302 Behavior on opacity {
304 duration: MD.Tokens.motion.duration.short4
310 background: MD.ElevationRectangle {
311 implicitWidth: state.containerWidth
312 implicitHeight: state.containerHeight
313 topLeftRadius: state.topLeftRadius
314 topRightRadius: state.topRightRadius
315 bottomLeftRadius: state.bottomLeftRadius
316 bottomRightRadius: state.bottomRightRadius
317 color: state.containerColor
318 elevation: state.elevation
321 objectName:
"fabMenuButtonRipple"
324 topLeftRadius: parent.topLeftRadius
325 topRightRadius: parent.topRightRadius
326 bottomLeftRadius: parent.bottomLeftRadius
327 bottomRightRadius: parent.bottomRightRadius
328 pressed: control.pressed
329 pressX: control.pressX
330 pressY: control.pressY
331 stateOpacity: state.stateLayerOpacity
332 color: state.stateLayerColor