mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 10:50:30 +03:00
refactor layouts in containment
--simplify and organize a bit more the main.qml in containment and move logic into LayoutsContainer
This commit is contained in:
parent
4b76fd1004
commit
3d8c8179e2
@ -58,14 +58,14 @@ Item {
|
||||
property bool isZoomed: false
|
||||
|
||||
//applet is in starting edge
|
||||
/*property bool startEdge: index < endLayout.beginIndex ? (index === 0)&&(mainLayout.count > 1) :
|
||||
(index === endLayout.beginIndex)&&(endLayout.count > 1)*/
|
||||
property bool startEdge: (index === startLayout.beginIndex) || (index === mainLayout.beginIndex) || (index === endLayout.beginIndex)
|
||||
/*property bool startEdge: index < layoutsContainer.endLayout.beginIndex ? (index === 0)&&(layoutsContainer.mainLayout.count > 1) :
|
||||
(index === layoutsContainer.endLayout.beginIndex)&&(layoutsContainer.endLayout.count > 1)*/
|
||||
property bool startEdge: (index === layoutsContainer.startLayout.beginIndex) || (index === layoutsContainer.mainLayout.beginIndex) || (index === layoutsContainer.endLayout.beginIndex)
|
||||
//applet is in ending edge
|
||||
property bool endEdge: plasmoid.configuration.panelPosition !== Latte.Dock.Justify ? (index === mainLayout.beginIndex + mainLayout.count - 1)&&(mainLayout.count>1) :
|
||||
(((index === startLayout.beginIndex+startLayout.count-2)&&(startLayout.count>2))
|
||||
||((index === mainLayout.beginIndex+mainLayout.count-2)&&(mainLayout.count>2))
|
||||
||((index === endLayout.beginIndex+endLayout.count-1)&&(endLayout.count>1)))
|
||||
property bool endEdge: plasmoid.configuration.panelPosition !== Latte.Dock.Justify ? (index === layoutsContainer.mainLayout.beginIndex + layoutsContainer.mainLayout.count - 1)&&(layoutsContainer.mainLayout.count>1) :
|
||||
(((index === layoutsContainer.startLayout.beginIndex+layoutsContainer.startLayout.count-2)&&(layoutsContainer.startLayout.count>2))
|
||||
||((index === layoutsContainer.mainLayout.beginIndex+layoutsContainer.mainLayout.count-2)&&(layoutsContainer.mainLayout.count>2))
|
||||
||((index === layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1)&&(layoutsContainer.endLayout.count>1)))
|
||||
|
||||
|
||||
|
||||
@ -141,39 +141,39 @@ Item {
|
||||
function checkIndex(){
|
||||
index = -1;
|
||||
|
||||
for(var i=0; i<startLayout.count; ++i){
|
||||
if(startLayout.children[i] === container){
|
||||
index = startLayout.beginIndex + i;
|
||||
for(var i=0; i<layoutsContainer.startLayout.count; ++i){
|
||||
if(layoutsContainer.startLayout.children[i] === container){
|
||||
index = layoutsContainer.startLayout.beginIndex + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=0; i<mainLayout.count; ++i){
|
||||
if(mainLayout.children[i] === container){
|
||||
index = mainLayout.beginIndex + i;
|
||||
for(var i=0; i<layoutsContainer.mainLayout.count; ++i){
|
||||
if(layoutsContainer.mainLayout.children[i] === container){
|
||||
index = layoutsContainer.mainLayout.beginIndex + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(var i=0; i<endLayout.count; ++i){
|
||||
if(endLayout.children[i] === container){
|
||||
for(var i=0; i<layoutsContainer.endLayout.count; ++i){
|
||||
if(layoutsContainer.endLayout.children[i] === container){
|
||||
//create a very high index in order to not need to exchange hovering messages
|
||||
//between mainLayout and endLayout
|
||||
index = endLayout.beginIndex + i;
|
||||
//between layoutsContainer.mainLayout and layoutsContainer.endLayout
|
||||
index = layoutsContainer.endLayout.beginIndex + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(container.latteApplet){
|
||||
if(index===startLayout.beginIndex || index===mainLayout.beginIndex || index===endLayout.beginIndex)
|
||||
if(index===layoutsContainer.startLayout.beginIndex || index===layoutsContainer.mainLayout.beginIndex || index===layoutsContainer.endLayout.beginIndex)
|
||||
latteApplet.disableLeftSpacer = false;
|
||||
else
|
||||
latteApplet.disableLeftSpacer = true;
|
||||
|
||||
if( index === startLayout.beginIndex + startLayout.count - 1
|
||||
|| index===mainLayout.beginIndex + mainLayout.count - 1
|
||||
|| index === endLayout.beginIndex + endLayout.count - 1)
|
||||
if( index === layoutsContainer.startLayout.beginIndex + layoutsContainer.startLayout.count - 1
|
||||
|| index===layoutsContainer.mainLayout.beginIndex + layoutsContainer.mainLayout.count - 1
|
||||
|| index === layoutsContainer.endLayout.beginIndex + layoutsContainer.endLayout.count - 1)
|
||||
latteApplet.disableRightSpacer = false;
|
||||
else
|
||||
latteApplet.disableRightSpacer = true;
|
||||
|
@ -131,8 +131,8 @@ MouseArea {
|
||||
lastX = mouse.x;
|
||||
lastY = mouse.y;
|
||||
|
||||
var relevantLayout = mapFromItem(mainLayout, 0, 0);
|
||||
var item = mainLayout.childAt(mouse.x-relevantLayout.x, mouse.y-relevantLayout.y);
|
||||
var relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
|
||||
var item = layoutsContainer.mainLayout.childAt(mouse.x-relevantLayout.x, mouse.y-relevantLayout.y);
|
||||
|
||||
if (item && item !== placeHolder) {
|
||||
// placeHolder.width = item.width;
|
||||
@ -149,9 +149,9 @@ MouseArea {
|
||||
}
|
||||
|
||||
} else {
|
||||
var relevantLayout = mapFromItem(mainLayout,0,0);
|
||||
var relevantLayout = mapFromItem(layoutsContainer.mainLayout,0,0);
|
||||
|
||||
var item = mainLayout.childAt(mouse.x-relevantLayout.x, mouse.y-relevantLayout.y);
|
||||
var item = layoutsContainer.mainLayout.childAt(mouse.x-relevantLayout.x, mouse.y-relevantLayout.y);
|
||||
if (root.dragOverlay && item && item !== lastSpacer) {
|
||||
root.dragOverlay.currentApplet = item;
|
||||
} else {
|
||||
@ -186,7 +186,7 @@ MouseArea {
|
||||
if(currentApplet.showZoomed !== undefined)
|
||||
currentApplet.showZoomed = true;
|
||||
|
||||
var relevantLayout = mapFromItem(mainLayout, 0, 0);
|
||||
var relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
|
||||
|
||||
handle.x = relevantLayout.x + currentApplet.x;
|
||||
handle.y = relevantLayout.y + currentApplet.y;
|
||||
@ -268,7 +268,7 @@ MouseArea {
|
||||
placeHolder.parent = configurationArea;
|
||||
currentApplet.z = 1;
|
||||
|
||||
var relevantLayout = mapFromItem(mainLayout, 0, 0);
|
||||
var relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
|
||||
|
||||
handle.x = relevantLayout.x + currentApplet.x;
|
||||
handle.y = relevantLayout.y + currentApplet.y;
|
||||
|
@ -609,7 +609,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: startLayout.shownApplets
|
||||
text: layoutsContainer.startLayout.shownApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -617,7 +617,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: startLayout.fillApplets
|
||||
text: layoutsContainer.startLayout.fillApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -625,7 +625,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: startLayout.sizeWithNoFillApplets+" px."
|
||||
text: layoutsContainer.startLayout.sizeWithNoFillApplets+" px."
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -641,7 +641,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: mainLayout.shownApplets
|
||||
text: layoutsContainer.mainLayout.shownApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -649,7 +649,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: mainLayout.fillApplets
|
||||
text: layoutsContainer.mainLayout.fillApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -657,7 +657,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: mainLayout.sizeWithNoFillApplets+" px."
|
||||
text: layoutsContainer.mainLayout.sizeWithNoFillApplets+" px."
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -673,7 +673,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: endLayout.shownApplets
|
||||
text: layoutsContainer.endLayout.shownApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -681,7 +681,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: endLayout.fillApplets
|
||||
text: layoutsContainer.endLayout.fillApplets
|
||||
}
|
||||
|
||||
Text{
|
||||
@ -689,7 +689,7 @@ Window{
|
||||
}
|
||||
|
||||
Text{
|
||||
text: endLayout.sizeWithNoFillApplets+" px."
|
||||
text: layoutsContainer.endLayout.sizeWithNoFillApplets+" px."
|
||||
}
|
||||
|
||||
}
|
||||
|
642
containment/package/contents/ui/LayoutsContainer.qml
Normal file
642
containment/package/contents/ui/LayoutsContainer.qml
Normal file
@ -0,0 +1,642 @@
|
||||
/*
|
||||
* Copyright 2016 Smith AR <audoban@openmailbox.org>
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick.Layouts 1.1
|
||||
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.latte 0.1 as Latte
|
||||
|
||||
import "../code/HeuristicTools.js" as HeuristicTools
|
||||
|
||||
Item{
|
||||
id: layoutsContainer
|
||||
|
||||
property int allCount: root.latteApplet ? _mainLayout.count-1+latteApplet.tasksCount : _mainLayout.count
|
||||
property int currentSpot: -1000
|
||||
property int hoveredIndex: -1
|
||||
|
||||
property Item startLayout : _startLayout
|
||||
property Item mainLayout: _mainLayout
|
||||
property Item endLayout: _endLayout
|
||||
|
||||
x: {
|
||||
if ( dock && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && root.isHorizontal
|
||||
&& !root.editMode && !root.behaveAsPlasmaPanel ){
|
||||
return ((dock.width/2) - (root.maxLength/2) + root.offset)
|
||||
} else {
|
||||
if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isVertical){
|
||||
return;
|
||||
}
|
||||
|
||||
if (dock.visibility.isHidden && root.isVertical) {
|
||||
if (Latte.WindowSystem.compositingActive) {
|
||||
return slidingOutToPos;
|
||||
} else {
|
||||
if ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) {
|
||||
return slidingOutToPos + 1;
|
||||
} else {
|
||||
return slidingOutToPos - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
y: {
|
||||
if ( dock && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && root.isVertical
|
||||
&& !root.editMode && !root.behaveAsPlasmaPanel ) {
|
||||
return ((dock.height/2) - (root.maxLength/2) + root.offset);
|
||||
} else {
|
||||
if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isHorizontal){
|
||||
return;
|
||||
}
|
||||
|
||||
if (dock.visibility.isHidden && root.isHorizontal) {
|
||||
if (Latte.WindowSystem.compositingActive) {
|
||||
return slidingOutToPos;
|
||||
} else {
|
||||
if ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) {
|
||||
return slidingOutToPos + 1;
|
||||
} else {
|
||||
return slidingOutToPos - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
width: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && root.isHorizontal && !root.editMode && !root.behaveAsPlasmaPanel ?
|
||||
root.maxLength : parent.width
|
||||
height: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && root.isVertical && !root.editMode && !root.behaveAsPlasmaPanel ?
|
||||
root.maxLength : parent.height
|
||||
z:10
|
||||
|
||||
property bool animationSent: false
|
||||
property bool shouldCheckHalfs: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && (_mainLayout.children>1)
|
||||
|
||||
property int contentsWidth: _startLayout.width + _mainLayout.width + _endLayout.width
|
||||
property int contentsHeight: _startLayout.height + _mainLayout.height + _endLayout.height
|
||||
|
||||
onContentsWidthChanged: {
|
||||
if (root.isHorizontal){
|
||||
var firstHalfExited = false;
|
||||
var secondHalfExited = false;
|
||||
|
||||
if (shouldCheckHalfs){
|
||||
firstHalfExited = ( (_startLayout.width + _mainLayout.width/2) >= root.maxLength/2 );
|
||||
secondHalfExited = ( (_endLayout.width + _mainLayout.width/2) >= root.maxLength/2 );
|
||||
}
|
||||
|
||||
if (dock && ((contentsWidth >= root.maxLength) || firstHalfExited || secondHalfExited)) {
|
||||
updateAutomaticIconSize();
|
||||
}
|
||||
|
||||
if (!animationSent) {
|
||||
animationSent = true;
|
||||
slotAnimationsNeedLength(1);
|
||||
}
|
||||
|
||||
HeuristicTools.updateSizeForAppletsInFill();
|
||||
|
||||
delayUpdateMaskArea.start();
|
||||
}
|
||||
}
|
||||
|
||||
onContentsHeightChanged: {
|
||||
if (root.isVertical){
|
||||
var firstHalfExited = false;
|
||||
var secondHalfExited = false;
|
||||
|
||||
if (shouldCheckHalfs){
|
||||
firstHalfExited = ( (_startLayout.height + _mainLayout.height/2) >= root.maxLength/2 );
|
||||
secondHalfExited = ( (_endLayout.height + _mainLayout.height/2) >= root.maxLength/2 );
|
||||
}
|
||||
|
||||
if (dock && ((contentsHeight >= root.maxLength) || firstHalfExited || secondHalfExited)) {
|
||||
updateAutomaticIconSize();
|
||||
}
|
||||
|
||||
if (!animationSent) {
|
||||
animationSent = true;
|
||||
slotAnimationsNeedLength(1);
|
||||
}
|
||||
|
||||
HeuristicTools.updateSizeForAppletsInFill();
|
||||
|
||||
delayUpdateMaskArea.start();
|
||||
}
|
||||
}
|
||||
|
||||
onXChanged: root.updateEffectsArea();
|
||||
onYChanged: root.updateEffectsArea();
|
||||
|
||||
Grid{
|
||||
id:_startLayout
|
||||
|
||||
columns: root.isVertical ? 1 : 0
|
||||
columnSpacing: 0
|
||||
flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom
|
||||
rows: root.isHorizontal ? 1 : 0
|
||||
rowSpacing: 0
|
||||
|
||||
Layout.preferredWidth: width
|
||||
Layout.preferredHeight: height
|
||||
|
||||
property int beginIndex: 0
|
||||
property int count: children.length
|
||||
|
||||
property int shownApplets: {
|
||||
var res = 0;
|
||||
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].applet
|
||||
&& (children[i].applet.status === PlasmaCore.Types.HiddenStatus || children[i].isInternalViewSplitter)) {
|
||||
//do nothing
|
||||
} else if (children[i] && children[i].applet){
|
||||
res = res + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int sizeWithNoFillApplets: {
|
||||
if (!visibilityManager || !visibilityManager.normalState)
|
||||
return;
|
||||
|
||||
var space = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && !children[i].needsFillSpace) {
|
||||
space = root.isHorizontal ? space + children[i].width : space + children[i].height;
|
||||
}
|
||||
}
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int fillApplets:{
|
||||
var no = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].needsFillSpace) {
|
||||
//console.log("fill :::: " + children[i].applet.pluginName);
|
||||
no++;
|
||||
}
|
||||
}
|
||||
|
||||
return no;
|
||||
}
|
||||
|
||||
onFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onShownAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onSizeWithNoFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
|
||||
states:[
|
||||
State {
|
||||
name: "bottom"
|
||||
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _startLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _startLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom;
|
||||
anchors.leftMargin: root.totalPanelEdgeSpacing/2; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "left"
|
||||
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _startLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _startLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.totalPanelEdgeSpacing/2; anchors.bottomMargin:0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "right"
|
||||
when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _startLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _startLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.totalPanelEdgeSpacing/2; anchors.bottomMargin:0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "top"
|
||||
when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _startLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _startLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop;
|
||||
anchors.leftMargin: root.totalPanelEdgeSpacing/2; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// This is the main Layout, in contrary with the others
|
||||
Grid{
|
||||
id: _mainLayout
|
||||
|
||||
columns: root.isVertical ? 1 : 0
|
||||
columnSpacing: 0
|
||||
flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom
|
||||
rows: root.isHorizontal ? 1 : 0
|
||||
rowSpacing: 0
|
||||
|
||||
Layout.preferredWidth: width
|
||||
Layout.preferredHeight: height
|
||||
|
||||
property int beginIndex: 100
|
||||
property int count: children.length
|
||||
|
||||
property int shownApplets: {
|
||||
var res = 0;
|
||||
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].applet
|
||||
&& (children[i].applet.status === PlasmaCore.Types.HiddenStatus || children[i].isInternalViewSplitter)) {
|
||||
//do nothing
|
||||
} else if (children[i] && children[i].applet){
|
||||
res = res + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int sizeWithNoFillApplets: {
|
||||
if (!visibilityManager || !visibilityManager.normalState)
|
||||
return;
|
||||
|
||||
var space = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && !children[i].needsFillSpace) {
|
||||
space = root.isHorizontal ? space + children[i].width : space + children[i].height;
|
||||
}
|
||||
}
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int fillApplets:{
|
||||
var no = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].needsFillSpace) {
|
||||
//console.log("fill :::: " + children[i].applet.pluginName);
|
||||
no++;
|
||||
}
|
||||
}
|
||||
|
||||
return no;
|
||||
}
|
||||
|
||||
onFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onShownAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onSizeWithNoFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
|
||||
|
||||
//////////////////////////BEGIN states
|
||||
//user set Panel Positions
|
||||
// 0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom
|
||||
states: [
|
||||
///Left Edge
|
||||
State {
|
||||
name: "leftCenter"
|
||||
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&((root.panelAlignment === Latte.Dock.Center)||(root.panelAlignment === Latte.Dock.Justify))
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: root.offset;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "leftTop"
|
||||
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Top)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offsetFixed; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "leftBottom"
|
||||
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Bottom)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offsetFixed;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
///Right Edge
|
||||
State {
|
||||
name: "rightCenter"
|
||||
when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&((root.panelAlignment === Latte.Dock.Center)||(root.panelAlignment === Latte.Dock.Justify))
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: root.offset;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "rightTop"
|
||||
when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Top)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offsetFixed; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "rightBottom"
|
||||
when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Bottom)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offsetFixed;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
///Bottom Edge
|
||||
State {
|
||||
name: "bottomCenter"
|
||||
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&((root.panelAlignment === Latte.Dock.Center)||(root.panelAlignment === Latte.Dock.Justify))
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: root.offset; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "bottomLeft"
|
||||
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Dock.Left)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
|
||||
anchors.leftMargin: root.offsetFixed; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "bottomRight"
|
||||
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Dock.Right)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
|
||||
anchors.leftMargin: 0; anchors.rightMargin:root.offsetFixed; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
///Top Edge
|
||||
State {
|
||||
name: "topCenter"
|
||||
when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&((root.panelAlignment === Latte.Dock.Center)||(root.panelAlignment === Latte.Dock.Justify))
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: root.offset; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "topLeft"
|
||||
when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Dock.Left)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
|
||||
anchors.leftMargin: root.offsetFixed; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "topRight"
|
||||
when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Dock.Right)
|
||||
|
||||
AnchorChanges {
|
||||
target: _mainLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _mainLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
|
||||
anchors.leftMargin: 0; anchors.rightMargin:root.offsetFixed; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0;
|
||||
}
|
||||
}
|
||||
]
|
||||
////////////////END states
|
||||
|
||||
}
|
||||
|
||||
Grid{
|
||||
id:_endLayout
|
||||
|
||||
columns: root.isVertical ? 1 : 0
|
||||
columnSpacing: 0
|
||||
flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom
|
||||
rows: root.isHorizontal ? 1 : 0
|
||||
rowSpacing: 0
|
||||
|
||||
Layout.preferredWidth: width
|
||||
Layout.preferredHeight: height
|
||||
|
||||
property int beginIndex: 200
|
||||
property int count: children.length
|
||||
|
||||
property int shownApplets: {
|
||||
var res = 0;
|
||||
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].applet
|
||||
&& (children[i].applet.status === PlasmaCore.Types.HiddenStatus || children[i].isInternalViewSplitter)) {
|
||||
//do nothing
|
||||
} else if (children[i] && children[i].applet){
|
||||
res = res + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int sizeWithNoFillApplets: {
|
||||
if (!visibilityManager || !visibilityManager.normalState)
|
||||
return;
|
||||
|
||||
var space = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && !children[i].needsFillSpace) {
|
||||
space = root.isHorizontal ? space + children[i].width : space + children[i].height;
|
||||
}
|
||||
}
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
//it is used in calculations for fillWidth,fillHeight applets
|
||||
property int fillApplets:{
|
||||
var no = 0;
|
||||
for (var i=0; i<children.length; ++i){
|
||||
if (children[i] && children[i].needsFillSpace) {
|
||||
//console.log("fill :::: " + children[i].applet.pluginName);
|
||||
no++;
|
||||
}
|
||||
}
|
||||
|
||||
return no;
|
||||
}
|
||||
|
||||
onFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onShownAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
onSizeWithNoFillAppletsChanged: HeuristicTools.updateSizeForAppletsInFill();
|
||||
|
||||
states:[
|
||||
State {
|
||||
name: "bottom"
|
||||
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _endLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _endLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignBottom
|
||||
anchors.leftMargin: 0; anchors.rightMargin:root.totalPanelEdgeSpacing/2; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "left"
|
||||
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _endLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _endLayout; horizontalItemAlignment: Grid.AlignLeft; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.totalPanelEdgeSpacing/2;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "right"
|
||||
when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _endLayout
|
||||
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _endLayout; horizontalItemAlignment: Grid.AlignRight; verticalItemAlignment: Grid.AlignVCenter;
|
||||
anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.totalPanelEdgeSpacing/2;
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "top"
|
||||
when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Dock.Justify)
|
||||
|
||||
AnchorChanges {
|
||||
target: _endLayout
|
||||
anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined}
|
||||
}
|
||||
PropertyChanges{
|
||||
target: _endLayout; horizontalItemAlignment: Grid.AlignHCenter; verticalItemAlignment: Grid.AlignTop
|
||||
anchors.leftMargin: 0; anchors.rightMargin:root.totalPanelEdgeSpacing/2; anchors.topMargin:0; anchors.bottomMargin:0;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
function updateSizeForAppletsInFill() {
|
||||
HeuristicTools.updateSizeForAppletsInFill();
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ Item{
|
||||
if ((root.panelAlignment === Latte.Dock.Justify) && root.isHorizontal && !root.editMode) {
|
||||
return root.maxLength;
|
||||
} else {
|
||||
return mainLayout.width + spacing;
|
||||
return layoutsContainer.mainLayout.width + spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ Item{
|
||||
if ((root.panelAlignment === Latte.Dock.Justify) && root.isVertical && !root.editMode) {
|
||||
return root.maxLength;
|
||||
} else {
|
||||
return mainLayout.height + spacing;
|
||||
return layoutsContainer.mainLayout.height + spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ Item{
|
||||
} else {
|
||||
if(root.isHorizontal) {
|
||||
tempLength = plasmoid.configuration.panelPosition === Latte.Dock.Justify ?
|
||||
layoutsContainer.width + space : mainLayout.width + space;
|
||||
layoutsContainer.width + space : layoutsContainer.mainLayout.width + space;
|
||||
} else {
|
||||
tempLength = plasmoid.configuration.panelPosition === Latte.Dock.Justify ?
|
||||
layoutsContainer.height + space : mainLayout.height + space;
|
||||
layoutsContainer.height + space : layoutsContainer.mainLayout.height + space;
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ Item{
|
||||
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||||
localX = (dock.width/2) - tempLength/2 + root.offset;
|
||||
} else if (root.panelAlignment === Latte.Dock.Right) {
|
||||
localX = dock.width - mainLayout.width - space - root.offset;
|
||||
localX = dock.width - layoutsContainer.mainLayout.width - space - root.offset;
|
||||
}
|
||||
} else if ((plasmoid.location === PlasmaCore.Types.LeftEdge) || (plasmoid.location === PlasmaCore.Types.RightEdge)){
|
||||
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
|
||||
@ -272,7 +272,7 @@ Item{
|
||||
} else if (root.panelAlignment === Latte.Dock.Center) {
|
||||
localY = (dock.height/2) - tempLength/2 + root.offset;
|
||||
} else if (root.panelAlignment === Latte.Dock.Bottom) {
|
||||
localY = dock.height - mainLayout.height - space - root.offset;
|
||||
localY = dock.height - layoutsContainer.mainLayout.height - space - root.offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user