mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added UI Project to this repository, small UI fixes
This commit is contained in:
@@ -15,6 +15,7 @@ using System.IO;
|
||||
using GlitchyEngine.Core;
|
||||
using GlitchyEditor.Assets;
|
||||
using GlitchyEngine.Scripting;
|
||||
using static GlitchyEngine.UI.Window;
|
||||
|
||||
namespace GlitchyEditor
|
||||
{
|
||||
@@ -1132,9 +1133,23 @@ namespace GlitchyEditor
|
||||
#endregion Scene Management
|
||||
|
||||
#region ImGui
|
||||
|
||||
|
||||
public static bool HoverCap;
|
||||
public static TitleBarButton HoveredTitleBarButton;
|
||||
public static int2 CursorPos;
|
||||
|
||||
private bool OnImGuiRender(ImGuiRenderEvent event)
|
||||
{
|
||||
if (ImGui.Begin("Test"))
|
||||
{
|
||||
ImGui.Text($"Hover Button {HoveredTitleBarButton}");
|
||||
ImGui.Text($"Hover Button2 {Application.Instance.Windows[1].[Friend]_hoveredTitleBarButton}");
|
||||
ImGui.Text($"Hover Cap {HoverCap}");
|
||||
ImGui.Text($"CursorPos {CursorPos.ToString(.. scope .())}");
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
ImGui.Viewport* viewport = ImGui.GetMainViewport();
|
||||
ImGui.DockSpaceOverViewport(viewport);
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using Ultralight.CAPI;
|
||||
using System;
|
||||
using GlitchyEngine;
|
||||
using static GlitchyEngine.UI.Window;
|
||||
|
||||
namespace GlitchyEditor.Ultralight;
|
||||
|
||||
class UltralightMainWindow : UltralightWindow
|
||||
{
|
||||
public this() : base("Glitchy Engine", "file:///dist/index.html")
|
||||
public this() : base("Glitchy Engine", "file:///index.html")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -32,13 +33,14 @@ class UltralightMainWindow : UltralightWindow
|
||||
_hoveringNonClientArea = JSValueToBoolean(context, arguments[0]);
|
||||
|
||||
_window.[Friend]_hoveredOverTitleBar = _hoveringNonClientArea;
|
||||
|
||||
EditorLayer.HoverCap = _window.[Friend]_hoveredOverTitleBar;
|
||||
|
||||
Log.ClientLogger.Info($"_hoveringNonClientArea: {_hoveringNonClientArea}");
|
||||
}
|
||||
|
||||
void HandleHoverMaximizeWindow(JSContextRef context, JSObjectRef thisObject, Span<JSValueRef> arguments, JSValueRef* exception = null)
|
||||
void HandleHoverTitlebarButton(TitleBarButton button, JSContextRef context, JSObjectRef thisObject, Span<JSValueRef> arguments, JSValueRef* exception = null)
|
||||
{
|
||||
Log.EngineLogger.Info("HandleHoverMaximizeWindow");
|
||||
|
||||
if (arguments.Length != 1)
|
||||
{
|
||||
Log.EngineLogger.Error("EngineGlue.HandleHoverMaximizeWindow: called with wrong number of arguments.");
|
||||
@@ -51,17 +53,9 @@ class UltralightMainWindow : UltralightWindow
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSValueToBoolean(context, arguments[0]))
|
||||
_window.[Friend]_hoveredTitleBarButton = .Maximize;
|
||||
else
|
||||
{
|
||||
_window.[Friend]_hoveredTitleBarButton = .None;
|
||||
Log.ClientLogger.Info($"esar ogsdflkg aerwufg");
|
||||
}
|
||||
|
||||
Enum.SetFlagConditionally(ref _window.[Friend]_hoveredTitleBarButton, button, JSValueToBoolean(context, arguments[0]));
|
||||
|
||||
EditorLayer.HoveredTitleBarButton = _window.[Friend]_hoveredTitleBarButton;
|
||||
|
||||
Log.ClientLogger.Info($"_hoveredTitleBarButton: {_window.[Friend]_hoveredTitleBarButton}");
|
||||
}
|
||||
|
||||
private void RegisterBeefFunction(JSContextRef context, JSObjectRef object, StringView functionName, JSCallback callback)
|
||||
@@ -96,9 +90,14 @@ class UltralightMainWindow : UltralightWindow
|
||||
}
|
||||
|
||||
StdAllocator stdAlloc = StdAllocator();
|
||||
|
||||
RegisterBeefFunction(context, scriptGlue, "setHoverNonClientArea", new:stdAlloc => HandleHoverNonClientArea);
|
||||
RegisterBeefFunction(context, scriptGlue, "setHoverMaximizeWindow", new:stdAlloc => HandleHoverMaximizeWindow);
|
||||
|
||||
RegisterBeefFunction(context, scriptGlue, "handleHoverNonClientArea", new:stdAlloc => HandleHoverNonClientArea);
|
||||
RegisterBeefFunction(context, scriptGlue, "handleHoverMaximizeWindow", new:stdAlloc (c, t, a, e) => HandleHoverTitlebarButton(.Maximize, c, t, a, e));
|
||||
RegisterBeefFunction(context, scriptGlue, "handleHoverMinimizeWindow", new:stdAlloc (c, t, a, e) => HandleHoverTitlebarButton(.Minimize, c, t, a, e));
|
||||
RegisterBeefFunction(context, scriptGlue, "handleHoverCloseWindow", new:stdAlloc (c, t, a, e) => HandleHoverTitlebarButton(.Close, c, t, a, e));
|
||||
RegisterBeefFunction(context, scriptGlue, "handleClickMaximizeWindow", new:stdAlloc (c, t, a, e) => { _window.ToggleMaximize(); });
|
||||
RegisterBeefFunction(context, scriptGlue, "handleClickMinimizeWindow", new:stdAlloc (c, t, a, e) => { _window.Minimize(); });
|
||||
RegisterBeefFunction(context, scriptGlue, "handleClickCloseWindow", new:stdAlloc (c, t, a, e) => { _window.Close(); });
|
||||
}
|
||||
|
||||
protected override void OnDOMReady(C_View* caller, uint64 frame_id, bool is_main_frame, C_String* url)
|
||||
|
||||
@@ -225,11 +225,14 @@ abstract class UltralightWindow
|
||||
|
||||
_cursorPosition = .(e.PositionX, e.PositionY);
|
||||
|
||||
EditorLayer.CursorPos = _cursorPosition;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool MousePressed(MouseButtonEvent e, bool press)
|
||||
{
|
||||
Log.ClientLogger.Warning($"{e.MouseButton} {press} {_cursorPosition.X} {_cursorPosition.Y}");
|
||||
|
||||
ULMouseButton button = .kMouseButton_None;
|
||||
|
||||
|
||||
@@ -54,13 +54,13 @@ class UltralightLayer : Layer
|
||||
|
||||
//ulConfigSetUserStylesheet(config);
|
||||
|
||||
ULString logPath = ulCreateString(@"D:\Development\Projects\Beef\GlitchyEngine\GlitchyEditor\ul.log");
|
||||
/*ULString logPath = ulCreateString(@"D:\Development\Projects\Beef\GlitchyEngine\GlitchyEditor\ul.log");
|
||||
ulEnableDefaultLogger(logPath);
|
||||
ulDestroyString(logPath);
|
||||
ulDestroyString(logPath);*/
|
||||
|
||||
ulEnablePlatformFontLoader();
|
||||
|
||||
ULString fileSystemPath = ulCreateString(@"D:\Development\Projects\Beef\GlitchyEngine\GlitchyEditor\assets");
|
||||
ULString fileSystemPath = ulCreateString("./EditorUI/dist");
|
||||
ulEnablePlatformFileSystem(fileSystemPath);
|
||||
ulDestroyString(fileSystemPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user