Skip to content

Commit 4b50ce4

Browse files
committed
Add icon for toggling pen pressure support
1 parent 9015f1f commit 4b50ce4

File tree

7 files changed

+78
-1
lines changed

7 files changed

+78
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ original file.
192192
* [Help Icon](https://www.iconfinder.com/icons/211675/help_icon) - Made by Ionicons
193193
* [Fullscreen Icon](https://www.iconfinder.com/icons/298714/screen_full_icon) - Made by Github
194194
* [Pencil Icon](https://github.com/twitter/twemoji/blob/8e58ae4/svg/270f.svg)
195+
* [Drawing Tablet Pen Icon](https://www.iconfinder.com/icons/8665767/pen_icon)
195196
* [Checkmark Icon](https://commons.wikimedia.org/wiki/File:Green_check_icon_with_gradient.svg)
196197
* [Fill Icon](https://commons.wikimedia.org/wiki/File:Circle-icons-paintcan.svg)
197198
* [Trash Icon](https://www.iconfinder.com/icons/315225/trash_can_icon) - Made by [Yannick Lung](https://yannicklung.com)

internal/frontend/lobby.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ const soundToggleLabel = document.getElementById("sound-toggle-label");
122122
let sound = localStorage.getItem("sound") !== "false";
123123
updateSoundIcon();
124124

125+
const penToggleLabel = document.getElementById("pen-pressure-toggle-label");
126+
let penPressure = localStorage.getItem("penPressure") !== "false";
127+
updateTogglePenIcon();
128+
125129
const set_dummy_word_hints = () => {
126130
// Dummy wordhint to prevent layout changes.
127131
applyWordHints([{
@@ -388,6 +392,21 @@ function updateSoundIcon() {
388392
}
389393
}
390394

395+
function togglePenPressure() {
396+
penPressure = !penPressure;
397+
localStorage.setItem("penPressure", penPressure.toString());
398+
updateTogglePenIcon();
399+
}
400+
document.getElementById("toggle-pen-pressure-button").addEventListener("click", togglePenPressure);
401+
402+
function updateTogglePenIcon() {
403+
if (penPressure) {
404+
penToggleLabel.src = "{{.RootPath}}/resources/pen.svg?cache_bust={{.CacheBust}}";
405+
} else {
406+
penToggleLabel.src = "{{.RootPath}}/resources/no-pen.svg?cache_bust={{.CacheBust}}";
407+
}
408+
}
409+
391410
//The drawing board has a base size. This base size results in a certain ratio
392411
//that the actual canvas has to be resized accordingly too. This is needed
393412
//since not every client has the same screensize.
@@ -1452,7 +1471,7 @@ function pressureToLineWidth(event) {
14521471
if (event.buttons !== 1 || event.pressure === 0 || event.pointerType === "touch") {
14531472
return 0;
14541473
}
1455-
if (event.pressure === 0.5 || !event.pressure) {
1474+
if (!penPressure || event.pressure === 0.5 || !event.pressure) {
14561475
return localLineWidth;
14571476
}
14581477
return Math.ceil(event.pressure * 32);
Lines changed: 47 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

internal/frontend/templates/lobby.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
<img id="sound-toggle-label" class="header-button-image" />
5151
{{.Translation.Get "toggle-soundeffects"}}
5252
</button>
53+
<button id="toggle-pen-pressure-button"
54+
class="dialog-button menu-item header-button"
55+
alt="{{.Translation.Get "toggle-pen-pressure"}}"
56+
title="{{.Translation.Get "toggle-pen-pressure"}}">
57+
<img id="pen-pressure-toggle-label" class="header-button-image" />
58+
{{.Translation.Get "toggle-pen-pressure"}}
59+
</button>
5360
<button id="name-change-button" class="dialog-button menu-item header-button"
5461
alt="{{.Translation.Get "change-your-name"}}"
5562
title="{{.Translation.Get "change-your-name"}}">

internal/translations/de_DE.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func initGermanTranslation() {
3030

3131
translation.put("round", "Runde")
3232
translation.put("toggle-soundeffects", "Sound ein- / ausschalten")
33+
translation.put("toggle-pen-pressure", "Tablet-Stiftdruck ein- / ausschalten")
3334
translation.put("change-your-name", "Anzeigename")
3435
translation.put("randomize", "Zufälliger Name")
3536
translation.put("apply", "Anwenden")

internal/translations/en_us.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func initEnglishTranslation() Translation {
2828

2929
translation.put("round", "Round")
3030
translation.put("toggle-soundeffects", "Toggle soundeffects")
31+
translation.put("toggle-pen-pressure", "Toggle pen pressure")
3132
translation.put("change-your-name", "Nickname")
3233
translation.put("randomize", "Randomize")
3334
translation.put("apply", "Apply")

0 commit comments

Comments
 (0)