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,82 +145,64 @@ 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;
} else {
height = root.size;
}
if(vertical && isActive && activeStyle === 0 /*Line*/) { property bool isBindingBlocked: isAnimating
height = stateHeight;
} else {
height = root.size;
}
if(!vertical && isActive && activeStyle === 0 /*Line*/) { readonly property bool isActiveStateForAnimation: indicator.isActive && root.activeStyle === 0 /*Line*/
width = stateWidth;
onIsActiveStateForAnimationChanged: {
if (root.activeStyle === 0 /*Line*/) {
if (isActiveStateForAnimation) {
inGrowAnimation = true;
inShrinkAnimation = false;
} else { } else {
width = root.size; inGrowAnimation = false;
inShrinkAnimation = true;
}
} else {
inGrowAnimation = false;
inShrinkAnimation = false;
}
}
onWidthChanged: {
if (!vertical) {
if (inGrowAnimation && width >= stateWidth) {
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*/) duration: firstPoint.animationTime
width = stateWidth; easing.type: Easing.Linear
}
onStateHeightChanged:{
if(!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/)
height = stateHeight;
}
onVerticalChanged: updateInitialSizes();
Component.onCompleted: {
updateInitialSizes();
if (indicator) {
indicator.onCurrentIconSizeChanged.connect(updateInitialSizes);
} }
} }
Component.onDestruction: { Behavior on height {
if (indicator) { enabled: (firstPoint.vertical && (firstPoint.isAnimating || firstPoint.opacity === 0/*first showing requirement*/))
indicator.onCurrentIconSizeChanged.disconnect(updateInitialSizes); NumberAnimation {
duration: firstPoint.animationTime
easing.type: Easing.Linear
} }
} }
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
easing.type: Easing.InQuad
onStopped: firstPoint.updateInitialSizes()
}
} }
Item{ Item{