Skip to content

Commit 7c124e5

Browse files
committed
Dear ImGui integration
Ported the example win32 & d3d11 backends from the main imgui repo. I didn't bother implementing gamepads or multi-viewport yet since Nanoforge doesn't use them yet. Multi viewports also looks like a pain to convert.
1 parent d59f12a commit 7c124e5

28 files changed

+1541
-176
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,4 @@ recovery/
285285
build/
286286

287287
BeefSpace_User.toml
288+
imgui.ini

Assets/fonts/NotoSans-SemiBold.ttf

544 KB
Binary file not shown.
-351 KB
Binary file not shown.

BeefProj.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ Dependencies = {corlib = "*", ImGui = "*"}
33

44
[Project]
55
Name = "Nanoforge"
6-
TargetType = "BeefGUIApplication"
76
StartupObject = "Nanoforge.Program"

src/App/App.bf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Collections;
22
using System.Diagnostics;
33
using System.Reflection;
4+
using Nanoforge.Misc;
45
using Nanoforge.Math;
56
using System;
67

78
namespace Nanoforge.App
89
{
10+
[ReflectAll]
911
public enum AppState
1012
{
1113
None,

src/Gui/FontManager.bf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Nanoforge.Gui
1616
private static append List<u16> _iconRanges = .();
1717
public static bool EnableNonLatinGlyphs = false; //Currently disabled by default since I (only dev) only use english & enabling these increases boot time. Will enable when necessary
1818

19-
public static void RegisterFonts(BuildConfig buildConfig)
19+
public static void LoadFonts(BuildConfig buildConfig)
2020
{
2121
static bool firstRun = true;
2222
if (firstRun) //Build glyph list the first time this is called

src/Gui/Gui.bf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace Nanoforge.Gui
3232
[SystemStage(.Update)]
3333
void Update(App app)
3434
{
35-
/*for (var layer in Layers)
35+
for (var layer in Layers)
3636
if (layer.Enabled)
37-
layer.Update(app);*/
37+
layer.Update(app);
3838
}
3939

4040
//Destroys all gui layers and their modules
@@ -94,7 +94,7 @@ namespace Nanoforge.Gui
9494
}
9595

9696
//Helper functions & constants
97-
public static Vec4<f32> SecondaryTextColor => .(0.2f, 0.7f, 1.0f, 1.00f) * 0.92f; //Light blue;
97+
public static Vec4<f32> SecondaryTextColor => .(0.32f, 0.67f, 1.0f, 1.00f);//.(0.2f, 0.7f, 1.0f, 1.00f) * 0.92f; //Light blue;
9898
public static Vec4<f32> TertiaryTextColor => .(0.64f, 0.67f, 0.69f, 1.00f); //Light grey;
9999
public static Vec4<f32> Red => .(0.784f, 0.094f, 0.035f, 1.0f);
100100

src/Gui/Panels/MainMenuBar.bf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ namespace Nanoforge.Gui.Panels
6060
private void DrawDockspace(App app)
6161
{
6262
//Dockspace flags
63-
dockspaceFlags = ImGui.DockNodeFlags.None | ImGui.DockNodeFlags.PassthruCentralNode;
63+
dockspaceFlags = ImGui.DockNodeFlags.None;
6464

6565
//Parent window flags
66-
ImGui.WindowFlags windowFlags = ImGui.WindowFlags.NoDocking | ImGui.WindowFlags.NoTitleBar | ImGui.WindowFlags.NoCollapse
67-
| ImGui.WindowFlags.NoResize | ImGui.WindowFlags.NoMove
68-
| ImGui.WindowFlags.NoBringToFrontOnFocus | ImGui.WindowFlags.NoNavFocus | ImGui.WindowFlags.NoBackground;
66+
ImGui.WindowFlags windowFlags = .NoDocking | .NoTitleBar | .NoCollapse | .NoResize | .NoMove | .NoBringToFrontOnFocus | .NoNavFocus | .NoBackground;
6967

7068
//Set dockspace size and params
7169
var viewport = ImGui.GetMainViewport();

src/Misc/Extensions.bf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace System
2424
return str;
2525
}
2626

27-
public static String ValueToString<T>(String str, T value)
27+
public static String ValueToString<T>(String str, T value) where T : operator explicit int, enum
2828
{
29-
T val = value;
29+
int val = (int)value;
3030
Type type = typeof(T);
3131
Runtime.Assert(type.IsEnum);
3232
for (var enumField in type.GetFields())

0 commit comments

Comments
 (0)