1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-24 11:02:47 +03:00

faster tab switching

This commit is contained in:
Eugene Pankov 2018-09-20 11:42:51 +02:00
parent c8b40647a9
commit cec349d021
5 changed files with 19 additions and 6 deletions

View File

@ -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 () {

View File

@ -13,8 +13,6 @@ $tabs-height: 36px;
overflow: hidden;
transition: 0.125s ease-out all;
.index {
flex: none;
font-weight: bold;

View File

@ -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 () {

View File

@ -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')
}

View File

@ -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) + '...'