let themes specify macos titlebar buttons offset - fixes #3507

This commit is contained in:
Eugene Pankov 2021-03-02 22:41:17 +01:00
parent b93989d02b
commit e07c5db0a8
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
6 changed files with 22 additions and 1 deletions

View File

@ -88,7 +88,7 @@ export class Window {
bwOptions.frame = true bwOptions.frame = true
} else { } else {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
bwOptions.titleBarStyle = 'hiddenInset' bwOptions.titleBarStyle = 'hidden'
} }
} }

View File

@ -10,4 +10,7 @@ export abstract class Theme {
css: string css: string
terminalBackground: string terminalBackground: string
macOSWindowButtonsInsetX?: number
macOSWindowButtonsInsetY?: number
} }

View File

@ -299,6 +299,10 @@ export class HostAppService {
} }
} }
setTrafficLightInset (x: number, y: number): void {
this.getWindow().setTrafficLightPosition({ x, y })
}
relaunch (): void { relaunch (): void {
if (this.isPortable) { if (this.isPortable) {
this.electron.app.relaunch({ execPath: process.env.PORTABLE_EXECUTABLE_FILE }) this.electron.app.relaunch({ execPath: process.env.PORTABLE_EXECUTABLE_FILE })

View File

@ -1,6 +1,7 @@
import { Inject, Injectable } from '@angular/core' import { Inject, Injectable } from '@angular/core'
import { ConfigService } from '../services/config.service' import { ConfigService } from '../services/config.service'
import { Theme } from '../api/theme' import { Theme } from '../api/theme'
import { HostAppService, Platform } from './hostApp.service'
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ThemesService { export class ThemesService {
@ -9,6 +10,7 @@ export class ThemesService {
/** @hidden */ /** @hidden */
private constructor ( private constructor (
private config: ConfigService, private config: ConfigService,
private hostApp: HostAppService,
@Inject(Theme) private themes: Theme[], @Inject(Theme) private themes: Theme[],
) { ) {
this.applyCurrentTheme() this.applyCurrentTheme()
@ -33,6 +35,12 @@ export class ThemesService {
} }
this.styleElement.textContent = theme.css this.styleElement.textContent = theme.css
document.querySelector('style#custom-css')!.innerHTML = this.config.store.appearance.css document.querySelector('style#custom-css')!.innerHTML = this.config.store.appearance.css
if (this.hostApp.platform === Platform.macOS) {
this.hostApp.setTrafficLightInset(
theme.macOSWindowButtonsInsetX ?? 14,
theme.macOSWindowButtonsInsetY ?? 22,
)
}
} }
private applyCurrentTheme (): void { private applyCurrentTheme (): void {

View File

@ -16,6 +16,10 @@ app-root {
height: 14px; height: 14px;
} }
} }
.inset {
width: 70 !important;
}
} }
terminaltab .content { terminaltab .content {

View File

@ -15,6 +15,8 @@ export class StandardCompactTheme extends Theme {
name = 'Compact' name = 'Compact'
css = require('./theme.compact.scss') css = require('./theme.compact.scss')
terminalBackground = '#222a33' terminalBackground = '#222a33'
macOSWindowButtonsInsetX = 8
macOSWindowButtonsInsetY = 12
} }
/** @hidden */ /** @hidden */