提交 f2622481 编写于 作者: I isidor

CompositeBar: fix overflow math

上级 33eb2e76
......@@ -75,7 +75,8 @@ export class ActivitybarPart extends Part {
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(ToggleViewletAction, this.viewletService.getViewlet(compositeId)),
getDefaultCompositeId: () => this.viewletService.getDefaultViewletId(),
hidePart: () => this.partService.setSideBarHidden(true),
colors: ActivitybarPart.COLORS
colors: ActivitybarPart.COLORS,
overflowActionSize: 50
});
this.registerListeners();
}
......
......@@ -26,6 +26,7 @@ export interface ICompositeBarOptions {
orientation: ActionsOrientation;
composites: { id: string, name: string }[];
colors: ICompositeBarColors;
overflowActionSize: number;
getActivityAction: (compositeId: string) => ActivityAction;
getCompositePinnedAction: (compositeId: string) => Action;
getOnCompositeClickAction: (compositeId: string) => Action;
......@@ -36,7 +37,6 @@ export interface ICompositeBarOptions {
export class CompositeBar implements ICompositeBar {
private static OVERFLOW_ACTION_SIZE = 50;
private _onDidContextMenu: Emitter<MouseEvent>;
private dimension: Dimension;
......@@ -220,9 +220,12 @@ export class CompositeBar implements ICompositeBar {
}
overflows = compositesToShow.length > maxVisible;
compositesToShow = compositesToShow.slice(0, maxVisible);
// Check if we need to make room for the overflow action
if (overflows && (size + CompositeBar.OVERFLOW_ACTION_SIZE - this.compositeSizeInBar.get(compositesToShow[maxVisible - 1]) - this.compositeSizeInBar.get(compositesToShow[maxVisible]) > limit)) {
if (overflows) {
size -= this.compositeSizeInBar.get(compositesToShow[maxVisible]);
compositesToShow = compositesToShow.slice(0, maxVisible);
}
// Check if we need to make extra room for the overflow action
if (overflows && (size + this.options.overflowActionSize > limit)) {
compositesToShow.pop();
}
}
......
......@@ -84,6 +84,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
getOnCompositeClickAction: (compositeId: string) => this.instantiationService.createInstance(OpenPanelAction, this.getPanel(compositeId)),
getDefaultCompositeId: () => Registry.as<PanelRegistry>(PanelExtensions.Panels).getDefaultPanelId(),
hidePart: () => this.partService.setPanelHidden(true),
overflowActionSize: 60,
colors: {
backgroundColor: PANEL_BACKGROUND,
badgeBackground,
......@@ -207,7 +208,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
// Pass to super
const sizes = super.layout(dimension);
let availableWidth = dimension.width;
let availableWidth = dimension.width - 8; // take padding into account
if (this.toolBar) {
// adjust height for global actions showing
availableWidth -= this.toolBar.getContainer().getHTMLElement().offsetWidth;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册