After hard work, I have managed to write a working "widget canvas" for GTK-3.0. The user is able to move native GtkWidget
s by dragging them around, pretty much like MDI.
However, moving a widget is slow. As soon as the number of widget increases, I get frametimes whell above 20 ms. After benchmarking, I have found that gtk_container_propagate_draw
is a huge bottleneck:
ui/widget_canvas_internal.cpp:operator():73 29046505 ns
ui/line_segment_renderer.cpp:draw_callback:56 33100 ns
operator()
basically calls gtk_container_propagate_draw
on each child widget. The widgets mainly contains GtkLabel
s and GtkSlider
s.
For reference, here is a link to the project:
https://github.com/milasudril/texpainter
The widget canvas is found here
- https://github.com/milasudril/texpainter/blob/master/ui/widget_canvas.hpp
- https://github.com/milasudril/texpainter/blob/master/ui/widget_canvas.cpp
- https://github.com/milasudril/texpainter/blob/master/ui/widget_canvas_internal.hpp
- https://github.com/milasudril/texpainter/blob/master/ui/widget_canvas_internal.cpp
The purpose of the widget canvas is to implement a "Node editor", similar to what you find in Blender. Here is a screenshot:
The connections are drawn on top of the other widgets. The widget canvas is much like a GtkLayout, with support for multiple "layers".
Question:
Should I try to replace GTK-3.0 with something else, and if so, what? I think it is a good idea to know how good the library is at handling user movable widgets, so porting the UI part would be worth the effort. Target platform is currently GNU/Linux desktop.