gui: improved canvas initial scroll to center

This commit is contained in:
Nedko Arnaudov 2009-10-05 00:45:28 +03:00
parent 1524ae1802
commit 19b0d68752
2 changed files with 24 additions and 4 deletions

View File

@ -48,11 +48,24 @@ public:
virtual ~canvas_cls() {}
#if 0
virtual void on_realize()
{
//log_debug("canvas_cls::on_realize");
log_info("canvas_cls::on_realize");
FlowCanvas::Canvas::on_realize();
scroll_to_center();
//scroll_to_center();
}
#endif
virtual void on_size_allocate(Gtk::Allocation& allocation)
{
//log_info("canvas_cls::on_size_allocate");
FlowCanvas::Canvas::on_size_allocate(allocation);
if (is_realized())
{
//log_info("... realized");
scroll_to_center();
}
}
virtual void connect(boost::shared_ptr<FlowCanvas::Connectable> port1, boost::shared_ptr<FlowCanvas::Connectable> port2);
@ -187,7 +200,15 @@ void
canvas_scroll_to_center(
canvas_handle canvas)
{
canvas_ptr->get()->scroll_to_center();
if (canvas_ptr->get()->is_realized())
{
//log_info("realized");
canvas_ptr->get()->scroll_to_center();
}
else
{
//log_info("NOT realized");
}
}
void

View File

@ -140,7 +140,6 @@ static void attach_canvas(struct graph_view * view_ptr)
g_current_view = view_ptr;
gtk_container_add(GTK_CONTAINER(g_main_scrolledwin), view_ptr->canvas_widget);
//_canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320), static_cast<int>(_canvas->height()/2 - 240)); // FIXME: hardcoded
//_main_scrolledwin->property_hadjustment().get_value()->set_step_increment(10);
//_main_scrolledwin->property_vadjustment().get_value()->set_step_increment(10);
}