Skip to content

Commit

Permalink
Add NativeFileDialog bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Jan 2, 2016
1 parent d101e31 commit 547c149
Show file tree
Hide file tree
Showing 18 changed files with 1,789 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ License terms: http://lwjgl.org/license.php
<arg value="${src.templates.kotlin}/org/lwjgl/egl/EGLTypes.kt" unless:true="${binding.egl}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/glfw" if:true="${binding.glfw}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/nanovg" if:true="${binding.nanovg}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/nfd" if:true="${binding.nfd}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/openal" if:true="${binding.openal}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/opencl" if:true="${binding.opencl}"/>
<arg value="${src.templates.kotlin}/org/lwjgl/opencl/CLTypes.kt" unless:true="${binding.opencl}"/>
Expand Down Expand Up @@ -243,6 +244,7 @@ License terms: http://lwjgl.org/license.php
<include name="org/lwjgl/egl/**" if:true="${binding.egl}"/>
<include name="org/lwjgl/glfw/**" if:true="${binding.glfw}"/>
<include name="org/lwjgl/nanovg/**" if:true="${binding.nanovg}"/>
<include name="org/lwjgl/nfd/**" if:true="${binding.nfd}"/>
<include name="org/lwjgl/openal/**" if:true="${binding.openal}"/>
<include name="org/lwjgl/opencl/**" if:true="${binding.opencl}"/>
<include name="org/lwjgl/opengl/**" if:true="${binding.opengl}"/>
Expand All @@ -255,6 +257,7 @@ License terms: http://lwjgl.org/license.php
<include name="org/lwjgl/egl/**" if:true="${binding.egl}"/>
<include name="org/lwjgl/glfw/**" if:true="${binding.glfw}"/>
<include name="org/lwjgl/nanovg/**" if:true="${binding.nanovg}"/>
<include name="org/lwjgl/nfd/**" if:true="${binding.nfd}"/>
<include name="org/lwjgl/openal/**" if:true="${binding.openal}"/>
<include name="org/lwjgl/opencl/**" if:true="${binding.opencl}"/>
<include name="org/lwjgl/opengl/**" if:true="${binding.opengl}"/>
Expand Down Expand Up @@ -335,6 +338,7 @@ License terms: http://lwjgl.org/license.php
<include name="org/lwjgl/demo/egl/**" if:true="${binding.egl}"/>
<include name="org/lwjgl/demo/glfw/**" if:true="${binding.glfw}"/>
<include name="org/lwjgl/demo/nanovg/**" if:true="${nanovg}"/>
<include name="org/lwjgl/demo/nfd/**" if:true="${binding.nfd}"/>

<include name="org/lwjgl/demo/openal/**" if:true="${binding.openal}"/>
<exclude name="org/lwjgl/demo/openal/ALCDemo.java" unless:true="${openal_stb}"/>
Expand Down
1 change: 1 addition & 0 deletions config/build-bindings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This script is included in /config/build-definitions.xml.

<property name="binding.glfw" value="true"/>
<property name="binding.nanovg" value="true"/>
<property name="binding.nfd" value="true"/>

<property name="binding.openal" value="true"/>
<property name="binding.opencl" value="true"/>
Expand Down
11 changes: 11 additions & 0 deletions config/linux/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ License terms: http://lwjgl.org/license.php
</arguments>
</compile>

<compile if:true="${binding.nfd}">
<arguments>
<arg value="-I${src.include.rel}/nfd"/>
<arg value="-I${src.include.rel}/nfd/include"/>
<fileset dir="." includes="${src.include}/nfd/nfd_common.c"/>
<fileset dir="." includes="${src.include}/nfd/nfd_gtk.c"/>
<fileset dir="." includes="${src.generated.native}/nfd/*.c"/>
</arguments>
</compile>

<compile if:true="${binding.opencl}">
<arguments>
<arg value="-I${src.include.rel}/opencl"/>
Expand Down Expand Up @@ -185,6 +195,7 @@ License terms: http://lwjgl.org/license.php
<arg value="-lm"/>
<arg value="-lrt"/>
<arg value="-lpthread"/>
<arg value="-lgtk-3" if:true="${binding.nfd}"/>

