Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the possibility to resize the content hover widget #176744

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
88e077e
Adding code
aiday-mar Mar 10, 2023
46446a0
Working code, work from here
aiday-mar Mar 10, 2023
492ecb6
Made the sashes appear, need to write the code so that the sashes can…
aiday-mar Mar 10, 2023
d01bccb
Added the possibility to persist the height of the hover content widget
aiday-mar Mar 10, 2023
c993315
Removing the persisting of the size because the hovers are of differe…
aiday-mar Mar 10, 2023
d34afc3
container dom node size now depends on the resizable element size too…
aiday-mar Mar 10, 2023
182f444
Added code in order to stop the hover from jumping on vertical resize
aiday-mar Mar 10, 2023
8f35179
code in for resizing, need to polish the code
aiday-mar Mar 10, 2023
3234bce
added todo list for steps to take
aiday-mar Mar 10, 2023
36fc4ab
adding some more comments
aiday-mar Mar 10, 2023
7ce0334
Adding comments, current solution works but scroll does not
aiday-mar Mar 12, 2023
2639aae
Added code in order to have the scroll bar on the contents dom node too
aiday-mar Mar 13, 2023
62e5490
Changing the available space above to the mouse box top along with th…
aiday-mar Mar 13, 2023
1ef04a3
work in progress
aiday-mar Mar 13, 2023
a3173d5
changed the code so that the maximu size is rspected for a given width
aiday-mar Mar 13, 2023
be2790e
Removing 4 instead of 2 make the sashes not overflow
aiday-mar Mar 13, 2023
1e79b87
Added code in order to reposition the content hover widget without ex…
aiday-mar Mar 14, 2023
8aff3b9
Changed the z-index of the hover
aiday-mar Mar 14, 2023
57ad530
Removing some code in order to remove the blinking
aiday-mar Mar 14, 2023
92f4f4d
Disabling the vertical sashes when the hover can not be resized anywa…
aiday-mar Mar 14, 2023
277f853
Adding code in order to initially render the layout when first shown …
aiday-mar Mar 14, 2023
66f9d16
Adding code in order to assign different heights and widths to the ho…
aiday-mar Mar 14, 2023
535e3b4
Cleaning the code
aiday-mar Mar 14, 2023
a87c073
Removing a comment
aiday-mar Mar 14, 2023
dd42a36
Changing the order of the code in order to remove error
aiday-mar Mar 14, 2023
c8dcf77
Adding comments
aiday-mar Mar 14, 2023
a477cde
adding a comment for debugging
aiday-mar Mar 14, 2023
8bf403f
Improvemenet in the sizes, somes sizes remain too small
aiday-mar Mar 15, 2023
0a400ab
Save the code
aiday-mar Mar 15, 2023
2bd18c5
Added code in order to persist the widget sizes inside of the file
aiday-mar Mar 15, 2023
69cd233
Changed the code so that the persisted size is taken into account of …
aiday-mar Mar 15, 2023
bab75aa
needs more cleanup
aiday-mar Mar 15, 2023
f5835d7
instead of using the persist widget class use a map that is valid onl…
aiday-mar Mar 15, 2023
d8807eb
working code, but not ideal
aiday-mar Mar 15, 2023
e42ab7f
The initial sizes are used and a resizable html element in the form o…
aiday-mar Mar 16, 2023
7b6261d
Work in progress, improvement
aiday-mar Mar 16, 2023
0bcf469
Placed css in different places and added pointer events none in order…
aiday-mar Mar 16, 2023
8ba746a
Saving changes before changing back to a content widget
aiday-mar Mar 17, 2023
6c438bb
Changed the code so that the sashes are around the content hover
aiday-mar Mar 17, 2023
1e8ff81
Changed the pixel sizes for better rendering
aiday-mar Mar 17, 2023
6b47b7a
persisting the widget sizes
aiday-mar Mar 17, 2023
8a187e3
persist the size event when abrupt disapperance
aiday-mar Mar 17, 2023
5b4795f
Changed the code so as to not have sudden disapperance of the content…
aiday-mar Mar 17, 2023
a05844b
scanning the dom node so as to update the scrollbar on resize
aiday-mar Mar 17, 2023
0315f7e
removing the max height and max width on the resize
aiday-mar Mar 17, 2023
623a5a9
Added a maximum height for the resize after rendering
aiday-mar Mar 17, 2023
a0ecb24
Max size but for some reason the persist size from before is applied …
aiday-mar Mar 17, 2023
4a91de7
Added code in order to cancel the max size on the hiding of the resiz…
aiday-mar Mar 17, 2023
383bb30
Changed the code so as to update the persisted widget sizes on model …
aiday-mar Mar 17, 2023
39439eb
scanning the dom node right after the resizable widget and widget are…
aiday-mar Mar 19, 2023
443b088
Cleaning the code
aiday-mar Mar 19, 2023
3503916
changed the code so that the content hover does not change sides on r…
aiday-mar Mar 19, 2023
892df25
Adding the maximum height and width on the content dom node after the…
aiday-mar Mar 19, 2023
f9a6afd
removing a comment
aiday-mar Mar 19, 2023
1530298
changed the code so that the else if statement is also correctly hand…
aiday-mar Mar 19, 2023
ca27764
Making the resizable eleemnt resize the left side correctly if left o…
aiday-mar Mar 19, 2023
09ec674
changing left offset
aiday-mar Mar 19, 2023
f0ccdf8
Changing the left offset of the resizable element when the widget dom…
aiday-mar Mar 19, 2023
d4635cd
Changed the contents sizes in order to take into account the horizont…
aiday-mar Mar 19, 2023
aed1565
Changint the code so that the vertical and horizontal scrollbars appe…
aiday-mar Mar 19, 2023
8aa537a
Adding a maximum rendering width
aiday-mar Mar 19, 2023
21fd598
Changed code so that when persisted size is used, the height and widt…
aiday-mar Mar 19, 2023
47c42b1
Added code in order to add the additional pixel padding only when the…
aiday-mar Mar 19, 2023
ac4b896
changing the height of the contents dom node depending on whether the…
aiday-mar Mar 19, 2023
90b6921
Changes the pixels so that the height does not change
aiday-mar Mar 19, 2023
24a790f
pixel sizes changed when not using a persisted size, need to further …
aiday-mar Mar 19, 2023
1899e74
added code in order to also know whether it is the first rendering or…
aiday-mar Mar 19, 2023
8114a1b
cleaning the code
aiday-mar Mar 20, 2023
b57836d
cleaned the code
aiday-mar Mar 20, 2023
de68929
Reset the css to original values
aiday-mar Mar 20, 2023
4ca32f2
cleaning the code
aiday-mar Mar 20, 2023
ea30718
Setting initial resizable element, also need to update the size on re…
aiday-mar Mar 20, 2023
2ae9ed2
Changed the pixel positions of the resizable element
aiday-mar Mar 20, 2023
e7cc218
Added some console logs to better understand the code
aiday-mar Mar 20, 2023
12be922
Cleaning the code
aiday-mar Mar 20, 2023
6b1a25b
cleaning the code
aiday-mar Mar 20, 2023
445f1a6
Adding changes
aiday-mar Mar 20, 2023
1fd67c5
Removed some useless code
aiday-mar Mar 20, 2023
791d2e3
Removing certain comments
aiday-mar Mar 20, 2023
6d962ac
Msking the exact persist size be used by chanigng the pixel size used…
aiday-mar Mar 20, 2023
f1a546c
fixing an error with the maximum height rendering
aiday-mar Mar 20, 2023
b300639
updating the top and left values at the very end
aiday-mar Mar 22, 2023
02e0e71
cleaning the code
aiday-mar Mar 23, 2023
4103ea9
added code to change the z index and resize the hover overlay when th…
aiday-mar Mar 23, 2023
b9a9629
cleaning the code
aiday-mar Mar 23, 2023
e7cad3c
Merge branch 'main' into aiday/issue#14165
aiday-mar Mar 23, 2023
0714b6c
cleaning the code
aiday-mar Mar 23, 2023
933a6c6
extracting the hard-coded values
aiday-mar Mar 23, 2023
df2efc4
work in progress which aims to add an underlay below the hover conten…
aiday-mar Mar 23, 2023
c18dc25
reverting to previous work without underlay
aiday-mar Mar 24, 2023
dbe2baa
cleaning the code
aiday-mar Mar 24, 2023
842ec61
changing the size of the sashes so looks better
aiday-mar Mar 24, 2023
e1e47d7
removing the console logs
aiday-mar Mar 24, 2023
b110bc5
cleaning the code
aiday-mar Mar 24, 2023
5f9bec0
Cleaning the CSS widths and heights
aiday-mar Mar 27, 2023
558793c
using a resource map instead of a generic map
aiday-mar Mar 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/vs/base/browser/ui/hover/hover.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
}

