internal void DrawWithTextSelection(Rect position, GUIContent content, bool isActive, bool hasKeyboardFocus, int firstSelectedCharacter, int lastSelectedCharacter, bool drawSelectionAsComposition, Color selectionColor) { if (Event.current.type != EventType.Repaint) { Debug.LogError("Style.Draw may not be called if it is not a repaint event"); return; } // Figure out the cursor color... Color cursorColor = new Color(0, 0, 0, 0); float cursorFlashSpeed = GUI.skin.settings.cursorFlashSpeed; float cursorFlashRel = (Time.realtimeSinceStartup - Internal_GetCursorFlashOffset()) % cursorFlashSpeed / cursorFlashSpeed; if (cursorFlashSpeed == 0 || cursorFlashRel < .5f) { cursorColor = GUI.skin.settings.cursorColor; } bool hovered = position.Contains(Event.current.mousePosition); var drawStates = new DrawStates(-1, hovered, isActive, false, hasKeyboardFocus, drawSelectionAsComposition, firstSelectedCharacter, lastSelectedCharacter, cursorColor, selectionColor); if (onDraw == null || !onDraw(this, position, content, drawStates)) { Internal_DrawWithTextSelection(position, content, hovered, isActive, false, hasKeyboardFocus, drawSelectionAsComposition, firstSelectedCharacter, lastSelectedCharacter, cursorColor, selectionColor); } }
private void Draw(Rect position, GUIContent content, int controlId, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { if (Event.current.type != EventType.Repaint) { throw new Exception("Style.Draw may not be called if it is not a repaint event"); } if (content == null) { throw new Exception("Style.Draw may not be called with GUIContent that is null."); } var drawStates = new DrawStates(controlId, isHover, isActive, on, hasKeyboardFocus); if (onDraw == null || !onDraw(this, position, content, drawStates)) { if (controlId == -1) { Internal_Draw(position, content, isHover, isActive, on, hasKeyboardFocus); } else { Internal_Draw2(position, content, controlId, on); } } }
internal void DrawWithTextSelection(Rect position, GUIContent content, bool isActive, bool hasKeyboardFocus, int firstSelectedCharacter, int lastSelectedCharacter, bool drawSelectionAsComposition, Color selectionColor) { bool flag = Event.current.type != EventType.Repaint; if (flag) { Debug.LogError("Style.Draw may not be called if it is not a repaint event"); } else { Color cursorColor = new Color(0f, 0f, 0f, 0f); float cursorFlashSpeed = GUI.skin.settings.cursorFlashSpeed; float num = (Time.realtimeSinceStartup - GUIStyle.Internal_GetCursorFlashOffset()) % cursorFlashSpeed / cursorFlashSpeed; bool flag2 = cursorFlashSpeed == 0f || num < 0.5f; if (flag2) { cursorColor = GUI.skin.settings.cursorColor; } bool isHover = position.Contains(Event.current.mousePosition); DrawStates states = new DrawStates(-1, isHover, isActive, false, hasKeyboardFocus, drawSelectionAsComposition, firstSelectedCharacter, lastSelectedCharacter, cursorColor, selectionColor); bool flag3 = GUIStyle.onDraw == null || !GUIStyle.onDraw(this, position, content, states); if (flag3) { this.Internal_DrawWithTextSelection(position, content, isHover, isActive, false, hasKeyboardFocus, drawSelectionAsComposition, firstSelectedCharacter, lastSelectedCharacter, cursorColor, selectionColor); } } }
private void Draw(Rect position, GUIContent content, int controlId, bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { bool flag = Event.current.type != EventType.Repaint; if (flag) { throw new Exception("Style.Draw may not be called if it is not a repaint event"); } bool flag2 = content == null; if (flag2) { throw new Exception("Style.Draw may not be called with GUIContent that is null."); } DrawStates states = new DrawStates(controlId, isHover, isActive, on, hasKeyboardFocus); bool flag3 = GUIStyle.onDraw == null || !GUIStyle.onDraw(this, position, content, states); if (flag3) { bool flag4 = controlId == -1; if (flag4) { this.Internal_Draw(position, content, isHover, isActive, on, hasKeyboardFocus); } else { this.Internal_Draw2(position, content, controlId, on); } } }
public DrawStates(int controlId, bool isHover, bool isActive, bool on, bool hasKeyboardFocus, bool drawSelectionAsComposition, int cursorFirst, int cursorLast, Color cursorColor, Color selectionColor) { this = new DrawStates(controlId, isHover, isActive, on, hasKeyboardFocus); this.hasTextInput = true; this.drawSelectionAsComposition = drawSelectionAsComposition; this.cursorFirst = cursorFirst; this.cursorLast = cursorLast; this.cursorColor = cursorColor; this.selectionColor = selectionColor; }
// PrefixLabel has to be drawn with an alternative draw method. // The normal draw methods use MonoGUIContentToTempNative which means they all share the same temp GUIContent on the native side. // A native IMGUI control such as GUIButton is already using this temp GUIContent when it calls GetControlID, which, // because of the delayed feature in PrefixLabel, can end up calling a style draw function again to draw the PrefixLabel. // This draw call cannot use the same temp GUIContent that is already needed for the GUIButton control itself, // so it has to use this alternative code path that uses a different GUIContent to store the content in. // We can all agree this workaround is not nice at all. But nobody seemed to be able to come up with something better. internal void DrawPrefixLabel(Rect position, GUIContent content, int controlID) { if (content != null) { var drawStates = new DrawStates(controlID, position.Contains(Event.current.mousePosition), false, false, GUIUtility.keyboardControl == controlID); if (onDraw == null || !onDraw(this, position, content, drawStates)) { Internal_DrawPrefixLabel(position, content, controlID, false); } } else { Debug.LogError("Style.DrawPrefixLabel may not be called with GUIContent that is null."); } }
internal void DrawPrefixLabel(Rect position, GUIContent content, int controlID) { bool flag = content != null; if (flag) { DrawStates states = new DrawStates(controlID, position.Contains(Event.current.mousePosition), false, false, GUIUtility.HasKeyFocus(controlID)); bool flag2 = GUIStyle.onDraw == null || !GUIStyle.onDraw(this, position, content, states); if (flag2) { this.Internal_DrawPrefixLabel(position, content, controlID, false); } } else { Debug.LogError("Style.DrawPrefixLabel may not be called with GUIContent that is null."); } }
public DrawStates(bool isHover, bool isActive, bool on, bool hasKeyboardFocus) { this = new DrawStates(-1, isHover, isActive, on, hasKeyboardFocus); }