feat: Add OtherItemsProxy TouchBar item (#22270)
* feat: Add OtherItemsProxy touchbar item * review!
This commit is contained in:
parent
8cc0435d9c
commit
1848e3f658
6 changed files with 83 additions and 29 deletions
|
@ -51,13 +51,27 @@ class TouchBar extends EventEmitter {
|
|||
item.child.ordereredItems.forEach(registerItem)
|
||||
}
|
||||
}
|
||||
|
||||
let hasOtherItemsProxy = false
|
||||
items.forEach((item) => {
|
||||
if (!(item instanceof TouchBarItem)) {
|
||||
throw new Error('Each item must be an instance of TouchBarItem')
|
||||
}
|
||||
|
||||
if (item.type === 'other_items_proxy') {
|
||||
if (!hasOtherItemsProxy) {
|
||||
hasOtherItemsProxy = true
|
||||
} else {
|
||||
throw new Error('Must only have one OtherItemsProxy per TouchBar')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// register in separate loop after all items are validated
|
||||
for (const item of items) {
|
||||
this.ordereredItems.push(item)
|
||||
registerItem(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
set escapeItem (item) {
|
||||
|
@ -334,4 +348,11 @@ TouchBar.TouchBarScrubber = class TouchBarScrubber extends TouchBarItem {
|
|||
}
|
||||
}
|
||||
|
||||
TouchBar.TouchBarOtherItemsProxy = class TouchBarOtherItemsProxy extends TouchBarItem {
|
||||
constructor (config) {
|
||||
super()
|
||||
this._addImmutableProperty('type', 'other_items_proxy')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TouchBar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue