GP-3419 add ctrl-0 key binding to reset font size

This commit is contained in:
dev747368 2023-05-10 16:45:44 +00:00
parent babc38dacc
commit ec54bd4e73
2 changed files with 22 additions and 0 deletions

View file

@ -51,6 +51,10 @@ public class FontAdjustPlugin extends Plugin {
.onAction(this::decrementFont)
.buildAndInstall(tool);
new ActionBuilder("Reset Font", "tool")
.keyBinding("ctrl 0")
.onAction(this::resetFontSize)
.buildAndInstall(tool);
}
private void incrementFont(ActionContext context) {
@ -67,4 +71,10 @@ public class FontAdjustPlugin extends Plugin {
}
}
private void resetFontSize(ActionContext context) {
ComponentProvider provider = context.getComponentProvider();
if (provider != null) {
provider.resetFontSize();
}
}
}

View file

@ -827,6 +827,18 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
ThemeManager.getInstance().setFont(registeredFontId, font.deriveFont((float) size));
}
/**
* Tells the provider to reset the font size for this provider.
* <p>
* See {@link #adjustFontSize(boolean)}
*/
public void resetFontSize() {
if (registeredFontId == null) {
return;
}
ThemeManager.getInstance().restoreFont(registeredFontId);
}
/**
* Registers a fontId for the font that will be automatically adjusted when
* {@link #adjustFontSize(boolean)} is called.