Merge remote-tracking branch 'origin/GP-3419_dev747368_ctrl-0_reset_font'

This commit is contained in:
Ryan Kurtz 2023-05-12 06:20:12 -04:00
commit d3301fc221
2 changed files with 22 additions and 0 deletions

View file

@ -51,6 +51,10 @@ public class FontAdjustPlugin extends Plugin {
.onAction(this::decrementFont) .onAction(this::decrementFont)
.buildAndInstall(tool); .buildAndInstall(tool);
new ActionBuilder("Reset Font", "tool")
.keyBinding("ctrl 0")
.onAction(this::resetFontSize)
.buildAndInstall(tool);
} }
private void incrementFont(ActionContext context) { 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)); 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 * Registers a fontId for the font that will be automatically adjusted when
* {@link #adjustFontSize(boolean)} is called. * {@link #adjustFontSize(boolean)} is called.