提交 540cfbd4 编写于 作者: B Benjamin Pasero

use correct theme

上级 fec6d40d
......@@ -8,7 +8,7 @@
import 'vs/css!./media/part';
import { Dimension, Builder } from 'vs/base/browser/builder';
import { WorkbenchComponent } from 'vs/workbench/common/component';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
export interface IPartOptions {
hasTitle?: boolean;
......@@ -32,9 +32,11 @@ export abstract class Part extends WorkbenchComponent {
super(id, themeService);
}
protected onThemeChange(): void {
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
// only call if our create() method has been called
if (this.parent) {
this.updateStyles(); // only call if our create() method has been called
super.onThemeChange(theme, collector);
}
}
......
......@@ -7,7 +7,7 @@
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import { Scope, Memento } from 'vs/workbench/common/memento';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IThemeService, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
/**
* Base class of any core/ui component in the workbench. Examples include services, extensions, parts, viewlets and quick open.
......@@ -39,6 +39,7 @@ export class WorkbenchComponent extends Disposable implements IWorkbenchComponen
private _toUnbind: IDisposable[];
private id: string;
private componentMemento: Memento;
private theme: ITheme;
constructor(
id: string,
......@@ -49,23 +50,26 @@ export class WorkbenchComponent extends Disposable implements IWorkbenchComponen
this._toUnbind = [];
this.id = id;
this.componentMemento = new Memento(this.id);
this.theme = themeService.getTheme();
// Hook up to theme changes
this.toUnbind.push(this.themeService.onThemeChange(() => this.onThemeChange()));
this.toUnbind.push(this.themeService.onThemeChange((theme, collector) => this.onThemeChange(theme, collector)));
}
protected getColor(id: string): string {
return this.themeService.getTheme().getColor(id).toString();
}
protected onThemeChange(theme: ITheme, collector: ICssStyleCollector): void {
this.theme = theme;
protected onThemeChange(): void {
this.updateStyles();
this.updateStyles(collector);
}
protected updateStyles(): void {
protected updateStyles(collector: ICssStyleCollector): void {
// Subclasses to override
}
protected getColor(id: string): string {
return this.theme.getColor(id).toString();
}
protected get toUnbind() {
return this._toUnbind;
}
......
......@@ -13,21 +13,7 @@ import { IWorkspaceContextService, WorkspaceContextService } from 'vs/platform/w
import { IStorageService } from 'vs/platform/storage/common/storage';
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IDisposable } from 'vs/base/common/lifecycle';
class TestThemeService implements IThemeService {
_serviceBrand: any;
getTheme(): ITheme {
throw new Error('Method not implemented.');
}
onThemeChange(participant: IThemingParticipant): IDisposable {
return { dispose: () => { } };
}
}
import { TestThemeService } from 'vs/workbench/test/workbenchTestServices';
class MyPart extends Part {
......
......@@ -52,6 +52,7 @@ import { RawTextSource, IRawTextSource } from 'vs/editor/common/model/textSource
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IThemeService, ITheme, IThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Color } from "vs/base/common/color";
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, void 0);
......@@ -973,12 +974,28 @@ export class TestWindowsService implements IWindowsService {
}
}
export class TestTheme implements ITheme {
selector: string;
label: string;
type: 'light' | 'dark' | 'hc';
getColor(color: string, useDefault?: boolean): Color {
throw new Error('Method not implemented.');
}
isDefault(color: string): boolean {
throw new Error('Method not implemented.');
}
}
const testTheme = new TestTheme();
export class TestThemeService implements IThemeService {
_serviceBrand: any;
getTheme(): ITheme {
throw new Error('Method not implemented.');
return testTheme;
}
onThemeChange(participant: IThemingParticipant): IDisposable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册