From ced4d67f557bdcf4f4462b654f844ab3eed50f13 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 11 Mar 2017 18:55:29 +0200 Subject: [PATCH] decouple thickness margins from iconMargin --- containment/contents/ui/AppletItem.qml | 15 +++++++----- containment/contents/ui/DebugWindow.qml | 24 +++++++++++++++++++ containment/contents/ui/PanelBox.qml | 2 +- containment/contents/ui/VisibilityManager.qml | 16 ++++++------- containment/contents/ui/main.qml | 16 ++++++++++--- plasmoid/contents/ui/TaskDelegate.qml | 14 +++++++---- plasmoid/contents/ui/TaskIconItem.qml | 9 ++++--- plasmoid/contents/ui/main.qml | 18 +++++++++----- 8 files changed, 79 insertions(+), 35 deletions(-) diff --git a/containment/contents/ui/AppletItem.qml b/containment/contents/ui/AppletItem.qml index bb2fe52f8..eab38cbe3 100644 --- a/containment/contents/ui/AppletItem.qml +++ b/containment/contents/ui/AppletItem.qml @@ -328,8 +328,11 @@ Item { property int iconSize: root.iconSize - property real scaledWidth: zoomScaleWidth * (layoutWidth + root.iconMargin) - property real scaledHeight: zoomScaleHeight * (layoutHeight + root.iconMargin) + property int marginWidth: root.isVertical ? root.thickMargin : root.iconMargin + property int marginHeight: root.isHorizontal ? root.thickMargin : root.iconMargin + + property real scaledWidth: zoomScaleWidth * (layoutWidth + marginWidth) + property real scaledHeight: zoomScaleHeight * (layoutHeight + marginHeight) property real zoomScaleWidth: disableScaleWidth ? 1 : zoomScale property real zoomScaleHeight: disableScaleHeight ? 1 : zoomScale @@ -522,10 +525,10 @@ Item { width: Math.round( container.isInternalViewSplitter ? wrapper.layoutWidth : parent.zoomScaleWidth * wrapper.layoutWidth ) height: Math.round( container.isInternalViewSplitter ? wrapper.layoutHeight : parent.zoomScaleHeight * wrapper.layoutHeight ) - anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? (root.iconMargin / 2) : 0 - anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? (root.iconMargin / 2) : 0 - anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? (root.iconMargin / 2) : 0 - anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? (root.iconMargin / 2) : 0 + anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? root.thickMarginBase : 0 + anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? root.thickMarginBase : 0 + anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? root.thickMarginBase : 0 + anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? root.thickMarginBase : 0 //BEGIN states states: [ diff --git a/containment/contents/ui/DebugWindow.qml b/containment/contents/ui/DebugWindow.qml index 41fc4ea4e..4a57d60a3 100644 --- a/containment/contents/ui/DebugWindow.qml +++ b/containment/contents/ui/DebugWindow.qml @@ -320,6 +320,30 @@ Window{ text: root.iconSize } + Text{ + text: "Icon Margin"+space + } + + Text{ + text: root.iconMargin + } + + Text{ + text: "Thick Margin Base"+space + } + + Text{ + text: root.thickMarginBase + } + + Text{ + text: "Thick Margin High"+space + } + + Text{ + text: root.thickMarginHigh + } + Text{ text: " ----------- " } diff --git a/containment/contents/ui/PanelBox.qml b/containment/contents/ui/PanelBox.qml index 26e35d02e..d49432b1f 100644 --- a/containment/contents/ui/PanelBox.qml +++ b/containment/contents/ui/PanelBox.qml @@ -145,7 +145,7 @@ Item{ root.realPanelThickness = iconS; return iconS; } else { - var icons = root.statesLineSize + root.iconSize + root.iconMargin + 1; + var icons = root.statesLineSize + root.iconSize + root.thickMargin + 1; var panels = root.themePanelSize + root.panelMargin; root.realPanelThickness = icons; diff --git a/containment/contents/ui/VisibilityManager.qml b/containment/contents/ui/VisibilityManager.qml index dc3b9f4c6..1d16d1d15 100644 --- a/containment/contents/ui/VisibilityManager.qml +++ b/containment/contents/ui/VisibilityManager.qml @@ -47,20 +47,18 @@ Item{ property int slidingOutToPos: ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) ? -thicknessNormal : thicknessNormal - //it is used in order to not break the calculations for the thickness placement - //especially in automatic icon sizes calculations - property real iconMarginOriginal: 0.12*root.maxIconSize + property int statesLineSizeOriginal: root.latteApplet ? Math.ceil( root.maxIconSize/13 ) : 0 property int thicknessAutoHidden: 2 - property int thicknessMid: root.statesLineSize + (1 + (0.65 * (root.zoomFactor-1)))*(root.iconSize+root.iconMargin) //needed in some animations - property int thicknessNormal: Math.max(root.statesLineSize + root.iconSize + root.iconMargin + 1, root.realPanelSize + root.panelShadow) - property int thicknessZoom: root.statesLineSize + ((root.iconSize+root.iconMargin) * root.zoomFactor) + 2 + property int thicknessMid: root.statesLineSize + (1 + (0.65 * (root.zoomFactor-1)))*(root.iconSize+root.thickMargin) //needed in some animations + property int thicknessNormal: Math.max(root.statesLineSize + root.iconSize + root.thickMargin + 1, root.realPanelSize + root.panelShadow) + property int thicknessZoom: root.statesLineSize + ((root.iconSize+root.thickMargin) * root.zoomFactor) + 2 //it is used to keep thickness solid e.g. when iconSize changes from auto functions - property int thicknessMidOriginal: Math.max(thicknessNormalOriginal, statesLineSizeOriginal + (1 + (0.65 * (root.zoomFactor-1)))*(root.maxIconSize+iconMarginOriginal)) //needed in some animations + property int thicknessMidOriginal: Math.max(thicknessNormalOriginal, statesLineSizeOriginal + (1 + (0.65 * (root.zoomFactor-1)))*(root.maxIconSize+root.thickMarginOriginal)) //needed in some animations property int thicknessNormalOriginal: Math.max(thicknessNormalOriginalValue, root.realPanelSize + root.panelShadow) - property int thicknessNormalOriginalValue: statesLineSizeOriginal + root.maxIconSize + iconMarginOriginal + 1 - property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((root.maxIconSize+iconMarginOriginal) * root.zoomFactor) + 2, + property int thicknessNormalOriginalValue: statesLineSizeOriginal + root.maxIconSize + root.thickMarginOriginal + 1 + property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + ((root.maxIconSize+root.thickMarginOriginal) * root.zoomFactor) + 2, root.realPanelSize + root.panelShadow) Binding{ diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index 8ff98f5ca..5a6f2e934 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -107,12 +107,22 @@ DragDrop.DropArea { property int themePanelSize: { //root.statesLineSize + root.iconSize + root.iconMargin + 1 var panelBase = root.statesLineSize + root.panelMargin; - var iconMarginUsed = latteApplet ? root.iconMargin : 0; - var maxPanelSize = (root.statesLineSize + root.iconSize + iconMarginUsed + 1) - panelBase; + var margin = latteApplet ? thickMargin : 0; + var maxPanelSize = (root.statesLineSize + iconSize + margin + 1) - panelBase; var percentage = plasmoid.configuration.panelSize/100; return Math.max(panelBase, panelBase + percentage*maxPanelSize); } + //decouple iconMargin which now is used only for length calculations with thickMargins + //which are used for thickness calculations + property int thickMarginBase: Math.ceil(iconMargin/2) + property int thickMarginHigh: Math.ceil(iconMargin/2) + property int thickMargin: thickMarginBase + thickMarginHigh + + //it is used in order to not break the calculations for the thickness placement + //especially in automatic icon sizes calculations + property int thickMarginOriginal: Math.ceil(0.12 * maxIconSize) + property int iconMargin: Math.ceil(0.12 * iconSize) property int statesLineSize: latteApplet ? Math.ceil( root.iconSize/13 ) : 0 @@ -1160,7 +1170,7 @@ DragDrop.DropArea { Item { id: dndSpacer - property int normalSize: root.statesLineSize + root.iconSize + root.iconMargin - 1 + property int normalSize: root.statesLineSize + root.iconSize + root.thickMargin - 1 //visibilityManager.statesLineSizeOriginal + root.maxIconSize + visibilityManager.iconMarginOriginal - 1 width: normalSize diff --git a/plasmoid/contents/ui/TaskDelegate.qml b/plasmoid/contents/ui/TaskDelegate.qml index 786211326..646ac0ddc 100644 --- a/plasmoid/contents/ui/TaskDelegate.qml +++ b/plasmoid/contents/ui/TaskDelegate.qml @@ -246,13 +246,17 @@ MouseArea{ property real scaleHeight: (inTempScaling == true) ? tempScaleHeight : mScale ///Dont use Math.floor it adds one pixel in animations and creates glitches - property real cleanScaling: root.realSize * mScale + property int widthMargins: root.vertical ? root.thickMargin : root.iconMargin + property int heightMargins: !root.vertical ? root.thickMargin : root.iconMargin - property real basicScalingWidth : (inTempScaling == true) ? (root.realSize * scaleWidth) : cleanScaling - property real basicScalingHeight : (inTempScaling == true) ? (root.realSize * scaleHeight) : cleanScaling + property real cleanScalingWidth: (root.iconSize + widthMargins) * mScale + property real cleanScalingHeight: (root.iconSize + heightMargins) * mScale - property real regulatorWidth: basicScalingWidth-2; - property real regulatorHeight: basicScalingHeight-2; + property real basicScalingWidth : (inTempScaling == true) ? ((root.iconSize + widthMargins) * scaleWidth) : cleanScalingWidth + property real basicScalingHeight : (inTempScaling == true) ? ((root.iconSize + heightMargins) * scaleHeight) : cleanScalingHeight + + property real regulatorWidth: basicScalingWidth;//-2; + property real regulatorHeight: basicScalingHeight;//-2; /// end of Scalers/////// //property int curIndex: icList.hoveredIndex diff --git a/plasmoid/contents/ui/TaskIconItem.qml b/plasmoid/contents/ui/TaskIconItem.qml index fbd09e964..bc745e58d 100644 --- a/plasmoid/contents/ui/TaskIconItem.qml +++ b/plasmoid/contents/ui/TaskIconItem.qml @@ -123,26 +123,25 @@ Item{ anchors.rightMargin: root.position === PlasmaCore.Types.RightPositioned || (root.position === PlasmaCore.Types.LeftPositioned && mainItemContainer.inAddRemoveAnimation) - ? margin : 0 + ? root.thickMarginBase : 0 anchors.leftMargin: root.position === PlasmaCore.Types.LeftPositioned || (root.position === PlasmaCore.Types.RightPositioned && mainItemContainer.inAddRemoveAnimation) - ? margin : 0 + ? root.thickMarginBase : 0 anchors.topMargin: root.position === PlasmaCore.Types.TopPositioned || (root.position === PlasmaCore.Types.BottomPositioned && mainItemContainer.inAddRemoveAnimation) - ? margin : 0 + ? root.thickMarginBase : 0 anchors.bottomMargin: root.position === PlasmaCore.Types.BottomPositioned || (root.position === PlasmaCore.Types.TopPositioned && mainItemContainer.inAddRemoveAnimation) - ? margin : 0 + ? root.thickMarginBase : 0 width: Math.round(newTempSize) //+ 2*centralItem.shadowSize height: Math.round(width) //icon: decoration source: decoration - property int margin: root.iconMargin/2 //visible: !root.enableShadows onValidChanged: { diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index f0a076dc6..8fc0c51e7 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -112,6 +112,12 @@ Item { property int durationTime: latteDock ? latteDock.durationTime : plasmoid.configuration.durationTime property int iconMargin: latteDock ? latteDock.iconMargin : 0.12*iconSize property int iconSize: latteDock ? latteDock.iconSize : Math.max(plasmoid.configuration.iconSize, 16) + //decouple iconMargin which now is used only for length calculations with thickMargins + //which are used for thickness calculations + property int thickMarginBase: latteDock ? latteDock.thickMarginBase : Math.ceil(iconMargin/2) + property int thickMarginHigh: latteDock ? latteDock.thickMarginHigh : Math.ceil(iconMargin/2) + property int thickMargin: thickMarginBase + thickMarginHigh + property int statesLineSize: latteDock ? latteDock.statesLineSize : Math.ceil( root.iconSize/13 ) property int tasksHeight: mouseHandler.height property int tasksWidth: mouseHandler.width @@ -657,8 +663,8 @@ Item { target: icList property int maxSize: (root.hoveredIndex>=0 && !root.dragSource) ? - root.statesLineSize + root.zoomFactor * (root.iconSize + root.iconMargin) - 1 : - root.statesLineSize + root.iconSize + root.iconMargin - 1 + root.statesLineSize + root.zoomFactor * (root.iconSize + root.thickMargin) - 1 : + root.statesLineSize + root.iconSize + root.thickMargin - 1 onUrlsDropped: { // If all dropped URLs point to application desktop files, we'll add a launcher for each of them. @@ -880,12 +886,12 @@ Item { if(icList.previousCount !== icList.count){ icList.previousCount = icList.count; - var zoomedLength = Math.floor( 1.2 * (iconSize+iconMargin) * (root.zoomFactor)); - var bigAxis = (tasksModel.count-1) * (iconSize+iconMargin) + zoomedLength; + var zoomedLength = Math.floor( 1.2 * (iconSize+thickMargin) * (root.zoomFactor)); + var bigAxis = (tasksModel.count-1) * (iconSize+thickMargin) + zoomedLength; var smallAxis = zoomedLength + statesLineSize; - var clearBigAxis = tasksModel.count * (iconSize+iconMargin) + (barLine.spacing/2); - var clearSmallAxis = (iconSize+iconMargin)+statesLineSize; + var clearBigAxis = tasksModel.count * (iconSize+thickMargin) + (barLine.spacing/2); + var clearSmallAxis = (iconSize+thickMargin)+statesLineSize; // debugging code // ncounter++;