Created
April 8, 2020 07:56
-
-
Save se5a/22a5b81f4408b582c316335f7dc3fc11 to your computer and use it in GitHub Desktop.
BorderGroup:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BorderGroup | |
{ | |
private static Vector2 _startPos; | |
private static Vector2 _labelSize; | |
private static uint _colour; | |
public static void BeginBorder(string label, uint colour) | |
{ | |
ImGui.PushID(label); | |
_colour = colour; | |
_startPos = ImGui.GetCursorScreenPos(); | |
_startPos.X -= 3; | |
_startPos.Y += ImGui.GetTextLineHeight() * 0.5f; | |
ImGui.Text(label); | |
_labelSize = ImGui.GetItemRectSize(); | |
} | |
public static void BeginBorder(string label) | |
{ | |
BeginBorder(label, ImGui.GetColorU32(ImGuiCol.Border)); | |
} | |
public static void BeginBorder(string label, ImGuiCol colorIdx) | |
{ | |
BeginBorder(label, ImGui.GetColorU32(colorIdx)); | |
} | |
public static void EndBoarder() | |
{ | |
Vector2 size = new Vector2(ImGui.GetContentRegionAvail().X, ImGui.GetCursorScreenPos().Y - _startPos.Y); | |
//ImGui.get | |
ImDrawListPtr wdl = ImGui.GetWindowDrawList(); | |
Vector2[] pts = new Vector2[6]; | |
pts[0] = new Vector2(_startPos.X + 2, _startPos.Y); | |
pts[1] = _startPos; //top left | |
pts[2] = new Vector2(_startPos.X, _startPos.Y + size.Y); //bottom left | |
pts[3] = new Vector2(_startPos.X + size.X + 3, _startPos.Y + size.Y); //bottom right | |
pts[4] = new Vector2(_startPos.X + size.X + 3, _startPos.Y); | |
pts[5] = new Vector2(_startPos.X + _labelSize.X + 3, _startPos.Y); | |
wdl.AddPolyline(ref pts[0], pts.Length, _colour, false, 1.0f); | |
ImGui.PopID(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment