mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-25 09:33:51 +03:00
simplify latte indicator implementation
--fix also the line animation in order to be always played correctly
This commit is contained in:
parent
ea500a8ec0
commit
e2b98892e5
@ -679,7 +679,7 @@ Item {
|
||||
target: root.latteView ? root.latteView.extendedInterface : null
|
||||
enabled: !appletItem.indexerIsSupported && !appletItem.isSeparator && !appletItem.isSpacer && !appletItem.isHidden
|
||||
|
||||
onHasExpandedAppletChanged: {
|
||||
onExpandedAppletStateChanged: {
|
||||
if (latteView.extendedInterface.hasExpandedApplet && appletItem.applet) {
|
||||
appletItem.isExpanded = latteView.extendedInterface.appletIsExpandable(appletItem.applet.id)
|
||||
&& latteView.extendedInterface.appletIsExpanded(appletItem.applet.id);
|
||||
|
@ -83,17 +83,19 @@ LatteComponents.IndicatorItem{
|
||||
|
||||
LatteComponents.GlowPoint{
|
||||
id:firstPoint
|
||||
width: stateWidth
|
||||
height: stateHeight
|
||||
opacity: {
|
||||
if (indicator.isEmptySpace) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (indicator.isTask) {
|
||||
return indicator.isLauncher || (indicator.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1
|
||||
return indicator.isLauncher || (indicator.inRemoving && !isAnimating) ? 0 : 1
|
||||
}
|
||||
|
||||
if (indicator.isApplet) {
|
||||
return (indicator.isActive || activeAndReverseAnimation.running) ? 1 : 0
|
||||
return (indicator.isActive || isAnimating) ? 1 : 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,12 +119,25 @@ LatteComponents.IndicatorItem{
|
||||
else
|
||||
return false;
|
||||
}
|
||||
showBorder: glowEnabled && glow3D
|
||||
showBorder: glow3D
|
||||
|
||||
property int stateWidth: (indicator.isGroup ? root.width - secondPoint.width : root.width - spacer.width) - glowMargins
|
||||
property int stateHeight: (indicator.isGroup ? root.height - secondPoint.height : root.height - spacer.height) - glowMargins
|
||||
property int stateWidth: {
|
||||
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
|
||||
|
||||
@ -130,82 +145,64 @@ LatteComponents.IndicatorItem{
|
||||
|
||||
property real scaleFactor: indicator.scaleFactor
|
||||
|
||||
function updateInitialSizes(){
|
||||
if(root){
|
||||
if(vertical) {
|
||||
width = root.size;
|
||||
} else {
|
||||
height = root.size;
|
||||
}
|
||||
readonly property bool isAnimating: inGrowAnimation || inShrinkAnimation
|
||||
property bool inGrowAnimation: false
|
||||
property bool inShrinkAnimation: false
|
||||
|
||||
if(vertical && isActive && activeStyle === 0 /*Line*/) {
|
||||
height = stateHeight;
|
||||
} else {
|
||||
height = root.size;
|
||||
}
|
||||
property bool isBindingBlocked: isAnimating
|
||||
|
||||
if(!vertical && isActive && activeStyle === 0 /*Line*/) {
|
||||
width = stateWidth;
|
||||
readonly property bool isActiveStateForAnimation: indicator.isActive && root.activeStyle === 0 /*Line*/
|
||||
|
||||
onIsActiveStateForAnimationChanged: {
|
||||
if (root.activeStyle === 0 /*Line*/) {
|
||||
if (isActiveStateForAnimation) {
|
||||
inGrowAnimation = true;
|
||||
inShrinkAnimation = false;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onIsActiveChanged: {
|
||||
if (activeStyle === 0 /*Line*/)
|
||||
activeAndReverseAnimation.start();
|
||||
}
|
||||
|
||||
onScaleFactorChanged: {
|
||||
if(!activeAndReverseAnimation.running && !vertical && isActive && activeStyle === 0 /*Line*/){
|
||||
width = stateWidth;
|
||||
}
|
||||
else if (!activeAndReverseAnimation.running && vertical && isActive && activeStyle === 0 /*Line*/){
|
||||
height = stateHeight;
|
||||
onHeightChanged: {
|
||||
if (vertical) {
|
||||
if (inGrowAnimation && height >= stateHeight) {
|
||||
inGrowAnimation = false;
|
||||
} else if (inShrinkAnimation && height <= stateHeight) {
|
||||
inShrinkAnimation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSizeChanged: updateInitialSizes();
|
||||
|
||||
onStateWidthChanged:{
|
||||
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);
|
||||
Behavior on width {
|
||||
enabled: (!firstPoint.vertical && (firstPoint.isAnimating || firstPoint.opacity === 0/*first showing requirement*/))
|
||||
NumberAnimation {
|
||||
duration: firstPoint.animationTime
|
||||
easing.type: Easing.Linear
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (indicator) {
|
||||
indicator.onCurrentIconSizeChanged.disconnect(updateInitialSizes);
|
||||
Behavior on height {
|
||||
enabled: (firstPoint.vertical && (firstPoint.isAnimating || firstPoint.opacity === 0/*first showing requirement*/))
|
||||
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{
|
||||
|
Loading…
Reference in New Issue
Block a user