mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Merge remote-tracking branch 'upstream/HEAD' into dev
# Conflicts: # osu.Framework/Platform/SDL3/SDL3Window_Input.cs
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
using System.IO;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
@@ -20,7 +21,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
Action = ShowHiddenItems.Toggle,
|
||||
};
|
||||
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new BasicDirectorySelectorDirectory(directory, displayName);
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, LocalisableString? displayName = null) => new BasicDirectorySelectorDirectory(directory, displayName);
|
||||
|
||||
protected override DirectorySelectorDirectory CreateParentDirectoryItem(DirectoryInfo directory) => new BasicDirectorySelectorParentDirectory(directory);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
using System.IO;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
@@ -20,7 +21,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
|
||||
protected override DirectorySelectorDirectory CreateRootDirectoryItem() => new BreadcrumbDisplayComputer();
|
||||
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new BreadcrumbDisplayDirectory(directory, displayName);
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, LocalisableString? displayName = null) => new BreadcrumbDisplayDirectory(directory, displayName);
|
||||
|
||||
protected partial class BreadcrumbDisplayComputer : BreadcrumbDisplayDirectory
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
{
|
||||
protected override IconUsage? Icon => Directory.Name.Contains(Path.DirectorySeparatorChar) ? base.Icon : null;
|
||||
|
||||
public BreadcrumbDisplayDirectory(DirectoryInfo directory, string displayName = null)
|
||||
public BreadcrumbDisplayDirectory(DirectoryInfo directory, LocalisableString? displayName = null)
|
||||
: base(directory, displayName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
using System.IO;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
Font = FrameworkFont.Regular.With(size: FONT_SIZE)
|
||||
};
|
||||
|
||||
public BasicDirectorySelectorDirectory(DirectoryInfo directory, string displayName = null)
|
||||
public BasicDirectorySelectorDirectory(DirectoryInfo directory, LocalisableString? displayName = null)
|
||||
: base(directory, displayName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
using System.IO;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
@@ -26,7 +27,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
Action = ShowHiddenItems.Toggle,
|
||||
};
|
||||
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null) => new BasicDirectorySelectorDirectory(directory, displayName);
|
||||
protected override DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, LocalisableString? displayName = null) => new BasicDirectorySelectorDirectory(directory, displayName);
|
||||
|
||||
protected override DirectorySelectorDirectory CreateParentDirectoryItem(DirectoryInfo directory) => new BasicDirectorySelectorParentDirectory(directory);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osuTK;
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
/// </remarks>
|
||||
protected virtual Drawable CreateHiddenToggleButton() => Empty();
|
||||
|
||||
protected abstract DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null);
|
||||
protected abstract DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, LocalisableString? displayName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Create the directory item that resolves the parent directory.
|
||||
|
||||
@@ -10,6 +10,7 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
@@ -25,7 +26,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
/// <summary>
|
||||
/// Create a directory item in the breadcrumb trail.
|
||||
/// </summary>
|
||||
protected abstract DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, string displayName = null);
|
||||
protected abstract DirectorySelectorDirectory CreateDirectoryItem(DirectoryInfo directory, LocalisableString? displayName = null);
|
||||
|
||||
/// <summary>
|
||||
/// Create the root directory item in the breadcrumb trail.
|
||||
|
||||
@@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
[Resolved]
|
||||
private Bindable<DirectoryInfo> currentDirectory { get; set; }
|
||||
|
||||
protected DirectorySelectorDirectory(DirectoryInfo directory, string displayName = null)
|
||||
protected DirectorySelectorDirectory(DirectoryInfo directory, LocalisableString? displayName = null)
|
||||
: base(displayName)
|
||||
{
|
||||
Directory = directory;
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Graphics.UserInterface
|
||||
{
|
||||
public abstract partial class DirectorySelectorItem : CompositeDrawable
|
||||
{
|
||||
private readonly string displayName;
|
||||
private readonly LocalisableString? displayName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the font size of this <see cref="DirectorySelectorItem"/>'s icon and text.
|
||||
@@ -31,7 +32,7 @@ namespace osu.Framework.Graphics.UserInterface
|
||||
|
||||
protected FillFlowContainer Flow;
|
||||
|
||||
protected DirectorySelectorItem(string displayName = null)
|
||||
protected DirectorySelectorItem(LocalisableString? displayName = null)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@@ -533,11 +533,36 @@ namespace osu.Framework.Platform.SDL3
|
||||
|
||||
private void handleKeymapChangedEvent() => KeymapChanged?.Invoke();
|
||||
|
||||
private readonly bool penProximityWorkaround = RuntimeInfo.OS == RuntimeInfo.Platform.Android;
|
||||
|
||||
private bool tryGetPenDeviceType(SDL_PenID penID, out TabletPenDeviceType deviceType)
|
||||
{
|
||||
if (penDeviceTypes.TryGetValue(penID, out deviceType))
|
||||
return true;
|
||||
|
||||
// Workaround for Android: after clicking with a pen, it can send motion and touch events even though we've received SDL_EVENT_PEN_PROXIMITY_OUT.
|
||||
// It's either a bug in Android or SDL.
|
||||
// Instead of ignoring those events, fetch the type and store it.
|
||||
if (penProximityWorkaround)
|
||||
{
|
||||
var sdlType = SDL_GetPenDeviceType(penID);
|
||||
|
||||
if (sdlType == SDL_PenDeviceType.SDL_PEN_DEVICE_TYPE_INVALID)
|
||||
return false;
|
||||
|
||||
deviceType = sdlType.ToTabletPenDeviceType();
|
||||
penDeviceTypes[penID] = deviceType;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handlePenProximityEvent(SDL_PenProximityEvent evtPenProximity)
|
||||
{
|
||||
if (evtPenProximity.type == SDL_EventType.SDL_EVENT_PEN_PROXIMITY_IN)
|
||||
{
|
||||
if (penDeviceTypes.ContainsKey(evtPenProximity.which))
|
||||
if (!penProximityWorkaround && penDeviceTypes.ContainsKey(evtPenProximity.which))
|
||||
Logger.Log($"Unexpected SDL_EVENT_PEN_PROXIMITY_IN for pen id={evtPenProximity.which}. Pen already in proximity.", level: LogLevel.Important);
|
||||
|
||||
penDeviceTypes[evtPenProximity.which] = SDL_GetPenDeviceType(evtPenProximity.which).ThrowIfFailed().ToTabletPenDeviceType();
|
||||
@@ -551,7 +576,7 @@ namespace osu.Framework.Platform.SDL3
|
||||
|
||||
private void handlePenMotionEvent(SDL_PenMotionEvent evtPenMotion)
|
||||
{
|
||||
if (penDeviceTypes.TryGetValue(evtPenMotion.which, out var type))
|
||||
if (tryGetPenDeviceType(evtPenMotion.which, out var type))
|
||||
PenMove?.Invoke(type, new Vector2(evtPenMotion.x, evtPenMotion.y) * Scale, evtPenMotion.pen_state.HasFlagFast(SDL_PenInputFlags.SDL_PEN_INPUT_DOWN));
|
||||
else
|
||||
Logger.Log($"Unexpected SDL_EVENT_PEN_MOTION for pen id={evtPenMotion.which}. Pen not in proximity.", level: LogLevel.Important);
|
||||
@@ -559,7 +584,7 @@ namespace osu.Framework.Platform.SDL3
|
||||
|
||||
private void handlePenTouchEvent(SDL_PenTouchEvent evtPenTouch)
|
||||
{
|
||||
if (penDeviceTypes.TryGetValue(evtPenTouch.which, out var type))
|
||||
if (tryGetPenDeviceType(evtPenTouch.which, out var type))
|
||||
PenTouch?.Invoke(type, evtPenTouch.down, new Vector2(evtPenTouch.x, evtPenTouch.y) * Scale);
|
||||
else
|
||||
Logger.Log($"Unexpected {evtPenTouch.type} for pen id={evtPenTouch.which}. Pen not in proximity.", level: LogLevel.Important);
|
||||
|
||||
Reference in New Issue
Block a user