🟑cl_frame.lua

Dlib.Frame is a custom visual GUI component for Garry's Mod, extending the base DFrame. It offers an enhanced, modernized look, the possibility for an entrance animation, and a custom close button.

PANEL Class Definition:

Properties:

  • useAnimation - Determines whether an entrance animation is to be used when the frame appears.

  • startAnim - Timestamp of when the animation starts (in system time).

  • animDuration - Duration of the entrance animation in seconds.

  • closeBtn - Custom close button object.

Functions & Methods:

  • Init() - Initializes the frame with default settings. This includes settings like size, title, and visibility of default buttons. Moreover, it sets up the custom close button and its functionality.

  • SetUseAnimation(useAnim) - Sets the state of whether the entrance animation should be used or not.

    • useAnim: Boolean (true or false).

  • Paint(w, h) - Custom paint function, responsible for rendering the frame. This includes drawing the frame's background and header, as well as positioning the close button.

    • w: Width of the frame.

    • h: Height of the frame.

Example Usage:

To open a Dlib.Frame:

concommand.Add("test", function()
    -- Creating a Dlib.Frame instance
    local frame = vgui.Create("Dlib.Frame")
    frame:SetSize(500, 500)
    frame:Center()
    frame:SetTitle("Test Frame")
end)

concommand.Add("test", function() -- Creating a Dlib.Frame instance local frame = vgui.Create("Dlib.Frame") frame:SetSize(500, 500) frame:Center() frame:SetTitle("Test Frame") end)

Preview:

Note:

For smooth user experience and improved aesthetics, ensure the entrance animation duration (animDuration) is chosen thoughtfully. Overly lengthy or abrupt animations might diminish user experience.

Last updated