From ffee0b679194e6ae7cbe0aae814d0c42a766d923 Mon Sep 17 00:00:00 2001 From: Aidan Lee Date: Wed, 17 Jan 2018 15:29:07 +0000 Subject: [PATCH] Added CustomRect API to ImFontAtlas --- imgui/font/ImFontAtlas.hx | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/imgui/font/ImFontAtlas.hx b/imgui/font/ImFontAtlas.hx index e940d80..3027843 100644 --- a/imgui/font/ImFontAtlas.hx +++ b/imgui/font/ImFontAtlas.hx @@ -1,7 +1,7 @@ package imgui.font; import imgui.ImGui; -import imgui.util.ImVector; +import imgui.util.ImVec2; import cpp.UInt8; import cpp.Pointer; import cpp.ConstPointer; @@ -71,9 +71,9 @@ extern class ImFontAtlas */ @:native('Clear') function clear() : Void; - // ------------------------------// + //-------------------------------// // Build and retrieve pixel data // - // ------------------------------// + //-------------------------------// @:native('Build') function build() : Void; @:native('ImGui::linc::GetTexDataAsRGBA32') private static function _getTexDataAsRGBA32(_atlas : Pointer, _outWidth : Int, _outHeight : Int) : Pointer; @@ -129,6 +129,18 @@ extern class ImFontAtlas @return ConstPointer */ @:native('GetGlyphRangesThai') function getGlyphRangesThai() : ConstPointer; + + //--------------------------------// + // Custom Rectangles / Glyphs API // + //--------------------------------// + + @:native('AddCustomRectRegular') public function addCustomRectRegular(_id : Int, _width : Int, _height : Int) : Int; + + @:overload(function(_font : Pointer, _id : ImWchar, _width : Int, _height : Int, _advanceX : Float) : Int {}) + @:native('AddCustomRectFontGlyph') public function AddCustomRectFontGlyph(_font : Pointer, _id : ImWchar, _width : Int, _height : Int, _advanceX : Float, _offset : ImVec2) : Int; + + @:native('CalcCustomRectUV') public function calcCustomRectUV(_rect : ConstPointer, _outUVMin : Pointer, _outUVMax : Pointer) : Void; + @:native('GetCustomRectByIndex') public function getCustomRectByIndex(_index : Int) : ConstPointer; } @:native('ImFontAtlas::GlyphRangesBuilder') @@ -148,3 +160,21 @@ extern class GlyphRangesBuilder @:native('AddRanges') public function addRanges(_ranges : ConstPointer) : Void; @:native('BuildRanges') public function buildRanges(_outRanges : Pointer) : Void; } + +@:native('ImFontAtlas::CustomRect') +@:structAccess +@:unreflective +extern class CustomRect +{ + @:native('ID') public var id : Int; + @:native('Width') public var width : Int; + @:native('Height') public var height : Int; + @:native('X') public var x : Int; + @:native('Y') public var y : Int; + @:native('GlyphAdvanceX') public var glyphAdvanceX : Float; + @:native('GlyphOffset') public var glyphOffset : ImVec2; + @:native('Font') public var font : cpp.RawPointer; + + @:native('new ImFontAtlas::CustomRect') public static function create() : Pointer; + @:native('IsPacked') public function isPacked() : Bool; +}