Skip to content

Commit

Permalink
Added CustomRect API to ImFontAtlas
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan63 committed Jan 17, 2018
1 parent 7969b28 commit ffee0b6
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions imgui/font/ImFontAtlas.hx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ImFontAtlas>, _outWidth : Int, _outHeight : Int) : Pointer<UInt8>;
Expand Down Expand Up @@ -129,6 +129,18 @@ extern class ImFontAtlas
@return ConstPointer<ImWchar>
*/
@:native('GetGlyphRangesThai') function getGlyphRangesThai() : ConstPointer<ImWchar>;

//--------------------------------//
// Custom Rectangles / Glyphs API //
//--------------------------------//

@:native('AddCustomRectRegular') public function addCustomRectRegular(_id : Int, _width : Int, _height : Int) : Int;

@:overload(function(_font : Pointer<ImFont>, _id : ImWchar, _width : Int, _height : Int, _advanceX : Float) : Int {})
@:native('AddCustomRectFontGlyph') public function AddCustomRectFontGlyph(_font : Pointer<ImFont>, _id : ImWchar, _width : Int, _height : Int, _advanceX : Float, _offset : ImVec2) : Int;

@:native('CalcCustomRectUV') public function calcCustomRectUV(_rect : ConstPointer<CustomRect>, _outUVMin : Pointer<ImVec2>, _outUVMax : Pointer<ImVec2>) : Void;
@:native('GetCustomRectByIndex') public function getCustomRectByIndex(_index : Int) : ConstPointer<CustomRect>;
}

@:native('ImFontAtlas::GlyphRangesBuilder')
Expand All @@ -148,3 +160,21 @@ extern class GlyphRangesBuilder
@:native('AddRanges') public function addRanges(_ranges : ConstPointer<ImWchar>) : Void;
@:native('BuildRanges') public function buildRanges(_outRanges : Pointer<ImVectorImWchar>) : 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<ImVec2>;

@:native('new ImFontAtlas::CustomRect') public static function create() : Pointer<CustomRect>;
@:native('IsPacked') public function isPacked() : Bool;
}

0 comments on commit ffee0b6

Please sign in to comment.