Skip to content
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

How to manage styles and colors #3

Open
charlesroddie opened this issue Oct 4, 2018 · 3 comments
Open

How to manage styles and colors #3

charlesroddie opened this issue Oct 4, 2018 · 3 comments

Comments

@charlesroddie
Copy link
Owner

charlesroddie commented Oct 4, 2018

Can we discuss the best way to describe styles (colors, italics, fonts, ...) in the Atom type?

Currently:

wpf-math CSharpMath Comment
Char of char * textStyle: string option
FixedChar of c:char * fontId:int
Styled of RowAtom* background: Brush * foreground: Brush Styled of Atom * Style

Color of Atom * colorString: string

Should we have a single Atom case Styled of Atom * Style to give style information?

type Style = System.Drawing.Color option * italic: bool option * bold: bool option * font: string option

Where inner styles take precedence over outer styles, and there is a default style which is the most outer style? Would this work?

@Happypig375
Copy link
Collaborator

Inner styles completely taking over outer ones is a problem. For example, setting text yellow inside bold text would un-bold the text.

@Happypig375
Copy link
Collaborator

I prefer different atoms for different style settings.

@charlesroddie
Copy link
Owner Author

charlesroddie commented Oct 5, 2018

Inner styles completely taking over outer ones is a problem. For example, setting text yellow inside bold text would un-bold the text.

Of course inner colors take precedence over outer colors etc.. So combining styles would go:

type Style =
    {   Color: System.Drawing.Color option
        Italic: bool option
        ... }
    static member Combine (outer:Style) (inner:Style) =
        {   Color = if inner.Color.IsSome then inner.Color else outer.Color
            Italic = if inner.Italic.IsSome then inner.Italic else outer.Italic
            ... }

So a single style atom vs separate color/bold/italic/etc. atoms vs anything inbetween shouldn't prevent correct behaviour here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants