-
Notifications
You must be signed in to change notification settings - Fork 226
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
[feature] Define page background color, line color, text color #225
Comments
I'm currently testing some draft code that will be able to read YAML input like this: X1:
pincount: 4
box:
color: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 12
title:
bgcolor: RD
fontsize: 20 Edit: Any attribute not specified under I guess specifying all this for each connector and cable is not wanted by anyone, but it might be useful to have the option. By grouping these attributes under If #214 is accepted and merged, I also have a draft code for harness options that will be able to read YAML input like this: options:
base:
color: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 16
connector:
bgcolor: RD
cable:
bgcolor: BU
bundle:
bgcolor: GN Edit: Any attribute not specified under These will be used for the whole harness unless overridden for some connectors/cables as described in the upper part of my comment. |
By moving the |
This solves the basic part of wireviz#225 - supporting options to specify - Foreground/border color and text color in addition to bgcolor - Font size is not requested in wireviz#225, but included as well
I suggest we consider accepting something like this refined syntax: options:
bordercolor: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 16
connector:
bgcolor: RD
title:
fontsize: 18
cable:
bgcolor: BU
title:
fontsize: 20
bundle:
bgcolor: GN
connectors:
X1:
pincount: 4
bordercolor: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 12
title:
bgcolor: RD
fontsize: 20 To obtain the above syntax (without the @dataclass
class Look:
"""Colors and font that defines how an element should look like."""
bordercolor: Optional[Color] = None
bgcolor: Optional[Color] = None
fontcolor: Optional[Color] = None
fontname: Optional[PlainText] = None
fontsize: Optional[Points] = None
@dataclass
class NodeLook(Look):
"""How a node look like possibly with a different looking title."""
title: Look = field(default_factory=dict)
@dataclass
class Options(Look):
node: NodeLook = field(default_factory=dict)
connector: NodeLook = field(default_factory=dict)
cable: NodeLook = field(default_factory=dict)
bundle: NodeLook = field(default_factory=dict)
...
@dataclass
class Connector(NodeLook):
... Such inheritance should also be possible to combine with my suggestions in issue #56 (comment). |
I will need some time to think about the best way to structure the data, but I agree that a dataclass could be a good solution. Also, you will be pleased to see that my refactoring effort is already beginning to implement some subclassing, similar to what you propose in #56. |
Yes, I had a quick look into |
I propose I am aware that Without going off-topic too much, I am envisioning a new
Dataclasses are pretty handy, especially when wanting to add some "smart" behavior using |
@formatc1702 wrote above:
If the options:
style:
bordercolor: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 16
wires:
bordercolor: IV
bgcolor: GY
nodes:
title:
color: YE
connectors:
bgcolor: RD
title:
fontsize: 18
cables:
bgcolor: BU
title:
fontsize: 20
bundles:
bgcolor: GN
connectors:
X1:
pincount: 4
style:
bordercolor: WH
bgcolor: BK
fontcolor: IV
fontname: times
fontsize: 12
title:
bgcolor: RD
fontsize: 20
image:
src: imagefile.png
style:
bgcolor: GY
fontcolor: BK
caption: Text in black This way, it becomes easy to define and use style templates and even theme templates for the options.style attribute. It also becomes easier to implement the style dataclasses independently of any inheritance between the dataclasses containing style attributes: @dataclass
class ColorStyle:
"""Colors that defines how a simple element should look like."""
bordercolor: Optional[Color] = None
bgcolor: Optional[Color] = None
@dataclass
class Style(ColorStyle):
"""Colors and font that defines how an element should look like."""
fontcolor: Optional[Color] = None
fontname: Optional[PlainText] = None
fontsize: Optional[Points] = None
@dataclass
class NodeStyle(Style):
"""How a node look like possibly with a different looking title."""
title: Style = field(default_factory=dict)
@dataclass
class DiagramStyle(Style):
"""How a diagram look like possibly with different looking node classes."""
wires: ColorStyle = field(default_factory=dict)
nodes: NodeStyle = field(default_factory=dict)
connectors: NodeStyle = field(default_factory=dict)
cables: NodeStyle = field(default_factory=dict)
bundles: NodeStyle = field(default_factory=dict)
@dataclass
class Options:
color_mode: ColorMode = 'SHORT'
mini_bom_mode: bool = True
style: DiagramStyle = field(default_factory=dict)
@dataclass
class Image:
...
style: Optional[Style] = None
...
@dataclass
class Connector:
...
style: Optional[NodeStyle] = None
...
@dataclass
class Cable:
...
style: Optional[NodeStyle] = None
... |
This is the next step after #219.
Any area that accepts a background color should have the option to set a foreground/text color, e.g. for good contrast against a dark background.
Additionally, the possibility of a "dark theme", with light text and lines on a dark background, would be very appealing.
The text was updated successfully, but these errors were encountered: