Skip to content

Commit

Permalink
Merge branch 'ImVector_impl'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan63 committed Feb 11, 2018
2 parents 9af2903 + 24a56fa commit 54a3a78
Show file tree
Hide file tree
Showing 17 changed files with 404 additions and 154 deletions.
26 changes: 26 additions & 0 deletions imgui/ImGui.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,32 @@ extern class ImGui
@:native('ImGui::SetClipboardText') static function setClipboardText(_text : String) : Void;
}

// Globally User ImVector wrappers

@:native('ImVector<ImWchar>')
@:structAccess
@:unreflective
extern class ImVectorImWchar extends ImVector<ImWchar>
{
//
}

@:native('ImVector<float>')
@:structAccess
@:unreflective
extern class ImVectorFloat extends ImVector<Float>
{
//
}

@:native('ImVector<unsigned short>')
@:structAccess
@:unreflective
extern class ImVectorInt extends ImVector<cpp.UInt16>
{
//
}

//-------//
// Enums //
//-------//
Expand Down
14 changes: 14 additions & 0 deletions imgui/draw/ImDrawChannel.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package imgui.draw;

import imgui.draw.ImDrawCmd;
import imgui.draw.ImDrawIdx;

@:include('linc_imgui.h')
@:native('ImDrawChannel')
@:unreflective
@:structAccess
extern class ImDrawChannel
{
@:native('CmdBuffer') public var cmdBuffer : ImDrawCmdVector;
@:native('IdxBuffer') public var idxBuffer : ImDrawIdxVector;
}
20 changes: 14 additions & 6 deletions imgui/draw/ImDrawCmd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package imgui.draw;

import imgui.ImGui;
import imgui.util.ImVec4;
import cpp.Pointer;
import imgui.util.ImVector;
import cpp.ConstPointer;
import cpp.Void;
import cpp.Callable;
Expand All @@ -19,27 +19,35 @@ extern class ImDrawCmd
Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
*/
public var ElemCount : UInt;
@:native('ElemCount') public var elemCount : UInt;

/**
Clipping rectangle (x1, y1, x2, y2)
*/
public var ClipRect : ImVec4;
@:native('ClipRect') public var clipRect : ImVec4;

/**
User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions.
Ignore if never using images or multiple fonts atlas.
*/
public var TextureId : ImTextureID;
@:native('TextureId') public var textureID : ImTextureID;

/**
If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
*/
public var UserCallback : Callable<ConstPointer<ImDrawList>->ConstPointer<ImDrawCmd>->Void>;
@:native('UserCallback') public var userCallback : Callable<ConstPointer<ImDrawList>->ConstPointer<ImDrawCmd>->Void>;

/**
The draw callback code can access this.
*/
public var UserCallbackData : Pointer<Void>;
@:native('UserCallbackData') public var userCallbackData : cpp.RawPointer<cpp.Void>;
}

