Add TextColor property to set base text color at runtime#31
Open
andrewtheart wants to merge 1 commit into
Open
Add TextColor property to set base text color at runtime#31andrewtheart wants to merge 1 commit into
andrewtheart wants to merge 1 commit into
Conversation
The internal plumbing (TextControlBoxDesign.TextColor, DesignHelper.TextColorBrush/CreateColorResources, and TextRenderer drawing body text with TextColorBrush) already existed; the only way to change it was to replace the whole Design object. Expose a granular public TextColor property on CoreTextControlBox and the public TextControlBox wrapper that updates the design color, rebuilds the brush and redraws, mirroring the other granular properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a public
TextColorproperty to set the editor's base body-text color at runtime, without replacing the wholeDesignobject.Why
Today the only way to change the text color is to build and assign a whole new
TextControlBoxDesign. All the internal plumbing for a granular setter already exists:TextControlBoxDesign.TextColor(model field) ✔DesignHelper.TextColorBrush+CreateColorResources()(already builds the brush from_Design.TextColor) ✔TextRendereralready draws body text withdesignHelper.TextColorBrush✔The only thing missing was a public property to change it and invalidate. This mirrors the existing granular properties (
ShowLineNumbers,ShowLineHighlighter, etc.).Change
CoreTextControlBox: newTextColorproperty — updates_Design.TextColor, forcesColorResourcesCreated = false(so the brush is rebuilt), flagsNeedsUpdateTextLayout, and redraws. No-ops when the value is unchanged.TextControlBox(public wrapper): forwardsTextColorto the core control, with an XML doc note that syntax-highlighting token colors still take precedence when enabled.Testing
TextControlBox.csproj, Release/x64).TextColorrecolors the body text immediately; with syntax highlighting on, non-token text uses the new color while token colors are unaffected.Extracted from downstream use of TextControlBox as a vendored editor and contributed back.