8000 Limit interface scale by AlbyIanna · Pull Request #1502 · arduino/arduino-ide · GitHub
[go: up one dir, main page]

Skip to content

Limit interface scale #1502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update menu actions when autoScaleInterface changes
  • Loading branch information
Alberto Iannaccone committed Oct 6, 2022
commit b118a1f3bbdd445b6cc5362d3974f5052f0847f8
41 changes: 24 additions & 17 deletions arduino-ide-extension/src/browser/contributions/interface-scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class InterfaceScale extends Contribution {
override onStart(): MaybePromise<void> {
const updateCurrent = (settings: Settings) => {
this.currentSettings = settings;
this.updateFontScalingEnabled();
};
this.settingsService.onDidChange((settings) => updateCurrent(settings));
this.settingsService.settings().then((settings) => updateCurrent(settings));
Expand Down Expand Up @@ -120,23 +121,14 @@ export class InterfaceScale extends Contribution {
this.mainMenuManager.update();
}

private updateFontSize(mode: 'increase' | 'decrease'): void {
if (this.currentSettings.autoScaleInterface) {
mode === 'increase'
? (this.currentSettings.interfaceScale += InterfaceScale.ZoomLevel.STEP)
: (this.currentSettings.interfaceScale -=
InterfaceScale.ZoomLevel.STEP);
} else {
mode === 'increase'
? (this.currentSettings.editorFontSize += InterfaceScale.FontSize.STEP)
: (this.currentSettings.editorFontSize -= InterfaceScale.FontSize.STEP);
}
let newFontScalingEnabled: InterfaceScale.FontScalingEnabled = {
private updateFontScalingEnabled(): void {
let fontScalingEnabled = {
increase: true,
decrease: true,
};

if (this.currentSettings.autoScaleInterface) {
newFontScalingEnabled = {
fontScalingEnabled = {
increase:
this.currentSettings.interfaceScale + InterfaceScale.ZoomLevel.STEP <=
InterfaceScale.ZoomLevel.MAX,
Expand All @@ -145,7 +137,7 @@ export class InterfaceScale extends Contribution {
InterfaceScale.ZoomLevel.MIN,
};
} else {
newFontScalingEnabled = {
fontScalingEnabled = {
increase:
this.currentSettings.editorFontSize + InterfaceScale.FontSize.STEP <=
InterfaceScale.FontSize.MAX,
Expand All @@ -154,14 +146,29 @@ export class InterfaceScale extends Contribution {
InterfaceScale.FontSize.MIN,
};
}
const isChanged = Object.keys(newFontScalingEnabled).some(

const isChanged = Object.keys(fontScalingEnabled).some(
(key: keyof InterfaceScale.FontScalingEnabled) =>
newFontScalingEnabled[key] !== this.fontScalingEnabled[key]
fontScalingEnabled[key] !== this.fontScalingEnabled[key]
);
if (isChanged) {
this.fontScalingEnabled = newFontScalingEnabled;
this.fontScalingEnabled = fontScalingEnabled;
this.registerMenus(this.menuRegistry);
}
}

private updateFontSize(mode: 'increase' | 'decrease'): void {
if (this.currentSettings.autoScaleInterface) {
mode === 'increase'
? (this.currentSettings.interfaceScale += InterfaceScale.ZoomLevel.STEP)
: (this.currentSettings.interfaceScale -=
InterfaceScale.ZoomLevel.STEP);
} else {
mode === 'increase'
? (this.currentSettings.editorFontSize += InterfaceScale.FontSize.STEP)
: (this.currentSettings.editorFontSize -= InterfaceScale.FontSize.STEP);
}
this.updateFontScalingEnabled();
this.updateSettingsDebounced();
}

Expand Down
0