提交 cec349d0 编写于 作者: E Eugene Pankov

faster tab switching

上级 c8b40647
......@@ -182,6 +182,10 @@ export class Window {
ipcMain.on('window-set-vibrancy', (_event, enabled) => {
this.setVibrancy(enabled)
})
ipcMain.on('window-set-title', (_event, title) => {
this.window.setTitle(title)
})
}
private destroy () {
......
......@@ -13,8 +13,6 @@ $tabs-height: 36px;
overflow: hidden;
transition: 0.125s ease-out all;
.index {
flex: none;
font-weight: bold;
......
......@@ -50,7 +50,7 @@ export class AppService {
tab.titleChange$.subscribe(title => {
if (tab === this.activeTab) {
this.hostApp.getWindow().setTitle(title)
this.hostApp.setTitle(title)
}
})
return tab
......@@ -75,7 +75,7 @@ export class AppService {
if (this.activeTab) {
this.activeTab.emitFocused()
}
this.hostApp.getWindow().setTitle(this.activeTab.title)
this.hostApp.setTitle(this.activeTab.title)
}
toggleLastTab () {
......
......@@ -151,6 +151,10 @@ export class HostAppService {
}
}
setTitle (title: string) {
this.electron.ipcRenderer.send('window-set-title', title)
}
broadcastConfigChange () {
this.electron.ipcRenderer.send('app:config-change')
}
......
......@@ -10,6 +10,7 @@ import { IToolbarButton, ToolbarButtonProvider } from '../api'
export class TouchbarService {
private tabsSegmentedControl: TouchBarSegmentedControl
private tabSegments: SegmentedControlSegment[] = []
private nsImageCache: {[id: string]: Electron.NativeImage} = {}
constructor (
private app: AppService,
......@@ -59,12 +60,18 @@ export class TouchbarService {
private getButton (button: IToolbarButton): Electron.TouchBarButton {
return new this.electron.TouchBar.TouchBarButton({
label: button.touchBarNSImage ? null : this.shortenTitle(button.touchBarTitle || button.title),
icon: button.touchBarNSImage ?
this.electron.nativeImage.createFromNamedImage(button.touchBarNSImage, [0, 0, 1]) : null,
icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : null,
click: () => this.zone.run(() => button.click()),
})
}
private getCachedNSImage (name: string) {
if (!this.nsImageCache[name]) {
this.nsImageCache[name] = this.electron.nativeImage.createFromNamedImage(name, [0, 0, 1])
}
return this.nsImageCache[name]
}
private shortenTitle (title: string): string {
if (title.length > 15) {
title = title.substring(0, 15) + '...'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册