Skip to content

Commit

Permalink
[API] Dear ImGui v1.81
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Feb 20, 2021
1 parent ec9226c commit 08bf84a
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 379 deletions.
29 changes: 14 additions & 15 deletions buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GenerateLibs extends DefaultTask {
private final boolean forMac64 = buildEnvs?.contains('mac64')

private final boolean isLocal = System.properties.containsKey("local")
private final boolean withFreeType = System.properties.containsKey("withFreeType")
private final boolean withFreeType = System.properties.containsKey("freetype")

private final String sourceDir = project.file('src/main/java')
private final String classpath = project.file('build/classes/java/main')
Expand All @@ -42,16 +42,17 @@ class GenerateLibs extends DefaultTask {
['include/imgui', 'include/imnodes', 'include/imgui-node-editor'].each {
spec.from(project.rootProject.file(it)) { CopySpec s -> s.include('*.h', '*.cpp', '*.inl') }
}
spec.from(project.rootProject.file('imgui-binding/src/main/native'))
spec.into(jniDir)
}

if (withFreeType) {
if (withFreeType) {
project.copy { CopySpec spec ->
spec.from(project.rootProject.file('include/imgui/misc/freetype')) { CopySpec it -> it.include('*.h', '*.cpp') }
spec.into("$jniDir/misc/freetype")
}

spec.into(jniDir)
}

project.copy {CopySpec spec ->
spec.from(project.rootProject.file('imgui-binding/src/main/native')).into(jniDir)
enableDefine('IMGUI_ENABLE_FREETYPE')
}

// Generate platform dependant ant configs and header files
Expand Down Expand Up @@ -104,8 +105,8 @@ class GenerateLibs extends DefaultTask {
def minMacOsVersion = '10.15'
def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
mac64.cppFlags += ' -std=c++14 -stdlib=libc++'
mac64.cppFlags = mac64.cppFlags.replace('10.5', minMacOsVersion).replace('10.7', minMacOsVersion)
mac64.linkerFlags = mac64.linkerFlags.replace('10.5', minMacOsVersion).replace('10.7', minMacOsVersion)
mac64.cppFlags = mac64.cppFlags.replace('10.7', minMacOsVersion)
mac64.linkerFlags = mac64.linkerFlags.replace('10.7', minMacOsVersion)

if (withFreeType) {
mac64.cppFlags += ' -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include'
Expand All @@ -117,12 +118,6 @@ class GenerateLibs extends DefaultTask {

new AntScriptGenerator().generate(buildConfig, buildTargets)

if (!withFreeType) {
project.delete {
it.delete("$jniDir/imgui_ImGuiFreeType.cpp", "$jniDir/imgui_ImGuiFreeType.h")
}
}

// Generate native libraries
// Comment/uncomment lines with OS you need.

Expand All @@ -139,4 +134,8 @@ class GenerateLibs extends DefaultTask {

BuildExecutor.executeAnt(jniDir + '/build.xml', '-v', 'pack-natives')
}

void enableDefine(String define) {
project.file("$jniDir/imconfig.h").text += "#define $define"
}
}
18 changes: 10 additions & 8 deletions imgui-binding/src/main/java/imgui/ImFontConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected long create() {

/**
* Rasterize at higher quality for sub-pixel positioning.
* Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory.
* Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
*/
public native int getOversampleH(); /*
Expand All @@ -124,6 +125,7 @@ protected long create() {

/**
* Rasterize at higher quality for sub-pixel positioning.
* Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory.
* Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
*/
public native void setOversampleH(int oversampleH); /*
Expand All @@ -132,15 +134,15 @@ protected long create() {

/**
* Rasterize at higher quality for sub-pixel positioning.
* We don't use sub-pixel positions on the Y axis.
* This is not really useful as we don't use sub-pixel positions on the Y axis.
*/
public native int getOversampleV(); /*
return IM_FONT_CONFIG->OversampleV;
*/

/**
* Rasterize at higher quality for sub-pixel positioning.
* We don't use sub-pixel positions on the Y axis.
* This is not really useful as we don't use sub-pixel positions on the Y axis.
*/
public native void setOversampleV(int oversampleV); /*
IM_FONT_CONFIG->OversampleV = oversampleV;
Expand Down Expand Up @@ -286,17 +288,17 @@ public void setGlyphRanges(final short[] glyphRanges) {
*/

/**
* Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one.
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public native int getRasterizerFlags(); /*
return IM_FONT_CONFIG->RasterizerFlags;
public native int getFontBuilderFlags(); /*
return IM_FONT_CONFIG->FontBuilderFlags;
*/

/**
* Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one.
* Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
*/
public native void setRasterizerFlags(int rasterizerFlags); /*
IM_FONT_CONFIG->RasterizerFlags = (unsigned int)rasterizerFlags;
public native void setFontBuilderFlags(int fontBuilderFlags); /*
IM_FONT_CONFIG->FontBuilderFlags = (unsigned int)fontBuilderFlags;
*/

/**
Expand Down
30 changes: 22 additions & 8 deletions imgui-binding/src/main/java/imgui/ImFontGlyph.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,47 @@ protected long create() {
*/

/**
* 0x0000..0xFFFF
* Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops).
*/
public native int getCodepoint(); /*
return (unsigned int)IM_FONT_GLYPH->Codepoint;
public native int getColored(); /*
return (unsigned int)IM_FONT_GLYPH->Colored;
*/

/**
* 0x0000..0xFFFF
* Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops).
*/
public native void setCodepoint(int codepoint); /*
IM_FONT_GLYPH->Codepoint = (unsigned int)codepoint;
public native void setColored(int colored); /*
IM_FONT_GLYPH->Colored = (unsigned int)colored;
*/

/**
* Flag to allow early out when rendering
* Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
*/
public native int getVisible(); /*
return (unsigned int)IM_FONT_GLYPH->Visible;
*/

/**
* Flag to allow early out when rendering
* Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
*/
public native void setVisible(int visible); /*
IM_FONT_GLYPH->Visible = (unsigned int)visible;
*/

/**
* 0x0000..0xFFFF
*/
public native int getCodepoint(); /*
return (unsigned int)IM_FONT_GLYPH->Codepoint;
*/

/**
* 0x0000..0xFFFF
*/
public native void setCodepoint(int codepoint); /*
IM_FONT_GLYPH->Codepoint = (unsigned int)codepoint;
*/

/**
* Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
*/
Expand Down
Loading

0 comments on commit 08bf84a

Please sign in to comment.