.monaco-hover .markdown-hover > .hover-contents:not(.code-hover-contents) {
max-width: 500px;
word-wrap: break-word;
}

Expand Down
16 changes: 16 additions & 0 deletions src/vs/base/browser/ui/resizable/resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,20 @@ export class ResizableHTMLElement {
get preferredSize() {
return this._preferredSize;
}

get northSash() {
return this._northSash;
}

get eastSash() {
return this._eastSash;
}

get westSash() {
return this._westSash;
}

get southSash() {
return this._southSash;
}
}
79 changes: 40 additions & 39 deletions src/vs/base/browser/ui/sash/sash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const PointerEventsDisabledCssClass = 'pointer-events-disabled';
*/
export class Sash extends Disposable {

private el: HTMLElement;
private _el: HTMLElement;
private layoutProvider: ISashLayoutProvider;
private orientation: Orientation;
private size: number;
Expand All @@ -269,6 +269,7 @@ export class Sash extends Disposable {
private readonly orthogonalEndDragHandleDisposables = this._register(new DisposableStore());
private _orthogonalEndDragHandle: HTMLElement | undefined;

get el(): HTMLElement { return this._el; }
get state(): SashState { return this._state; }
get orthogonalStartSash(): Sash | undefined { return this._orthogonalStartSash; }
get orthogonalEndSash(): Sash | undefined { return this._orthogonalEndSash; }
Expand All @@ -282,9 +283,9 @@ export class Sash extends Disposable {
return;
}

this.el.classList.toggle('disabled', state === SashState.Disabled);
this.el.classList.toggle('minimum', state === SashState.AtMinimum);
this.el.classList.toggle('maximum', state === SashState.AtMaximum);
this._el.classList.toggle('disabled', state === SashState.Disabled);
this._el.classList.toggle('minimum', state === SashState.AtMinimum);
this._el.classList.toggle('maximum', state === SashState.AtMaximum);

this._state = state;
this.onDidEnablementChange.fire(state);
Expand Down Expand Up @@ -336,7 +337,7 @@ export class Sash extends Disposable {
this.orthogonalStartDragHandleDisposables.clear();

if (state !== SashState.Disabled) {
this._orthogonalStartDragHandle = append(this.el, $('.orthogonal-drag-handle.start'));
this._orthogonalStartDragHandle = append(this._el, $('.orthogonal-drag-handle.start'));
this.orthogonalStartDragHandleDisposables.add(toDisposable(() => this._orthogonalStartDragHandle!.remove()));
this.orthogonalStartDragHandleDisposables.add(new DomEmitter(this._orthogonalStartDragHandle, 'mouseenter')).event
(() => Sash.onMouseEnter(sash), undefined, this.orthogonalStartDragHandleDisposables);
Expand Down Expand Up @@ -370,7 +371,7 @@ export class Sash extends Disposable {
this.orthogonalEndDragHandleDisposables.clear();

if (state !== SashState.Disabled) {
this._orthogonalEndDragHandle = append(this.el, $('.orthogonal-drag-handle.end'));
this._orthogonalEndDragHandle = append(this._el, $('.orthogonal-drag-handle.end'));
this.orthogonalEndDragHandleDisposables.add(toDisposable(() => this._orthogonalEndDragHandle!.remove()));
this.orthogonalEndDragHandleDisposables.add(new DomEmitter(this._orthogonalEndDragHandle, 'mouseenter')).event
(() => Sash.onMouseEnter(sash), undefined, this.orthogonalEndDragHandleDisposables);
Expand Down Expand Up @@ -406,30 +407,30 @@ export class Sash extends Disposable {
constructor(container: HTMLElement, layoutProvider: ISashLayoutProvider, options: ISashOptions) {
super();

this.el = append(container, $('.monaco-sash'));
this._el = append(container, $('.monaco-sash'));

if (options.orthogonalEdge) {
this.el.classList.add(`orthogonal-edge-${options.orthogonalEdge}`);
this._el.classList.add(`orthogonal-edge-${options.orthogonalEdge}`);
}

if (isMacintosh) {
this.el.classList.add('mac');
this._el.classList.add('mac');
}

const onMouseDown = this._register(new DomEmitter(this.el, 'mousedown')).event;
const onMouseDown = this._register(new DomEmitter(this._el, 'mousedown')).event;
this._register(onMouseDown(e => this.onPointerStart(e, new MouseEventFactory()), this));
const onMouseDoubleClick = this._register(new DomEmitter(this.el, 'dblclick')).event;
const onMouseDoubleClick = this._register(new DomEmitter(this._el, 'dblclick')).event;
this._register(onMouseDoubleClick(this.onPointerDoublePress, this));
const onMouseEnter = this._register(new DomEmitter(this.el, 'mouseenter')).event;
const onMouseEnter = this._register(new DomEmitter(this._el, 'mouseenter')).event;
this._register(onMouseEnter(() => Sash.onMouseEnter(this)));
const onMouseLeave = this._register(new DomEmitter(this.el, 'mouseleave')).event;
const onMouseLeave = this._register(new DomEmitter(this._el, 'mouseleave')).event;
this._register(onMouseLeave(() => Sash.onMouseLeave(this)));

this._register(Gesture.addTarget(this.el));
this._register(Gesture.addTarget(this._el));

const onTouchStart = this._register(new DomEmitter(this.el, EventType.Start)).event;
this._register(onTouchStart(e => this.onPointerStart(e, new GestureEventFactory(this.el)), this));
const onTap = this._register(new DomEmitter(this.el, EventType.Tap)).event;
const onTouchStart = this._register(new DomEmitter(this._el, EventType.Start)).event;
this._register(onTouchStart(e => this.onPointerStart(e, new GestureEventFactory(this._el)), this));
const onTap = this._register(new DomEmitter(this._el, EventType.Tap)).event;

let doubleTapTimeout: any = undefined;
this._register(onTap(event => {
Expand All @@ -448,9 +449,9 @@ export class Sash extends Disposable {
this.size = options.size;

if (options.orientation === Orientation.VERTICAL) {
this.el.style.width = `${this.size}px`;
this._el.style.width = `${this.size - 2}px`;
} else {
this.el.style.height = `${this.size}px`;
this._el.style.height = `${this.size - 2}px`;
}
} else {
this.size = globalSize;
Expand All @@ -470,14 +471,14 @@ export class Sash extends Disposable {
this.orientation = options.orientation || Orientation.VERTICAL;

if (this.orientation === Orientation.HORIZONTAL) {
this.el.classList.add('horizontal');
this.el.classList.remove('vertical');
this._el.classList.add('horizontal');
this._el.classList.remove('vertical');
} else {
this.el.classList.remove('horizontal');
this.el.classList.add('vertical');
this._el.classList.remove('horizontal');
this._el.classList.add('vertical');
}

this.el.classList.toggle('debug', DEBUG);
this._el.classList.toggle('debug', DEBUG);

this.layout();
}
Expand Down Expand Up @@ -516,11 +517,11 @@ export class Sash extends Disposable {
const altKey = event.altKey;
const startEvent: ISashEvent = { startX, currentX: startX, startY, currentY: startY, altKey };

this.el.classList.add('active');
this._el.classList.add('active');
this._onDidStart.fire(startEvent);

// fix https://github.com/microsoft/vscode/issues/21675
const style = createStyleSheet(this.el);
const style = createStyleSheet(this._el);
const updateStyle = () => {
let cursor = '';

Expand Down Expand Up @@ -565,9 +566,9 @@ export class Sash extends Disposable {
const onPointerUp = (e: PointerEvent) => {
EventHelper.stop(e, false);

this.el.removeChild(style);
this._el.removeChild(style);

this.el.classList.remove('active');
this._el.classList.remove('active');
this._onDidEnd.fire();

disposables.dispose();
Expand Down Expand Up @@ -597,11 +598,11 @@ export class Sash extends Disposable {
}

private static onMouseEnter(sash: Sash, fromLinkedSash: boolean = false): void {
if (sash.el.classList.contains('active')) {
if (sash._el.classList.contains('active')) {
sash.hoverDelayer.cancel();
sash.el.classList.add('hover');
sash._el.classList.add('hover');
} else {
sash.hoverDelayer.trigger(() => sash.el.classList.add('hover'), sash.hoverDelay).then(undefined, () => { });
sash.hoverDelayer.trigger(() => sash._el.classList.add('hover'), sash.hoverDelay).then(undefined, () => { });
}

if (!fromLinkedSash && sash.linkedSash) {
Expand All @@ -611,7 +612,7 @@ export class Sash extends Disposable {

private static onMouseLeave(sash: Sash, fromLinkedSash: boolean = false): void {
sash.hoverDelayer.cancel();
sash.el.classList.remove('hover');
sash._el.classList.remove('hover');

if (!fromLinkedSash && sash.linkedSash) {
Sash.onMouseLeave(sash.linkedSash, true);
Expand All @@ -634,25 +635,25 @@ export class Sash extends Disposable {
layout(): void {
if (this.orientation === Orientation.VERTICAL) {
const verticalProvider = (<IVerticalSashLayoutProvider>this.layoutProvider);
this.el.style.left = verticalProvider.getVerticalSashLeft(this) - (this.size / 2) + 'px';
this._el.style.left = verticalProvider.getVerticalSashLeft(this) - (this.size / 2) + 'px';

if (verticalProvider.getVerticalSashTop) {
this.el.style.top = verticalProvider.getVerticalSashTop(this) + 'px';
this._el.style.top = verticalProvider.getVerticalSashTop(this) + 'px';
}

if (verticalProvider.getVerticalSashHeight) {
this.el.style.height = verticalProvider.getVerticalSashHeight(this) + 'px';
this._el.style.height = verticalProvider.getVerticalSashHeight(this) + 'px';
}
} else {
const horizontalProvider = (<IHorizontalSashLayoutProvider>this.layoutProvider);
this.el.style.top = horizontalProvider.getHorizontalSashTop(this) - (this.size / 2) + 'px';
this._el.style.top = horizontalProvider.getHorizontalSashTop(this) - (this.size / 2) + 'px';

if (horizontalProvider.getHorizontalSashLeft) {
this.el.style.left = horizontalProvider.getHorizontalSashLeft(this) + 'px';
this._el.style.left = horizontalProvider.getHorizontalSashLeft(this) + 'px';
}

if (horizontalProvider.getHorizontalSashWidth) {
this.el.style.width = horizontalProvider.getHorizontalSashWidth(this) + 'px';
this._el.style.width = horizontalProvider.getHorizontalSashWidth(this) + 'px';
}
}
}
Expand All @@ -673,6 +674,6 @@ export class Sash extends Disposable {

override dispose(): void {
super.dispose();
this.el.remove();
this._el.remove();
}
}
Loading