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;
}
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();
onShownAppletsChanged: layoutsContainer.updateSizeForAppletsInFill();
onSizeWithNoFillAppletsChanged: layoutsContainer.updateSizeForAppletsInFill();

@ -160,21 +160,24 @@ Item {
index = -1;
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;
break;
}
}
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;
break;
}
}
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
//between layoutsContainer.mainLayout and layoutsContainer.endLayout
index = layoutsContainer.endLayout.beginIndex + i;
@ -182,7 +185,6 @@ Item {
}
}
if(appletItem.latteApplet){
if(index===layoutsContainer.startLayout.beginIndex || index===layoutsContainer.mainLayout.beginIndex || index===layoutsContainer.endLayout.beginIndex)
latteApplet.disableLeftSpacer = false;
@ -237,6 +239,12 @@ Item {
}
}
function slotDestroyInternalViewSplitters() {
if (isInternalViewSplitter) {
destroy();
}
}
//! pos in global root positioning
function containsPos(pos) {
var relPos = root.mapToItem(appletItem,pos.x, pos.y);
@ -330,6 +338,7 @@ Item {
checkIndex();
root.updateIndexes.connect(checkIndex);
root.clearZoomSignal.connect(clearZoom);
root.destroyInternalViewSplitters.connect(slotDestroyInternalViewSplitters);
}
Component.onDestruction: {
@ -348,6 +357,7 @@ Item {
root.updateIndexes.disconnect(checkIndex);
root.clearZoomSignal.disconnect(clearZoom);
root.destroyInternalViewSplitters.disconnect(slotDestroyInternalViewSplitters);
if (appletItem.latteApplet) {
appletItem.latteApplet.signalAnimationsNeedBothAxis.disconnect(slotAnimationsNeedBothAxis);

@ -46,6 +46,7 @@ DragDrop.DropArea {
//// BEGIN SIGNALS
signal clearZoomSignal();
signal destroyInternalViewSplitters();
signal separatorsUpdated();
signal signalActivateEntryAtIndex(int entryIndex);
signal signalNewInstanceForEntryAtIndex(int entryIndex);
@ -587,6 +588,8 @@ DragDrop.DropArea {
} else if (!inConfigureAppletsMode) {
splitMainLayoutToLayouts();
}
updateIndexes();
}
//! It is used only when the user chooses different alignment types
@ -602,14 +605,17 @@ DragDrop.DropArea {
splitMainLayoutToLayouts();
} else {
joinLayoutsToMainLayout();
root.destroyInternalViewSplitters();
}
} else {
if (panelUserSetAlignment===Latte.Types.Justify) {
addInternalViewSplitters();
} else {
removeInternalViewSplitters();
root.destroyInternalViewSplitters();
}
}
updateIndexes();
}
onLatteViewChanged: {
@ -1221,35 +1227,6 @@ DragDrop.DropArea {
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) {
layoutsContainer.hoveredIndex = ind;
}
@ -1526,8 +1503,6 @@ DragDrop.DropArea {
item.parent = layoutsContainer.endLayout;
}
}
updateIndexes();
}
function joinLayoutsToMainLayout() {
@ -1550,8 +1525,6 @@ DragDrop.DropArea {
var itemL = layoutsContainer.startLayout.children[0];
itemL.parent = layoutsContainer.mainLayout;
}
updateIndexes();
}
//END functions

Loading…
Cancel
Save