A squash of hundreds of commits with a binding API generator. The API generator works with a hybrid model: 1. We define methods and fields in the code. 2. Mark them with API annotations. 3. For specific use cases, we use the old approach with JNI generation comments. There is also an API to generate an AST tree, which is saved to JSON. This JSON can be used for full API generation by declaring only field/method names. Currently, it is used to generate constants. By eyeballing, 95% of the API has been converted to the new approach. This is sufficient for the current moment. Only edge cases with specific API calls are left. fix: ambiguous call for ImGui::GetColorU32 build: disable checkstyle for imgui-binding module Since the module is heavily generated, checkstyle for it doesn't make sense. build: make buildSrc to use JDK 11 build: make generateApi optional when compiling project Initially generated module was not included to the project VCS. Since it's now in the separate src folder, we don't need to call generator every time. Only when a new generation result is required.
143 lines
3.8 KiB
Java
143 lines
3.8 KiB
Java
package imgui;
|
|
|
|
import imgui.binding.ImGuiStructDestroyable;
|
|
import imgui.binding.annotation.ArgValue;
|
|
import imgui.binding.annotation.BindingField;
|
|
import imgui.binding.annotation.BindingMethod;
|
|
import imgui.binding.annotation.BindingSource;
|
|
import imgui.binding.annotation.OptArg;
|
|
import imgui.binding.annotation.ReturnValue;
|
|
|
|
/**
|
|
* Font runtime data and rendering
|
|
* ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
|
*/
|
|
@BindingSource
|
|
public final class ImFont extends ImGuiStructDestroyable {
|
|
public ImFont() {
|
|
}
|
|
|
|
public ImFont(final long ptr) {
|
|
super(ptr);
|
|
}
|
|
|
|
@Override
|
|
protected long create() {
|
|
return nCreate();
|
|
}
|
|
|
|
/*JNI
|
|
#include "_common.h"
|
|
#define THIS ((ImFont*)STRUCT_PTR)
|
|
*/
|
|
|
|
private native long nCreate(); /*
|
|
return (intptr_t)(new ImFont());
|
|
*/
|
|
|
|
// TODO IndexAdvanceX
|
|
|
|
/**
|
|
* = FallbackGlyph.AdvanceX
|
|
*/
|
|
@BindingField
|
|
public float FallbackAdvanceX;
|
|
|
|
/**
|
|
* Height of characters/line, set during loading (don't change after loading)
|
|
*/
|
|
@BindingField
|
|
public float FontSize;
|
|
|
|
// TODO IndexLookup, Glyphs
|
|
|
|
/**
|
|
* = FindGlyph(FontFallbackChar)
|
|
*/
|
|
@BindingField
|
|
@ReturnValue(isStatic = true)
|
|
public ImFontGlyph FallbackGlyph;
|
|
|
|
// TODO ContainerAtlas, ConfigData
|
|
|
|
/**
|
|
* Number of ImFontConfig involved in creating this font.
|
|
* Bigger than 1 when merging multiple font sources into one ImFont.
|
|
*/
|
|
@BindingField
|
|
public short ConfigDataCount;
|
|
|
|
/**
|
|
* Character used for ellipsis rendering.
|
|
*/
|
|
@BindingField
|
|
public short EllipsisChar;
|
|
|
|
/**
|
|
* Character used for ellipsis rendering (if a single '...' character isn't found)
|
|
*/
|
|
@BindingField
|
|
public short DotChar;
|
|
|
|
@BindingField
|
|
public boolean DirtyLookupTables;
|
|
|
|
/**
|
|
* Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
|
*/
|
|
@BindingField
|
|
public float Scale;
|
|
|
|
/**
|
|
* Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
|
*/
|
|
@BindingField
|
|
public float Ascent;
|
|
|
|
@BindingField
|
|
public float Descent;
|
|
|
|
/**
|
|
* Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
|
*/
|
|
@BindingField
|
|
public int MetricsTotalSurface;
|
|
|
|
// Methods
|
|
|
|
@BindingMethod
|
|
public native ImFontGlyph FindGlyph(@ArgValue(callPrefix = "(ImWchar)") int c);
|
|
|
|
@BindingMethod
|
|
public native ImFontGlyph FindGlyphNoFallback(@ArgValue(callPrefix = "(ImWchar)") int c);
|
|
|
|
@BindingMethod
|
|
public native float GetCharAdvance(@ArgValue(callPrefix = "(ImWchar)") int c);
|
|
|
|
@BindingMethod
|
|
public native boolean IsLoaded();
|
|
|
|
@BindingMethod
|
|
public native String GetDebugName();
|
|
|
|
/**
|
|
* 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
|
* 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
|
*/
|
|
@BindingMethod
|
|
public native ImVec2 CalcTextSizeA(float size, float maxWidth, float wrapWidth, String textBegin, @OptArg String textEnd);
|
|
|
|
@BindingMethod
|
|
public native String CalcWordWrapPositionA(float scale, String text, String textEnd, float wrapWidth);
|
|
|
|
@BindingMethod
|
|
public native void RenderChar(ImDrawList drawList, float size, ImVec2 pos, int col, @ArgValue(callPrefix = "(ImWchar)") int c);
|
|
|
|
@BindingMethod
|
|
public native void RenderText(ImDrawList drawList, float size, ImVec2 pos, int col, ImVec4 clipRect, String textBegin, String textEnd, @OptArg(callValue = "0.0f") float wrapWidth, @OptArg boolean cpuFineClip);
|
|
|
|
/*JNI
|
|
#undef THIS
|
|
*/
|
|
}
|