mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Integrate the pane containers into the workspace
This commit is contained in:
@@ -42,6 +42,7 @@ class PanelContainer
|
||||
index = @panels.length
|
||||
@panels.push(panel)
|
||||
@emitter.emit 'did-add-panel', {panel, index}
|
||||
panel
|
||||
|
||||
panelDestoryed: (panel) ->
|
||||
index = @panels.indexOf(panel)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Public:
|
||||
module.exports =
|
||||
class Panel
|
||||
constructor: ({@viewRegistry, @item, @orientation}) ->
|
||||
constructor: ({@viewRegistry, @item}) ->
|
||||
@emitter = new Emitter
|
||||
|
||||
destroy: ->
|
||||
@@ -11,8 +11,6 @@ class Panel
|
||||
|
||||
getView: -> @viewRegistry.getView(@item)
|
||||
|
||||
getOrientation: -> @orientation
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
###
|
||||
|
||||
@@ -65,7 +65,17 @@ class WorkspaceElement extends HTMLElement
|
||||
window.addEventListener 'focus', handleWindowFocus
|
||||
@subscriptions.add(new Disposable -> window.removeEventListener 'focus', handleWindowFocus)
|
||||
|
||||
@subscriptions.add @model.onDidAddPanel(@panelAdded.bind(this))
|
||||
@panelContainers =
|
||||
top: @model.panelContainers.top.getView()
|
||||
left: @model.panelContainers.left.getView()
|
||||
right: @model.panelContainers.right.getView()
|
||||
bottom: @model.panelContainers.bottom.getView()
|
||||
|
||||
@horizontalAxis.insertBefore(@panelContainers.left, @verticalAxis)
|
||||
@horizontalAxis.appendChild(@panelContainers.right)
|
||||
|
||||
@verticalAxis.insertBefore(@panelContainers.top, @paneContainer)
|
||||
@verticalAxis.appendChild(@panelContainers.bottom)
|
||||
|
||||
@__spacePenView.setModel(@model)
|
||||
|
||||
@@ -92,13 +102,6 @@ class WorkspaceElement extends HTMLElement
|
||||
|
||||
focusPaneViewOnRight: -> @paneContainer.focusPaneViewOnRight()
|
||||
|
||||
panelAdded: (panel) ->
|
||||
panelView = @model.getView(panel)
|
||||
|
||||
switch panel.getOrientation()
|
||||
when 'left'
|
||||
@horizontalAxis.insertBefore(panelView, @verticalAxis)
|
||||
|
||||
atom.commands.add 'atom-workspace',
|
||||
'window:increase-font-size': -> @getModel().increaseFontSize()
|
||||
'window:decrease-font-size': -> @getModel().decreaseFontSize()
|
||||
|
||||
@@ -12,6 +12,8 @@ PaneContainer = require './pane-container'
|
||||
Pane = require './pane'
|
||||
Panel = require './panel'
|
||||
PanelElement = require './panel-element'
|
||||
PanelContainer = require './panel-container'
|
||||
PanelContainerElement = require './panel-container-element'
|
||||
ViewRegistry = require './view-registry'
|
||||
WorkspaceElement = require './workspace-element'
|
||||
|
||||
@@ -47,6 +49,12 @@ class Workspace extends Model
|
||||
@paneContainer ?= new PaneContainer({@viewRegistry})
|
||||
@paneContainer.onDidDestroyPaneItem(@onPaneItemDestroyed)
|
||||
|
||||
@panelContainers =
|
||||
top: new PanelContainer({@viewRegistry, orientation: 'top'})
|
||||
left: new PanelContainer({@viewRegistry, orientation: 'left'})
|
||||
right: new PanelContainer({@viewRegistry, orientation: 'right'})
|
||||
bottom: new PanelContainer({@viewRegistry, orientation: 'bottom'})
|
||||
|
||||
@subscribeToActiveItem()
|
||||
|
||||
@addOpener (filePath) =>
|
||||
@@ -64,6 +72,10 @@ class Workspace extends Model
|
||||
modelConstructor: Workspace
|
||||
viewConstructor: WorkspaceElement
|
||||
|
||||
@addViewProvider
|
||||
modelConstructor: PanelContainer
|
||||
viewConstructor: PanelContainerElement
|
||||
|
||||
@addViewProvider
|
||||
modelConstructor: Panel
|
||||
viewConstructor: PanelElement
|
||||
@@ -283,9 +295,6 @@ class Workspace extends Model
|
||||
@onDidAddPaneItem ({item, pane, index}) ->
|
||||
callback({textEditor: item, pane, index}) if item instanceof TextEditor
|
||||
|
||||
onDidAddPanel: (callback) ->
|
||||
@emitter.on 'did-add-panel', callback
|
||||
|
||||
eachEditor: (callback) ->
|
||||
deprecate("Use Workspace::observeTextEditors instead")
|
||||
|
||||
@@ -673,7 +682,19 @@ class Workspace extends Model
|
||||
Section: Panels
|
||||
###
|
||||
|
||||
addTopPanel: (options) ->
|
||||
@addPanel('top', options)
|
||||
|
||||
addBottomPanel: (options) ->
|
||||
@addPanel('bottom', options)
|
||||
|
||||
addLeftPanel: (options) ->
|
||||
panel = new Panel(_.extend(options, {@viewRegistry, orientation: 'left'}))
|
||||
@emitter.emit('did-add-panel', panel)
|
||||
panel
|
||||
@addPanel('left', options)
|
||||
|
||||
addRightPanel: (options) ->
|
||||
@addPanel('right', options)
|
||||
|
||||
addPanel: (orientation, options) ->
|
||||
options ?= {}
|
||||
options.viewRegistry = @viewRegistry
|
||||
@panelContainers[orientation].addPanel(new Panel(options))
|
||||
|
||||
Reference in New Issue
Block a user