Prep
Now using sln for project Changed a lot of the control's getting ready to move to https://git.jacobtech.com
This commit is contained in:
parent
91db2b6471
commit
b10a10fede
428
.gitignore
vendored
428
.gitignore
vendored
@ -1,350 +1,78 @@
|
|||||||
## Ignore Visual Studio temporary files, build results, and
|
# ---> JetBrains
|
||||||
## files generated by popular Visual Studio add-ons.
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
##
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
|
||||||
|
# User-specific stuff
|
||||||
# User-specific files
|
.idea/**/workspace.xml
|
||||||
*.rsuser
|
.idea/**/tasks.xml
|
||||||
*.suo
|
.idea/**/usage.statistics.xml
|
||||||
*.user
|
.idea/**/dictionaries
|
||||||
*.userosscache
|
.idea/**/shelf
|
||||||
*.sln.docstates
|
|
||||||
|
# AWS User-specific
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
.idea/**/aws.xml
|
||||||
*.userprefs
|
|
||||||
|
# Generated files
|
||||||
# Mono auto generated files
|
.idea/**/contentModel.xml
|
||||||
mono_crash.*
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
# Build results
|
.idea/**/dataSources/
|
||||||
[Dd]ebug/
|
.idea/**/dataSources.ids
|
||||||
[Dd]ebugPublic/
|
.idea/**/dataSources.local.xml
|
||||||
[Rr]elease/
|
.idea/**/sqlDataSources.xml
|
||||||
[Rr]eleases/
|
.idea/**/dynamic.xml
|
||||||
x64/
|
.idea/**/uiDesigner.xml
|
||||||
x86/
|
.idea/**/dbnavigator.xml
|
||||||
[Aa][Rr][Mm]/
|
|
||||||
[Aa][Rr][Mm]64/
|
# Gradle
|
||||||
bld/
|
.idea/**/gradle.xml
|
||||||
[Bb]in/
|
.idea/**/libraries
|
||||||
[Oo]bj/
|
|
||||||
[Ll]og/
|
# Gradle and Maven with auto-import
|
||||||
[Ll]ogs/
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
# Visual Studio 2015/2017 cache/options directory
|
# auto-import.
|
||||||
.vs/
|
# .idea/artifacts
|
||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
# .idea/compiler.xml
|
||||||
#wwwroot/
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
# Visual Studio 2017 auto generated files
|
# .idea/*.iml
|
||||||
Generated\ Files/
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
# MSTest test Results
|
# *.ipr
|
||||||
[Tt]est[Rr]esult*/
|
|
||||||
[Bb]uild[Ll]og.*
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
# NUnit
|
|
||||||
*.VisualState.xml
|
# Mongo Explorer plugin
|
||||||
TestResult.xml
|
.idea/**/mongoSettings.xml
|
||||||
nunit-*.xml
|
|
||||||
|
# File-based project format
|
||||||
# Build Results of an ATL Project
|
*.iws
|
||||||
[Dd]ebugPS/
|
|
||||||
[Rr]eleasePS/
|
# IntelliJ
|
||||||
dlldata.c
|
out/
|
||||||
|
|
||||||
# Benchmark Results
|
# mpeltonen/sbt-idea plugin
|
||||||
BenchmarkDotNet.Artifacts/
|
.idea_modules/
|
||||||
|
|
||||||
# .NET Core
|
# JIRA plugin
|
||||||
project.lock.json
|
atlassian-ide-plugin.xml
|
||||||
project.fragment.lock.json
|
|
||||||
artifacts/
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
# StyleCop
|
|
||||||
StyleCopReport.xml
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
# Files built by Visual Studio
|
|
||||||
*_i.c
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
*_p.c
|
com_crashlytics_export_strings.xml
|
||||||
*_h.h
|
crashlytics.properties
|
||||||
*.ilk
|
crashlytics-build.properties
|
||||||
*.meta
|
fabric.properties
|
||||||
*.obj
|
|
||||||
*.iobj
|
# Editor-based Rest Client
|
||||||
*.pch
|
.idea/httpRequests
|
||||||
*.pdb
|
|
||||||
*.ipdb
|
# Android studio 3.1+ serialized cache file
|
||||||
*.pgc
|
.idea/caches/build_file_checksums.ser
|
||||||
*.pgd
|
|
||||||
*.rsp
|
|
||||||
*.sbr
|
|
||||||
*.tlb
|
|
||||||
*.tli
|
|
||||||
*.tlh
|
|
||||||
*.tmp
|
|
||||||
*.tmp_proj
|
|
||||||
*_wpftmp.csproj
|
|
||||||
*.log
|
|
||||||
*.vspscc
|
|
||||||
*.vssscc
|
|
||||||
.builds
|
|
||||||
*.pidb
|
|
||||||
*.svclog
|
|
||||||
*.scc
|
|
||||||
|
|
||||||
# Chutzpah Test files
|
|
||||||
_Chutzpah*
|
|
||||||
|
|
||||||
# Visual C++ cache files
|
|
||||||
ipch/
|
|
||||||
*.aps
|
|
||||||
*.ncb
|
|
||||||
*.opendb
|
|
||||||
*.opensdf
|
|
||||||
*.sdf
|
|
||||||
*.cachefile
|
|
||||||
*.VC.db
|
|
||||||
*.VC.VC.opendb
|
|
||||||
|
|
||||||
# Visual Studio profiler
|
|
||||||
*.psess
|
|
||||||
*.vsp
|
|
||||||
*.vspx
|
|
||||||
*.sap
|
|
||||||
|
|
||||||
# Visual Studio Trace Files
|
|
||||||
*.e2e
|
|
||||||
|
|
||||||
# TFS 2012 Local Workspace
|
|
||||||
$tf/
|
|
||||||
|
|
||||||
# Guidance Automation Toolkit
|
|
||||||
*.gpState
|
|
||||||
|
|
||||||
# ReSharper is a .NET coding add-in
|
|
||||||
_ReSharper*/
|
|
||||||
*.[Rr]e[Ss]harper
|
|
||||||
*.DotSettings.user
|
|
||||||
|
|
||||||
# TeamCity is a build add-in
|
|
||||||
_TeamCity*
|
|
||||||
|
|
||||||
# DotCover is a Code Coverage Tool
|
|
||||||
*.dotCover
|
|
||||||
|
|
||||||
# AxoCover is a Code Coverage Tool
|
|
||||||
.axoCover/*
|
|
||||||
!.axoCover/settings.json
|
|
||||||
|
|
||||||
# Visual Studio code coverage results
|
|
||||||
*.coverage
|
|
||||||
*.coveragexml
|
|
||||||
|
|
||||||
# NCrunch
|
|
||||||
_NCrunch_*
|
|
||||||
.*crunch*.local.xml
|
|
||||||
nCrunchTemp_*
|
|
||||||
|
|
||||||
# MightyMoose
|
|
||||||
*.mm.*
|
|
||||||
AutoTest.Net/
|
|
||||||
|
|
||||||
# Web workbench (sass)
|
|
||||||
.sass-cache/
|
|
||||||
|
|
||||||
# Installshield output folder
|
|
||||||
[Ee]xpress/
|
|
||||||
|
|
||||||
# DocProject is a documentation generator add-in
|
|
||||||
DocProject/buildhelp/
|
|
||||||
DocProject/Help/*.HxT
|
|
||||||
DocProject/Help/*.HxC
|
|
||||||
DocProject/Help/*.hhc
|
|
||||||
DocProject/Help/*.hhk
|
|
||||||
DocProject/Help/*.hhp
|
|
||||||
DocProject/Help/Html2
|
|
||||||
DocProject/Help/html
|
|
||||||
|
|
||||||
# Click-Once directory
|
|
||||||
publish/
|
|
||||||
|
|
||||||
# Publish Web Output
|
|
||||||
*.[Pp]ublish.xml
|
|
||||||
*.azurePubxml
|
|
||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
|
||||||
# but database connection strings (with potential passwords) will be unencrypted
|
|
||||||
*.pubxml
|
|
||||||
*.publishproj
|
|
||||||
|
|
||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
|
||||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
|
||||||
# in these scripts will be unencrypted
|
|
||||||
PublishScripts/
|
|
||||||
|
|
||||||
# NuGet Packages
|
|
||||||
*.nupkg
|
|
||||||
# NuGet Symbol Packages
|
|
||||||
*.snupkg
|
|
||||||
# The packages folder can be ignored because of Package Restore
|
|
||||||
**/[Pp]ackages/*
|
|
||||||
# except build/, which is used as an MSBuild target.
|
|
||||||
!**/[Pp]ackages/build/
|
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
|
||||||
#!**/[Pp]ackages/repositories.config
|
|
||||||
# NuGet v3's project.json files produces more ignorable files
|
|
||||||
*.nuget.props
|
|
||||||
*.nuget.targets
|
|
||||||
|
|
||||||
# Microsoft Azure Build Output
|
|
||||||
csx/
|
|
||||||
*.build.csdef
|
|
||||||
|
|
||||||
# Microsoft Azure Emulator
|
|
||||||
ecf/
|
|
||||||
rcf/
|
|
||||||
|
|
||||||
# Windows Store app package directories and files
|
|
||||||
AppPackages/
|
|
||||||
BundleArtifacts/
|
|
||||||
Package.StoreAssociation.xml
|
|
||||||
_pkginfo.txt
|
|
||||||
*.appx
|
|
||||||
*.appxbundle
|
|
||||||
*.appxupload
|
|
||||||
|
|
||||||
# Visual Studio cache files
|
|
||||||
# files ending in .cache can be ignored
|
|
||||||
*.[Cc]ache
|
|
||||||
# but keep track of directories ending in .cache
|
|
||||||
!?*.[Cc]ache/
|
|
||||||
|
|
||||||
# Others
|
|
||||||
ClientBin/
|
|
||||||
~$*
|
|
||||||
*~
|
|
||||||
*.dbmdl
|
|
||||||
*.dbproj.schemaview
|
|
||||||
*.jfm
|
|
||||||
*.pfx
|
|
||||||
*.publishsettings
|
|
||||||
orleans.codegen.cs
|
|
||||||
|
|
||||||
# Including strong name files can present a security risk
|
|
||||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
|
||||||
#*.snk
|
|
||||||
|
|
||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
|
||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
|
||||||
#bower_components/
|
|
||||||
|
|
||||||
# RIA/Silverlight projects
|
|
||||||
Generated_Code/
|
|
||||||
|
|
||||||
# Backup & report files from converting an old project file
|
|
||||||
# to a newer Visual Studio version. Backup files are not needed,
|
|
||||||
# because we have git ;-)
|
|
||||||
_UpgradeReport_Files/
|
|
||||||
Backup*/
|
|
||||||
UpgradeLog*.XML
|
|
||||||
UpgradeLog*.htm
|
|
||||||
ServiceFabricBackup/
|
|
||||||
*.rptproj.bak
|
|
||||||
|
|
||||||
# SQL Server files
|
|
||||||
*.mdf
|
|
||||||
*.ldf
|
|
||||||
*.ndf
|
|
||||||
|
|
||||||
# Business Intelligence projects
|
|
||||||
*.rdl.data
|
|
||||||
*.bim.layout
|
|
||||||
*.bim_*.settings
|
|
||||||
*.rptproj.rsuser
|
|
||||||
*- [Bb]ackup.rdl
|
|
||||||
*- [Bb]ackup ([0-9]).rdl
|
|
||||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
|
||||||
|
|
||||||
# Microsoft Fakes
|
|
||||||
FakesAssemblies/
|
|
||||||
|
|
||||||
# GhostDoc plugin setting file
|
|
||||||
*.GhostDoc.xml
|
|
||||||
|
|
||||||
# Node.js Tools for Visual Studio
|
|
||||||
.ntvs_analysis.dat
|
|
||||||
node_modules/
|
|
||||||
|
|
||||||
# Visual Studio 6 build log
|
|
||||||
*.plg
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace options file
|
|
||||||
*.opt
|
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
|
||||||
*.vbw
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
|
||||||
**/*.DesktopClient/ModelManifest.xml
|
|
||||||
**/*.Server/GeneratedArtifacts
|
|
||||||
**/*.Server/ModelManifest.xml
|
|
||||||
_Pvt_Extensions
|
|
||||||
|
|
||||||
# Paket dependency manager
|
|
||||||
.paket/paket.exe
|
|
||||||
paket-files/
|
|
||||||
|
|
||||||
# FAKE - F# Make
|
|
||||||
.fake/
|
|
||||||
|
|
||||||
# CodeRush personal settings
|
|
||||||
.cr/personal
|
|
||||||
|
|
||||||
# Python Tools for Visual Studio (PTVS)
|
|
||||||
__pycache__/
|
|
||||||
*.pyc
|
|
||||||
|
|
||||||
# Cake - Uncomment if you are using it
|
|
||||||
# tools/**
|
|
||||||
# !tools/packages.config
|
|
||||||
|
|
||||||
# Tabs Studio
|
|
||||||
*.tss
|
|
||||||
|
|
||||||
# Telerik's JustMock configuration file
|
|
||||||
*.jmconfig
|
|
||||||
|
|
||||||
# BizTalk build output
|
|
||||||
*.btp.cs
|
|
||||||
*.btm.cs
|
|
||||||
*.odx.cs
|
|
||||||
*.xsd.cs
|
|
||||||
|
|
||||||
# OpenCover UI analysis results
|
|
||||||
OpenCover/
|
|
||||||
|
|
||||||
# Azure Stream Analytics local run output
|
|
||||||
ASALocalRun/
|
|
||||||
|
|
||||||
# MSBuild Binary and Structured Log
|
|
||||||
*.binlog
|
|
||||||
|
|
||||||
# NVidia Nsight GPU debugger configuration file
|
|
||||||
*.nvuser
|
|
||||||
|
|
||||||
# MFractors (Xamarin productivity tool) working folder
|
|
||||||
.mfractor/
|
|
||||||
|
|
||||||
# Local History for Visual Studio
|
|
||||||
.localhistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
|
||||||
healthchecksdb
|
|
||||||
|
|
||||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
|
||||||
MigrationBackup/
|
|
||||||
|
|
||||||
# Ionide (cross platform F# VS Code tools) working folder
|
|
||||||
.ionide/
|
|
||||||
|
16
GraphicsManager.sln
Normal file
16
GraphicsManager.sln
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphicsManager", "GraphicsManager\GraphicsManager.csproj", "{5C6FC242-E345-4244-BDDE-FD5132BD7889}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5C6FC242-E345-4244-BDDE-FD5132BD7889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5C6FC242-E345-4244-BDDE-FD5132BD7889}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5C6FC242-E345-4244-BDDE-FD5132BD7889}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5C6FC242-E345-4244-BDDE-FD5132BD7889}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
1
GraphicsManager/Enums/ObjectAnchor.cs
Normal file → Executable file
1
GraphicsManager/Enums/ObjectAnchor.cs
Normal file → Executable file
@ -1,5 +1,6 @@
|
|||||||
namespace GraphicsManager.Enums;
|
namespace GraphicsManager.Enums;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum ObjectAnchor
|
public enum ObjectAnchor
|
||||||
{
|
{
|
||||||
Left = 0b_0001,
|
Left = 0b_0001,
|
||||||
|
7
GraphicsManager/Enums/Rendertype.cs
Executable file
7
GraphicsManager/Enums/Rendertype.cs
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
namespace GraphicsManager.Enums;
|
||||||
|
|
||||||
|
public enum Rendertype
|
||||||
|
{
|
||||||
|
Limit = 0b_0001,
|
||||||
|
ControlUpdates = 0b_0010,
|
||||||
|
}
|
@ -1,20 +1,38 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
|
<Authors>JacobTech</Authors>
|
||||||
|
<Company>JacobTech, LLC</Company>
|
||||||
|
<IncludeSymbols>False</IncludeSymbols>
|
||||||
|
<RepositoryUrl>https://github.com/JacobTech-com/GraphicsManager</RepositoryUrl>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
<Version>1.0.0-alpha2</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources/**"></EmbeddedResource>
|
<EmbeddedResource Include="Resources/**"></EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="OpenTK" Version="4.7.1" />
|
<Content Include="freetype6.dll">
|
||||||
<PackageReference Include="SharpFontCore" Version="0.1.1" />
|
<Pack>true</Pack>
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
|
<PackagePath>lib\$(TargetFramework)</PackagePath>
|
||||||
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" />
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenTK" Version="4.7.1" />
|
||||||
|
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
|
||||||
|
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CustomActionsAfterPack" AfterTargets="Pack">
|
||||||
|
<Message Text="Actions AfterPack: $(PackageId).$(PackageVersion).nupkg" Importance="high" />
|
||||||
|
<Exec Command="nuget push -Source https://nuget.jacobtech.com/v3/index.json bin/Release/$(PackageId).$(PackageVersion).nupkg" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
5
GraphicsManager/Interfaces/IParent.cs
Normal file → Executable file
5
GraphicsManager/Interfaces/IParent.cs
Normal file → Executable file
@ -5,9 +5,12 @@ namespace GraphicsManager.Interfaces;
|
|||||||
|
|
||||||
public interface IParent
|
public interface IParent
|
||||||
{
|
{
|
||||||
|
public Vector2 LocationAsFloat { get; }
|
||||||
|
public IParent? Parent { get; }
|
||||||
public Vector2i Size { get; }
|
public Vector2i Size { get; }
|
||||||
public void Resize(ResizeEventArgs e);
|
public void ParentResize(ResizeEventArgs e);
|
||||||
public float[] RctToFloat(int x, int y, int Width, int Height, bool hastexture = false, float z = 0.0f);
|
public float[] RctToFloat(int x, int y, int Width, int Height, bool hastexture = false, float z = 0.0f);
|
||||||
|
public Vector3 PointToVector(int x, int y, float z = 0.0f);
|
||||||
public float IntToFloat(int p, bool Invert = false);
|
public float IntToFloat(int p, bool Invert = false);
|
||||||
public float FloatToInt(float p, bool Invert = false);
|
public float FloatToInt(float p, bool Invert = false);
|
||||||
public event Action<MouseButtonEventArgs> MouseDown;
|
public event Action<MouseButtonEventArgs> MouseDown;
|
||||||
|
0
GraphicsManager/Interfaces/IRenderObject.cs
Normal file → Executable file
0
GraphicsManager/Interfaces/IRenderObject.cs
Normal file → Executable file
0
GraphicsManager/Interfaces/ITextureObject.cs
Normal file → Executable file
0
GraphicsManager/Interfaces/ITextureObject.cs
Normal file → Executable file
117
GraphicsManager/Objects/Core/Font.cs
Normal file → Executable file
117
GraphicsManager/Objects/Core/Font.cs
Normal file → Executable file
@ -1,9 +1,14 @@
|
|||||||
using System.Reflection;
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
using SharpFont;
|
||||||
|
|
||||||
namespace GraphicsManager.Objects.Core;
|
namespace GraphicsManager.Objects.Core;
|
||||||
|
|
||||||
public class Font
|
public class Font
|
||||||
{
|
{
|
||||||
|
private List<Face> _Faces = new();
|
||||||
|
private Library lib;
|
||||||
|
public IReadOnlyList<Face> Faces => _Faces.AsReadOnly();
|
||||||
public void SetEmbeddedFont(string Font, Assembly? Assembly = null)
|
public void SetEmbeddedFont(string Font, Assembly? Assembly = null)
|
||||||
{
|
{
|
||||||
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
||||||
@ -15,45 +20,127 @@ public class Font
|
|||||||
public static Font MakeEmbeddedFont(string Font, Assembly? Assembly = null)
|
public static Font MakeEmbeddedFont(string Font, Assembly? Assembly = null)
|
||||||
{
|
{
|
||||||
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
||||||
return new Font()
|
Font fontclass = new Font()
|
||||||
{
|
{
|
||||||
Assembly = Assembly,
|
Assembly = Assembly,
|
||||||
Embeded = true,
|
Embeded = true,
|
||||||
Name = Font,
|
Name = Font,
|
||||||
};
|
};
|
||||||
|
Library lib = new();
|
||||||
|
string Base = "GraphicsManager.Resources.Fonts.";
|
||||||
|
if (Assembly is not null) Base = string.Empty;
|
||||||
|
byte[] f = (Assembly is null
|
||||||
|
? Tools.GetResourceBytes(Base + Font)
|
||||||
|
: Tools.GetResourceBytes(Assembly!, $"{Base}{Font}"));
|
||||||
|
fontclass._Faces.Add(new Face(lib, f, 0));
|
||||||
|
//load the fucking system fonts
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process proc = new()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
proc.Start();
|
||||||
|
proc.WaitForExit();
|
||||||
|
string[] files = proc.StandardOutput.ReadToEnd().Split($":{Environment.NewLine}");
|
||||||
|
for (int i = 0; i < files.Length; i++)
|
||||||
|
{
|
||||||
|
fontclass._Faces.Add(new Face(lib, files[i], 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fontclass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Font MakeFontFromSystem()
|
||||||
|
{
|
||||||
|
|
||||||
|
Font fontclass = new()
|
||||||
|
{
|
||||||
|
Assembly = null,
|
||||||
|
Embeded = false,
|
||||||
|
Name = default!,
|
||||||
|
lib = new()
|
||||||
|
};
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process proc = new()
|
||||||
|
{
|
||||||
|
StartInfo = new()
|
||||||
|
{
|
||||||
|
FileName = "/bin/bash",
|
||||||
|
Arguments = "-c \"fc-list ':' file\"",
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
proc.Start();
|
||||||
|
proc.WaitForExit();
|
||||||
|
string[] files = proc.StandardOutput.ReadToEnd().Split($": {Environment.NewLine}");
|
||||||
|
for (int i = 0; i < files.Length; i++)
|
||||||
|
{
|
||||||
|
fontclass._Faces.Add(new Face(fontclass.lib, files[i], 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fontclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Font MakeFontFromFile(string Font)
|
public static Font MakeFontFromFile(string Font)
|
||||||
{
|
{
|
||||||
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
||||||
return new Font()
|
Font fontclass = new Font()
|
||||||
{
|
{
|
||||||
Assembly = null,
|
Assembly = null,
|
||||||
Embeded = false,
|
Embeded = false,
|
||||||
Name = Font,
|
Name = Font,
|
||||||
};
|
};
|
||||||
|
fontclass.lib = new();
|
||||||
|
fontclass._Faces.Add(new Face(fontclass.lib, File.ReadAllBytes(Font), 0));
|
||||||
|
//load the fucking system fonts
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process proc = new()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
proc.Start();
|
||||||
|
proc.WaitForExit();
|
||||||
|
string[] files = proc.StandardOutput.ReadToEnd().Split($":{Environment.NewLine}");
|
||||||
|
for (int i = 0; i < files.Length; i++)
|
||||||
|
{
|
||||||
|
fontclass._Faces.Add(new Face(fontclass.lib, files[i], 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fontclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFontFile(string Font)
|
public void SetFontFile(string Font)
|
||||||
{
|
{
|
||||||
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
_ = Font ?? throw new ArgumentNullException(nameof(Font));
|
||||||
|
_Faces.RemoveAt(0);
|
||||||
|
_Faces.Reverse();
|
||||||
|
_Faces.Add(new Face(lib, File.ReadAllBytes(Font), 0));
|
||||||
|
_Faces.Reverse();
|
||||||
this.Assembly = null;
|
this.Assembly = null;
|
||||||
this.Embeded = false;
|
this.Embeded = false;
|
||||||
this.Name = Font;
|
this.Name = Font;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] GetData()
|
public string Name { get; private set; } = default!;
|
||||||
{
|
|
||||||
if (Embeded)
|
|
||||||
{
|
|
||||||
string Base = "GraphicsManager.Resources.Fonts.";
|
|
||||||
if (Assembly is not null) Base = string.Empty;
|
|
||||||
return (Assembly is null ? Tools.GetResourceBytes(Base + Name) : Tools.GetResourceBytes(Assembly!, $"{Base}{Name}"));
|
|
||||||
}
|
|
||||||
return File.ReadAllBytes(Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; private set; } = "shal be default";
|
|
||||||
public bool Embeded { get; private set; }
|
public bool Embeded { get; private set; }
|
||||||
public Assembly? Assembly { get; private set; }
|
public Assembly? Assembly { get; private set; }
|
||||||
}
|
}
|
||||||
|
0
GraphicsManager/Objects/Core/Shader.cs
Normal file → Executable file
0
GraphicsManager/Objects/Core/Shader.cs
Normal file → Executable file
76
GraphicsManager/Objects/Core/Texture.cs
Normal file → Executable file
76
GraphicsManager/Objects/Core/Texture.cs
Normal file → Executable file
@ -41,44 +41,56 @@ public class Texture
|
|||||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Texture(Label l, char charter, uint PixelHeight, Face face)
|
private Texture()
|
||||||
{
|
{
|
||||||
if (!Label._characters.ContainsKey(l)) Label._characters.Add(l, new Dictionary<uint, Character>());
|
}
|
||||||
face.SetPixelSizes(0, PixelHeight);
|
|
||||||
|
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
internal static Texture TextureForChar(Label l, char charter, uint PixelHeight, Face[] faces)
|
||||||
|
{
|
||||||
GL.ActiveTexture(TextureUnit.Texture0);
|
Texture t = new();
|
||||||
face.SelectCharmap(Encoding.Unicode);
|
for (int i = 0; i < faces.Length; i++)
|
||||||
ushort temp = ((ushort)charter);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
face.LoadChar(temp, LoadFlags.Render, LoadTarget.Normal);
|
try
|
||||||
GlyphSlot glyph = face.Glyph;
|
|
||||||
FTBitmap bitmap = glyph.Bitmap;
|
|
||||||
|
|
||||||
handel = GL.GenTexture();
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, handel);
|
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0,
|
|
||||||
PixelInternalFormat.R8, bitmap.Width, bitmap.Rows, 0,
|
|
||||||
PixelFormat.Red, PixelType.UnsignedByte, bitmap.Buffer);
|
|
||||||
|
|
||||||
|
|
||||||
Character cha = new()
|
|
||||||
{
|
{
|
||||||
Size = new Vector2(bitmap.Width, bitmap.Rows),
|
if (!Label._characters.ContainsKey(l)) Label._characters.Add(l, new Dictionary<uint, Character>());
|
||||||
Bearing = new Vector2(glyph.BitmapLeft, glyph.BitmapTop),
|
if (Label._characters[l].ContainsKey(charter)) return Label._characters[l][(ushort)charter].Texture;
|
||||||
Advance = (int)glyph.Advance.X.Value,
|
faces[i].SetPixelSizes(0, PixelHeight);
|
||||||
Texture = this,
|
|
||||||
};
|
|
||||||
|
|
||||||
Label._characters[l].Add(temp, cha);
|
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
||||||
}
|
|
||||||
catch (Exception ex)
|
GL.ActiveTexture(TextureUnit.Texture0);
|
||||||
{
|
faces[i].SelectCharmap(Encoding.Unicode);
|
||||||
Console.WriteLine(ex);
|
ushort temp = ((ushort)charter);
|
||||||
|
if (faces[i].GetCharIndex(temp) == 0) continue;
|
||||||
|
faces[i].LoadChar(temp, LoadFlags.Render, LoadTarget.Normal);
|
||||||
|
GlyphSlot glyph = faces[i].Glyph;
|
||||||
|
FTBitmap bitmap = glyph.Bitmap;
|
||||||
|
|
||||||
|
t.handel = GL.GenTexture();
|
||||||
|
GL.BindTexture(TextureTarget.Texture2D, t.handel);
|
||||||
|
GL.TexImage2D(TextureTarget.Texture2D, 0,
|
||||||
|
PixelInternalFormat.R8, bitmap.Width, bitmap.Rows, 0,
|
||||||
|
PixelFormat.Red, PixelType.UnsignedByte, bitmap.Buffer);
|
||||||
|
|
||||||
|
|
||||||
|
Character cha = new()
|
||||||
|
{
|
||||||
|
Size = new Vector2(bitmap.Width, bitmap.Rows),
|
||||||
|
Bearing = new Vector2(glyph.BitmapLeft, glyph.BitmapTop),
|
||||||
|
Advance = (int)glyph.Advance.X.Value,
|
||||||
|
Texture = t,
|
||||||
|
};
|
||||||
|
|
||||||
|
Label._characters[l].Add(temp, cha);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadText()
|
public void LoadText()
|
||||||
|
16
GraphicsManager/Objects/Core/Uniform.cs
Executable file
16
GraphicsManager/Objects/Core/Uniform.cs
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
|
using Vector4 = OpenTK.Mathematics.Vector4;
|
||||||
|
|
||||||
|
namespace GraphicsManager.Objects.Core;
|
||||||
|
|
||||||
|
public record Uniform<TVertex> where TVertex : struct
|
||||||
|
{
|
||||||
|
public int Location { get; set; }
|
||||||
|
public TVertex Value { get; set; }
|
||||||
|
}
|
16
GraphicsManager/Objects/Core/Uniforms.cs
Executable file
16
GraphicsManager/Objects/Core/Uniforms.cs
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
using OpenTK.Mathematics;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GraphicsManager.Objects.Core;
|
||||||
|
|
||||||
|
public class Uniforms
|
||||||
|
{
|
||||||
|
public List<Uniform<Vector4>> Uniform4 { get; set; } = new();
|
||||||
|
public List<Uniform<Vector3>> Uniform3 { get; set; } = new();
|
||||||
|
public List<Uniform<Vector2>> Uniform2 { get; set; } = new();
|
||||||
|
public List<Uniform<float>> Uniform1 { get; set; } = new();
|
||||||
|
}
|
62
GraphicsManager/Objects/Label.cs
Normal file → Executable file
62
GraphicsManager/Objects/Label.cs
Normal file → Executable file
@ -5,7 +5,6 @@ using GraphicsManager.Structs;
|
|||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using SharpFont;
|
using SharpFont;
|
||||||
using System.Reflection;
|
|
||||||
using Encoding = SharpFont.Encoding;
|
using Encoding = SharpFont.Encoding;
|
||||||
|
|
||||||
namespace GraphicsManager.Objects;
|
namespace GraphicsManager.Objects;
|
||||||
@ -31,33 +30,25 @@ public class Label : IRenderObject
|
|||||||
get => text;
|
get => text;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
text = value;
|
||||||
if (Loaded)
|
if (Loaded)
|
||||||
{
|
{
|
||||||
Library lib = new();
|
|
||||||
Face face = new(lib, Font.GetData(), 0);
|
|
||||||
|
|
||||||
face.SetPixelSizes(0, PixelHeight);
|
|
||||||
|
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
||||||
|
|
||||||
face.SelectCharmap(Encoding.Unicode);
|
|
||||||
if (!_characters.ContainsKey(this)) _characters.Add(this, new Dictionary<uint, Character>());
|
if (!_characters.ContainsKey(this)) _characters.Add(this, new Dictionary<uint, Character>());
|
||||||
foreach (char character in value)
|
foreach (char character in value)
|
||||||
{
|
{
|
||||||
if (_characters[this].ContainsKey(character) == false)
|
if (_characters[this].ContainsKey(character)) continue;
|
||||||
{
|
var f = Texture.TextureForChar(this, character, PixelHeight, Font.Faces.ToArray());
|
||||||
var f = new Texture(this, character, PixelHeight, face);
|
f.LoadText();
|
||||||
f.LoadText();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (Window is not null && Window.CanControleUpdate && Loaded) Window.DrawFrame();
|
||||||
}
|
}
|
||||||
text = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public uint PixelHeight { get; set; } = 20;
|
public uint PixelHeight { get; set; } = 20;
|
||||||
public float Scale { get; set; } = 1.2f;
|
public float Scale { get; set; } = 1.0f;
|
||||||
public Shader Shader { get; } = DefaultTextShader;
|
public Shader Shader { get; set; } = DefaultTextShader;
|
||||||
public Font Font { get; set; } = Font.MakeEmbeddedFont("TektonPro-Regular.otf");
|
public Font Font { get; set; } = Font.MakeFontFromSystem();
|
||||||
|
|
||||||
public Vector4 Color { get; set; } = new Vector4(1, 1, 1, 1);
|
public Vector4 Color { get; set; } = new Vector4(1, 1, 1, 1);
|
||||||
public Vector2i Distance { get; private set; }
|
public Vector2i Distance { get; private set; }
|
||||||
@ -71,10 +62,10 @@ public class Label : IRenderObject
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
||||||
loc_ = value;
|
loc_ = value;
|
||||||
if (Window is null || Parent is null) return;
|
if (Window is null || Parent is null) return;
|
||||||
locc_ = new(value.X + Parent.Position.X, value.Y + Parent.Position.Y);
|
locc_ = new((int)Window.FloatToInt(Parent.IntToFloat(value.X)), (int)Window.FloatToInt(Parent.IntToFloat(value.Y, true), true));
|
||||||
|
if (Window.CanControleUpdate && Loaded) Window.DrawFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Vector2i Size { get; set; }
|
public Vector2i Size { get; set; }
|
||||||
@ -86,7 +77,7 @@ public class Label : IRenderObject
|
|||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
if (Visible & loadd)
|
if (Visible & Loaded)
|
||||||
{
|
{
|
||||||
Shader.Use();
|
Shader.Use();
|
||||||
GL.Enable(EnableCap.Blend);
|
GL.Enable(EnableCap.Blend);
|
||||||
@ -104,17 +95,8 @@ public class Label : IRenderObject
|
|||||||
|
|
||||||
float char_x = 0.0f;
|
float char_x = 0.0f;
|
||||||
|
|
||||||
Library lib = new();
|
|
||||||
|
|
||||||
Face face = new(lib, Font.GetData(), 0);
|
|
||||||
|
|
||||||
face.SetPixelSizes(0, PixelHeight);
|
|
||||||
|
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture0);
|
GL.ActiveTexture(TextureUnit.Texture0);
|
||||||
face.SelectCharmap(Encoding.Unicode);
|
|
||||||
|
|
||||||
|
|
||||||
float hhh = 0f;
|
float hhh = 0f;
|
||||||
foreach (char c in Text)
|
foreach (char c in Text)
|
||||||
@ -155,16 +137,16 @@ public class Label : IRenderObject
|
|||||||
|
|
||||||
public void LoadToParent(IParent window, Window win)
|
public void LoadToParent(IParent window, Window win)
|
||||||
{
|
{
|
||||||
|
if (Loaded) return;
|
||||||
|
if (!_characters.ContainsKey(this)) _characters.Add(this, new Dictionary<uint, Character>());
|
||||||
Parent = window;
|
Parent = window;
|
||||||
Window = win;
|
Window = win;
|
||||||
//X = window.FloatToInt(X, window.Size.X);
|
|
||||||
//Y = window.FloatToInt(Y, window.Size.Y, true);
|
|
||||||
Library lib = new();
|
Library lib = new();
|
||||||
|
|
||||||
Face face = new(lib, Font.GetData(), 0);
|
//Face face = new(lib, Font.Faces.First(), 0);
|
||||||
face.SetPixelSizes(0, PixelHeight);
|
//face.SetPixelSizes(0, PixelHeight);
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
||||||
face.SelectCharmap(Encoding.Unicode);
|
//face.SelectCharmap(Encoding.Unicode);
|
||||||
|
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 4);
|
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 4);
|
||||||
|
|
||||||
@ -182,7 +164,7 @@ public class Label : IRenderObject
|
|||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, VBO);
|
GL.BindBuffer(BufferTarget.ArrayBuffer, VBO);
|
||||||
GL.BufferData(BufferTarget.ArrayBuffer, 4 * 6 * 4, vquad, BufferUsageHint.StaticDraw);
|
GL.BufferData(BufferTarget.ArrayBuffer, 4 * 6 * 4, vquad, BufferUsageHint.StaticDraw);
|
||||||
|
|
||||||
VAO = GL.GenVertexArray();
|
VAO = GL.GenVertexArray();/*
|
||||||
if (!_characters.ContainsKey(this)) _characters.Add(this, new Dictionary<uint, Character>());
|
if (!_characters.ContainsKey(this)) _characters.Add(this, new Dictionary<uint, Character>());
|
||||||
foreach (char character in Text)
|
foreach (char character in Text)
|
||||||
{
|
{
|
||||||
@ -191,7 +173,7 @@ public class Label : IRenderObject
|
|||||||
var f = new Texture(this, character, PixelHeight, face);
|
var f = new Texture(this, character, PixelHeight, face);
|
||||||
f.LoadText();
|
f.LoadText();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
GL.BindVertexArray(VAO);
|
GL.BindVertexArray(VAO);
|
||||||
GL.EnableVertexAttribArray(0);
|
GL.EnableVertexAttribArray(0);
|
||||||
GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * 4, 0);
|
GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * 4, 0);
|
||||||
@ -200,15 +182,15 @@ public class Label : IRenderObject
|
|||||||
|
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||||
GL.BindVertexArray(0);
|
GL.BindVertexArray(0);
|
||||||
Text = text;
|
|
||||||
loadd = true;
|
Loaded = true;
|
||||||
|
Text = Text;
|
||||||
Location = Location;
|
Location = Location;
|
||||||
Distance = new(window.Size.X - Size.X - Location.X, window.Size.Y - Size.Y - Location.Y);
|
Distance = new(window.Size.X - Size.X - Location.X, window.Size.Y - Size.Y - Location.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool loadd = false;
|
|
||||||
|
|
||||||
public event Func<IRenderObject, Task>? Clicked;
|
public event Func<IRenderObject, Task>? Clicked;
|
||||||
|
|
||||||
public bool Loaded => loadd;
|
public bool Loaded { get; private set; } = false;
|
||||||
}
|
}
|
||||||
|
49
GraphicsManager/Objects/Rectangle.cs
Normal file → Executable file
49
GraphicsManager/Objects/Rectangle.cs
Normal file → Executable file
@ -3,6 +3,7 @@ using GraphicsManager.Interfaces;
|
|||||||
using GraphicsManager.Objects.Core;
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
|
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||||
|
|
||||||
namespace GraphicsManager.Objects;
|
namespace GraphicsManager.Objects;
|
||||||
|
|
||||||
@ -31,17 +32,32 @@ public class Rectangle : ITextureObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector4 Color { get; set; }
|
public Uniforms Uniforms { get; } = new() { Uniform4 = new() { new() { Location = 0, Value = new(0,0,0,1) } } };
|
||||||
|
|
||||||
public bool Visible { get; set; } = true;
|
public bool Visible { get; set; } = true;
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
if (Visible)
|
if (Visible && Loaded)
|
||||||
{
|
{
|
||||||
if (Texture is not null) Texture.Use();
|
if (Texture is not null) Texture.Use();
|
||||||
Shader.Use();
|
Shader.Use();
|
||||||
GL.Uniform4(0, Color);
|
for (int i = 0; i < Uniforms.Uniform4.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform4(Uniforms.Uniform4[i].Location, Uniforms.Uniform4[i].Value);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Uniforms.Uniform3.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform3(Uniforms.Uniform3[i].Location, Uniforms.Uniform3[i].Value);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Uniforms.Uniform2.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform2(Uniforms.Uniform2[i].Location, Uniforms.Uniform2[i].Value);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Uniforms.Uniform1.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform1(Uniforms.Uniform1[i].Location, Uniforms.Uniform1[i].Value);
|
||||||
|
}
|
||||||
if (Texture is not null)
|
if (Texture is not null)
|
||||||
{
|
{
|
||||||
GL.Enable(EnableCap.Blend);
|
GL.Enable(EnableCap.Blend);
|
||||||
@ -62,6 +78,7 @@ public class Rectangle : ITextureObject
|
|||||||
|
|
||||||
public void LoadToParent(IParent Parent, Window Window)
|
public void LoadToParent(IParent Parent, Window Window)
|
||||||
{
|
{
|
||||||
|
if (Loaded) return;
|
||||||
this.Parent = Parent;
|
this.Parent = Parent;
|
||||||
this.Window = Window;
|
this.Window = Window;
|
||||||
int pos = Points.Length - 3;
|
int pos = Points.Length - 3;
|
||||||
@ -88,9 +105,7 @@ public class Rectangle : ITextureObject
|
|||||||
ElementBufferObject = GL.GenBuffer();
|
ElementBufferObject = GL.GenBuffer();
|
||||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
||||||
load = true;
|
Loaded = true;
|
||||||
loadd = true;
|
|
||||||
|
|
||||||
Window.MouseDown += Window_MouseDown;
|
Window.MouseDown += Window_MouseDown;
|
||||||
Location = Location;
|
Location = Location;
|
||||||
Distance = new(Parent.Size.X - Size.X - Location.X, Parent.Size.Y - Size.Y - Location.Y);
|
Distance = new(Parent.Size.X - Size.X - Location.X, Parent.Size.Y - Size.Y - Location.Y);
|
||||||
@ -101,7 +116,14 @@ public class Rectangle : ITextureObject
|
|||||||
|
|
||||||
private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (Clicked is not null && e.Button == OpenTK.Windowing.GraphicsLibraryFramework.MouseButton.Button1 && Location.X <= Parent?.MousePosition.X && Size.X + Location.X >= Parent?.MousePosition.X && Location.Y + Size.Y >= Parent?.MousePosition.Y && Location.Y <= Parent?.MousePosition.Y) Clicked.Invoke(this);
|
if (e.Button == MouseButton.Button1 &&
|
||||||
|
Parent?.IntToFloat(Location.X) <= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Size.X + Location.X) >= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Location.Y + Size.Y, true) <= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true) &&
|
||||||
|
Parent?.IntToFloat(Location.Y, true) >= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true))
|
||||||
|
{
|
||||||
|
if (Clicked is not null) Clicked.Invoke(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Rectangle()
|
~Rectangle()
|
||||||
@ -116,7 +138,6 @@ public class Rectangle : ITextureObject
|
|||||||
public int ArrayObject { get; private set; }
|
public int ArrayObject { get; private set; }
|
||||||
private float[] Points_;
|
private float[] Points_;
|
||||||
private Vector2i size_ = new(), loc_ = new();
|
private Vector2i size_ = new(), loc_ = new();
|
||||||
bool load = false;
|
|
||||||
|
|
||||||
public float[] Points
|
public float[] Points
|
||||||
{
|
{
|
||||||
@ -129,7 +150,7 @@ public class Rectangle : ITextureObject
|
|||||||
Points_ = value;
|
Points_ = value;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (load)
|
if (Loaded)
|
||||||
{
|
{
|
||||||
int add = 3;
|
int add = 3;
|
||||||
if (Texture is not null) add = 5;
|
if (Texture is not null) add = 5;
|
||||||
@ -142,6 +163,7 @@ public class Rectangle : ITextureObject
|
|||||||
GL.BindVertexArray(ArrayObject);
|
GL.BindVertexArray(ArrayObject);
|
||||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||||
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
||||||
|
if (Window is not null && Window.CanControleUpdate && Loaded) Window.DrawFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (AccessViolationException v)
|
catch (AccessViolationException v)
|
||||||
@ -154,11 +176,10 @@ public class Rectangle : ITextureObject
|
|||||||
public uint[] Indexs { get; set; } = new uint[6] { 0, 1, 3, 1, 2, 3 };
|
public uint[] Indexs { get; set; } = new uint[6] { 0, 1, 3, 1, 2, 3 };
|
||||||
public BufferUsageHint Hint { get; set; } = BufferUsageHint.StaticDraw;
|
public BufferUsageHint Hint { get; set; } = BufferUsageHint.StaticDraw;
|
||||||
|
|
||||||
private bool loadd = false;
|
|
||||||
|
|
||||||
public event Func<IRenderObject, Task>? Clicked;
|
public event Func<IRenderObject, Task>? Clicked;
|
||||||
|
|
||||||
public bool Loaded => loadd;
|
public bool Loaded { get; private set; } = false;
|
||||||
public Vector2i Distance { get; private set; }
|
public Vector2i Distance { get; private set; }
|
||||||
|
|
||||||
public Vector2i Size
|
public Vector2i Size
|
||||||
@ -172,7 +193,7 @@ public class Rectangle : ITextureObject
|
|||||||
size_ = value;
|
size_ = value;
|
||||||
if (Window is null || Parent is null) return;
|
if (Window is null || Parent is null) return;
|
||||||
float[] temp = Points;
|
float[] temp = Points;
|
||||||
saf = new Vector2(Window.IntToFloat(value.X + loc_.X + Parent.Position.X, false), Window.IntToFloat(value.Y + loc_.Y + Parent.Position.Y, true));
|
saf = new Vector2(Parent.IntToFloat(value.X + loc_.X, false), Parent.IntToFloat(value.Y + loc_.Y, true));
|
||||||
temp[0] = saf.X;
|
temp[0] = saf.X;
|
||||||
temp[(Texture is null ? 3 : 5)] = saf.X;
|
temp[(Texture is null ? 3 : 5)] = saf.X;
|
||||||
temp[(Texture is null ? 4 : 6)] = saf.Y;
|
temp[(Texture is null ? 4 : 6)] = saf.Y;
|
||||||
@ -192,12 +213,12 @@ public class Rectangle : ITextureObject
|
|||||||
loc_ = value;
|
loc_ = value;
|
||||||
if (Window is null || Parent is null) return;
|
if (Window is null || Parent is null) return;
|
||||||
float[] temp = Points;
|
float[] temp = Points;
|
||||||
laf = new Vector2(Window.IntToFloat(value.X + Parent.Position.X, false), Window.IntToFloat(value.Y + Parent.Position.Y, true));
|
laf = new Vector2(Parent.IntToFloat(value.X, false), Parent.IntToFloat(value.Y, true));
|
||||||
temp[(Texture is null ? 6 : 10)] = laf.X;
|
temp[(Texture is null ? 6 : 10)] = laf.X;
|
||||||
temp[(Texture is null ? 9 : 15)] = laf.X;
|
temp[(Texture is null ? 9 : 15)] = laf.X;
|
||||||
temp[1] = laf.Y;
|
temp[1] = laf.Y;
|
||||||
temp[(Texture is null ? 10 : 16)] = laf.Y;
|
temp[(Texture is null ? 10 : 16)] = laf.Y;
|
||||||
saf = new Vector2(Window.IntToFloat(Size.X + value.X + Parent.Position.X, false), Window.IntToFloat(Size.Y + value.Y + Parent.Position.Y, true));
|
saf = new Vector2(Parent.IntToFloat(Size.X + value.X, false), Parent.IntToFloat(Size.Y + value.Y, true));
|
||||||
temp[0] = saf.X;
|
temp[0] = saf.X;
|
||||||
temp[(Texture is null ? 3 : 5)] = saf.X;
|
temp[(Texture is null ? 3 : 5)] = saf.X;
|
||||||
temp[(Texture is null ? 4 : 6)] = saf.Y;
|
temp[(Texture is null ? 4 : 6)] = saf.Y;
|
||||||
|
317
GraphicsManager/Objects/RoundedRectangle.cs
Executable file
317
GraphicsManager/Objects/RoundedRectangle.cs
Executable file
@ -0,0 +1,317 @@
|
|||||||
|
using GraphicsManager.Enums;
|
||||||
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
using OpenTK.Mathematics;
|
||||||
|
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||||
|
using System.Runtime.Intrinsics.X86;
|
||||||
|
|
||||||
|
namespace GraphicsManager.Objects;
|
||||||
|
|
||||||
|
public class RoundedRectangle : IRenderObject
|
||||||
|
{
|
||||||
|
public static readonly Shader DefaultShader = Rectangle.DefaultShader;
|
||||||
|
|
||||||
|
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
||||||
|
private const int sn = 4, r = 5;
|
||||||
|
private int sn_ = sn, r_ = r;
|
||||||
|
|
||||||
|
public RoundedRectangle()
|
||||||
|
{
|
||||||
|
Points_ = new float[36 + (((sn - 1) * 4) * 3)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uniforms Uniforms { get; set; } = new() { Uniform4 = new() { new() { Location = 0, Value = new(0,0,0,1) } } };
|
||||||
|
public int Radius
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return r_;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
r_ = value;
|
||||||
|
Location = Location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Smoothness
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return sn_;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
sn_ = value;
|
||||||
|
List<uint> Indexs = this.Indexs.ToList().GetRange(0, 30);
|
||||||
|
uint wall = 5;
|
||||||
|
uint last = 12;
|
||||||
|
for (uint i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (value == 1)
|
||||||
|
{
|
||||||
|
Indexs.Add(i);
|
||||||
|
Indexs.Add(wall);
|
||||||
|
wall++;
|
||||||
|
if (wall == 12) wall = 4;
|
||||||
|
Indexs.Add(wall);
|
||||||
|
wall++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint j = 0; j < value; j++)
|
||||||
|
{
|
||||||
|
Indexs.Add(i);
|
||||||
|
if (j == 0 || j == value - 1)
|
||||||
|
{
|
||||||
|
if (wall == 12) wall = 4;
|
||||||
|
Indexs.Add(wall);
|
||||||
|
wall++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Indexs.Add(last);
|
||||||
|
last++;
|
||||||
|
}
|
||||||
|
Indexs.Add(last);
|
||||||
|
|
||||||
|
}
|
||||||
|
last++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Indexs = Indexs.ToArray();
|
||||||
|
Location = Location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Visible { get; set; } = true;
|
||||||
|
|
||||||
|
public void Draw()
|
||||||
|
{
|
||||||
|
if (Visible && Loaded)
|
||||||
|
{
|
||||||
|
GL.Enable(EnableCap.Multisample);
|
||||||
|
GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
|
||||||
|
GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
|
||||||
|
GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest);
|
||||||
|
GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
|
||||||
|
Shader.Use();
|
||||||
|
for (int i = 0; i < Uniforms.Uniform4.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform4(Uniforms.Uniform4[i].Location, Uniforms.Uniform4[i].Value);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Uniforms.Uniform3.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform3(Uniforms.Uniform3[i].Location, Uniforms.Uniform3[i].Value);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < Uniforms.Uniform2.Count; i++)
|
||||||
|
{
|
||||||
|
GL.Uniform2(Uniforms.Uniform2[i].Location, Uniforms.Uniform2[i].Value);
|
||||||
|
}
|
||||||
|
GL.BindVertexArray(ArrayObject);
|
||||||
|
|
||||||
|
GL.DrawElements(PrimitiveType.Triangles, Indexs.Length, DrawElementsType.UnsignedInt, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clean()
|
||||||
|
{
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||||
|
GL.DeleteBuffer(BufferObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadToParent(IParent Parent, Window Window)
|
||||||
|
{
|
||||||
|
if (Loaded) return;
|
||||||
|
this.Parent = Parent;
|
||||||
|
this.Window = Window;
|
||||||
|
int pos = Points.Length - 3;
|
||||||
|
pos = 4;
|
||||||
|
|
||||||
|
BufferObject = GL.GenBuffer();
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||||
|
ArrayObject = GL.GenVertexArray();
|
||||||
|
GL.BindVertexArray(ArrayObject);
|
||||||
|
int add = 3;
|
||||||
|
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, add * sizeof(float), 0);
|
||||||
|
GL.EnableVertexAttribArray(0);
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||||
|
GL.BufferData(BufferTarget.ArrayBuffer, Points.Length * sizeof(float), Points, Hint);
|
||||||
|
GL.BindVertexArray(ArrayObject);
|
||||||
|
ElementBufferObject = GL.GenBuffer();
|
||||||
|
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||||
|
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
||||||
|
Loaded = true;
|
||||||
|
Window.MouseDown += Window_MouseDown;
|
||||||
|
Location = Location;
|
||||||
|
Distance = new(Parent.Size.X - Size.X - Location.X, Parent.Size.Y - Size.Y - Location.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IParent? Parent { get; private set; }
|
||||||
|
public Window? Window { get; private set; }
|
||||||
|
|
||||||
|
private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Button == MouseButton.Button1 &&
|
||||||
|
Parent?.IntToFloat(Location.X) <= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Size.X + Location.X) >= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Location.Y + Size.Y, true) <= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true) &&
|
||||||
|
Parent?.IntToFloat(Location.Y, true) >= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true))
|
||||||
|
{
|
||||||
|
if (Clicked is not null) Clicked.Invoke(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~RoundedRectangle()
|
||||||
|
{
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||||
|
GL.DeleteBuffer(BufferObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shader Shader { get; set; } = DefaultShader;
|
||||||
|
public int ElementBufferObject { get; private set; }
|
||||||
|
public int BufferObject { get; private set; }
|
||||||
|
public int ArrayObject { get; private set; }
|
||||||
|
private float[] Points_;
|
||||||
|
private Vector2i size_ = new(), loc_ = new();
|
||||||
|
|
||||||
|
public float[] Points
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Points_;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Points_ = value;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Loaded)
|
||||||
|
{
|
||||||
|
int add = 3;
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||||
|
GL.BindVertexArray(ArrayObject);
|
||||||
|
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, add * sizeof(float), 0);
|
||||||
|
GL.EnableVertexAttribArray(0);
|
||||||
|
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferObject);
|
||||||
|
GL.BufferData(BufferTarget.ArrayBuffer, Points_.Length * sizeof(float), Points_, Hint);
|
||||||
|
GL.BindVertexArray(ArrayObject);
|
||||||
|
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
|
||||||
|
GL.BufferData(BufferTarget.ElementArrayBuffer, Indexs.Length * sizeof(uint), Indexs, Hint);
|
||||||
|
if (Window is not null && Window.CanControleUpdate && Loaded) Window.DrawFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (AccessViolationException v)
|
||||||
|
{
|
||||||
|
Console.WriteLine(v.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint[] Indexs { get; set; } = new uint[30 + ((sn * 4) * 3)] { 0, 1, 3, 1, 2, 3, 0, 3, 4, 0, 4, 5, 0, 1, 7, 0, 6, 7, 1, 2, 9, 1, 8, 9, 2, 3, 11, 2, 10, 11,
|
||||||
|
0, 5, 12,
|
||||||
|
0, 12, 13,
|
||||||
|
0, 13, 14,
|
||||||
|
0, 6, 14,
|
||||||
|
|
||||||
|
1, 7, 15,
|
||||||
|
1, 15, 16,
|
||||||
|
1, 16, 17,
|
||||||
|
1, 8, 17,
|
||||||
|
|
||||||
|
2, 9, 18,
|
||||||
|
2, 18, 19,
|
||||||
|
2, 19, 20,
|
||||||
|
2, 10, 20,
|
||||||
|
|
||||||
|
3, 11, 21,
|
||||||
|
3, 21, 22,
|
||||||
|
3, 22, 23,
|
||||||
|
3, 4, 23};
|
||||||
|
public BufferUsageHint Hint { get; set; } = BufferUsageHint.StaticDraw;
|
||||||
|
|
||||||
|
|
||||||
|
public event Func<IRenderObject, Task>? Clicked;
|
||||||
|
|
||||||
|
public bool Loaded { get; private set; } = false;
|
||||||
|
public Vector2i Distance { get; private set; }
|
||||||
|
|
||||||
|
public Vector2i Size
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
size_ = value;
|
||||||
|
if (Window is null || Parent is null) return;
|
||||||
|
Location = Location;
|
||||||
|
saf = new Vector2(Parent.IntToFloat(value.X + loc_.X, false), Parent.IntToFloat(value.Y + loc_.Y, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2i Location
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return loc_;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
loc_ = value;
|
||||||
|
if (Window is null || Parent is null) return;
|
||||||
|
List<float> temp;
|
||||||
|
saf = new Vector2(Parent.IntToFloat(Size.X + loc_.X, false), Parent.IntToFloat(Size.Y + loc_.Y, true));
|
||||||
|
Vector3 _0 = Parent.PointToVector(value.X + Size.X - Radius, value.Y + Radius, 0);
|
||||||
|
Vector3 _1 = Parent.PointToVector(value.X + Size.X - Radius, value.Y + Size.Y - Radius, 0);
|
||||||
|
Vector3 _2 = Parent.PointToVector(value.X + Radius, value.Y + Size.Y - Radius, 0);
|
||||||
|
Vector3 _3 = Parent.PointToVector(value.X + Radius, value.Y + Radius, 0);
|
||||||
|
Vector3 _4 = Parent.PointToVector(value.X + Radius, value.Y, 0);
|
||||||
|
Vector3 _5 = Parent.PointToVector(value.X + Size.X - Radius, value.Y, 0);
|
||||||
|
Vector3 _6 = Parent.PointToVector(value.X + Size.X, value.Y + Radius, 0);
|
||||||
|
Vector3 _7 = Parent.PointToVector(value.X + Size.X, value.Y + Size.Y - Radius, 0);
|
||||||
|
Vector3 _8 = Parent.PointToVector(value.X + Size.X - Radius, value.Y + Size.Y, 0);
|
||||||
|
Vector3 _9 = Parent.PointToVector(value.X + Radius, value.Y + Size.Y, 0);
|
||||||
|
Vector3 _10 = Parent.PointToVector(value.X, value.Y + Size.Y - Radius, 0);
|
||||||
|
Vector3 _11 = Parent.PointToVector(value.X, value.Y + Radius, 0);
|
||||||
|
int[] ff = new int[]
|
||||||
|
{
|
||||||
|
value.X + Size.X - Radius,
|
||||||
|
value.X + Size.X - Radius,
|
||||||
|
value.X + Radius,
|
||||||
|
value.X + Radius,
|
||||||
|
value.Y + Radius,
|
||||||
|
value.Y + Size.Y - Radius,
|
||||||
|
value.Y + Size.Y - Radius,
|
||||||
|
value.Y + Radius
|
||||||
|
};
|
||||||
|
float rotation = 90f / (Smoothness);
|
||||||
|
temp = new()
|
||||||
|
{
|
||||||
|
_0.X, _0.Y, _0.Z, _1.X, _1.Y, _1.Z, _2.X, _2.Y, _2.Z, _3.X, _3.Y, _3.Z, _4.X, _4.Y, _4.Z, _5.X, _5.Y, _5.Z, _6.X, _6.Y, _6.Z, _7.X, _7.Y, _7.Z, _8.X, _8.Y, _8.Z, _9.X, _9.Y, _9.Z, _10.X, _10.Y, _10.Z, _11.X, _11.Y, _11.Z
|
||||||
|
};
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
int start = 90 - (j * 90);
|
||||||
|
for (int i = 0; i < Smoothness - 1; i++)
|
||||||
|
{
|
||||||
|
var degpre = (rotation * (i + 1));
|
||||||
|
var deg = start - degpre;
|
||||||
|
double y = ff[j + 4] - (Math.Sin(MathHelper.DegreesToRadians(deg)) * Radius);
|
||||||
|
double x = (Math.Cos(MathHelper.DegreesToRadians(deg)) * Radius) + ff[j];
|
||||||
|
Vector3 tri = Parent.PointToVector((int)x, (int)y, 0f);
|
||||||
|
temp.Add(tri.X);
|
||||||
|
temp.Add(tri.Y);
|
||||||
|
temp.Add(tri.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Points = temp.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Vector2 laf = new(), saf = new();
|
||||||
|
|
||||||
|
public Vector2 LocationAsFloat { get { return laf; } }
|
||||||
|
public Vector2 SizeAsFloat { get { return saf; } }
|
||||||
|
}
|
193
GraphicsManager/Objects/Textbox.cs
Normal file → Executable file
193
GraphicsManager/Objects/Textbox.cs
Normal file → Executable file
@ -6,116 +6,155 @@ using OpenTK.Windowing.GraphicsLibraryFramework;
|
|||||||
|
|
||||||
namespace GraphicsManager.Objects;
|
namespace GraphicsManager.Objects;
|
||||||
|
|
||||||
public class Textbox : ITextureObject
|
public class Textbox : IRenderObject
|
||||||
{
|
{
|
||||||
public event Func<IRenderObject, Task>? Clicked;
|
private RoundedRectangle _bounds, _inside;
|
||||||
public Rectangle Bounds;
|
private Label _label;
|
||||||
public Label Label;
|
public Textbox()
|
||||||
public IParent Parent { get; private set; }
|
|
||||||
public Textbox(Texture texture = null!)
|
|
||||||
{
|
{
|
||||||
Bounds = new Rectangle(texture ?? new Texture(Tools.GetResourceBytes("GraphicsManager.Resources.Textures.Textbox.png")));
|
_bounds = new RoundedRectangle();
|
||||||
Label = new Label()
|
_inside = new RoundedRectangle();
|
||||||
{
|
_label = new Label();
|
||||||
Text = nameof(Textbox)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
public Vector2i Size { get { return Bounds.Size; } set { Bounds.Size = value; } }
|
|
||||||
public Vector2i Location { get { return Bounds.Location; } set { Bounds.Location = value; } }
|
|
||||||
public Vector2i Distance { get { return Bounds.Distance; }}
|
|
||||||
public Texture Texture => Bounds.Texture!;
|
|
||||||
|
|
||||||
public string Text { get => Label.Text; set => Label.Text = value; }
|
public int Radius { get => _bounds.Radius; set { _bounds.Radius = value; _inside.Radius = value; } }
|
||||||
public Font Font { get => Label.Font; set => Label.Font = value; }
|
public int Border { get; set; } = 2;
|
||||||
public Vector4 BackgroundColor { get => Bounds.Color; set => Bounds.Color = value; }
|
public int Smoothness { get => _bounds.Smoothness; set { _bounds.Smoothness = value; _inside.Smoothness = value; } }
|
||||||
public float[] Points
|
public ObjectAnchor Anchor { get => _bounds.Anchor; set { _bounds.Anchor = value; _inside.Anchor = value; _label.Anchor = value; } }
|
||||||
|
public Font Font { get => _label.Font; set => _label.Font = value; }
|
||||||
|
public string Text { get => _label.Text; set => _label.Text = value; }
|
||||||
|
public bool Loaded { get; private set; } = false;
|
||||||
|
public Vector2i Size
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Bounds.Points;
|
return _bounds.Size;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (Label is not null && Parent is not null)
|
_bounds.Size = value;
|
||||||
{
|
_inside.Size = new(value.X - (Border * 2), value.Y - (Border * 2));
|
||||||
Label.Location = new Vector2i((int)Parent.FloatToInt(value[10] + ((-1 - Parent.IntToFloat(10)) * -1)), (int)Parent.FloatToInt(value[6] + (-1 - Parent.IntToFloat(5)) * -1, true));
|
|
||||||
}
|
|
||||||
Bounds.Points = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Vector2i Location {
|
||||||
|
get => _bounds.Location;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_bounds.Location = value;
|
||||||
|
_label.Location = new(value.X + Radius + 5, value.Y + Size.Y - Radius - 5);
|
||||||
|
_inside.Location = new(value.X + Border, value.Y + Border);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; }
|
||||||
|
public Vector2 LocationAsFloat { get => _bounds.LocationAsFloat; }
|
||||||
|
public Vector2i Distance { get => _bounds.Distance; }
|
||||||
|
public IParent? Parent { get; private set; } = null;
|
||||||
|
public Window? Window { get; private set; } = null;
|
||||||
|
|
||||||
public ObjectAnchor Anchor { get; set; } = ObjectAnchor.Left | ObjectAnchor.Top;
|
public Color4 InsideColor
|
||||||
|
{
|
||||||
private bool _loaded = false;
|
get
|
||||||
public bool Loaded => _loaded;
|
{
|
||||||
|
Uniform<Vector4> u4 = _inside.Uniforms.Uniform4.Where(u => u.Location == 0).First();
|
||||||
|
if (u4 is null) u4 = new() { Location = 0, Value = new(1, 1, 0, 1) };
|
||||||
|
return new Color4(u4.Value.X, u4.Value.X, u4.Value.X, u4.Value.X);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Uniform<Vector4> u4 = _inside.Uniforms.Uniform4.Where(u => u.Location == 0).First();
|
||||||
|
if (u4 is not null) _inside.Uniforms.Uniform4.Remove(u4);
|
||||||
|
if (u4 is null) u4 = new() { Location = 0 };
|
||||||
|
u4.Value = new(value.R, value.G, value.B, value.A);
|
||||||
|
_inside.Uniforms.Uniform4.Add(u4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Color4 BorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Uniform<Vector4> u4 = _bounds.Uniforms.Uniform4.Where(u => u.Location == 0).First();
|
||||||
|
if (u4 is null) u4 = new() { Location = 0, Value = new(1, 1, 0, 1) };
|
||||||
|
return new Color4(u4.Value.X, u4.Value.X, u4.Value.X, u4.Value.X);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Uniform<Vector4> u4 = _bounds.Uniforms.Uniform4.Where(u => u.Location == 0).First();
|
||||||
|
if (u4 is not null) _bounds.Uniforms.Uniform4.Remove(u4);
|
||||||
|
if (u4 is null) u4 = new() { Location = 0 };
|
||||||
|
u4.Value = new(value.R, value.G, value.B, value.A);
|
||||||
|
_bounds.Uniforms.Uniform4.Add(u4);
|
||||||
|
}
|
||||||
|
}
|
||||||
public bool Visible { get; set; } = true;
|
public bool Visible { get; set; } = true;
|
||||||
|
public event Func<IRenderObject, Task>? Clicked;
|
||||||
|
|
||||||
public void Clean()
|
public void Clean()
|
||||||
{
|
{
|
||||||
Bounds.Clean();
|
_bounds.Clean();
|
||||||
Label.Clean();
|
_inside.Clean();
|
||||||
|
_label.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
Bounds.Draw();
|
if (!Visible || !Loaded) return;
|
||||||
Label.Draw();
|
_bounds.Draw();
|
||||||
}
|
_inside.Draw();
|
||||||
public Window? Window { get; private set; }
|
_label.Draw();
|
||||||
public void LoadToParent(IParent Parent, Window Window)
|
|
||||||
{
|
|
||||||
this.Parent = Parent;
|
|
||||||
this.Window = Window;
|
|
||||||
this.Parent.MouseDown += Parrent_MouseDown;
|
|
||||||
this.Parent.KeyDown += Parrent_KeyDown;
|
|
||||||
Bounds.LoadToParent(Parent, Window);
|
|
||||||
Points = Points;
|
|
||||||
Label.LoadToParent(Parent, Window);
|
|
||||||
_loaded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Parrent_KeyDown(OpenTK.Windowing.Common.KeyboardKeyEventArgs obj)
|
public void LoadToParent(IParent Parent, Window Window)
|
||||||
{
|
{
|
||||||
if (use)
|
if (Loaded) return;
|
||||||
|
this.Parent = Parent;
|
||||||
|
this.Window = Window;
|
||||||
|
this.Window.MouseDown += Window_MouseDown;
|
||||||
|
this.Window.KeyDown += Window_KeyDown;
|
||||||
|
Loaded = true;
|
||||||
|
_bounds.LoadToParent(Parent, Window);
|
||||||
|
_inside.LoadToParent(Parent, Window);
|
||||||
|
_label.LoadToParent(Parent, Window);
|
||||||
|
Location = Location;
|
||||||
|
}
|
||||||
|
private bool use = false;
|
||||||
|
private void Window_KeyDown(OpenTK.Windowing.Common.KeyboardKeyEventArgs obj)
|
||||||
|
{
|
||||||
|
if (!use) return;
|
||||||
|
if (obj.Key == Keys.CapsLock || obj.Key == Keys.Menu || obj.Key == Keys.LeftSuper || obj.Key == Keys.RightSuper || obj.Key == Keys.End || obj.Key == Keys.Home || obj.Key == Keys.PageDown || obj.Key == Keys.PageUp || obj.Key == Keys.Insert || obj.Key == Keys.Up || obj.Key == Keys.Down || obj.Key == Keys.Left || obj.Key == Keys.Right) return;
|
||||||
|
if (obj.Key == Keys.Backspace)
|
||||||
{
|
{
|
||||||
if (obj.Key == Keys.CapsLock || obj.Key == Keys.Menu || obj.Key == Keys.LeftSuper || obj.Key == Keys.RightSuper || obj.Key == Keys.End || obj.Key == Keys.Home || obj.Key == Keys.PageDown || obj.Key == Keys.PageUp || obj.Key == Keys.Insert || obj.Key == Keys.Up || obj.Key == Keys.Down || obj.Key == Keys.Left || obj.Key == Keys.Right) return;
|
if (!(Text.Length > 0)) return;
|
||||||
if (obj.Key == Keys.Backspace)
|
Text = Text.Remove(Text.Length - 1, 1);
|
||||||
{
|
}
|
||||||
if (!(Text.Length > 0)) return;
|
else if (obj.Key == Keys.Delete)
|
||||||
Text = Text.Remove(Text.Length - 1, 1);
|
{
|
||||||
}
|
if (!(Text.Length > 0)) return;
|
||||||
else if (obj.Key == Keys.Delete)
|
Text = Text.Remove(Text.Length - 1, 1);
|
||||||
{
|
}
|
||||||
if (!(Text.Length > 0)) return;
|
else if (obj.Shift)
|
||||||
Text = Text.Remove(Text.Length - 1, 1);
|
{
|
||||||
}
|
if (obj.Key == Keys.Enter || obj.Key == Keys.KeyPadEnter) Text += '\n';
|
||||||
else if (obj.Shift)
|
else if (obj.Key == Keys.LeftShift || obj.Key == Keys.KeyPadEnter || obj.Key == Keys.Enter || obj.Key == Keys.End || obj.Key == Keys.Down) return;
|
||||||
{
|
else Text += ((char)obj.Key).ToString().ToUpper();
|
||||||
if (obj.Key == Keys.Enter || obj.Key == Keys.KeyPadEnter) Text += '\n';
|
}
|
||||||
else if (obj.Key == Keys.LeftShift || obj.Key == Keys.KeyPadEnter || obj.Key == Keys.Enter || obj.Key == Keys.End || obj.Key == Keys.Down) return;
|
else if (obj.Command || obj.Alt || obj.Control) { }
|
||||||
else Text += ((char)obj.Key).ToString().ToUpper();
|
else
|
||||||
}
|
{
|
||||||
else if (obj.Command || obj.Alt || obj.Control) { }
|
Text += ((char)obj.Key).ToString().ToLower();
|
||||||
else
|
|
||||||
{
|
|
||||||
Text += ((char)obj.Key).ToString().ToLower();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use = false;
|
private void Window_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
||||||
|
|
||||||
private void Parrent_MouseDown(OpenTK.Windowing.Common.MouseButtonEventArgs e)
|
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButton.Button1 && Location.X <= Parent?.MousePosition.X && Size.X + Location.X >= Parent?.MousePosition.X && Location.Y + Size.Y >= Parent?.MousePosition.Y && Location.Y <= Parent?.MousePosition.Y)
|
if (e.Button == MouseButton.Button1 &&
|
||||||
|
Parent?.IntToFloat(Location.X) <= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Size.X + Location.X) >= Parent?.IntToFloat((int)Parent?.MousePosition.X!) &&
|
||||||
|
Parent?.IntToFloat(Location.Y + Size.Y, true) <= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true) &&
|
||||||
|
Parent?.IntToFloat(Location.Y, true) >= Parent?.IntToFloat((int)Parent?.MousePosition.Y!, true))
|
||||||
{
|
{
|
||||||
use = true;
|
use = true;
|
||||||
if (Clicked is not null) Clicked.Invoke(this);
|
if (Clicked is not null) Clicked.Invoke(this);
|
||||||
}
|
}
|
||||||
else use = false;
|
else use = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 LocationAsFloat { get { return Bounds.LocationAsFloat; } }
|
|
||||||
public Vector2 SizeAsFloat { get { return Bounds.SizeAsFloat; } }
|
|
||||||
}
|
}
|
||||||
|
38
GraphicsManager/Objects/UserControl.cs
Normal file → Executable file
38
GraphicsManager/Objects/UserControl.cs
Normal file → Executable file
@ -1,5 +1,6 @@
|
|||||||
using GraphicsManager.Enums;
|
using GraphicsManager.Enums;
|
||||||
using GraphicsManager.Interfaces;
|
using GraphicsManager.Interfaces;
|
||||||
|
using GraphicsManager.Objects.Core;
|
||||||
using OpenTK.Mathematics;
|
using OpenTK.Mathematics;
|
||||||
using OpenTK.Windowing.Common;
|
using OpenTK.Windowing.Common;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public class UserControl : IRenderObject, IParent
|
|||||||
|
|
||||||
public ICollection<IRenderObject> Controls { get; } = new List<IRenderObject>();
|
public ICollection<IRenderObject> Controls { get; } = new List<IRenderObject>();
|
||||||
public ObjectAnchor Anchor { get => _bounds.Anchor; set => _bounds.Anchor = value; }
|
public ObjectAnchor Anchor { get => _bounds.Anchor; set => _bounds.Anchor = value; }
|
||||||
public Vector4 Color { get => _bounds.Color; set => _bounds.Color = value; }
|
public Uniforms Uniforms { get => _bounds.Uniforms; }
|
||||||
public bool Visible { get => _bounds.Visible; set => _bounds.Visible = value; }
|
public bool Visible { get => _bounds.Visible; set => _bounds.Visible = value; }
|
||||||
public Vector2i Size { get => _bounds.Size; set => _bounds.Size = value; }
|
public Vector2i Size { get => _bounds.Size; set => _bounds.Size = value; }
|
||||||
public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; }
|
public Vector2 SizeAsFloat { get => _bounds.SizeAsFloat; }
|
||||||
@ -39,18 +40,19 @@ public class UserControl : IRenderObject, IParent
|
|||||||
public Window? Window { get; private set; }
|
public Window? Window { get; private set; }
|
||||||
public bool Loaded { get; private set; } = false;
|
public bool Loaded { get; private set; } = false;
|
||||||
|
|
||||||
public Vector2 MousePosition => throw new NotImplementedException();
|
public Vector2 MousePosition => Window!.MousePosition;
|
||||||
|
|
||||||
public void LoadToParent(IParent Parent, Window Window)
|
public void LoadToParent(IParent Parent, Window Window)
|
||||||
{
|
{
|
||||||
|
if (Loaded) return;
|
||||||
this.Parent = Parent;
|
this.Parent = Parent;
|
||||||
this.Window = Window;
|
this.Window = Window;
|
||||||
|
Loaded = true;
|
||||||
_bounds.LoadToParent(Parent, Window);
|
_bounds.LoadToParent(Parent, Window);
|
||||||
foreach (IRenderObject obj in Controls)
|
foreach (IRenderObject obj in Controls)
|
||||||
{
|
{
|
||||||
obj.LoadToParent(this, Window);
|
obj.LoadToParent(this, Window);
|
||||||
}
|
}
|
||||||
Loaded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
@ -83,7 +85,7 @@ public class UserControl : IRenderObject, IParent
|
|||||||
_bounds.Clean();
|
_bounds.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resize(ResizeEventArgs e)
|
public void ParentResize(ResizeEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Width == 0 && e.Height == 0) return;
|
if (e.Width == 0 && e.Height == 0) return;
|
||||||
foreach (IRenderObject Control in Controls)
|
foreach (IRenderObject Control in Controls)
|
||||||
@ -102,6 +104,10 @@ public class UserControl : IRenderObject, IParent
|
|||||||
int sx = (right ? Size.X - Control.Distance.X - lx : Control.Size.X);
|
int sx = (right ? Size.X - Control.Distance.X - lx : Control.Size.X);
|
||||||
Control.Size = new(sx, sy);
|
Control.Size = new(sx, sy);
|
||||||
Control.Location = new(lx, ly);
|
Control.Location = new(lx, ly);
|
||||||
|
if (Control is IParent parent)
|
||||||
|
{
|
||||||
|
parent.ParentResize(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,9 +135,21 @@ public class UserControl : IRenderObject, IParent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3 PointToVector(int x, int y, float z = 0.0f)
|
||||||
|
{
|
||||||
|
return new Vector3(IntToFloat(x), IntToFloat(y, true), z);
|
||||||
|
}
|
||||||
|
|
||||||
public float IntToFloat(int p, bool Invert = false)
|
public float IntToFloat(int p, bool Invert = false)
|
||||||
{
|
{
|
||||||
int Size = (Invert ? this.Size.Y : this.Size.X);
|
p += (Invert ? Location.Y : Location.X);
|
||||||
|
IParent? tempp = Parent;
|
||||||
|
while (tempp is not null)
|
||||||
|
{
|
||||||
|
p += (Invert ? tempp.Position.Y : tempp.Position.X);
|
||||||
|
tempp = tempp.Parent;
|
||||||
|
}
|
||||||
|
int Size = (Invert ? Window!.Size.Y : Window!.Size.X);
|
||||||
double half = Math.Round((double)Size / (double)2, 1);
|
double half = Math.Round((double)Size / (double)2, 1);
|
||||||
double Per = Math.Round((double)1 / half, 15);
|
double Per = Math.Round((double)1 / half, 15);
|
||||||
if (p == half) return 0.0f;
|
if (p == half) return 0.0f;
|
||||||
@ -149,7 +167,15 @@ public class UserControl : IRenderObject, IParent
|
|||||||
|
|
||||||
public float FloatToInt(float p, bool Invert = false)
|
public float FloatToInt(float p, bool Invert = false)
|
||||||
{
|
{
|
||||||
int Size = (Invert ? this.Size.Y : this.Size.X);
|
p += (Invert ? LocationAsFloat.Y : LocationAsFloat.X);
|
||||||
|
IParent? tempp = Parent;
|
||||||
|
while (tempp is not null)
|
||||||
|
{
|
||||||
|
p += (Invert ? tempp.LocationAsFloat.Y : tempp.LocationAsFloat.X);
|
||||||
|
tempp = tempp.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Size = (Invert ? Window!.Size.Y : Window!.Size.X);
|
||||||
double half = Math.Round((double)Size / (double)2, 15);
|
double half = Math.Round((double)Size / (double)2, 15);
|
||||||
if (p == 0) return (int)half;
|
if (p == 0) return (int)half;
|
||||||
if (Invert)
|
if (Invert)
|
||||||
|
0
GraphicsManager/Resources/Fonts/TektonPro-Regular.otf
Normal file → Executable file
0
GraphicsManager/Resources/Fonts/TektonPro-Regular.otf
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Label.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Label.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Label.vert
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Label.vert
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Rectangle.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Rectangle.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Rectangle.vert
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/Rectangle.vert
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/RectangleTexture.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/RectangleTexture.frag
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/RectangleTexture.vert
Normal file → Executable file
0
GraphicsManager/Resources/Shaders/RectangleTexture.vert
Normal file → Executable file
Binary file not shown.
Before Width: | Height: | Size: 267 B |
0
GraphicsManager/Structs/Character.cs
Normal file → Executable file
0
GraphicsManager/Structs/Character.cs
Normal file → Executable file
0
GraphicsManager/Tools.cs
Normal file → Executable file
0
GraphicsManager/Tools.cs
Normal file → Executable file
60
GraphicsManager/Window.cs
Normal file → Executable file
60
GraphicsManager/Window.cs
Normal file → Executable file
@ -9,6 +9,8 @@ namespace GraphicsManager;
|
|||||||
|
|
||||||
public class Window : NativeWindow , IParent
|
public class Window : NativeWindow , IParent
|
||||||
{
|
{
|
||||||
|
public IParent? Parent { get; } = null;
|
||||||
|
public Vector2 LocationAsFloat { get; } = new Vector2(0f, 0f);
|
||||||
public Window(NativeWindowSettings nativeWindowSettings) : base(nativeWindowSettings)
|
public Window(NativeWindowSettings nativeWindowSettings) : base(nativeWindowSettings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -44,6 +46,11 @@ public class Window : NativeWindow , IParent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3 PointToVector(int x, int y, float z = 0.0f)
|
||||||
|
{
|
||||||
|
return new Vector3(IntToFloat(x), IntToFloat(y, true), z);
|
||||||
|
}
|
||||||
|
|
||||||
public float IntToFloat(int p, bool Invert = false)
|
public float IntToFloat(int p, bool Invert = false)
|
||||||
{
|
{
|
||||||
int Size = (Invert ? this.Size.Y : this.Size.X);
|
int Size = (Invert ? this.Size.Y : this.Size.X);
|
||||||
@ -96,53 +103,60 @@ public class Window : NativeWindow , IParent
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void Resize(ResizeEventArgs e)
|
public void ParentResize(ResizeEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Width == 0 && e.Height == 0) return;
|
if (e.Width == 0 && e.Height == 0) return;
|
||||||
base.OnResize(e);
|
base.OnResize(e);
|
||||||
GL.Viewport(0, 0, e.Width, e.Height);
|
GL.Viewport(0, 0, e.Width, e.Height);
|
||||||
foreach (IRenderObject Control in Controls)
|
foreach (IRenderObject Control in Controls)
|
||||||
{
|
{
|
||||||
if (Control.Loaded)
|
if (!Control.Loaded) continue;
|
||||||
|
bool top = (Control.Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
||||||
|
bool left = (Control.Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
||||||
|
bool right = (Control.Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
||||||
|
bool bottom = (Control.Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
||||||
|
if (!top && !bottom) { Control.Anchor |= ObjectAnchor.Top; top = true; }
|
||||||
|
if (!left && !right) { Control.Anchor |= ObjectAnchor.Left; left = true; }
|
||||||
|
int lx = (left ? Control.Location.X : Size.X - Control.Distance.X - Control.Size.X);
|
||||||
|
int ly = (top ? Control.Location.Y : Size.Y - Control.Distance.Y - Control.Size.Y);
|
||||||
|
int sy = (bottom ? Size.Y - Control.Distance.Y - ly : Control.Size.Y);
|
||||||
|
int sx = (right ? Size.X - Control.Distance.X - lx : Control.Size.X);
|
||||||
|
Control.Size = new(sx, sy);
|
||||||
|
Control.Location = new(lx, ly);
|
||||||
|
if (Control is IParent parent)
|
||||||
{
|
{
|
||||||
bool top = (Control.Anchor & ObjectAnchor.Top) == ObjectAnchor.Top;
|
parent.ParentResize(e);
|
||||||
bool left = (Control.Anchor & ObjectAnchor.Left) == ObjectAnchor.Left;
|
|
||||||
bool right = (Control.Anchor & ObjectAnchor.Right) == ObjectAnchor.Right;
|
|
||||||
bool bottom = (Control.Anchor & ObjectAnchor.Bottom) == ObjectAnchor.Bottom;
|
|
||||||
if (!top && !bottom) { Control.Anchor |= ObjectAnchor.Top; top = true; }
|
|
||||||
if (!left && !right) { Control.Anchor |= ObjectAnchor.Left; left = true; }
|
|
||||||
int lx = (left ? Control.Location.X : Size.X - Control.Distance.X - Control.Size.X);
|
|
||||||
int ly = (top ? Control.Location.Y : Size.Y - Control.Distance.Y - Control.Size.Y);
|
|
||||||
int sy = (bottom ? Size.Y - Control.Distance.Y - ly : Control.Size.Y);
|
|
||||||
int sx = (right ? Size.X - Control.Distance.X - lx : Control.Size.X);
|
|
||||||
Control.Size = new(sx, sy);
|
|
||||||
Control.Location = new(lx, ly);
|
|
||||||
if (Control is IParent)
|
|
||||||
{
|
|
||||||
IParent parent = (IParent)Control;
|
|
||||||
parent.Resize(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnResize(ResizeEventArgs e)
|
protected override void OnResize(ResizeEventArgs e)
|
||||||
{
|
{
|
||||||
Resize(e);
|
ParentResize(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rendertype Rendertype { get; set; } = Rendertype.ControlUpdates;
|
||||||
|
|
||||||
|
internal bool CanControleUpdate { get; private set; } = true;
|
||||||
|
|
||||||
|
public int FPS { get; set; } = 0;
|
||||||
|
|
||||||
public void StartRender()
|
public void StartRender()
|
||||||
{
|
{
|
||||||
Context.MakeCurrent();
|
Context.MakeCurrent();
|
||||||
|
ProcessEvents();
|
||||||
|
DrawFrame();
|
||||||
while (Exists && IsVisible && !IsExiting)
|
while (Exists && IsVisible && !IsExiting)
|
||||||
{
|
{
|
||||||
DrawFrame();
|
ProcessEvents();
|
||||||
|
bool u = (Rendertype & Rendertype.ControlUpdates) == Rendertype.ControlUpdates;
|
||||||
|
if (!u) DrawFrame();
|
||||||
|
Thread.Sleep(8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawFrame()
|
public void DrawFrame()
|
||||||
{
|
{
|
||||||
ProcessEvents();
|
|
||||||
GL.ClearColor(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, (BackgroundColor.A * -1) + 1);
|
GL.ClearColor(BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, (BackgroundColor.A * -1) + 1);
|
||||||
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
IEnumerable<IRenderObject> needload = Controls.Where(a => a.Loaded == false);
|
||||||
|
|
||||||
@ -160,6 +174,6 @@ public class Window : NativeWindow , IParent
|
|||||||
if (obj.Loaded) obj.Draw();
|
if (obj.Loaded) obj.Draw();
|
||||||
}
|
}
|
||||||
Context.SwapBuffers();
|
Context.SwapBuffers();
|
||||||
Thread.Sleep(8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
GraphicsManager/freetype6.dll
Executable file
BIN
GraphicsManager/freetype6.dll
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user