Compare commits

...

2 Commits

Author SHA1 Message Date
6670667ff6 Fix some broken dependencies. 2024-07-18 20:34:39 +03:00
d06264e424 Rename some classes to fit the new names. 2024-07-18 20:28:02 +03:00
10 changed files with 56 additions and 61 deletions

@ -9,7 +9,7 @@ using Dashboard.PAL;
namespace Dashboard.OpenTK namespace Dashboard.OpenTK
{ {
public class OpenTKPlatform : IQuikPlatform public class OpenTKPlatform : IDashboardPlatform
{ {
private readonly List<OpenTKPort> _ports = new List<OpenTKPort>(); private readonly List<OpenTKPort> _ports = new List<OpenTKPort>();
@ -25,7 +25,7 @@ namespace Dashboard.OpenTK
private bool IsGLInitialized = false; private bool IsGLInitialized = false;
public IQuikPortHandle CreatePort() public IDashHandle CreatePort()
{ {
NativeWindow window = new NativeWindow(DefaultSettings); NativeWindow window = new NativeWindow(DefaultSettings);
OpenTKPort port = new OpenTKPort(window); OpenTKPort port = new OpenTKPort(window);
@ -62,31 +62,31 @@ namespace Dashboard.OpenTK
NativeWindow.ProcessWindowEvents(block); NativeWindow.ProcessWindowEvents(block);
} }
public void DestroyPort(IQuikPortHandle port) => ((OpenTKPort)port).Dispose(); public void DestroyPort(IDashHandle port) => ((OpenTKPort)port).Dispose();
public string PortGetTitle(IQuikPortHandle port) => ((OpenTKPort)port).Title; public string PortGetTitle(IDashHandle port) => ((OpenTKPort)port).Title;
public void PortSetTitle(IQuikPortHandle port, string title) => ((OpenTKPort)port).Title = title; public void PortSetTitle(IDashHandle port, string title) => ((OpenTKPort)port).Title = title;
public QVec2 PortGetSize(IQuikPortHandle port) => ((OpenTKPort)port).Size; public QVec2 PortGetSize(IDashHandle port) => ((OpenTKPort)port).Size;
public void PortSetSize(IQuikPortHandle port, QVec2 size) => ((OpenTKPort)port).Size = size; public void PortSetSize(IDashHandle port, QVec2 size) => ((OpenTKPort)port).Size = size;
public QVec2 PortGetPosition(IQuikPortHandle port) => ((OpenTKPort)port).Position; public QVec2 PortGetPosition(IDashHandle port) => ((OpenTKPort)port).Position;
public void PortSetPosition(IQuikPortHandle port, QVec2 position) => ((OpenTKPort)port).Position = position; public void PortSetPosition(IDashHandle port, QVec2 position) => ((OpenTKPort)port).Position = position;
public bool PortIsValid(IQuikPortHandle port) => ((OpenTKPort)port).IsValid; public bool PortIsValid(IDashHandle port) => ((OpenTKPort)port).IsValid;
public void PortSubscribeEvent(IQuikPortHandle port, EventHandler handler) => ((OpenTKPort)port).EventRaised += handler; public void PortSubscribeEvent(IDashHandle port, EventHandler handler) => ((OpenTKPort)port).EventRaised += handler;
public void PortUnsubscribeEvent(IQuikPortHandle port, EventHandler handler) => ((OpenTKPort)port).EventRaised -= handler; public void PortUnsubscribeEvent(IDashHandle port, EventHandler handler) => ((OpenTKPort)port).EventRaised -= handler;
public void PortFocus(IQuikPortHandle port) => ((OpenTKPort)port).Focus(); public void PortFocus(IDashHandle port) => ((OpenTKPort)port).Focus();
public void PortShow(IQuikPortHandle port, bool shown = true) => ((OpenTKPort)port).Show(shown); public void PortShow(IDashHandle port, bool shown = true) => ((OpenTKPort)port).Show(shown);
public void PortPaint(IQuikPortHandle port, CommandList commands) => ((OpenTKPort)port).Paint(commands); public void PortPaint(IDashHandle port, CommandList commands) => ((OpenTKPort)port).Paint(commands);
public void GetMaximumImage(out int width, out int height) public void GetMaximumImage(out int width, out int height)
{ {

@ -8,7 +8,7 @@ using Dashboard.VertexGenerator;
namespace Dashboard.OpenTK namespace Dashboard.OpenTK
{ {
public class OpenTKPort : IQuikPortHandle public class OpenTKPort : IDashHandle
{ {
private readonly NativeWindow _window; private readonly NativeWindow _window;
private readonly GL21Driver _glDriver; private readonly GL21Driver _glDriver;

@ -7,9 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard", "Dashboard\Dash
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard.Media.Defaults", "Dashboard.Media.Defaults\Dashboard.Media.Defaults.csproj", "{3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard.Media.Defaults", "Dashboard.Media.Defaults\Dashboard.Media.Defaults.csproj", "{3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AE0F4030-F24D-47D0-ACDE-2E13340E617B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dashboard.OpenTK", "Dashboard.OpenTK\Dashboard.OpenTK.csproj", "{2013470A-915C-46F2-BDD3-FCAA39C845EE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DashboardDemo", "tests\Dashboard.Demo\DashboardDemo.csproj", "{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -28,12 +26,9 @@ Global
{3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Debug|Any CPU.Build.0 = Debug|Any CPU {3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Release|Any CPU.ActiveCfg = Release|Any CPU {3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Release|Any CPU.Build.0 = Release|Any CPU {3798F6DD-8F84-4B7D-A810-B0D4B5ACB672}.Release|Any CPU.Build.0 = Release|Any CPU
{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2013470A-915C-46F2-BDD3-FCAA39C845EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B}.Debug|Any CPU.Build.0 = Debug|Any CPU {2013470A-915C-46F2-BDD3-FCAA39C845EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B}.Release|Any CPU.ActiveCfg = Release|Any CPU {2013470A-915C-46F2-BDD3-FCAA39C845EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B}.Release|Any CPU.Build.0 = Release|Any CPU {2013470A-915C-46F2-BDD3-FCAA39C845EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1D65CA5B-E6CA-43CA-B957-320BE5BCE77B} = {AE0F4030-F24D-47D0-ACDE-2E13340E617B}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

@ -59,14 +59,14 @@ namespace Dashboard.Media
{ {
Size = size; Size = size;
QuikApplication.Current.Platform.GetMaximumImage(out int height, out int width); DashboardApplication.Current.Platform.GetMaximumImage(out int height, out int width);
// Do no allow to create a texture that is greater than 16 square characters at 200 DPI. // Do no allow to create a texture that is greater than 16 square characters at 200 DPI.
width = Math.Min(width, (int)(size * 200 * 16)); width = Math.Min(width, (int)(size * 200 * 16));
height = Math.Min(height, (int)(size * 200 * 16)); height = Math.Min(height, (int)(size * 200 * 16));
// width = height = 256; // width = height = 256;
atlas = new FontAtlas(width, height, QuikApplication.Current.FontProvider.RasterizerOptions.Sdf); atlas = new FontAtlas(width, height, DashboardApplication.Current.FontProvider.RasterizerOptions.Sdf);
} }
public void Get(int codepoint, out FontGlyph glyph, QFont font) public void Get(int codepoint, out FontGlyph glyph, QFont font)
@ -78,7 +78,7 @@ namespace Dashboard.Media
out QGlyphMetrics metrics, out QGlyphMetrics metrics,
codepoint, codepoint,
Size, Size,
QuikApplication.Current.FontProvider.RasterizerOptions); DashboardApplication.Current.FontProvider.RasterizerOptions);
if (image != null) if (image != null)
{ {

@ -11,10 +11,10 @@ namespace Dashboard.PAL
/// <summary> /// <summary>
/// An abstraction layer over the UI input and output. /// An abstraction layer over the UI input and output.
/// </summary> /// </summary>
public class QuikPort public class Dash
{ {
private readonly IQuikPortHandle handle; private readonly IDashHandle handle;
private readonly IQuikPlatform platform; private readonly IDashboardPlatform platform;
public string Title public string Title
{ {
@ -50,7 +50,7 @@ namespace Dashboard.PAL
} }
} }
public QuikPort(IQuikPlatform platform) public Dash(IDashboardPlatform platform)
{ {
this.platform = platform; this.platform = platform;
handle = platform.CreatePort(); handle = platform.CreatePort();

@ -7,14 +7,14 @@ namespace Dashboard.PAL
/// <summary> /// <summary>
/// An empty interface to statically type Quik port handles. /// An empty interface to statically type Quik port handles.
/// </summary> /// </summary>
public interface IQuikPortHandle public interface IDashHandle
{ {
} }
/// <summary> /// <summary>
/// The primary primary platform abstraction interface for Quik hosts. /// The primary primary platform abstraction interface for dashboard hosts.
/// </summary> /// </summary>
public interface IQuikPlatform : IDisposable public interface IDashboardPlatform : IDisposable
{ {
/// <summary> /// <summary>
/// The title of the application. /// The title of the application.
@ -41,20 +41,20 @@ namespace Dashboard.PAL
/// Create a window. /// Create a window.
/// </summary> /// </summary>
/// <returns>The window instance.</returns> /// <returns>The window instance.</returns>
IQuikPortHandle CreatePort(); IDashHandle CreatePort();
void DestroyPort(IQuikPortHandle port); void DestroyPort(IDashHandle port);
string PortGetTitle(IQuikPortHandle port); string PortGetTitle(IDashHandle port);
void PortSetTitle(IQuikPortHandle port, string title); void PortSetTitle(IDashHandle port, string title);
QVec2 PortGetSize(IQuikPortHandle port); QVec2 PortGetSize(IDashHandle port);
void PortSetSize(IQuikPortHandle port, QVec2 size); void PortSetSize(IDashHandle port, QVec2 size);
QVec2 PortGetPosition(IQuikPortHandle port); QVec2 PortGetPosition(IDashHandle port);
void PortSetPosition(IQuikPortHandle port, QVec2 position); void PortSetPosition(IDashHandle port, QVec2 position);
bool PortIsValid(IQuikPortHandle port); bool PortIsValid(IDashHandle port);
void PortSubscribeEvent(IQuikPortHandle port, EventHandler handler); void PortSubscribeEvent(IDashHandle port, EventHandler handler);
void PortUnsubscribeEvent(IQuikPortHandle port, EventHandler handler); void PortUnsubscribeEvent(IDashHandle port, EventHandler handler);
void PortFocus(IQuikPortHandle port); void PortFocus(IDashHandle port);
void PortShow(IQuikPortHandle port, bool shown = true); void PortShow(IDashHandle port, bool shown = true);
void PortPaint(IQuikPortHandle port, CommandList commands); void PortPaint(IDashHandle port, CommandList commands);
void GetMaximumImage(out int width, out int height); void GetMaximumImage(out int width, out int height);
void GetMaximumImage(out int width, out int height, out int depth); void GetMaximumImage(out int width, out int height, out int depth);
} }

@ -12,12 +12,12 @@ namespace Dashboard
/// <summary> /// <summary>
/// Main class for Quik applications. /// Main class for Quik applications.
/// </summary> /// </summary>
public class QuikApplication public class DashboardApplication
{ {
/// <summary> /// <summary>
/// The application platform driver. /// The application platform driver.
/// </summary> /// </summary>
public IQuikPlatform Platform { get; } public IDashboardPlatform Platform { get; }
/// <summary> /// <summary>
/// Title of the application. /// Title of the application.
@ -37,7 +37,7 @@ namespace Dashboard
set => Platform.Icon = value; set => Platform.Icon = value;
} }
public QuikPort? MainPort { get; private set; } = null; public PAL.Dash? MainPort { get; private set; } = null;
public FontProvider FontProvider { get; } public FontProvider FontProvider { get; }
@ -46,7 +46,7 @@ namespace Dashboard
/// </summary> /// </summary>
public List<MediaLoader> MediaLoaders { get; } = new List<MediaLoader>(); public List<MediaLoader> MediaLoaders { get; } = new List<MediaLoader>();
public QuikApplication(IQuikPlatform platform) public DashboardApplication(IDashboardPlatform platform)
{ {
Platform = platform; Platform = platform;
FontProvider = new FontProvider(this); FontProvider = new FontProvider(this);
@ -103,7 +103,7 @@ namespace Dashboard
public void Init(View mainView) public void Init(View mainView)
{ {
MainPort = new QuikPort(Platform) { UIElement = mainView }; MainPort = new PAL.Dash(Platform) { UIElement = mainView };
MainPort.EventRaised += (sender, ea) => mainView.NotifyEvent(sender, ea); MainPort.EventRaised += (sender, ea) => mainView.NotifyEvent(sender, ea);
} }
@ -123,9 +123,9 @@ namespace Dashboard
return true; return true;
} }
public static QuikApplication Current { get; private set; } = null!; public static DashboardApplication Current { get; private set; } = null!;
public static void SetCurrentApplication(QuikApplication application) public static void SetCurrentApplication(DashboardApplication application)
{ {
Current = application; Current = application;
} }

@ -18,7 +18,7 @@ namespace Dashboard.Typography
public readonly FontRasterizerOptions RasterizerOptions; public readonly FontRasterizerOptions RasterizerOptions;
public IFontDataBase? Database { get; set; } public IFontDataBase? Database { get; set; }
public IFontFactory? FontFactory { get; set; } public IFontFactory? FontFactory { get; set; }
private readonly QuikApplication App; private readonly DashboardApplication App;
public QFont this[FontFace info] public QFont this[FontFace info]
{ {
@ -51,7 +51,7 @@ namespace Dashboard.Typography
} }
} }
public FontProvider(QuikApplication app, in FontRasterizerOptions options) public FontProvider(DashboardApplication app, in FontRasterizerOptions options)
{ {
RasterizerOptions = options; RasterizerOptions = options;
App = app; App = app;
@ -73,7 +73,7 @@ namespace Dashboard.Typography
FontFactory = (IFontFactory?)ctor?.Invoke(null); FontFactory = (IFontFactory?)ctor?.Invoke(null);
} }
} }
public FontProvider(QuikApplication app) public FontProvider(DashboardApplication app)
: this(app, FontRasterizerOptions.Default) : this(app, FontRasterizerOptions.Default)
{ {
} }

@ -10,7 +10,7 @@ namespace Dashboard.Demo
{ {
public static class Program public static class Program
{ {
public static readonly QuikApplication Application = new QuikApplication(new OpenTKPlatform()); public static readonly DashboardApplication Application = new DashboardApplication(new OpenTKPlatform());
public static void Main(string[] args) public static void Main(string[] args)
{ {