diff --git a/src/components/widgets/lively-window-docking.js b/src/components/widgets/lively-window-docking.js index 216674718..bd44d9d7b 100644 --- a/src/components/widgets/lively-window-docking.js +++ b/src/components/widgets/lively-window-docking.js @@ -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... diff --git a/src/components/widgets/lively-window.js b/src/components/widgets/lively-window.js index f5e6005ab..38ef6d13a 100644 --- a/src/components/widgets/lively-window.js +++ b/src/components/widgets/lively-window.js @@ -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) } @@ -487,7 +488,6 @@ export default class Window extends Morph { onWindowMouseMove(evt) { - //lively.showEvent(evt) if (this.dragging) { evt.preventDefault(); @@ -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); + } } } @@ -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() {