Hi,
I started a previous thread on how to achieve a node based interface for visual programming here.
My goal is to have a scrollable and zoomable area where the nodes (that are actually a derived Gtk::Grid
widget) are displayed.
I was advised to use the Gtk::Layout
class which have the following documentation :
Infinite scrollable area containing child widgets and/or custom drawing.
This is exactly what I want so I am also using the Gtk::ScrolledWindow
class where I can have scrollbars since the layout supports scrolling natively.
Now I am struggling to figure out how it works. I read on StackOverflow here the following (by @underscore-d) :
Gtk::Layout
can be placed into aGtk::ScrolledWindow
, and when the scrollable area is set to something larger than the visible allocation, scrollbars will show up.
However, this example doesn’t work, the scrollbars are not here :
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
Gtk::Window window;
Gtk::ScrolledWindow scrolled_window(Gtk::Adjustment::create(0, 0, 5000),
Gtk::Adjustment::create(0, 0, 5000));
// The layout scrolling area is 5 times lower than the scrolled window one
Gtk::Layout layout(Gtk::Adjustment::create(0, 0, 1000),
Gtk::Adjustment::create(0, 0, 1000));
Gtk::Button button("Hello World!");
layout.put(button, 100, 100);
scrolled_window.add(layout);
window.add(scrolled_window);
window.show_all();
return app->run(window);
}
Can someone tell me what is wrong here?