1/*
2    SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
3    SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6import QtQuick 2.7
7
8import org.kde.plasma.plasmoid 2.0
9import org.kde.plasma.core 2.0 as PlasmaCore
10
11import org.kde.latte.core 0.2 as LatteCore
12
13import "./privates" as Ability
14
15Ability.MetricsPrivate {
16    id: metrics
17    //! Signals
18    signal iconSizeAnimationEnded();
19
20    //! Public Properties
21    iconSize: _iconSize
22    maxIconSize: _maxIconSize
23    backgroundThickness: background.thickness
24
25    //! Margin
26    margin.length: fraction.lengthMargin * iconSize
27    margin.thickness: marginMinThickness + fraction.thicknessMargin * Math.max(0, _iconSize - marginMinThickness)
28    margin.maxThickness: marginMinThickness + fraction.thicknessMargin * Math.max(0, _maxIconSize - marginMinThickness)
29    //margin.thickness: fraction.thicknessMargin * iconSize
30   // margin.maxThickness: fraction.thicknessMargin * maxIconSize
31    margin.screenEdge: (root.screenEdgeMarginEnabled && root.behaveAsPlasmaPanel)
32                       || !root.screenEdgeMarginEnabled
33                       || root.hideThickScreenGap ?
34                           0 : plasmoid.configuration.screenEdgeMargin
35
36    //! MarginsAra
37    marginsArea.marginThickness: {
38        if (!themeExtended) {
39            return metrics.margin.thickness;
40        }
41
42        if (plasmoid.location === PlasmaCore.Types.TopEdge) {
43            return themeExtended.marginsAreaBottom + metrics.margin.thickness;
44        } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
45            return themeExtended.marginsAreaRight + metrics.margin.thickness;
46        } else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
47            return themeExtended.marginsAreaLeft + metrics.margin.thickness;
48        }
49
50        return themeExtended.marginsAreaTop + metrics.margin.thickness;
51    }
52
53    //! Mask
54    mask.maxScreenEdge : root.behaveAsDockWithMask ? Math.max(0, plasmoid.configuration.screenEdgeMargin) : 0
55      // window geometry is updated after the local screen margin animation was zeroed*/
56    mask.screenEdge: (!root.screenEdgeMarginEnabled || root.hideThickScreenGap) ? 0 : plasmoid.configuration.screenEdgeMargin
57
58    mask.thickness.hidden: LatteCore.WindowSystem.compositingActive ?  2 : 1
59    mask.thickness.normal: mask.screenEdge + Math.max(totals.thickness + extraThicknessForNormal, background.thickness + background.shadows.headThickness)
60    mask.thickness.medium: mask.screenEdge + (1 + (0.65 * (parabolic.factor.maxZoom-1)))*(totals.thickness+extraThicknessForZoomed)
61    mask.thickness.zoomed: mask.screenEdge + ((totals.thickness+extraThicknessForZoomed) * parabolic.factor.maxZoom) + 2
62    mask.thickness.maxNormal: mask.maxScreenEdge + maxIconSize + (margin.maxThickness * 2) + extraThicknessForNormal
63    mask.thickness.maxMedium: mask.maxScreenEdge + Math.max(mask.thickness.maxNormalForItems, extraThicknessForNormal + (1 + (0.65 * (parabolic.factor.maxZoom-1)))*(maxIconSize+margin.maxThickness))
64    mask.thickness.maxZoomed: mask.maxScreenEdge + Math.max( ((maxIconSize+(margin.maxThickness * 2)) * parabolic.factor.maxZoom) + extraThicknessForZoomed,
65                                                                    background.thickness + background.shadows.headThickness)
66
67    mask.thickness.normalForItems: margin.screenEdge + totals.thickness
68    mask.thickness.zoomedForItems: margin.screenEdge + (parabolic.factor.zoom * totals.thickness)
69
70    mask.thickness.maxNormalForItemsWithoutScreenEdge: maxIconSize + (margin.maxThickness * 2)
71    mask.thickness.maxZoomedForItemsWithoutScreenEdge: (maxIconSize + (margin.maxThickness * 2)) * parabolic.factor.maxZoom
72
73    mask.thickness.maxNormalForItems: mask.maxScreenEdge + mask.thickness.maxNormalForItemsWithoutScreenEdge
74    mask.thickness.maxZoomedForItems: mask.maxScreenEdge + mask.thickness.maxZoomedForItemsWithoutScreenEdge
75
76    //! Padding
77    padding.length: fraction.lengthPadding * iconSize
78    padding.lengthApplet: fraction.lengthAppletPadding * iconSize
79}
80