improve updateIndexes at Justify alignment changes

--fix how applets are identifying their index when the
user switches alignments from Justify to Another and
vice versa. More specific this patch helps in order to
not break the parabolic effect between alignment changes.
pull/5/head
Michail Vourlakos 6 years ago
parent d5b294b88e
commit f497d4ae62

@ -357,6 +357,13 @@ Item{
return no; return no;
} }
onCountChanged: {
if (root.editMode) {
//! this is mainly used when removing/adding internal view splitters
//! in order to not break the parabolic effect from wrong indexes
root.updateIndexes();
}
}
onFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill(); onFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill();
onShownAppletsChanged: layoutsContainer.updateSizeForAppletsInFill(); onShownAppletsChanged: layoutsContainer.updateSizeForAppletsInFill();
onSizeWithNoFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill(); onSizeWithNoFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill();

@ -160,21 +160,24 @@ Item {
index = -1; index = -1;
for(var i=0; i<layoutsContainer.startLayout.count; ++i){ for(var i=0; i<layoutsContainer.startLayout.count; ++i){
if(layoutsContainer.startLayout.children[i] === appletItem){ var child = layoutsContainer.startLayout.children[i];
if (child === appletItem){
index = layoutsContainer.startLayout.beginIndex + i; index = layoutsContainer.startLayout.beginIndex + i;
break; break;
} }
} }
for(var i=0; i<layoutsContainer.mainLayout.count; ++i){ for(var i=0; i<layoutsContainer.mainLayout.count; ++i){
if(layoutsContainer.mainLayout.children[i] === appletItem){ var child = layoutsContainer.mainLayout.children[i];
if (child === appletItem){
index = layoutsContainer.mainLayout.beginIndex + i; index = layoutsContainer.mainLayout.beginIndex + i;
break; break;
} }
} }
for(var i=0; i<layoutsContainer.endLayout.count; ++i){ for(var i=0; i<layoutsContainer.endLayout.count; ++i){
if(layoutsContainer.endLayout.children[i] === appletItem){ var child = layoutsContainer.endLayout.children[i];
if (child === appletItem){
//create a very high index in order to not need to exchange hovering messages //create a very high index in order to not need to exchange hovering messages
//between layoutsContainer.mainLayout and layoutsContainer.endLayout //between layoutsContainer.mainLayout and layoutsContainer.endLayout
index = layoutsContainer.endLayout.beginIndex + i; index = layoutsContainer.endLayout.beginIndex + i;
@ -182,7 +185,6 @@ Item {
} }
} }
if(appletItem.latteApplet){ if(appletItem.latteApplet){
if(index===layoutsContainer.startLayout.beginIndex || index===layoutsContainer.mainLayout.beginIndex || index===layoutsContainer.endLayout.beginIndex) if(index===layoutsContainer.startLayout.beginIndex || index===layoutsContainer.mainLayout.beginIndex || index===layoutsContainer.endLayout.beginIndex)
latteApplet.disableLeftSpacer = false; latteApplet.disableLeftSpacer = false;
@ -237,6 +239,12 @@ Item {
} }
} }
function slotDestroyInternalViewSplitters() {
if (isInternalViewSplitter) {
destroy();
}
}
//! pos in global root positioning //! pos in global root positioning
function containsPos(pos) { function containsPos(pos) {
var relPos = root.mapToItem(appletItem,pos.x, pos.y); var relPos = root.mapToItem(appletItem,pos.x, pos.y);
@ -330,6 +338,7 @@ Item {
checkIndex(); checkIndex();
root.updateIndexes.connect(checkIndex); root.updateIndexes.connect(checkIndex);
root.clearZoomSignal.connect(clearZoom); root.clearZoomSignal.connect(clearZoom);
root.destroyInternalViewSplitters.connect(slotDestroyInternalViewSplitters);
} }
Component.onDestruction: { Component.onDestruction: {
@ -348,6 +357,7 @@ Item {
root.updateIndexes.disconnect(checkIndex); root.updateIndexes.disconnect(checkIndex);
root.clearZoomSignal.disconnect(clearZoom); root.clearZoomSignal.disconnect(clearZoom);
root.destroyInternalViewSplitters.disconnect(slotDestroyInternalViewSplitters);
if (appletItem.latteApplet) { if (appletItem.latteApplet) {
appletItem.latteApplet.signalAnimationsNeedBothAxis.disconnect(slotAnimationsNeedBothAxis); appletItem.latteApplet.signalAnimationsNeedBothAxis.disconnect(slotAnimationsNeedBothAxis);

@ -46,6 +46,7 @@ DragDrop.DropArea {
//// BEGIN SIGNALS //// BEGIN SIGNALS
signal clearZoomSignal(); signal clearZoomSignal();
signal destroyInternalViewSplitters();
signal separatorsUpdated(); signal separatorsUpdated();
signal signalActivateEntryAtIndex(int entryIndex); signal signalActivateEntryAtIndex(int entryIndex);
signal signalNewInstanceForEntryAtIndex(int entryIndex); signal signalNewInstanceForEntryAtIndex(int entryIndex);
@ -587,6 +588,8 @@ DragDrop.DropArea {
} else if (!inConfigureAppletsMode) { } else if (!inConfigureAppletsMode) {
splitMainLayoutToLayouts(); splitMainLayoutToLayouts();
} }
updateIndexes();
} }
//! It is used only when the user chooses different alignment types //! It is used only when the user chooses different alignment types
@ -602,14 +605,17 @@ DragDrop.DropArea {
splitMainLayoutToLayouts(); splitMainLayoutToLayouts();
} else { } else {
joinLayoutsToMainLayout(); joinLayoutsToMainLayout();
root.destroyInternalViewSplitters();
} }
} else { } else {
if (panelUserSetAlignment===Latte.Types.Justify) { if (panelUserSetAlignment===Latte.Types.Justify) {
addInternalViewSplitters(); addInternalViewSplitters();
} else { } else {
removeInternalViewSplitters(); root.destroyInternalViewSplitters();
} }
} }
updateIndexes();
} }
onLatteViewChanged: { onLatteViewChanged: {
@ -1221,35 +1227,6 @@ DragDrop.DropArea {
return (latteView.visibility.containsMouse && !rootMouseArea.containsMouse && mouseInCanBeHoveredApplet()); return (latteView.visibility.containsMouse && !rootMouseArea.containsMouse && mouseInCanBeHoveredApplet());
} }
function removeInternalViewSplitters(){
if (internalViewSplittersCount() > 0) {
console.log("Removing splitters... : " + internalViewSplittersCount());
for (var container in layoutsContainer.startLayout.children) {
var item = layoutsContainer.startLayout.children[container];
if(item && item.isInternalViewSplitter) {
item.destroy();
}
}
for (var container in layoutsContainer.mainLayout.children) {
var item = layoutsContainer.mainLayout.children[container];
if(item && item.isInternalViewSplitter) {
item.destroy();
}
}
for (var container in layoutsContainer.endLayout.children) {
var item = layoutsContainer.endLayout.children[container];
if(item && item.isInternalViewSplitter) {
item.destroy();
}
}
console.log("Removed splitters... : " + internalViewSplittersCount());
}
}
function setHoveredIndex(ind) { function setHoveredIndex(ind) {
layoutsContainer.hoveredIndex = ind; layoutsContainer.hoveredIndex = ind;
} }
@ -1526,8 +1503,6 @@ DragDrop.DropArea {
item.parent = layoutsContainer.endLayout; item.parent = layoutsContainer.endLayout;
} }
} }
updateIndexes();
} }
function joinLayoutsToMainLayout() { function joinLayoutsToMainLayout() {
@ -1550,8 +1525,6 @@ DragDrop.DropArea {
var itemL = layoutsContainer.startLayout.children[0]; var itemL = layoutsContainer.startLayout.children[0];
itemL.parent = layoutsContainer.mainLayout; itemL.parent = layoutsContainer.mainLayout;
} }
updateIndexes();
} }
//END functions //END functions

Loading…
Cancel
Save