Skip to content

Commit e93367e

Browse files
committed
feat(consoletop): distinct metrics panels, fluent right panels, stretch layouts
- Metrics grid: accent-colored titles, visible separators between panels, distinct semi-transparent backgrounds per section (CPU/Memory/Network), bars stretch to fill available width - Right panels: fluent section labels with accent color + thin rule, removed boxy headers, RightPanelBg for depth separation - All bar graphs and sparklines use HorizontalAlignment.Stretch - Left card bars stretch instead of fixed width - Hide system top/bottom panels - Fix ColumnContainer ignoring BackgroundColor alpha (framework bug)
1 parent 135e520 commit e93367e

9 files changed

Lines changed: 173 additions & 297 deletions

File tree

Examples/ConsoleTopExample/Dashboard/DashboardWindow.cs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,39 +130,56 @@ private void BuildTopStatusBar(Window mainWindow)
130130

131131
#region Metrics Grid
132132

133-
private static BarGraphControl BuildMetricsBar(string name, string label, int labelWidth, Color[] gradient, int marginLeft = 1, int marginRight = 0, int marginBottom = 0)
133+
private static BarGraphControl BuildMetricsBar(string name, string label, int labelWidth, Color[] gradient)
134134
{
135135
return new BarGraphBuilder()
136136
.WithName(name).WithLabel(label).WithLabelWidth(labelWidth)
137-
.WithValue(0).WithMaxValue(100).WithBarWidth(UIConstants.MetricsBarWidth)
137+
.WithValue(0).WithMaxValue(100)
138138
.WithUnfilledColor(UIConstants.BarUnfilledColor)
139+
.WithAlignment(HorizontalAlignment.Stretch)
139140
.ShowLabel().ShowValue().WithValueFormat("F1")
140-
.WithMargin(marginLeft, 0, marginRight, marginBottom)
141+
.WithMargin(1, 0, 1, 0)
141142
.WithSmoothGradient(gradient)
142143
.Build();
143144
}
144145

145146
private void BuildMetricsGrid(Window mainWindow)
146147
{
147-
var muted = UIConstants.MutedText.ToMarkup();
148+
var accent = UIConstants.Accent.ToMarkup();
148149
var metricsGrid = Controls.HorizontalGrid()
149150
.WithMargin(0, 0, 0, 0)
150151
.Column(col =>
151-
col.Add(Controls.Markup($"[{muted} bold] CPU[/]").WithMargin(0, 0, 0, 0).Build())
152+
col.Add(Controls.Markup($"[{accent} bold] CPU[/]").WithMargin(0, 0, 0, 0).Build())
152153
.Add(BuildMetricsBar("cpuUserBar", "User", UIConstants.MetricsCpuLabelWidth, UIConstants.GradientHealthy))
153-
.Add(BuildMetricsBar("cpuSystemBar", "Sys", UIConstants.MetricsCpuLabelWidth, UIConstants.SparkCpuSystem))
154-
.Add(BuildMetricsBar("cpuIoWaitBar", "IO", UIConstants.MetricsCpuLabelWidth, UIConstants.GradientIoRead)))
155-
.Column(col => col.Width(1))
154+
.Add(BuildMetricsBar("cpuSystemBar", "System", UIConstants.MetricsCpuLabelWidth, UIConstants.SparkCpuSystem))
155+
.Add(BuildMetricsBar("cpuIoWaitBar", "IOwait", UIConstants.MetricsCpuLabelWidth, UIConstants.GradientIoRead)))
156156
.Column(col =>
157-
col.Add(Controls.Markup($"[{muted} bold] Memory[/]").WithMargin(0, 0, 0, 0).Build())
158-
.Add(BuildMetricsBar("memUsedBar", "Used", UIConstants.MetricsMemLabelWidth, UIConstants.GradientHealthy, marginRight: 1))
159-
.Add(BuildMetricsBar("memCachedBar", "Cache", UIConstants.MetricsMemLabelWidth, UIConstants.SparkMemCached, marginRight: 1))
160-
.Add(BuildMetricsBar("memIoBar", "IO", UIConstants.MetricsMemLabelWidth, UIConstants.GradientIoWrite, marginRight: 1)))
161-
.Column(col => col.Width(1))
157+
{
158+
col.Width(1);
159+
col.Add(new SeparatorControl
160+
{
161+
ForegroundColor = UIConstants.SeparatorColor,
162+
VerticalAlignment = VerticalAlignment.Fill
163+
});
164+
})
165+
.Column(col =>
166+
col.Add(Controls.Markup($"[{accent} bold] Memory[/]").WithMargin(0, 0, 0, 0).Build())
167+
.Add(BuildMetricsBar("memUsedBar", "Used %", UIConstants.MetricsMemLabelWidth, UIConstants.GradientHealthy))
168+
.Add(BuildMetricsBar("memCachedBar", "Cached %", UIConstants.MetricsMemLabelWidth, UIConstants.SparkMemCached))
169+
.Add(BuildMetricsBar("memIoBar", "Disk IO", UIConstants.MetricsMemLabelWidth, UIConstants.GradientIoWrite)))
170+
.Column(col =>
171+
{
172+
col.Width(1);
173+
col.Add(new SeparatorControl
174+
{
175+
ForegroundColor = UIConstants.SeparatorColor,
176+
VerticalAlignment = VerticalAlignment.Fill
177+
});
178+
})
162179
.Column(col =>
163-
col.Add(Controls.Markup($"[{muted} bold] Network[/]").WithMargin(0, 0, 0, 0).Build())
164-
.Add(BuildMetricsBar("netUploadBar", "Up", UIConstants.MetricsNetLabelWidth, UIConstants.GradientNetUpload, marginRight: 1))
165-
.Add(BuildMetricsBar("netDownloadBar", "Down", UIConstants.MetricsNetLabelWidth, UIConstants.GradientNetDownload, marginRight: 1)))
180+
col.Add(Controls.Markup($"[{accent} bold] Network[/]").WithMargin(0, 0, 0, 0).Build())
181+
.Add(BuildMetricsBar("netUploadBar", "Upload", UIConstants.MetricsNetLabelWidth, UIConstants.GradientNetUpload))
182+
.Add(BuildMetricsBar("netDownloadBar", "Download", UIConstants.MetricsNetLabelWidth, UIConstants.GradientNetDownload)))
166183
.WithAlignment(HorizontalAlignment.Stretch)
167184
.Build();
168185

