Skip to content

Commit

Permalink
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core
Browse files Browse the repository at this point in the history
… into gh-pages
  • Loading branch information
JensLincke committed Sep 27, 2023
2 parents 33d8d60 + 0b3f04e commit 572212c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/components/widgets/lively-window-docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,35 @@ export default class LivelyWindowDocking extends Morph {
}
}

resizeMySlot(window, newSize) {
return; // @debug
var slot = this.availableDockingAreas.find((area) => (area.window == window)); // recheck diff between var and let
// lively.notify("Resize slot called");
if (slot) {
this.availableDockingAreas.forEach(ea => {
// debugger; tabbed wrapper closing detection still fails...
if (!ea.window || !(ea.window.parentElement)) {
var newBounds = null;
if (ea.bounds.left() == slot.bounds.left() && ea.bounds.width == slot.bounds.width) { // vertical setup
if (ea.bounds.top() + ea.bounds.height == slot.bounds.top()) { // ea top() of slot
newBounds = rect(ea.bounds.left(), ea.bounds.top(), ea.bounds.width, ea.bounds.height + slot.bounds.height);
} else if (slot.bounds.top() + slot.bounds.height == ea.bounds.top()) { // ea bottom of slot
newBounds = rect(slot.bounds.left(), slot.bounds.top(), slot.bounds.width, slot.bounds.height + ea.bounds.height);
}
} else if (ea.bounds.top() == slot.bounds.top() && ea.bounds.height == slot.bounds.height) { // horizontal setup
if (ea.bounds.left() + ea.bounds.width == slot.bounds.left()) { // ea left() of slot
newBounds = rect(ea.bounds.left(), ea.bounds.top(), ea.bounds.width + slot.bounds.width, ea.bounds.height);
} else if (slot.bounds.left() + slot.bounds.width == ea.bounds.left()) { // ea right of slot
newBounds = rect(slot.bounds.left(), slot.bounds.top(), slot.bounds.width + ea.bounds.width, slot.bounds.height);
}
}
}
});
// only finally resize it's own slot after each neighboring slot has been accounted for. expect newSize to be compatible with bounds?
slot.bounds = newSize;
}
}

tryAdjoiningEmptySlots(slot) {
this.availableDockingAreas.forEach(ea => {
// debugger; tabbed wrapper closing detection still fails...
Expand Down
9 changes: 7 additions & 2 deletions src/components/widgets/lively-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default class Window extends Morph {
this.addEventListener('dblclick', evt => { this.onDoubleClick(evt); });
this.get('.window-close').addEventListener('click', evt => { this.onCloseButtonClicked(evt); });
this.addEventListener('keyup', evt => { this.onKeyUp(evt); });

} catch (err) {
console.log("Error, binding events! Continue anyway!", err)
}
Expand Down Expand Up @@ -487,7 +488,6 @@ export default class Window extends Morph {


onWindowMouseMove(evt) {
//lively.showEvent(evt)

if (this.dragging) {
evt.preventDefault();
Expand Down Expand Up @@ -530,8 +530,12 @@ export default class Window extends Morph {
}

onExtentChanged(evt) {
console.log(evt); // evt has no content? => current bounds must already have been refreshed
if (this.target) {
this.target.dispatchEvent(new CustomEvent("extent-changed"));
if (this.isDocked()) {
lively.windowDocking.resizeMySlot(this, evt);
}
}
}

Expand Down Expand Up @@ -606,7 +610,8 @@ export default class Window extends Morph {
this.target.dispatchEvent(new CustomEvent("extent-changed"))
this.classList.add("docked")

this.displayResizeHandle(!this.isDocked())
// DO display resize handles to change slot sizes. Could be made custom in the future to disallow out-of-bounds dragging
this.displayResizeHandle(this.isDocked())
}

undockMe() {
Expand Down

0 comments on commit 572212c

Please sign in to comment.