try to display file dialog
This commit is contained in:
parent
68df481b8a
commit
af6d9551ef
|
@ -19,6 +19,7 @@ pub fn build(b: *std.build.Builder) void {
|
||||||
exe.linkLibrary(ray);
|
exe.linkLibrary(ray);
|
||||||
exe.addIncludeDir("3rdparty/raylib/src");
|
exe.addIncludeDir("3rdparty/raylib/src");
|
||||||
exe.addIncludeDir("3rdparty/raygui/src");
|
exe.addIncludeDir("3rdparty/raygui/src");
|
||||||
|
exe.addIncludeDir("3rdparty/raygui/examples");
|
||||||
exe.addCSourceFile("src/raylib.c", &[_][]u8{});
|
exe.addCSourceFile("src/raylib.c", &[_][]u8{});
|
||||||
|
|
||||||
exe.setBuildMode(mode);
|
exe.setBuildMode(mode);
|
||||||
|
|
21
src/main.zig
21
src/main.zig
|
@ -2,21 +2,36 @@ const std = @import("std");
|
||||||
const r = @import("raylib.zig");
|
const r = @import("raylib.zig");
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
std.log.info("All your codebase are belong to us.", .{});
|
r.InitWindow(800, 450, "doggo");
|
||||||
|
|
||||||
r.InitWindow(800, 450, "ray [core] example - basic window");
|
|
||||||
defer r.CloseWindow();
|
defer r.CloseWindow();
|
||||||
|
|
||||||
|
// var selected_filename: [512]u8 = undefined;
|
||||||
|
var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false);
|
||||||
|
|
||||||
while (!r.WindowShouldClose()) {
|
while (!r.WindowShouldClose()) {
|
||||||
|
// Update
|
||||||
|
if (file_dialog_state.SelectFilePressed) {
|
||||||
|
std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
r.BeginDrawing();
|
r.BeginDrawing();
|
||||||
defer r.EndDrawing();
|
defer r.EndDrawing();
|
||||||
|
|
||||||
r.ClearBackground(r.RAYWHITE);
|
r.ClearBackground(r.RAYWHITE);
|
||||||
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
|
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
|
||||||
|
|
||||||
|
if (file_dialog_state.fileDialogActive) {
|
||||||
|
r.GuiLock();
|
||||||
|
}
|
||||||
|
|
||||||
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
|
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
|
||||||
std.log.info("Button pressed", .{});
|
std.log.info("Button pressed", .{});
|
||||||
|
file_dialog_state.fileDialogActive = true;
|
||||||
}
|
}
|
||||||
|
r.GuiUnlock();
|
||||||
|
|
||||||
|
r.GuiFileDialog(&file_dialog_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#include <raygui.h>
|
#include <raygui.h>
|
||||||
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||||
|
|
||||||
|
#define GUI_FILE_DIALOG_IMPLEMENTATION
|
||||||
|
#include <custom_file_dialog/gui_file_dialog.h>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pub usingnamespace @cImport({
|
pub usingnamespace @cImport({
|
||||||
@cInclude("raylib.h");
|
@cInclude("raylib.h");
|
||||||
@cInclude("raygui.h");
|
@cInclude("raygui.h");
|
||||||
|
@cInclude("custom_file_dialog/gui_file_dialog.h");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue