@@ -353,11 +353,84 @@ function Table:CreateFrame(config)
353353 if isHeaderRow and tableFrame .config .sorting and tableFrame .config .sorting .enabled then
354354 columnFrame :RegisterForClicks (" LeftButtonUp" , " RightButtonUp" )
355355 end
356- columnFrame .text :SetWordWrap (false )
357- columnFrame .text :SetJustifyH (columnTextAlign )
358- columnFrame .text :SetPoint (" TOPLEFT" , columnFrame , " TOPLEFT" , tableFrame .config .cells .padding , - tableFrame .config .cells .padding )
359- columnFrame .text :SetPoint (" BOTTOMRIGHT" , columnFrame , " BOTTOMRIGHT" , - tableFrame .config .cells .padding , tableFrame .config .cells .padding )
360- columnFrame .text :SetText (column .text )
356+ if column .icons then
357+ -- Icon cell: hide the FontString, show/create icon child frames
358+ columnFrame .text :Hide ()
359+ columnFrame .iconFrames = columnFrame .iconFrames or {}
360+
361+ for i , iconData in ipairs (column .icons ) do
362+ local iconFrame = columnFrame .iconFrames [i ]
363+ if not iconFrame then
364+ iconFrame = CreateFrame (" Frame" , nil , columnFrame )
365+ iconFrame .texture = iconFrame :CreateTexture (nil , " ARTWORK" )
366+ iconFrame .texture :SetPoint (" TOPLEFT" , iconFrame , " TOPLEFT" , 1 , - 1 )
367+ iconFrame .texture :SetPoint (" BOTTOMRIGHT" , iconFrame , " BOTTOMRIGHT" , - 1 , 1 )
368+ iconFrame .border = iconFrame :CreateTexture (nil , " BACKGROUND" )
369+ iconFrame .border :SetAllPoints ()
370+ iconFrame .overlay = iconFrame :CreateTexture (nil , " OVERLAY" )
371+ columnFrame .iconFrames [i ] = iconFrame
372+ end
373+
374+ local iconSize = iconData .size or 18
375+ iconFrame :SetSize (iconSize , iconSize )
376+ iconFrame .texture :SetTexture (iconData .iconFileID )
377+ if iconData .unscanned then
378+ iconFrame .texture :SetVertexColor (0.4 , 0.4 , 0.4 , 1 )
379+ else
380+ iconFrame .texture :SetVertexColor (1 , 1 , 1 , 1 )
381+ end
382+
383+ if iconData .borderColor then
384+ local bc = iconData .borderColor
385+ iconFrame .border :SetColorTexture (bc .r , bc .g , bc .b , 1 )
386+ iconFrame .border :Show ()
387+ else
388+ iconFrame .border :Hide ()
389+ end
390+
391+ iconFrame .overlay :SetSize (10 , 10 )
392+ iconFrame .overlay :ClearAllPoints ()
393+ iconFrame .overlay :SetPoint (" TOPLEFT" , iconFrame , " TOPLEFT" , - 2 , 2 )
394+ if iconData .overlayAtlas then
395+ iconFrame .overlay :SetAtlas (iconData .overlayAtlas )
396+ iconFrame .overlay :Show ()
397+ else
398+ iconFrame .overlay :Hide ()
399+ end
400+
401+ iconFrame :ClearAllPoints ()
402+ iconFrame :SetPoint (" LEFT" , columnFrame , " LEFT" ,
403+ tableFrame .config .cells .padding + (i - 1 ) * (iconSize + 2 ), 0 )
404+ if iconData .onEnter or iconData .onLeave then
405+ iconFrame :EnableMouse (true )
406+ iconFrame :SetScript (" OnEnter" , iconData .onEnter or nil )
407+ iconFrame :SetScript (" OnLeave" , iconData .onLeave or nil )
408+ iconFrame :SetScript (" OnMouseUp" , function () columnFrame :onClickHandler (columnFrame ) end )
409+ else
410+ iconFrame :EnableMouse (false )
411+ iconFrame :SetScript (" OnEnter" , nil )
412+ iconFrame :SetScript (" OnLeave" , nil )
413+ iconFrame :SetScript (" OnMouseUp" , nil )
414+ end
415+ iconFrame :Show ()
416+ end
417+
418+ -- Hide leftover icon frames from a previous wider render
419+ for i = # column .icons + 1 , # columnFrame .iconFrames do
420+ columnFrame .iconFrames [i ]:Hide ()
421+ end
422+ else
423+ -- Text cell: show the FontString, hide any icon child frames
424+ columnFrame .text :Show ()
425+ columnFrame .text :SetWordWrap (false )
426+ columnFrame .text :SetJustifyH (columnTextAlign )
427+ columnFrame .text :SetPoint (" TOPLEFT" , columnFrame , " TOPLEFT" , tableFrame .config .cells .padding , - tableFrame .config .cells .padding )
428+ columnFrame .text :SetPoint (" BOTTOMRIGHT" , columnFrame , " BOTTOMRIGHT" , - tableFrame .config .cells .padding , tableFrame .config .cells .padding )
429+ columnFrame .text :SetText (column .text )
430+ if columnFrame .iconFrames then
431+ for _ , f in ipairs (columnFrame .iconFrames ) do f :Hide () end
432+ end
433+ end
361434 columnFrame :Show ()
362435
363436 if column .backgroundColor then
0 commit comments