So far I got this:
[lua]local Line = PANEL.AppList:GetLine(1)
function Line:Paint(w, h)
surface.SetDrawColor(Color(255, 50, 50))
local x, y = self:GetPos()
surface.DrawRect(x - 1, y, w, h)
end[/lua]
And it sort of works
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=159225223[/url]
But when I click on the column names, and the items get rearranged, all background disappears from the line.
[url]http://steamcommunity.com/sharedfiles/filedetails/?id=159225473[/url]
Tips?
I would use the base function for DListView_Line paint. You can find it [URL=https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dlistview_line.lua]here[/URL] at line 33. Unfortunately, the line is painted with a derma_hook, or a derma skin, so you will have to look into how the default derma skin paints the line.
The line is complicated, obviously. There is the selected color, the deselected color, the regular color, and the every-other color. I would just copy the current derma skin and modify the colors there.
You could also try Line:SetColor() but I assume you already did that and it probably didn't work.
[QUOTE=bobbleheadbob;41408134]I would use the base function for DListView_Line paint. You can find it [URL=https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/vgui/dlistview_line.lua]here[/URL] at line 33. Unfortunately, the line is painted with a derma_hook, or a derma skin, so you will have to look into how the default derma skin paints the line.
The line is complicated, obviously. There is the selected color, the deselected color, the regular color, and the every-other color. I would just copy the current derma skin and modify the colors there.
You could also try Line:SetColor() but I assume you already did that and it probably didn't work.[/QUOTE]
I didn't do SetColor because I knew from the beginning it wouldn't have worked.
And yes, I plan was already planning on having the selcted colors and stuff. Did it various time for other components.
Will look into it
Eh.. I'm just gonna try to code my own DListView.
It might be BUMP but anyway...
if you want to color all lines then its something like this:
[CODE]
for k,v in pairs(player.GetAll()) do
DListView:AddLine( ) --what ever you want to add
DListView:GetLine(k).Paint = function()
-- what you want to paint EXAMPLE:
-- draw.RoundedBox(0,0,0, DListView:GetWide(), DListView:GetTall(), Color(249,105,14,255)) -- this will make every line Orange.
end
end
[/CODE]
If you still need it or not I decided to put it here so maybe someone in near future could be looking for this :)
I realize this is a bump as well, but this might be helpful for anyone working with the DListView.
[QUOTE=xeon365;44982674]It might be BUMP but anyway...
if you want to color all lines then its something like this:
--code--
If you still need it or not I decided to put it here so maybe someone in near future could be looking for this :)[/QUOTE]
PANEL:Paint( [B]w[/B], [B]h[/B] ) automatically gives you the width and height parameters. You don't need to use :GetWide() and :GetTall().
If you want to override the paint hooks of an already existing DListView panel, you can also do something along these lines:
[CODE]
for _, line in pairs( YourDListView:GetLines() ) do
function line:Paint( w, h )
if ( self:IsHovered() ) then
-- draw it highlighted
elseif ( self:IsSelected() ) then
-- draw it selected
elseif ( self:GetAltLine() ) then
-- draw it lighter or darker
else
-- draw it normally
end
end
-- if you want to change the text font/color of the columns
for _, column in pairs( line["Columns"] ) do
column:SetFont( "YourFont" )
column:SetTextColor( YourColor )
end
end
[/CODE]
You can also color the column tabs at the top:
[CODE]
for _, v in pairs( YourDListView[ "Tabs" ] ) do
function v.Header:Paint( w, h )
-- paint it how you want
end
v.Header:SetFont( "YourFont" )
v.Header:SetTextColor( YourColor )
end
[/CODE]
Finally, you can also change the look of the vertical scroll bar so it fits your theme:
[CODE]
function YourDListView.VBar:Paint( w, h )
-- paints the track area behind the grip and the buttons
end
function YourDListView.VBar.btnUp:Paint( w, h )
-- paints the top button that lets you scroll up
end
function YourDListView.VBar.btnDown:Paint( w, h )
-- paints the bottom button that lets you scroll down
end
function YourDListView.VBar.btnGrip:Paint( w, h )
-- paints the portion of the scrollbar that you can grab
end
[/CODE]
With those functions overwritten, you can produce something like:
[IMG]http://build.ijwtb.net/images/commands.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.