Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions App/Dialogs/ConnectDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,7 @@ public ConnectDialog(
};

// Default button highlighted with amber
var defaultButtonScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var defaultButtonScheme = ThemeStyler.CreateAccentButtonScheme(theme);

var connectButton = new Button
{
Expand Down
9 changes: 1 addition & 8 deletions App/Dialogs/OpenConfigDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,7 @@ public OpenConfigDialog()
Y = Pos.AnchorEnd(1),
Text = $"{theme.ButtonPrefix}Open{theme.ButtonSuffix}",
IsDefault = true,
ColorScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
}
ColorScheme = ThemeStyler.CreateAccentButtonScheme(theme)
};
openButton.Accepting += (_, _) => Confirm();

Expand Down
9 changes: 1 addition & 8 deletions App/Dialogs/PasswordPromptDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ public PasswordPromptDialog(string username, string endpoint)
Secret = true
};

var defaultButtonScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var defaultButtonScheme = ThemeStyler.CreateAccentButtonScheme(theme);

var okButton = new Button
{
Expand Down
9 changes: 1 addition & 8 deletions App/Dialogs/SaveConfigDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,7 @@ public SaveConfigDialog(string defaultDirectory, string defaultFilename)
};

// Buttons
var defaultButtonScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var defaultButtonScheme = ThemeStyler.CreateAccentButtonScheme(theme);

var saveButton = new Button
{
Expand Down
9 changes: 1 addition & 8 deletions App/Dialogs/SaveRecordingDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ public SaveRecordingDialog(string defaultDirectory, string defaultFilename)
};

// Buttons
var defaultButtonScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var defaultButtonScheme = ThemeStyler.CreateAccentButtonScheme(theme);

