mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 17:33:50 +03:00
support theme length paddings
--update layouter, background and layoutscontainer in order to take into account the background length paddings
This commit is contained in:
parent
24696fcf06
commit
af37c31f36
@ -69,6 +69,7 @@ void Effects::init()
|
||||
|
||||
connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::maxLengthChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::offsetChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::screenEdgeMarginEnabledChanged, this, &Effects::updateEnabledBorders);
|
||||
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects);
|
||||
connect(this, &Effects::drawShadowsChanged, this, &Effects::updateShadows);
|
||||
|
@ -31,7 +31,9 @@ Item {
|
||||
|
||||
readonly property int fillApplets: startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets
|
||||
|
||||
readonly property int maxLength: root.panelAlignment === LatteCore.Types.Justify ? root.maxLength : Math.min(root.minLength, root.maxLength)
|
||||
readonly property int maxLength: root.panelAlignment === LatteCore.Types.Justify ? contentsMaxLength : Math.min(root.minLength, contentsMaxLength)
|
||||
|
||||
readonly property int contentsMaxLength: root.maxLength - background.totals.paddingsLength
|
||||
|
||||
readonly property Item startLayout: LayouterElements.AppletsContainer {
|
||||
grid: layouts.startLayout
|
||||
@ -267,15 +269,15 @@ Item {
|
||||
|
||||
function updateFillAppletsWithTwoSteps(inMaxAutoFillCalculations) {
|
||||
var noA = startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets;
|
||||
var max_length = inMaxAutoFillCalculations ? root.maxLength : root.minLength
|
||||
var max_length = inMaxAutoFillCalculations ? contentsMaxLength : root.minLength
|
||||
|
||||
// console.log(" S3 _ SIZES ::: " + max_length + " ___ " + inMaxAutoFillCalculations + " __ " + startLayout.sizeWithNoFillApplets + " ___ " + mainLayout.sizeWithNoFillApplets + " ___ " + endLayout.sizeWithNoFillApplets);
|
||||
|
||||
//! compute the two free spaces around the centered layout
|
||||
//! they are called start and end accordingly
|
||||
var halfMainLayout = mainLayout.sizeWithNoFillApplets / 2;
|
||||
var availableSpaceStart = Math.max(0, max_length/2 - startLayout.sizeWithNoFillApplets - halfMainLayout - root.panelEdgeSpacing/2);
|
||||
var availableSpaceEnd = Math.max(0, max_length/2 - endLayout.sizeWithNoFillApplets - halfMainLayout - root.panelEdgeSpacing/2);
|
||||
var availableSpaceStart = Math.max(0, max_length/2 - startLayout.sizeWithNoFillApplets - halfMainLayout /*- layoutsContainer.backgroundTailLength*/);
|
||||
var availableSpaceEnd = Math.max(0, max_length/2 - endLayout.sizeWithNoFillApplets - halfMainLayout /*- layoutsContainer.backgroundHeadLength*/);
|
||||
var availableSpace;
|
||||
|
||||
if (mainLayout.fillApplets === 0 || (startLayout.shownApplets ===0 && endLayout.shownApplets===0)){
|
||||
@ -350,12 +352,12 @@ Item {
|
||||
}
|
||||
|
||||
function updateFillAppletsWithOneStep(inMaxAutoFillCalculations) {
|
||||
var max_length = inMaxAutoFillCalculations ? root.maxLength : root.minLength
|
||||
var max_length = inMaxAutoFillCalculations ? contentsMaxLength : root.minLength
|
||||
var noA = startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets;
|
||||
|
||||
// console.log(" S2 _ SIZES ::: " + max_length + " ___ " + inMaxAutoFillCalculations + " __ " + startLayout.sizeWithNoFillApplets + " ___ " + mainLayout.sizeWithNoFillApplets + " ___ " + endLayout.sizeWithNoFillApplets);
|
||||
|
||||
var availableSpace = Math.max(0, max_length - startLayout.sizeWithNoFillApplets - mainLayout.sizeWithNoFillApplets - endLayout.sizeWithNoFillApplets - root.panelEdgeSpacing);
|
||||
var availableSpace = Math.max(0, max_length - startLayout.sizeWithNoFillApplets - mainLayout.sizeWithNoFillApplets - endLayout.sizeWithNoFillApplets);
|
||||
var sizePerApplet = availableSpace / noA;
|
||||
|
||||
var res = initializationPhase(availableSpace, sizePerApplet, noA, inMaxAutoFillCalculations);
|
||||
|
@ -61,16 +61,16 @@ BackgroundProperties{
|
||||
screenEdgeMargin: root.screenEdgeMarginEnabled ? metrics.margin.screenEdge - shadows.tailThickness : 0
|
||||
|
||||
paddings.top: {
|
||||
if (root.isHorizontal && hasTopBorder) {
|
||||
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.topEdgeRoundness : 0;
|
||||
if (hasTopBorder) {
|
||||
var minimum = themeExtended ? themeExtended.topEdgeRoundness : 0;
|
||||
return Math.max(minimum, solidBackground.margins.top);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
paddings.bottom: {
|
||||
if (root.isHorizontal && hasBottomBorder) {
|
||||
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.bottomEdgeRoundness : 0;
|
||||
if (hasBottomBorder) {
|
||||
var minimum = themeExtended ? themeExtended.bottomEdgeRoundness : 0;
|
||||
return Math.max(minimum, solidBackground.margins.bottom);
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ BackgroundProperties{
|
||||
}
|
||||
|
||||
paddings.left: {
|
||||
if (root.isVertical && hasLeftBorder) {
|
||||
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.leftEdgeRoundness : 0;
|
||||
if (hasLeftBorder) {
|
||||
var minimum = themeExtended ? themeExtended.leftEdgeRoundness : 0;
|
||||
return Math.max(minimum, solidBackground.margins.left);
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ BackgroundProperties{
|
||||
}
|
||||
|
||||
paddings.right: {
|
||||
if (root.isVertical && hasRightBorder) {
|
||||
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.rightEdgeRoundness : 0;
|
||||
if (hasRightBorder) {
|
||||
var minimum = themeExtended ? themeExtended.rightEdgeRoundness : 0;
|
||||
return Math.max(minimum, solidBackground.margins.right);
|
||||
}
|
||||
|
||||
@ -105,9 +105,9 @@ BackgroundProperties{
|
||||
}
|
||||
|
||||
if (root.isVertical) {
|
||||
return Math.max(root.minLength, layoutsContainerItem.mainLayout.height);
|
||||
return Math.max(root.minLength, layoutsContainerItem.mainLayout.height + totals.paddingsLength);
|
||||
} else {
|
||||
return Math.max(root.minLength, layoutsContainerItem.mainLayout.width);
|
||||
return Math.max(root.minLength, layoutsContainerItem.mainLayout.width + totals.paddingsLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
width: root.isHorizontal && root.panelAlignment === LatteCore.Types.Justify ? root.maxLength : parent.width
|
||||
width: root.isHorizontal && root.panelAlignment === LatteCore.Types.Justify ? root.maxLength : parent.width
|
||||
height: root.isVertical && root.panelAlignment === LatteCore.Types.Justify ? root.maxLength : parent.height
|
||||
z:10
|
||||
|
||||
@ -126,6 +126,75 @@ Item{
|
||||
property int contentsWidth: _startLayout.width + _mainLayout.width + _endLayout.width
|
||||
property int contentsHeight: _startLayout.height + _mainLayout.height + _endLayout.height
|
||||
|
||||
|
||||
readonly property int backgroundShadowTailLength: {
|
||||
if (root.behaveAsPlasmaPanel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (root.panelAlignment === LatteCore.Types.Left) {
|
||||
return background.shadows.left;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Right) {
|
||||
return background.shadows.right;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Top) {
|
||||
return background.shadows.top;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Bottom) {
|
||||
return background.shadows.bottom;
|
||||
}
|
||||
|
||||
//! centered case
|
||||
return root.isHorizontal ? background.shadows.left : background.shadows.top;
|
||||
}
|
||||
|
||||
readonly property int backgroundShadowHeadLength: {
|
||||
if (root.behaveAsPlasmaPanel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (root.panelAlignment === LatteCore.Types.Left) {
|
||||
return background.shadows.right;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Right) {
|
||||
return background.shadows.left;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Top) {
|
||||
return background.shadows.bottom;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Bottom) {
|
||||
return background.shadows.top;
|
||||
}
|
||||
|
||||
//! centered case
|
||||
return root.isHorizontal ? background.shadows.right : background.shadows.bottom;
|
||||
}
|
||||
|
||||
readonly property int backgroundTailLength: {
|
||||
if (root.panelAlignment === LatteCore.Types.Left) {
|
||||
return backgroundShadowTailLength + background.paddings.left;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Right) {
|
||||
return backgroundShadowTailLength + background.paddings.right;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Top) {
|
||||
return backgroundShadowTailLength + background.paddings.top;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Bottom) {
|
||||
return backgroundShadowTailLength + background.paddings.bottom;
|
||||
}
|
||||
|
||||
//! centered case
|
||||
return root.isHorizontal ? background.paddings.left : background.paddings.top; //shadow is already calculated
|
||||
}
|
||||
|
||||
readonly property int backgroundHeadLength: {
|
||||
if (root.panelAlignment === LatteCore.Types.Left) {
|
||||
return backgroundShadowHeadLength + background.paddings.right;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Right) {
|
||||
return backgroundShadowHeadLength + background.paddings.left;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Top) {
|
||||
return backgroundShadowHeadLength + background.paddings.bottom;
|
||||
} else if (root.panelAlignment === LatteCore.Types.Bottom) {
|
||||
return backgroundShadowHeadLength + background.paddings.top;
|
||||
}
|
||||
|
||||
//! centered case
|
||||
return root.isHorizontal ? background.paddings.right : background.paddings.bottom; //shadow is already calculated
|
||||
}
|
||||
|
||||
onContentsWidthChanged: {
|
||||
if (root.isHorizontal){
|
||||
var firstHalfExited = false;
|
||||
@ -187,7 +256,7 @@ Item{
|
||||
AppletsContainer {
|
||||
id: _startLayout
|
||||
beginIndex: 0
|
||||
offset: 0
|
||||
offset: backgroundTailLength
|
||||
alignment: {
|
||||
switch(plasmoid.location) {
|
||||
case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeLeftAlign;
|
||||
@ -209,9 +278,9 @@ Item{
|
||||
return inJustifyCenterOffset;
|
||||
}
|
||||
|
||||
if (background.hasBothLengthShadows && !centered) {
|
||||
if (!centered) {
|
||||
//! it is used for Top/Bottom/Left/Right alignments when they show both background length shadows
|
||||
return background.offset + background.totals.shadowsLength/2;
|
||||
return background.offset + backgroundTailLength;
|
||||
}
|
||||
|
||||
return (root.panelAlignment === LatteCore.Types.Justify) ? 0 : background.offset
|
||||
@ -330,7 +399,7 @@ Item{
|
||||
AppletsContainer {
|
||||
id: _endLayout
|
||||
beginIndex: 200
|
||||
offset: 0
|
||||
offset: backgroundHeadLength
|
||||
alignment: {
|
||||
switch(plasmoid.location) {
|
||||
case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeRightAlign;
|
||||
|
Loading…
Reference in New Issue
Block a user