Skip to content

Commit

Permalink
Use items width to compute overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Apr 11, 2018
1 parent b21e8d4 commit 6bf56c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/vs/base/browser/ui/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ export class ToolBar {
return this.actionBar.getContainer();
}

public getItemsWidth(): number {
let itemsWidth = 0;
for (let i = 0; i < this.actionBar.length(); i++) {
itemsWidth += this.actionBar.getWidth(i);
}
return itemsWidth;
}

public setAriaLabel(label: string): void {
this.actionBar.setAriaLabel(label);
}
Expand Down
4 changes: 0 additions & 4 deletions src/vs/workbench/browser/parts/panel/media/panelpart.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
border-left-style: solid;
}

.monaco-workbench > .part.panel > .composite.title > .title-actions {
flex-grow: 0;
}

.monaco-workbench > .part.panel > .title > .title-actions .monaco-action-bar .action-item .action-label {
outline-offset: -2px;
}
Expand Down
7 changes: 1 addition & 6 deletions src/vs/workbench/browser/parts/panel/panelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private blockOpeningPanel: boolean;
private compositeBar: CompositeBar;
private dimension: Dimension;
private toolbarWidth = new Map<string, number>();

constructor(
id: string,
Expand Down Expand Up @@ -258,11 +257,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
if (!activePanel) {
return 0;
}
if (!this.toolbarWidth.has(activePanel.getId())) {
this.toolbarWidth.set(activePanel.getId(), this.toolBar.getContainer().offsetWidth);
}

return this.toolbarWidth.get(activePanel.getId());
return this.toolBar.getItemsWidth();
}
}

Expand Down

2 comments on commit 6bf56c4

@sandy081
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidorn Please check this change. Needed this to have an adaptive filter box in problems view.
See - #22289 (comment)

@isidorn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandy081 the issue with this change is that everytime you call getItemsWidth you call getWidth for every toolbar item which results in relayout each item because the property clientWidth is called.
And this gets called everytime and layoutCompositeBar is called, which is too often.
For performance reasons I recommend that you cache this aggressively.

Please sign in to comment.