From cd6bb5fd23390c6d2dadbc38f90a706c2122238a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 17 Feb 2022 21:35:29 +0100 Subject: [PATCH] Fix numerous scrolling issues on DialogNotebook Remove double scrollbar from layers and objects dialog, symbols and Paint servers Set overlay Scrolling OFF on dialogs Hide non active notebooks to update scrool to visible widget Allow have wider tabs hidden bigger than current allocation size for the notebook fix https://gitlab.com/inkscape/inkscape/-/issues/659 --- src/ui/dialog/dialog-notebook.cpp | 43 +++++++++++++++++++++++++++++++ src/ui/dialog/objects.cpp | 6 +++++ src/ui/dialog/paint-servers.cpp | 6 +++++ src/ui/dialog/symbols.cpp | 7 ++++- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/ui/dialog/dialog-notebook.cpp b/src/ui/dialog/dialog-notebook.cpp index 733497630f..6dd516807c 100644 --- a/src/ui/dialog/dialog-notebook.cpp +++ b/src/ui/dialog/dialog-notebook.cpp @@ -55,6 +55,7 @@ DialogNotebook::DialogNotebook(DialogContainer *container) set_shadow_type(Gtk::SHADOW_NONE); set_vexpand(true); set_hexpand(true); + set_overlay_scrolling(false); // =========== Getting preferences ========== Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -238,6 +239,10 @@ void DialogNotebook::remove_highlight_header() style->remove_class("nb-highlight"); } +auto dialog_notebook_handle_unmap = [](Gtk::Widget *child) { + child->hide(); +}; + /** * Adds a widget as a new page with a tab. */ @@ -247,6 +252,16 @@ void DialogNotebook::add_page(Gtk::Widget &page, Gtk::Widget &tab, Glib::ustring page.set_vexpand(); int page_number = _notebook.append_page(page, tab); + auto container = dynamic_cast(&page); + if (container) { + std::vector widgets = container->get_children(); + if (widgets.size()) { + Gtk::Widget *child = widgets[0]; + if (child) { + child->signal_unmap().connect([=]() { dialog_notebook_handle_unmap(child);}); + } + } + } _notebook.set_tab_reorderable(page); _notebook.set_tab_detachable(page); _notebook.show_all(); @@ -764,6 +779,16 @@ void DialogNotebook::toggle_tab_labels_callback(bool show) void DialogNotebook::on_page_switch(Gtk::Widget *curr_page, guint page_number) { + auto container = dynamic_cast(curr_page); + if (container) { + std::vector widgets = container->get_children(); + if (widgets.size()) { + Gtk::Widget *child = widgets[0]; + if (child) { + child->show(); + } + } + } for (auto const &page : _notebook.get_children()) { if (_prev_alloc_width) { auto dialogbase = dynamic_cast(page); @@ -817,6 +842,14 @@ void DialogNotebook::on_page_switch(Gtk::Widget *curr_page, guint page_number) if (_prev_alloc_width && !_label_visible) { queue_allocate(); } + // fix a issue with subnotebook that make scrool move to subtab on show + auto swin = dynamic_cast(_notebook.get_parent()); + if (swin) { + const auto adjustment = swin->get_vadjustment(); + if (adjustment) { + adjustment->set_value(adjustment->get_lower()); + } + } } /** @@ -825,6 +858,16 @@ void DialogNotebook::on_page_switch(Gtk::Widget *curr_page, guint page_number) void DialogNotebook::change_page(size_t pagenum) { _notebook.set_current_page(pagenum); + auto container = dynamic_cast(_notebook.get_nth_page(pagenum)); + if (container) { + std::vector widgets = container->get_children(); + if (widgets.size()) { + Gtk::Widget *child = widgets[0]; + if (child) { + child->show(); + } + } + } } /** diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 9eee5a82ca..5c43fd52be 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -812,6 +812,12 @@ ObjectsPanel::ObjectsPanel() : _scroller.set_overlay_scrolling(false); _scroller.add(_tree); _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); + _scroller.signal_map().connect([=]() { + _scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER); + }); + _scroller.signal_unmap().connect([=]() { + _scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + }); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; Gtk::Requisition sreq_natural; diff --git a/src/ui/dialog/paint-servers.cpp b/src/ui/dialog/paint-servers.cpp index ed1c486187..a33f5e29e6 100644 --- a/src/ui/dialog/paint-servers.cpp +++ b/src/ui/dialog/paint-servers.cpp @@ -125,6 +125,12 @@ PaintServersDialog::PaintServersDialog() scroller->set_hexpand(); scroller->set_vexpand(); scroller->add(*icon_view); + scroller->signal_map().connect([=]() { + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER); + }); + scroller->signal_unmap().connect([=]() { + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + }); grid->attach(*scroller, 0, 2, 2, 1); // Events diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 7b67a69e5b..007e55e705 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -176,7 +176,12 @@ SymbolsDialog::SymbolsDialog(gchar const *prefsPath) scroller->add(*Gtk::manage(icon_view)); scroller->set_hexpand(); scroller->set_vexpand(); - + scroller->signal_map().connect([=]() { + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER); + }); + scroller->signal_unmap().connect([=]() { + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + }); overlay = new Gtk::Overlay(); overlay->set_hexpand(); overlay->set_vexpand(); -- GitLab