Advertisement
CODE_BLUE

Untitled

May 2nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. function BU3.UI.Elements.CreateTextEntry(ghostText, parent, shouldMakeSmaller, hasCloseButton)
  2.  
  3. local p = vgui.Create("DTextEntry", parent)
  4. p:SetPaintBackground(false)
  5. p:SetUpdateOnType(true)
  6. p.lerpValue = 0
  7. p.Paint = function(s, w, h)
  8. if not shouldMakeSmaller then
  9. s.lerpValue = 1
  10. end
  11.  
  12. local lerpPixelValue = (1 - s.lerpValue) * 125
  13.  
  14. draw.RoundedBox(4,lerpPixelValue,0,w - lerpPixelValue,h,Color(40,40,45,255))
  15.  
  16. --Draw ghost text
  17. if s:GetText() == "" and not s:IsEditing() then
  18. draw.SimpleText(ghostText, BU3.UI.Fonts["small_bold"], lerpPixelValue + 5, (h/2) - 2 , Color(149, 152, 154), 0, 1)
  19. end
  20.  
  21. s:DrawTextEntryText(Color(149, 152, 154), Color(255, 152, 154), Color(255, 255, 255))
  22.  
  23. if s:IsHovered() or s:IsEditing() or s:GetText() ~= "" then
  24. s.lerpValue = Lerp(15 * FrameTime(), s.lerpValue, 1)
  25. else
  26. s.lerpValue = Lerp(15 * FrameTime(), s.lerpValue, 0)
  27. end
  28.  
  29. end
  30.  
  31. function p:PerformLayout()
  32.  
  33. end
  34.  
  35. function p:PerformLayout(width, height)
  36. if hasCloseButton then
  37. self.b:SetPos(width - height, 0)
  38. self.b:SetSize(height, height)
  39. end
  40. self:SetFontInternal(BU3.UI.Fonts["small_bold"])
  41. end
  42.  
  43. if hasCloseButton then
  44.  
  45. --Now create the clear button
  46. local b = vgui.Create("DButton", p)
  47. b:SetText("")
  48. b.DoClick = function() p:SetText("") end
  49. b.Paint = function(s , w , h)
  50. surface.SetDrawColor(Color(149,152,154, 255 * p.lerpValue))
  51. surface.SetMaterial(BU3.UI.Materials.iconClose)
  52. surface.DrawTexturedRect(7,7,w - 14,h - 14)
  53. end
  54.  
  55. p.b = b
  56.  
  57. end
  58.  
  59. return p
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement