-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
The most absolutely terrible part of the API is the layouting. This is my current idea for making it better:
From this:
def ui(f: Frame, app: App): Unit = {
val verticalChunks = Layout(
direction = Direction.Vertical,
margin = Margin(2, 2),
constraints = Array(Constraint.Percentage(50), Constraint.Percentage(50)),
).split(f.size)
val barchart1 = BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data1")), borders = Borders.ALL)),
data = app.data,
bar_width = 9,
bar_style = Style(fg = Some(Color.Yellow)),
value_style = Style(fg = Some(Color.Black), bg = Some(Color.Yellow))
)
f.render_widget(barchart1, verticalChunks(0))
val horizontalChunks = Layout(
direction = Direction.Horizontal,
constraints = Array(Constraint.Percentage(50), Constraint.Percentage(50))
).split(verticalChunks(1))
val barchart2 = BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data2")), borders = Borders.ALL)),
bar_width = 5,
bar_gap = 3,
bar_style = Style(fg = Some(Color.Green)),
value_style = Style(bg = Some(Color.Green), add_modifier = Modifier.BOLD),
data = app.data
)
f.render_widget(barchart2, horizontalChunks(0))
val barchart3 = BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data3")), borders = Borders.ALL)),
data = app.data,
bar_style = Style(fg = Some(Color.Red)),
bar_width = 7,
bar_gap = 0,
value_style = Style(bg = Some(Color.Red)),
label_style = Style(fg = Some(Color.Cyan), add_modifier = Modifier.ITALIC)
)
f.render_widget(barchart3, horizontalChunks(1))
}
to something this:
def ui(app: App): Widget = {
Layout(direction = Direction.Vertical, margin = Margin(2, 2))(
Constraint.Percentage(50) ->
BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data1")), borders = Borders.ALL)),
data = app.data,
bar_width = 9,
bar_style = Style(fg = Some(Color.Yellow)),
value_style = Style(fg = Some(Color.Black), bg = Some(Color.Yellow))
),
Constraint.Percentage(50) ->
Layout(direction = Direction.Horizontal)(
Constraint.Percentage(50) -> BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data2")), borders = Borders.ALL)),
bar_width = 5,
bar_gap = 3,
bar_style = Style(fg = Some(Color.Green)),
value_style = Style(bg = Some(Color.Green), add_modifier = Modifier.BOLD),
data = app.data
),
Constraint.Percentage(50) -> BarChartWidget(
block = Some(BlockWidget(title = Some(Spans.nostyle("Data3")), borders = Borders.ALL)),
data = app.data,
bar_style = Style(fg = Some(Color.Red)),
bar_width = 7,
bar_gap = 0,
value_style = Style(bg = Some(Color.Red)),
label_style = Style(fg = Some(Color.Cyan), add_modifier = Modifier.ITALIC)
)
)
)
}ckipp01 and dejvid
Metadata
Metadata
Assignees
Labels
No labels