Skip to content

Commit d81274b

Browse files
committed
refactor(panel): remove StatusBarOptions/StatusBarStateService, add default panels with visibility control
- Delete StatusBarOptions and StatusBarStateService (replaced by Panel system) - Default top panel (app name + clock) and bottom panel (status text + taskbar) created on init - Add ShowTopPanel/ShowBottomPanel options for init-time visibility control - Consolidate dirty tracking: single source of truth in Panel.IsDirty - Remove render-loop sync; TopStatus/BottomStatus are now convenience setters that update StatusTextElement directly - Update all examples, tests, and schost template
1 parent 3626a85 commit d81274b

28 files changed

Lines changed: 282 additions & 871 deletions

File tree

Examples/AgentStudio/Program.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using SharpConsoleUI.Configuration;
1313
using SharpConsoleUI.Drivers;
1414
using SharpConsoleUI.Helpers;
15+
using SharpConsoleUI.Panel;
1516

1617
namespace AgentStudio;
1718

@@ -32,12 +33,9 @@ static async Task<int> Main(string[] args)
3233
var windowSystem = new ConsoleWindowSystem(
3334
driver,
3435
options: new ConsoleWindowSystemOptions(
35-
StatusBarOptions: new StatusBarOptions(
36-
ShowTaskBar: false,
37-
ShowBottomStatus: false
38-
)
36+
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))
3937
));
40-
windowSystem.StatusBarStateService.TopStatus = "AgentStudio - TUI Showcase";
38+
windowSystem.PanelStateService.TopStatus = "AgentStudio - TUI Showcase";
4139

4240
// Setup graceful shutdown
4341
Console.CancelKeyPress += (sender, e) =>

Examples/CanvasDemo/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using SharpConsoleUI.Helpers;
1919
using SharpConsoleUI.Configuration;
2020
using SharpConsoleUI.Layout;
21+
using SharpConsoleUI.Panel;
2122

2223
namespace CanvasDemo;
2324

@@ -45,9 +46,9 @@ static async Task<int> Main()
4546
var windowSystem = new ConsoleWindowSystem(
4647
RenderMode.Buffer,
4748
options: new ConsoleWindowSystemOptions(
48-
StatusBarOptions: new StatusBarOptions(ShowTaskBar: false)));
49+
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))));
4950

50-
windowSystem.StatusBarStateService.TopStatus =
51+
windowSystem.PanelStateService.TopStatus =
5152
"Canvas Demo — Click inside canvases | Resize windows | Esc: Quit";
5253

5354
Console.CancelKeyPress += (_, e) =>

Examples/ConsoleTopExample/Program.cs

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

1516
namespace ConsoleTopExample;
1617

@@ -26,9 +27,9 @@ static async Task<int> Main(string[] args)
2627
var windowSystem = new ConsoleWindowSystem(
2728
new NetConsoleDriver(RenderMode.Buffer),
2829
options: new ConsoleWindowSystemOptions(
29-
StatusBarOptions: new StatusBarOptions(ShowTaskBar: false)));
30+
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))));
3031

31-
windowSystem.StatusBarStateService.TopStatus =
32+
windowSystem.PanelStateService.TopStatus =
3233
$"ConsoleTop - System Monitor ({SystemStatsFactory.GetPlatformName()})";
3334

3435
Console.CancelKeyPress += (sender, e) =>