@:native('ImVector<ImDrawCmd>')
@:structAccess
@:unreflective
extern class ImVectorImDrawCmd extends ImVector<ImDrawCmd>
{
@:native('ImVector<ImDrawCmd>') public static function create() : ImVectorImDrawCmd;
}
10 changes: 5 additions & 5 deletions imgui/draw/ImDrawData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import imgui.util.ImVec2;
@:unreflective
extern class ImDrawData
{
public var Valid : Bool;
public var CmdLists : RawPointer<RawPointer<ImDrawList>>;
public var CmdListsCount : Int;
public var TotalVtxCount : Int;
public var TotalIdxCount : Int;
@:native('Valid') public var valid : Bool;
@:native('CmdLists') public var cmdLists : RawPointer<RawPointer<ImDrawList>>;
@:native('CmdListsCount') public var cmdListsCount : Int;
@:native('TotalVtxCount') public var totalVtxCount : Int;
@:native('TotalIdxCount') public var totalIdxCount : Int;

@:native('ImDrawData') static function create() : Pointer<ImDrawData>;
@:native('ImGui::linc::GetDrawList') static function getDrawList(_data : Pointer<ImDrawData>, _index : Int) : Pointer<ImDrawList>;
Expand Down
13 changes: 13 additions & 0 deletions imgui/draw/ImDrawIdx.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package imgui.draw;

import imgui.util.ImVector;

typedef ImDrawIdx = cpp.UInt16;

@:native('ImVector<ImDrawIdx>')
@:structAccess
@:unreflective
extern class ImVectorImDrawIdx extends ImVector<ImDrawIdx>
{
@:native('ImVector<ImDrawIdx>') public static function create() : ImVectorImDrawIdx;
}
35 changes: 7 additions & 28 deletions imgui/draw/ImDrawList.hx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package imgui.draw;

import cpp.Pointer;
import cpp.ConstPointer;
import cpp.RawPointer;
import cpp.RawConstPointer;
import cpp.Reference;
import cpp.Callable;
import imgui.ImGui;
import imgui.draw.ImDrawCmd;
import imgui.draw.ImDrawIdx;
import imgui.draw.ImDrawVert;
import imgui.font.ImFont;
import imgui.util.ImVec2;
import imgui.util.ImVec4;
import imgui.font.ImFont;

typedef ImDrawIdx = cpp.UInt16;

@:keep
@:include('linc_imgui.h')
Expand All @@ -20,29 +19,9 @@ typedef ImDrawIdx = cpp.UInt16;
@:unreflective
extern class ImDrawList
{
@:native('ImVector<ImDrawCmd>' ) var CmdBuffer : Dynamic;
@:native('ImVector<ImDrawIdx>' ) var IdxBuffer : Dynamic;
@:native('ImVector<ImDrawVert>') var VtxBuffer : Dynamic;

public inline function getCmdData() : cpp.RawPointer<ImDrawCmd> {
return untyped __cpp__('{0}.CmdBuffer.Data', this);
}
public inline function getIdxData() : cpp.RawPointer<ImDrawIdx> {
return untyped __cpp__('{0}.IdxBuffer.Data', this);
}
public inline function getVtxData() : cpp.RawPointer<ImDrawVert> {
return untyped __cpp__('{0}.VtxBuffer.Data', this);
}

public inline function getCmdLength() : Int {
return untyped __cpp__('{0}.CmdBuffer.Size', this);
}
public inline function getIdxLength() : Int {
return untyped __cpp__('{0}.IdxBuffer.Size', this);
}
public inline function getVtxBuffer() : Int {
return untyped __cpp__('{0}.VtxBuffer.Size', this);
}
@:native('CmdBuffer') public var cmdBuffer : ImVectorImDrawCmd;
@:native('IdxBuffer') public var idxBuffer : ImVectorImDrawIdx;
@:native('VtxBuffer') public var vtxBuffer : ImVectorImDrawVert;

//------------//
// //
Expand Down
9 changes: 9 additions & 0 deletions imgui/draw/ImDrawVert.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package imgui.draw;

import imgui.ImGui;
import imgui.util.ImVector;
import imgui.util.ImVec2;

@:keep
Expand All @@ -14,3 +15,11 @@ extern class ImDrawVert
public var uv : ImVec2;
public var col : ImU32;
}

@:native('ImVector<ImDrawVert>')
@:structAccess
@:unreflective
extern class ImVectorImDrawVert extends ImVector<ImDrawVert>
{
@:native('ImVector<ImDrawIdx>') public static function create() : ImVectorImDrawVert;
}
63 changes: 4 additions & 59 deletions imgui/font/ImFont.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package imgui.font;

import imgui.ImGui;
import imgui.draw.ImDrawList;
import imgui.font.ImFontGlyph;
import imgui.util.ImVec2;
import imgui.util.ImVec4;
import cpp.UInt16;
Expand Down Expand Up @@ -36,17 +37,17 @@ extern class ImFont
/**
All glyphs.
*/
@:native('Glyphs') public var glyphs : Dynamic;
@:native('Glyphs') public var glyphs : ImVectorImFontGlyph;

/**
Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
*/
@:native('IndexAdvanceX') public var indexAdvanceX : Dynamic;
@:native('IndexAdvanceX') public var indexAdvanceX : ImVectorFloat;

/**
Sparse. Index glyphs by Unicode code-point.
*/
@:native('IndexLookup') public var indexLookup : Dynamic;
@:native('IndexLookup') public var indexLookup : ImVectorInt;

/**
== FindGlyph(FontFallbackChar)
Expand Down Expand Up @@ -102,59 +103,3 @@ extern class ImFont
@:native('RenderChar') function renderChar(_drawList : Pointer<ImDrawList>, _size : Float, _pos : ImVec2, _col : ImU32, _c : UInt16) : Void;
@:native('RenderText') function renderText(_drawList : Pointer<ImDrawList>, _size : Float, _pos : ImVec2, _col : ImU32, _clipRect : Reference<ImVec4>, _textBegin : ConstCharStar, _textEnd : ConstCharStar, _wrapWidth : Float = 0.0, _cpuFineClip : Bool = false) : Void;
}

@:native('ImFont')
@:structAccess
@:unreflective
extern class ImFontGlyph
{
/**
0x0000..0xFFFF
*/
@:native('Codepoint') public var codepoint : ImWchar;

/**
Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
*/
@:native('AdvanceX') public var advanceX : Float;

/**
Top left x glyph position
*/
@:native('X0') public var x0 : Float;

/**
Top left y glyph position
*/
@:native('Y0') public var y0 : Float;

/**
Bottom right x glyph position
*/
@:native('X1') public var x1 : Float;

/**
Bottom right y glyph position
*/
@:native('Y1') public var y1 : Float;

/**
Top left x texture position
*/
@:native('U0') public var u0 : Float;

/**
Top left y texture position
*/
@:native('V0') public var v0 : Float;

/**
Bottom right x texture position
*/
@:native('U1') public var u1 : Float;

/**
Bottom right y texture position
*/
@:native('V1') public var v1 : Float;
}
60 changes: 52 additions & 8 deletions imgui/font/ImFontAtlas.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package imgui.font;

