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:
Nathan Sobo
2013-02-25 16:26:50 -07:00
committed by probablycorey
parent 892ff0c51f
commit 15d8a6cada
4 changed files with 40 additions and 26 deletions

View File

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

View File

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