mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 12:29:18 +02:00
reformat: parameters can be made const
This commit is contained in:
@@ -54,28 +54,28 @@ namespace ImGuizmo
|
||||
static const float DEG2RAD = (ZPI / 180.f);
|
||||
constexpr float screenRotateSize = 0.06f;
|
||||
|
||||
static OPERATION operator&(OPERATION lhs, OPERATION rhs)
|
||||
static OPERATION operator&(const OPERATION lhs, const OPERATION rhs)
|
||||
{
|
||||
return static_cast<OPERATION>(static_cast<int>(lhs) & static_cast<int>(rhs));
|
||||
}
|
||||
|
||||
static bool operator!=(OPERATION lhs, int rhs)
|
||||
static bool operator!=(const OPERATION lhs, const int rhs)
|
||||
{
|
||||
return static_cast<int>(lhs) != rhs;
|
||||
}
|
||||
|
||||
static bool operator==(OPERATION lhs, int rhs)
|
||||
static bool operator==(const OPERATION lhs, const int rhs)
|
||||
{
|
||||
return static_cast<int>(lhs) == rhs;
|
||||
}
|
||||
|
||||
static bool Intersects(OPERATION lhs, OPERATION rhs)
|
||||
static bool Intersects(const OPERATION lhs, const OPERATION rhs)
|
||||
{
|
||||
return (lhs & rhs) != 0;
|
||||
}
|
||||
|
||||
// True if lhs contains rhs
|
||||
static bool Contains(OPERATION lhs, OPERATION rhs)
|
||||
static bool Contains(const OPERATION lhs, const OPERATION rhs)
|
||||
{
|
||||
return (lhs & rhs) == rhs;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
r[15] = a[12] * b[3] + a[13] * b[7] + a[14] * b[11] + a[15] * b[15];
|
||||
}
|
||||
|
||||
void Frustum(float left, float right, float bottom, float top, float znear, float zfar, float* m16)
|
||||
void Frustum(const float left, const float right, const float bottom, const float top, const float znear, const float zfar, float* m16)
|
||||
{
|
||||
float temp, temp2, temp3, temp4;
|
||||
temp = 2.0f * znear;
|
||||
@@ -131,7 +131,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
m16[15] = 0.0;
|
||||
}
|
||||
|
||||
void Perspective(float fovyInDegrees, float aspectRatio, float znear, float zfar, float* m16)
|
||||
void Perspective(const float fovyInDegrees, const float aspectRatio, const float znear, const float zfar, float* m16)
|
||||
{
|
||||
float ymax, xmax;
|
||||
ymax = znear * tanf(fovyInDegrees * DEG2RAD);
|
||||
@@ -202,7 +202,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
public:
|
||||
float x, y, z, w;
|
||||
|
||||
void Lerp(const vec_t& v, float t)
|
||||
void Lerp(const vec_t& v, const float t)
|
||||
{
|
||||
x += (v.x - x) * t;
|
||||
y += (v.y - y) * t;
|
||||
@@ -210,13 +210,13 @@ constexpr float screenRotateSize = 0.06f;
|
||||
w += (v.w - w) * t;
|
||||
}
|
||||
|
||||
void Set(float v) { x = y = z = w = v; }
|
||||
void Set(float _x, float _y, float _z = 0.f, float _w = 0.f) { x = _x; y = _y; z = _z; w = _w; }
|
||||
void Set(const float v) { x = y = z = w = v; }
|
||||
void Set(const float _x, const float _y, const float _z = 0.f, const float _w = 0.f) { x = _x; y = _y; z = _z; w = _w; }
|
||||
|
||||
vec_t& operator -= (const vec_t& v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; }
|
||||
vec_t& operator += (const vec_t& v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; }
|
||||
vec_t& operator *= (const vec_t& v) { x *= v.x; y *= v.y; z *= v.z; w *= v.w; return *this; }
|
||||
vec_t& operator *= (float v) { x *= v; y *= v; z *= v; w *= v; return *this; }
|
||||
vec_t& operator *= (const float v) { x *= v; y *= v; z *= v; w *= v; return *this; }
|
||||
|
||||
vec_t operator * (float f) const;
|
||||
vec_t operator - () const;
|
||||
@@ -270,14 +270,14 @@ constexpr float screenRotateSize = 0.06f;
|
||||
void TransformVector(const vec_t& v, const matrix_t& matrix) { (*this) = v; this->TransformVector(matrix); }
|
||||
void TransformPoint(const vec_t& v, const matrix_t& matrix) { (*this) = v; this->TransformPoint(matrix); }
|
||||
|
||||
float& operator [] (size_t index) { return ((float*)&x)[index]; }
|
||||
const float& operator [] (size_t index) const { return ((float*)&x)[index]; }
|
||||
float& operator [] (const size_t index) { return ((float*)&x)[index]; }
|
||||
const float& operator [] (const size_t index) const { return ((float*)&x)[index]; }
|
||||
bool operator!=(const vec_t& other) const { return memcmp(this, &other, sizeof(vec_t)); }
|
||||
};
|
||||
|
||||
vec_t makeVect(float _x, float _y, float _z = 0.f, float _w = 0.f) { vec_t res; res.x = _x; res.y = _y; res.z = _z; res.w = _w; return res; }
|
||||
vec_t makeVect(ImVec2 v) { vec_t res; res.x = v.x; res.y = v.y; res.z = 0.f; res.w = 0.f; return res; }
|
||||
vec_t vec_t::operator * (float f) const { return makeVect(x * f, y * f, z * f, w * f); }
|
||||
vec_t makeVect(const float _x, const float _y, const float _z = 0.f, const float _w = 0.f) { vec_t res; res.x = _x; res.y = _y; res.z = _z; res.w = _w; return res; }
|
||||
vec_t makeVect(const ImVec2 v) { vec_t res; res.x = v.x; res.y = v.y; res.z = 0.f; res.w = 0.f; return res; }
|
||||
vec_t vec_t::operator * (const float f) const { return makeVect(x * f, y * f, z * f, w * f); }
|
||||
vec_t vec_t::operator - () const { return makeVect(-x, -y, -z, -w); }
|
||||
vec_t vec_t::operator - (const vec_t& v) const { return makeVect(x - v.x, y - v.y, z - v.z, w - v.w); }
|
||||
vec_t vec_t::operator + (const vec_t& v) const { return makeVect(x + v.x, y + v.y, z + v.z, w + v.w); }
|
||||
@@ -331,7 +331,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
|
||||
operator float* () { return m16; }
|
||||
operator const float* () const { return m16; }
|
||||
void Translation(float _x, float _y, float _z) { this->Translation(makeVect(_x, _y, _z)); }
|
||||
void Translation(const float _x, const float _y, const float _z) { this->Translation(makeVect(_x, _y, _z)); }
|
||||
|
||||
void Translation(const vec_t& vt)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
v.position.Set(vt.x, vt.y, vt.z, 1.f);
|
||||
}
|
||||
|
||||
void Scale(float _x, float _y, float _z)
|
||||
void Scale(const float _x, const float _y, const float _z)
|
||||
{
|
||||
v.right.Set(_x, 0.f, 0.f, 0.f);
|
||||
v.up.Set(0.f, _y, 0.f, 0.f);
|
||||
@@ -466,7 +466,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
w = out.w;
|
||||
}
|
||||
|
||||
float matrix_t::Inverse(const matrix_t& srcMatrix, bool affine)
|
||||
float matrix_t::Inverse(const matrix_t& srcMatrix, const bool affine)
|
||||
{
|
||||
float det = 0;
|
||||
|
||||
@@ -562,7 +562,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return det;
|
||||
}
|
||||
|
||||
void matrix_t::RotationAxis(const vec_t& axis, float angle)
|
||||
void matrix_t::RotationAxis(const vec_t& axis, const float angle)
|
||||
{
|
||||
const float length2 = axis.LengthSq();
|
||||
if (length2 < FLT_EPSILON)
|
||||
@@ -627,17 +627,17 @@ constexpr float screenRotateSize = 0.06f;
|
||||
MT_SCALE_XYZ
|
||||
};
|
||||
|
||||
static bool IsTranslateType(int type)
|
||||
static bool IsTranslateType(const int type)
|
||||
{
|
||||
return type >= MT_MOVE_X && type <= MT_MOVE_SCREEN;
|
||||
}
|
||||
|
||||
static bool IsRotateType(int type)
|
||||
static bool IsRotateType(const int type)
|
||||
{
|
||||
return type >= MT_ROTATE_X && type <= MT_ROTATE_SCREEN;
|
||||
}
|
||||
|
||||
static bool IsScaleType(int type)
|
||||
static bool IsScaleType(const int type)
|
||||
{
|
||||
return type >= MT_SCALE_X && type <= MT_SCALE_XYZ;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
static int GetRotateType(OPERATION op);
|
||||
static int GetScaleType(OPERATION op);
|
||||
|
||||
static ImVec2 worldToPos(const vec_t& worldPos, const matrix_t& mat, ImVec2 position = ImVec2(gContext.mX, gContext.mY), ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight))
|
||||
static ImVec2 worldToPos(const vec_t& worldPos, const matrix_t& mat, const ImVec2 position = ImVec2(gContext.mX, gContext.mY), const ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight))
|
||||
{
|
||||
vec_t trans;
|
||||
trans.TransformPoint(worldPos, mat);
|
||||
@@ -780,7 +780,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return ImVec2(trans.x, trans.y);
|
||||
}
|
||||
|
||||
static void ComputeCameraRay(vec_t& rayOrigin, vec_t& rayDir, ImVec2 position = ImVec2(gContext.mX, gContext.mY), ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight))
|
||||
static void ComputeCameraRay(vec_t& rayOrigin, vec_t& rayDir, const ImVec2 position = ImVec2(gContext.mX, gContext.mY), const ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight))
|
||||
{
|
||||
const ImGuiIO & io = ImGui::GetIO();
|
||||
|
||||
@@ -885,12 +885,12 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return plan.Dot3(point) + plan.w;
|
||||
}
|
||||
|
||||
static bool IsInContextRect(ImVec2 p)
|
||||
static bool IsInContextRect(const ImVec2 p)
|
||||
{
|
||||
return IsWithin(p.x, gContext.mX, gContext.mXMax) && IsWithin(p.y, gContext.mY, gContext.mYMax);
|
||||
}
|
||||
|
||||
void SetRect(float x, float y, float width, float height)
|
||||
void SetRect(const float x, const float y, const float width, const float height)
|
||||
{
|
||||
gContext.mX = x;
|
||||
gContext.mY = y;
|
||||
@@ -901,7 +901,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
gContext.mDisplayRatio = width / height;
|
||||
}
|
||||
|
||||
void SetOrthographic(bool isOrthographic)
|
||||
void SetOrthographic(const bool isOrthographic)
|
||||
{
|
||||
gContext.mIsOrthographic = isOrthographic;
|
||||
}
|
||||
@@ -952,7 +952,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
(Intersects(gContext.mOperation, SCALE) && GetScaleType(gContext.mOperation) != MT_NONE) || IsUsing();
|
||||
}
|
||||
|
||||
bool IsOver(OPERATION op)
|
||||
bool IsOver(const OPERATION op)
|
||||
{
|
||||
if(IsUsing())
|
||||
{
|
||||
@@ -973,7 +973,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Enable(bool enable)
|
||||
void Enable(const bool enable)
|
||||
{
|
||||
gContext.mbEnable = enable;
|
||||
if (!enable)
|
||||
@@ -983,7 +983,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
}
|
||||
}
|
||||
|
||||
static void ComputeContext(const float* view, const float* projection, float* matrix, MODE mode)
|
||||
static void ComputeContext(const float* view, const float* projection, float* matrix, const MODE mode)
|
||||
{
|
||||
gContext.mMode = mode;
|
||||
gContext.mViewMat = *(matrix_t*)view;
|
||||
@@ -1038,7 +1038,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
ComputeCameraRay(gContext.mRayOrigin, gContext.mRayVector);
|
||||
}
|
||||
|
||||
static void ComputeColors(ImU32* colors, int type, OPERATION operation)
|
||||
static void ComputeColors(ImU32* colors, const int type, const OPERATION operation)
|
||||
{
|
||||
if (gContext.mbEnable)
|
||||
{
|
||||
@@ -1081,7 +1081,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
}
|
||||
}
|
||||
|
||||
static void ComputeTripodAxisAndVisibility(int axisIndex, vec_t& dirAxis, vec_t& dirPlaneX, vec_t& dirPlaneY, bool& belowAxisLimit, bool& belowPlaneLimit)
|
||||
static void ComputeTripodAxisAndVisibility(const int axisIndex, vec_t& dirAxis, vec_t& dirPlaneX, vec_t& dirPlaneY, bool& belowAxisLimit, bool& belowPlaneLimit)
|
||||
{
|
||||
dirAxis = directionUnary[axisIndex];
|
||||
dirPlaneX = directionUnary[(axisIndex + 1) % 3];
|
||||
@@ -1134,7 +1134,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
}
|
||||
}
|
||||
|
||||
static void ComputeSnap(float* value, float snap)
|
||||
static void ComputeSnap(float* value, const float snap)
|
||||
{
|
||||
if (snap <= FLT_EPSILON)
|
||||
{
|
||||
@@ -1174,7 +1174,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return angle;
|
||||
}
|
||||
|
||||
static void DrawRotationGizmo(OPERATION op, int type)
|
||||
static void DrawRotationGizmo(const OPERATION op, const int type)
|
||||
{
|
||||
if(!Intersects(op, ROTATE))
|
||||
{
|
||||
@@ -1271,7 +1271,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawScaleGizmo(OPERATION op, int type)
|
||||
static void DrawScaleGizmo(const OPERATION op, const int type)
|
||||
{
|
||||
ImDrawList* drawList = gContext.mDrawList;
|
||||
|
||||
@@ -1354,7 +1354,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
}
|
||||
|
||||
|
||||
static void DrawTranslationGizmo(OPERATION op, int type)
|
||||
static void DrawTranslationGizmo(const OPERATION op, const int type)
|
||||
{
|
||||
ImDrawList* drawList = gContext.mDrawList;
|
||||
if (!drawList)
|
||||
@@ -1714,7 +1714,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
static int GetScaleType(OPERATION op)
|
||||
static int GetScaleType(const OPERATION op)
|
||||
{
|
||||
const ImGuiIO & io = ImGui::GetIO();
|
||||
int type = MT_NONE;
|
||||
@@ -1760,7 +1760,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return type;
|
||||
}
|
||||
|
||||
static int GetRotateType(OPERATION op)
|
||||
static int GetRotateType(const OPERATION op)
|
||||
{
|
||||
const ImGuiIO & io = ImGui::GetIO();
|
||||
int type = MT_NONE;
|
||||
@@ -1814,7 +1814,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return type;
|
||||
}
|
||||
|
||||
static int GetMoveType(OPERATION op, vec_t* gizmoHitProportion)
|
||||
static int GetMoveType(const OPERATION op, vec_t* gizmoHitProportion)
|
||||
{
|
||||
if(!Intersects(op, TRANSLATE))
|
||||
{
|
||||
@@ -2246,17 +2246,17 @@ constexpr float screenRotateSize = 0.06f;
|
||||
mat.v.position.Set(translation[0], translation[1], translation[2], 1.f);
|
||||
}
|
||||
|
||||
void SetID(int id)
|
||||
void SetID(const int id)
|
||||
{
|
||||
gContext.mActualID = id;
|
||||
}
|
||||
|
||||
void AllowAxisFlip(bool value)
|
||||
void AllowAxisFlip(const bool value)
|
||||
{
|
||||
gContext.mAllowAxisFlip = value;
|
||||
}
|
||||
|
||||
bool Manipulate(const float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float* deltaMatrix, const float* snap, const float* localBounds, const float* boundsSnap)
|
||||
bool Manipulate(const float* view, const float* projection, const OPERATION operation, const MODE mode, float* matrix, float* deltaMatrix, const float* snap, const float* localBounds, const float* boundsSnap)
|
||||
{
|
||||
ComputeContext(view, projection, matrix, mode);
|
||||
|
||||
@@ -2302,7 +2302,7 @@ constexpr float screenRotateSize = 0.06f;
|
||||
return manipulated;
|
||||
}
|
||||
|
||||
void SetGizmoSizeClipSpace(float value)
|
||||
void SetGizmoSizeClipSpace(const float value)
|
||||
{
|
||||
gContext.mGizmoSizeClipSpace = value;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace ImGuizmo
|
||||
SCALE = SCALE_X | SCALE_Y | SCALE_Z
|
||||
};
|
||||
|
||||
inline OPERATION operator|(OPERATION lhs, OPERATION rhs)
|
||||
inline OPERATION operator|(const OPERATION lhs, const OPERATION rhs)
|
||||
{
|
||||
return static_cast<OPERATION>(static_cast<int>(lhs) | static_cast<int>(rhs));
|
||||
}
|
||||
|
||||
373
imgui/imgui.cpp
373
imgui/imgui.cpp
File diff suppressed because it is too large
Load Diff
@@ -180,9 +180,9 @@ struct ImVec2
|
||||
{
|
||||
float x, y;
|
||||
ImVec2() { x = y = 0.0f; }
|
||||
ImVec2(float _x, float _y) { x = _x; y = _y; }
|
||||
float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
ImVec2(const float _x, const float _y) { x = _x; y = _y; }
|
||||
float operator[] (const size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float& operator[] (const size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
#ifdef IM_VEC2_CLASS_EXTRA
|
||||
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
|
||||
#endif
|
||||
@@ -193,7 +193,7 @@ struct ImVec4
|
||||
{
|
||||
float x, y, z, w;
|
||||
ImVec4() { x = y = z = w = 0.0f; }
|
||||
ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
|
||||
ImVec4(const float _x, const float _y, const float _z, const float _w) { x = _x; y = _y; z = _z; w = _w; }
|
||||
#ifdef IM_VEC4_CLASS_EXTRA
|
||||
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
||||
#endif
|
||||
@@ -1265,11 +1265,11 @@ struct ImVector
|
||||
const int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size;
|
||||
const int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||
|
||||
int _grow_capacity(int sz) const {
|
||||
int _grow_capacity(const int sz) const {
|
||||
const int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
||||
void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
|
||||
void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; }
|
||||
void resize(const int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
void resize(const int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
|
||||
void reserve(const int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; }
|
||||
|
||||
// NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden.
|
||||
void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
|
||||
@@ -1567,13 +1567,13 @@ namespace ImGui
|
||||
// OBSOLETED in 1.72 (from July 2019)
|
||||
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
||||
// OBSOLETED in 1.71 (from June 2019)
|
||||
static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
||||
static inline void SetNextTreeNodeOpen(const bool open, const ImGuiCond cond = 0) { SetNextItemOpen(open, cond); }
|
||||
// OBSOLETED in 1.70 (from May 2019)
|
||||
static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; }
|
||||
// OBSOLETED in 1.69 (from Mar 2019)
|
||||
static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); }
|
||||
// OBSOLETED in 1.66 (from Sep 2018)
|
||||
static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); }
|
||||
static inline void SetScrollHere(const float center_ratio=0.5f){ SetScrollHereY(center_ratio); }
|
||||
// OBSOLETED in 1.63 (between Aug 2018 and Sept 2018)
|
||||
static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); }
|
||||
// OBSOLETED in 1.61 (between Apr 2018 and Aug 2018)
|
||||
@@ -1584,18 +1584,18 @@ namespace ImGui
|
||||
// OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
||||
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
|
||||
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
|
||||
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; }
|
||||
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, const bool on_edge = false, const float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; }
|
||||
// OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||
static inline void ShowTestWindow() { return ShowDemoWindow(); }
|
||||
static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
|
||||
static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); }
|
||||
static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
|
||||
static inline void SetNextWindowContentWidth(const float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
|
||||
static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); }
|
||||
// OBSOLETED in 1.52 (between Aug 2017 and Oct 2017)
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize(size, ImGuiCond_FirstUseEver) + SetNextWindowBgAlpha() instead.
|
||||
static inline bool IsRootWindowOrAnyChildHovered() { return IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); }
|
||||
static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); }
|
||||
static inline void SetNextWindowPosCenter(ImGuiCond c=0) {
|
||||
static inline void SetNextWindowPosCenter(const ImGuiCond c=0) {
|
||||
const ImGuiIO & io = GetIO(); SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), c, ImVec2(0.5f, 0.5f)); }
|
||||
}
|
||||
typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent
|
||||
@@ -1650,13 +1650,13 @@ struct ImGuiTextBuffer
|
||||
IMGUI_API static char EmptyString[1];
|
||||
|
||||
ImGuiTextBuffer() { }
|
||||
char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
|
||||
char operator[](const int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
|
||||
const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; }
|
||||
const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
|
||||
int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
|
||||
bool empty() { return Buf.Size <= 1; }
|
||||
void clear() { Buf.clear(); }
|
||||
void reserve(int capacity) { Buf.reserve(capacity); }
|
||||
void reserve(const int capacity) { Buf.reserve(capacity); }
|
||||
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
|
||||
IMGUI_API void append(const char* str, const char* str_end = NULL);
|
||||
IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2);
|
||||
@@ -1678,9 +1678,9 @@ struct ImGuiStorage
|
||||
{
|
||||
ImGuiID key;
|
||||
union { int val_i; float val_f; void* val_p; };
|
||||
ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
|
||||
ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
|
||||
ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
|
||||
ImGuiStoragePair(const ImGuiID _key, const int _val_i) { key = _key; val_i = _val_i; }
|
||||
ImGuiStoragePair(const ImGuiID _key, const float _val_f) { key = _key; val_f = _val_f; }
|
||||
ImGuiStoragePair(const ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
|
||||
};
|
||||
|
||||
ImVector<ImGuiStoragePair> Data;
|
||||
@@ -1736,7 +1736,7 @@ struct ImGuiListClipper
|
||||
// items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).
|
||||
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
||||
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
|
||||
ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
|
||||
ImGuiListClipper(const int items_count = -1, const float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
|
||||
~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false.
|
||||
|
||||
IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
|
||||
@@ -1772,18 +1772,18 @@ struct ImColor
|
||||
ImVec4 Value;
|
||||
|
||||
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
||||
ImColor(int r, int g, int b, int a = 255) {
|
||||
ImColor(const int r, const int g, const int b, const int a = 255) {
|
||||
constexpr float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
||||
ImColor(ImU32 rgba) {
|
||||
ImColor(const ImU32 rgba) {
|
||||
constexpr float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
|
||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||
ImColor(const float r, const float g, const float b, const float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||
ImColor(const ImVec4& col) { Value = col; }
|
||||
operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||
operator ImVec4() const { return Value; }
|
||||
|
||||
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
|
||||
void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
||||
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
|
||||
void SetHSV(const float h, const float s, const float v, const float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
||||
static ImColor HSV(const float h, const float s, const float v, const float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1962,8 +1962,8 @@ struct ImDrawList
|
||||
void PathClear() { _Path.Size = 0; }
|
||||
void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||
void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||
void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||
void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
||||
void PathFillConvex(const ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||
void PathStroke(const ImU32 col, const bool closed, const float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
||||
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
||||
IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
||||
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
||||
@@ -1977,9 +1977,9 @@ struct ImDrawList
|
||||
// Advanced: Channels
|
||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
|
||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||
void ChannelsSplit(int count) { _Splitter.Split(this, count); }
|
||||
void ChannelsSplit(const int count) { _Splitter.Split(this, count); }
|
||||
void ChannelsMerge() { _Splitter.Merge(this); }
|
||||
void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
|
||||
void ChannelsSetCurrent(const int n) { _Splitter.SetCurrentChannel(this, n); }
|
||||
|
||||
// Internal helpers
|
||||
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
|
||||
@@ -1989,9 +1989,9 @@ struct ImDrawList
|
||||
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
|
||||
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
|
||||
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
|
||||
void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
|
||||
void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
|
||||
void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
|
||||
void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, const ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
|
||||
void PrimWriteIdx(const ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
|
||||
void PrimVtx(const ImVec2& pos, const ImVec2& uv, const ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
|
||||
IMGUI_API void UpdateClipRect();
|
||||
IMGUI_API void UpdateTextureID();
|
||||
};
|
||||
@@ -2066,13 +2066,13 @@ struct ImFontGlyphRangesBuilder
|
||||
ImFontGlyphRangesBuilder() { Clear(); }
|
||||
void Clear() {
|
||||
constexpr int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
|
||||
bool GetBit(int n) const {
|
||||
bool GetBit(const int n) const {
|
||||
const int off = (n >> 5);
|
||||
const ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
|
||||
void SetBit(int n) {
|
||||
void SetBit(const int n) {
|
||||
const int off = (n >> 5);
|
||||
const ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
|
||||
void AddChar(ImWchar c) { SetBit(c); } // Add character
|
||||
void AddChar(const ImWchar c) { SetBit(c); } // Add character
|
||||
IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
|
||||
IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
|
||||
IMGUI_API void BuildRanges(ImVector<ImWchar>* out_ranges); // Output new ranges
|
||||
@@ -2139,7 +2139,7 @@ struct ImFontAtlas
|
||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
||||
bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); }
|
||||
void SetTexID(ImTextureID id) { TexID = id; }
|
||||
void SetTexID(const ImTextureID id) { TexID = id; }
|
||||
|
||||
//-------------------------------------------
|
||||
// Glyph Ranges
|
||||
@@ -2168,7 +2168,7 @@ struct ImFontAtlas
|
||||
// Read misc/fonts/README.txt for more details about using colorful icons.
|
||||
IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font.
|
||||
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||
const ImFontAtlasCustomRect*GetCustomRectByIndex(const int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||
|
||||
// [Internal]
|
||||
IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
|
||||
@@ -2234,7 +2234,7 @@ struct ImFont
|
||||
IMGUI_API ~ImFont();
|
||||
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
|
||||
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
|
||||
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
|
||||
float GetCharAdvance(const ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
|
||||
bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
|
||||
|
||||
|
||||
@@ -827,7 +827,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items));
|
||||
|
||||
// Simplified one-liner Combo() using an accessor function
|
||||
struct FuncHolder { static bool ItemGetter(void* data, int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } };
|
||||
struct FuncHolder { static bool ItemGetter(void* data, const int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } };
|
||||
static int item_current_4 = 0;
|
||||
ImGui::Combo("combo 4 (function)", &item_current_4, &FuncHolder::ItemGetter, items, IM_ARRAYSIZE(items));
|
||||
|
||||
@@ -1013,7 +1013,7 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
// Tip: Because ImGui:: is a namespace you would typicall add your own function into the namespace in your own source files.
|
||||
// For example, you may add a function called ImGui::InputText(const char* label, MyString* my_str).
|
||||
static bool MyInputTextMultiline(const char* label, ImVector<char>* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0)
|
||||
static bool MyInputTextMultiline(const char* label, ImVector<char>* my_str, const ImVec2& size = ImVec2(0, 0), const ImGuiInputTextFlags flags = 0)
|
||||
{
|
||||
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
|
||||
return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, MyResizeCallback, (void*)my_str);
|
||||
@@ -1063,8 +1063,8 @@ static void ShowDemoWindowWidgets()
|
||||
// FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count.
|
||||
struct Funcs
|
||||
{
|
||||
static float Sin(void*, int i) { return sinf(i * 0.1f); }
|
||||
static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; }
|
||||
static float Sin(void*, const int i) { return sinf(i * 0.1f); }
|
||||
static float Saw(void*, const int i) { return (i & 1) ? 1.0f : -1.0f; }
|
||||
};
|
||||
static int func_type = 0, display_count = 70;
|
||||
ImGui::Separator();
|
||||
@@ -3956,7 +3956,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
|
||||
struct funcs
|
||||
{
|
||||
static void ShowDummyObject(const char* prefix, int uid)
|
||||
static void ShowDummyObject(const char* prefix, const int uid)
|
||||
{
|
||||
ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
||||
ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
|
||||
@@ -4365,7 +4365,7 @@ struct MyDocument
|
||||
bool WantClose; // Set when the document
|
||||
ImVec4 Color; // An arbitrary variable associated to the document
|
||||
|
||||
MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f))
|
||||
MyDocument(const char* name, const bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f))
|
||||
{
|
||||
Name = name;
|
||||
Open = OpenPrev = open;
|
||||
|
||||
@@ -415,7 +415,7 @@ void ImDrawList::AddDrawCmd()
|
||||
CmdBuffer.push_back(draw_cmd);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
||||
void ImDrawList::AddCallback(const ImDrawCallback callback, void* callback_data)
|
||||
{
|
||||
ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL;
|
||||
if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL)
|
||||
@@ -473,7 +473,7 @@ void ImDrawList::UpdateTextureID()
|
||||
#undef GetCurrentTextureId
|
||||
|
||||
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||
void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
|
||||
void ImDrawList::PushClipRect(const ImVec2 cr_min, const ImVec2 cr_max, const bool intersect_with_current_clip_rect)
|
||||
{
|
||||
ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y);
|
||||
if (intersect_with_current_clip_rect && _ClipRectStack.Size)
|
||||
@@ -503,7 +503,7 @@ void ImDrawList::PopClipRect()
|
||||
UpdateClipRect();
|
||||
}
|
||||
|
||||
void ImDrawList::PushTextureID(ImTextureID texture_id)
|
||||
void ImDrawList::PushTextureID(const ImTextureID texture_id)
|
||||
{
|
||||
_TextureIdStack.push_back(texture_id);
|
||||
UpdateTextureID();
|
||||
@@ -517,7 +517,7 @@ void ImDrawList::PopTextureID()
|
||||
}
|
||||
|
||||
// NB: this can be called with negative count for removing primitives (as long as the result does not underflow)
|
||||
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||
void ImDrawList::PrimReserve(const int idx_count, const int vtx_count)
|
||||
{
|
||||
// Large mesh support (when enabled)
|
||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
@@ -540,7 +540,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||
}
|
||||
|
||||
// Fully unrolled with inline call to keep our debug builds decently fast.
|
||||
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
||||
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, const ImU32 col)
|
||||
{
|
||||
ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel);
|
||||
const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
|
||||
@@ -555,7 +555,7 @@ void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
||||
_IdxWritePtr += 6;
|
||||
}
|
||||
|
||||
void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col)
|
||||
void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, const ImU32 col)
|
||||
{
|
||||
ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y);
|
||||
const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
|
||||
@@ -570,7 +570,7 @@ void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a
|
||||
_IdxWritePtr += 6;
|
||||
}
|
||||
|
||||
void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
|
||||
void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, const ImU32 col)
|
||||
{
|
||||
const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
|
||||
_IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
|
||||
@@ -591,7 +591,7 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
|
||||
|
||||
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
|
||||
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
||||
void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness)
|
||||
void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, const ImU32 col, const bool closed, const float thickness)
|
||||
{
|
||||
if (points_count < 2)
|
||||
return;
|
||||
@@ -779,7 +779,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
}
|
||||
|
||||
// We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
||||
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
|
||||
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, const ImU32 col)
|
||||
{
|
||||
if (points_count < 3)
|
||||
return;
|
||||
@@ -860,7 +860,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12)
|
||||
void ImDrawList::PathArcToFast(const ImVec2& center, const float radius, const int a_min_of_12, const int a_max_of_12)
|
||||
{
|
||||
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
||||
{
|
||||
@@ -875,7 +875,7 @@ void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
|
||||
void ImDrawList::PathArcTo(const ImVec2& center, const float radius, const float a_min, const float a_max, const int num_segments)
|
||||
{
|
||||
if (radius == 0.0f)
|
||||
{
|
||||
@@ -893,7 +893,8 @@ void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, floa
|
||||
}
|
||||
}
|
||||
|
||||
static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
||||
static void PathBezierToCasteljau(ImVector<ImVec2>* path, const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4,
|
||||
const float tess_tol, const int level)
|
||||
{
|
||||
const float dx = x4 - x1;
|
||||
const float dy = y4 - y1;
|
||||
@@ -919,7 +920,7 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments)
|
||||
void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const int num_segments)
|
||||
{
|
||||
const ImVec2 p1 = _Path.back();
|
||||
if (num_segments == 0)
|
||||
@@ -943,7 +944,7 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawCornerFlags rounding_corners)
|
||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, const ImDrawCornerFlags rounding_corners)
|
||||
{
|
||||
rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
||||
@@ -968,7 +969,7 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDr
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness)
|
||||
void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, const ImU32 col, const float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -979,7 +980,7 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th
|
||||
|
||||
// p_min = upper-left, p_max = lower-right
|
||||
// Note we don't render 1 pixels sized rectangles properly.
|
||||
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness)
|
||||
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col, const float rounding, const ImDrawCornerFlags rounding_corners, const float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -990,7 +991,7 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||
void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col, const float rounding, const ImDrawCornerFlags rounding_corners)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1007,7 +1008,7 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c
|
||||
}
|
||||
|
||||
// p_min = upper-left, p_max = lower-right
|
||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col_upr_left, const ImU32 col_upr_right, const ImU32 col_bot_right, const ImU32 col_bot_left)
|
||||
{
|
||||
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1022,7 +1023,7 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_ma
|
||||
PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left);
|
||||
}
|
||||
|
||||
void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness)
|
||||
void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImU32 col, const float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1034,7 +1035,7 @@ void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, c
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col)
|
||||
void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImU32 col)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1046,7 +1047,7 @@ void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2&
|
||||
PathFillConvex(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness)
|
||||
void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImU32 col, const float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1057,7 +1058,7 @@ void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col)
|
||||
void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImU32 col)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1068,7 +1069,7 @@ void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImV
|
||||
PathFillConvex(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
|
||||
void ImDrawList::AddCircle(const ImVec2& center, const float radius, const ImU32 col, const int num_segments, const float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||
return;
|
||||
@@ -1079,7 +1080,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
|
||||
void ImDrawList::AddCircleFilled(const ImVec2& center, const float radius, const ImU32 col, const int num_segments)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||
return;
|
||||
@@ -1090,7 +1091,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
|
||||
PathFillConvex(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, const ImU32 col, const float thickness, const int num_segments)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1100,7 +1101,7 @@ void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImV
|
||||
PathStroke(col, false, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, const ImU32 col, const char* text_begin, const char* text_end, const float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1129,12 +1130,12 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
void ImDrawList::AddText(const ImVec2& pos, const ImU32 col, const char* text_begin, const char* text_end)
|
||||
{
|
||||
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||
}
|
||||
|
||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
|
||||
void ImDrawList::AddImage(const ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, const ImU32 col)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1150,7 +1151,7 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, cons
|
||||
PopTextureID();
|
||||
}
|
||||
|
||||
void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col)
|
||||
void ImDrawList::AddImageQuad(const ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, const ImU32 col)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1166,7 +1167,8 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, con
|
||||
PopTextureID();
|
||||
}
|
||||
|
||||
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||
void ImDrawList::AddImageRounded(const ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, const ImU32 col, const float rounding,
|
||||
const ImDrawCornerFlags rounding_corners)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
@@ -1212,7 +1214,7 @@ void ImDrawListSplitter::ClearFreeMemory()
|
||||
_Channels.clear();
|
||||
}
|
||||
|
||||
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
||||
void ImDrawListSplitter::Split(ImDrawList* draw_list, const int channels_count)
|
||||
{
|
||||
IM_ASSERT(_Current == 0 && _Count <= 1);
|
||||
const int old_channels_count = _Channels.Size;
|
||||
@@ -1305,7 +1307,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
||||
_Count = 1;
|
||||
}
|
||||
|
||||
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, const int idx)
|
||||
{
|
||||
IM_ASSERT(idx >= 0 && idx < _Count);
|
||||
if (_Current == idx)
|
||||
@@ -1363,7 +1365,8 @@ void ImDrawData::ScaleClipRects(const ImVec2& fb_scale)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generic linear color gradient, write to RGB fields, leave A untouched.
|
||||
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
|
||||
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, const int vert_start_idx, const int vert_end_idx, const ImVec2 gradient_p0, const ImVec2 gradient_p1, const ImU32 col0,
|
||||
const ImU32 col1)
|
||||
{
|
||||
const ImVec2 gradient_extent = gradient_p1 - gradient_p0;
|
||||
const float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
||||
@@ -1381,7 +1384,7 @@ void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int ve
|
||||
}
|
||||
|
||||
// Distribute UV over (a, b) rectangle
|
||||
void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
|
||||
void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, const int vert_start_idx, const int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, const bool clamp)
|
||||
{
|
||||
const ImVec2 size = b - a;
|
||||
const ImVec2 uv_size = uv_b - uv_a;
|
||||
@@ -1632,7 +1635,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||
static unsigned int stb_decompress_length(const unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static unsigned int Decode85Byte(const char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
{
|
||||
while (*src)
|
||||
@@ -1666,7 +1669,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||
return font;
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||
size_t data_size = 0;
|
||||
@@ -1688,7 +1691,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||
}
|
||||
|
||||
// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, const int ttf_size, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||
@@ -1701,7 +1704,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si
|
||||
return AddFont(&font_cfg);
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, const int compressed_ttf_size, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
||||
const auto buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size);
|
||||
@@ -1713,7 +1716,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d
|
||||
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges);
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, const float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
|
||||
{
|
||||
const int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
|
||||
void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size);
|
||||
@@ -1723,7 +1726,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
||||
return font;
|
||||
}
|
||||
|
||||
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||
int ImFontAtlas::AddCustomRectRegular(const unsigned int id, const int width, const int height)
|
||||
{
|
||||
IM_ASSERT(id >= 0x10000);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
@@ -1736,7 +1739,7 @@ int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||
return CustomRects.Size - 1; // Return index
|
||||
}
|
||||
|
||||
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
|
||||
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, const ImWchar id, const int width, const int height, const float advance_x, const ImVec2& offset)
|
||||
{
|
||||
IM_ASSERT(font != NULL);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
@@ -1760,7 +1763,7 @@ void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* ou
|
||||
*out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y);
|
||||
}
|
||||
|
||||
bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2])
|
||||
bool ImFontAtlas::GetMouseCursorTexData(const ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2])
|
||||
{
|
||||
if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT)
|
||||
return false;
|
||||
@@ -1788,7 +1791,7 @@ bool ImFontAtlas::Build()
|
||||
return ImFontAtlasBuildWithStbTruetype(this);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor)
|
||||
void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], const float in_brighten_factor)
|
||||
{
|
||||
for (unsigned int i = 0; i < 256; i++)
|
||||
{
|
||||
@@ -1797,7 +1800,7 @@ void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], fl
|
||||
}
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride)
|
||||
void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, const int x, const int y, const int w, const int h, const int stride)
|
||||
{
|
||||
unsigned char* data = pixels + x + y * stride;
|
||||
for (int j = h; j > 0; j--, data += stride)
|
||||
@@ -2108,7 +2111,7 @@ void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, const float ascent, const float descent)
|
||||
{
|
||||
if (!font_config->MergeMode)
|
||||
{
|
||||
@@ -2259,7 +2262,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull()
|
||||
return &ranges[0];
|
||||
}
|
||||
|
||||
static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges)
|
||||
static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, const int accumulative_offsets_count, ImWchar* out_ranges)
|
||||
{
|
||||
for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2)
|
||||
{
|
||||
@@ -2558,13 +2561,13 @@ void ImFont::BuildLookupTable()
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
}
|
||||
|
||||
void ImFont::SetFallbackChar(ImWchar c)
|
||||
void ImFont::SetFallbackChar(const ImWchar c)
|
||||
{
|
||||
FallbackChar = c;
|
||||
BuildLookupTable();
|
||||
}
|
||||
|
||||
void ImFont::GrowIndex(int new_size)
|
||||
void ImFont::GrowIndex(const int new_size)
|
||||
{
|
||||
IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
|
||||
if (new_size <= IndexLookup.Size)
|
||||
@@ -2575,7 +2578,7 @@ void ImFont::GrowIndex(int new_size)
|
||||
|
||||
// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
|
||||
// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis).
|
||||
void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
|
||||
void ImFont::AddGlyph(const ImWchar codepoint, const float x0, const float y0, const float x1, const float y1, const float u0, const float v0, const float u1, const float v1, const float advance_x)
|
||||
{
|
||||
Glyphs.resize(Glyphs.Size + 1);
|
||||
ImFontGlyph& glyph = Glyphs.back();
|
||||
@@ -2598,7 +2601,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
|
||||
MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f);
|
||||
}
|
||||
|
||||
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
void ImFont::AddRemapChar(const ImWchar dst, const ImWchar src, const bool overwrite_dst)
|
||||
{
|
||||
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
|
||||
const int index_size = IndexLookup.Size;
|
||||
@@ -2613,7 +2616,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
|
||||
}
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
|
||||
const ImFontGlyph* ImFont::FindGlyph(const ImWchar c) const
|
||||
{
|
||||
if (c >= IndexLookup.Size)
|
||||
return FallbackGlyph;
|
||||
@@ -2623,7 +2626,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
|
||||
const ImFontGlyph* ImFont::FindGlyphNoFallback(const ImWchar c) const
|
||||
{
|
||||
if (c >= IndexLookup.Size)
|
||||
return NULL;
|
||||
@@ -2633,7 +2636,7 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const
|
||||
const char* ImFont::CalcWordWrapPositionA(const float scale, const char* text, const char* text_end, float wrap_width) const
|
||||
{
|
||||
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
|
||||
// FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
|
||||
@@ -2732,7 +2735,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
return s;
|
||||
}
|
||||
|
||||
ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const
|
||||
ImVec2 ImFont::CalcTextSizeA(const float size, const float max_width, const float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this.
|
||||
@@ -2826,7 +2829,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
return text_size;
|
||||
}
|
||||
|
||||
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
|
||||
void ImFont::RenderChar(ImDrawList* draw_list, const float size, ImVec2 pos, const ImU32 col, const ImWchar c) const
|
||||
{
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
|
||||
return;
|
||||
@@ -2840,7 +2843,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
}
|
||||
}
|
||||
|
||||
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
|
||||
void ImFont::RenderText(ImDrawList* draw_list, const float size, ImVec2 pos, const ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, const float wrap_width,
|
||||
const bool cpu_fine_clip) const
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||
@@ -3038,7 +3042,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
// - RenderRectFilledRangeH()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
|
||||
void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, const float scale, const ImGuiMouseCursor mouse_cursor, const ImU32 col_fill, const ImU32 col_border, const ImU32 col_shadow)
|
||||
{
|
||||
if (mouse_cursor == ImGuiMouseCursor_None)
|
||||
return;
|
||||
@@ -3060,7 +3064,7 @@ void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, Im
|
||||
}
|
||||
|
||||
// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.
|
||||
void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
|
||||
void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, const ImVec2 pos, const ImVec2 half_sz, const ImGuiDir direction, const ImU32 col)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
@@ -3072,7 +3076,7 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half
|
||||
}
|
||||
}
|
||||
|
||||
static inline float ImAcos01(float x)
|
||||
static inline float ImAcos01(const float x)
|
||||
{
|
||||
if (x <= 0.0f) return IM_PI * 0.5f;
|
||||
if (x >= 1.0f) return 0.0f;
|
||||
@@ -3081,7 +3085,7 @@ static inline float ImAcos01(float x)
|
||||
}
|
||||
|
||||
// FIXME: Cleanup and move code to ImDrawList.
|
||||
void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding)
|
||||
void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, const ImU32 col, float x_start_norm, float x_end_norm, float rounding)
|
||||
{
|
||||
if (x_end_norm == x_start_norm)
|
||||
return;
|
||||
@@ -3167,7 +3171,7 @@ static void stb__match(const unsigned char *data, unsigned int length)
|
||||
while (length--) *stb__dout++ = *data++;
|
||||
}
|
||||
|
||||
static void stb__lit(const unsigned char *data, unsigned int length)
|
||||
static void stb__lit(const unsigned char *data, const unsigned int length)
|
||||
{
|
||||
IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
|
||||
if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
|
||||
@@ -3197,7 +3201,7 @@ static const unsigned char *stb_decompress_token(const unsigned char *i)
|
||||
return i;
|
||||
}
|
||||
|
||||
static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen)
|
||||
static unsigned int stb_adler32(const unsigned int adler32, unsigned char *buffer, unsigned int buflen)
|
||||
{
|
||||
constexpr unsigned long ADLER_MOD = 65521;
|
||||
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
|
||||
|
||||
@@ -79,7 +79,7 @@ static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
||||
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, const int button, const int action, const int mods)
|
||||
{
|
||||
if (g_PrevUserCallbackMousebutton != NULL)
|
||||
g_PrevUserCallbackMousebutton(window, button, action, mods);
|
||||
@@ -88,7 +88,7 @@ void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int acti
|
||||
g_MouseJustPressed[button] = true;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, const double xoffset, const double yoffset)
|
||||
{
|
||||
if (g_PrevUserCallbackScroll != NULL)
|
||||
g_PrevUserCallbackScroll(window, xoffset, yoffset);
|
||||
@@ -98,7 +98,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo
|
||||
io.MouseWheel += (float)yoffset;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, const int key, const int scancode, const int action, const int mods)
|
||||
{
|
||||
if (g_PrevUserCallbackKey != NULL)
|
||||
g_PrevUserCallbackKey(window, key, scancode, action, mods);
|
||||
@@ -116,7 +116,7 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int a
|
||||
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, const unsigned int c)
|
||||
{
|
||||
if (g_PrevUserCallbackChar != NULL)
|
||||
g_PrevUserCallbackChar(window, c);
|
||||
@@ -125,7 +125,7 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||
io.AddInputCharacter(c);
|
||||
}
|
||||
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, const bool install_callbacks, const GlfwClientApi client_api)
|
||||
{
|
||||
g_Window = window;
|
||||
g_Time = 0.0;
|
||||
@@ -193,12 +193,12 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
|
||||
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, const bool install_callbacks)
|
||||
{
|
||||
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
|
||||
bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, const bool install_callbacks)
|
||||
{
|
||||
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void ImGui_ImplOpenGL2_NewFrame()
|
||||
ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
|
||||
static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, const int fb_width, const int fb_height)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
@@ -132,7 +132,7 @@ void ImGui_ImplOpenGL3_NewFrame()
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, const int fb_width, const int fb_height, const GLuint vertex_array_object)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
@@ -358,7 +358,7 @@ void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
static bool CheckShader(const GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
|
||||
@@ -376,7 +376,7 @@ static bool CheckShader(GLuint handle, const char* desc)
|
||||
}
|
||||
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
static bool CheckProgram(const GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
|
||||
@@ -170,13 +170,13 @@ IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 see
|
||||
IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0);
|
||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||
IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
|
||||
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||||
static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||
static inline bool ImCharIsBlankA(const char c) { return c == ' ' || c == '\t'; }
|
||||
static inline bool ImCharIsBlankW(const unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||
static inline bool ImIsPowerOfTwo(const int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||||
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||||
#define ImQsort qsort
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline ImU32 ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
|
||||
static inline ImU32 ImHash(const void* data, const int size, const ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
|
||||
#endif
|
||||
|
||||
// Helpers: Geometry
|
||||
@@ -227,19 +227,19 @@ static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)
|
||||
// Helpers: Maths
|
||||
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
|
||||
#ifndef IMGUI_DISABLE_MATH_FUNCTIONS
|
||||
static inline float ImFabs(float x) { return fabsf(x); }
|
||||
static inline float ImSqrt(float x) { return sqrtf(x); }
|
||||
static inline float ImPow(float x, float y) { return powf(x, y); }
|
||||
static inline double ImPow(double x, double y) { return pow(x, y); }
|
||||
static inline float ImFmod(float x, float y) { return fmodf(x, y); }
|
||||
static inline double ImFmod(double x, double y) { return fmod(x, y); }
|
||||
static inline float ImCos(float x) { return cosf(x); }
|
||||
static inline float ImSin(float x) { return sinf(x); }
|
||||
static inline float ImAcos(float x) { return acosf(x); }
|
||||
static inline float ImAtan2(float y, float x) { return atan2f(y, x); }
|
||||
static inline float ImFabs(const float x) { return fabsf(x); }
|
||||
static inline float ImSqrt(const float x) { return sqrtf(x); }
|
||||
static inline float ImPow(const float x, const float y) { return powf(x, y); }
|
||||
static inline double ImPow(const double x, const double y) { return pow(x, y); }
|
||||
static inline float ImFmod(const float x, const float y) { return fmodf(x, y); }
|
||||
static inline double ImFmod(const double x, const double y) { return fmod(x, y); }
|
||||
static inline float ImCos(const float x) { return cosf(x); }
|
||||
static inline float ImSin(const float x) { return sinf(x); }
|
||||
static inline float ImAcos(const float x) { return acosf(x); }
|
||||
static inline float ImAtan2(const float y, const float x) { return atan2f(y, x); }
|
||||
static inline double ImAtof(const char* s) { return atof(s); }
|
||||
static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
|
||||
static inline float ImCeil(float x) { return ceilf(x); }
|
||||
static inline float ImFloorStd(const float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
|
||||
static inline float ImCeil(const float x) { return ceilf(x); }
|
||||
#endif
|
||||
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double
|
||||
// (Exceptionally using templates here but we could also redefine them for variety of types)
|
||||
@@ -253,21 +253,21 @@ template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx)
|
||||
// - Misc maths helpers
|
||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, const ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, const float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||
static inline float ImSaturate(const float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) {
|
||||
static inline float ImInvLength(const ImVec2& lhs, const float fail_value) {
|
||||
const float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; }
|
||||
static inline float ImFloor(float f) { return (float)(int)f; }
|
||||
static inline float ImFloor(const float f) { return (float)(int)f; }
|
||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
||||
static inline int ImModPositive(const int a, const int b) { return (a + b) % b; }
|
||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||
static inline ImVec2 ImRotate(const ImVec2& v, const float cos_a, const float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||
static inline float ImLinearSweep(const float current, const float target, const float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||||
|
||||
// Helper: ImBoolVector. Store 1-bit per value.
|
||||
@@ -276,12 +276,12 @@ struct ImBoolVector
|
||||
{
|
||||
ImVector<int> Storage;
|
||||
ImBoolVector() { }
|
||||
void Resize(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||||
void Resize(const int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||||
void Clear() { Storage.clear(); }
|
||||
bool GetBit(int n) const {
|
||||
bool GetBit(const int n) const {
|
||||
const int off = (n >> 5);
|
||||
const int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; }
|
||||
void SetBit(int n, bool v) {
|
||||
void SetBit(const int n, const bool v) {
|
||||
const int off = (n >> 5);
|
||||
const int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; }
|
||||
};
|
||||
@@ -298,15 +298,15 @@ struct IMGUI_API ImPool
|
||||
|
||||
ImPool() { FreeIdx = 0; }
|
||||
~ImPool() { Clear(); }
|
||||
T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
|
||||
T* GetByKey(const ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
|
||||
T* GetByIndex(ImPoolIdx n) { return &Data[n]; }
|
||||
ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
|
||||
T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
||||
T* GetOrAddByKey(const ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
||||
bool Contains(const T* p) const { return (p >= Data.Data && p < Data.Data + Data.Size); }
|
||||
void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; }
|
||||
T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
|
||||
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||||
void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
||||
void Remove(const ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||||
void Remove(const ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
|
||||
void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); }
|
||||
int GetSize() const { return Data.Size; }
|
||||
};
|
||||
@@ -530,7 +530,7 @@ struct ImVec1
|
||||
{
|
||||
float x;
|
||||
ImVec1() { x = 0.0f; }
|
||||
ImVec1(float _x) { x = _x; }
|
||||
ImVec1(const float _x) { x = _x; }
|
||||
};
|
||||
|
||||
// 2D vector (half-size integer)
|
||||
@@ -538,7 +538,7 @@ struct ImVec2ih
|
||||
{
|
||||
short x, y;
|
||||
ImVec2ih() { x = y = 0; }
|
||||
ImVec2ih(short _x, short _y) { x = _x; y = _y; }
|
||||
ImVec2ih(const short _x, const short _y) { x = _x; y = _y; }
|
||||
};
|
||||
|
||||
// 2D axis aligned bounding-box
|
||||
@@ -551,7 +551,7 @@ struct IMGUI_API ImRect
|
||||
ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {}
|
||||
ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
|
||||
ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
|
||||
ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
|
||||
ImRect(const float x1, const float y1, const float x2, const float y2) : Min(x1, y1), Max(x2, y2) {}
|
||||
|
||||
ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
|
||||
ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
|
||||
@@ -569,8 +569,8 @@ struct IMGUI_API ImRect
|
||||
void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
|
||||
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
||||
void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
|
||||
void TranslateX(float dx) { Min.x += dx; Max.x += dx; }
|
||||
void TranslateY(float dy) { Min.y += dy; Max.y += dy; }
|
||||
void TranslateX(const float dx) { Min.x += dx; Max.x += dx; }
|
||||
void TranslateY(const float dy) { Min.y += dy; Max.y += dy; }
|
||||
void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
|
||||
void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
|
||||
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||
@@ -597,9 +597,9 @@ struct ImGuiStyleMod
|
||||
{
|
||||
ImGuiStyleVar VarIdx;
|
||||
union { int BackupInt[2]; float BackupFloat[2]; };
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; }
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; }
|
||||
ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
|
||||
ImGuiStyleMod(const ImGuiStyleVar idx, const int v) { VarIdx = idx; BackupInt[0] = v; }
|
||||
ImGuiStyleMod(const ImGuiStyleVar idx, const float v) { VarIdx = idx; BackupFloat[0] = v; }
|
||||
ImGuiStyleMod(const ImGuiStyleVar idx, const ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
|
||||
};
|
||||
|
||||
// Stacked storage data for BeginGroup()/EndGroup()
|
||||
@@ -852,7 +852,7 @@ struct ImGuiPtrOrIndex
|
||||
int Index; // Usually index in a main pool.
|
||||
|
||||
ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; }
|
||||
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
||||
ImGuiPtrOrIndex(const int index) { Ptr = NULL; Index = index; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1601,10 +1601,10 @@ namespace ImGui
|
||||
|
||||
// Inputs
|
||||
IMGUI_API bool IsMouseDragPastThreshold(int button, float lock_threshold = -1.0f);
|
||||
inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
|
||||
inline bool IsNavInputDown(ImGuiNavInput n) { return GImGui->IO.NavInputs[n] > 0.0f; }
|
||||
inline bool IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
|
||||
inline bool IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
|
||||
inline bool IsKeyPressedMap(const ImGuiKey key, const bool repeat = true) { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
|
||||
inline bool IsNavInputDown(const ImGuiNavInput n) { return GImGui->IO.NavInputs[n] > 0.0f; }
|
||||
inline bool IsNavInputPressed(const ImGuiNavInput n, const ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
|
||||
inline bool IsNavInputPressedAnyOfTwo(const ImGuiNavInput n1, const ImGuiNavInput n2, const ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
|
||||
|
||||
// Drag and Drop
|
||||
IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
|
||||
@@ -1658,9 +1658,9 @@ namespace ImGui
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while.
|
||||
inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) {
|
||||
inline void RenderArrow(const ImVec2 pos, const ImGuiDir dir, const float scale=1.0f) {
|
||||
const ImGuiWindow * window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); }
|
||||
inline void RenderBullet(ImVec2 pos) {
|
||||
inline void RenderBullet(const ImVec2 pos) {
|
||||
const ImGuiWindow * window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); }
|
||||
#endif
|
||||
|
||||
@@ -1701,7 +1701,7 @@ namespace ImGui
|
||||
// InputText
|
||||
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format);
|
||||
inline bool TempInputTextIsActive(ImGuiID id) {
|
||||
inline bool TempInputTextIsActive(const ImGuiID id) {
|
||||
const ImGuiContext & g = *GImGui; return (g.ActiveId == id && g.TempInputTextId == id); }
|
||||
|
||||
// Color
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -227,7 +227,7 @@ enum
|
||||
STBRP__INIT_skyline = 1
|
||||
};
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
|
||||
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, const int heuristic)
|
||||
{
|
||||
switch (context->init_mode) {
|
||||
case STBRP__INIT_skyline:
|
||||
@@ -239,7 +239,7 @@ STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, const int allow_out_of_mem)
|
||||
{
|
||||
if (allow_out_of_mem)
|
||||
// if it's ok to run out of memory, then don't bother aligning them;
|
||||
@@ -259,7 +259,7 @@ STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_ou
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
|
||||
STBRP_DEF void stbrp_init_target(stbrp_context *context, const int width, const int height, stbrp_node *nodes, const int num_nodes)
|
||||
{
|
||||
int i;
|
||||
#ifndef STBRP_LARGE_RECTS
|
||||
@@ -292,7 +292,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height,
|
||||
}
|
||||
|
||||
// find minimum y position if it starts at x1
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, const int x0, const int width, int *pwaste)
|
||||
{
|
||||
const stbrp_node *node = first;
|
||||
const int x1 = x0 + width;
|
||||
@@ -348,7 +348,7 @@ typedef struct
|
||||
stbrp_node **prev_link;
|
||||
} stbrp__findresult;
|
||||
|
||||
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
|
||||
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, const int height)
|
||||
{
|
||||
int best_waste = (1<<30), best_x, best_y = (1 << 30);
|
||||
stbrp__findresult fr;
|
||||
@@ -450,7 +450,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt
|
||||
return fr;
|
||||
}
|
||||
|
||||
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
|
||||
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, const int width, const int height)
|
||||
{
|
||||
// find best position according to heuristic
|
||||
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
|
||||
@@ -555,7 +555,7 @@ static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||
#define STBRP__MAXVAL 0xffff
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, const int num_rects)
|
||||
{
|
||||
int i, all_rects_packed = 1;
|
||||
|
||||
|
||||
@@ -1127,18 +1127,18 @@ static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b)
|
||||
return b->data[b->cursor];
|
||||
}
|
||||
|
||||
static void stbtt__buf_seek(stbtt__buf *b, int o)
|
||||
static void stbtt__buf_seek(stbtt__buf *b, const int o)
|
||||
{
|
||||
STBTT_assert(!(o > b->size || o < 0));
|
||||
b->cursor = (o > b->size || o < 0) ? b->size : o;
|
||||
}
|
||||
|
||||
static void stbtt__buf_skip(stbtt__buf *b, int o)
|
||||
static void stbtt__buf_skip(stbtt__buf *b, const int o)
|
||||
{
|
||||
stbtt__buf_seek(b, b->cursor + o);
|
||||
}
|
||||
|
||||
static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n)
|
||||
static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, const int n)
|
||||
{
|
||||
stbtt_uint32 v = 0;
|
||||
int i;
|
||||
@@ -1148,7 +1148,7 @@ static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n)
|
||||
return v;
|
||||
}
|
||||
|
||||
static stbtt__buf stbtt__new_buf(const void *p, size_t size)
|
||||
static stbtt__buf stbtt__new_buf(const void *p, const size_t size)
|
||||
{
|
||||
stbtt__buf r;
|
||||
STBTT_assert(size < 0x40000000);
|
||||
@@ -1161,7 +1161,7 @@ static stbtt__buf stbtt__new_buf(const void *p, size_t size)
|
||||
#define stbtt__buf_get16(b) stbtt__buf_get((b), 2)
|
||||
#define stbtt__buf_get32(b) stbtt__buf_get((b), 4)
|
||||
|
||||
static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s)
|
||||
static stbtt__buf stbtt__buf_range(const stbtt__buf *b, const int o, const int s)
|
||||
{
|
||||
stbtt__buf r = stbtt__new_buf(NULL, 0);
|
||||
if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r;
|
||||
@@ -1221,7 +1221,7 @@ static void stbtt__cff_skip_operand(stbtt__buf *b) {
|
||||
}
|
||||
}
|
||||
|
||||
static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key)
|
||||
static stbtt__buf stbtt__dict_get(stbtt__buf *b, const int key)
|
||||
{
|
||||
stbtt__buf_seek(b, 0);
|
||||
while (b->cursor < b->size) {
|
||||
@@ -1236,7 +1236,7 @@ static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key)
|
||||
return stbtt__buf_range(b, 0, 0);
|
||||
}
|
||||
|
||||
static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out)
|
||||
static void stbtt__dict_get_ints(stbtt__buf *b, const int key, const int outcount, stbtt_uint32 *out)
|
||||
{
|
||||
int i;
|
||||
stbtt__buf operands = stbtt__dict_get(b, key);
|
||||
@@ -1250,7 +1250,7 @@ static int stbtt__cff_index_count(stbtt__buf *b)
|
||||
return stbtt__buf_get16(b);
|
||||
}
|
||||
|
||||
static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i)
|
||||
static stbtt__buf stbtt__cff_index_get(stbtt__buf b, const int i)
|
||||
{
|
||||
int count, offsize, start, end;
|
||||
stbtt__buf_seek(&b, 0);
|
||||
@@ -1296,7 +1296,7 @@ static int stbtt__isfont(stbtt_uint8 *font)
|
||||
}
|
||||
|
||||
// @OPTIMIZE: binary search
|
||||
static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag)
|
||||
static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, const stbtt_uint32 fontstart, const char *tag)
|
||||
{
|
||||
const stbtt_int32 num_tables = ttUSHORT(data+fontstart+4);
|
||||
const stbtt_uint32 tabledir = fontstart + 12;
|
||||
@@ -1309,7 +1309,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index)
|
||||
static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, const int index)
|
||||
{
|
||||
// if it's just a font, there's only one valid index
|
||||
if (stbtt__isfont(font_collection))
|
||||
@@ -1357,7 +1357,7 @@ static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict)
|
||||
return stbtt__cff_get_index(&cff);
|
||||
}
|
||||
|
||||
static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart)
|
||||
static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, const int fontstart)
|
||||
{
|
||||
stbtt_uint32 cmap, t;
|
||||
stbtt_int32 i,numTables;
|
||||
@@ -1468,7 +1468,7 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
|
||||
return 1;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
|
||||
STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, const int unicode_codepoint)
|
||||
{
|
||||
stbtt_uint8 *data = info->data;
|
||||
const stbtt_uint32 index_map = info->index_map;
|
||||
@@ -1578,12 +1578,12 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
|
||||
return 0;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
|
||||
STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, const int unicode_codepoint, stbtt_vertex **vertices)
|
||||
{
|
||||
return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
|
||||
}
|
||||
|
||||
static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy)
|
||||
static void stbtt_setvertex(stbtt_vertex *v, const stbtt_uint8 type, const stbtt_int32 x, const stbtt_int32 y, const stbtt_int32 cx, const stbtt_int32 cy)
|
||||
{
|
||||
v->type = type;
|
||||
v->x = (stbtt_int16) x;
|
||||
@@ -1592,7 +1592,7 @@ static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, st
|
||||
v->cy = (stbtt_int16) cy;
|
||||
}
|
||||
|
||||
static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
|
||||
static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, const int glyph_index)
|
||||
{
|
||||
int g1,g2;
|
||||
|
||||
@@ -1614,7 +1614,7 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
|
||||
|
||||
static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
|
||||
|
||||
STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
||||
STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, const int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
||||
{
|
||||
if (info->cff.size) {
|
||||
stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
|
||||
@@ -1630,12 +1630,12 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int
|
||||
return 1;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
|
||||
STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, const int codepoint, int *x0, int *y0, int *x1, int *y1)
|
||||
{
|
||||
return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
|
||||
STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, const int glyph_index)
|
||||
{
|
||||
stbtt_int16 numberOfContours;
|
||||
int g;
|
||||
@@ -1647,8 +1647,8 @@ STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
|
||||
return numberOfContours == 0;
|
||||
}
|
||||
|
||||
static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off,
|
||||
stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy)
|
||||
static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, const int was_off, const int start_off, const stbtt_int32 sx, const stbtt_int32 sy, const stbtt_int32 scx,
|
||||
const stbtt_int32 scy, const stbtt_int32 cx, const stbtt_int32 cy)
|
||||
{
|
||||
if (start_off) {
|
||||
if (was_off)
|
||||
@@ -1903,7 +1903,7 @@ typedef struct
|
||||
|
||||
#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0}
|
||||
|
||||
static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y)
|
||||
static void stbtt__track_vertex(stbtt__csctx *c, const stbtt_int32 x, const stbtt_int32 y)
|
||||
{
|
||||
if (x > c->max_x || !c->started) c->max_x = x;
|
||||
if (y > c->max_y || !c->started) c->max_y = y;
|
||||
@@ -1912,7 +1912,7 @@ static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y)
|
||||
c->started = 1;
|
||||
}
|
||||
|
||||
static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1)
|
||||
static void stbtt__csctx_v(stbtt__csctx *c, const stbtt_uint8 type, const stbtt_int32 x, const stbtt_int32 y, const stbtt_int32 cx, const stbtt_int32 cy, const stbtt_int32 cx1, const stbtt_int32 cy1)
|
||||
{
|
||||
if (c->bounds) {
|
||||
stbtt__track_vertex(c, x, y);
|
||||
@@ -1934,7 +1934,7 @@ static void stbtt__csctx_close_shape(stbtt__csctx *ctx)
|
||||
stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy)
|
||||
static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, const float dx, const float dy)
|
||||
{
|
||||
stbtt__csctx_close_shape(ctx);
|
||||
ctx->first_x = ctx->x = ctx->x + dx;
|
||||
@@ -1942,14 +1942,14 @@ static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy)
|
||||
stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy)
|
||||
static void stbtt__csctx_rline_to(stbtt__csctx *ctx, const float dx, const float dy)
|
||||
{
|
||||
ctx->x += dx;
|
||||
ctx->y += dy;
|
||||
stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
|
||||
static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, const float dx1, const float dy1, const float dx2, const float dy2, const float dx3, const float dy3)
|
||||
{
|
||||
const float cx1 = ctx->x + dx1;
|
||||
const float cy1 = ctx->y + dy1;
|
||||
@@ -1974,7 +1974,7 @@ static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n)
|
||||
return stbtt__cff_index_get(idx, n);
|
||||
}
|
||||
|
||||
static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index)
|
||||
static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, const int glyph_index)
|
||||
{
|
||||
stbtt__buf fdselect = info->fdselect;
|
||||
int nranges, start, end, v, fmt, fdselector = -1, i;
|
||||
@@ -2261,7 +2261,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st
|
||||
#undef STBTT__CSERR
|
||||
}
|
||||
|
||||
static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
|
||||
static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, const int glyph_index, stbtt_vertex **pvertices)
|
||||
{
|
||||
// runs the charstring twice, once to count and once to output (to avoid realloc)
|
||||
stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1);
|
||||
@@ -2278,7 +2278,7 @@ static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, s
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
||||
static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, const int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
||||
{
|
||||
stbtt__csctx c = STBTT__CSCTX_INIT(1);
|
||||
const int r = stbtt__run_charstring(info, glyph_index, &c);
|
||||
@@ -2289,7 +2289,7 @@ static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, in
|
||||
return r ? c.num_vertices : 0;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
|
||||
STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, const int glyph_index, stbtt_vertex **pvertices)
|
||||
{
|
||||
if (!info->cff.size)
|
||||
return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices);
|
||||
@@ -2297,7 +2297,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s
|
||||
return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
|
||||
STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, const int glyph_index, int *advanceWidth, int *leftSideBearing)
|
||||
{
|
||||
const stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
|
||||
if (glyph_index < numOfLongHorMetrics) {
|
||||
@@ -2309,7 +2309,7 @@ STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_inde
|
||||
}
|
||||
}
|
||||
|
||||
static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
|
||||
static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, const int glyph1, const int glyph2)
|
||||
{
|
||||
stbtt_uint8 *data = info->data + info->kern;
|
||||
stbtt_uint32 needle, straw;
|
||||
@@ -2339,7 +2339,7 @@ static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph
|
||||
return 0;
|
||||
}
|
||||
|
||||
static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
|
||||
static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, const int glyph)
|
||||
{
|
||||
const stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
|
||||
switch(coverageFormat) {
|
||||
@@ -2398,7 +2398,7 @@ static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyp
|
||||
return -1;
|
||||
}
|
||||
|
||||
static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
||||
static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, const int glyph)
|
||||
{
|
||||
const stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
|
||||
switch(classDefFormat)
|
||||
@@ -2452,7 +2452,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
||||
// Define to STBTT_assert(x) if you want to break on unimplemented formats.
|
||||
#define STBTT_GPOS_TODO_assert(x)
|
||||
|
||||
static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
|
||||
static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, const int glyph1, const int glyph2)
|
||||
{
|
||||
stbtt_uint16 lookupListOffset;
|
||||
stbtt_uint8 *lookupList;
|
||||
@@ -2580,7 +2580,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, i
|
||||
return 0;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
|
||||
STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, const int g1, const int g2)
|
||||
{
|
||||
int xAdvance = 0;
|
||||
|
||||
@@ -2593,14 +2593,14 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int
|
||||
return xAdvance;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
|
||||
STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, const int ch1, const int ch2)
|
||||
{
|
||||
if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs
|
||||
return 0;
|
||||
return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
|
||||
STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, const int codepoint, int *advanceWidth, int *leftSideBearing)
|
||||
{
|
||||
stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
|
||||
}
|
||||
@@ -2631,13 +2631,13 @@ STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int
|
||||
*y1 = ttSHORT(info->data + info->head + 42);
|
||||
}
|
||||
|
||||
STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
|
||||
STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, const float height)
|
||||
{
|
||||
const int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
|
||||
return (float) height / fheight;
|
||||
}
|
||||
|
||||
STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
|
||||
STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, const float pixels)
|
||||
{
|
||||
const int unitsPerEm = ttUSHORT(info->data + info->head + 18);
|
||||
return pixels / unitsPerEm;
|
||||
@@ -2653,7 +2653,7 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
|
||||
// antialiasing software rasterizer
|
||||
//
|
||||
|
||||
STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, const int glyph, const float scale_x, const float scale_y, const float shift_x, const float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
{
|
||||
int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning
|
||||
if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
|
||||
@@ -2671,17 +2671,17 @@ STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int g
|
||||
}
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, const int glyph, const float scale_x, const float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
{
|
||||
stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, const int codepoint, const float scale_x, const float scale_y, const float shift_x, const float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
{
|
||||
stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, const int codepoint, const float scale_x, const float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
{
|
||||
stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
|
||||
}
|
||||
@@ -2702,7 +2702,7 @@ typedef struct stbtt__hheap
|
||||
int num_remaining_in_head_chunk;
|
||||
} stbtt__hheap;
|
||||
|
||||
static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata)
|
||||
static void *stbtt__hheap_alloc(stbtt__hheap *hh, const size_t size, void *userdata)
|
||||
{
|
||||
if (hh->first_free) {
|
||||
void *p = hh->first_free;
|
||||
@@ -2789,7 +2789,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i
|
||||
return z;
|
||||
}
|
||||
#elif STBTT_RASTERIZER_VERSION == 2
|
||||
static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
|
||||
static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, const float start_point, void *userdata)
|
||||
{
|
||||
auto z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
|
||||
float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
|
||||
@@ -2960,7 +2960,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
||||
|
||||
// the edge passed in here does not cross the vertical line at x or the vertical line at x+1
|
||||
// (i.e. it has already been clipped to those)
|
||||
static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1)
|
||||
static void stbtt__handle_clipped_edge(float *scanline, const int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1)
|
||||
{
|
||||
if (y0 == y1) return;
|
||||
STBTT_assert(y0 < y1);
|
||||
@@ -2997,7 +2997,7 @@ static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edg
|
||||
}
|
||||
}
|
||||
|
||||
static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top)
|
||||
static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, const int len, stbtt__active_edge *e, const float y_top)
|
||||
{
|
||||
const float y_bottom = y_top+1;
|
||||
|
||||
@@ -3161,7 +3161,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
|
||||
}
|
||||
|
||||
// directly AA rasterize edges w/o supersampling
|
||||
static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
|
||||
static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, const int n, const int vsubsample, const int off_x, const int off_y, void *userdata)
|
||||
{
|
||||
stbtt__hheap hh = { 0, 0, 0 };
|
||||
stbtt__active_edge *active = NULL;
|
||||
@@ -3263,7 +3263,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
||||
|
||||
#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0)
|
||||
|
||||
static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
|
||||
static void stbtt__sort_edges_ins_sort(stbtt__edge *p, const int n)
|
||||
{
|
||||
int i,j;
|
||||
for (i=1; i < n; ++i) {
|
||||
@@ -3343,7 +3343,7 @@ static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
|
||||
}
|
||||
}
|
||||
|
||||
static void stbtt__sort_edges(stbtt__edge *p, int n)
|
||||
static void stbtt__sort_edges(stbtt__edge *p, const int n)
|
||||
{
|
||||
stbtt__sort_edges_quicksort(p, n);
|
||||
stbtt__sort_edges_ins_sort(p, n);
|
||||
@@ -3354,7 +3354,8 @@ typedef struct
|
||||
float x,y;
|
||||
} stbtt__point;
|
||||
|
||||
static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata)
|
||||
static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, const int windings, const float scale_x, const float scale_y, const float shift_x, const float shift_y,
|
||||
const int off_x, const int off_y, const int invert, void *userdata)
|
||||
{
|
||||
const float y_scale_inv = invert ? -scale_y : scale_y;
|
||||
stbtt__edge *e;
|
||||
@@ -3411,7 +3412,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou
|
||||
STBTT_free(e, userdata);
|
||||
}
|
||||
|
||||
static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
|
||||
static void stbtt__add_point(stbtt__point *points, const int n, const float x, const float y)
|
||||
{
|
||||
if (!points) return; // during first pass, it's unallocated
|
||||
points[n].x = x;
|
||||
@@ -3419,7 +3420,8 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
|
||||
}
|
||||
|
||||
// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching
|
||||
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
|
||||
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, const float x0, const float y0, const float x1, const float y1, const float x2, const float y2,
|
||||
const float objspace_flatness_squared, const int n)
|
||||
{
|
||||
// midpoint
|
||||
const float mx = (x0 + 2*x1 + x2)/4;
|
||||
@@ -3439,7 +3441,8 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n)
|
||||
static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, const float x0, const float y0, const float x1, const float y1, const float x2, const float y2, const float x3,
|
||||
const float y3, const float objspace_flatness_squared, const int n)
|
||||
{
|
||||
// @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough
|
||||
const float dx0 = x1-x0;
|
||||
@@ -3482,7 +3485,7 @@ static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float
|
||||
}
|
||||
|
||||
// returns number of contours
|
||||
static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
|
||||
static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, const int num_verts, const float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
|
||||
{
|
||||
stbtt__point *points=0;
|
||||
int num_points=0;
|
||||
@@ -3559,7 +3562,8 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
|
||||
STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, const float flatness_in_pixels, stbtt_vertex *vertices, const int num_verts, const float scale_x, const float scale_y, const float shift_x,
|
||||
const float shift_y, const int x_off, const int y_off, const int invert, void *userdata)
|
||||
{
|
||||
const float scale = scale_x > scale_y ? scale_y : scale_x;
|
||||
int winding_count = 0;
|
||||
@@ -3577,7 +3581,7 @@ STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
|
||||
STBTT_free(bitmap, userdata);
|
||||
}
|
||||
|
||||
STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
||||
STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, const float shift_x, const float shift_y, const int glyph, int *width, int *height, int *xoff, int *yoff)
|
||||
{
|
||||
int ix0,iy0,ix1,iy1;
|
||||
stbtt__bitmap gbm;
|
||||
@@ -3617,12 +3621,13 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info
|
||||
return gbm.pixels;
|
||||
}
|
||||
|
||||
STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
||||
STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const int glyph, int *width, int *height, int *xoff, int *yoff)
|
||||
{
|
||||
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y,
|
||||
const float shift_x, const float shift_y, const int glyph)
|
||||
{
|
||||
int ix0,iy0;
|
||||
stbtt_vertex *vertices;
|
||||
@@ -3641,32 +3646,37 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne
|
||||
STBTT_free(vertices, info->userdata);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y,
|
||||
const int glyph)
|
||||
{
|
||||
stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
|
||||
}
|
||||
|
||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const float shift_x, const float shift_y, const int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||
{
|
||||
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x,
|
||||
const float scale_y, const float shift_x, const float shift_y, const int oversample_x, const int oversample_y, float *sub_x, float *sub_y,
|
||||
const int codepoint)
|
||||
{
|
||||
stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint));
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y,
|
||||
const float shift_x, const float shift_y, const int codepoint)
|
||||
{
|
||||
stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
|
||||
}
|
||||
|
||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||
STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const int codepoint, int *width, int *height, int *xoff, int *yoff)
|
||||
{
|
||||
return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
|
||||
STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y,
|
||||
const int codepoint)
|
||||
{
|
||||
stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
|
||||
}
|
||||
@@ -3677,10 +3687,10 @@ STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned ch
|
||||
//
|
||||
// This is SUPER-CRAPPY packing to keep source code small
|
||||
|
||||
static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
|
||||
float pixel_height, // height of font in pixels
|
||||
unsigned char *pixels, int pw, int ph, // bitmap to be filled in
|
||||
int first_char, int num_chars, // characters to bake
|
||||
static int stbtt_BakeFontBitmap_internal(unsigned char *data, const int offset, // font location (use offset=0 for plain .ttf)
|
||||
const float pixel_height, // height of font in pixels
|
||||
unsigned char *pixels, const int pw, const int ph, // bitmap to be filled in
|
||||
const int first_char, const int num_chars, // characters to bake
|
||||
stbtt_bakedchar *chardata)
|
||||
{
|
||||
float scale;
|
||||
@@ -3723,7 +3733,7 @@ static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // fo
|
||||
return bottom_y;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
|
||||
STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, const int pw, const int ph, const int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, const int opengl_fillrule)
|
||||
{
|
||||
const float d3d_bias = opengl_fillrule ? 0 : -0.5f;
|
||||
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
||||
@@ -3821,7 +3831,7 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect
|
||||
// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
|
||||
// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
|
||||
|
||||
STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
|
||||
STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, const int pw, const int ph, const int stride_in_bytes, const int padding, void *alloc_context)
|
||||
{
|
||||
auto context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context);
|
||||
int num_nodes = pw - padding;
|
||||
@@ -3859,7 +3869,7 @@ STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc)
|
||||
STBTT_free(spc->pack_info, spc->user_allocator_context);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
|
||||
STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, const unsigned int h_oversample, const unsigned int v_oversample)
|
||||
{
|
||||
STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
|
||||
STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
|
||||
@@ -3869,14 +3879,14 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
||||
spc->v_oversample = v_oversample;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
|
||||
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, const int skip)
|
||||
{
|
||||
spc->skip_missing = skip;
|
||||
}
|
||||
|
||||
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
||||
|
||||
static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
||||
static void stbtt__h_prefilter(unsigned char *pixels, const int w, const int h, const int stride_in_bytes, const unsigned int kernel_width)
|
||||
{
|
||||
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
|
||||
const int safe_w = w - kernel_width;
|
||||
@@ -3938,7 +3948,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i
|
||||
}
|
||||
}
|
||||
|
||||
static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
||||
static void stbtt__v_prefilter(unsigned char *pixels, const int w, const int h, const int stride_in_bytes, const unsigned int kernel_width)
|
||||
{
|
||||
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
|
||||
const int safe_h = h - kernel_width;
|
||||
@@ -4000,7 +4010,7 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i
|
||||
}
|
||||
}
|
||||
|
||||
static float stbtt__oversample_shift(int oversample)
|
||||
static float stbtt__oversample_shift(const int oversample)
|
||||
{
|
||||
if (!oversample)
|
||||
return 0.0f;
|
||||
@@ -4013,7 +4023,7 @@ static float stbtt__oversample_shift(int oversample)
|
||||
}
|
||||
|
||||
// rects array must be big enough to accommodate all characters in the given ranges
|
||||
STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
||||
STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, const int num_ranges, stbrp_rect *rects)
|
||||
{
|
||||
int i,j,k;
|
||||
|
||||
@@ -4045,7 +4055,9 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb
|
||||
return k;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph)
|
||||
STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x,
|
||||
const float scale_y, const float shift_x, const float shift_y, const int prefilter_x, const int prefilter_y, float *sub_x, float *sub_y,
|
||||
const int glyph)
|
||||
{
|
||||
stbtt_MakeGlyphBitmapSubpixel(info,
|
||||
output,
|
||||
@@ -4069,7 +4081,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info
|
||||
}
|
||||
|
||||
// rects array must be big enough to accommodate all characters in the given ranges
|
||||
STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
||||
STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, const int num_ranges, stbrp_rect *rects)
|
||||
{
|
||||
int i,j,k, return_value = 1;
|
||||
|
||||
@@ -4151,12 +4163,12 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const
|
||||
return return_value;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects)
|
||||
STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, const int num_rects)
|
||||
{
|
||||
stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
|
||||
STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, const int font_index, stbtt_pack_range *ranges, const int num_ranges)
|
||||
{
|
||||
stbtt_fontinfo info;
|
||||
int i,j,n, return_value = 1;
|
||||
@@ -4192,8 +4204,8 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char
|
||||
return return_value;
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
|
||||
int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
|
||||
STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, const int font_index, const float font_size, const int first_unicode_codepoint_in_range,
|
||||
const int num_chars_in_range, stbtt_packedchar *chardata_for_range)
|
||||
{
|
||||
stbtt_pack_range range;
|
||||
range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range;
|
||||
@@ -4204,7 +4216,7 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *
|
||||
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap)
|
||||
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, const int index, const float size, float *ascent, float *descent, float *lineGap)
|
||||
{
|
||||
int i_ascent, i_descent, i_lineGap;
|
||||
float scale;
|
||||
@@ -4217,7 +4229,7 @@ STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int in
|
||||
*lineGap = (float) i_lineGap * scale;
|
||||
}
|
||||
|
||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
|
||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, const int pw, const int ph, const int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, const int align_to_integer)
|
||||
{
|
||||
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
||||
const stbtt_packedchar *b = chardata + char_index;
|
||||
@@ -4321,7 +4333,7 @@ static int equal(float *a, float *b)
|
||||
return (a[0] == b[0] && a[1] == b[1]);
|
||||
}
|
||||
|
||||
static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts)
|
||||
static int stbtt__compute_crossings_x(const float x, float y, const int nverts, stbtt_vertex *verts)
|
||||
{
|
||||
int i;
|
||||
float orig[2], ray[2] = { 1, 0 };
|
||||
@@ -4390,7 +4402,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
||||
return winding;
|
||||
}
|
||||
|
||||
static float stbtt__cuberoot( float x )
|
||||
static float stbtt__cuberoot(const float x )
|
||||
{
|
||||
if (x<0)
|
||||
return -(float) STBTT_pow(-x,1.0f/3.0f);
|
||||
@@ -4399,7 +4411,7 @@ static float stbtt__cuberoot( float x )
|
||||
}
|
||||
|
||||
// x^3 + c*x^2 + b*x + a = 0
|
||||
static int stbtt__solve_cubic(float a, float b, float c, float* r)
|
||||
static int stbtt__solve_cubic(const float a, const float b, const float c, float* r)
|
||||
{
|
||||
const float s = -a / 3;
|
||||
const float p = b - a*a / 3;
|
||||
@@ -4616,7 +4628,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
||||
return data;
|
||||
}
|
||||
|
||||
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
|
||||
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, const float scale, const int codepoint, const int padding, const unsigned char onedge_value, const float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
|
||||
{
|
||||
return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff);
|
||||
}
|
||||
@@ -4632,7 +4644,7 @@ STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata)
|
||||
//
|
||||
|
||||
// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
|
||||
static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
|
||||
static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, const stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
|
||||
{
|
||||
stbtt_int32 i=0;
|
||||
|
||||
@@ -4671,14 +4683,14 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, s
|
||||
return i;
|
||||
}
|
||||
|
||||
static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
|
||||
static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, const int len1, char *s2, const int len2)
|
||||
{
|
||||
return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
|
||||
}
|
||||
|
||||
// returns results in whatever encoding you request... but note that 2-byte encodings
|
||||
// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
|
||||
STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
|
||||
STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, const int platformID, const int encodingID, const int languageID, const int nameID)
|
||||
{
|
||||
stbtt_int32 i,count,stringOffset;
|
||||
stbtt_uint8 *fc = font->data;
|
||||
@@ -4699,7 +4711,7 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id)
|
||||
static int stbtt__matchpair(stbtt_uint8 *fc, const stbtt_uint32 nm, stbtt_uint8 *name, const stbtt_int32 nlen, const stbtt_int32 target_id, const stbtt_int32 next_id)
|
||||
{
|
||||
stbtt_int32 i;
|
||||
const stbtt_int32 count = ttUSHORT(fc+nm+2);
|
||||
@@ -4746,7 +4758,7 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags)
|
||||
static int stbtt__matches(stbtt_uint8 *fc, const stbtt_uint32 offset, stbtt_uint8 *name, const stbtt_int32 flags)
|
||||
{
|
||||
const stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name);
|
||||
stbtt_uint32 nm,hd;
|
||||
@@ -4775,7 +4787,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags)
|
||||
static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, const stbtt_int32 flags)
|
||||
{
|
||||
stbtt_int32 i;
|
||||
for (i=0;;++i) {
|
||||
@@ -4791,14 +4803,12 @@ static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
#endif
|
||||
|
||||
STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,
|
||||
float pixel_height, unsigned char *pixels, int pw, int ph,
|
||||
int first_char, int num_chars, stbtt_bakedchar *chardata)
|
||||
STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, const int offset, const float pixel_height, unsigned char *pixels, const int pw, const int ph, const int first_char, const int num_chars, stbtt_bakedchar *chardata)
|
||||
{
|
||||
return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
|
||||
STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, const int index)
|
||||
{
|
||||
return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
|
||||
}
|
||||
@@ -4808,17 +4818,17 @@ STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
|
||||
return stbtt_GetNumberOfFonts_internal((unsigned char *) data);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
|
||||
STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, const int offset)
|
||||
{
|
||||
return stbtt_InitFont_internal(info, (unsigned char *) data, offset);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags)
|
||||
STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, const int flags)
|
||||
{
|
||||
return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags);
|
||||
}
|
||||
|
||||
STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
|
||||
STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, const int len1, const char *s2, const int len2)
|
||||
{
|
||||
return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user