Permalink
Browse files

Updated color mixer panels

  • Loading branch information...
1 parent afbbff5 commit 0323111bc452e6afdb5842f7ebf5f14c5f94c1fd @robotboy655 robotboy655 committed Jun 7, 2016
@@ -1,20 +1,8 @@
---[[
- _
- ( )
- _| | __ _ __ ___ ___ _ _
- /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
-( (_| |( ___/| | | ( ) ( ) |( (_| |
-`\__,_)`\____)(_) (_) (_) (_)`\__,_)
- DAlphaBar
---]]
-
-local AccessorFunc = AccessorFunc
+local PANEL = {}
local matGradient = Material( "vgui/gradient-u" )
-local matGrid = Material( "vgui/bg-lines" )
-
-local PANEL = {}
+local matGrid = Material( "gui/alpha_grid.png", "nocull" )
AccessorFunc( PANEL, "m_Value", "Value" )
AccessorFunc( PANEL, "m_BarColor", "BarColor" )
@@ -23,7 +11,7 @@ AccessorFunc( PANEL, "m_BarColor", "BarColor" )
Name: Init
-----------------------------------------------------------]]
function PANEL:Init()
-
+
self:SetBarColor( Color( 255, 255, 255, 255 ) )
self:SetSize( 26, 26 )
self:SetValue( 1 )
@@ -34,46 +22,42 @@ end
Name: OnCursorMoved
-----------------------------------------------------------]]
function PANEL:OnCursorMoved( x, y )
-
+
if ( !input.IsMouseDown( MOUSE_LEFT ) ) then return end
-
+
local fHeight = y / self:GetTall()
-
+
fHeight = 1 - math.Clamp( fHeight, 0, 1 )
-
+
self:SetValue( fHeight )
self:OnChange( fHeight )
-
-end
+end
--[[---------------------------------------------------------
Name: OnMousePressed
-----------------------------------------------------------]]
function PANEL:OnMousePressed( mcode )
self:MouseCapture( true )
- self:OnCursorMoved( self:CursorPos() );
-
-end
+ self:OnCursorMoved( self:CursorPos() )
+end
--[[---------------------------------------------------------
Name: OnMouseReleased
-----------------------------------------------------------]]
function PANEL:OnMouseReleased( mcode )
self:MouseCapture( false )
- self:OnCursorMoved( self:CursorPos() );
+ self:OnCursorMoved( self:CursorPos() )
end
-
--[[---------------------------------------------------------
Name: OnChange
-----------------------------------------------------------]]
function PANEL:OnChange( fAlpha )
-
end
--[[---------------------------------------------------------
@@ -84,11 +68,11 @@ function PANEL:Paint( w, h )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( matGrid )
local size = 128
- local x, y = w / 2 - size / 2, h / 2 - size / 2
+ local x, y = w / 2 - size / 2, h / 2 - size / 2
surface.DrawTexturedRect( x, y , size, size )
surface.DrawTexturedRect( x, y - size, size, size )
surface.DrawTexturedRect( x, y + size, size, size )
-
+
surface.SetDrawColor( self.m_BarColor )
surface.SetMaterial( matGradient )
surface.DrawTexturedRect( 0, 0, w, h )
@@ -97,10 +81,10 @@ function PANEL:Paint( w, h )
surface.SetDrawColor( 0, 0, 0, 250 )
self:DrawOutlinedRect()
surface.DrawRect( 0, ( 1-self.m_Value ) * h - 2, w, 3 )
-
+
surface.SetDrawColor( 255, 255, 255, 250 )
surface.DrawRect( 0, ( 1-self.m_Value ) * h - 1, w, 1 )
end
-derma.DefineControl( "DAlphaBar", "", PANEL, "DPanel" )
+derma.DefineControl( "DAlphaBar", "", PANEL, "DPanel" )
@@ -1,18 +1,8 @@
---[[
- _
- ( )
- _| | __ _ __ ___ ___ _ _
- /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
-( (_| |( ___/| | | ( ) ( ) |( (_| |
-`\__,_)`\____)(_) (_) (_) (_)`\__,_)
-
- DColorButton
---]]
-
-local matGrid = Material( "gui/bg-lines.png", "nocull" )
local PANEL = {}
+local matGrid = Material( "gui/alpha_grid.png", "nocull" )
+
AccessorFunc( PANEL, "m_bBorder", "DrawBorder", FORCE_BOOL )
AccessorFunc( PANEL, "m_bDisabled", "Disabled", FORCE_BOOL )
AccessorFunc( PANEL, "m_bSelected", "Selected", FORCE_BOOL )
@@ -50,7 +40,7 @@ end
-----------------------------------------------------------]]
function PANEL:SetColor( color )
- local colorStr = "R: "..color.r.."\nG: "..color.g.."\nB: "..color.b.."\nA: "..color.a
+ local colorStr = "R: " .. color.r .. "\nG: " .. color.g .. "\nB: " .. color.b .. "\nA: " .. color.a
self:SetTooltip( colorStr )
self.m_Color = color
@@ -68,7 +58,7 @@ function PANEL:Paint( w, h )
surface.SetMaterial( matGrid )
local size = math.max( 128, math.max( w, h ) )
- local x, y = w / 2 - size / 2, h / 2 - size / 2
+ local x, y = w / 2 - size / 2, h / 2 - size / 2
surface.DrawTexturedRect( x, y , size, size )
end
@@ -88,7 +78,7 @@ end
-----------------------------------------------------------]]
function PANEL:SetDisabled( bDisabled )
- self.m_bDisabled = bDisabled
+ self.m_bDisabled = bDisabled
self:InvalidateLayout()
end
@@ -99,10 +89,11 @@ end
function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height )
local ctrl = vgui.Create( ClassName )
- ctrl:SetSize( 64, 64 )
+ ctrl:SetSize( 64, 64 )
+ ctrl:SetColor( Color( 255, 0, 0, 128 ) )
PropertySheet:AddSheet( ClassName, ctrl, nil, true, true )
end
-derma.DefineControl( "DColorButton", "A Color Button", PANEL, "DLabel" )
+derma.DefineControl( "DColorButton", "A Color Button", PANEL, "DLabel" )
@@ -1,14 +1,3 @@
---[[
- _
- ( )
- _| | __ _ __ ___ ___ _ _
- /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
-( (_| |( ___/| | | ( ) ( ) |( (_| |
-`\__,_)`\____)(_) (_) (_) (_)`\__,_)
-
- DColorMixer
---]]
-
local PANEL = {}
@@ -28,28 +17,28 @@ function PANEL:BuildControls()
-- Mixer
--
local ctrl = self:Add( "DColorMixer" )
- ctrl:Dock( FILL )
- ctrl:DockMargin( 8, 8, 8, 8 )
- ctrl:SetPalette( false )
- ctrl:SetAlphaBar( false )
- ctrl:SetWangs( false )
- --ctrl:SetNumRows( 35 )
- --ctrl:Reset()
- ctrl.ValueChanged = function( ctrl, color ) self.m_bEditing = true self:OnValueChanged( color ) self.m_bEditing = false end
- self.Mixer = ctrl;
+ ctrl:Dock( FILL )
+ ctrl:DockMargin( 8, 8, 8, 8 )
+ ctrl:SetPalette( false )
+ ctrl:SetAlphaBar( false )
+ ctrl:SetWangs( false )
+ --ctrl:SetNumRows( 35 )
+ --ctrl:Reset()
+ ctrl.ValueChanged = function( ctrl, color ) self.m_bEditing = true self:OnValueChanged( color ) self.m_bEditing = false end
+ self.Mixer = ctrl
self:AddSheet( "", ctrl, "icon16/color_wheel.png" )
--
-- Palettes
--
local ctrl = self:Add( "DColorPalette" )
- ctrl:Dock( FILL )
- ctrl:DockMargin( 8, 2, 8, 8 )
- ctrl:SetButtonSize( 16 )
- ctrl:SetNumRows( 35 )
- ctrl:Reset()
- ctrl.OnValueChanged = function( ctrl, color ) self.m_bEditing = true self:OnValueChanged( color ) self.m_bEditing = false end
- self.Palette = ctrl;
+ ctrl:Dock( FILL )
+ ctrl:DockMargin( 8, 2, 8, 8 )
+ ctrl:SetButtonSize( 16 )
+ ctrl:SetNumRows( 35 )
+ ctrl:Reset()
+ ctrl.OnValueChanged = function( ctrl, color ) self.m_bEditing = true self:OnValueChanged( color ) self.m_bEditing = false end
+ self.Palette = ctrl
self:AddSheet( "", ctrl, "icon16/palette.png" )
end
@@ -61,12 +50,9 @@ function PANEL:IsEditing()
end
function PANEL:PerformLayout()
-
end
-
function PANEL:OnValueChanged( newcol )
-
end
function PANEL:SetColor( newcol )
@@ -76,4 +62,4 @@ function PANEL:SetColor( newcol )
end
-derma.DefineControl( "DColorCombo", "", PANEL, "DPropertySheet" )
+derma.DefineControl( "DColorCombo", "", PANEL, "DPropertySheet" )
@@ -1,13 +1,3 @@
---[[
- _
- ( )
- _| | __ _ __ ___ ___ _ _
- /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
-( (_| |( ___/| | | ( ) ( ) |( (_| |
-`\__,_)`\____)(_) (_) (_) (_)`\__,_)
-
- DColorCube
---]]
local PANEL = {}
@@ -22,14 +12,14 @@ function PANEL:Init()
self:SetImage( "vgui/minixhair" )
self.Knob:NoClipping( false )
-
+
self.BGSaturation = vgui.Create( "DImage", self )
self.BGSaturation:SetImage( "vgui/gradient-r" )
-
+
self.BGValue = vgui.Create( "DImage", self )
self.BGValue:SetImage( "vgui/gradient-d" )
self.BGValue:SetImageColor( Color( 0, 0, 0, 255 ) )
-
+
self:SetBaseRGB( Color( 255, 0, 0 ) )
self:SetRGB( Color( 255, 0, 0 ) )
self:SetColor( Color( 255, 0, 0 ) )
@@ -45,10 +35,10 @@ end
function PANEL:PerformLayout()
DSlider.PerformLayout( self )
-
+
self.BGSaturation:StretchToParent( 0,0,0,0 )
self.BGSaturation:SetZPos( -9 )
-
+
self.BGValue:StretchToParent( 0,0,0,0 )
self.BGValue:SetZPos( -8 )
@@ -81,7 +71,7 @@ function PANEL:TranslateValues( x, y )
self:UpdateColor( x, y )
self:OnUserChanged( self.m_OutRGB )
-
+
return x, y
end
@@ -93,13 +83,13 @@ function PANEL:UpdateColor( x, y )
x = x or self:GetSlideX()
y = y or self:GetSlideY()
-
+
local value = 1 - y
local saturation = 1 - x
local h = ColorToHSV( self.m_BaseRGB )
-
+
local color = HSVToColor( h, saturation, value )
-
+
self:SetRGB( color )
end
@@ -119,9 +109,9 @@ end
function PANEL:SetColor( color )
local h, s, v = ColorToHSV( color )
-
+
self:SetBaseRGB( HSVToColor( h, 1, 1 ) )
-
+
self:SetSlideY( 1 - v )
self:SetSlideX( 1 - s )
self:UpdateColor()
@@ -217,7 +217,7 @@ end
function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height )
local ctrl = vgui.Create( ClassName )
- ctrl:SetSize( 256, 256 )
+ ctrl:SetSize( 160, 256 )
PropertySheet:AddSheet( ClassName, ctrl, nil, true, true )

0 comments on commit 0323111

Please sign in to comment.