<arg line="-Xlinker --version-script -Xlinker ${version.script}"/>

Expand Down
13 changes: 12 additions & 1 deletion config/macosx/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ License terms: http://lwjgl.org/license.php
</arguments>
</compile>

<compile if:true="${binding.nfd}">
<arguments>
<arg value="-I${src.include.rel}/nfd"/>
<arg value="-I${src.include.rel}/nfd/include"/>
<fileset dir="." includes="${src.include}/nfd/nfd_common.c"/>
<fileset dir="." includes="${src.include}/nfd/nfd_cocoa.m"/>
<fileset dir="." includes="${src.generated.native}/nfd/*.c"/>
</arguments>
</compile>

<compile if:true="${binding.opencl}">
<arguments>
<arg value="-I${src.include.rel}/opencl"/>
Expand Down Expand Up @@ -164,7 +174,8 @@ License terms: http://lwjgl.org/license.php
<apply executable="${compiler}" failonerror="true" parallel="true" taskname="Linker">
<srcfile/>
<arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=${macosx-version-min} -o ${lib}/${LWJGL_LIBRARY}'/>
<arg line="-framework Foundation"/>
<arg line="-framework Foundation" unless:true="${binding.nfd}"/>
<arg line="-framework AppKit" if:true="${binding.nfd}"/>

<fileset refid="link-objects"/>
<fileset refid="link-libraries"/>
Expand Down
17 changes: 17 additions & 0 deletions config/windows/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ License terms: http://lwjgl.org/license.php
</arguments>
</cl>

<cl if:true="${binding.nfd}">
<arguments>
<arg value="/I${src.include}\nfd"/>
<arg value="/I${src.include}\nfd\include"/>
<fileset dir="." includes="${src.generated.native}/nfd/*.c"/>
</arguments>
</cl>

<cl flags="" if:true="${binding.nfd}">
<arguments>
<arg value="/I${src.include}\nfd"/>
<arg value="/I${src.include}\nfd\include"/>
<fileset dir="." includes="${src.include}/nfd/nfd_common.c"/>
<fileset dir="." includes="${src.include}/nfd/nfd_win.cpp"/>
</arguments>
</cl>

<cl if:true="${binding.opencl}">
<arguments>
<arg value="/I${src.include}\opencl"/>
Expand Down
16 changes: 16 additions & 0 deletions doc/3rdparty/nfd_license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

69 changes: 69 additions & 0 deletions modules/core/src/main/include/nfd/include/nfd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Native File Dialog
User API
http://www.frogtoss.com/labs
*/


#ifndef _NFD_H
#define _NFD_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

/* denotes UTF-8 char */
typedef char nfdchar_t;

/* opaque data structure -- see NFD_PathSet_* */
typedef struct {
nfdchar_t *buf;
size_t *indices; /* byte offsets into buf */
size_t count; /* number of indices into buf */
}nfdpathset_t;

typedef enum {
NFD_ERROR, /* programmatic error */
NFD_OKAY, /* user pressed okay, or successful return */
NFD_CANCEL /* user pressed cancel */
}nfdresult_t;


/* nfd_<targetplatform>.c */

/* single file open dialog */
nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList,
const nfdchar_t *defaultPath,
nfdchar_t **outPath );

/* multiple file open dialog */
nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
const nfdchar_t *defaultPath,
nfdpathset_t *outPaths );

/* save dialog */
nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
const nfdchar_t *defaultPath,
nfdchar_t **outPath );

/* nfd_common.c */

/* get last error -- set when nfdresult_t returns NFD_ERROR */
const char *NFD_GetError( void );
/* get the number of entries stored in pathSet */
size_t NFD_PathSet_GetCount( const nfdpathset_t *pathSet );
/* Get the UTF-8 path at offset index */
nfdchar_t *NFD_PathSet_GetPath( const nfdpathset_t *pathSet, size_t index );
/* Free the pathSet */
void NFD_PathSet_Free( nfdpathset_t *pathSet );


#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit 547c149

Please sign in to comment.