diff --git a/frontend/gtkmm/NotebookWindow.cc b/frontend/gtkmm/NotebookWindow.cc index 858be56564..ae75f51a25 100644 --- a/frontend/gtkmm/NotebookWindow.cc +++ b/frontend/gtkmm/NotebookWindow.cc @@ -908,6 +908,7 @@ void NotebookWindow::resize_codeinput_texview_all(int width) // have a maximum width equal to the window width (minus scrollbar), // except when they contain Python code (which does not word-wrap). auto it=doc.begin(); + std::cerr << "----" << std::endl; while(it!=doc.end()) { resize_codeinput_texview(it, width); ++it; @@ -937,11 +938,20 @@ void NotebookWindow::resize_codeinput_texview(DTree::iterator it, int width) auto fnd = canvasses[i]->visualcells.find(&(*it)); if(fnd != canvasses[i]->visualcells.end()) { TeXView *tex_view = fnd->second.outbox; - Gtk::Allocation allocation = tex_view->get_allocation(); - allocation.set_width(width - 20); - tex_view->size_allocate(allocation); tex_view->window_width = width; + + Gtk::Allocation allocation = tex_view->image.get_allocation(); + allocation.set_width(width - 20); + int need_height = tex_view->image.need_height(width - 20); + std::cerr << "Need height " << need_height << std::endl; + allocation.set_height(need_height+100); + tex_view->image.size_allocate(allocation); + tex_view->queue_draw(); + Glib::signal_timeout().connect_once([tex_view]() + { + tex_view->queue_resize(); + }, 50); } } } @@ -1949,6 +1959,7 @@ bool NotebookWindow::cell_content_execute(DTree::iterator it, int canvas_number, else { (*vis).second.inbox->edit.hide(); it->hidden=true; +// resize_codeinput_texview(it, last_configure_width); } } } diff --git a/frontend/gtkmm/TeXView.cc b/frontend/gtkmm/TeXView.cc index d0225692f2..f12fa1af54 100644 --- a/frontend/gtkmm/TeXView.cc +++ b/frontend/gtkmm/TeXView.cc @@ -123,6 +123,13 @@ void TeXView::TeXArea::get_preferred_height_for_width_vfunc(int width, } } +int TeXView::TeXArea::need_height(int width) const + { + int h1, h2; + get_preferred_height_for_width_vfunc(width, h1, h2); + return h1; + } + void TeXView::TeXArea::get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const { diff --git a/frontend/gtkmm/TeXView.hh b/frontend/gtkmm/TeXView.hh index 9d7dba7636..2f8078efb3 100644 --- a/frontend/gtkmm/TeXView.hh +++ b/frontend/gtkmm/TeXView.hh @@ -75,6 +75,7 @@ namespace cadabra { bool use_microtex; + int need_height(int width) const; protected: Gtk::SizeRequestMode get_request_mode_vfunc() const override; void get_preferred_height_for_width_vfunc(int width, int& minimum_height,