mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Simplify pane:active-item-changed events
Panes now trigger an event every time their active item changes, regardless of whether the pane itself is active. Panes also trigger events when the become active and when they are removed. The rootView now scopes its active-item-changed event listener only to active panes, and also listens to listens to pane activation and removal events to update the title when switching active panes and removing the last pane.
This commit is contained in:
committed by
probablycorey
parent
892ff0c51f
commit
15d8a6cada
@@ -40,7 +40,7 @@ class Pane extends View
|
||||
pane.makeInactive()
|
||||
wasActive = @isActive()
|
||||
@addClass('active')
|
||||
@trigger 'pane:active-item-changed', [@currentItem] unless wasActive
|
||||
@trigger 'pane:became-active' unless wasActive
|
||||
|
||||
makeInactive: ->
|
||||
@removeClass('active')
|
||||
@@ -80,7 +80,7 @@ class Pane extends View
|
||||
@currentItem = item
|
||||
@currentView = view
|
||||
@currentView.show()
|
||||
@trigger 'pane:active-item-changed', [item] if @isActive()
|
||||
@trigger 'pane:active-item-changed', [item]
|
||||
|
||||
addItem: (item) ->
|
||||
return if _.include(@items, item)
|
||||
@@ -187,7 +187,7 @@ class Pane extends View
|
||||
sibling = parentAxis.children().detach()
|
||||
parentAxis.replaceWith(sibling)
|
||||
container.adjustPaneDimensions()
|
||||
container.trigger 'pane:active-item-changed', [null] unless container.getActivePaneItem()
|
||||
container.trigger 'pane:removed', [this]
|
||||
|
||||
afterRemove: ->
|
||||
item.destroy?() for item in @getItems()
|
||||
|
||||
@@ -40,7 +40,9 @@ class RootView extends View
|
||||
@handleFocus(e) if document.activeElement is document.body
|
||||
|
||||
project.on 'path-changed', => @updateTitle()
|
||||
@on 'pane:active-item-changed', => @updateTitle()
|
||||
@on 'pane:became-active', => @updateTitle()
|
||||
@on 'pane:active-item-changed', '.active.pane', => @updateTitle()
|
||||
@on 'pane:removed', => @updateTitle() unless @getActivePane()
|
||||
|
||||
@command 'window:increase-font-size', =>
|
||||
config.set("editor.fontSize", config.get("editor.fontSize") + 1)
|
||||
|
||||
Reference in New Issue
Block a user