1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

NEW Intuitive InConfigureApplets Mode

--I have managed to solve most of the issues that were
preventing a live demonstration of applets layout
during InConfigureApplets mode... Things are more
intuitive now are updated correctly between different
layout areas... enjoy...
This commit is contained in:
Michail Vourlakos 2020-05-08 21:15:10 +03:00
parent 7a451facb2
commit 97a1c3fdb8
8 changed files with 342 additions and 212 deletions

View File

@ -238,7 +238,7 @@ function removeApplet (applet) {
//insert item2 before item1
function insertBefore(item1, item2) {
return insertBeforeForLayout(layout, item1, item2);
return insertBeforeForLayout(item1.parent, item1, item2);;
}
//insert item2 before item1
@ -273,7 +273,7 @@ function insertBeforeForLayout(tLayout, item1, item2) {
//insert item2 after item1
function insertAfter(item1, item2) {
return insertAfterForLayout(layout, item1, item2);
return insertAfterForLayout(item1.parent, item1, item2);
}
//insert item2 after item1
@ -315,16 +315,16 @@ function insertAfterForLayout(tLayout, item1, item2) {
}
function insertAtIndex(item, position) {
function insertAtIndex(relevantLayout, item, position) {
var addToEnd = false;
if (position < 0 || (position > layout.children.length && !item.isInternalViewSplitter)) {
if (position < 0 || (position > relevantLayout.children.length && !item.isInternalViewSplitter)) {
return;
} else if (position >= layout.children.length) {
} else if (position >= relevantLayout.children.length) {
addToEnd = true;
}
//never ever insert after lastSpacer
var firstItem = (layout.children.length === 1) && (layout.children[0] === lastSpacer);
var firstItem = (relevantLayout.children.length === 1) && (relevantLayout.children[0] === lastSpacer);
//Important !!! , this is used to add the first item
if(firstItem){
@ -333,28 +333,28 @@ function insertAtIndex(item, position) {
}
if (addToEnd){
item.parent=layout;
item.parent=relevantLayout;
return;
}
if(layout.children.length > 0){
if (layout.children[position] === lastSpacer) {
if(relevantLayout.children.length > 0){
if (relevantLayout.children[position] === lastSpacer) {
--position;
}
}
var removedItems = new Array();
var totalChildren = layout.children.length;
var totalChildren = relevantLayout.children.length;
for (var i = position; i < totalChildren; ++i) {
var child = layout.children[position];
var child = relevantLayout.children[position];
child.parent = root;
removedItems.push(child);
}
item.parent = layout;
item.parent = relevantLayout;
for (var i in removedItems) {
removedItems[i].parent = layout;
removedItems[i].parent = relevantLayout;
}
}
@ -479,14 +479,12 @@ function insertAtLayoutCoordinates(tLayout, item, x, y) {
function insertAtCoordinates2(item, x, y) {
var pos = -1;
if (!root.inConfigureAppletsMode) {
var layoutPosS = layoutS.mapFromItem(root, x, y);
pos = insertAtLayoutCoordinates(layoutS, item, layoutPosS.x, layoutPosS.y);
var layoutPosS = layoutS.mapFromItem(root, x, y);
pos = insertAtLayoutCoordinates(layoutS, item, layoutPosS.x, layoutPosS.y);
if (pos === -1){
var layoutPosE = layoutE.mapFromItem(root, x, y);
pos = insertAtLayoutCoordinates(layoutE, item, layoutPosE.x, layoutPosE.y);
}
if (pos === -1){
var layoutPosE = layoutE.mapFromItem(root, x, y);
pos = insertAtLayoutCoordinates(layoutE, item, layoutPosE.x, layoutPosE.y);
}
if (pos!==childFoundId && pos === -1) {

View File

@ -33,7 +33,7 @@ ContainerAbility.Animations {
&& needThickness.count === 0
&& ((needLength.count === 0)
|| (needLength.count===1 && editModeVisual.inEditMode))
&& (!dragOverlay || (dragOverlay && !dragOverlay.pressed)) /*do not update during moving/dragging applets*/
//! Public Properties
active: plasmoid.configuration.animationsEnabled && LatteCore.WindowSystem.compositingActive

View File

@ -23,6 +23,9 @@ import org.kde.plasma.plasmoid 2.0
import "./privates" as Ability
Ability.IndexerPrivate {
//! do not update during dragging/moving applets inConfigureAppletsMode
updateIsBlocked: root.dragOverlay && root.dragOverlay.pressed
function getClientBridge(index) {
if (clientsBridges.length<=0) {
return false;

View File

@ -27,148 +27,184 @@ AbilityDefinition.Indexer {
property Item layouts: null
separators: {
var seps = [];
property bool updateIsBlocked: false
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
property var clients: []
property var clientsBridges: []
Binding{
target: indxr
property: "separators"
value: {
if (index.updateIsBlocked) {
return;
}
}
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
var seps = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
}
}
}
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
}
}
}
return seps;
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem && appletItem.isSeparator && appletItem.index>=0) {
seps.push(appletItem.index);
}
}
return seps;
}
}
hidden: {
var hdn = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
Binding {
target: indxr
property: "hidden"
value: {
if (index.updateIsBlocked) {
return;
}
}
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
var hdn = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
}
}
}
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
}
}
}
return hdn;
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem && appletItem.isHidden && appletItem.index>=0) {
hdn.push(appletItem.index);
}
}
return hdn;
}
}
readonly property var clients: {
var clns = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
Binding {
target: indxr
property: "clients"
value: {
if (index.updateIsBlocked) {
return;
}
}
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
var clns = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
}
}
}
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
}
}
}
return clns;
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported) {
clns.push(appletItem.index);
}
}
return clns;
}
}
readonly property var clientsBridges: {
var bdgs = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
Binding {
target: indxr
property: "clientsBridges"
value: {
if (index.updateIsBlocked) {
return;
}
}
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
var bdgs = [];
var sLayout = layouts.startLayout;
for (var i=0; i<sLayout.children.length; ++i){
var appletItem = sLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
}
}
}
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
var mLayout = layouts.mainLayout;
for (var i=0; i<mLayout.children.length; ++i){
var appletItem = mLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
}
}
}
return bdgs;
var eLayout = layouts.endLayout;
for (var i=0; i<eLayout.children.length; ++i){
var appletItem = eLayout.children[i];
if (appletItem
&& appletItem.index>=0
&& appletItem.communicator
&& appletItem.communicator.indexerIsSupported
&& appletItem.communicator.bridge
&& appletItem.communicator.bridge.indexer) {
bdgs.push(appletItem.communicator.bridge.indexer);
}
}
return bdgs;
}
}
}