Examples/DemoApp/Program.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ static async Task<int> Main(string[] args)
2020
try
2121
{
2222
var options = new ConsoleWindowSystemOptions(
23-
StatusBarOptions: new StatusBarOptions(
24-
ShowStartButton: true,
25-
StartMenu: new StartMenuOptions
26-
{
27-
AppName = "SharpConsoleUI Demo",
28-
SidebarStyle = StartMenuSidebarStyle.IconLabel,
29-
BackgroundGradient = new GradientBackground(
30-
ColorGradient.FromColors(new Color(25, 25, 60), new Color(15, 15, 35)),
31-
GradientDirection.Vertical)
32-
}),
23+
StartMenu: new StartMenuOptions
24+
{
25+
AppName = "SharpConsoleUI Demo",
26+
SidebarStyle = StartMenuSidebarStyle.IconLabel,
27+
BackgroundGradient = new GradientBackground(
28+
ColorGradient.FromColors(new Color(25, 25, 60), new Color(15, 15, 35)),
29+
GradientDirection.Vertical)
30+
},
3331
TopPanelConfig: panel => panel
3432
.Left(Elements.StatusText("[bold cyan]SharpConsoleUI Demo[/]"))
3533
.Left(Elements.Separator())

Examples/FrameRateDemo/Program.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using SharpConsoleUI.Configuration;
33
using SharpConsoleUI.Controls;
44
using SharpConsoleUI.Drivers;
5+
using SharpConsoleUI.Panel;
56
using System.Timers;
67

78
namespace FrameRateDemo;
@@ -20,10 +21,13 @@ static void Main()
2021
var options = new ConsoleWindowSystemOptions(
2122
EnablePerformanceMetrics: true,
2223
EnableFrameRateLimiting: true,
23-
TargetFPS: 60
24+
TargetFPS: 60,
25+
TopPanelConfig: panel => panel
26+
.Left(Elements.StatusText(""))
27+
.Right(Elements.Performance())
2428
);
2529
var windowSystem = new ConsoleWindowSystem(driver, options: options);
26-
windowSystem.StatusBarStateService.TopStatus = "[bold cyan]Frame Rate Demo[/] - Change FPS with 1-5, Toggle limiting with E/D, Toggle metrics with M, Quit with Ctrl+Q";
30+
windowSystem.PanelStateService.TopStatus = "[bold cyan]Frame Rate Demo[/] - Change FPS with 1-5, Toggle limiting with E/D, Toggle metrics with M, Quit with Ctrl+Q";
2731

2832
// Create control panel window
2933
var controlWindow = CreateControlPanel(windowSystem);

Examples/FullScreenExample/Program.cs

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

1516
namespace FullScreenExample;
1617

@@ -30,11 +31,9 @@ static async Task<int> Main(string[] args)
3031
_windowSystem = new ConsoleWindowSystem(
3132
new NetConsoleDriver(RenderMode.Buffer),
3233
options: new ConsoleWindowSystemOptions(
33-
StatusBarOptions: new StatusBarOptions(
34-
ShowTaskBar: false // Hide taskbar for true full-screen experience
35-
)
34+
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))
3635
));
37-
_windowSystem.StatusBarStateService.TopStatus = "Full Screen Example - Press F10 to Exit";
36+
_windowSystem.PanelStateService.TopStatus = "Full Screen Example - Press F10 to Exit";
3837

3938
// Setup graceful shutdown handler for Ctrl+C
4039
Console.CancelKeyPress += (sender, e) =>
@@ -100,7 +99,7 @@ private static void CreateFullScreenWindow()
10099
" [green]•[/] IsClosable = false - Window cannot be closed with X button",
101100
" [green]•[/] IsMinimizable = false - Window cannot be minimized",
102101
" [green]•[/] IsMaximizable = false - Window cannot be maximized/restored",
103-
" [green]•[/] StatusBarOptions.ShowTaskBar = false - Taskbar hidden for full-screen",
102+
" [green]•[/] No BottomPanelConfig - Taskbar hidden for full-screen",
104103
" [green]•[/] State = Maximized - Fills console, resizes with it",
105104
"",
106105
"[dim]This is ideal for:[/]",

Examples/MenuDemo/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SharpConsoleUI.Drivers;
66
using SharpConsoleUI.Helpers;
77
using SharpConsoleUI.Layout;
8+
using SharpConsoleUI.Panel;
89

910
namespace MenuDemo;
1011

