Refactor depencies, add clay to the repo in preparation to move from raygui to clay
This commit is contained in:
parent
d748f742f7
commit
3c4ad68059
10 changed files with 528 additions and 81 deletions
32
vendors/dialog/tinyfiledialog.odin
vendored
32
vendors/dialog/tinyfiledialog.odin
vendored
|
|
@ -1,32 +0,0 @@
|
|||
package tinyfiledialogs
|
||||
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib {"tinyfiledialogs.lib", "system:comdlg32.lib", "system:Ole32.lib"}
|
||||
} else when ODIN_OS == .Linux || ODIN_OS == .Darwin {
|
||||
foreign import lib "libtinyfiledialogs.a"
|
||||
}
|
||||
|
||||
foreign lib {
|
||||
@(link_name = "tinyfd_notifyPopup")
|
||||
notify_popup :: proc(title, message, icon_type: cstring) -> c.int ---
|
||||
|
||||
@(link_name = "tinyfd_messageBox")
|
||||
message_box :: proc(title, message, dialog_type, icon_type: cstring, default_button: c.int) -> c.int ---
|
||||
|
||||
@(link_name = "tinyfd_inputBox")
|
||||
input_box :: proc(title, message, default_input: cstring) -> [^]c.char ---
|
||||
|
||||
@(link_name = "tinyfd_saveFileDialog")
|
||||
save_file_dialog :: proc(title, default_path: cstring, pattern_count: c.int, patterns: [^]cstring, file_desc: cstring) -> [^]c.char ---
|
||||
|
||||
@(link_name = "tinyfd_openFileDialog")
|
||||
open_file_dialog :: proc(title, default_path: cstring, pattern_count: c.int, patterns: [^]cstring, file_desc: cstring, allow_multi: c.int) -> [^]c.char ---
|
||||
|
||||
@(link_name = "tinyfd_selectFolderDialog")
|
||||
select_folder_dialog :: proc(title, default_path: cstring) -> [^]c.char ---
|
||||
|
||||
@(link_name = "tinyfd_colorChooser")
|
||||
color_chooser :: proc(title, default_hex_rgb: cstring, default_rgb, result_rgb: [3]byte) -> [^]c.char ---
|
||||
}
|
||||
161
vendors/dialog/tinyfiledialogs.odin
vendored
Normal file
161
vendors/dialog/tinyfiledialogs.odin
vendored
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
package tinyfiledialogs
|
||||
|
||||
import "core:c"
|
||||
import "core:mem"
|
||||
import "core:strings"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib {"tinyfiledialogs.lib", "system:comdlg32.lib", "system:Ole32.lib"}
|
||||
} else when ODIN_OS == .Linux || ODIN_OS == .Darwin {
|
||||
foreign import lib "libtinyfiledialogs.a"
|
||||
}
|
||||
|
||||
@(default_calling_convention = "c", link_prefix = "tinyfd_")
|
||||
foreign lib {
|
||||
notifyPopup :: proc(title, message, icon_type: cstring) -> c.int ---
|
||||
|
||||
messageBox :: proc(title, message, dialog_type, icon_type: cstring, default_button: c.int) -> c.int ---
|
||||
inputBox :: proc(title, message, default_input: cstring) -> cstring ---
|
||||
|
||||
saveFileDialog :: proc(title, default_path: cstring, pattern_count: c.int, patterns: [^]cstring, file_desc: cstring) -> cstring ---
|
||||
openFileDialog :: proc(title, default_path: cstring, pattern_count: c.int, patterns: [^]cstring, file_desc: cstring, allow_multi: c.int) -> cstring ---
|
||||
|
||||
selectFolderDialog :: proc(title, default_path: cstring) -> cstring ---
|
||||
|
||||
colorChooser :: proc(title, default_hex_rgb: cstring, default_rgb, result_rgb: [3]byte) -> cstring ---
|
||||
}
|
||||
|
||||
select_folder_dialog :: proc(
|
||||
title, default_path: string,
|
||||
alloc := context.allocator,
|
||||
temp_alloc := context.temp_allocator,
|
||||
) -> (
|
||||
path: string,
|
||||
success: bool,
|
||||
) {
|
||||
ctitle: cstring = nil
|
||||
cdefault_path: cstring = nil
|
||||
err: mem.Allocator_Error
|
||||
|
||||
if len(title) > 0 {
|
||||
ctitle, err = strings.clone_to_cstring(title, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
if len(default_path) > 0 {
|
||||
cdefault_path, err = strings.clone_to_cstring(default_path, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
res := selectFolderDialog(ctitle, cdefault_path)
|
||||
path, err = strings.clone_from_cstring(res, alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
return path, true
|
||||
}
|
||||
|
||||
save_file_dialog :: proc(
|
||||
title, default_path: string,
|
||||
pattern_count: i32,
|
||||
patterns: []string,
|
||||
file_desc: string,
|
||||
alloc := context.allocator,
|
||||
temp_alloc := context.temp_allocator,
|
||||
) -> (
|
||||
path: string,
|
||||
success: bool,
|
||||
) {
|
||||
ctitle: cstring = nil
|
||||
cdefault_path: cstring = nil
|
||||
cfile_desc: cstring = nil
|
||||
cpatterns: [^]cstring = nil
|
||||
err: mem.Allocator_Error
|
||||
|
||||
if len(title) > 0 {
|
||||
ctitle, err = strings.clone_to_cstring(title, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
if len(default_path) > 0 {
|
||||
cdefault_path, err = strings.clone_to_cstring(default_path, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
if len(cfile_desc) > 0 {
|
||||
cfile_desc, err = strings.clone_to_cstring(file_desc, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
|
||||
if pattern_count > 0 {
|
||||
cpatterns = make([^]cstring, pattern_count + 1, temp_alloc)
|
||||
for p, i in patterns {
|
||||
cpatterns[i] = strings.clone_to_cstring(p)
|
||||
}
|
||||
cpatterns[pattern_count] = nil // null terminate the array
|
||||
}
|
||||
res := saveFileDialog(ctitle, cdefault_path, pattern_count, cpatterns, cfile_desc)
|
||||
path, err = strings.clone_from_cstring(res, alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
return path, true
|
||||
}
|
||||
|
||||
open_file_dialog :: proc(
|
||||
title, default_path: string,
|
||||
pattern_count: i32,
|
||||
patterns: []string,
|
||||
file_desc: string,
|
||||
allow_multi: i32,
|
||||
alloc := context.allocator,
|
||||
temp_alloc := context.temp_allocator,
|
||||
) -> (
|
||||
path: string,
|
||||
success: bool,
|
||||
) {
|
||||
ctitle: cstring = nil
|
||||
cdefault_path: cstring = nil
|
||||
cfile_desc: cstring = nil
|
||||
cpatterns: [^]cstring = nil
|
||||
err: mem.Allocator_Error
|
||||
|
||||
if len(title) > 0 {
|
||||
ctitle, err = strings.clone_to_cstring(title, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
if len(default_path) > 0 {
|
||||
cdefault_path, err = strings.clone_to_cstring(default_path, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
if len(cfile_desc) > 0 {
|
||||
cfile_desc, err = strings.clone_to_cstring(file_desc, temp_alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
}
|
||||
|
||||
if pattern_count > 0 {
|
||||
cpatterns = make([^]cstring, pattern_count + 1, temp_alloc)
|
||||
for p, i in patterns {
|
||||
cpatterns[i] = strings.clone_to_cstring(p)
|
||||
}
|
||||
cpatterns[pattern_count] = nil // null terminate the array
|
||||
}
|
||||
res := openFileDialog(ctitle, cdefault_path, pattern_count, cpatterns, cfile_desc, allow_multi)
|
||||
path, err = strings.clone_from_cstring(res, alloc)
|
||||
if err != nil {
|
||||
return {}, false
|
||||
}
|
||||
return path, true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue