Skip to content

Commit

Permalink
UI: Revert to Avalonia 11-preview8
Browse files Browse the repository at this point in the history
AvaloniaEdit is broken in RC1 and there appears to be some keyboard focus issues on Linux

This reverts commit b90ffc7.
  • Loading branch information
SourMesen committed Jun 30, 2023
1 parent dbde333 commit 600d4bf
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 117 deletions.
4 changes: 2 additions & 2 deletions UI/Controls/ButtonWithIcon.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace Mesen.Controls
{
public class ButtonWithIcon : Button
public class ButtonWithIcon : Button, IStyleable
{
protected override Type StyleKeyOverride => typeof(Button);
Type IStyleable.StyleKey => typeof(Button);

public static readonly StyledProperty<string> TextProperty = AvaloniaProperty.Register<ButtonWithIcon, string>(nameof(Text), "");
public static readonly StyledProperty<string> IconProperty = AvaloniaProperty.Register<ButtonWithIcon, string>(nameof(Icon), "");
Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/EnumRadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Mesen.Controls
{
public class EnumRadioButton : RadioButton
public class EnumRadioButton : RadioButton, IStyleable
{
protected override Type StyleKeyOverride => typeof(RadioButton);
Type IStyleable.StyleKey => typeof(RadioButton);

public static readonly StyledProperty<Enum> ValueProperty = AvaloniaProperty.Register<EnumRadioButton, Enum>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
public static readonly StyledProperty<Enum> CheckedWhenProperty = AvaloniaProperty.Register<EnumRadioButton, Enum>(nameof(CheckedWhen));
Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/IconButton.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace Mesen.Controls
{
public class IconButton : Button
public class IconButton : Button, IStyleable
{
protected override Type StyleKeyOverride => typeof(Button);
Type IStyleable.StyleKey => typeof(Button);

public static readonly StyledProperty<string> IconProperty = AvaloniaProperty.Register<KeyBindingButton, string>(nameof(Icon), "");

Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/ImageAspectRatio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Mesen.Controls
{
public class ImageAspectRatio : Image
public class ImageAspectRatio : Image, IStyleable
{
protected override Type StyleKeyOverride => typeof(Image);
Type IStyleable.StyleKey => typeof(Image);

public ImageAspectRatio()
{
Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/KeyBindingButton.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace Mesen.Controls
{
public class KeyBindingButton : Button
public class KeyBindingButton : Button, IStyleable
{
protected override Type StyleKeyOverride => typeof(Button);
Type IStyleable.StyleKey => typeof(Button);

public static readonly StyledProperty<UInt16> KeyBindingProperty = AvaloniaProperty.Register<KeyBindingButton, UInt16>(nameof(KeyBinding), 0, false, Avalonia.Data.BindingMode.TwoWay);

Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/MesenMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Mesen.Controls
{
public class MesenMenu : Menu
public class MesenMenu : Menu, IStyleable
{
protected override Type StyleKeyOverride => typeof(Menu);
Type IStyleable.StyleKey => typeof(Menu);

private void SubmenuOpened(object? sender, RoutedEventArgs e) {
MenuItem menuItem = (MenuItem)sender!;
Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/MesenNumericTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Mesen.Controls
{
public class MesenNumericTextBox : TextBox
public class MesenNumericTextBox : TextBox, IStyleable
{
protected override Type StyleKeyOverride => typeof(TextBox);
Type IStyleable.StyleKey => typeof(TextBox);

private static HexConverter _hexConverter = new HexConverter();

Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/MesenScrollContentPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

namespace Mesen.Controls
{
public class MesenScrollContentPresenter : ScrollContentPresenter
public class MesenScrollContentPresenter : ScrollContentPresenter, IStyleable
{
protected override Type StyleKeyOverride => typeof(ScrollContentPresenter);
Type IStyleable.StyleKey => typeof(ScrollContentPresenter);

protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
Expand Down
4 changes: 2 additions & 2 deletions UI/Controls/MultiKeyBindingButton.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Mesen.Controls
{
public class MultiKeyBindingButton : Button
public class MultiKeyBindingButton : Button, IStyleable
{
protected override Type StyleKeyOverride => typeof(Button);
Type IStyleable.StyleKey => typeof(Button);

public static readonly StyledProperty<KeyCombination> KeyBindingProperty = AvaloniaProperty.Register<KeyBindingButton, KeyCombination>(nameof(KeyBinding), new KeyCombination(), false, Avalonia.Data.BindingMode.TwoWay);

Expand Down
4 changes: 2 additions & 2 deletions UI/Debugger/Controls/DebuggerKeyBindingButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace Mesen.Debugger.Controls
{
public class DebuggerKeyBindingButton : Button
public class DebuggerKeyBindingButton : Button, IStyleable
{
protected override Type StyleKeyOverride => typeof(Button);
Type IStyleable.StyleKey => typeof(Button);

public static readonly StyledProperty<DbgShortKeys> KeyBindingProperty = AvaloniaProperty.Register<DebuggerKeyBindingButton, DbgShortKeys>(nameof(KeyBinding), new DbgShortKeys(), false, Avalonia.Data.BindingMode.TwoWay);

Expand Down
4 changes: 2 additions & 2 deletions UI/Debugger/Controls/MesenTextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

namespace Mesen.Debugger.Controls
{
public class MesenTextEditor : TextEditor
public class MesenTextEditor : TextEditor, IStyleable
{
protected override Type StyleKeyOverride => typeof(TextEditor);
Type IStyleable.StyleKey => typeof(TextEditor);

public static readonly StyledProperty<string> TextBindingProperty = AvaloniaProperty.Register<MesenTextEditor, string>(nameof(TextBinding), "", defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);

Expand Down
106 changes: 51 additions & 55 deletions UI/Debugger/DebuggerDockFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ public override IRootDock CreateLayout()
{
if(_savedRootDef != null) {
//Restore previous layout
try {
if(FromDockDefinition(_savedRootDef) is IRootDock savedRootLayout) {
return savedRootLayout;
}
} catch {
//Reset layout if any error occurs
if(FromDockDefinition(_savedRootDef) is IRootDock savedRootLayout) {
return savedRootLayout;
}
}

Expand All @@ -72,55 +68,55 @@ public IRootDock GetDefaultLayout()
var mainLayout = new ProportionalDock {
Orientation = Orientation.Vertical,
VisibleDockables = CreateList<IDockable>(
new ProportionalDock {
Proportion = 0.75,
Orientation = Orientation.Horizontal,
ActiveDockable = null,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.60,
VisibleDockables = CreateList<IDockable>(DisassemblyTool)
},
new ProportionalDockSplitter(),
new ProportionalDock {
Proportion = 0.40,
Orientation = Orientation.Vertical,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.5,
VisibleDockables = CreateList<IDockable>(StatusTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.5,
VisibleDockables = CreateList<IDockable>(LabelListTool, FunctionListTool, FindResultListTool, ControllerListTool)
}
)
}
)
},
new ProportionalDockSplitter(),
new ProportionalDock {
Proportion = 0.25,
Orientation = Orientation.Horizontal,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(WatchListTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(BreakpointListTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(CallStackTool)
}
)
}
)
new ProportionalDock {
Proportion = 0.75,
Orientation = Orientation.Horizontal,
ActiveDockable = null,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.60,
VisibleDockables = CreateList<IDockable>(DisassemblyTool)
},
new ProportionalDockSplitter(),
new ProportionalDock {
Proportion = 0.40,
Orientation = Orientation.Vertical,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.5,
VisibleDockables = CreateList<IDockable>(StatusTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.5,
VisibleDockables = CreateList<IDockable>(LabelListTool, FunctionListTool, FindResultListTool, ControllerListTool)
}
)
}
)
},
new ProportionalDockSplitter(),
new ProportionalDock {
Proportion = 0.25,
Orientation = Orientation.Horizontal,
VisibleDockables = CreateList<IDockable>(
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(WatchListTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(BreakpointListTool)
},
new ProportionalDockSplitter(),
new ToolDock {
Proportion = 0.33,
VisibleDockables = CreateList<IDockable>(CallStackTool)
}
)
}
)
};

var root = CreateRootDock();
Expand Down
4 changes: 2 additions & 2 deletions UI/Debugger/Views/WatchListView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ private void OnGridKeyDown(object? sender, KeyEventArgs e)
}
}

public class WatchListTextBox : TextBox
public class WatchListTextBox : TextBox, IStyleable
{
protected override Type StyleKeyOverride => typeof(TextBox);
Type IStyleable.StyleKey => typeof(TextBox);

private WatchListView? _listView;
private bool _inOnGotFocus = false;
Expand Down
4 changes: 2 additions & 2 deletions UI/Debugger/Windows/DebuggerWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
xmlns:dm="clr-namespace:Dock.Model;assembly=Dock.Model.Avalonia"
xmlns:dmc="clr-namespace:Dock.Model.Controls;assembly=Dock.Model.Avalonia"
mc:Ignorable="d"
DragDrop.AllowDrop="True"
DragDrop.AllowDrop="True"
x:Class="Mesen.Debugger.Windows.DebuggerWindow"
x:DataType="vm:DebuggerWindowViewModel"
Title="{CompiledBinding Title}"
Expand Down Expand Up @@ -130,7 +130,7 @@
DockPanel.Dock="Bottom"
/>

<idc:DockControl Layout="{CompiledBinding DockLayout}" />
<idc:DockControl Layout="{CompiledBinding DockLayout}"/>
</DockPanel>
</DockPanel>
</Window>
2 changes: 1 addition & 1 deletion UI/Debugger/Windows/DebuggerWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void ProcessNotification(NotificationEventArgs e)
Dispatcher.UIThread.Post(() => {
if(!ToolRefreshHelper.LimitFps(this, 20)) {
//Prevent watch update when user is typing a new watch entry
bool updatingWatchEntry = TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is TextBox txt && txt.FindAncestorOfType<WatchListView>() != null;
bool updatingWatchEntry = FocusManager.Instance?.Current is TextBox txt && txt.FindAncestorOfType<WatchListView>() != null;
_model.PartialRefresh(!updatingWatchEntry);
}
});
Expand Down
2 changes: 1 addition & 1 deletion UI/Debugger/Windows/ScriptWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public MyCompletionData(string text, string? enumName = null, int insertOffset =
_insertOffset = insertOffset;
}

public Bitmap Image
public IBitmap Image
{
get
{
Expand Down
2 changes: 1 addition & 1 deletion UI/Debugger/Windows/WatchWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void ProcessNotification(NotificationEventArgs e)
break;

case ConsoleNotificationType.PpuFrameDone:
if(TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is TextBox) {
if(FocusManager.Instance?.Current is TextBox) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions UI/ThirdParty/DataBox/Controls/DataBoxPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace DataBoxControl.Controls;

public class DataBoxPanel : VirtualizingStackPanel
public class DataBoxPanel : VirtualizingStackPanel, IStyleable
{
protected override Type StyleKeyOverride => typeof(DataBoxPanel);
Type IStyleable.StyleKey => typeof(DataBoxPanel);

internal DataBox? DataBox { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion UI/ThirdParty/DataBox/DataBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private void OnPreviewKeyDown(object? sender, KeyEventArgs e)
if(e.Key == Key.Space) {
ProcessKeyPress(" ");
e.Handled = true;
} else if(IsKeyboardFocusWithin && TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is CheckBox) {
} else if(IsKeyboardFocusWithin && FocusManager.Instance?.Current is CheckBox) {
//Allow up/down arrow keys to work properly when focus is on a checkbox column
_rowsPresenter?.ContainerFromIndex(Selection.SelectedIndex)?.Focus();
}
Expand Down
4 changes: 2 additions & 2 deletions UI/ThirdParty/DataBox/DataBoxCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace DataBoxControl;

public class DataBoxCell : ContentControl
public class DataBoxCell : ContentControl, IStyleable
{
internal DataBox? DataBox { get; set; }
internal DataBoxColumn? Column { get; set; }

protected override Type StyleKeyOverride => typeof(DataBoxCell);
Type IStyleable.StyleKey => typeof(DataBoxCell);
}
4 changes: 2 additions & 2 deletions UI/ThirdParty/DataBox/DataBoxColumnHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace DataBoxControl;

[PseudoClasses(":pressed", ":sortascending", ":sortdescending")]
public class DataBoxColumnHeader : ContentControl
public class DataBoxColumnHeader : ContentControl, IStyleable
{
public static readonly StyledProperty<IBrush?> SeparatorBrushProperty =
AvaloniaProperty.Register<DataBoxColumnHeader, IBrush?>(nameof(SeparatorBrush));
Expand All @@ -39,7 +39,7 @@ public DataBoxColumnHeader()
UpdatePseudoClassesIsPressed(IsPressed);
}

protected override Type StyleKeyOverride => typeof(DataBoxColumnHeader);
Type IStyleable.StyleKey => typeof(DataBoxColumnHeader);

internal DataBox? DataBox { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions UI/ThirdParty/DataBox/DataBoxRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace DataBoxControl;

public class DataBoxRow : ListBoxItem
public class DataBoxRow : ListBoxItem, IStyleable
{
private Rectangle? _bottomGridLine;

protected override Type StyleKeyOverride => typeof(DataBoxRow);
Type IStyleable.StyleKey => typeof(DataBoxRow);

internal DataBox? DataBox { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions UI/ThirdParty/DataBox/Primitives/DataBoxCellsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace DataBoxControl.Primitives;

public class DataBoxCellsPresenter : Panel
public class DataBoxCellsPresenter : Panel, IStyleable
{
protected override Type StyleKeyOverride => typeof(DataBoxCellsPresenter);
Type IStyleable.StyleKey => typeof(DataBoxCellsPresenter);

internal DataBox? DataBox { get; set; }

Expand Down
Loading

0 comments on commit 600d4bf

Please sign in to comment.