Ejemplo n.º 1
0
        public static void DrawText(Font font, string text, Color color, ref TextLayoutOptions layout)
        {
#if UNIT_TEST_COMPILANT
            throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set.");
#else
            Internal_DrawText1(Object.GetUnmanagedPtr(font), text, ref color, ref layout);
#endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a text using a custom material shader. Given material must have GUI domain and a public parameter named Font (texture parameter used for a font atlas sampling).
        /// </summary>
        /// <param name="font">The font to use.</param>
        /// <param name="customMaterial">Custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.</param>
        /// <param name="text">The text to render.</param>
        /// <param name="layoutRect">The size and position of the area in which the text is drawn.</param>
        /// <param name="color">The text color.</param>
        /// <param name="horizontalAlignment">The horizontal alignment of the text in a layout rectangle.</param>
        /// <param name="verticalAlignment">The vertical alignment of the text in a layout rectangle.</param>
        /// <param name="textWrapping">Describes how wrap text inside a layout rectangle.</param>
        /// <param name="baseLinesGapScale">The scale for distance one baseline from another. Default is 1.</param>
        /// <param name="scale">The text drawing scale. Default is 1.</param>
        public static void DrawText(Font font, MaterialBase customMaterial, string text, Rectangle layoutRect, Color color, TextAlignment horizontalAlignment = TextAlignment.Near, TextAlignment verticalAlignment = TextAlignment.Near, TextWrapping textWrapping = TextWrapping.NoWrap, float baseLinesGapScale = 1.0f, float scale = 1.0f)
        {
            var layout = new TextLayoutOptions
            {
                Bounds = layoutRect,
                HorizontalAlignment = horizontalAlignment,
                VerticalAlignment   = verticalAlignment,
                TextWrapping        = textWrapping,
                Scale             = scale,
                BaseLinesGapScale = baseLinesGapScale,
            };

            DrawText(font, text, color, ref layout, customMaterial);
        }
Ejemplo n.º 3
0
 internal static extern void Internal_DrawText3(IntPtr font, string text, ref TextRange textRange, ref Color color, ref TextLayoutOptions layout, IntPtr customMaterial);
Ejemplo n.º 4
0
 /// <summary>
 /// Draws a text with formatting.
 /// </summary>
 /// <param name="font">The font to use.</param>
 /// <param name="text">The text to render.</param>
 /// <param name="textRange">The input text range (substring range of the input text parameter).</param>
 /// <param name="color">The text color.</param>
 /// <param name="layout">The text layout properties.</param>
 /// <param name="customMaterial">The custom material for font characters rendering. It must contain texture parameter named Font used to sample font texture.</param>
 public static void DrawText(Font font, string text, ref TextRange textRange, Color color, ref TextLayoutOptions layout, MaterialBase customMaterial = null)
 {
     Internal_DrawText3(FlaxEngine.Object.GetUnmanagedPtr(font), text, ref textRange, ref color, ref layout, FlaxEngine.Object.GetUnmanagedPtr(customMaterial));
 }
Ejemplo n.º 5
0
 internal static extern void Internal_SetLayoutOptions(IntPtr obj, ref TextLayoutOptions value);
Ejemplo n.º 6
0
 internal static extern void Internal_GetLayoutOptions(IntPtr obj, out TextLayoutOptions resultAsRef);
Ejemplo n.º 7
0
 internal static extern void Internal_GetCharPosition1(IntPtr obj, string text, ref TextRange textRange, int index, ref TextLayoutOptions layout, out Vector2 resultAsRef);
Ejemplo n.º 8
0
 internal static extern void Internal_DrawText1(IntPtr font, string text, ref Color color, ref TextLayoutOptions layout);
Ejemplo n.º 9
0
 internal static extern int Internal_HitTestText1(IntPtr obj, string text, ref Vector2 location, ref TextLayoutOptions layout);
Ejemplo n.º 10
0
 /// <summary>
 /// Calculates character position for given text and character index.
 /// </summary>
 /// <param name="text">The input text to test.</param>
 /// <param name="textRange">The input text range (substring range of the input text parameter).</param>
 /// <param name="index">The text position to get coordinates of.</param>
 /// <param name="layout">The text layout properties.</param>
 /// <returns>The character position (upper left corner which can be used for a caret position).</returns>
 public Vector2 GetCharPosition(string text, ref TextRange textRange, int index, ref TextLayoutOptions layout)
 {
     Internal_GetCharPosition1(unmanagedPtr, text, ref textRange, index, ref layout, out var resultAsRef); return(resultAsRef);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Calculates hit character index at given location.
 /// </summary>
 /// <param name="text">The input text to test.</param>
 /// <param name="location">The input location to test.</param>
 /// <param name="layout">The text layout properties.</param>
 /// <returns>The selected character position index (can be equal to text length if location is outside of the layout rectangle).</returns>
 public int HitTestText(string text, Vector2 location, ref TextLayoutOptions layout)
 {
     return(Internal_HitTestText1(unmanagedPtr, text, ref location, ref layout));
 }
Ejemplo n.º 12
0
 internal static extern void Internal_MeasureText(IntPtr obj, string text, ref TextLayoutOptions layout, out Vector2 resultAsRef);
Ejemplo n.º 13
0
 /// <summary>
 /// Measures minimum size of the rectangle that will be needed to draw given text.
 /// </summary>
 /// <param name="text">The input text to test.</param>
 /// <param name="layout">The layout properties.</param>
 /// <returns>The minimum size for that text and fot to render properly.</returns>
 public Vector2 MeasureText(string text, ref TextLayoutOptions layout)
 {
     Internal_MeasureText(unmanagedPtr, text, ref layout, out var resultAsRef); return(resultAsRef);
 }
Ejemplo n.º 14
0
 internal static extern FontLineCache[] Internal_ProcessText(IntPtr obj, string text, ref TextLayoutOptions layout, System.Type resultArrayItemType0);
Ejemplo n.º 15
0
 /// <summary>
 /// Processes text to get cached lines for rendering.
 /// </summary>
 /// <param name="text">The input text.</param>
 /// <param name="layout">The layout properties.</param>
 /// <returns>The output lines list.</returns>
 public FontLineCache[] ProcessText(string text, ref TextLayoutOptions layout)
 {
     return(Internal_ProcessText(unmanagedPtr, text, ref layout, typeof(FontLineCache)));
 }