-
Notifications
You must be signed in to change notification settings - Fork 1
melon.elements
melon.elements
Contains all PANEL objects added by the library
melon
Generic unstyled button

melon.elements.Button:Click(enum: MOUSE_, double?: bool)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | enum | MOUSE_ | What was the MOUSE_ enum of the click |
| 2 | double? | bool | Was this click a double click |
Called on any click, dont override this unless you have to

melon.elements.Button:RightClick(double?: bool)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | double? | bool | Was this click a double click |
Called on right click, override this.

melon.elements.Button:LeftClick(double?: bool)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | double? | bool | Was this click a double click |
Called on left click, override this.

melon.elements.Button:CanClick(enum: MOUSE_, double?: bool) -> bool?
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | enum | MOUSE_ | What was the MOUSE_ enum of the click |
| 2 | double? | bool | Was this click a double click |
| # | Name | Type | Description |
|---|---|---|---|
| 1 | can_click | bool | Should we fire the click event |
Override this to determine whether or not to fire click events

melon.elements.Button:OtherClick(enum: MOUSE_, double?: bool)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | enum | MOUSE_ | What was the MOUSE_ enum of the click |
| 2 | double? | bool | Was this click a double click |
Called on any click that isnt right or left.
Draggable Panel object
local p = vgui.Create("DPanel")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p.drag = vgui.Create("Melon:Draggable", p)
p.drag:SetSize(200, 200)
p.drag:Center()
p.drag:SetAreaOf(p) local p = vgui.Create("DPanel")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p.drag = vgui.Create("Melon:Draggable", p)
p.drag:SetSize(200, 200)
p.drag:Center()
p.drag:SetAreaOf(p) All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*
| Name | Type | Comment |
|---|---|---|
| AreaOf | panel | Panel to drag when dragging this panel, think a topbar of a frame |
| Bounded | panel | Panel to limit the draggable area to, you can also pass true for the parent or false to disable |

melon.elements.Draggable:EndDragging()
Called when the panel stops being dragged, remember to invalidlink(SetCursor)

melon.elements.Draggable:StartDragging()
Called when the panel starts being dragged, remember to invalidlink(SetCursor)
A basepanel thats children render adheres to a mask

