Example #1
0
        internal static void Clear()
        {
            LGuiContextCache.Clear();

            IO.Clear();
            Font = LGuiFont.Default;

            FocusID           = 0;
            ActiveID          = 0;
            HoveredID         = 0;
            FrameCount        = 0;
            PreviousControlID = 0;
            ActiveRect        = LGuiRect.Zero;
        }
Example #2
0
        internal static LGuiVec2 GetTextSize(string Text, LGuiFont Font)
        {
            if (string.IsNullOrEmpty(Text))
            {
                Text = " ";
            }

            var Hash = Font.GetHashCode();

            if (!TextSizeCache_.ContainsKey(Hash))
            {
                TextSizeCache_.Add(Hash, new Dictionary <string, LGuiVec2>());
            }

            if (!TextSizeCache_[Hash].ContainsKey(Text))
            {
                TextSizeCache_[Hash].Add(Text, GetTextSizeFunc?.Invoke(Text, Font) ?? LGuiVec2.Zero);
            }

            return(TextSizeCache_[Hash][Text]);

            // return GetTextSizeFunc?.Invoke(Text, Style) ?? LGuiVec2.Zero;
        }