Hello!
How I can paint "DCheckBoxLabel" and "DNumSlider" which on screenshot?
https://files.facepunch.com/forum/upload/111131/13310548-0ba7-45f1-9c58-844eb5e016cc/FJIMG_20180627_213526.jpg
Hi Maximaler
You're going to have to explain what you are trying to do in more detail. Are you trying to replicate the effect shown in the screenshot?
Yes.
Painting the checkbox button is quite simple, you just have to paint an orange rectangle in the background and then paint something over it if the checkbox is checked. Here's a quick example:
TestFrame = vgui.Create("DFrame")
TestFrame:SetSize(500,200)
TestFrame:Center()
TestFrame:MakePopup()
TestFrame:SetTitle("PaintTest")
CB = vgui.Create("DCheckBoxLabel", TestFrame) -- DCheckBoxLabel contains a DLabel and a DCheckBox
CB:SetText("Example DCheckBoxLabel")
CB:SetPos(0, 100)
CB:CenterHorizontal()
CB:SetValue(false) -- Unchecked by default
function CB.Button:Paint(w, h) -- Overwrite the paint function on the button
surface.SetDrawColor(255, 150, 50, 255) -- Set colour to orange
surface.DrawRect(0, 0, 15, 15) -- Draw orange background (x, y, width, height)
if self:GetChecked() then -- If checkbox is checked
surface.SetDrawColor(0, 0, 0, 255) -- Set colour to black
surface.DrawRect(3, 3, 9, 9) -- Draw black checkmark
end
end
A DNumSlider contains a DSlider, DTextEntry and DLabel. Painting the DSlider like in the screenshot it a little more complex. I haven't written derma interfaces for a while but I'll have a quick play around and see if I can make something work.
Thank u!
Sorry, you need to Log In to post a reply to this thread.