diff options
author | Tom Schindl | 2016-09-16 09:49:25 +0000 |
---|---|---|
committer | Tom Schindl | 2016-09-16 09:49:25 +0000 |
commit | 83d5286743720eeba155e8d9e8b2d95bb6fa7dfa (patch) | |
tree | c053870f493008ab7e6003a9c1fe162ea5498fe1 | |
parent | 95d02d23bf0f5d95324fecad0bc9ba981a7fb5a5 (diff) | |
download | org.eclipse.efxclipse-83d5286743720eeba155e8d9e8b2d95bb6fa7dfa.tar.gz org.eclipse.efxclipse-83d5286743720eeba155e8d9e8b2d95bb6fa7dfa.tar.xz org.eclipse.efxclipse-83d5286743720eeba155e8d9e8b2d95bb6fa7dfa.zip |
refs #9
- remembers zoom factor
- applies zoom on all editors
Change-Id: Iea37e8c4c13f11eef098a23d322877bbd29ab4c9
2 files changed, 14 insertions, 2 deletions
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java index 41779b290..c0026c295 100644 --- a/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java +++ b/bundles/code/org.eclipse.fx.code.editor.fx/src/org/eclipse/fx/code/editor/fx/TextEditor.java @@ -132,6 +132,13 @@ public class TextEditor { } } + @Inject + public void setZoomFactor(@Preference(nodePath=Constants.PREFERENCE_NODE_PATH, key=Constants.PREFERENCE_ZOOMFACTOR, defaultValue="1.0") double zoomFactor) { + if( viewer != null ) { + viewer.getTextWidget().setFontZoomFactor(zoomFactor); + } + } + public void setInput(Input<?> input) { if( viewer != null ) { throw new IllegalArgumentException("The input has to be set before the editor is initialized"); @@ -154,7 +161,8 @@ public class TextEditor { SourceViewerConfiguration configuration, IDocumentPartitioner partitioner, Input<?> input, - @Optional @ContextValue("activeInput") Property<Input<?>> activeInput) { + @Optional @ContextValue("activeInput") Property<Input<?>> activeInput, + @Preference(nodePath=Constants.PREFERENCE_NODE_PATH, key=Constants.PREFERENCE_ZOOMFACTOR, defaultValue="1.0") Property<Double> zoomFactor) { setContextMenuProvider(contextMenuProvider); setContextInformationPresenter(contextInformationPresenter); setEditingContext(editingContext); @@ -185,6 +193,10 @@ public class TextEditor { if( activeInput != null ) { activeInput.setValue(input); } + viewer.getTextWidget().setFontZoomFactor(zoomFactor.getValue() != null ? zoomFactor.getValue() : 1.0); + viewer.getTextWidget().fontZoomFactorProperty().addListener( (o,ol,ne) -> { + zoomFactor.setValue(ne.doubleValue()); + }); eventBus.subscribe(Constants.TOPIC_SELECT_SOURCE, EventBus.data(this::onSourceSelect)); diff --git a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java index b73806261..9496938fc 100644 --- a/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java +++ b/bundles/code/org.eclipse.fx.code.editor/src/org/eclipse/fx/code/editor/Constants.java @@ -38,5 +38,5 @@ public class Constants { public static final String PREFERENCE_KEY_EDITOR_FEATURE = "editorFeatures"; public static final String PREFERENCE_TAB_ADVANCE = "tabAdvance"; public static final String PREFERENCE_SPACES_FOR_TAB = "spacesForTab"; - + public static final String PREFERENCE_ZOOMFACTOR = "zoomFactor"; } |