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 methods, etc not listed on this page from DIconLayout.
Implements
Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.
Events
DColorPalette:OnValueChanged( table newcol )
Called when the color is changed after clicking a new value. For Override
Methods
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!
For Override
number DColorPalette:GetButtonSize()
An AccessorFunc that returns the size of each palette button. Set by DColorPalette:SetButtonSize.
string DColorPalette:GetConVarA()
An AccessorFunc that 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()
An AccessorFunc that 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()
An AccessorFunc that 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()
An AccessorFunc that 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()
An AccessorFunc that 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. For Override
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.
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.
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 )
An AccessorFunc that 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 )
An AccessorFunc that 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 )
An AccessorFunc that 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 )
An AccessorFunc that 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. This is an AccessorFunc
DColorPalette:Reset or DColorPalette:ResetSavedColors must be called after this function to apply changes.
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
Preview from the derma_controls
concmd