1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +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:
Michail Vourlakos 2020-07-20 15:16:03 +03:00
parent 24696fcf06
commit af37c31f36
4 changed files with 93 additions and 21 deletions

View File

@ -69,6 +69,7 @@ void Effects::init()
connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders); connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::maxLengthChanged, 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::screenEdgeMarginEnabledChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects); connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects);
connect(this, &Effects::drawShadowsChanged, this, &Effects::updateShadows); connect(this, &Effects::drawShadowsChanged, this, &Effects::updateShadows);

View File

@ -31,7 +31,9 @@ Item {
readonly property int fillApplets: startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets 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 { readonly property Item startLayout: LayouterElements.AppletsContainer {
grid: layouts.startLayout grid: layouts.startLayout
@ -267,15 +269,15 @@ Item {
function updateFillAppletsWithTwoSteps(inMaxAutoFillCalculations) { function updateFillAppletsWithTwoSteps(inMaxAutoFillCalculations) {
var noA = startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets; 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); // console.log(" S3 _ SIZES ::: " + max_length + " ___ " + inMaxAutoFillCalculations + " __ " + startLayout.sizeWithNoFillApplets + " ___ " + mainLayout.sizeWithNoFillApplets + " ___ " + endLayout.sizeWithNoFillApplets);
//! compute the two free spaces around the centered layout //! compute the two free spaces around the centered layout
//! they are called start and end accordingly //! they are called start and end accordingly
var halfMainLayout = mainLayout.sizeWithNoFillApplets / 2; var halfMainLayout = mainLayout.sizeWithNoFillApplets / 2;
var availableSpaceStart = Math.max(0, max_length/2 - startLayout.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 - root.panelEdgeSpacing/2); var availableSpaceEnd = Math.max(0, max_length/2 - endLayout.sizeWithNoFillApplets - halfMainLayout /*- layoutsContainer.backgroundHeadLength*/);
var availableSpace; var availableSpace;
if (mainLayout.fillApplets === 0 || (startLayout.shownApplets ===0 && endLayout.shownApplets===0)){ if (mainLayout.fillApplets === 0 || (startLayout.shownApplets ===0 && endLayout.shownApplets===0)){
@ -350,12 +352,12 @@ Item {
} }
function updateFillAppletsWithOneStep(inMaxAutoFillCalculations) { 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; var noA = startLayout.fillApplets + mainLayout.fillApplets + endLayout.fillApplets;
// console.log(" S2 _ SIZES ::: " + max_length + " ___ " + inMaxAutoFillCalculations + " __ " + startLayout.sizeWithNoFillApplets + " ___ " + mainLayout.sizeWithNoFillApplets + " ___ " + endLayout.sizeWithNoFillApplets); // 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 sizePerApplet = availableSpace / noA;
var res = initializationPhase(availableSpace, sizePerApplet, noA, inMaxAutoFillCalculations); var res = initializationPhase(availableSpace, sizePerApplet, noA, inMaxAutoFillCalculations);

View File

@ -61,16 +61,16 @@ BackgroundProperties{
screenEdgeMargin: root.screenEdgeMarginEnabled ? metrics.margin.screenEdge - shadows.tailThickness : 0 screenEdgeMargin: root.screenEdgeMarginEnabled ? metrics.margin.screenEdge - shadows.tailThickness : 0
paddings.top: { paddings.top: {
if (root.isHorizontal && hasTopBorder) { if (hasTopBorder) {
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.topEdgeRoundness : 0; var minimum = themeExtended ? themeExtended.topEdgeRoundness : 0;
return Math.max(minimum, solidBackground.margins.top); return Math.max(minimum, solidBackground.margins.top);
} }
return 0; return 0;
} }
paddings.bottom: { paddings.bottom: {
if (root.isHorizontal && hasBottomBorder) { if (hasBottomBorder) {
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.bottomEdgeRoundness : 0; var minimum = themeExtended ? themeExtended.bottomEdgeRoundness : 0;
return Math.max(minimum, solidBackground.margins.bottom); return Math.max(minimum, solidBackground.margins.bottom);
} }
@ -78,8 +78,8 @@ BackgroundProperties{
} }
paddings.left: { paddings.left: {
if (root.isVertical && hasLeftBorder) { if (hasLeftBorder) {
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.leftEdgeRoundness : 0; var minimum = themeExtended ? themeExtended.leftEdgeRoundness : 0;
return Math.max(minimum, solidBackground.margins.left); return Math.max(minimum, solidBackground.margins.left);
} }
@ -87,8 +87,8 @@ BackgroundProperties{
} }
paddings.right: { paddings.right: {
if (root.isVertical && hasRightBorder) { if (hasRightBorder) {
var minimum = root.screenEdgeMarginEnabled && themeExtended ? themeExtended.rightEdgeRoundness : 0; var minimum = themeExtended ? themeExtended.rightEdgeRoundness : 0;
return Math.max(minimum, solidBackground.margins.right); return Math.max(minimum, solidBackground.margins.right);
} }
@ -105,9 +105,9 @@ BackgroundProperties{
} }
if (root.isVertical) { if (root.isVertical) {
return Math.max(root.minLength, layoutsContainerItem.mainLayout.height); return Math.max(root.minLength, layoutsContainerItem.mainLayout.height + totals.paddingsLength);
} else { } else {
return Math.max(root.minLength, layoutsContainerItem.mainLayout.width); return Math.max(root.minLength, layoutsContainerItem.mainLayout.width + totals.paddingsLength);
} }
} }

View File

@ -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 height: root.isVertical && root.panelAlignment === LatteCore.Types.Justify ? root.maxLength : parent.height
z:10 z:10
@ -126,6 +126,75 @@ Item{
property int contentsWidth: _startLayout.width + _mainLayout.width + _endLayout.width property int contentsWidth: _startLayout.width + _mainLayout.width + _endLayout.width
property int contentsHeight: _startLayout.height + _mainLayout.height + _endLayout.height 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: { onContentsWidthChanged: {
if (root.isHorizontal){ if (root.isHorizontal){
var firstHalfExited = false; var firstHalfExited = false;
@ -187,7 +256,7 @@ Item{
AppletsContainer { AppletsContainer {
id: _startLayout id: _startLayout
beginIndex: 0 beginIndex: 0
offset: 0 offset: backgroundTailLength
alignment: { alignment: {
switch(plasmoid.location) { switch(plasmoid.location) {
case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeLeftAlign; case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeLeftAlign;
@ -209,9 +278,9 @@ Item{
return inJustifyCenterOffset; return inJustifyCenterOffset;
} }
if (background.hasBothLengthShadows && !centered) { if (!centered) {
//! it is used for Top/Bottom/Left/Right alignments when they show both background length shadows //! 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 return (root.panelAlignment === LatteCore.Types.Justify) ? 0 : background.offset
@ -330,7 +399,7 @@ Item{
AppletsContainer { AppletsContainer {
id: _endLayout id: _endLayout
beginIndex: 200 beginIndex: 200
offset: 0 offset: backgroundHeadLength
alignment: { alignment: {
switch(plasmoid.location) { switch(plasmoid.location) {
case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeRightAlign; case PlasmaCore.Types.BottomEdge: return LatteCore.Types.BottomEdgeRightAlign;