Merge pull request #8910 from electron/touchbar-scrubber

Touchbar NSScrubber
This commit is contained in:
Kevin Sawicki 2017-03-16 09:10:59 -07:00 committed by GitHub
commit da0d0e7aac
7 changed files with 325 additions and 15 deletions

View file

@ -231,4 +231,32 @@ TouchBar.TouchBarSegmentedControl = class TouchBarSegmentedControl extends Touch
}
}
TouchBar.TouchBarScrubber = class TouchBarScrubber extends TouchBarItem {
constructor (config) {
super()
if (config == null) config = {}
const {items, selectedStyle, overlayStyle, showArrowButtons, continuous, mode} = config
let {select, highlight} = config
this.type = 'scrubber'
this._addLiveProperty('items', items)
this._addLiveProperty('selectedStyle', selectedStyle || null)
this._addLiveProperty('overlayStyle', overlayStyle || null)
this._addLiveProperty('showArrowButtons', showArrowButtons || false)
this._addLiveProperty('mode', mode || 'free')
this._addLiveProperty('continuous', continuous || true)
if (typeof select === 'function' || typeof highlight === 'function') {
if (select == null) select = () => {}
if (highlight == null) highlight = () => {}
this.onInteraction = (details) => {
if (details.type === 'select') {
select(details.selectedIndex)
} else if (details.type === 'highlight') {
highlight(details.highlightedIndex)
}
}
}
}
}
module.exports = TouchBar