-
Notifications
You must be signed in to change notification settings - Fork 0
/
dggTouchbar.js
78 lines (68 loc) · 2.18 KB
/
dggTouchbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* TouchBar定義(macOS)
**/
"use strict";
const {TouchBar} = require ('electron');
const i18n = require('./i18n');
const config = require('./config');
const common = null;
let touchBar = null;
const slider = null;
class dggTouchbar {
constructor(common) {
this.common = common;
const {TouchBarLabel, TouchBarButton, TouchBarSlider, TouchBarSpacer} = TouchBar;
//TouchBar用部品を用意
const _ = new i18n(config.get('lang'), 'menu');
const TbBtn_JumpBackward = new TouchBarButton({
label: '◀◀',
accessibilityLabel: _.t('JUMP_R'),
backgroundColor: '#444',
click: (event) => this.common.skipBackwardToPlayer(event),
});
const TbBtn_JumpForwardward = new TouchBarButton({
label: '▶▶',
accessibilityLabel: _.t('JUMP_F'),
backgroundColor: '#444',
click: (event) => this.common.skipForwardToPlayer(event),
});
const TbBtn_PlayPasue = new TouchBarButton({
label: '▶/II',
accessibilityLabel: _.t('PLAY-PAUSE'),
backgroundColor: '#444',
click: (event) => this.common.playPauseToPlayer(event),
});
const TBSlider_ChangePosition = new TouchBarSlider({
accessibilityLabel: _.t('PLAYBACK_SLIDER'),
backgroundColor: '#444',
minValue: 0,
maxValue: 100,
value: 0,
change: (event) => this.common.changePositionFromSlider(event)
});
this.slider = TBSlider_ChangePosition;
this.touchBar = new TouchBar({
items: [
TbBtn_JumpBackward,
TbBtn_PlayPasue,
TbBtn_JumpForwardward,
TBSlider_ChangePosition,
]
});
}
//クラスの中のtouchBar定義を返す
getTouchBar () {
return this.touchBar;
}
setCommon(cmn) {
this.common = cmn;
}
/**
* ノブ位置を再生位置に同期
* @param {Number} pos(0-100)
*/
updateKnobPosition(pos) {
this.slider.value = Math.floor(pos);
}
}
module.exports = new dggTouchbar();