Add an image_size attribute to both Connectors and Cables
It is a list containing minimum width and minimum height of the image cell. To obtain more available space in the image cell, this size must be set greater than the natural size of the image.
This commit is contained in:
parent
3dc2a55f81
commit
41b3f3acfe
@ -20,6 +20,7 @@ class Connector:
|
|||||||
pincount: Optional[int] = None
|
pincount: Optional[int] = None
|
||||||
image: Optional[str] = None
|
image: Optional[str] = None
|
||||||
image_scale: Optional[str] = "FALSE"
|
image_scale: Optional[str] = "FALSE"
|
||||||
|
image_size: List[Any] = field(default_factory=list)
|
||||||
caption: Optional[str] = None
|
caption: Optional[str] = None
|
||||||
notes: Optional[str] = None
|
notes: Optional[str] = None
|
||||||
pinlabels: List[Any] = field(default_factory=list)
|
pinlabels: List[Any] = field(default_factory=list)
|
||||||
@ -96,6 +97,7 @@ class Cable:
|
|||||||
shield: bool = False
|
shield: bool = False
|
||||||
image: Optional[str] = None
|
image: Optional[str] = None
|
||||||
image_scale: Optional[str] = "FALSE"
|
image_scale: Optional[str] = "FALSE"
|
||||||
|
image_size: List[Any] = field(default_factory=list)
|
||||||
caption: Optional[str] = None
|
caption: Optional[str] = None
|
||||||
notes: Optional[str] = None
|
notes: Optional[str] = None
|
||||||
colors: List[Any] = field(default_factory=list)
|
colors: List[Any] = field(default_factory=list)
|
||||||
|
|||||||
@ -58,11 +58,22 @@ def nested_html_table(rows):
|
|||||||
def html_image(node):
|
def html_image(node):
|
||||||
if not node.image:
|
if not node.image:
|
||||||
return None
|
return None
|
||||||
return f'''<tdX{' sides="TLR"' if node.caption else ''}><img scale="{node.image_scale}" src="{node.image}"/>'''
|
return f'''<tdX{' sides="TLR"' if node.caption else ''}{html_size_attr(node.image_size)}>''' \
|
||||||
|
f'''<img scale="{node.image_scale}" src="{node.image}"/>'''
|
||||||
|
|
||||||
def html_caption(node):
|
def html_caption(node):
|
||||||
return f'''<tdX{' sides="LRB"' if node.image else ''}>{html_line_breaks(node.caption)}''' if node.caption else None
|
return f'''<tdX{' sides="LRB"' if node.image else ''}>{html_line_breaks(node.caption)}''' if node.caption else None
|
||||||
|
|
||||||
|
def html_size_attr(size):
|
||||||
|
# Return Graphviz HTML attributes to specify minimum size of a TABLE or TD object
|
||||||
|
# size: List of values where only these are used:
|
||||||
|
# - First value is minimum width of object in points, an int value in the range 1-65535. (Default 0 = none)
|
||||||
|
# - Second value is minimum height of the object in points, an int value in the range 1-65535. (Default 0 = none)
|
||||||
|
if not size or not isinstance(size, list):
|
||||||
|
return ''
|
||||||
|
return ((f' width="{size[0]}"' if len(size) > 0 and size[0] else '')
|
||||||
|
+ (f' height="{size[1]}"' if len(size) > 1 and size[1] else ''))
|
||||||
|
|
||||||
|
|
||||||
def expand(yaml_data):
|
def expand(yaml_data):
|
||||||
# yaml_data can be:
|
# yaml_data can be:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user