Skip to content

Commit a15ef2c

Browse files
committed
1 parent 05f97f5 commit a15ef2c

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/vs/workbench/browser/dnd.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,10 @@ export function containsDragType(event: DragEvent, ...dragTypesToFind: string[])
509509
return false;
510510
}
511511

512+
export type Before2D = { verticallyBefore: boolean; horizontallyBefore: boolean; };
513+
512514
export interface ICompositeDragAndDrop {
513-
drop(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent, before?: boolean): void;
515+
drop(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent, before?: Before2D): void;
514516
onDragOver(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent): boolean;
515517
onDragEnter(data: IDragAndDropData, target: string | undefined, originalEvent: DragEvent): boolean;
516518
}

src/vs/workbench/browser/parts/activitybar/activitybarPart.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
4242
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
4343
import { getUserDataSyncStore } from 'vs/platform/userDataSync/common/userDataSync';
4444
import { IProductService } from 'vs/platform/product/common/productService';
45+
import { Before2D } from 'vs/workbench/browser/dnd';
4546

4647
interface IPlaceholderViewlet {
4748
id: string;
@@ -152,7 +153,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
152153
hidePart: () => this.layoutService.setSideBarHidden(true),
153154
dndHandler: new CompositeDragAndDrop(this.viewDescriptorService, ViewContainerLocation.Sidebar,
154155
(id: string, focus?: boolean) => this.viewletService.openViewlet(id, focus),
155-
(from: string, to: string, before?: boolean) => this.compositeBar.move(from, to, before)
156+
(from: string, to: string, before?: Before2D) => this.compositeBar.move(from, to, before?.verticallyBefore)
156157
),
157158
compositeSize: 50,
158159
colors: (theme: IColorTheme) => this.getActivitybarItemColors(theme),

src/vs/workbench/browser/parts/compositeBar.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
2323
import { IViewContainersRegistry, Extensions as ViewContainerExtensions, ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
2424
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
2525
import { IComposite } from 'vs/workbench/common/composite';
26-
import { CompositeDragAndDropData, CompositeDragAndDropObserver, IDraggedCompositeData, ICompositeDragAndDrop } from 'vs/workbench/browser/dnd';
26+
import { CompositeDragAndDropData, CompositeDragAndDropObserver, IDraggedCompositeData, ICompositeDragAndDrop, Before2D } from 'vs/workbench/browser/dnd';
2727

2828
export interface ICompositeBarItem {
2929
id: string;
@@ -39,9 +39,9 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
3939
private viewDescriptorService: IViewDescriptorService,
4040
private targetContainerLocation: ViewContainerLocation,
4141
private openComposite: (id: string, focus?: boolean) => Promise<IPaneComposite | undefined>,
42-
private moveComposite: (from: string, to: string, before?: boolean) => void,
42+
private moveComposite: (from: string, to: string, before?: Before2D) => void,
4343
) { }
44-
drop(data: CompositeDragAndDropData, targetCompositeId: string | undefined, originalEvent: DragEvent, before?: boolean): void {
44+
drop(data: CompositeDragAndDropData, targetCompositeId: string | undefined, originalEvent: DragEvent, before?: Before2D): void {
4545
const dragData = data.getData();
4646
const viewContainerRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);
4747

@@ -255,7 +255,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
255255
},
256256
onDrop: (e: IDraggedCompositeData) => {
257257
const pinnedItems = this.getPinnedComposites();
258-
this.options.dndHandler.drop(e.dragAndDropData, pinnedItems[pinnedItems.length - 1].id, e.eventData, false);
258+
this.options.dndHandler.drop(e.dragAndDropData, pinnedItems[pinnedItems.length - 1].id, e.eventData, { horizontallyBefore: false, verticallyBefore: false });
259259
toggleClass(parent, 'dragged-over', false);
260260
}
261261
}));

src/vs/workbench/browser/parts/compositeBarActions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { DelayedDragHandler } from 'vs/base/browser/dnd';
1818
import { IActivity } from 'vs/workbench/common/activity';
1919
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2020
import { Emitter } from 'vs/base/common/event';
21-
import { LocalSelectionTransfer, DraggedCompositeIdentifier, DraggedViewIdentifier, CompositeDragAndDropObserver, ICompositeDragAndDrop } from 'vs/workbench/browser/dnd';
21+
import { LocalSelectionTransfer, DraggedCompositeIdentifier, DraggedViewIdentifier, CompositeDragAndDropObserver, ICompositeDragAndDrop, Before2D } from 'vs/workbench/browser/dnd';
2222
import { Color } from 'vs/base/common/color';
2323

2424
export interface ICompositeActivity {
@@ -516,7 +516,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
516516
this.showContextMenu(container);
517517
}));
518518

519-
let insertDropBefore: boolean | undefined = undefined;
519+
let insertDropBefore: Before2D | undefined = undefined;
520520
// Allow to drag
521521
this._register(CompositeDragAndDropObserver.INSTANCE.registerDraggable(this.container, () => { return { type: 'composite', id: this.activity.id }; }, {
522522
onDragOver: e => {
@@ -534,7 +534,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
534534

535535
onDrop: e => {
536536
dom.EventHelper.stop(e.eventData, true);
537-
this.dndHandler.drop(e.dragAndDropData, this.activity.id, e.eventData, !!insertDropBefore);
537+
this.dndHandler.drop(e.dragAndDropData, this.activity.id, e.eventData, insertDropBefore);
538538
insertDropBefore = this.updateFromDragging(container, false, e.eventData);
539539
},
540540
onDragStart: e => {
@@ -563,7 +563,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
563563
this.updateStyles();
564564
}
565565

566-
private updateFromDragging(element: HTMLElement, showFeedback: boolean, event: DragEvent): boolean | undefined {
566+
private updateFromDragging(element: HTMLElement, showFeedback: boolean, event: DragEvent): Before2D | undefined {
567567
const rect = element.getBoundingClientRect();
568568
const posX = event.clientX;
569569
const posY = event.clientY;
@@ -598,7 +598,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
598598
return undefined;
599599
}
600600

601-
return top || left;
601+
return { verticallyBefore: top, horizontallyBefore: left };
602602
}
603603

604604
private showContextMenu(container: HTMLElement): void {

src/vs/workbench/browser/parts/panel/panelPart.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { MenuId } from 'vs/platform/actions/common/actions';
3838
import { ViewMenuActions } from 'vs/workbench/browser/parts/views/viewMenuActions';
3939
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
4040
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
41+
import { Before2D } from 'vs/workbench/browser/dnd';
4142

4243
interface ICachedPanel {
4344
id: string;
@@ -148,7 +149,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
148149
hidePart: () => this.layoutService.setPanelHidden(true),
149150
dndHandler: new CompositeDragAndDrop(this.viewDescriptorService, ViewContainerLocation.Panel,
150151
(id: string, focus?: boolean) => this.openPanel(id, focus) as Promise<IPaneComposite | undefined>,
151-
(from: string, to: string, before?: boolean) => this.compositeBar.move(from, to, before)
152+
(from: string, to: string, before?: Before2D) => this.compositeBar.move(from, to, before?.horizontallyBefore)
152153
),
153154
compositeSize: 0,
154155
overflowActionSize: 44,

0 commit comments

Comments
 (0)