import imgui.ImGui;
import imgui.util.ImVec2;
import cpp.UInt8;
import cpp.Pointer;
import cpp.ConstPointer;
Expand Down Expand Up @@ -70,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 All @@ -87,12 +88,7 @@ extern class ImFontAtlas
_pixels = cast ptr.toUnmanagedArray(_outWidth * _outHeight);
}

/*
@:native('ImGui::linc::SetTexID') private static function _setTexID(_atlas : RawPointer<ImFontAtlas>, _data : String) : RawPointer<cpp.Void>;
inline function setTexID(_data : String) : RawPointer<cpp.Void> {
return _setTexID(RawPointer.addressOf(this), _data);
}
*/
@:native('SetTexID') function setTexID(_id : ImTextureID) : Void;

//--------------//
// Glyph Ranges //
Expand Down Expand Up @@ -133,4 +129,52 @@ 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')
@:structAccess
@:unreflective
extern class GlyphRangesBuilder
{
@:native('UsedChars') public var usedChars : ImVectorImWchar;

@:native('new ImFontAtlas::GlyphRangesBuilder') public static function create() : Pointer<GlyphRangesBuilder>;
@:native('GetBit') public function getBit(_n : Int) : Bool;
@:native('SetBit') public function setBit(_n : Int) : Void;

@:overload(function(_text : String) : Void {})
@:native('AddText') public function addText(_text : String, _textEnd : String) : Void;

@: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;
}
Loading

0 comments on commit 54a3a78

Please sign in to comment.