Skip to content

Commit

Permalink
Implement scrolling of tabs in tabbar
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Mar 27, 2022
1 parent ddf4ae5 commit 0b65894
Show file tree
Hide file tree
Showing 3 changed files with 442 additions and 26 deletions.
29 changes: 29 additions & 0 deletions packages/widgets/src/dockpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 @@ -258,6 +261,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 @@ -938,6 +958,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 @@ -1083,6 +1104,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 @@ -1165,6 +1187,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

0 comments on commit 0b65894

Please sign in to comment.