melon.elements.Mask:Mask(w: number, h: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | w | number | Width of the panel |
| 2 | h | number | Height of the panel |
Called once per frame to determine the mask of the panel, override this

melon.elements.Mask:PaintMaskRelative()
Paints the mask texture relative to the given panel

melon.elements.Mask:DoMask(pnl: Panel, w: number, h: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | pnl | Panel | Panel were rendering the mask of |
| 2 | w | number | Width of the panel |
| 3 | h | number | Height of the panel |

melon.elements.Mask:MakeMask(panel: panel)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | panel | panel | Panel to add to this mask |
Resizable Panel object
local p = vgui.Create("Melon:Resizable")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p:SetMaxSize(600, 600)
p:SetMinSize(200, 200) local p = vgui.Create("Melon:Resizable")
p:SetSize(400, 400)
p:Center()
p:MakePopup()
p:SetMaxSize(600, 600)
p:SetMinSize(200, 200)

melon.elements.Resizable:SetMaxSize(w: number, h: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | w | number | Width of the max size |
| 2 | h | number | Height of the max size |
Sets the maximum size for the panel to be resizable to

melon.elements.Resizable:StartDragging()
Called when the panel starts being resized, remember to invalidlink(SetCursor)

melon.elements.Resizable:WithinDragRegion(x: number, y: number) -> bool?
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | x | number | X to check |
| 2 | y | number | Y to check |
| # | Name | Type | Description |
|---|---|---|---|
| 1 | is | bool | Is it within the draggable region |
Check if a coord is within the drag region

melon.elements.Resizable:AnimDone()
Called when the animation is done, if you replace Paint you need to call this by hand

melon.elements.Resizable:SetDragSize(size: number, pad: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | size | number | Size of the draggable area |
| 2 | pad | number | Padding from the edge of the draggable area |
Sets the draggable corner size and padding

melon.elements.Resizable:OnTabChanged(new: panel, old: panel)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | new | panel | New tab panel |
| 2 | old | panel | Old tab panel |
Called when the tab is changed

melon.elements.Resizable:EndDragging()
Called when the panel stops being resized, remember to invalidlink(SetCursor)

melon.elements.Resizable:SetMinSize(w: number, h: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | w | number | Width of the min size |
| 2 | h | number | Height of the min size |
Sets the minimum size for the panel to be resizable to
Scrollbar for ScrollPanels, handles the actual scrolling logic
All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*
| Name | Type | Comment |
|---|---|---|
| ScrollAmount | number | Current scroll pos in pixels |
| Canvas | Panel | Current canvas panel |
| Horizontal | boolean | Is the scrollbar horizontal |
| OverflowAmount | number | How much is the scrollbar currently overflowing, negative if up |
| iRealScrollAmount | number | Internal, current real scroll position, interpolated |
| iGrabbed | table | Internal, grab data |
| iGripColor | Color | Internal, grip color |
| iPanning | boolean | Internal, are we panning |

melon.elements.ScrollBar:GetDomain() -> number
Returns the "Domain", the actual scrollable area of the canvas, so (canvas_size - parent_size)

melon.elements.ScrollBar:Grab()
Initiates grip grabbing

melon.elements.ScrollBar:ScrollTo(pos: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | pos | number | Position to scroll to |
Scrolls to the given coordinate, if horizontal than X, if vertical than Y

melon.elements.ScrollBar:ScrollToChild(pnl: Panel)
Scrolls to a child panel, if the panel isnt a child then silently fails

melon.elements.ScrollBar:AddScroll(delta: number, pixels?: number)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | delta | number | Scroll delta to add |
| 2 | pixels? | number | Optional, how many pixels to scroll instead of delta |
Scrolls the scrollbar however much is specified
A general purpose unstyled scrollpanel rewrite containing over-content scrollbars, smooth scrolling and canvas based scrolling.
All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*
| Name | Type | Comment |
|---|---|---|
| ScrollPerDelta | number | How many pixels to scroll per-scroll wheel delta, unscaled |
| ScrollbarSize | number | How wide should the scrollbars be |
| ScrollbarPad | number | How much padding should the scrollbars have |
| ScrollbarMaxOverflow | number | How much overflow in pixels should we allocate to the scrollbars, unscaled |
| PanningEnabled | boolean | Should we allow panning on the scrollbars with middle mouse button note you need to call :Pan() yourself |
| Canvas | Panel | Canvas panel |
| VerticalScrollEnabled | boolean | Should we allow vertical scrolling |
| HorizontalScrollEnabled | boolean | Should we allow horizontal scrolling |

melon.elements.ScrollPanel:Pan()
Start panning, should only be called while MOUSE_MIDDLE is down
Automatically abides by the PanningEnabled accessor
Handles multiple tabs, think DPropertySheet without the visuals and builtin handling
All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*
| Name | Type | Comment |
|---|---|---|
| ActiveTab | any | Active tab keyname |
| AnimTime | number | Animation time |
| InitialTab | any | First tab keyname |

melon.elements.Tabs:SetTab(name: string)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | name | string | Name of the tab to set |
Sets the current tab to the given tab, animates!

melon.elements.Tabs:SetTabPending(name: string)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | name | string | Name of the tab to set |
Sets the current tab to the given tab on the next tick
Handles applying animation progress, read the source before replacing the Paint of this, Paint the parent instead

melon.elements.Tabs:AddFutureTab(name: any, fn(name: self) -> Panel)
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | name | any | Identifier for the tab |
| 2 | fn | fn(name: self) -> Panel | Function to run to generate the tab |
Adds a tab that will be generated when the tab gets switched to
Handles animation progress stuff, dont touch, if you do touch replace it

melon.elements.Tabs:AddTab(name: any, panel: Panel) -> Panel
Argument and Return information
| # | Name | Type | Description |
|---|---|---|---|
| 1 | name | any | Keyname for the tab |
| 2 | panel | Panel | Valid Panel to add to the tab handler |
| # | Name | Type | Description |
|---|---|---|---|
| 1 | added | Panel | Panel that was added |
Adds the given panel as a tab with the name given to the handler
A RichText renderer and layout system
[!NOTE]
This is a Panel, it can be created usingvgui.Create("Melon:RichText"). ItsPANELmetatable can be accessed withmelon.elements.RichText
All of these values have Set*/Get* methods for them. They can also be indexed by their name, object.*
| Name | Type | Comment |
|---|---|---|
| Color | Color | Color of the tetx |
| Font | string | Font of the text |
| Underline | number | Should the text be underlined If so, how far should it be from the text baseline, scaled. |
| Strikethrough | bool | Should the text be struck through |
| Interactable | fn | Function to run on text click |
| Custom | fn | Function to run instead of rendering the text |