Examples/ConsoleTopExample/Helpers/UIConstants.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ internal static class UIConstants
103103
public static readonly Color CardBg = new(20, 28, 40, 180);
104104

105105
// Metrics grid sub-panel tinted backgrounds (semi-transparent, distinct hues)
106-
public static readonly Color MetricsCpuBg = new(0x0d, 0x20, 0x30, 190); // deep blue-teal tint
107-
public static readonly Color MetricsMemBg = new(0x15, 0x1a, 0x30, 190); // indigo tint
108-
public static readonly Color MetricsNetBg = new(0x0d, 0x25, 0x20, 190); // teal-green tint
106+
public static readonly Color MetricsCpuBg = new(10, 40, 60, 180); // blue-teal tint
107+
public static readonly Color MetricsMemBg = new(30, 20, 55, 180); // indigo/purple tint
108+
public static readonly Color MetricsNetBg = new(10, 45, 35, 180); // teal-green tint
109109

110-
// Right panel background (slightly lighter than base for subtle separation)
111-
public static readonly Color RightPanelBg = new(12, 18, 28, 200);
110+
// Right panel background
111+
public static readonly Color RightPanelBg = new(10, 16, 26, 210);
112112

113113
// Status bars — darkest layer
114114
public static readonly Color HeaderBg = new(0x0a, 0x0e, 0x14);

Examples/ConsoleTopExample/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using SharpConsoleUI.Configuration;
1212
using SharpConsoleUI.Drivers;
1313
using SharpConsoleUI.Helpers;
14-
using SharpConsoleUI.Panel;
1514

1615
namespace ConsoleTopExample;
1716

@@ -27,7 +26,8 @@ static async Task<int> Main(string[] args)
2726
var windowSystem = new ConsoleWindowSystem(
2827
new NetConsoleDriver(RenderMode.Buffer),
2928
options: new ConsoleWindowSystemOptions(
30-
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))));
29+
ShowTopPanel: false,
30+
ShowBottomPanel: false));
3131

3232
windowSystem.PanelStateService.TopStatus =
3333
$"ConsoleTop - System Monitor ({SystemStatsFactory.GetPlatformName()})";

Examples/ConsoleTopExample/Tabs/BaseResponsiveTab.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,22 @@ protected static void AddSectionHeader(ScrollablePanelControl panel, string titl
324324
);
325325
}
326326

327+
protected static void AddFluentSectionLabel(ScrollablePanelControl panel, string title)
328+
{
329+
panel.AddControl(
330+
Controls.Markup()
331+
.AddLine($"[{UIConstants.Accent.ToMarkup()}]{title}[/]")
332+
.WithAlignment(HorizontalAlignment.Left)
333+
.WithMargin(1, 1, 1, 0)
334+
.Build()
335+
);
336+
panel.AddControl(
337+
Controls.RuleBuilder()
338+
.WithColor(UIConstants.SeparatorColor)
339+
.Build()
340+
);
341+
}
342+
327343
#endregion
328344

329345
#region Window Access

0 commit comments

Comments
 (0)