mirror of
https://github.com/atom/atom.git
synced 2026-02-16 09:35:54 -05:00
replace OSX window title bar with custom title-bar
This commit is contained in:
@@ -31,6 +31,7 @@ ContextMenuManager = require './context-menu-manager'
|
||||
CommandInstaller = require './command-installer'
|
||||
Clipboard = require './clipboard'
|
||||
Project = require './project'
|
||||
TitleBar = require './title-bar'
|
||||
Workspace = require './workspace'
|
||||
PanelContainer = require './panel-container'
|
||||
Panel = require './panel'
|
||||
@@ -44,6 +45,7 @@ Gutter = require './gutter'
|
||||
TextEditorRegistry = require './text-editor-registry'
|
||||
AutoUpdateManager = require './auto-update-manager'
|
||||
|
||||
TitleBarElement = require './title-bar-element'
|
||||
WorkspaceElement = require './workspace-element'
|
||||
PanelContainerElement = require './panel-container-element'
|
||||
PanelElement = require './panel-element'
|
||||
@@ -193,6 +195,8 @@ class AtomEnvironment extends Model
|
||||
@config, @project, packageManager: @packages, grammarRegistry: @grammars, deserializerManager: @deserializers,
|
||||
notificationManager: @notifications, @applicationDelegate, @clipboard, viewRegistry: @views, assert: @assert.bind(this)
|
||||
})
|
||||
|
||||
@titleBar = new TitleBar() if process.platform is 'darwin'
|
||||
@themes.workspace = @workspace
|
||||
|
||||
@textEditors = new TextEditorRegistry
|
||||
@@ -259,6 +263,8 @@ class AtomEnvironment extends Model
|
||||
registerDefaultCommands({commandRegistry: @commands, @config, @commandInstaller, notificationManager: @notifications, @project, @clipboard})
|
||||
|
||||
registerDefaultViewProviders: ->
|
||||
@views.addViewProvider TitleBar, (model, env) ->
|
||||
new TitleBarElement().initialize(model, env)
|
||||
@views.addViewProvider Workspace, (model, env) ->
|
||||
new WorkspaceElement().initialize(model, env)
|
||||
@views.addViewProvider PanelContainer, (model, env) ->
|
||||
@@ -678,6 +684,7 @@ class AtomEnvironment extends Model
|
||||
@deserialize(state) if state?
|
||||
@deserializeTimings.atom = Date.now() - startTime
|
||||
|
||||
@document.body.appendChild(@views.getView(@titleBar)) if @titleBar
|
||||
@document.body.appendChild(@views.getView(@workspace))
|
||||
@backgroundStylesheet?.remove()
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ class AtomWindow
|
||||
options =
|
||||
show: false
|
||||
title: 'Atom'
|
||||
titleBarStyle: 'hidden'
|
||||
# Add an opaque backgroundColor (instead of keeping the default
|
||||
# transparent one) to prevent subpixel anti-aliasing from being disabled.
|
||||
# We believe this is a regression introduced with Electron 0.37.3, and
|
||||
|
||||
30
src/title-bar-element.coffee
Normal file
30
src/title-bar-element.coffee
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
module.exports =
|
||||
class TitleBarElement extends HTMLElement
|
||||
initialize: (@model, {@views, @workspace, @project, @config, @styles}) ->
|
||||
|
||||
@classList.add('title-bar')
|
||||
|
||||
@titleElement = document.createElement('div')
|
||||
@titleElement.classList.add('title')
|
||||
@titleElement.textContent = document.title
|
||||
@appendChild @titleElement
|
||||
|
||||
@activeItemSubscription = atom.workspace.onDidChangeActivePaneItem (activeItem) =>
|
||||
@subscribeToActiveTextEditor()
|
||||
|
||||
return this
|
||||
|
||||
subscribeToActiveTextEditor: ->
|
||||
@cursorSubscription?.dispose()
|
||||
@cursorSubscription = @getActiveTextEditor()?.onDidChangeTitle =>
|
||||
@updateTitle()
|
||||
@updateTitle()
|
||||
|
||||
updateTitle: ->
|
||||
@titleElement.textContent = document.title
|
||||
|
||||
getActiveTextEditor: ->
|
||||
atom.workspace.getActiveTextEditor()
|
||||
|
||||
module.exports = TitleBarElement = document.registerElement 'atom-title-bar', prototype: TitleBarElement.prototype
|
||||
6
src/title-bar.coffee
Normal file
6
src/title-bar.coffee
Normal file
@@ -0,0 +1,6 @@
|
||||
Model = require './model'
|
||||
|
||||
module.exports =
|
||||
class TitleBar extends Model
|
||||
constructor: (params) ->
|
||||
super
|
||||
Reference in New Issue
Block a user