@@ -23,12 +24,11 @@ static async Task<int> Main(string[] args)
2324
_windowSystem = new ConsoleWindowSystem(
2425
new NetConsoleDriver(RenderMode.Buffer),
2526
options: new ConsoleWindowSystemOptions(
26-
StatusBarOptions: new StatusBarOptions(
27-
ShowTaskBar: true
28-
)
27+
TopPanelConfig: panel => panel.Left(Elements.StatusText("")),
28+
BottomPanelConfig: panel => panel.Center(Elements.TaskBar())
2929
));
30-
_windowSystem.StatusBarStateService.TopStatus = "MenuControl Demo - Full-Featured Menu with Keyboard & Mouse Support";
31-
_windowSystem.StatusBarStateService.BottomStatus =
30+
_windowSystem.PanelStateService.TopStatus = "MenuControl Demo - Full-Featured Menu with Keyboard & Mouse Support";
31+
_windowSystem.PanelStateService.BottomStatus =
3232
"Use Arrow Keys, Enter, Escape, Home/End, or Mouse | Tab to focus menu | ESC to close | Ctrl+C to Quit";
3333

3434
// Graceful shutdown

Examples/MultiDashboard/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SharpConsoleUI.Controls;
66
using SharpConsoleUI.Drivers;
77
using SharpConsoleUI.Helpers;
8+
using SharpConsoleUI.Panel;
89

910
namespace MultiDashboard;
1011

@@ -27,12 +28,15 @@ static async Task<int> Main(string[] args)
2728
_windowSystem = new ConsoleWindowSystem(
2829
new NetConsoleDriver(RenderMode.Buffer),
2930
options: new ConsoleWindowSystemOptions(
30-
StatusBarOptions: new StatusBarOptions(ShowTaskBar: true, ShowStartButton: true)
31+
TopPanelConfig: panel => panel.Left(Elements.StatusText("")),
32+
BottomPanelConfig: panel => panel
33+
.Left(Elements.StartMenu())
34+
.Center(Elements.TaskBar())
3135
)
3236
);
33-
_windowSystem.StatusBarStateService.TopStatus =
37+
_windowSystem.PanelStateService.TopStatus =
3438
"Multi-Dashboard Showcase - ConsoleEx Unique Capabilities Demo";
35-
_windowSystem.StatusBarStateService.BottomStatus =
39+
_windowSystem.PanelStateService.BottomStatus =
3640
"F1-F6: Toggle Windows | ESC: Close Window | F10: Close All | Ctrl+C: Quit";
3741

3842
// 2. Graceful shutdown

Examples/NavigationViewDemo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ static int Main(string[] args)
1818
var windowSystem = new ConsoleWindowSystem(
1919
new NetConsoleDriver(RenderMode.Buffer));
2020

21-
windowSystem.StatusBarStateService.ShowTopStatus = false;
22-
windowSystem.StatusBarStateService.ShowBottomStatus = false;
21+
windowSystem.PanelStateService.ShowTopPanel = false;
22+
windowSystem.PanelStateService.ShowBottomPanel = false;
2323

2424
CreateMainWindow(windowSystem);
2525

Examples/PanelDemo/Program.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
using SharpConsoleUI;
22
using SharpConsoleUI.Builders;
3+
using SharpConsoleUI.Configuration;
34
using SharpConsoleUI.Controls;
45
using SharpConsoleUI.Drivers;
56
using SharpConsoleUI.Layout;
7+
using SharpConsoleUI.Panel;
68

7-
var windowSystem = new ConsoleWindowSystem(new NetConsoleDriver(RenderMode.Buffer));
8-
windowSystem.StatusBarStateService.TopStatus = "PanelControl Demo - Mouse Event Handling";
9-
windowSystem.StatusBarStateService.BottomStatus = "Click panels to see events | Mouse wheel bubbles to scrollable parent | ESC: Close";
9+
var windowSystem = new ConsoleWindowSystem(new NetConsoleDriver(RenderMode.Buffer),
10+
options: new ConsoleWindowSystemOptions(
11+
TopPanelConfig: panel => panel.Left(Elements.StatusText(""))
12+
));
13+
windowSystem.PanelStateService.TopStatus = "PanelControl Demo - Mouse Event Handling";
14+
windowSystem.PanelStateService.BottomStatus = "Click panels to see events | Mouse wheel bubbles to scrollable parent | ESC: Close";
1015

1116
// Status display
1217
var statusControl = new MarkupControl(new List<string> { "[dim]Waiting for interaction...[/]" })

0 commit comments

Comments
 (0)