1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00

Indicators:different margins for applets

--indicators gained a way to set different margins
for applets if they want to
This commit is contained in:
Michail Vourlakos 2019-08-30 15:03:13 +03:00
parent edfd111d9a
commit 5a2c59601c
7 changed files with 52 additions and 18 deletions

View File

@ -131,7 +131,7 @@ Item {
property int previousIndex: -1
property int sizeForFill: -1 //it is used in calculations for fillWidth,fillHeight applets
property int spacersMaxSize: Math.max(0,Math.ceil(0.55 * root.iconSize) - root.lengthMargins)
property int spacersMaxSize: Math.max(0,Math.ceil(0.55 * root.iconSize) - root.lengthAppletMargins)
property int status: applet ? applet.status : -1
//! are set by the indicator

View File

@ -33,7 +33,7 @@ Item{
property bool neighbourSeparator: false;
property int separatorSpace: neighbourSeparator && !appletItem.isSeparator && root.parabolicEffectEnabled
&& !appletItem.latteApplet ? (2.5+root.lengthExtMargin) : 0
&& !appletItem.latteApplet ? (2.5+root.lengthExtMargin) : subtrackedMargins
property real nHiddenSize: {
if (isSeparator || !communicator.lengthMarginsEnabled) {
@ -45,6 +45,10 @@ Item{
property bool rightSpacer: false
readonly property bool atEdgeForcingFittsLaw: !isSeparator && !root.parabolicEffectEnabled && root.inFullJustify && atScreenEdge && !isSquare
readonly property int subtrackedMargins: atEdgeForcingFittsLaw && ((startEdge && rightSpacer) || (endEdge && !rightSpacer )) ?
root.lengthAppletIntMargin + root.lengthExtMargin : 0
property real nScale: 0
Behavior on nHiddenSize {

View File

@ -117,12 +117,13 @@ Item{
property int marginWidth: root.isVertical ?
root.thickMargins :
(root.inFullJustify && atScreenEdge ? 0 : localLengthMargins) //Fitt's Law
(root.inFullJustify && atScreenEdge ? edgeLengthMargins : localLengthMargins) //Fitt's Law
property int marginHeight: root.isHorizontal ?
root.thickMargins :
(root.inFullJustify && atScreenEdge ? 0 : localLengthMargins) //Fitt's Law
(root.inFullJustify && atScreenEdge ? edgeLengthMargins : localLengthMargins) //Fitt's Law
property int localLengthMargins: isSeparator || !communicator.lengthMarginsEnabled ? 0 : root.lengthMargins
property int localLengthMargins: isSeparator || !communicator.lengthMarginsEnabled ? 0 : root.lengthAppletMargins
property int edgeLengthMargins: isSeparator || !communicator.lengthMarginsEnabled || !isSquare ? 0 : root.lengthAppletMargins
property real scaledWidth: zoomScaleWidth * (layoutWidth + marginWidth)
property real scaledHeight: zoomScaleHeight * (layoutHeight + marginHeight)

View File

@ -42,11 +42,11 @@ Loader {
return indicators.indicatorComponent;
}
width: root.isHorizontal && !(root.inFullJustify && atScreenEdge /*Fitt's Law*/) ?
width: root.isHorizontal && !(root.inFullJustify && atScreenEdge /*Fitt's Law*/ && !isSquare) ?
appletItem.wrapperAlias.width - 2*appletItem.wrapperAlias.zoomScale*root.lengthExtMargin
: appletItem.wrapperAlias.width
height: root.isVertical && !(root.inFullJustify && atScreenEdge /*Fitt's Law*/) ?
height: root.isVertical && !(root.inFullJustify && atScreenEdge /*Fitt's Law*/ && !isSquare) ?
appletItem.wrapperAlias.height - 2*appletItem.wrapperAlias.zoomScale*root.lengthExtMargin :
appletItem.wrapperAlias.height

View File

@ -37,27 +37,29 @@ Item{
readonly property real padding: Math.max(info.minLengthPadding, latteView && latteView.indicator ? latteView.indicator.padding : 0.08)
readonly property string type: latteView && latteView.indicator ? latteView.indicator.type : "org.kde.latte.default"
readonly property bool infoLoaded: metricsLoader.active && metricsLoader.item
readonly property Component plasmaStyleComponent: latteView && latteView.indicator ? latteView.indicator.plasmaComponent : null
readonly property Component indicatorComponent: latteView && latteView.indicator ? latteView.indicator.component : null
readonly property Item info: Item{
readonly property bool needsIconColors: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsIconColors")
readonly property bool needsIconColors: infoLoaded && metricsLoader.item.hasOwnProperty("needsIconColors")
&& metricsLoader.item.needsIconColors
readonly property bool needsMouseEventCoordinates: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsMouseEventCoordinates")
readonly property bool needsMouseEventCoordinates: infoLoaded && metricsLoader.item.hasOwnProperty("needsMouseEventCoordinates")
&& metricsLoader.item.needsMouseEventCoordinates
readonly property bool providesFrontLayer: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesFrontLayer")
readonly property bool providesFrontLayer: minfoLoaded && metricsLoader.item.hasOwnProperty("providesFrontLayer")
&& metricsLoader.item.providesFrontLayer
readonly property bool providesHoveredAnimation: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesHoveredAnimation")
readonly property bool providesHoveredAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesHoveredAnimation")
&& metricsLoader.item.providesHoveredAnimation
readonly property bool providesClickedAnimation: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesClickedAnimation")
readonly property bool providesClickedAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesClickedAnimation")
&& metricsLoader.item.providesClickedAnimation
readonly property int extraMaskThickness: {
if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("extraMaskThickness")) {
if (infoLoaded && metricsLoader.item.hasOwnProperty("extraMaskThickness")) {
return metricsLoader.item.extraMaskThickness;
}
@ -65,7 +67,7 @@ Item{
}
readonly property real minThicknessPadding: {
if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("minThicknessPadding")) {
if (infoLoaded && metricsLoader.item.hasOwnProperty("minThicknessPadding")) {
return metricsLoader.item.minThicknessPadding;
}
@ -73,14 +75,22 @@ Item{
}
readonly property real minLengthPadding: {
if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("minLengthPadding")) {
if (infoLoaded && metricsLoader.item.hasOwnProperty("minLengthPadding")) {
return metricsLoader.item.minLengthPadding;
}
return 0;
}
readonly property variant svgPaths: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("svgImagePaths") ?
readonly property real appletLengthPadding: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("appletLengthPadding")) {
return metricsLoader.item.appletLengthPadding;
}
return -1;
}
readonly property variant svgPaths: infoLoaded && metricsLoader.item.hasOwnProperty("svgImagePaths") ?
metricsLoader.item.svgImagePaths : []
onSvgPathsChanged: latteView.indicator.resources.setSvgImagePaths(svgPaths);

View File

@ -377,6 +377,9 @@ Item {
property real lengthIntMarginFactor: indicators.isEnabled ? indicators.padding : 0
property real lengthExtMarginFactor: plasmoid.configuration.lengthExtMargin / 100
property int lengthAppletIntMargin: lengthAppletIntMarginFactor === -1 ? lengthIntMargin : lengthAppletIntMarginFactor * root.iconSize
property real lengthAppletIntMarginFactor: indicators.infoLoaded && !parabolicEffectEnabled ? indicators.info.appletLengthPadding : -1
property real thickMarginFactor: {
if (shrinkThickMargins) {
return indicators.info.minThicknessPadding;
@ -398,11 +401,14 @@ Item {
property int lengthMargin: lengthIntMargin + lengthExtMargin
property int lengthMargins: 2 * lengthMargin
property int lengthAppletMargin: lengthAppletIntMargin + lengthExtMargin
property int lengthAppletMargins: 2 * lengthAppletIntMargin
property int widthMargins: root.isVertical ? thickMargins : lengthMargins
property int heightMargins: root.isHorizontal ? thickMargins : lengthMargins
property int internalWidthMargins: root.isVertical ? thickMargins : 2 * lengthIntMargin
property int internalHeightMargins: root.isHorizontal ? thickMargins : 2 * lengthIntMargin
property int internalWidthMargins: root.isVertical ? thickMargins : 2 * lengthAppletMargin
property int internalHeightMargins: root.isHorizontal ? thickMargins : 2 * lengthAppletMargin
///FIXME: <delete both> I can't remember why this is needed, maybe for the anchorings!!! In order for the Double Layout to not mess the anchorings...
//property int layoutsContainer.mainLayoutPosition: !plasmoid.immutable ? Latte.Types.Center : (root.isVertical ? Latte.Types.Top : Latte.Types.Left)
@ -607,6 +613,13 @@ Item {
}
}
Behavior on lengthAppletIntMargin {
NumberAnimation {
duration: 0.8 * root.animationTime
easing.type: Easing.OutCubic
}
}
Behavior on lengthExtMargin {
NumberAnimation {
duration: 0.8 * root.animationTime

View File

@ -49,6 +49,12 @@ Item {
//! e.g 0.06 -> 6%
property real minLengthPadding: 0
//! this indicator specifies a different padding value for applets. This value is a percentage,
//! -1, means disabled and the regular padding is used
//! 0.06 -> 6%
//! [since v0.9.2]
property real appletLengthPadding: -1
//! svg image paths either from plasma theme or local files relevant to indicator "ui" directory
//! in order to reduce resources usage
property var svgImagePaths: []