Cross-platform utility library for Odin to open native dialogs for the filesystem, message boxes, color-picking.
| Linux | Windows | macOS |
|---|---|---|
| | |
-
Add it as a submodule to your Odin Git project
# <projects-path>/your-awesome-odin-project git submodule add https://github.com/ttytm/osdialog-odin.git osdialog -
Prepare the C Binding
Unix-like
cd osdialog && make && cd -
Windows
cd osdialog nmake cd ..
Ref.: osdialog-odin/osdialog.odin
// Opens a message box and returns `true` if "OK" or "Yes" was pressed. message :: proc(message: string, level: MessageLevel = .Info, buttons: MessageButtons = .Ok) -> bool // Opens an input prompt with an "OK" and "Cancel" button and returns the entered text and `true`, // or `false` if the dialog was cancelled. `text` optionally sets the initial content of the input box. prompt :: proc(message: string, text: string = "", level: MessageLevel = .Info) -> (string, bool) #optional_ok // Opens a file dialog and returns the selected path and `true` or `false` if the selection was canceled. path :: proc(action: PathAction, path: string = "", filename: string = "") -> (string, bool) #optional_ok // Opens an RGBA color picker and returns the selected `Color` and `true`, or `false` if the selection was canceled. // Optionally, it takes a `color` and `opacity` argument. `color` sets the dialogs initial color. `opacity` can be // set to `false` to disable the opacity slider on unix-like systems. It has no effect on Windows. color :: proc(color: Color = {255, 255, 255, 255}, opacity: bool = true) -> (Color, bool) #optional_okRef.: osdialog-odin/examples/main.odin
package main import osd "osdialog" import "core:fmt" main :: proc() { osd.message("Hello, World!") input := osd.prompt("Give me some input") fmt.println("Input:", input) if color, ok := osd.color(); ok { fmt.println("Selected color", color) } if path, ok := osd.path(.Open); ok { fmt.println("Selected file:", path) } if path, ok := osd.path(.Open_Dir); ok { fmt.println("Selected dir", path) } if path, ok := osd.path(.Save); ok { fmt.println("Selected save path", path) } }For a simple local run:
Unix-like
One-shot copy pasta to perform a lighter, filtered development clone and build the C binding target.
git clone --recursive --filter=blob:none --also-filter-submodules \ https://github.com/ttytm/osdialog-odin \ && cd osdialog-odin && makeWindows
git clone --recursive --filter=blob:none --also-filter-submodules https://github.com/ttytm/osdialog-odincd osdialog-odin nmakeRun the example
odin run examples/main.odin -file- AndrewBelt/osdialog - The C project this library is leveraging














