提交 8ffed7ef 编写于 作者: B Benjamin Pasero

title - fix quick open positioning

上级 152cccfe
......@@ -108,6 +108,10 @@ export class QuickOpenWidget implements IModelProvider {
this.model = null;
}
public getElement(): Builder {
return $(this.builder);
}
public getModel(): IModel<any> {
return this.model;
}
......
......@@ -217,6 +217,12 @@ export class TestMessageService implements IMessageService {
export class TestPartService implements IPartService {
public _serviceBrand: any;
private _onTitleBarVisibilityChange = new Emitter<void>();
public get onTitleBarVisibilityChange(): Event<void> {
return this._onTitleBarVisibilityChange.event;
}
public layout(): void { }
public isCreated(): boolean {
......@@ -243,6 +249,10 @@ export class TestPartService implements IPartService {
return false;
}
public getTitleBarOffset(): number {
return 0;
}
public isStatusBarHidden(): boolean {
return false;
}
......
......@@ -8,6 +8,7 @@
import 'vs/css!./media/quickopen';
import { TPromise, ValueCallback } from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import * as browser from 'vs/base/browser/browser';
import { Dimension, withElementById } from 'vs/base/browser/builder';
import strings = require('vs/base/common/strings');
import filters = require('vs/base/common/filters');
......@@ -126,7 +127,9 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
}
private registerListeners(): void {
this.configurationService.onDidUpdateConfiguration(e => this.updateConfiguration(e.config));
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.updateConfiguration(e.config)));
this.toUnbind.push(this.partService.onTitleBarVisibilityChange(() => this.positionQuickOpenWidget()));
this.toUnbind.push(browser.onDidChangeZoomLevel(() => this.positionQuickOpenWidget()));
}
private updateConfiguration(settings: IWorkbenchQuickOpenConfiguration): void {
......@@ -279,6 +282,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
const pickOpenContainer = this.pickOpenWidget.create();
DOM.addClass(pickOpenContainer, 'show-file-icons');
this.positionQuickOpenWidget();
}
// Update otherwise
......@@ -512,6 +516,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
const quickOpenContainer = this.quickOpenWidget.create();
DOM.addClass(quickOpenContainer, 'show-file-icons');
this.positionQuickOpenWidget();
}
// Layout
......@@ -549,6 +554,18 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
return promiseCompletedOnHide;
}
private positionQuickOpenWidget(): void {
let titlebarOffset = this.partService.getTitleBarOffset();
if (this.quickOpenWidget) {
this.quickOpenWidget.getElement().style('top', `${titlebarOffset}px`);
}
if (this.pickOpenWidget) {
this.pickOpenWidget.getElement().style('top', `${titlebarOffset}px`);
}
}
private handleOnShow(isPicker: boolean): void {
if (isPicker && this.quickOpenWidget) {
this.quickOpenWidget.hide(HideReason.FOCUS_LOST);
......
......@@ -31,14 +31,6 @@
zoom: 1; /* prevent zooming */
}
.titlebar-style-custom .monaco-workbench.fullscreen .quick-open-widget {
top: 0;
}
.titlebar-style-custom .monaco-workbench .quick-open-widget {
top: 22px; /* push down quick open when we have a custom title bar */
}
/* Theming */
.vs .monaco-workbench > .part.titlebar {
......
......@@ -10,6 +10,7 @@ import 'vs/css!./media/workbench';
import { TPromise, ValueCallback } from 'vs/base/common/winjs.base';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import strings = require('vs/base/common/strings');
import Event, { Emitter } from 'vs/base/common/event';
import DOM = require('vs/base/browser/dom');
import { Builder, $ } from 'vs/base/browser/builder';
import { Delayer } from 'vs/base/common/async';
......@@ -120,6 +121,8 @@ export class Workbench implements IPartService {
private static sidebarPositionConfigurationKey = 'workbench.sideBar.location';
private static statusbarVisibleConfigurationKey = 'workbench.statusBar.visible';
private _onTitleBarVisibilityChange: Emitter<void>;
public _serviceBrand: any;
private parent: HTMLElement;
......@@ -187,11 +190,17 @@ export class Workbench implements IPartService {
this.toShutdown = [];
this.editorBackgroundDelayer = new Delayer<void>(50);
this._onTitleBarVisibilityChange = new Emitter<void>();
this.creationPromise = new TPromise<boolean>(c => {
this.creationPromiseComplete = c;
});
}
public get onTitleBarVisibilityChange(): Event<void> {
return this._onTitleBarVisibilityChange.event;
}
/**
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started
* once. Use the shutdown function to free up resources created by the workbench on startup.
......@@ -546,6 +555,15 @@ export class Workbench implements IPartService {
return !this.getCustomTitleBarStyle() || browser.isFullscreen();
}
public getTitleBarOffset(): number {
let offset = 0;
if (!this.isTitleBarHidden()) {
offset = 22 / browser.getZoomFactor(); // adjust the position based on title bar size and zoom factor
}
return offset;
}
private getCustomTitleBarStyle(): string {
if (!isMacintosh) {
return null; // custom title bar is only supported on Mac currently
......@@ -752,12 +770,14 @@ export class Workbench implements IPartService {
this.addClass('fullscreen');
if (hasCustomTitle) {
this._onTitleBarVisibilityChange.fire();
this.layout({ forceStyleRecompute: true }); // handle title bar when fullscreen changes
}
} else {
this.removeClass('fullscreen');
if (hasCustomTitle) {
this._onTitleBarVisibilityChange.fire();
this.layout({ forceStyleRecompute: true }); // handle title bar when fullscreen changes
}
}
......
......@@ -211,6 +211,10 @@ export class MessageList {
}
private positionMessageList(animate?: boolean): void {
if (!this.messageListContainer) {
return; // not yet created
}
$(this.messageListContainer).removeClass('transition'); // disable any animations
let position = 0;
......
......@@ -6,6 +6,7 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
export enum Parts {
ACTIVITYBAR_PART,
......@@ -31,6 +32,11 @@ export const IPartService = createDecorator<IPartService>('partService');
export interface IPartService {
_serviceBrand: ServiceIdentifier<any>;
/**
* Emits when the visibility of the title bar changes.
*/
onTitleBarVisibilityChange: Event<void>;
/**
* Asks the part service to layout all parts.
*/
......@@ -66,6 +72,11 @@ export interface IPartService {
*/
isTitleBarHidden(): boolean;
/**
* Number of pixels (adjusted for zooming) that the title bar (if visible) pushes down the workbench contents.
*/
getTitleBarOffset(): number;
/**
* Checks if the statusbar is currently hidden or not
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册