var saveButton = new Button
{
Expand Down
9 changes: 1 addition & 8 deletions App/Dialogs/WriteValueDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,7 @@ public WriteValueDialog(NodeId nodeId, string nodeName, BuiltInType dataType, st


// Default button highlighted with amber
var defaultButtonScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var defaultButtonScheme = ThemeStyler.CreateAccentButtonScheme(theme);

var writeButton = new Button
{
Expand Down
20 changes: 1 addition & 19 deletions App/FocusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private bool PollFocus()
/// <summary>
/// Sets focus to the pane at the specified index.
/// </summary>
public void FocusPane(int index)
private void FocusPane(int index)
{
if (index >= 0 && index < _panes.Length)
{
Expand All @@ -96,15 +96,6 @@ public void FocusNext()
FocusPane(GetNextIndex(currentIndex, _panes.Length));
}

/// <summary>
/// Cycles focus to the previous pane.
/// </summary>
public void FocusPrevious()
{
var currentIndex = _currentPane != null ? Array.IndexOf(_panes, _currentPane) : 0;
FocusPane(GetPreviousIndex(currentIndex, _panes.Length));
}

/// <summary>
/// Computes the index of the next pane in tab order, wrapping around to the
/// first pane after the last. Pure helper extracted for testability.
Expand All @@ -113,13 +104,4 @@ internal static int GetNextIndex(int currentIndex, int paneCount)
{
return (currentIndex + 1) % paneCount;
}

/// <summary>
/// Computes the index of the previous pane in tab order, wrapping around to the
/// last pane before the first. Pure helper extracted for testability.
/// </summary>
internal static int GetPreviousIndex(int currentIndex, int paneCount)
{
return (currentIndex - 1 + paneCount) % paneCount;
}
}
45 changes: 9 additions & 36 deletions App/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ public MainWindow()
// Override global "Menu" ColorScheme BEFORE creating any views
// This prevents StatusBar's blue background flash on first render
var theme = ThemeManager.Current;
Colors.ColorSchemes["Menu"] = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Foreground, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.ForegroundBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
Colors.ColorSchemes["Menu"] = ThemeStyler.CreateFlatBarScheme(theme);

// Create theme toggle menu item
_themeToggleItem = new MenuItem(GetThemeToggleTitle(), "", ToggleTheme);
Expand Down Expand Up @@ -149,14 +142,7 @@ public MainWindow()
};

// Also set ColorScheme directly on the StatusBar instance
_statusBar.ColorScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Foreground, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.ForegroundBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
_statusBar.ColorScheme = ThemeStyler.CreateFlatBarScheme(theme);

// Connection status indicator (colored) - FAR RIGHT, overlaid on status bar row
// We position it dynamically based on text width
Expand Down Expand Up @@ -330,14 +316,7 @@ private void ApplyTheme()
var theme = ThemeManager.Current;

// Update global "Menu" ColorScheme (used by StatusBar)
Colors.ColorSchemes["Menu"] = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Foreground, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.ForegroundBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
Colors.ColorSchemes["Menu"] = ThemeStyler.CreateFlatBarScheme(theme);

// Apply main window styling - double-line for emphasis
ColorScheme = theme.MainColorScheme;
Expand All @@ -354,14 +333,7 @@ private void ApplyTheme()

// Apply clean status bar styling (no blue background)
// Must set ColorScheme AND call SetNeedsDisplay to override Terminal.Gui defaults
var cleanStatusBarScheme = new ColorScheme
{
Normal = new Terminal.Gui.Attribute(theme.Foreground, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.ForegroundBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
var cleanStatusBarScheme = ThemeStyler.CreateFlatBarScheme(theme);
_statusBar.ColorScheme = cleanStatusBarScheme;
_statusBar.SetNeedsLayout();

Expand Down Expand Up @@ -626,7 +598,7 @@ private async Task WriteToAddressSpaceNodeAsync(BrowsedNode node)

if (Opc.Ua.StatusCode.IsGood(attrs[1].StatusCode) && attrs[1].Value is Opc.Ua.NodeId dataTypeNodeId)
{
(builtInType, dataTypeName) = SubscriptionManager.ResolveDataType(dataTypeNodeId);
(builtInType, dataTypeName) = DataTypeResolver.Resolve(dataTypeNodeId);
}
}

Expand Down Expand Up @@ -1251,15 +1223,16 @@ private async Task LoadConfigurationAsync(string filePath)
// old server while (or after) the new connection is attempted.
await DisconnectAsync();

// Honor the config's security and sampling settings (the connect dialog has
// no UI for these, so the config file is their only source).
// Honor the config's security and subscription settings (the connect dialog
// has no UI for these, so the config file is their only source).
var connected = await _connectionManager.ConnectAsync(
config.Server.EndpointUrl,
config.Settings.PublishingIntervalMs,
credentials,
config.Server.SecurityMode,
config.Server.SecurityPolicy,
config.Settings.SamplingIntervalMs);
config.Settings.SamplingIntervalMs,
config.Settings.QueueSize);

if (connected)
{
Expand Down
87 changes: 26 additions & 61 deletions App/Themes/ThemeStyler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,39 @@ namespace Opcilloscope.App.Themes;
public static class ThemeStyler
{
/// <summary>
/// Applies full theme styling to a view including borders, colors, and spacing.
/// Applies full theme styling to a frame including borders, colors, and spacing.
/// Note: Does NOT override BorderStyle - caller should set that explicitly to control
/// whether a view uses emphasized (double-line) or secondary (single-line) borders.
/// </summary>
public static void ApplyTo(View view, AppTheme? theme = null)
public static void ApplyToFrame(FrameView frame, AppTheme? theme = null)
{
theme ??= ThemeManager.Current;

// Apply color scheme
view.ColorScheme = theme.MainColorScheme;
frame.ColorScheme = theme.MainColorScheme;

// Note: BorderStyle is NOT set here - callers should set it explicitly
// to control emphasized vs secondary border styling

// Configure border colors - use BorderColorScheme for consistent grey borders
// that don't change to amber/yellow when focused (avoids terminal inconsistencies)
if (view.Border != null)
if (frame.Border != null)
{
view.Border.ColorScheme = theme.BorderColorScheme;
frame.Border.ColorScheme = theme.BorderColorScheme;
}

// Apply margin and padding from theme
if (view.Margin != null)
if (frame.Margin != null)
{
view.Margin.Thickness = theme.MarginThickness;
frame.Margin.Thickness = theme.MarginThickness;
}

if (view.Padding != null)
if (frame.Padding != null)
{
view.Padding.Thickness = theme.PaddingThickness;
frame.Padding.Thickness = theme.PaddingThickness;
}
}

/// <summary>
/// Applies styling to a FrameView with themed borders.
/// </summary>
public static void ApplyToFrame(FrameView frame, AppTheme? theme = null)
{
theme ??= ThemeManager.Current;

// Apply base styling
ApplyTo(frame, theme);
}

/// <summary>
/// Applies dialog-specific styling.
/// </summary>
Expand All @@ -69,15 +58,6 @@ public static void ApplyToDialog(Dialog dialog, AppTheme? theme = null)
}
}

/// <summary>
/// Applies styling to a button.
/// </summary>
public static void ApplyToButton(Button button, AppTheme? theme = null)
{
theme ??= ThemeManager.Current;
button.ColorScheme = theme.ButtonColorScheme;
}

/// <summary>
/// Applies menu bar styling.
/// </summary>
Expand All @@ -88,50 +68,35 @@ public static void ApplyToMenuBar(MenuBar menuBar, AppTheme? theme = null)
}

/// <summary>
/// Applies status bar styling.
/// </summary>
public static void ApplyToStatusBar(StatusBar statusBar, AppTheme? theme = null)
{
theme ??= ThemeManager.Current;
statusBar.ColorScheme = theme.MenuColorScheme;
}

/// <summary>
/// Creates a styled label with theme colors.
/// </summary>
public static Label CreateLabel(string text, AppTheme? theme = null)
{
theme ??= ThemeManager.Current;
return new Label
{
Text = text,
ColorScheme = theme.MainColorScheme
};
}

/// <summary>
/// Creates a styled TextField with theme colors.
/// Creates the accent-colored scheme used to highlight a dialog's default button.
/// </summary>
public static TextField CreateTextField(string text = "", AppTheme? theme = null)
public static ColorScheme CreateAccentButtonScheme(AppTheme? theme = null)
{
theme ??= ThemeManager.Current;
return new TextField
return new ColorScheme
{
Text = text,
ColorScheme = theme.MainColorScheme
Normal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
}

/// <summary>
/// Creates a styled button with theme decorations.
/// Creates the flat menu/status bar scheme. Unlike MenuColorScheme this keeps the
/// theme background on focus, avoiding inverted highlight flashes on the bars.
/// </summary>
public static Button CreateButton(string text, AppTheme? theme = null)
public static ColorScheme CreateFlatBarScheme(AppTheme? theme = null)
{
theme ??= ThemeManager.Current;
return new Button
return new ColorScheme
{
Text = text,
ColorScheme = theme.ButtonColorScheme
Normal = new Terminal.Gui.Attribute(theme.Foreground, theme.Background),
Focus = new Terminal.Gui.Attribute(theme.ForegroundBright, theme.Background),
HotNormal = new Terminal.Gui.Attribute(theme.Accent, theme.Background),
HotFocus = new Terminal.Gui.Attribute(theme.AccentBright, theme.Background),
Disabled = new Terminal.Gui.Attribute(theme.MutedText, theme.Background)
};
}
}
Loading
Loading