/* * Copyright 2017-2018 Michail Vourlakos * * 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 . */ //! FILLWIDTH/FILLHEIGHT COMPUTATIONS //! Computations in order to calculate correctly the sizes for applets //! that are requesting fillWidth or fillHeight //! initialize AppletItems flag "inFillCalculations" in orderf //! to inform them that new calculations are taking place function initLayoutForFillsCalculations(layout) { for(var i=0; i=0) && (maxSize !== Infinity)) { curApplet.sizeForFill = maxSize; // console.log("s3_1 "+ maxSize + " _ per applet:" + sizePerApplet); curApplet.inFillCalculations = false; availableSpace = Math.abs(availableSpace - maxSize); noOfApplets = noOfApplets - 1; sizePerApplet = noOfApplets > 1 ? Math.floor(availableSpace / noOfApplets) : availableSpace; // console.log(noOfApplets + " - " + sizePerApplet + " - " + availableSpace); } } return [availableSpace, sizePerApplet, noOfApplets]; } //! during step2/pass2 all the applets with fills //! that remained with no computations from pass1 //! are updated with the algorithm's proposed size function computeStep2ForLayout(layout, sizePerApplet) { for(var i=0; i 0 ? availableSpace / noA : 0 ; var noStart = startLayout.fillApplets; var noMain = mainLayout.fillApplets; var noEnd = endLayout.fillApplets; //! initialize the computations initLayoutForFillsCalculations(startLayout); initLayoutForFillsCalculations(mainLayout); initLayoutForFillsCalculations(endLayout); //console.log("s3..."); var res; //! first pass if (mainLayout.fillApplets > 0){ res = computeStep1ForLayout(mainLayout, availableSpace, sizePerAppletMain, noMain); sizePerAppletMain = res[1]; noMain = res[2]; var dif = (availableSpace - res[0]) / 2; availableSpaceStart = availableSpaceStart - dif; availableSpaceEnd = availableSpaceEnd - dif; } var sizePerAppletStart = startLayout.fillApplets > 0 ? availableSpaceStart / noStart : 0 ; var sizePerAppletEnd = endLayout.fillApplets > 0 ? availableSpaceEnd / noEnd : 0 ; if (startLayout.fillApplets > 0) { res = computeStep1ForLayout(startLayout, availableSpaceStart, sizePerAppletStart, noStart); availableSpaceStart = res[0]; sizePerAppletStart = res[1]; noStart = res[2]; } if (endLayout.fillApplets > 0) { res = computeStep1ForLayout(endLayout, availableSpaceEnd, sizePerAppletEnd, noEnd); availableSpaceEnd = res[0]; sizePerAppletEnd = res[1]; noEnd = res[2]; } //// //! second pass if (mainLayout.shownApplets > 0) { //var bSize = root.isHorizontal ? mainLayout.width : mainLayout.height; sizePerAppletMain = (availableSpaceStart + availableSpaceEnd) / (noStart + noMain + noEnd); computeStep2ForLayout(mainLayout, sizePerAppletMain); // var aSize = root.isHorizontal ? mainLayout.width : mainLayout.height; // availableSpaceStart = availableSpaceStart - aSize/2; // availableSpaceEnd = availableSpaceEnd - aSize/2; sizePerAppletStart = startLayout.fillApplets > 0 ? availableSpaceStart / noStart : 0 ; sizePerAppletEnd = endLayout.fillApplets > 0 ? availableSpaceEnd / noEnd : 0 ; } if (startLayout.fillApplets > 0) computeStep2ForLayout(startLayout, sizePerAppletStart); if (endLayout.fillApplets > 0) computeStep2ForLayout(endLayout, sizePerAppletEnd); } } }