Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function BU3.UI.Elements.CreateTextEntry(ghostText, parent, shouldMakeSmaller, hasCloseButton)
- local p = vgui.Create("DTextEntry", parent)
- p:SetPaintBackground(false)
- p:SetUpdateOnType(true)
- p.lerpValue = 0
- p.Paint = function(s, w, h)
- if not shouldMakeSmaller then
- s.lerpValue = 1
- end
- local lerpPixelValue = (1 - s.lerpValue) * 125
- draw.RoundedBox(4,lerpPixelValue,0,w - lerpPixelValue,h,Color(40,40,45,255))
- --Draw ghost text
- if s:GetText() == "" and not s:IsEditing() then
- draw.SimpleText(ghostText, BU3.UI.Fonts["small_bold"], lerpPixelValue + 5, (h/2) - 2 , Color(149, 152, 154), 0, 1)
- end
- s:DrawTextEntryText(Color(149, 152, 154), Color(255, 152, 154), Color(255, 255, 255))
- if s:IsHovered() or s:IsEditing() or s:GetText() ~= "" then
- s.lerpValue = Lerp(15 * FrameTime(), s.lerpValue, 1)
- else
- s.lerpValue = Lerp(15 * FrameTime(), s.lerpValue, 0)
- end
- end
- function p:PerformLayout()
- end
- function p:PerformLayout(width, height)
- if hasCloseButton then
- self.b:SetPos(width - height, 0)
- self.b:SetSize(height, height)
- end
- self:SetFontInternal(BU3.UI.Fonts["small_bold"])
- end
- if hasCloseButton then
- --Now create the clear button
- local b = vgui.Create("DButton", p)
- b:SetText("")
- b.DoClick = function() p:SetText("") end
- b.Paint = function(s , w , h)
- surface.SetDrawColor(Color(149,152,154, 255 * p.lerpValue))
- surface.SetMaterial(BU3.UI.Materials.iconClose)
- surface.DrawTexturedRect(7,7,w - 14,h - 14)
- end
- p.b = b
- end
- return p
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement