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
Binary file removed src/Dasher.Windows/Assets/avalonia-logo.ico
Binary file not shown.
23 changes: 3 additions & 20 deletions src/Dasher.Windows/Controls/DasherCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public partial class DasherCanvas : Control
private EyeGazeIntegration? _eyeGazeIntegration;
private bool _useEyeGazeInput;

private NativeBridge.OutputCallback? _outputCallback;
private NativeBridge.MessageCallback? _messageCallback;
private bool _callbacksRegistered;
private int _lastScreenWidth;
Expand All @@ -48,6 +47,9 @@ public DasherCanvas()

public IntPtr GetHandle() => _handle;

public void PauseTimer() => _timer.Stop();
public void ResumeTimer() => _timer.Start();

public void Initialize(string dataDir, string userDir)
{
_handle = NativeBridge.dasher_create(dataDir, userDir, out var errorPtr);
Expand Down Expand Up @@ -133,13 +135,6 @@ private void EnsureCallbacksRegistered()
if (_callbacksRegistered) return;
_callbacksRegistered = true;

try
{
_outputCallback = new NativeBridge.OutputCallback(OnOutputEvent);
NativeBridge.dasher_set_output_callback(_handle, _outputCallback, IntPtr.Zero);
}
catch { }

try
{
_messageCallback = new NativeBridge.MessageCallback(OnEngineMessage);
Expand Down Expand Up @@ -221,18 +216,6 @@ private void OnTick(object? sender, EventArgs e)
InvalidateVisual();
}

private void OnOutputEvent(int eventType, IntPtr textPtr, IntPtr userData)
{
var text = textPtr != IntPtr.Zero ? Marshal.PtrToStringUTF8(textPtr) ?? "" : "";
Dispatcher.UIThread.Post(() =>
{
if (eventType == 0)
OutputText += text;
else if (eventType == 1 && OutputText.Length >= text.Length)
OutputText = OutputText[..^text.Length];
});
}

private void OnEngineMessage(int messageType, IntPtr textPtr, IntPtr userData)
{
var text = textPtr != IntPtr.Zero ? Marshal.PtrToStringUTF8(textPtr) ?? "" : "";
Expand Down
63 changes: 22 additions & 41 deletions src/Dasher.Windows/Controls/SettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ private void ShowCategoryCore(string category)

_panel.Children.Clear();

var backBtn = new Button
{
Content = "\u2190 Back",
FontSize = 12,
FontWeight = FontWeight.Medium,
Foreground = new SolidColorBrush(Color.FromRgb(0x8B, 0x92, 0x9A)),
Background = Brushes.Transparent,
Padding = new Thickness(0, 0, 0, 6),
BorderThickness = new Thickness(0),
};
backBtn.Click += (s, e) => BackRequested?.Invoke(this, EventArgs.Empty);
_panel.Children.Add(backBtn);

if (category == "Input")
{
var inputSourceRow = BuildInputSourceRow();
Expand Down Expand Up @@ -212,7 +199,6 @@ private void ShowCategoryCore(string category)
}
}

public event EventHandler? BackRequested;
public event EventHandler<(EyeGazeIntegration.TrackerType trackerType, int udpPort)>? InputSourceChanged;
public event EventHandler? JoystickRequested;
public event Action<string, int>? OutputFontChanged;
Expand Down Expand Up @@ -743,27 +729,20 @@ private static bool IsColourPaletteParameter(ParameterDisplayInfo info)
? Marshal.PtrToStringUTF8(currentPalettePtr) ?? ""
: "";

var section = new StackPanel { Spacing = 8, Margin = new Thickness(0, 4, 0, 12) };
var section = new StackPanel { Spacing = 10, Margin = new Thickness(0, 4, 0, 12) };

var header = new TextBlock
{
Text = "Colour Theme",
FontSize = 12,
FontWeight = FontWeight.Medium,
Foreground = new SolidColorBrush(Color.FromRgb(0x0F, 0x4B, 0x75)),
FontSize = 13,
FontWeight = FontWeight.SemiBold,
Foreground = Application.Current?.FindResource("TextPrimary") as IBrush ?? Brushes.Black,
};
section.Children.Add(header);

var scroll = new ScrollViewer
{
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Disabled,
};

var strip = new StackPanel
var wrap = new WrapPanel
{
Orientation = Orientation.Horizontal,
Spacing = 10,
};

var colors = new int[4];
Expand All @@ -777,23 +756,24 @@ private static bool IsColourPaletteParameter(ParameterDisplayInfo info)

var card = new Button
{
Padding = new Thickness(0),
Padding = new Thickness(6),
Margin = new Thickness(0, 0, 8, 8),
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
Cursor = new Cursor(StandardCursorType.Hand),
Tag = name,
};

var cardContent = new StackPanel { Spacing = 4, HorizontalAlignment = HorizontalAlignment.Center };
var cardContent = new StackPanel { Spacing = 6, HorizontalAlignment = HorizontalAlignment.Center };

var swatchRow = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 2 };
for (int c = 0; c < 4; c++)
{
var swatch = new Border
{
Width = 16,
Height = 24,
CornerRadius = new CornerRadius(2),
Width = 22,
Height = 28,
CornerRadius = new CornerRadius(3),
Background = ArgbToBrush(colors[c]),
};
swatchRow.Children.Add(swatch);
Expand All @@ -802,41 +782,42 @@ private static bool IsColourPaletteParameter(ParameterDisplayInfo info)
var swatchContainer = new Border
{
Child = swatchRow,
CornerRadius = new CornerRadius(4),
CornerRadius = new CornerRadius(5),
BorderThickness = new Thickness(isSelected ? 2 : 1),
BorderBrush = isSelected
? new SolidColorBrush(Color.FromRgb(0x00, 0x53, 0x7F))
? (Application.Current?.FindResource("DeepNavy") as IBrush ?? Brushes.Navy)
: new SolidColorBrush(Color.FromArgb(0x4D, 0x80, 0x80, 0x80)),
Padding = new Thickness(1),
Padding = new Thickness(2),
};
cardContent.Children.Add(swatchContainer);

var nameLabel = new TextBlock
{
Text = name,
FontSize = 9,
FontSize = 11,
Foreground = isSelected
? new SolidColorBrush(Color.FromRgb(0x0F, 0x4B, 0x75))
: new SolidColorBrush(Color.FromRgb(0x8B, 0x92, 0x9A)),
? (Application.Current?.FindResource("TextPrimary") as IBrush ?? Brushes.Black)
: (Application.Current?.FindResource("TextSecondary") as IBrush ?? Brushes.Gray),
HorizontalAlignment = HorizontalAlignment.Center,
TextTrimming = TextTrimming.CharacterEllipsis,
Width = 100,
TextAlignment = TextAlignment.Center,
};
cardContent.Children.Add(nameLabel);

card.Content = cardContent;
card.Width = 80;
card.Width = 110;

card.Click += (s, e) =>
{
if (s is Button b && b.Tag is string paletteName)
NativeBridge.dasher_set_palette(_handle, paletteName);
};

strip.Children.Add(card);
wrap.Children.Add(card);
}

scroll.Content = strip;
section.Children.Add(scroll);
section.Children.Add(wrap);
return section;
}

Expand Down
135 changes: 100 additions & 35 deletions src/Dasher.Windows/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,35 +87,36 @@
<Setter Property="Background" Value="{DynamicResource ControlBgHover}"/>
</Style>

<Style Selector="Border.prefs-bar">
<Setter Property="Background" Value="{DynamicResource SurfaceLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderLight}"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
<Setter Property="Height" Value="42"/>
<Setter Property="Padding" Value="16,0"/>
</Style>
<Style Selector="Border.prefs-bar Button.prefs-tab">
<Style Selector="Button.settings-tab">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{DynamicResource TextSecondary}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="500"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="CornerRadius" Value="{DynamicResource RadiusSm}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="CornerRadius" Value="6"/>
<Setter Property="Padding" Value="10,6"/>
<Setter Property="Margin" Value="0,0,2,0"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style Selector="Border.prefs-bar Button.prefs-tab:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ControlBg}"/>
<Style Selector="Button.settings-tab:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ControlBgHover}"/>
</Style>
<Style Selector="Border.prefs-bar Button.prefs-tab.active /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ControlBg}"/>
<Style Selector="Button.settings-tab.active /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource DasherTeal}"/>
</Style>
<Style Selector="Border.prefs-bar Button.prefs-tab.active TextBlock">
<Setter Property="Foreground" Value="{DynamicResource TextPrimary}"/>
<Style Selector="Button.settings-tab.active TextBlock">
<Setter Property="Foreground" Value="{DynamicResource DeepNavy}"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
<Style Selector="Button.settings-tab.active LucideIcon">
<Setter Property="Foreground" Value="{DynamicResource DeepNavy}"/>
</Style>
<Style Selector="Button.settings-tab TextBlock">
<Setter Property="Foreground" Value="{DynamicResource TextSecondary}"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Medium"/>
</Style>
<Style Selector="Button.settings-tab LucideIcon">
<Setter Property="Foreground" Value="{DynamicResource TextSecondary}"/>
</Style>

<Style Selector="TextBlock.ui-nav-label">
<Setter Property="FontSize" Value="12"/>
Expand Down Expand Up @@ -173,10 +174,41 @@
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="16"/>
</Style>

<Style Selector="Border.kb-bar">
<Setter Property="Background" Value="{DynamicResource SurfaceLight}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderLight}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="4,3"/>
<Setter Property="BoxShadow" Value="0 2 6 0 #40000000"/>
</Style>
<Style Selector="Border.kb-bar Button">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="CornerRadius" Value="6"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Cursor" Value="Hand"/>
</Style>
<Style Selector="Border.kb-bar Button:pointerover /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource ControlBgHover}"/>
</Style>
<Style Selector="Border.kb-bar Button LucideIcon">
<Setter Property="Foreground" Value="{DynamicResource TextSecondary}"/>
</Style>
<Style Selector="Border.kb-bar Button.accent LucideIcon">
<Setter Property="Foreground" Value="{DynamicResource DeepNavy}"/>
</Style>
<Style Selector="Border.kb-bar Button.accent">
<Setter Property="Background" Value="{DynamicResource DasherTeal}"/>
</Style>
</Window.Styles>

<Grid>
<DockPanel>
<Border Classes="top-bar" DockPanel.Dock="Top">
<Border x:Name="TopBar" Classes="top-bar" DockPanel.Dock="Top">
<Grid ColumnDefinitions="*, Auto">
<StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center" HorizontalAlignment="Left">
<Button Classes="nav-btn" Click="OnNew" ToolTip.Tip="New document">
Expand Down Expand Up @@ -263,19 +295,8 @@
</Grid>
</Border>

<StackPanel DockPanel.Dock="Top" IsVisible="{Binding IsPrefsVisible}">
<Border Classes="prefs-bar">
<Border x:Name="PrefsTabStrip" IsVisible="True">
<StackPanel x:Name="PrefsTabContainer" Orientation="Horizontal" Spacing="2" VerticalAlignment="Center"/>
</Border>
</Border>
<Border x:Name="PrefsContentPanel" Classes="prefs-content" IsVisible="False"
Background="{DynamicResource BgLight}" BorderBrush="{DynamicResource BorderLight}" BorderThickness="0,0,0,1"
MaxHeight="320">
<controls:SettingsPanel x:Name="SettingsPanel"/>
</Border>
</StackPanel>

<Grid>
<DockPanel>
<Border x:Name="StatusBarShowBtn" DockPanel.Dock="Bottom" IsVisible="{Binding IsStatusBarHidden}"
Background="Transparent" Padding="4">
<Button Width="28" Height="20" CornerRadius="6" Background="{DynamicResource ControlBg}" BorderThickness="0"
Expand Down Expand Up @@ -425,5 +446,49 @@
</Grid>
</Border>
</Grid>
</DockPanel>
</Grid>
</DockPanel>

<Border x:Name="SettingsDock" IsVisible="False"
Background="{DynamicResource SurfaceLight}">
<DockPanel>
<Border DockPanel.Dock="Top" Background="{DynamicResource BgLight}"
BorderBrush="{DynamicResource BorderLight}" BorderThickness="0,0,0,1"
Padding="12,8">
<DockPanel>
<Button x:Name="SettingsCloseBtn" DockPanel.Dock="Right"
Width="28" Height="28" CornerRadius="6"
Background="Transparent" BorderThickness="0"
VerticalAlignment="Center" Cursor="Hand"
Click="OnTogglePrefs" ToolTip.Tip="Close settings">
<LucideIcon Kind="{x:Static lucide:LucideIconKind.X}" Size="16" Foreground="{DynamicResource TextSecondary}"/>
</Button>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<StackPanel x:Name="SettingsTabContainer" Orientation="Horizontal" Spacing="2"/>
</ScrollViewer>
</DockPanel>
</Border>
<ScrollViewer Padding="24,16" Background="{DynamicResource BgLight}">
<controls:SettingsPanel x:Name="DockedSettingsPanel"/>
</ScrollViewer>
</DockPanel>
</Border>

<Border x:Name="KeyboardMiniBar" Classes="kb-bar" IsVisible="False"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="8,8,8,0" ZIndex="100">
<StackPanel Orientation="Horizontal" Spacing="2">
<Button x:Name="KbControlBtn" Click="OnToggleControlMode" ToolTip.Tip="Control mode">
<LucideIcon Kind="{x:Static lucide:LucideIconKind.MousePointerClick}" Size="18"/>
</Button>
<Button Click="OnTogglePrefs" ToolTip.Tip="Settings">
<LucideIcon Kind="{x:Static lucide:LucideIconKind.Settings}" Size="18"/>
</Button>
<Button Click="OnToggleMode" ToolTip.Tip="Exit keyboard mode">
<LucideIcon Kind="{x:Static lucide:LucideIconKind.Keyboard}" Size="18"/>
</Button>
</StackPanel>
</Border>
</Grid>
</Window>
Loading
Loading