1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

simplify latte indicator implementation

--fix also the line animation in order to be always
played correctly
This commit is contained in:
Michail Vourlakos 2021-10-24 11:59:42 +03:00
parent ea500a8ec0
commit e2b98892e5
2 changed files with 65 additions and 68 deletions

View File

@ -679,7 +679,7 @@ Item {
target: root.latteView ? root.latteView.extendedInterface : null target: root.latteView ? root.latteView.extendedInterface : null
enabled: !appletItem.indexerIsSupported && !appletItem.isSeparator && !appletItem.isSpacer && !appletItem.isHidden enabled: !appletItem.indexerIsSupported && !appletItem.isSeparator && !appletItem.isSpacer && !appletItem.isHidden
onHasExpandedAppletChanged: { onExpandedAppletStateChanged: {
if (latteView.extendedInterface.hasExpandedApplet && appletItem.applet) { if (latteView.extendedInterface.hasExpandedApplet && appletItem.applet) {
appletItem.isExpanded = latteView.extendedInterface.appletIsExpandable(appletItem.applet.id) appletItem.isExpanded = latteView.extendedInterface.appletIsExpandable(appletItem.applet.id)
&& latteView.extendedInterface.appletIsExpanded(appletItem.applet.id); && latteView.extendedInterface.appletIsExpanded(appletItem.applet.id);

View File

@ -83,17 +83,19 @@ LatteComponents.IndicatorItem{
LatteComponents.GlowPoint{ LatteComponents.GlowPoint{
id:firstPoint id:firstPoint
width: stateWidth
height: stateHeight
opacity: { opacity: {
if (indicator.isEmptySpace) { if (indicator.isEmptySpace) {
return 0; return 0;
} }
if (indicator.isTask) { if (indicator.isTask) {
return indicator.isLauncher || (indicator.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 return indicator.isLauncher || (indicator.inRemoving && !isAnimating) ? 0 : 1
} }
if (indicator.isApplet) { if (indicator.isApplet) {
return (indicator.isActive || activeAndReverseAnimation.running) ? 1 : 0 return (indicator.isActive || isAnimating) ? 1 : 0
} }
} }
@ -117,12 +119,25 @@ LatteComponents.IndicatorItem{
else else
return false; return false;
} }
showBorder: glowEnabled && glow3D showBorder: glow3D
property int stateWidth: (indicator.isGroup ? root.width - secondPoint.width : root.width - spacer.width) - glowMargins property int stateWidth: {
property int stateHeight: (indicator.isGroup ? root.height - secondPoint.height : root.height - spacer.height) - glowMargins if (!vertical && isActive && activeStyle === 0 /*Line*/) {
return (indicator.isGroup ? root.width - secondPoint.width : root.width - spacer.width) - glowMargins;
}
property int animationTime: indicator.durationTime* (0.7*LatteCore.Environment.longDuration) return root.size;
}
property int stateHeight: {
if (vertical && isActive && activeStyle === 0 /*Line*/) {
return (indicator.isGroup ? root.height - secondPoint.height : root.height - spacer.height) - glowMargins;
}
return root.size;
}
property int animationTime: indicator.durationTime* (0.75*LatteCore.Environment.longDuration)
property bool isActive: indicator.hasActive || indicator.isActive property bool isActive: indicator.hasActive || indicator.isActive
@ -130,81 +145,63 @@ LatteComponents.IndicatorItem{
property real scaleFactor: indicator.scaleFactor property real scaleFactor: indicator.scaleFactor
function updateInitialSizes(){ readonly property bool isAnimating: inGrowAnimation || inShrinkAnimation
if(root){ property bool inGrowAnimation: false
if(vertical) { property bool inShrinkAnimation: false
width = root.size;
property bool isBindingBlocked: isAnimating
readonly property bool isActiveStateForAnimation: indicator.isActive && root.activeStyle === 0 /*Line*/
onIsActiveStateForAnimationChanged: {
if (root.activeStyle === 0 /*Line*/) {
if (isActiveStateForAnimation) {
inGrowAnimation = true;
inShrinkAnimation = false;
} else { } else {
height = root.size; inGrowAnimation = false;
inShrinkAnimation = true;
} }
if(vertical && isActive && activeStyle === 0 /*Line*/) {
height = stateHeight;
} else { } else {
height = root.size; inGrowAnimation = false;
inShrinkAnimation = false;
}
} }
if(!vertical && isActive && activeStyle === 0 /*Line*/) { onWidthChanged: {
width = stateWidth; if (!vertical) {
} else { if (inGrowAnimation && width >= stateWidth) {
width = root.size; inGrowAnimation = false;
} else if (inShrinkAnimation && width <= stateWidth) {
inShrinkAnimation = false;
} }
} }
} }
onHeightChanged: {
onIsActiveChanged: { if (vertical) {
if (activeStyle === 0 /*Line*/) if (inGrowAnimation && height >= stateHeight) {
activeAndReverseAnimation.start(); inGrowAnimation = false;
} else if (inShrinkAnimation && height <= stateHeight) {
inShrinkAnimation = false;
} }
onScaleFactorChanged: {
if(!activeAndReverseAnimation.running && !vertical && isActive && activeStyle === 0 /*Line*/){
width = stateWidth;
}
else if (!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/){
height = stateHeight;
} }
} }
onSizeChanged: updateInitialSizes(); Behavior on width {
enabled: (!firstPoint.vertical && (firstPoint.isAnimating || firstPoint.opacity === 0/*first showing requirement*/))
onStateWidthChanged:{ NumberAnimation {
if(!activeAndReverseAnimation.running && !vertical && isActive && activeStyle === 0 /*Line*/)
width = stateWidth;
}
onStateHeightChanged:{
if(!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/)
height = stateHeight;
}
onVerticalChanged: updateInitialSizes();
Component.onCompleted: {
updateInitialSizes();
if (indicator) {
indicator.onCurrentIconSizeChanged.connect(updateInitialSizes);
}
}
Component.onDestruction: {
if (indicator) {
indicator.onCurrentIconSizeChanged.disconnect(updateInitialSizes);
}
}
NumberAnimation{
id: activeAndReverseAnimation
target: firstPoint
property: plasmoid.formFactor === PlasmaCore.Types.Vertical ? "height" : "width"
to: indicator.hasActive && activeStyle === 0 /*Line*/
? (plasmoid.formFactor === PlasmaCore.Types.Vertical ? firstPoint.stateHeight : firstPoint.stateWidth) : root.size
duration: firstPoint.animationTime duration: firstPoint.animationTime
easing.type: Easing.InQuad easing.type: Easing.Linear
}
}
onStopped: firstPoint.updateInitialSizes() Behavior on height {
enabled: (firstPoint.vertical && (firstPoint.isAnimating || firstPoint.opacity === 0/*first showing requirement*/))
NumberAnimation {
duration: firstPoint.animationTime
easing.type: Easing.Linear
}
} }
} }