Skip to content

Commit bb6a143

Browse files
danecreekphotographyd1ylszomoru
authored
105160: Support configuring keyboard overlay timeout + mouse indicator color/size (microsoft#105219)
Co-authored-by: 陈大大哦了 <chenhonzhou@gmail.com> Co-authored-by: Ladislau Szomoru <lszomoru@microsoft.com>
1 parent ae0dbb3 commit bb6a143

2 files changed

Lines changed: 69 additions & 13 deletions

File tree

src/vs/workbench/browser/actions/developerActions.ts

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,37 @@ class ToggleScreencastModeAction extends Action2 {
123123
const onMouseUp = domEvent(container, 'mouseup', true);
124124
const onMouseMove = domEvent(container, 'mousemove', true);
125125

126+
let mouseIndicatorColor: string;
127+
const updateMouseIndicatorColor = () => {
128+
mouseIndicatorColor = configurationService.getValue<string>('screencastMode.mouseIndicatorColor');
129+
130+
let style = new Option().style;
131+
style.color = mouseIndicatorColor;
132+
if (mouseIndicatorColor === '' || !style.color) {
133+
mouseIndicatorColor = 'red';
134+
}
135+
};
136+
137+
let mouseIndicatorSize: number;
138+
const updateMouseIndicatorSize = () => {
139+
mouseIndicatorSize = clamp(configurationService.getValue<number>('screencastMode.mouseIndicatorSize') || 20, 20, 100);
140+
};
141+
142+
updateMouseIndicatorColor();
143+
updateMouseIndicatorSize();
144+
126145
disposables.add(onMouseDown(e => {
127-
mouseMarker.style.top = `${e.clientY - 10}px`;
128-
mouseMarker.style.left = `${e.clientX - 10}px`;
146+
mouseMarker.style.height = `${mouseIndicatorSize}px`;
147+
mouseMarker.style.width = `${mouseIndicatorSize}px`;
148+
mouseMarker.style.borderRadius = '50%';
149+
mouseMarker.style.borderColor = mouseIndicatorColor;
150+
mouseMarker.style.top = `${e.clientY - mouseIndicatorSize / 2}px`;
151+
mouseMarker.style.left = `${e.clientX - mouseIndicatorSize / 2}px`;
129152
mouseMarker.style.display = 'block';
130153

131154
const mouseMoveListener = onMouseMove(e => {
132-
mouseMarker.style.top = `${e.clientY - 10}px`;
133-
mouseMarker.style.left = `${e.clientX - 10}px`;
155+
mouseMarker.style.top = `${e.clientY - mouseIndicatorSize / 2}px`;
156+
mouseMarker.style.left = `${e.clientX - mouseIndicatorSize / 2}px`;
134157
});
135158

136159
Event.once(onMouseUp)(() => {
@@ -150,8 +173,14 @@ class ToggleScreencastModeAction extends Action2 {
150173
keyboardMarker.style.bottom = `${clamp(configurationService.getValue<number>('screencastMode.verticalOffset') || 0, 0, 90)}%`;
151174
};
152175

176+
let keyboardMarkerTimeout: number;
177+
const updateKeyboardMarkerTimeout = () => {
178+
keyboardMarkerTimeout = clamp(configurationService.getValue<number>('screencastMode.keyboardOverlayTimeout') || 800, 500, 5000);
179+
};
180+
153181
updateKeyboardFontSize();
154182
updateKeyboardMarker();
183+
updateKeyboardMarkerTimeout();
155184

156185
disposables.add(configurationService.onDidChangeConfiguration(e => {
157186
if (e.affectsConfiguration('screencastMode.verticalOffset')) {
@@ -161,6 +190,18 @@ class ToggleScreencastModeAction extends Action2 {
161190
if (e.affectsConfiguration('screencastMode.fontSize')) {
162191
updateKeyboardFontSize();
163192
}
193+
194+
if (e.affectsConfiguration('screencastMode.keyboardOverlayTimeout')) {
195+
updateKeyboardMarkerTimeout();
196+
}
197+
198+
if (e.affectsConfiguration('screencastMode.mouseIndicatorColor')) {
199+
updateMouseIndicatorColor();
200+
}
201+
202+
if (e.affectsConfiguration('screencastMode.mouseIndicatorSize')) {
203+
updateMouseIndicatorSize();
204+
}
164205
}));
165206

166207
const onKeyDown = domEvent(window, 'keydown', true);
@@ -190,7 +231,7 @@ class ToggleScreencastModeAction extends Action2 {
190231
append(keyboardMarker, key);
191232
}
192233

193-
const promise = timeout(800);
234+
const promise = timeout(keyboardMarkerTimeout);
194235
keyboardTimeout = toDisposable(() => promise.cancel());
195236

196237
promise.then(() => {
@@ -276,8 +317,27 @@ configurationRegistry.registerConfiguration({
276317
},
277318
'screencastMode.onlyKeyboardShortcuts': {
278319
type: 'boolean',
279-
description: nls.localize('screencastMode.onlyKeyboardShortcuts', "Only show keyboard shortcuts in Screencast Mode."),
320+
description: nls.localize('screencastMode.onlyKeyboardShortcuts', "Only show keyboard shortcuts in screencast mode."),
280321
default: false
281-
}
322+
},
323+
'screencastMode.keyboardOverlayTimeout': {
324+
type: 'number',
325+
default: 800,
326+
minimum: 500,
327+
maximum: 5000,
328+
description: nls.localize('screencastMode.keyboardOverlayTimeout', "Controls how long (in milliseconds) the keyboard overlay is shown in screencast mode.")
329+
},
330+
'screencastMode.mouseIndicatorColor': {
331+
type: 'string',
332+
default: 'red',
333+
description: nls.localize('screencastMode.mouseIndicatorColor', "Controls the color (string or Hex) of the mouse indicator in screencast mode.")
334+
},
335+
'screencastMode.mouseIndicatorSize': {
336+
type: 'number',
337+
default: 20,
338+
minimum: 20,
339+
maximum: 100,
340+
description: nls.localize('screencastMode.mouseIndicatorSize', "Controls the size (in pixels) of the mouse indicator in screencast mode.")
341+
},
282342
}
283343
});

src/vs/workbench/browser/actions/media/actions.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99

1010
.monaco-workbench .screencast-mouse {
1111
position: absolute;
12-
border: 2px solid red;
13-
border-radius: 20px;
14-
width: 20px;
15-
height: 20px;
16-
top: 0;
17-
left: 0;
12+
border-width: 2px;
13+
border-style: solid;
1814
z-index: 100000;
1915
content: ' ';
2016
pointer-events: none;

0 commit comments

Comments
 (0)