Garry's Mod Wiki

DColorPalette

Description

The DColorPalette allows the player to select a color from a list of given colors.

This panel supports saving across sessions via the panel cookie system.

Use Panel:SetCookieName to change "save files".

Parent

Derives from DIconLayout.

Methods

DColorPalette:DoClick( table clr, Panel btn )
We advise against using this. It may be changed or removed in a future update. Basically the same functionality as DColorPalette:OnValueChanged, you should use that instead!
number DColorPalette:GetButtonSize()
Returns the size of each palette button. Set by DColorPalette:SetButtonSize.
string DColorPalette:GetConVarA()
Returns the ConVar name for the alpha channel of the color. See also: DColorPalette:GetConVarR - For the red channel DColorPalette:GetConVarG - For the green channel DColorPalette:GetConVarB - For the blue channel
string DColorPalette:GetConVarB()
Returns the ConVar name for the blue channel of the color. See also: DColorPalette:GetConVarR - For the red channel DColorPalette:GetConVarG - For the green channel DColorPalette:GetConVarA - For the alpha channel
string DColorPalette:GetConVarG()
Returns the ConVar name for the green channel of the color. See also: DColorPalette:GetConVarR - For the red channel DColorPalette:GetConVarB - For the blue channel DColorPalette:GetConVarA - For the alpha channel
string DColorPalette:GetConVarR()
Returns the ConVar name for the red channel of the color. See also: DColorPalette:GetConVarG - For the green channel DColorPalette:GetConVarB - For the blue channel DColorPalette:GetConVarA - For the alpha channel
number DColorPalette:GetNumRows()
Returns the number of rows of the palette, provided 6 colors fill each row. This value is equal to the number of colors in the DColorPalette divided by 6.
DColorPalette:NetworkColorChange()
This is used internally - although you're able to use it you probably shouldn't. Used internally to make sure changes on one palette affect other palettes with same name.
DColorPalette:OnRightClickButton( Panel pnl )
Called when a palette button has been pressed
DColorPalette:OnValueChanged( table newcol )
Called when the color is changed after clicking a new value.
DColorPalette:Reset()
Resets this entire color palette to a default preset one, without saving. See DColorPalette:ResetSavedColors for version that also saves the changes.
DColorPalette:ResetSavedColors()
Resets this entire color palette to a default preset one and saves the changes. See DColorPalette:Reset for version that does not save the changes.
DColorPalette:SaveColor( Panel btn, table clr )
Saves the color of given button across sessions. The color is saved as a panel cookie, see Panel:SetCookie and Panel:SetCookieName. It is expected that the amount of colors per palette (Panel:SetCookieName) is the same every time.
DColorPalette:SetButtonSize( number size )
Sets the size of each palette button. This is best kept to such a number, where this equation would return a whole number: WidthOfColorPalette / ButtonSize= WholeNumber If not, there will be ugly whitespace on the right side of the panel.
DColorPalette:SetColor( table clr )
We advise against using this. It may be changed or removed in a future update. Currently does nothing. Intended to "select" the color.
DColorPalette:SetColorButtons( table tab )
Clears the palette and adds new buttons with given colors.
DColorPalette:SetConVarA( string convar )
Sets the ConVar name for the alpha channel of the color. See also: DColorPalette:SetConVarR - For the red channel DColorPalette:SetConVarG - For the green channel DColorPalette:SetConVarB - For the blue channel
DColorPalette:SetConVarB( string convar )
Sets the ConVar name for the blue channel of the color. See also: DColorPalette:SetConVarR - For the red channel DColorPalette:SetConVarG - For the green channel DColorPalette:SetConVarA - For the alpha channel
DColorPalette:SetConVarG( string convar )
Sets the ConVar name for the green channel of the color. See also: DColorPalette:SetConVarR - For the red channel DColorPalette:SetConVarB - For the blue channel DColorPalette:SetConVarA - For the alpha channel
DColorPalette:SetConVarR( string convar )
Sets the ConVar name for the red channel of the color. See also: DColorPalette:SetConVarG - For the green channel DColorPalette:SetConVarB - For the blue channel DColorPalette:SetConVarA - For the alpha channel
DColorPalette:SetNumRows( number rows )
Roughly sets the number of colors that can be picked by the user. If the DColorPalette is exactly 6 rows tall, this function will set the number of colors shown per row in the palette. DColorPalette:Reset or DColorPalette:ResetSavedColors must be called after this function to apply changes.
DColorPalette:UpdateConVar( string name, string key, table clr )
This is used internally - although you're able to use it you probably shouldn't. Internal helper function for DColorPalette:UpdateConVars.
DColorPalette:UpdateConVars( table clr )
This is used internally - although you're able to use it you probably shouldn't. Updates all the console variables set by DColorPalette:SetConVarR and so on with given color. Called internally when a palette color is clicked.

Example

Creates a DColorPalette in a DFrame, clicking on a color will change the DColorButton's color to the selected color

local Frame = vgui.Create( "DFrame" ) Frame:SetSize( 170, 200 ) Frame:Center() Frame:MakePopup() local DColorPalette = vgui.Create( "DColorPalette", Frame ) DColorPalette:SetPos( 5, 50 ) DColorPalette:SetSize( 160, 50 ) local DColorButton = vgui.Create( "DColorButton", Frame ) DColorButton:SetSize( 50, 50 ) DColorButton:SetPos( 60, 100 ) -- This function is assigned AFTER DColorButton is created so we can use the DColorButton DColorPalette.OnValueChanged = function( s, value ) DColorButton:SetColor( value ) end

Page Links


Special Pages


Wikis

?

Render Time: 89ms

DB GetPage 10
Generate Html 10
SaveChanges (1) 56
Render Body 0
Render Sidebar 11