1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-02-04 13:47:19 +03:00

references improvements in container qml

This commit is contained in:
Michail Vourlakos 2020-04-26 15:07:22 +03:00
parent c43dd6d003
commit 368b4b8441
9 changed files with 74 additions and 66 deletions

View File

@ -153,7 +153,7 @@ Item {
readonly property bool isSquare: communicator.overlayLatteIconIsActive
readonly property bool screenEdgeMarginSupported: communicator.requires.screenEdgeMarginSupported
property int animationTime: animations.speedFactor.normal * (1.2*animations.duration.small)
property int animationTime: appletItem.animations.speedFactor.normal * (1.2*appletItem.animations.duration.small)
property int hoveredIndex: layoutsContainer.hoveredIndex
property int index: -1
property int maxWidth: root.isHorizontal ? root.height : root.width
@ -223,6 +223,9 @@ Item {
property Item communicatorAlias: communicator
property Item wrapperAlias: wrapper
property Item animations: null
property Item container: null
property bool containsMouse: appletMouseArea.containsMouse /*|| appletMouseAreaBottom.containsMouse*/
property bool pressed: viewSignalsConnector.pressed || clickedAnimation.running
@ -291,7 +294,7 @@ Item {
NumberAnimation {
id: translAnim
duration: animations.duration.large
duration: appletItem.animations.duration.large
easing.type: Easing.InOutQuad
target: translation
properties: "x,y"
@ -300,7 +303,7 @@ Item {
Behavior on lengthAppletIntMargin {
NumberAnimation {
duration: 0.8 * animations.duration.proposed
duration: 0.8 * appletItem.animations.duration.proposed
easing.type: Easing.OutCubic
}
}
@ -397,8 +400,8 @@ Item {
return;
}
var maxSize = container.iconSize + root.thickMargins;
var maxForMinimumSize = container.iconSize + root.thickMargins;
var maxSize = appletItem.container.iconSize + root.thickMargins;
var maxForMinimumSize = appletItem.container.iconSize + root.thickMargins;
if ( isSystray
|| appletItem.needsFillSpace
@ -521,7 +524,7 @@ Item {
}
Component.onDestruction: {
animations.needBothAxis.removeEvent(appletItem);
appletItem.animations.needBothAxis.removeEvent(appletItem);
if (isSeparator){
parabolicManager.setSeparator(previousIndex, -1);
@ -791,6 +794,7 @@ Item {
TitleTooltipParent{
id: titleTooltipParent
container: appletItem.container
}
}
@ -807,7 +811,7 @@ Item {
Behavior on opacity {
NumberAnimation {
duration: 1.2 * animations.duration.proposed
duration: 1.2 * appletItem.animations.duration.proposed
easing.type: Easing.OutCubic
}
}
@ -828,7 +832,7 @@ Item {
width: {
if (root.isHorizontal) {
return container.iconSize * wrapper.zoomScale
return appletItem.container.iconSize * wrapper.zoomScale
} else {
return badgeThickness;
}
@ -838,17 +842,17 @@ Item {
if (root.isHorizontal) {
return badgeThickness;
} else {
return container.iconSize * wrapper.zoomScale
return appletItem.container.iconSize * wrapper.zoomScale
}
}
readonly property int badgeThickness: {
if (plasmoid.location === PlasmaCore.Types.BottomEdge
|| plasmoid.location === PlasmaCore.Types.RightEdge) {
return ((container.iconSize + root.thickMargin) * wrapper.zoomScale) + root.localScreenEdgeMargin;
return ((appletItem.container.iconSize + root.thickMargin) * wrapper.zoomScale) + root.localScreenEdgeMargin;
}
return ((container.iconSize + root.thickMargin) * wrapper.zoomScale);
return ((appletItem.container.iconSize + root.thickMargin) * wrapper.zoomScale);
}
ShortcutBadge{
@ -907,10 +911,10 @@ Item {
// width: root.isHorizontal ? parent.width : parent.width - root.localScreenEdgeMargin
// height: root.isHorizontal ? parent.height - root.localScreenEdgeMargin : parent.height
radius: container.iconSize/10
radius: appletItem.container.iconSize/10
opacity: root.addLaunchersMessage ? 1 : 0
backgroundOpacity: 0.75
duration: animations.speedFactor.current
duration: appletItem.animations.speedFactor.current
title: i18n("Tasks Area")
}
@ -1077,7 +1081,7 @@ Item {
if( ((wrapper.zoomScale == 1 || wrapper.zoomScale === root.zoomFactor) && !root.globalDirectRender) || root.globalDirectRender) {
if (root.isHorizontal){
var step = Math.abs(layoutsContainer.currentSpot-mouse.x);
if (step >= animations.hoverPixelSensitivity){
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouse.x;
wrapper.calculateScales(mouse.x);
@ -1085,7 +1089,7 @@ Item {
}
else{
var step = Math.abs(layoutsContainer.currentSpot-mouse.y);
if (step >= animations.hoverPixelSensitivity){
if (step >= appletItem.animations.hoverPixelSensitivity){
layoutsContainer.currentSpot = mouse.y;
wrapper.calculateScales(mouse.y);
@ -1191,14 +1195,14 @@ Item {
id: clickedAnimation
alwaysRunToEnd: true
running: appletItem.isSquare && !originalAppletBehavior && appletItem.pressed
&& (animations.speedFactor.current > 0) && !indicators.info.providesClickedAnimation
&& (appletItem.animations.speedFactor.current > 0) && !indicators.info.providesClickedAnimation
ParallelAnimation{
PropertyAnimation {
target: wrapper.clickedEffect
property: "brightness"
to: -0.35
duration: animations.duration.large
duration: appletItem.animations.duration.large
easing.type: Easing.OutQuad
}
}
@ -1207,7 +1211,7 @@ Item {
target: wrapper.clickedEffect
property: "brightness"
to: 0
duration: animations.duration.large
duration: appletItem.animations.duration.large
easing.type: Easing.OutQuad
}
}

View File

@ -49,7 +49,7 @@ Item{
var constrainedWidth = MathTools.bound(applet.Layout.minimumWidth, applet.Layout.preferredWidth, maximumValue);
return root.inConfigureAppletsMode ? Math.max(constrainedWidth, container.iconSize) : constrainedWidth;
return root.inConfigureAppletsMode ? Math.max(constrainedWidth, appletItem.container.iconSize) : constrainedWidth;
}
if(appletItem.sizeForFill>-1){
@ -61,7 +61,7 @@ Item{
return latteApplet.tasksWidth;
} else {
if (root.isHorizontal && root.inConfigureAppletsMode) {
return Math.max(Math.min(container.iconSize, root.minAppletLengthInConfigure), scaledWidth);
return Math.max(Math.min(appletItem.container.iconSize, root.minAppletLengthInConfigure), scaledWidth);
}
return root.isVertical ? scaledWidth + root.localScreenEdgeMargin : scaledWidth;
@ -84,7 +84,7 @@ Item{
var constrainedHeight = MathTools.bound(applet.Layout.minimumHeight, applet.Layout.preferredHeight, maximumValue);
return root.inConfigureAppletsMode ? Math.max(constrainedHeight, container.iconSize) : constrainedHeight;
return root.inConfigureAppletsMode ? Math.max(constrainedHeight, appletItem.container.iconSize) : constrainedHeight;
}
if (appletItem.sizeForFill>-1){
@ -96,7 +96,7 @@ Item{
return latteApplet.tasksHeight;
} else {
if (root.isVertical && root.inConfigureAppletsMode) {
return Math.max(Math.min(container.iconSize, root.minAppletLengthInConfigure), scaledHeight);
return Math.max(Math.min(appletItem.container.iconSize, root.minAppletLengthInConfigure), scaledHeight);
}
return root.isHorizontal ? scaledHeight + root.localScreenEdgeMargin : scaledHeight;
@ -123,7 +123,7 @@ Item{
property int appletMaximumWidth: applet && applet.Layout ? applet.Layout.maximumWidth : -1
property int appletMaximumHeight: applet && applet.Layout ? applet.Layout.maximumHeight : -1
property int iconSize: container.iconSize
property int iconSize: appletItem.container.iconSize
property int marginWidth: root.isVertical ?
root.thickMargins :
@ -160,7 +160,7 @@ Item{
Behavior on opacity {
NumberAnimation {
duration: 0.8 * animations.duration.proposed
duration: 0.8 * appletItem.animations.duration.proposed
easing.type: Easing.OutCubic
}
}
@ -187,11 +187,11 @@ Item{
console.log("Real Wrapper Height: "+wrapper.height);
console.log("-----");
console.log("Can be hovered: " + canBeHovered);
console.log("Icon size: " + container.iconSize);
console.log("Icon size: " + appletItem.container.iconSize);
console.log("Thick Margins: " + root.thickMargins);
console.log("Intern. Margins: " + (root.lengthIntMargin * 2));
console.log("Intern. Margins: " + (root.lengthExtMargin * 2));
console.log("Max hovered criteria: " + (container.iconSize + thickMargins));
console.log("Max hovered criteria: " + (appletItem.container.iconSize + thickMargins));
console.log("-----");
console.log("LayoutW: " + layoutWidth);
console.log("LayoutH: " + layoutHeight);
@ -264,10 +264,10 @@ Item{
if ((zoomScale > 1) && !appletItem.isZoomed) {
appletItem.isZoomed = true;
animations.needBothAxis.addEvent(appletItem);
appletItem.animations.needBothAxis.addEvent(appletItem);
} else if (zoomScale == 1) {
appletItem.isZoomed = false;
animations.needBothAxis.removeEvent(appletItem);
appletItem.animations.needBothAxis.removeEvent(appletItem);
}
}
@ -307,39 +307,39 @@ Item{
if(!root.inConfigureAppletsMode) {
layoutHeight = 0;
} else {
layoutHeight = (root.isHorizontal ? container.iconSize : Math.min(container.iconSize, root.maxJustifySplitterSize));
layoutHeight = (root.isHorizontal ? appletItem.container.iconSize : Math.min(appletItem.container.iconSize, root.maxJustifySplitterSize));
}
}
else if(appletItem.isSystray && root.isHorizontal){
layoutHeight = container.iconSize;
layoutHeight = appletItem.container.iconSize;
}
else{
if(applet && (applet.Layout.minimumHeight > container.iconSize) && root.isVertical && !canBeHovered && !communicator.overlayLatteIconIsActive){
if(applet && (applet.Layout.minimumHeight > appletItem.container.iconSize) && root.isVertical && !canBeHovered && !communicator.overlayLatteIconIsActive){
blockParabolicEffect = true;
layoutHeight = applet.Layout.minimumHeight;
} //it is used for plasmoids that need to scale only one axis... e.g. the Weather Plasmoid
else if(applet
&& ( applet.Layout.maximumHeight < container.iconSize
|| applet.Layout.preferredHeight > container.iconSize
&& ( applet.Layout.maximumHeight < appletItem.container.iconSize
|| applet.Layout.preferredHeight > appletItem.container.iconSize
|| appletItem.originalAppletBehavior)
&& root.isVertical
&& !disableScaleWidth
&& !communicator.overlayLatteIconIsActive) {
//this way improves performance, probably because during animation the preferred sizes update a lot
if((applet.Layout.maximumHeight < container.iconSize)){
if((applet.Layout.maximumHeight < appletItem.container.iconSize)){
layoutHeight = applet.Layout.maximumHeight;
} else if (applet.Layout.minimumHeight > container.iconSize){
} else if (applet.Layout.minimumHeight > appletItem.container.iconSize){
blockParabolicEffect = true;
layoutHeight = applet.Layout.minimumHeight;
} else if ((applet.Layout.preferredHeight > container.iconSize)
} else if ((applet.Layout.preferredHeight > appletItem.container.iconSize)
|| (appletItem.originalAppletBehavior && applet.Layout.preferredHeight > 0 )){
blockParabolicEffect = true;
layoutHeight = applet.Layout.preferredHeight;
} else{
layoutHeight = container.iconSize;
layoutHeight = appletItem.container.iconSize;
}
} else {
layoutHeight = container.iconSize;
layoutHeight = appletItem.container.iconSize;
}
}
@ -368,41 +368,41 @@ Item{
if(!root.inConfigureAppletsMode) {
layoutWidth = 0;
} else {
layoutWidth = (root.isVertical ? container.iconSize : Math.min(container.iconSize, root.maxJustifySplitterSize));
layoutWidth = (root.isVertical ? appletItem.container.iconSize : Math.min(appletItem.container.iconSize, root.maxJustifySplitterSize));
}
}
else if(appletItem.isSystray && root.isVertical){
layoutWidth = container.iconSize;
layoutWidth = appletItem.container.iconSize;
}
else{
if(applet && (applet.Layout.minimumWidth > container.iconSize) && root.isHorizontal && !canBeHovered && !communicator.overlayLatteIconIsActive){
if(applet && (applet.Layout.minimumWidth > appletItem.container.iconSize) && root.isHorizontal && !canBeHovered && !communicator.overlayLatteIconIsActive){
blockParabolicEffect = true;
layoutWidth = applet.Layout.minimumWidth;
} //it is used for plasmoids that need to scale only one axis... e.g. the Weather Plasmoid
else if(applet
&& ( applet.Layout.maximumWidth < container.iconSize
|| applet.Layout.preferredWidth > container.iconSize
&& ( applet.Layout.maximumWidth < appletItem.container.iconSize
|| applet.Layout.preferredWidth > appletItem.container.iconSize
|| appletItem.originalAppletBehavior)
&& root.isHorizontal
&& !disableScaleHeight
&& !communicator.overlayLatteIconIsActive){
//this way improves performance, probably because during animation the preferred sizes update a lot
if((applet.Layout.maximumWidth < container.iconSize)){
if((applet.Layout.maximumWidth < appletItem.container.iconSize)){
// return applet.Layout.maximumWidth;
layoutWidth = applet.Layout.maximumWidth;
} else if (applet.Layout.minimumWidth > container.iconSize){
} else if (applet.Layout.minimumWidth > appletItem.container.iconSize){
blockParabolicEffect = true;
layoutWidth = applet.Layout.minimumWidth;
} else if ((applet.Layout.preferredWidth > container.iconSize)
} else if ((applet.Layout.preferredWidth > appletItem.container.iconSize)
|| (appletItem.originalAppletBehavior && applet.Layout.preferredWidth > 0 )){
blockParabolicEffect = true;
layoutWidth = applet.Layout.preferredWidth;
} else{
layoutWidth = container.iconSize;
layoutWidth = appletItem.container.iconSize;
}
} else{
layoutWidth = container.iconSize;
layoutWidth = appletItem.container.iconSize;
}
}
@ -427,7 +427,7 @@ Item{
return wrapper.layoutWidth;
} else {
if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
var wrapperContainerThickness = parent.zoomScaleWidth * (container.iconSize + root.thickMargins);
var wrapperContainerThickness = parent.zoomScaleWidth * (appletItem.container.iconSize + root.thickMargins);
return appletItem.screenEdgeMarginSupported ? wrapperContainerThickness + root.localScreenEdgeMargin : wrapperContainerThickness;
} else {
return parent.zoomScaleWidth * wrapper.layoutWidth;
@ -444,7 +444,7 @@ Item{
return wrapper.layoutHeight;
} else {
if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
var wrapperContainerThickness = parent.zoomScaleHeight * (container.iconSize + root.thickMargins);
var wrapperContainerThickness = parent.zoomScaleHeight * (appletItem.container.iconSize + root.thickMargins);
return appletItem.screenEdgeMarginSupported ? wrapperContainerThickness + root.localScreenEdgeMargin : wrapperContainerThickness;
} else {
return parent.zoomScaleHeight * wrapper.layoutHeight;
@ -605,7 +605,7 @@ Item{
PlasmaCore.SvgItem{
id:splitterImage
anchors.centerIn: parent
width: Math.min(root.maxJustifySplitterSize, container.iconSize)
width: Math.min(root.maxJustifySplitterSize, appletItem.container.iconSize)
height: width
rotation: root.isVertical ? 90 : 0
@ -671,7 +671,7 @@ Item{
visible: !indicators.info.providesHoveredAnimation
Behavior on opacity {
NumberAnimation { duration: animations.speedFactor.current*animations.duration.large }
NumberAnimation { duration: appletItem.animations.speedFactor.current*appletItem.animations.duration.large }
}
}

View File

@ -101,13 +101,13 @@ Loader{
// when iconSize < 48, height is always = 24, height / iconSize > 50%
// we prefer center aligned badges to top-left aligned ones
property bool centerInParent: container.iconSize < 48
property bool centerInParent: appletItem.container.iconSize < 48
anchors.left: centerInParent? undefined : parent.left
anchors.top: centerInParent? undefined : parent.top
anchors.centerIn: centerInParent? parent : undefined
minimumWidth: 0.4 * (wrapper.zoomScale * container.iconSize)
height: Math.max(24, 0.4 * (wrapper.zoomScale * container.iconSize))
minimumWidth: 0.4 * (wrapper.zoomScale * appletItem.container.iconSize)
height: Math.max(24, 0.4 * (wrapper.zoomScale * appletItem.container.iconSize))
borderColor: colorizerManager.originalLightTextColor
proportion: 0

View File

@ -34,6 +34,7 @@ Item{
readonly property int preferredThickness: (root.zoomFactor * (container.iconSize + root.thickMargins)) + root.localScreenEdgeMargin
property int maximumThickness: 9999
property Item container: null
//border.width: 1
//border.color: "green"
//color: "transparent"

View File

@ -86,7 +86,7 @@ Item{
// USE CASE: it can be used from applets that want their size to be always
// relevant to the view icon size
// @since: 0.9
readonly property int iconSize: container.iconSize
readonly property int iconSize: appletItem.container.iconSize
// NAME: screenEdgeMargin
// USAGE: read-only
@ -115,8 +115,8 @@ Item{
readonly property Item actions: Actions{}
readonly property Item applet: mainCommunicator.requires
readonly property Item animations: root.animations.publicApi
readonly property Item container: root.container.publicApi
readonly property Item animations: appletItem.animations.publicApi
readonly property Item container: appletItem.container.publicApi
Connections {
target: root

View File

@ -56,14 +56,14 @@ Item{
readonly property int windowsCount: 0
readonly property int windowsMinimizedCount: 0
readonly property int currentIconSize: container.iconSize
readonly property int maxIconSize: container.maxIconSize
readonly property int currentIconSize: appletIsValid ? appletItem.container.iconSize : container.iconSize
readonly property int maxIconSize: appletIsValid ? appletItem.container.maxIconSize : container.maxIconSize
readonly property real scaleFactor: appletIsValid ? appletItem.wrapperAlias.zoomScale : 1
readonly property real panelOpacity: root.currentPanelOpacity
readonly property color shadowColor: root.appShadowColorSolid
readonly property bool animationsEnabled: animations.active
readonly property real durationTime: animations.speedFactor.current
readonly property bool animationsEnabled: appletIsValid ? appletItem.animations.active : animations.active
readonly property real durationTime: appletIsValid ? appletItem.animations.speedFactor.current : animations.speedFactor.current
readonly property bool progressVisible: false /*since 0.9.2*/
readonly property real progress: 0 /*since 0.9.2*/

View File

@ -66,8 +66,8 @@ Loader {
readonly property bool locked: appletItem.lockZoom || root.zoomFactor === 1
property real visualLockedWidth: container.iconSize + appletItem.internalWidthMargins
property real visualLockedHeight: container.iconSize + appletItem.internalHeightMargins
property real visualLockedWidth: appletItem.container.iconSize + appletItem.internalWidthMargins
property real visualLockedHeight: appletItem.container.iconSize + appletItem.internalHeightMargins
//! Communications !//

View File

@ -221,7 +221,7 @@ Item{
Applet.TitleTooltipParent {
id: titleTooltipParent
container: root.container
minimumThickness: visibilityManager.thicknessEditMode
maximumThickness: root.inConfigureAppletsMode ? visibilityManager.thicknessEditMode : 9999
}

View File

@ -1530,7 +1530,10 @@ Item {
///////////////BEGIN components
Component {
id: appletContainerComponent
Applet.AppletItem{}
Applet.AppletItem{
animations: _animations
container: _container
}
}
ParabolicManager{