use header width for sql_tables if larger than row width
This commit is contained in:
parent
51c03985e7
commit
8b81428693
3 changed files with 8 additions and 5 deletions
|
|
@ -805,7 +805,9 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R
|
||||||
|
|
||||||
// The rows get padded a little due to header font being larger than row font
|
// The rows get padded a little due to header font being larger than row font
|
||||||
dims.Height = labelDims.Height * (len(obj.SQLTable.Columns) + 1)
|
dims.Height = labelDims.Height * (len(obj.SQLTable.Columns) + 1)
|
||||||
dims.Width = d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth
|
headerWidth := d2target.HeaderPadding + labelDims.Width + d2target.HeaderPadding
|
||||||
|
rowsWidth := d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth
|
||||||
|
dims.Width = go2.Max(headerWidth, rowsWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &dims, nil
|
return &dims, nil
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ func tableHeader(shape d2target.Shape, box *geo.Box, text string, textWidth, tex
|
||||||
if text != "" {
|
if text != "" {
|
||||||
tl := label.InsideMiddleLeft.GetPointOnBox(
|
tl := label.InsideMiddleLeft.GetPointOnBox(
|
||||||
box,
|
box,
|
||||||
20,
|
float64(d2target.HeaderPadding),
|
||||||
textWidth,
|
float64(shape.Width),
|
||||||
textHeight,
|
textHeight,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ package d2target
|
||||||
import "oss.terrastruct.com/d2/d2renderers/d2fonts"
|
import "oss.terrastruct.com/d2/d2renderers/d2fonts"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NamePadding = 10
|
NamePadding = 10
|
||||||
TypePadding = 20
|
TypePadding = 20
|
||||||
|
HeaderPadding = 20
|
||||||
)
|
)
|
||||||
|
|
||||||
type SQLTable struct {
|
type SQLTable struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue