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

feat: onDidRepositionFloatingGroup event #754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions packages/dockview-core/src/api/component.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,20 @@ export class DockviewApi implements CommonApi<SerializedDockview> {
return this.component.onDidRemovePanel;
}

/**
* Invoked when a panel is moved
*/
get onDidMovePanel(): Event<MovePanelEvent> {
return this.component.onDidMovePanel;
}

/**
* Invoked when a floating group is repositioned.
*/
get onDidRepositionFloatingGroup(): Event<DockviewGroupPanel> {
return this.component.onDidRepositionFloatingGroup;
}

/**
* Invoked after a layout is deserialzied using the `fromJSON` method.
*/
Expand Down
11 changes: 9 additions & 2 deletions packages/dockview-core/src/dockview/dockviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export interface IDockviewComponent extends IBaseGrid<DockviewGroupPanel> {
readonly onDidActiveGroupChange: Event<DockviewGroupPanel | undefined>;
readonly onUnhandledDragOverEvent: Event<DockviewDndOverlayEvent>;
readonly onDidMovePanel: Event<MovePanelEvent>;
readonly onDidRepositionFloatingGroup: Event<DockviewGroupPanel>;
readonly options: DockviewComponentOptions;
updateOptions(options: DockviewOptions): void;
moveGroupOrPanel(options: MoveGroupOrPanelOptions): void;
Expand Down Expand Up @@ -298,6 +299,11 @@ export class DockviewComponent
readonly onDidActiveGroupChange: Event<DockviewGroupPanel | undefined> =
this._onDidActiveGroupChange.event;

private readonly _onDidRepositionFloatingGroup =
new Emitter<DockviewGroupPanel>();
readonly onDidRepositionFloatingGroup: Event<DockviewGroupPanel> =
this._onDidRepositionFloatingGroup.event;

get orientation(): Orientation {
return this.gridview.orientation;
}
Expand Down Expand Up @@ -407,7 +413,8 @@ export class DockviewComponent
this.onDidAddGroup,
this.onDidRemove,
this.onDidMovePanel,
this.onDidActivePanelChange
this.onDidActivePanelChange,
this.onDidRepositionFloatingGroup
)(() => {
this._bufferOnDidLayoutChange.fire();
}),
Expand Down Expand Up @@ -964,7 +971,7 @@ export class DockviewComponent
group.layout(group.width, group.height);
}),
overlay.onDidChangeEnd(() => {
this._bufferOnDidLayoutChange.fire();
this._onDidRepositionFloatingGroup.fire(group);
}),
group.onDidChange((event) => {
overlay.setBounds({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ const DockviewDemo = (props: { theme?: string }) => {
addLogLine(`Group Added ${event.id}`);
});

event.api.onDidRepositionFloatingGroup((event) => {
addLogLine(`Floating Group repositioned ${event.id}`);
});

event.api.onDidMovePanel((event) => {
addLogLine(`Panel Moved ${event.panel.id}`);
});
Expand Down