DNumberScratch-how to paint?

I have a DFrame that is fully black that needs to have a DNumberScratch on it. I need the color of the panel to remain fully black, so I need the DNumberScratch to be as white (or as distinguishable from the black) as possible. So far I’ve made the number on the right of it fully white by doing



Slider.TextArea:SetTextColor(Color(255,255,255,255))


But how would I make the actual slider and all it’s notches white without remaking all of it’s code?

Remake this control !

I think the function is vgui.Register but i’m not sure search that on gmod WIKI.
Actualy what you want can be long depending on what exactly you want to repaint. If you want to repaint th controls inside this control itself, then it will be a bit longer.

That’s what I done to the GMod DFrame.

I literally just said in my first post that I didn’t want to remake all it’s code. Besides, why would I bother doing that when I could just do something like



Slider.Paint = function()


To simply isolate the part I actually want to change? By the way, why did you remake the DFrame? There’s nothing really that wrong with it, although the shrinking and opening buttons next to the close button are a bit annoying in that they don’t do anything, but I’m sure it’d be extremely simple to attach the buttons to a function so they actually work.

Actualy you can choose DNumberScratch as a base in vgui.Register this allows you to remake only the Paint function.
You asked me why I remaked the DFrame well it’s simple : It’s Horrible at HELL !!! Not even any transparency, bad colors, bad looking, no icons, no open animations, only a vulgary gray thing…

Ah. I just looked at the DNumberScratch’s code and realized why Garry decided to not make coloring an option. In the notch painting function, the alpha channel gets modified depending on something to do with the size of self.GetZoom(), so if he included an option to modify the color of the notches, the alpha channel would be all dodgy, as Color() has four values- one for the alpha.

Then correct his problem. I’m sure there’s a way to color only the view not the in change view.

You don’t need to use vgui.Register to edit the paint function of the panel. It depends where you’re using the panel. All you need to do is something like



local panel = vgui.Create( "DFrame")


Then do



panel.Paint = function( self, w, h )


Then you can make the panel.Paint function create a surface shape or an image or whatever you want. You don’t have to create a new vgui element for everything!

If you want to do transparency, you could do something like



local panel = vgui.Create( "DFrame")
panel.Paint = function( self, w, h )
      draw.RoundedBox( 0, 0, 0, w, h, Color( red, green, blue, alpha )) //Note this can be anything, such as a surface or draw element
end


With red, green, blue and alpha being replaced with actual color values. Note the alpha means the transparency.
Bad colors? Change the red, green and blue channels of the example above.
No icons? Just do



panel:SetIcon(path/to/icon.extension)


with the path being a material path and the extension being the file type. The icon will be displayed in the panel’s corner, although you could just parent a DImage to the panel and change it’s position if you didn’t want that. No open animation? True. I’ve never worked with panel animations before, but I’d probably use this to figure something out, or just mess around in the Paint() function until I got something good.

The DFrame is only grey for you to color! You don’t have to remake the entire thing, but I’d like to see what you came up with.

[editline]26th May 2015[/editline]

You’d have to add a couple more variables into the paint() function of the notches, one for the red, one for the green and one for the blue, although this would be pretty dodgy, so I see why Garry didn’t do it. He’s not evil, he’s just good at thinking of quick solutions to create panels, even though his ideas could be further refined it’s better than nothing (I’m utterly horrible at math, so thank god Garry could be bothered creating some odd code for the slider’s gaps).

Bump- I still need to know how to paint the notches- I tried overriding the entire notch-painting function and it still didn’t change anything.