Right-aligned rendering with GtkTreeView in GtkScrolledWindow in GtkPaned

I am using gtkmm 3.22.2, gtk 3.22.19-4 (latest gtk3 provided by vcpkg)

I currently have a GtkTreeView with 1 visible column using a custom GtkCellRenderer. The GtkTreeView is in a GtkScrolledWindow which is in a GtkPaned. I want to add something else to be rendered and have it float on top of everything else like an overlay. Here’s the result I’m looking for using what I think is a bit of a messy solution.


This is implemented by giving the CellRenderer a reference to the GtkPaned and drawing based off the position property of the GtkPaned. There is also a callback to the changed signal of the position property (paned.property_position().signal_changed().connect()) which calls queue_draw() on the GtkTreeView since shrinking the GtkPaned wont redraw at all if shrunk too small. The queue_draw() seems pretty inefficient but I suspect that can maybe be optimized by calling queue_draw_area() with a small strip over where the red placeholder would appear.

I can get by with this solution but I don’t like that the CellRenderer needs to know about the GtkPaned and that attaching to the GtkPaned’s position changed callback is necessary to get it to draw when it has to. Also if I ever wanted to use the same renderer somewhere else where a GtkPaned wasn’t in the picture then I would need to have two versions of the render function. Is there a better way to get the result I’m looking for?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.