Skip to content

Commit

Permalink
Merge pull request #63 from epics-containers/allow_labels_on_tables
Browse files Browse the repository at this point in the history
Align the table header to the table when labels are used
  • Loading branch information
evalott100 authored Nov 23, 2023
2 parents 799b31b + 42fbbb3 commit 3e0640a
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 116 deletions.
22 changes: 17 additions & 5 deletions src/pvi/_format/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,18 +417,30 @@ def generate_component_formatters(
c.children
), "Header length does not match number of elements"

header_bounds = component_bounds.copy()
if add_label:
# Scale the headers by the width with the label then
# indent them
original_width = len(c.layout.header) * (
header_bounds.w + self.layout.spacing
)
label_width = self.layout.label_width + self.layout.spacing

scaling_factor = (original_width - label_width) / original_width
header_bounds.w = int(header_bounds.w * scaling_factor)

header_bounds.indent(label_width)

# Create column headers
for column_header in c.layout.header:
yield self.widget_formatter_factory.header_formatter_cls(
component_bounds.copy(), column_header
header_bounds.copy(), column_header
)
component_bounds.x += component_bounds.w + self.layout.spacing
header_bounds.x += header_bounds.w + self.layout.spacing

# Reset x and shift down y
component_bounds.x = bounds.x
# Shift down y
component_bounds.y += self.layout.widget_height + self.layout.spacing

add_label = False # Don't add a row label
row_components = c.children # Create a widget for each row of Group
# Allow given component width for each column, plus spacing
component_bounds = component_bounds.tile(
Expand Down
130 changes: 91 additions & 39 deletions tests/format/output/static_table_BigTable.adl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ display {
object {
x=0
y=0
width=1652
width=1650
height=150
}
clr=14
Expand Down Expand Up @@ -91,7 +91,7 @@ rectangle {
object {
x=0
y=0
width=1652
width=1650
height=26
}
"basic attribute" {
Expand All @@ -102,7 +102,7 @@ text {
object {
x=0
y=0
width=1652
width=1650
height=26
}
"basic attribute" {
Expand All @@ -113,9 +113,9 @@ text {
}
text {
object {
x=4
x=158
y=30
width=408
width=369
height=20
}
"basic attribute" {
Expand All @@ -126,9 +126,9 @@ text {
}
text {
object {
x=416
x=531
y=30
width=408
width=369
height=20
}
"basic attribute" {
Expand All @@ -139,9 +139,9 @@ text {
}
text {
object {
x=828
x=904
y=30
width=408
width=369
height=20
}
"basic attribute" {
Expand All @@ -152,9 +152,9 @@ text {
}
text {
object {
x=1240
x=1277
y=30
width=408
width=369
height=20
}
"basic attribute" {
Expand All @@ -163,9 +163,22 @@ text {
textix="String Column"
align="horiz. centered"
}
text {
object {
x=4
y=54
width=150
height=20
}
"basic attribute" {
clr=14
}
textix="Row 1"
align="horiz. right"
}
byte {
object {
x=198
x=332
y=54
width=20
height=20
Expand All @@ -179,9 +192,9 @@ byte {
}
"text update" {
object {
x=416
x=531
y=54
width=408
width=369
height=20
}
monitor {
Expand All @@ -194,9 +207,9 @@ byte {
}
"text update" {
object {
x=828
x=904
y=54
width=408
width=369
height=20
}
monitor {
Expand All @@ -209,9 +222,9 @@ byte {
}
"text update" {
object {
x=1240
x=1277
y=54
width=408
width=369
height=20
}
monitor {
Expand All @@ -222,9 +235,22 @@ byte {
limits {
}
}
text {
object {
x=4
y=78
width=150
height=20
}
"basic attribute" {
clr=14
}
textix="Row 2"
align="horiz. right"
}
byte {
object {
x=198
x=332
y=78
width=20
height=20
Expand All @@ -238,9 +264,9 @@ byte {
}
"text update" {
object {
x=416
x=531
y=78
width=408
width=369
height=20
}
monitor {
Expand All @@ -253,9 +279,9 @@ byte {
}
"text update" {
object {
x=828
x=904
y=78
width=408
width=369
height=20
}
monitor {
Expand All @@ -268,9 +294,9 @@ byte {
}
"text update" {
object {
x=1240
x=1277
y=78
width=408
width=369
height=20
}
monitor {
Expand All @@ -281,9 +307,22 @@ byte {
limits {
}
}
text {
object {
x=4
y=102
width=150
height=20
}
"basic attribute" {
clr=14
}
textix="Row 3"
align="horiz. right"
}
byte {
object {
x=198
x=332
y=102
width=20
height=20
Expand All @@ -297,9 +336,9 @@ byte {
}
"text update" {
object {
x=416
x=531
y=102
width=408
width=369
height=20
}
monitor {
Expand All @@ -312,9 +351,9 @@ byte {
}
"text update" {
object {
x=828
x=904
y=102
width=408
width=369
height=20
}
monitor {
Expand All @@ -327,9 +366,9 @@ byte {
}
"text update" {
object {
x=1240
x=1277
y=102
width=408
width=369
height=20
}
monitor {
Expand All @@ -340,9 +379,22 @@ byte {
limits {
}
}
text {
object {
x=4
y=126
width=150
height=20
}
"basic attribute" {
clr=14
}
textix="Row 4"
align="horiz. right"
}
byte {
object {
x=198
x=332
y=126
width=20
height=20
Expand All @@ -356,9 +408,9 @@ byte {
}
"text update" {
object {
x=416
x=531
y=126
width=408
width=369
height=20
}
monitor {
Expand All @@ -371,9 +423,9 @@ byte {
}
"text update" {
object {
x=828
x=904
y=126
width=408
width=369
height=20
}
monitor {
Expand All @@ -386,9 +438,9 @@ byte {
}
"text update" {
object {
x=1240
x=1277
y=126
width=408
width=369
height=20
}
monitor {
Expand Down
Loading

0 comments on commit 3e0640a

Please sign in to comment.