View File

@ -64,6 +64,40 @@ MouseArea {
onWidthChanged: tooltip.visible = false;
function hoveredItem(x, y) {
//! main layout
var relevantLayout = mapFromItem(layoutsContainer.mainLayout,0,0);
var item = layoutsContainer.mainLayout.childAt(x-relevantLayout.x, y-relevantLayout.y);
if (!item) {
// start layout
relevantLayout = mapFromItem(layoutsContainer.startLayout,0,0);
item = layoutsContainer.startLayout.childAt(x-relevantLayout.x, y-relevantLayout.y);
}
if (!item) {
relevantLayout = mapFromItem(layoutsContainer.endLayout,0,0);
item = layoutsContainer.endLayout.childAt(x-relevantLayout.x, y-relevantLayout.y);
}
return item;
}
function relevantLayoutForApplet(curapplet) {
var relevantLayout;
if (curapplet.parent === layoutsContainer.mainLayout) {
relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
} else if (curapplet.parent === layoutsContainer.startLayout) {
relevantLayout = mapFromItem(layoutsContainer.startLayout, 0, 0);
} else if (curapplet.parent === layoutsContainer.endLayout) {
relevantLayout = mapFromItem(layoutsContainer.endLayout, 0, 0);
}
return relevantLayout;
}
onPositionChanged: {
if (pressed) {
var padding = units.gridUnit * 3;
@ -92,8 +126,7 @@ MouseArea {
lastX = mouse.x;
lastY = mouse.y;
var relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
var item = layoutsContainer.mainLayout.childAt(mouse.x-relevantLayout.x, mouse.y-relevantLayout.y);
var item = hoveredItem(mouse.x, mouse.y);
if (item && item !== placeHolder) {
placeHolder.parent = configurationArea;
@ -107,10 +140,9 @@ MouseArea {
}
}
} else {
var relevantLayout = mapFromItem(layoutsContainer.mainLayout,0,0);
} else {
var item = hoveredItem(mouse.x, mouse.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 {
@ -132,13 +164,16 @@ MouseArea {
onCurrentAppletChanged: {
previousCurrentApplet = currentApplet;
if (!currentApplet
|| !root.dragOverlay.currentApplet) {
if (!currentApplet || !root.dragOverlay.currentApplet) {
hideTimer.restart();
return;
}
var relevantLayout = mapFromItem(layoutsContainer.mainLayout, 0, 0);
var relevantLayout = relevantLayoutForApplet(currentApplet) ;
if (!relevantLayout) {
return;
}
handle.x = relevantLayout.x + currentApplet.x;
handle.y = relevantLayout.y + currentApplet.y;
@ -202,6 +237,8 @@ MouseArea {
// handle.width = currentApplet.width;
// handle.height = currentApplet.height;
root.layoutManagerSave();
root.layoutManagerMoveAppletsOutOfMainLayoutToLayouts();
layoutsContainer.updateSizeForAppletsInFill();
}
onWheel: {

View File

@ -43,15 +43,26 @@ Abilities.AbilityGrid {
readonly property int count: children.length
//it is used in calculations for fillWidth,fillHeight applets
property int shownApplets: 0
property int fillApplets: 0
//it is used in calculations for fillWidth,fillHeight applets
property int sizeWithNoFillApplets: 0
readonly property int maxIndex: 99999
property int firstVisibleIndex: -1
property int lastVisibleIndex: -1
//! do not update during dragging/moving applets inConfigureAppletsMode
readonly property bool updateIsBlocked: root.dragOverlay && root.dragOverlay.pressed
Binding{
target: appletsContainer
property:"sizeWithNoFillApplets"
when: appletsContainer
value: {
if (!animations.inNormalFillCalculationsState) {
if (!animations.inNormalFillCalculationsState || updateIsBlocked) {
return;
}
@ -68,43 +79,58 @@ Abilities.AbilityGrid {
}
}
property int shownApplets: {
var res = 0;
for (var i=0; i<children.length; ++i){
if (children[i] && children[i].isHidden) {
//do nothing
} else if (children[i] && (children[i].applet || children[i].isInternalViewSplitter)){
res = res + 1;
Binding{
target: appletsContainer
property:"shownApplets"
when: appletsContainer
value: {
if (updateIsBlocked) {
return;
}
}
return res;
var res = 0;
for (var i=0; i<children.length; ++i){
if (children[i] && children[i].isHidden) {
//do nothing
} else if (children[i] && (children[i].applet || children[i].isInternalViewSplitter)){
res = res + 1;
}
}
return res;
}
}
//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++;
Binding{
target: appletsContainer
property:"fillApplets"
when: appletsContainer
value: {
if (updateIsBlocked) {
return;
}
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;
}
return no;
}
readonly property int maxIndex: 99999
property int firstVisibleIndex: -1
property int lastVisibleIndex: -1
Binding{
target: appletsContainer
property:"firstVisibleIndex"
when: appletsContainer
value: {
if (root.inConfigureAppletsMode) {
if (updateIsBlocked) {
return;
}
@ -128,7 +154,7 @@ Abilities.AbilityGrid {
property:"lastVisibleIndex"
when: appletsContainer
value: {
if (root.inConfigureAppletsMode) {
if (updateIsBlocked) {
return;
}

View File

@ -24,48 +24,75 @@ import org.kde.plasma.core 2.0 as PlasmaCore
AbilityGridPrivate {
id: grid
ability.parabolic.restoreZoomIsBlocked: {
//! do not update during dragging/moving applets inConfigureAppletsMode
readonly property bool updateIsBlocked: root.dragOverlay && root.dragOverlay.pressed
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.parabolicEffectIsSupported
&& appletItem.communicator.bridge.parabolic.client.restoreZoomIsBlocked) {
return true;
Binding{
target: ability.require
property: "restoreZoomIsBlocked"
value: {
if (grid.updateIsBlocked) {
return;
}
}
return false;
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.parabolicEffectIsSupported
&& appletItem.communicator.bridge.parabolic.client.restoreZoomIsBlocked) {
return true;
}
}
return false;
}
}
ability.require.windowsTrackingCount: {
var cnts = 0;
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.requires.windowsTrackingEnabled) {
cnts = cnts + 1;
Binding{
target: ability.require
property: "windowsTrackingCount"
value: {
if (grid.updateIsBlocked) {
return;
}
}
return cnts;
var cnts = 0;
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.requires.windowsTrackingEnabled) {
cnts = cnts + 1;
}
}
return cnts;
}
}
ability.require.maxInnerZoomFactor: {
var max = 1.0;
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.requires.innerZoomFactor > max) {
max = appletItem.communicator.requires.innerZoomFactor;
Binding{
target: ability.require
property: "maxInnerZoomFactor"
value: {
if (grid.updateIsBlocked) {
return;
}
}
return max;
var max = 1.0;
for (var i=0; i<grid.children.length; ++i){
var appletItem = grid.children[i];
if (appletItem
&& appletItem.communicator
&& appletItem.communicator.requires.innerZoomFactor > max) {
max = appletItem.communicator.requires.innerZoomFactor;
}
}
return max;
}
}
}

View File

@ -543,7 +543,7 @@ Item {
return;
}
if (!inConfigureAppletsMode){
if (root.editMode/*!inConfigureAppletsMode*/){
if (panelUserSetAlignment===LatteCore.Types.Justify) {
addInternalViewSplitters();
splitMainLayoutToLayouts();
@ -551,12 +551,6 @@ Item {
joinLayoutsToMainLayout();
root.destroyInternalViewSplitters();
}
} else {
if (panelUserSetAlignment===LatteCore.Types.Justify) {
addInternalViewSplitters();
} else {
root.destroyInternalViewSplitters();
}
}
LayoutManager.save();
@ -827,7 +821,7 @@ Item {
if (internalViewSplittersCount() === 0) {
addInternalViewSplitter(plasmoid.configuration.splitterPosition);
addInternalViewSplitter(plasmoid.configuration.splitterPosition2);
}
}
}
function addInternalViewSplitter(pos){
@ -839,9 +833,9 @@ Item {
container.visible = true;
if(pos>=0 ){
LayoutManager.insertAtIndex(container, pos);
LayoutManager.insertAtIndex(layoutsContainer.mainLayout, container, pos);
} else {
LayoutManager.insertAtIndex(container, Math.floor(layoutsContainer.mainLayout.count / 2));
LayoutManager.insertAtIndex(layoutsContainer.mainLayout, container, Math.floor(layoutsContainer.mainLayout.count / 2));
}
}
}
@ -1118,6 +1112,14 @@ Item {
layoutsContainer.updateSizeForAppletsInFill();
}
function layoutManagerMoveAppletsOutOfMainLayoutToLayouts() {
if (plasmoid.configuration.alignment !== 10) {
return;
}
splitMainLayoutToLayouts();
}
function splitMainLayoutToLayouts() {
if (internalViewSplittersCount() === 2) {
console.log("LAYOUTS: Moving applets from MAIN to THREE Layouts mode...");
@ -1136,18 +1138,19 @@ Item {
}
// console.log("update layouts 1:"+splitter + " - "+splitter2);
for (var i=0; i<=splitter; ++i){
for (var i=0; i<splitter; ++i){
var item = layoutsContainer.mainLayout.children[0];
item.parent = layoutsContainer.startLayout;
}
splitter2 = splitter2 - splitter - 1;
splitter2 = splitter2 - splitter;
// console.log("update layouts 2:"+splitter + " - "+splitter2);
totalChildren = layoutsContainer.mainLayout.children.length;
for (var i=splitter2+1; i<totalChildren; ++i){
var item = layoutsContainer.mainLayout.children[splitter2+1];
item.parent = layoutsContainer.endLayout;
for (var i=totalChildren-1; i>=splitter2+1; --i){
var item = layoutsContainer.mainLayout.children[i];
LayoutManager.insertAtIndex(layoutsContainer.endLayout, item, 0);
}
}
}