Implemented. This will be included in the next Objo Studio release: https://feedback.objo.dev/feature/1116
Because TreeView uses a node-based API, the new events are named PaintNodeBackground and PaintNodeText:
PaintNodeBackground draws across the complete visible row, including the indentation and expansion-chevron area.
PaintNodeText supplies the normal text origin. Returning True suppresses the default icon and text, allowing the handler to draw both itself. Returning False keeps the standard TreeView rendering and discards any custom drawing commands from that event.
Both events provide the actual TreeViewNode, along with its selected and hovering states. g.Width and g.Height describe the available drawing area.
TreeView also now has a RowHeight property:
Tree.RowHeight = 42
It defaults to 32 logical points and can be changed at runtime. It is also available in Studio’s visual designer and is included in generated source and layout serialization.
Here is a small custom-painting example:
# In the TreeView's PaintNodeBackground event
If selected Then
g.DrawingColour = ThemeColours.SelectionBackground
ElseIf hovering Then
g.DrawingColour = ThemeColours.Accent
g.Opacity = 0.16
Else
Return False
End If
g.FillRectangle(0, 0, g.Width, g.Height)
Return True
# In the TreeView's PaintNodeText event
Pragma Unused hovering
Pragma Unused y
If selected Then
g.DrawingColour = ThemeColours.SelectionText
Else
g.DrawingColour = ThemeColours.Accent
End If
g.Bold = True
Var textY As Double = (g.Height - g.TextHeight(node.Text, g.Width)) / 2
g.DrawText(node.Text, x, textY)
Return True
If custom painting depends on application state unrelated to a node property, calling Tree.Refresh() repaints the visible nodes.
I also corrected the existing TreeViewNode.Icon support: assigned pictures are now displayed beside the node text and retained correctly for as long as the node uses them.
The bundled TreeView example has been expanded into a full demonstration of:
- Adjustable row heights
- Custom background and text painting
- Selected and hovering states
- SVG node icons
- Inline editing
- Drag reordering
- Switching between custom and default painting
Thanks for the suggestion!