Advertisement
Slawer

DComboBox Painting

Jul 10th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. local PANEL = {}
  2.  
  3. function PANEL:Init()
  4.     self:SetTextColor(color_white)
  5.     self:SetSortItems(false)
  6. end
  7.  
  8. function PANEL:Paint(intW, intH)
  9.     surface.SetDrawColor(ADDON.Colors.Primary)
  10.     surface.DrawRect(0, 0, intW, intH)
  11.  
  12.     surface.SetDrawColor(ADDON.Colors.Outline)
  13.     surface.DrawOutlinedRect(0, 0, intW, intH)
  14. end
  15.  
  16. function PANEL:DoClick()
  17.     if self:IsMenuOpen() then
  18.         return self:CloseMenu()
  19.     end
  20.  
  21.     self:OpenMenu()
  22.    
  23.     for k, v in pairs(self.Menu:GetCanvas():GetChildren()) do
  24.         v:SetTextColor(color_white)
  25.         v:SetFont("ADDON:R15")
  26.         function v:Paint(w, h)
  27.             surface.SetDrawColor(ADDON.Colors.Outline)
  28.             surface.DrawOutlinedRect(0, -1, w, h + 1)
  29.  
  30.             if self:IsHovered() then
  31.                 surface.SetDrawColor(ADDON.Colors.Blue)
  32.                 surface.DrawRect(1, 1, w - 2, h - 2)
  33.             end
  34.         end
  35.     end
  36.  
  37.     function self.Menu:Paint(intW, intH)
  38.         surface.SetDrawColor(ADDON.Colors.Primary)
  39.         surface.DrawRect(0, 0, intW, intH)
  40.        
  41.         surface.SetDrawColor(ADDON.Colors.Outline)
  42.         surface.DrawRect(0, 0, intW, 1)
  43.     end
  44. end
  45.  
  46. vgui.Register("ADDON:DComboBox", PANEL, "DComboBox")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement