Merge pull request #8910 from electron/touchbar-scrubber
Touchbar NSScrubber
This commit is contained in:
commit
da0d0e7aac
7 changed files with 325 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue