mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
improve fill(s) calculations for single alignments
--improve how the applet size is calculated for fill(s) applets when such applets are used in Left/Center/Right alignments. This also fixes the bug that the plasma taskmanager was not updating its size properly when tasks were added after the initialization phase. BUG: 401456 FIXED-IN: 0.8.4
This commit is contained in:
parent
a353c5eb36
commit
c9b99434ed
25
containment/package/contents/code/MathTools.js
Normal file
25
containment/package/contents/code/MathTools.js
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* This file is part of Latte-Dock
|
||||
*
|
||||
* Latte-Dock is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Latte-Dock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
//! bound the preferred value between minimum and maximum boundaries
|
||||
function bound(min, pref, max)
|
||||
{
|
||||
return Math.max(min, Math.min(pref, max));
|
||||
}
|
@ -28,6 +28,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
import org.kde.latte 0.1 as Latte
|
||||
|
||||
import "../../code/MathTools.js" as MathTools
|
||||
|
||||
Item{
|
||||
id: wrapper
|
||||
@ -44,15 +45,17 @@ Item{
|
||||
}
|
||||
|
||||
//! width for applets that use fillWidth/fillHeight such plasma taskmanagers and AWC
|
||||
if (container.needsFillSpace) {
|
||||
if (root.panelAlignment !== Latte.Dock.Justify && root.isHorizontal) {
|
||||
var constrainedWidth = container.sizeForFill>-1 ? Math.min(container.sizeForFill, applet.Layout.preferredWidth) :
|
||||
applet.Layout.preferredWidth;
|
||||
if (container.needsFillSpace && root.isHorizontal) {
|
||||
if (root.panelAlignment !== Latte.Dock.Justify) {
|
||||
var maximumValue = (applet.Layout.maximumWidth === Infinity) || applet.Layout.maximumWidth === -1 ?
|
||||
container.sizeForFill : Math.min(container.sizeForFill, applet.Layout.maximumWidth);
|
||||
|
||||
var constrainedWidth = MathTools.bound(applet.Layout.minimumWidth, applet.Layout.preferredWidth, maximumValue);
|
||||
|
||||
return root.editMode ? Math.max(constrainedWidth, root.iconSize) : constrainedWidth;
|
||||
}
|
||||
|
||||
if((container.sizeForFill>-1) && root.isHorizontal){
|
||||
if(container.sizeForFill>-1){
|
||||
return container.sizeForFill;
|
||||
}
|
||||
}
|
||||
@ -81,16 +84,18 @@ Item{
|
||||
return root.iconSize;
|
||||
}
|
||||
|
||||
if (container.needsFillSpace) {
|
||||
//! height for applets that use fillWidth/fillHeight such plasma taskmanagers and AWC
|
||||
if (root.panelAlignment !== Latte.Dock.Justify && root.isVertical) {
|
||||
var constrainedHeight = container.sizeForFill>-1 ? Math.min(container.sizeForFill, applet.Layout.preferredHeight) :
|
||||
applet.Layout.preferredHeight;
|
||||
//! height for applets that use fillWidth/fillHeight such plasma taskmanagers and AWC
|
||||
if (container.needsFillSpace && root.isVertical) {
|
||||
if (root.panelAlignment !== Latte.Dock.Justify) {
|
||||
var maximumValue = (applet.Layout.maximumHeight === Infinity) || applet.Layout.maximumHeight === -1 ?
|
||||
container.sizeForFill : Math.min(container.sizeForFill, applet.Layout.maximumHeight);
|
||||
|
||||
var constrainedHeight = MathTools.bound(applet.Layout.minimumHeight, applet.Layout.preferredHeight, maximumValue);
|
||||
|
||||
return root.editMode ? Math.max(constrainedHeight, root.iconSize) : constrainedHeight;
|
||||
}
|
||||
|
||||
if ((container.sizeForFill>-1) && root.isVertical){
|
||||
if (container.sizeForFill>-1){
|
||||
return container.sizeForFill;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user