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

Implement tab scrolling on tabbar #297

Open
wants to merge 8 commits into
base: main
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
29 changes: 29 additions & 0 deletions packages/widgets/src/dockpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export class DockPanel extends Widget {
if (options.addButtonEnabled !== undefined) {
this._addButtonEnabled = options.addButtonEnabled;
}
if (options.tabScrollingEnabled !== undefined) {
this._tabScrollingEnabled = options.tabScrollingEnabled;
}

// Toggle the CSS mode attribute.
this.dataset['mode'] = this._mode;
Expand Down Expand Up @@ -255,6 +258,23 @@ export class DockPanel extends Widget {
});
}

/**
* Whether scrolling of tabs in tab bars is enabled.
*/
get tabScrollingEnabled(): boolean {
return this._tabScrollingEnabled;
}

/**
* Set whether the add buttons for each tab bar are enabled.
*/
set tabScrollingEnabled(value: boolean) {
this._tabScrollingEnabled = value;
each(this.tabBars(), tabbar => {
tabbar.scrollingEnabled = value;
});
}

/**
* Whether the dock panel is empty.
*/
Expand Down Expand Up @@ -914,6 +934,7 @@ export class DockPanel extends Widget {
tabBar.tabsMovable = this._tabsMovable;
tabBar.allowDeselect = false;
tabBar.addButtonEnabled = this._addButtonEnabled;
tabBar.scrollingEnabled = this._tabScrollingEnabled;
tabBar.removeBehavior = 'select-previous-tab';
tabBar.insertBehavior = 'select-tab-if-needed';

Expand Down Expand Up @@ -1054,6 +1075,7 @@ export class DockPanel extends Widget {
private _tabsMovable: boolean = true;
private _tabsConstrained: boolean = false;
private _addButtonEnabled: boolean = false;
private _tabScrollingEnabled: boolean = false;
private _pressData: Private.IPressData | null = null;
private _layoutModified = new Signal<this, void>(this);

Expand Down Expand Up @@ -1136,6 +1158,13 @@ export namespace DockPanel {
* The default is `'false'`.
*/
addButtonEnabled?: boolean;

/**
* Enable scrolling in each of the dock panel's tab bars.
*
* The default is `'false'`.
*/
tabScrollingEnabled?: boolean;
}

/**
Expand Down
Loading