From db45a011870c1ae1d9a776148c1213a6a54e5db9 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 5 Jan 2022 03:57:12 -0500 Subject: [PATCH 1/2] Using a Pane and scroll the toolbox flows horz The use of a scrolling window and Horz Pane allows the toolbox to be flowed better. --- share/ui/toolbar-tool.ui | 1083 ++++++++++++++++---------------- src/ui/uxmanager.cpp | 2 - src/widgets/desktop-widget.cpp | 13 +- src/widgets/desktop-widget.h | 1 + src/widgets/toolbox.cpp | 9 +- 5 files changed, 556 insertions(+), 552 deletions(-) diff --git a/share/ui/toolbar-tool.ui b/share/ui/toolbar-tool.ui index b5ab18822c..7c5fdd81ca 100644 --- a/share/ui/toolbar-tool.ui +++ b/share/ui/toolbar-tool.ui @@ -117,688 +117,697 @@ False tool-pages - - tool-toolbar + True - False - vertical - start - center + False + none + False + True + never - - True + + tool-toolbar True False - start - start vertical - 2 - + start + fill - + + True True - True + False + start + start + horizontal + 2 + - + True True - False - center - center - win.tool-switch - 'Select' - icon-select - none - + + + True + True + False + center + center + win.tool-switch + 'Select' + icon-select + none + + + - - - - - True - True - True - + True True - False - center - center - win.tool-switch - 'Node' - icon-node - none - + + + True + True + False + center + center + win.tool-switch + 'Node' + icon-node + none + + + + + False + False + 0 + - - - False - False - 0 - - - - - True - False - - - False - False - 1 - - - - - True - True - False - start - start - vertical - 5 - - + True - True + False + + + False + False + 1 + + + + + True + True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Rect' - icon-rect - none - + + + True + True + False + center + center + win.tool-switch + 'Rect' + icon-rect + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Arc' - icon-ellipse - none - + + + True + True + False + center + center + win.tool-switch + 'Arc' + icon-ellipse + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Star' - icon-star - none - + + + True + True + False + center + center + win.tool-switch + 'Star' + icon-star + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - '3DBox' - icon-threedee - none - + + + True + True + False + center + center + win.tool-switch + '3DBox' + icon-threedee + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Spiral' - icon-spiral - none - + + + True + True + False + center + center + win.tool-switch + 'Spiral' + icon-spiral + none + + + + + False + False + 2 + - - - False - False - 2 - - - - - True - False - - - False - False - 3 - - - - - True - True - False - start - start - vertical - 6 - - + True - True + False + + + False + False + 3 + + + + + True + True + False + start + start + horizontal + 6 + - + True True - False - center - center - win.tool-switch - 'Pen' - icon-pen - none - + + + True + True + False + center + center + win.tool-switch + 'Pen' + icon-pen + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Pencil' - icon-pencil - none - + + + True + True + False + center + center + win.tool-switch + 'Pencil' + icon-pencil + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Calligraphic' - icon-calligraphic - none - + + + True + True + False + center + center + win.tool-switch + 'Calligraphic' + icon-calligraphic + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Text' - image-text-tool - none - + + + True + True + False + center + center + win.tool-switch + 'Text' + image-text-tool + none + + + + + False + False + 4 + + + + + True + False + + + False + False + 5 + - - - False - False - 4 - - - - - True - False - - - False - False - 5 - - - - - True - True - False - start - start - vertical - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Gradient' - icon-gradient - none - + + + True + True + False + center + center + win.tool-switch + 'Gradient' + icon-gradient + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Mesh' - icon-mesh-gradient - none - + + + True + True + False + center + center + win.tool-switch + 'Mesh' + icon-mesh-gradient + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Dropper' - icon-dropper - none - + + + True + True + False + center + center + win.tool-switch + 'Dropper' + icon-dropper + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'PaintBucket' - icon-bucket - none - + + + True + True + False + center + center + win.tool-switch + 'PaintBucket' + icon-bucket + none + + + + + False + False + 6 + - - - False - False - 6 - - - - - True - False - - - False - False - 7 - - - - - True - True - False - start - start - vertical - 5 - - + True - True + False + + + False + False + 7 + + + + + True + True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Tweak' - icon-tweak - none - + + + True + True + False + center + center + win.tool-switch + 'Tweak' + icon-tweak + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Spray' - icon-spray - none - + + + True + True + False + center + center + win.tool-switch + 'Spray' + icon-spray + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Eraser' - icon-eraser - none - + + + True + True + False + center + center + win.tool-switch + 'Eraser' + icon-eraser + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Connector' - icon-connector - none - + + + True + True + False + center + center + win.tool-switch + 'Connector' + icon-connector + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'LPETool' - icon-geometry - none - + + + True + True + False + center + center + win.tool-switch + 'LPETool' + icon-geometry + none + + + + + False + False + 8 + + + + + True + False + + + False + False + 9 + - - - False - False - 8 - - - - - True - False - - - False - False - 9 - - - - - True - True - False - start - start - vertical - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Measure' - icon-measure - none - + + + True + True + False + center + center + win.tool-switch + 'Measure' + icon-measure + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Zoom' - icon-zoom - none - + + + True + True + False + center + center + win.tool-switch + 'Zoom' + icon-zoom + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Pages' - icon-pages - none - + + + True + True + False + center + center + win.tool-switch + 'Pages' + icon-pages + none + + + + + False + False + 10 + - - False - False - 10 - diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 58f0e11326..5a1efa077e 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -150,7 +150,6 @@ void UXManagerImpl::setTask(SPDesktop* dt, gint val) switch (val) { default: case 0: - dtw->setToolboxPosition("ToolToolbar", GTK_POS_LEFT); dtw->setToolboxPosition("CommandsToolbar", GTK_POS_TOP); if (notDone) { dtw->setToolboxPosition("AuxToolbar", GTK_POS_TOP); @@ -160,7 +159,6 @@ void UXManagerImpl::setTask(SPDesktop* dt, gint val) case 1: case 2: - dtw->setToolboxPosition("ToolToolbar", GTK_POS_LEFT); dtw->setToolboxPosition("CommandsToolbar", GTK_POS_RIGHT); if (notDone) { dtw->setToolboxPosition("AuxToolbar", GTK_POS_RIGHT); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index f27c552925..48dd62ddab 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -227,6 +227,11 @@ SPDesktopWidget::SPDesktopWidget() /* DesktopHBox (Vertical toolboxes, canvas) */ dtw->_hbox = Gtk::manage(new Gtk::Box()); dtw->_hbox->set_name("DesktopHbox"); + + dtw->_tbbox = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); + dtw->_tbbox->set_name("ToolboxCanvasPaned"); + dtw->_hbox->pack_start(*dtw->_tbbox, true, true); + dtw->_vbox->pack_end(*dtw->_hbox, true, true); dtw->_top_toolbars = Gtk::make_managed(); @@ -247,7 +252,7 @@ SPDesktopWidget::SPDesktopWidget() dtw->tool_toolbox = ToolboxFactory::createToolToolbox(); ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL ); - dtw->_hbox->pack_start(*Glib::wrap(dtw->tool_toolbox), false, true); + dtw->_tbbox->pack1(*Glib::wrap(dtw->tool_toolbox), false, true); auto set_visible_buttons = [=](GtkWidget* tb) { int buttons_before_separator = 0; @@ -329,7 +334,7 @@ SPDesktopWidget::SPDesktopWidget() _container = Gtk::manage(new DialogContainer()); _columns = _container->get_columns(); _columns->set_dropzone_sizes(2, -1); - dtw->_hbox->pack_start(*_container, false, true); + dtw->_tbbox->pack2(*_container, true, true); _canvas_grid->set_hexpand(true); _canvas_grid->set_vexpand(true); @@ -1231,9 +1236,7 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp { // Note - later on these won't be individual member variables. GtkWidget* toolbox = nullptr; - if (id == "ToolToolbar") { - toolbox = tool_toolbox; - } else if (id == "AuxToolbar") { + if (id == "AuxToolbar") { toolbox = aux_toolbox; } else if (id == "CommandsToolbar") { toolbox = commands_toolbox; diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index a177c67780..ff6bc76f29 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -109,6 +109,7 @@ private: // The root vbox of the window layout. Gtk::Box *_vbox; + Gtk::Paned *_tbbox; Gtk::Box *_hbox; Inkscape::UI::Dialog::DialogContainer *_container = nullptr; Inkscape::UI::Dialog::DialogMultipaned *_columns; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index a6b95862d7..9960360c62 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -174,11 +174,6 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType /*h GtkWidget *ToolboxFactory::createToolToolbox() { - auto tb = new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0); - tb->set_name("ToolToolbox"); - tb->set_homogeneous(false); - tb->set_hexpand(false); - Glib::ustring tool_toolbar_builder_file = get_filename(UIS, "toolbar-tool.ui"); auto builder = Gtk::Builder::create(); try @@ -194,11 +189,9 @@ GtkWidget *ToolboxFactory::createToolToolbox() builder->get_widget("tool-toolbar", toolbar); if (!toolbar) { std::cerr << "InkscapeWindow: Failed to load tool toolbar!" << std::endl; - } else { - tb->pack_start(*toolbar, false, false, 0); } - return toolboxNewCommon( GTK_WIDGET(tb->gobj()), BAR_TOOL, GTK_POS_LEFT ); + return toolboxNewCommon( GTK_WIDGET(toolbar->gobj()), BAR_TOOL, GTK_POS_LEFT ); } GtkWidget *ToolboxFactory::createAuxToolbox() -- GitLab From 514a94e1d66db1a34af1e0b3d0e7e4fab5be863f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 7 Jan 2022 23:35:38 +0100 Subject: [PATCH 2/2] Add multipaned to toolbox Based on Martin Owens code I add Multipaned to the Toolbox --- share/ui/style.css | 7 +- share/ui/toolbar-tool.ui | 1078 ++++++++++++++------------- src/inkscape-window.cpp | 47 ++ src/ui/dialog/dialog-multipaned.cpp | 31 +- src/ui/dialog/dialog-multipaned.h | 4 +- src/widgets/desktop-widget.cpp | 9 +- src/widgets/desktop-widget.h | 2 +- src/widgets/toolbox.cpp | 24 +- src/widgets/toolbox.h | 4 +- 9 files changed, 655 insertions(+), 551 deletions(-) diff --git a/share/ui/style.css b/share/ui/style.css index 460b71c002..2ffb07631a 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -411,7 +411,12 @@ SPCanvas { #CMS_Adjust { padding: 0; } - +.toolboxdragger{ + background-color:@theme_base_color; +} +.smalldragger{ + background-color:@borders; +} /* Keep palette scrollbar from generating warnings. */ #PreviewHolderScroller .vertical slider { min-height: 15px; diff --git a/share/ui/toolbar-tool.ui b/share/ui/toolbar-tool.ui index 7c5fdd81ca..fef571669b 100644 --- a/share/ui/toolbar-tool.ui +++ b/share/ui/toolbar-tool.ui @@ -121,691 +121,697 @@ True False none - False + True True never - - tool-toolbar + True False - vertical - start - fill - - True + + tool-toolbar True False + vertical start - start - horizontal - 2 - + fill - + + True True - True + False + start + start + horizontal + 2 + - + True True - False - center - center - win.tool-switch - 'Select' - icon-select - none - + + + True + True + False + center + center + win.tool-switch + 'Select' + icon-select + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Node' - icon-node - none - + + + True + True + False + center + center + win.tool-switch + 'Node' + icon-node + none + + + + + False + False + 0 + + + + + True + False + + + False + False + 1 + - - - False - False - 0 - - - - - True - False - - - False - False - 1 - - - - - True - True - False - start - start - horizontal - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Rect' - icon-rect - none - + + + True + True + False + center + center + win.tool-switch + 'Rect' + icon-rect + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Arc' - icon-ellipse - none - + + + True + True + False + center + center + win.tool-switch + 'Arc' + icon-ellipse + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Star' - icon-star - none - + + + True + True + False + center + center + win.tool-switch + 'Star' + icon-star + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - '3DBox' - icon-threedee - none - + + + True + True + False + center + center + win.tool-switch + '3DBox' + icon-threedee + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Spiral' - icon-spiral - none - + + + True + True + False + center + center + win.tool-switch + 'Spiral' + icon-spiral + none + + + + + False + False + 2 + + + + + True + False + + + False + False + 3 + - - - False - False - 2 - - - - - True - False - - - False - False - 3 - - - - - True - True - False - start - start - horizontal - 6 - - + + True True - True + False + start + start + horizontal + 6 + - + True True - False - center - center - win.tool-switch - 'Pen' - icon-pen - none - + + + True + True + False + center + center + win.tool-switch + 'Pen' + icon-pen + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Pencil' - icon-pencil - none - + + + True + True + False + center + center + win.tool-switch + 'Pencil' + icon-pencil + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Calligraphic' - icon-calligraphic - none - + + + True + True + False + center + center + win.tool-switch + 'Calligraphic' + icon-calligraphic + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Text' - image-text-tool - none - + + + True + True + False + center + center + win.tool-switch + 'Text' + image-text-tool + none + + + + + False + False + 4 + + + + + True + False + + + False + False + 5 + - - - False - False - 4 - - - - - True - False - - - False - False - 5 - - - - - True - True - False - start - start - horizontal - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Gradient' - icon-gradient - none - + + + True + True + False + center + center + win.tool-switch + 'Gradient' + icon-gradient + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Mesh' - icon-mesh-gradient - none - + + + True + True + False + center + center + win.tool-switch + 'Mesh' + icon-mesh-gradient + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Dropper' - icon-dropper - none - + + + True + True + False + center + center + win.tool-switch + 'Dropper' + icon-dropper + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'PaintBucket' - icon-bucket - none - + + + True + True + False + center + center + win.tool-switch + 'PaintBucket' + icon-bucket + none + + + + + False + False + 6 + + + + + True + False + + + False + False + 7 + - - - False - False - 6 - - - - - True - False - - - False - False - 7 - - - - - True - True - False - start - start - horizontal - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Tweak' - icon-tweak - none - + + + True + True + False + center + center + win.tool-switch + 'Tweak' + icon-tweak + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Spray' - icon-spray - none - + + + True + True + False + center + center + win.tool-switch + 'Spray' + icon-spray + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Eraser' - icon-eraser - none - + + + True + True + False + center + center + win.tool-switch + 'Eraser' + icon-eraser + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Connector' - icon-connector - none - + + + True + True + False + center + center + win.tool-switch + 'Connector' + icon-connector + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'LPETool' - icon-geometry - none - + + + True + True + False + center + center + win.tool-switch + 'LPETool' + icon-geometry + none + + + + + False + False + 8 + + + + + True + False + + + False + False + 9 + - - - False - False - 8 - - - - - True - False - - - False - False - 9 - - - - - True - True - False - start - start - horizontal - 5 - - + + True True - True + False + start + start + horizontal + 5 + - + True True - False - center - center - win.tool-switch - 'Measure' - icon-measure - none - + + + True + True + False + center + center + win.tool-switch + 'Measure' + icon-measure + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Zoom' - icon-zoom - none - + + + True + True + False + center + center + win.tool-switch + 'Zoom' + icon-zoom + none + + + - - - - - True - True - + True True - False - center - center - win.tool-switch - 'Pages' - icon-pages - none - + + + True + True + False + center + center + win.tool-switch + 'Pages' + icon-pages + none + + + + + False + False + 10 + - - False - False - 10 - diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp index 4b39edbaf6..970f15f003 100644 --- a/src/inkscape-window.cpp +++ b/src/inkscape-window.cpp @@ -50,6 +50,7 @@ #include "ui/desktop/menubar.h" #include "ui/desktop/menu-icon-shift.h" +#include "ui/dialog/dialog-multipaned.h" #include "ui/drag-and-drop.h" @@ -145,6 +146,52 @@ InkscapeWindow::InkscapeWindow(SPDocument* document) // Restore short-lived floating dialogs state if this is the first window being opened bool include_short_lived = _app->get_number_of_windows() == 0; DialogManager::singleton().restore_dialogs_state(_desktop->getContainer(), include_short_lived); + auto container = _desktop->getContainer(); + Inkscape::UI::Dialog::DialogMultipaned *columns = container->get_columns(); + std::vector columnswidgets = columns->get_children(); + gint pos = -1; + for (auto column : columnswidgets) { + pos += 1; + if (column->get_name() == ("canvas_grid")) { + /* Toolbox container */ + Gtk::Widget *widg = _desktop_widget->get_tool_toolbox(); + Inkscape::UI::Dialog::MyDropZone *dropzone_s = nullptr; + if (pos > 1) { + auto prev_multipaned = dynamic_cast(columnswidgets[pos-2]); + if (prev_multipaned) { + prev_multipaned[0].prepend(widg); + dropzone_s = dynamic_cast(prev_multipaned[0].get_children()[0]); + } + } else { + Inkscape::UI::Dialog::DialogMultipaned *new_column = container->create_column(); + new_column[0].add(*widg); + columns->prepend(new_column); + dropzone_s = dynamic_cast(new_column[0].get_children()[0]); + } + if (dropzone_s) { + dropzone_s->setPaused(true); + dropzone_s->set_size_request(0,0); + dropzone_s->set_sensitive(false); + } + std::vector columnswidgets2 = columns->get_children(); + auto *dragger = dynamic_cast(columnswidgets2[pos+1]); + if (dragger) { + dragger->get_children()[0]->hide(); + dragger->set_size_request(2, -1); + dragger->get_style_context()->add_class("toolboxdragger"); + dragger->get_style_context()->add_class("smalldragger"); + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gint widthtoolbox = prefs->getInt("/toolbox/width", 0); + if (widthtoolbox) { + auto eventbox = dynamic_cast(widg); + if (eventbox) { + eventbox->get_child()->set_size_request(widthtoolbox + 1,-1); + } + } + break; + } + } // This pokes the window to request the right size for the dialogs once loaded. g_idle_add(GSourceFunc(&_resize_children), this); diff --git a/src/ui/dialog/dialog-multipaned.cpp b/src/ui/dialog/dialog-multipaned.cpp index 784574eb2b..bcfd828b08 100644 --- a/src/ui/dialog/dialog-multipaned.cpp +++ b/src/ui/dialog/dialog-multipaned.cpp @@ -71,7 +71,7 @@ MyDropZone::MyDropZone(Gtk::Orientation orientation) get_style_context()->add_class("backgnd-passive"); signal_drag_motion().connect([=](const Glib::RefPtr& ctx, int x, int y, guint time) { - if (!_active) { + if (!_active && !_paused) { _active = true; add_highlight(); set_size(DROPZONE_SIZE + DROPZONE_EXPANSION); @@ -80,7 +80,7 @@ MyDropZone::MyDropZone(Gtk::Orientation orientation) }); signal_drag_leave().connect([=](const Glib::RefPtr&, guint time) { - if (_active) { + if (_active && !_paused) { _active = false; set_size(DROPZONE_SIZE); } @@ -97,7 +97,10 @@ MyDropZone::~MyDropZone() void MyDropZone::add_highlight_instances() { for (auto *instance : _instances_list) { - instance->add_highlight(); + if (!instance->_paused) { + instance->add_highlight(); + instance->set_size(DROPZONE_SIZE); + } } } @@ -105,7 +108,7 @@ void MyDropZone::remove_highlight_instances() { for (auto *instance : _instances_list) { instance->remove_highlight(); - // instance->set_size(DROPZONE_SIZE); + instance->set_size(0); } } @@ -140,6 +143,7 @@ MyHandle::MyHandle(Gtk::Orientation orientation, int size = get_handle_size()) , Gtk::EventBox() , _cross_size(0) , _child(nullptr) + , _size(size) { set_name("MultipanedHandle"); set_orientation(orientation); @@ -223,6 +227,11 @@ bool MyHandle::on_enter_notify_event(GdkEventCrossing *crossing_event) if (get_orientation() == Gtk::ORIENTATION_HORIZONTAL) { auto cursor = Gdk::Cursor::create(display, "col-resize"); window->set_cursor(cursor); + if (get_style_context()->has_class("toolboxdragger")) { + set_size_request(_size, -1); + get_children()[0]->show(); + get_style_context()->remove_class("smalldragger"); + } } else { auto cursor = Gdk::Cursor::create(display, "row-resize"); window->set_cursor(cursor); @@ -235,6 +244,11 @@ bool MyHandle::on_enter_notify_event(GdkEventCrossing *crossing_event) bool MyHandle::on_leave_notify_event(GdkEventCrossing* crossing_event) { show_click_indicator(false); + if (!_dragging && get_style_context()->has_class("toolboxdragger")) { + set_size_request(2, -1); + get_children()[0]->hide(); + get_style_context()->add_class("smalldragger"); + } return false; } @@ -1143,7 +1157,7 @@ void DialogMultipaned::on_drag_update(double offset_x, double offset_y) auto width = start_width + offset_x; bool resizing = false; Gtk::Widget* hide = nullptr; - + bool toolbox = handle->get_style_context()->has_class("toolboxdragger"); if (!child->is_visible() && can_collapse(child, handle)) { child->show(); resizing = true; @@ -1153,12 +1167,19 @@ void DialogMultipaned::on_drag_update(double offset_x, double offset_y) if (can_collapse(child, handle)) { resizing = true; auto w = start_width == 0 ? reveal_curve(width, minimum_size) : collapse_curve(width, minimum_size); + if (toolbox) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + w = std::max(w,(double)prefs->getInt("/toolbox/minimumwidth",0)); + } offset_x = w - start_width; // facilitate closing/opening panels: users don't have to drag handle all the // way to collapse/expand a panel, they just need to move it fraction of the way; // note: those thresholds correspond to the easing functions used auto threshold = start_width == 0 ? minimum_size * 0.20 : minimum_size * 0.42; hide = width <= threshold ? child : nullptr; + if (toolbox) { + hide = nullptr; + } } else { offset_x = -(start_width - minimum_size) + BIAS; diff --git a/src/ui/dialog/dialog-multipaned.h b/src/ui/dialog/dialog-multipaned.h index 1d1bb50dd2..3c43609f8f 100644 --- a/src/ui/dialog/dialog-multipaned.h +++ b/src/ui/dialog/dialog-multipaned.h @@ -43,13 +43,14 @@ class MyDropZone public: MyDropZone(Gtk::Orientation orientation); ~MyDropZone() override; - + void setPaused(bool paused) { _paused = paused; } static void add_highlight_instances(); static void remove_highlight_instances(); private: void set_size(int size); bool _active = false; + bool _paused = false; void add_highlight(); void remove_highlight(); @@ -77,6 +78,7 @@ private: bool on_button_release_event(GdkEventButton *event) override; bool on_motion_notify_event(GdkEventMotion* motion_event) override; void toggle_multipaned(); + int _size; void update_click_indicator(double x, double y); void show_click_indicator(bool show); bool on_draw(const Cairo::RefPtr& cr) override; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 48dd62ddab..44e8774e34 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -228,8 +228,8 @@ SPDesktopWidget::SPDesktopWidget() dtw->_hbox = Gtk::manage(new Gtk::Box()); dtw->_hbox->set_name("DesktopHbox"); - dtw->_tbbox = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); - dtw->_tbbox->set_name("ToolboxCanvasPaned"); + dtw->_tbbox = Gtk::manage(new Gtk::Box()); + dtw->_hbox->pack_start(*dtw->_tbbox, true, true); dtw->_vbox->pack_end(*dtw->_hbox, true, true); @@ -252,8 +252,6 @@ SPDesktopWidget::SPDesktopWidget() dtw->tool_toolbox = ToolboxFactory::createToolToolbox(); ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL ); - dtw->_tbbox->pack1(*Glib::wrap(dtw->tool_toolbox), false, true); - auto set_visible_buttons = [=](GtkWidget* tb) { int buttons_before_separator = 0; Gtk::Widget* last_sep = nullptr; @@ -334,8 +332,9 @@ SPDesktopWidget::SPDesktopWidget() _container = Gtk::manage(new DialogContainer()); _columns = _container->get_columns(); _columns->set_dropzone_sizes(2, -1); - dtw->_tbbox->pack2(*_container, true, true); + dtw->_tbbox->add(*_container); + _canvas_grid->set_name("canvas_grid"); _canvas_grid->set_hexpand(true); _canvas_grid->set_vexpand(true); _columns->append(_canvas_grid); diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index ff6bc76f29..87c8bfcc03 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -109,7 +109,7 @@ private: // The root vbox of the window layout. Gtk::Box *_vbox; - Gtk::Paned *_tbbox; + Gtk::Box *_tbbox; Gtk::Box *_hbox; Inkscape::UI::Dialog::DialogContainer *_container = nullptr; Inkscape::UI::Dialog::DialogMultipaned *_columns; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 9960360c62..73c8a5d168 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -190,10 +190,32 @@ GtkWidget *ToolboxFactory::createToolToolbox() if (!toolbar) { std::cerr << "InkscapeWindow: Failed to load tool toolbar!" << std::endl; } - + g_signal_connect(G_OBJECT(GTK_WIDGET(toolbar->gobj())), "size_allocate", G_CALLBACK(ToolboxFactory::toolboxresized), G_OBJECT(GTK_WIDGET(toolbar->gobj()))); return toolboxNewCommon( GTK_WIDGET(toolbar->gobj()), BAR_TOOL, GTK_POS_LEFT ); } +void ToolboxFactory::toolboxresized(GtkWidget widget, gpointer data) { + if (data) { + GtkScrolledWindow *sw = reinterpret_cast(data); + if (sw) { + auto toolbox = dynamic_cast(Glib::wrap(sw)); + if (toolbox){ + auto viewport = dynamic_cast(toolbox->get_child()); + if (viewport) { + gint minimum_width = 0; + gint natural_width = 0; + viewport->get_child()->get_preferred_width(minimum_width, natural_width); + gint widthscroll = std::max(toolbox->get_width(), minimum_width); + toolbox->set_size_request(widthscroll,-1); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/toolbox/width", widthscroll); + prefs->setInt("/toolbox/minimumwidth", minimum_width); + } + } + } + } +} + GtkWidget *ToolboxFactory::createAuxToolbox() { auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index efe4514b3c..7655e46aaf 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -18,6 +18,8 @@ #include #include +#include + #include "preferences.h" class SPDesktop; @@ -45,7 +47,7 @@ public: static void set_icon_size(GtkWidget* toolbox, int pixel_size); ToolboxFactory() = delete; - + static void toolboxresized(GtkWidget widget, gpointer data); static constexpr const char* tools_icon_size = "/toolbox/tools/iconsize"; static constexpr const char* tools_visible_buttons = "/toolbox/tools/buttons"; static constexpr const char* ctrlbars_icon_size = "/toolbox/controlbars/iconsize"; -- GitLab