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.addIncludeDir("3rdparty/raylib/src");
|
||||
exe.addIncludeDir("3rdparty/raygui/src");
|
||||
exe.addIncludeDir("3rdparty/raygui/examples");
|
||||
exe.addCSourceFile("src/raylib.c", &[_][]u8{});
|
||||
|
||||
exe.setBuildMode(mode);
|
||||
|
|
21
src/main.zig
21
src/main.zig
|
@ -2,21 +2,36 @@ const std = @import("std");
|
|||
const r = @import("raylib.zig");
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
std.log.info("All your codebase are belong to us.", .{});
|
||||
|
||||
r.InitWindow(800, 450, "ray [core] example - basic window");
|
||||
r.InitWindow(800, 450, "doggo");
|
||||
defer r.CloseWindow();
|
||||
|
||||
// var selected_filename: [512]u8 = undefined;
|
||||
var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false);
|
||||
|
||||
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();
|
||||
defer r.EndDrawing();
|
||||
|
||||
r.ClearBackground(r.RAYWHITE);
|
||||
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")) {
|
||||
std.log.info("Button pressed", .{});
|
||||
file_dialog_state.fileDialogActive = true;
|
||||
}
|
||||
r.GuiUnlock();
|
||||
|
||||
r.GuiFileDialog(&file_dialog_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
#define RAYGUI_IMPLEMENTATION
|
||||
#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({
|
||||
@cInclude("raylib.h");
|
||||
@cInclude("raygui.h");
|
||||
@cInclude("custom_file_dialog/gui_file_dialog.h");
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue