Fix color editing functions

internals
Eric Mellino 8 years ago
parent bf7aab44e2
commit c054db3719
  1. 53
      src/ImGui.NET/ImGui.cs
  2. 4
      src/ImGui.NET/ImGuiNative.cs

@ -170,18 +170,57 @@ namespace ImGuiNET
return ImGuiNative.igColorButton(color, smallHeight, outlineBorder);
}
public static bool ColorEdit3(string label, float r, float g, float b) => ColorEdit3(label, new Vector3(r, g, b));
public static bool ColorEdit3(string label, Vector3 color)
public static unsafe bool ColorEdit3(string label, ref float r, ref float g, ref float b, bool showAlpha)
{
return ImGuiNative.igColorEdit3(label, color);
Vector3 localColor = new Vector3(r, g, b);
bool result = ImGuiNative.igColorEdit3(label, &localColor);
if (result)
{
r = localColor.X;
g = localColor.Y;
b = localColor.Z;
}
return result;
}
public static bool ColorEdit4(string label, float r, float g, float b, float a, bool showAlpha)
=> ColorEdit4(label, new Vector4(r, g, b, a), showAlpha);
public static unsafe bool ColorEdit3(string label, ref Vector3 color, bool showAlpha)
{
Vector3 localColor = color;
bool result = ImGuiNative.igColorEdit3(label, &localColor);
if (result)
{
color = localColor;
}
public static bool ColorEdit4(string label, Vector4 color, bool showAlpha)
return result;
}
public static unsafe bool ColorEdit4(string label, ref float r, ref float g, ref float b, ref float a, bool showAlpha)
{
return ImGuiNative.igColorEdit4(label, color, showAlpha);
Vector4 localColor = new Vector4(r, g, b, a);
bool result = ImGuiNative.igColorEdit4(label, &localColor, showAlpha);
if (result)
{
r = localColor.X;
g = localColor.Y;
b = localColor.Z;
a = localColor.W;
}
return result;
}
public static unsafe bool ColorEdit4(string label, ref Vector4 color, bool showAlpha)
{
Vector4 localColor = color;
bool result = ImGuiNative.igColorEdit4(label, &localColor, showAlpha);
if (result)
{
color = localColor;
}
return result;
}
public static void ColorEditMode(ColorEditMode mode)

@ -326,10 +326,10 @@ namespace ImGuiNET
public static extern bool igColorButton(Vector4 col, bool small_height, bool outline_border);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool igColorEdit3(string label, Vector3 col);
public static extern bool igColorEdit3(string label, Vector3* col);
[DllImport(cimguiLib)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool igColorEdit4(string label, Vector4 col, bool show_alpha);
public static extern bool igColorEdit4(string label, Vector4* col, bool show_alpha);
[DllImport(cimguiLib)]
public static extern void igColorEditMode(ColorEditMode mode);
[DllImport(cimguiLib)]

Loading…
Cancel
Save