Fix @kvid's suggestions:
- Rename image alignment to position - Rename under to below - Display the above positioned images right above the pins list Fixes #418
This commit is contained in:
parent
00716d0c61
commit
f19fafb638
@ -23,7 +23,7 @@ CableMultiplier = (
|
|||||||
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
|
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
|
||||||
)
|
)
|
||||||
ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both']
|
ImageScale = PlainText # = Literal['false', 'true', 'width', 'height', 'both']
|
||||||
ImageAlignment = PlainText # = Literal['under', 'above', 'left', 'right']
|
ImagePosition = PlainText # = Literal['below', 'above', 'left', 'right']
|
||||||
|
|
||||||
# Type combinations
|
# Type combinations
|
||||||
Pin = Union[int, PlainText] # Pin identifier
|
Pin = Union[int, PlainText] # Pin identifier
|
||||||
@ -87,7 +87,7 @@ class Image:
|
|||||||
height: Optional[int] = None
|
height: Optional[int] = None
|
||||||
fixedsize: Optional[bool] = None
|
fixedsize: Optional[bool] = None
|
||||||
bgcolor: Optional[Color] = None
|
bgcolor: Optional[Color] = None
|
||||||
alignment: Optional[ImageAlignment] = None
|
position: Optional[ImagePosition] = None
|
||||||
# Contents of the text cell <td> just below the image cell:
|
# Contents of the text cell <td> just below the image cell:
|
||||||
caption: Optional[MultilineHypertext] = None
|
caption: Optional[MultilineHypertext] = None
|
||||||
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
|
||||||
|
|||||||
@ -193,7 +193,7 @@ class Harness:
|
|||||||
html = []
|
html = []
|
||||||
|
|
||||||
image_rows = []
|
image_rows = []
|
||||||
if connector.image:
|
if connector.image and connector.image.position != 'above':
|
||||||
image_rows = [[html_image(connector.image)],
|
image_rows = [[html_image(connector.image)],
|
||||||
[html_caption(connector.image)]]
|
[html_caption(connector.image)]]
|
||||||
|
|
||||||
@ -205,17 +205,17 @@ class Harness:
|
|||||||
html_line_breaks(pn_info_string(HEADER_SPN, connector.supplier, connector.spn))],
|
html_line_breaks(pn_info_string(HEADER_SPN, connector.supplier, connector.spn))],
|
||||||
[html_line_breaks(connector.type),
|
[html_line_breaks(connector.type),
|
||||||
html_line_breaks(connector.subtype),
|
html_line_breaks(connector.subtype),
|
||||||
f'{connector.pincount}-pin' if connector.show_pincount else None,
|
f'{connector.pincount}-pin' if connector.show_pincount else None],
|
||||||
|
[html_caption(connector.image) if connector.image and connector.image.position == 'above' else None,
|
||||||
|
html_image(connector.image) if connector.image and connector.image.position == 'above' else None,
|
||||||
translate_color(connector.color, self.options.color_mode) if connector.color else None,
|
translate_color(connector.color, self.options.color_mode) if connector.color else None,
|
||||||
html_colorbar(connector.color)],
|
html_colorbar(connector.color)],
|
||||||
'<!-- connector table -->' if connector.style != 'simple' else None]
|
'<!-- connector table -->' if connector.style != 'simple' else None]
|
||||||
# fmt: on
|
# fmt: on
|
||||||
imagetable=''
|
imagetable=''
|
||||||
if connector.image:
|
if connector.image:
|
||||||
if connector.image.alignment == 'under' or connector.image.alignment is None:
|
if connector.image.position == 'below' or connector.image.position is None:
|
||||||
rows += image_rows
|
rows += image_rows
|
||||||
elif connector.image.alignment == 'above':
|
|
||||||
rows = image_rows + rows
|
|
||||||
else:
|
else:
|
||||||
imagetable = ''.join(nested_html_table(image_rows, html_bgcolor_attr(connector.bgcolor)))
|
imagetable = ''.join(nested_html_table(image_rows, html_bgcolor_attr(connector.bgcolor)))
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ class Harness:
|
|||||||
|
|
||||||
pinhtml.append(" <tr>")
|
pinhtml.append(" <tr>")
|
||||||
|
|
||||||
if firstpin and connector.image and connector.image.alignment == 'left':
|
if firstpin and connector.image and connector.image.position == 'left':
|
||||||
firstpin = False
|
firstpin = False
|
||||||
pinhtml.append(f'<td rowspan="{pincount}">{imagetable}</td>')
|
pinhtml.append(f'<td rowspan="{pincount}">{imagetable}</td>')
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class Harness:
|
|||||||
if connector.ports_right:
|
if connector.ports_right:
|
||||||
pinhtml.append(f' <td port="p{pinindex+1}r">{pinname}</td>')
|
pinhtml.append(f' <td port="p{pinindex+1}r">{pinname}</td>')
|
||||||
|
|
||||||
if firstpin and connector.image and connector.image.alignment == 'right':
|
if firstpin and connector.image and connector.image.position == 'right':
|
||||||
firstpin = False
|
firstpin = False
|
||||||
pinhtml.append(
|
pinhtml.append(
|
||||||
f'<td rowspan="{pincount}">{imagetable}</td>')
|
f'<td rowspan="{pincount}">{imagetable}</td>')
|
||||||
@ -741,3 +741,4 @@ class Harness:
|
|||||||
if not self._bom:
|
if not self._bom:
|
||||||
self._bom = generate_bom(self)
|
self._bom = generate_bom(self)
|
||||||
return self._bom
|
return self._bom
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user