diff --git a/share/ui/style.css b/share/ui/style.css index 460b71c00278c8fde102c8637bb7959dadc27b97..2ffb07631a735d0655b72b250827b430ff3db702 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 b5ab18822c0e35e2b6da3e3e4840b9cccbae9b7e..fef571669b4f25f290696ff14543e66158d4392f 100644 --- a/share/ui/toolbar-tool.ui +++ b/share/ui/toolbar-tool.ui @@ -117,688 +117,703 @@ False tool-pages - - tool-toolbar + True - False - vertical - start - center + False + none + True + True + never - - True + True False - start - start - vertical - 2 - - + + tool-toolbar True - True + False + vertical + start + fill - + + True True - True - False - center - center - win.tool-switch - 'Select' - icon-select - none + False + start + start + horizontal + 2 + + + True + True + + + 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 + + + + + + + False + False + 0 + - - - - - True - True - True - + True - True - False - center - center - win.tool-switch - 'Node' - icon-node - none - + False + + False + False + 1 + - - - - - False - False - 0 - - - - - True - False - - - False - False - 1 - - - - - True - True - False - start - start - vertical - 5 - - - - True - True - + + True True - True - False - center - center - win.tool-switch - 'Rect' - icon-rect - none + False + start + start + horizontal + 5 + + + True + True + + + 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 + + + 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 + + + True + True + False + center + center + win.tool-switch + 'Spiral' + icon-spiral + none + + + + + + + False + False + 2 + - - - - - True - True - + True - True - False - center - center - win.tool-switch - 'Arc' - icon-ellipse - none - + False + + False + False + 3 + - - - - - True - True - + + True True - True - False - center - center - win.tool-switch - 'Star' - icon-star - none + False + start + start + horizontal + 6 + + + True + True + + + 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 + + + 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 + + + + + + + False + False + 4 + - - - - - True - True - + True - True - False - center - center - win.tool-switch - '3DBox' - icon-threedee - none - + False + + False + False + 5 + - - - - - True - True - + + True True - True - False - center - center - win.tool-switch - 'Spiral' - icon-spiral - none + False + start + start + horizontal + 5 + + + True + True + + + 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 + + + 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 + + + + + + + False + False + 6 + - - - - - False - False - 2 - - - - - True - False - - - False - False - 3 - - - - - True - True - False - start - start - vertical - 6 - - - - True - True - + 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 - + False + + False + False + 7 + - - - - - True - True - + + True True - True - False - center - center - win.tool-switch - 'Calligraphic' - icon-calligraphic - none + False + start + start + horizontal + 5 + + + True + True + + + 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 + + + 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 + + + True + True + False + center + center + win.tool-switch + 'LPETool' + icon-geometry + none + + + + + + + False + False + 8 + - - - - - True - True - + True - True - False - center - center - win.tool-switch - 'Text' - image-text-tool - none - + False + + False + False + 9 + - - - - - False - False - 4 - - - - - True - False - - - False - False - 5 - - - - - True - True - False - start - start - vertical - 5 - - - - True - True - - - 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 - - - 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 - - - - - - - - False - False - 6 - - - - - True - False - - - False - False - 7 - - - - - True - True - False - start - start - vertical - 5 - - - - True - True - - - 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 - - - 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 - - - True - True - False - center - center - win.tool-switch - 'LPETool' - icon-geometry - none - - - - - - - - False - False - 8 - - - - - True - False - - - False - False - 9 - - - - - True - True - False - start - start - vertical - 5 - - - - True - True - - - 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 - + + True True - True - False - center - center - win.tool-switch - 'Pages' - icon-pages - none + False + start + start + horizontal + 5 + + + True + True + + + 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 + + + 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 4b39edbaf63d99b2178eed45ba568b1397e466e8..970f15f003791365db76da217b2235939bf6f7c3 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 784574eb2bc838699ece1597cf79640b20cdbbec..bcfd828b08a743214ff3a4c239c842f879308f99 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 1d1bb50dd22b2b619916807b629a831ed00caba4..3c43609f8f82d17d7a775c3358600a4108f29d20 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/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 58f0e11326191667dc0117d317d7a904e56359e2..5a1efa077ee5ee429d82dae2ad6983b1e58fd401 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 f27c5529252c55c09f845aeba3eaabcfe686fb98..44e8774e34b960d12ee41163de95e54b96732ef4 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::Box()); + + dtw->_hbox->pack_start(*dtw->_tbbox, true, true); + dtw->_vbox->pack_end(*dtw->_hbox, true, true); dtw->_top_toolbars = Gtk::make_managed(); @@ -247,8 +252,6 @@ 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); - auto set_visible_buttons = [=](GtkWidget* tb) { int buttons_before_separator = 0; Gtk::Widget* last_sep = nullptr; @@ -329,8 +332,9 @@ 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->add(*_container); + _canvas_grid->set_name("canvas_grid"); _canvas_grid->set_hexpand(true); _canvas_grid->set_vexpand(true); _columns->append(_canvas_grid); @@ -1231,9 +1235,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 a177c67780c49356d89d9250ab19318a09753fae..87c8bfcc03f8125c82a43e49a3fc856e302db035 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::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 a6b95862d763de25ed1e85de6e42e6a77da7ad46..73c8a5d168058372cd5ec4683b457447c078315f 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,31 @@ 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); } + 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 ); +} - return toolboxNewCommon( GTK_WIDGET(tb->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() diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index efe4514b3c109ce271e2633795020abaeb829179..7655e46aaffa78b90280a02234531930f0c19b66 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";