/// <summary> /// Draws a quad with a the provided texture displayed. /// </summary> /// <param name="texture">Texture to draw.</param> /// <param name="area">Position and size of the texture to draw. Position is relative to the canvas origin /// (top-left). If size is zero, the default texture size will be used.</param> /// <param name="color">Color to tint the drawn texture with.</param> /// <param name="scaleMode">Scale mode to use when sizing the texture. Only relevant if the provided quad size /// doesn't match the texture size.</param> /// <param name="depth">Depth at which to draw the element. Elements with higher depth will be drawn before others. /// Additionally elements of the same type (triangle or line) will be drawn in order they are /// submitted if they share the same depth.</param> public void DrawTexture(SpriteTexture texture, Rect2I area, Color color, GUITextureScaleMode scaleMode = GUITextureScaleMode.StretchToFit, byte depth = 128) { IntPtr texturePtr = IntPtr.Zero; if (texture != null) { texturePtr = texture.GetCachedPtr(); } Internal_DrawTexture(mCachedPtr, texturePtr, ref area, scaleMode, ref color, depth); }
/// <summary> /// Clips current rectangle so that it does not overlap the provided rectangle. After clipping no area of this /// rectangle will intersect the clip area. /// </summary> /// <param name="clipRect">Rectangle to clip against.</param> public void Clip(Rect2I clipRect) { int newLeft = Math.Max(x, clipRect.x); int newTop = Math.Max(y, clipRect.y); int newRight = Math.Min(x + width, clipRect.x + clipRect.width); int newBottom = Math.Min(y + height, clipRect.y + clipRect.height); x = Math.Min(newLeft, newRight); y = Math.Min(newTop, newBottom); width = Math.Max(0, newRight - newLeft); height = Math.Max(0, newBottom - newTop); }
/// <summary> /// Changes the size of the list view. /// </summary> /// <param name="width">Width in pixels.</param> /// <param name="height">Height in pixels.</param> public void SetSize(int width, int height) { if (width != this.width || height != this.height) { this.width = width; this.height = height; Rect2I bounds = scrollArea.Bounds; bounds.width = width; bounds.height = height; scrollArea.Bounds = bounds; } }
/// <summary> /// Returns true if the rectangle overlaps the provided rectangle. Also returns true if the rectangles are // contained within each other completely (no intersecting edges). /// </summary> /// <param name="other">Other rectangle to compare with.</param> /// <returns>True if the rectangles overlap.</returns> public bool Overlaps(Rect2I other) { int otherRight = other.x + other.width; int myRight = x + width; int otherBottom = other.y + other.height; int myBottom = y + height; if (x < otherRight && myRight > other.x && y < otherBottom && myBottom > other.y) { return(true); } return(false); }
/// <inheritdoc/> public override bool Equals(object other) { if (!(other is Rect2I)) { return(false); } Rect2I rect = (Rect2I)other; if (x.Equals(rect.x) && y.Equals(rect.y) && width.Equals(rect.width) && height.Equals(rect.height)) { return(true); } return(false); }
private static extern void Internal_GetContentBounds(IntPtr nativeInstance, out Rect2I value);
private static extern void Internal_SetBounds(IntPtr nativeInstance, ref Rect2I value);
private static extern void Internal_DrawTexture(IntPtr nativeInstance, IntPtr texture, ref Rect2I area, GUITextureScaleMode scaleMode, ref Color color, byte depth);
private static extern void Internal_CalculateBounds(IntPtr element, IntPtr relativeTo, out Rect2I output);
private static extern void Internal_getPixelArea(IntPtr thisPtr, out Rect2I __output);
/// <summary> /// Clips the cursor to the specified area. Enabled until <see cref="ClipDisable"/> is called. /// </summary> /// <param name="area">Area in screen space to clip the cursor to.</param> public static void ClipToRect(Rect2I area) { Internal_ClipToRect(ref area); }
private static extern void Internal_ClipToRect(ref Rect2I value);