diff --git a/share/ui/toolbar-gradient.ui b/share/ui/toolbar-gradient.ui
index 8d62029a1c5fbfdf579aec2bfa1f34e83173f14c..c0c9e7b412654effc529550510a47ae4aa9465e7 100644
--- a/share/ui/toolbar-gradient.ui
+++ b/share/ui/toolbar-gradient.ui
@@ -1,6 +1,7 @@
-
+
+
-
+
@@ -100,24 +112,48 @@
+
+
+ Repeat
+
+
+
+
+ false
+ false
+ true
+ Whether to fill with flat color beyond the ends of the gradient vector (spreadMethod="pad"), or repeat the gradient in the same direction (spreadMethod="repeat"), or repeat the gradient in alternating opposite directions (spreadMethod="reflect")
+
+
-
-
+
+
+
+ Stop
+
+
+
+
+ false
+ false
+ true
+
+
Offset of selected stop
@@ -148,7 +184,7 @@
False
node-add
@@ -162,12 +198,12 @@
False
node-delete
diff --git a/share/ui/toolbar-lpe.ui b/share/ui/toolbar-lpe.ui
index 92cc21f9c6f696a59dd4de20dd3bcebdfd6c7b33..6fbeaf97c9d0e4274b0e434e554985ad114662b5 100644
--- a/share/ui/toolbar-lpe.ui
+++ b/share/ui/toolbar-lpe.ui
@@ -1,6 +1,6 @@
-
+
start
center
@@ -99,8 +99,7 @@
-
-
+
@@ -125,17 +124,20 @@
-
-
+
Choose a line segment type
+
+
+ Choose a line segment type
+
+
-
-
+
@@ -147,7 +149,7 @@
False
draw-geometry-show-measuring-info
@@ -155,14 +157,14 @@
Scatter randomly the corners and angles
@@ -176,12 +178,12 @@
False
dialog-geometry
diff --git a/share/ui/toolbar-mesh.ui b/share/ui/toolbar-mesh.ui
index 5f037b5c51564a7df36c807aea0784d8c61df021..67b17974e3d33a8fcf843a019ee824bbde4dc6d0 100644
--- a/share/ui/toolbar-mesh.ui
+++ b/share/ui/toolbar-mesh.ui
@@ -1,6 +1,6 @@
-
+
1
20
@@ -116,8 +116,7 @@
-
-
+
@@ -129,7 +128,7 @@
False
object-fill
@@ -143,14 +142,14 @@
False
object-stroke
@@ -164,7 +163,7 @@
False
show-node-handles
@@ -178,7 +177,7 @@
False
node-segment-line
@@ -192,7 +191,7 @@
False
node-segment-curve
@@ -206,7 +205,7 @@
False
color-picker
@@ -220,14 +219,14 @@
False
mesh-gradient-fit
@@ -241,20 +240,31 @@
False
dialog-warning
+ 2
5
+
+
+ Smoothing
+
+
+
+
+ Coons: no smoothing. Bicubic: smoothing across patch boundaries.
+
+
diff --git a/share/ui/toolbar-paintbucket.ui b/share/ui/toolbar-paintbucket.ui
index e0525ad61e516b18feafa18957e42defa1f2c76d..a28c2bc19336541cde7e91bc083375cdbc412c4c 100644
--- a/share/ui/toolbar-paintbucket.ui
+++ b/share/ui/toolbar-paintbucket.ui
@@ -1,6 +1,6 @@
-
+
-10000
10000
@@ -18,11 +18,18 @@
True
+
+
+ Fill by
+
+
+
+
+
-
-
+
@@ -66,25 +73,31 @@
-
+
-
-
+
5
+
+
+ Close gaps
+
+
+
+
+
@@ -97,7 +110,7 @@
Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)
False
@@ -107,7 +120,7 @@
diff --git a/share/ui/toolbar-pencil.ui b/share/ui/toolbar-pencil.ui
index 0af5fe22209d988f8d00a2160755bbe7bca7033f..34459fbf05fcebd189ba72ac33d84961b44ecbfb 100644
--- a/share/ui/toolbar-pencil.ui
+++ b/share/ui/toolbar-pencil.ui
@@ -1,6 +1,7 @@
-
+
+
100
1
@@ -26,7 +27,7 @@
Mode of new lines drawn by this tool
- Mode:
+ Mode
@@ -89,8 +90,7 @@
-
-
+
@@ -106,6 +106,7 @@
+ 2
center
@@ -122,6 +123,7 @@
Min percent of pressure
+ 0
5
Min
@@ -160,11 +162,20 @@
Line endings when drawing with pressure-sensitive PowerPencil
+
+
+ Caps
+
+
+
+
+ Line endings when drawing with pressure-sensitive PowerPencil
+
+
-
-
+
@@ -209,11 +220,10 @@
-
-
+
@@ -221,6 +231,14 @@
5
Shape of new paths drawn by this tool
+
+
+ Shape
+
+
+
+
+
@@ -245,7 +263,7 @@
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 3494592f278595d6caed9b7bd826e6e417a6f13e..f53f60a8317bc6041e323d298cc1c8627567136f 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -1997,11 +1997,13 @@ void GrDrag::selectByCoords(std::vector coords)
*/
void GrDrag::selectByStop(SPStop *stop, bool add_to_selection, bool override )
{
- for (auto dragger : this->draggers) {
+ if (_update.pending()) return;
+
+ auto block = _update.block();
- for (std::vector::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) {
+ for (auto dragger : this->draggers) {
- GrDraggable *d = *j;
+ for (auto& d : dragger->draggables) {
SPGradient *gradient = getGradient(d->item, d->fill_or_stroke);
SPGradient *vector = gradient->getVector(false);
SPStop *stop_i = sp_get_stop_i(vector, d->point_i);
@@ -2024,6 +2026,46 @@ void GrDrag::selectRect(Geom::Rect const &r)
}
}
+SPStop* GrDrag::getStop(GrDragger *dragger, SPGradient* gradient) {
+ if (!dragger || !gradient) return nullptr;
+
+ gint n = 0;
+ SPStop* stop = nullptr;
+ auto vector = gradient->getVector(false);
+
+ // For all draggables of dragger
+ for (auto draggable : dragger->draggables) {
+ if (draggable->point_type != POINT_RG_FOCUS) {
+ n++;
+ if (n > 1) break;
+ }
+
+ stop = vector->getFirstStop();
+
+ switch (draggable->point_type) {
+ case POINT_LG_MID:
+ case POINT_RG_MID1:
+ case POINT_RG_MID2:
+ stop = sp_get_stop_i(vector, draggable->point_i);
+ break;
+ case POINT_LG_END:
+ case POINT_RG_R1:
+ case POINT_RG_R2:
+ stop = sp_last_stop(vector);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (n > 1) {
+ // Multiple stops selected
+ return nullptr;
+ }
+
+ return stop;
+}
+
/**
* Select a dragger.
* @param dragger The dragger to select.
@@ -2066,7 +2108,13 @@ void GrDrag::setSelected(GrDragger *dragger, bool add_to_selection, bool overrid
}
}
if (seldragger) {
- desktop->emit_gradient_stop_selected(nullptr);
+ SPStop* stop = nullptr;
+ if (!seldragger->draggables.empty()) {
+ auto d = seldragger->draggables.front();
+ stop = getStop(seldragger, getGradient(d->item, d->fill_or_stroke));
+ }
+ auto block = _update.block();
+ desktop->emit_gradient_stop_selected(stop);
}
}
diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index 8e24f43a83ac49d7eb1d73295c68a5f774f8782b..0ee0d7f01607552d2f8798c4eee95a423500c04d 100644
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
@@ -31,6 +31,7 @@
#include "object/sp-gradient.h" // TODO refactor enums to external .h file
#include "object/sp-mesh-array.h"
#include "display/control/canvas-item-ptr.h"
+#include "ui/operation-blocker.h"
class SPKnot;
@@ -173,6 +174,7 @@ public: // FIXME: make more of this private!
void selectByCoords(std::vector coords);
void selectByStop(SPStop *stop, bool add_to_selection = true, bool override = true);
void selectRect(Geom::Rect const &r);
+ static SPStop* getStop(GrDragger* dragger, SPGradient* gradient);
void addColorToDragger(GrDragger &dragger, const char *color);
void dropColorOnCorrespondingRegion(const char *color, Geom::Point p);
@@ -254,6 +256,7 @@ private:
sigc::connection style_set_connection;
sigc::connection style_query_connection;
+ OperationBlocker _update;
};
#endif // SEEN_GRADIENT_DRAG_H
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 9e4300054d5846f9ddf8006eae9cf25676856e3a..909123cd8261fe650180bae83a3ae77dfa95788b 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -246,7 +246,7 @@ target_sources(inkscape_base PRIVATE
widget/gradient-vector-selector.cpp
widget/gradient-with-stops.cpp
widget/gtk-registry.cpp
- widget/icon-combobox.cpp
+ widget/generic/icon-combobox.cpp
widget/handle-preview.cpp
widget/image-properties.cpp
widget/imagetoggler.cpp
@@ -578,7 +578,7 @@ target_sources(inkscape_base PRIVATE
widget/gradient-vector-selector.h
widget/gradient-with-stops.h
widget/gtk-registry.h
- widget/icon-combobox.h
+ widget/generic/icon-combobox.h
widget/handle-preview.h
widget/image-properties.h
widget/imagetoggler.h
diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h
index 329b9621bb664d6a676225b528a26500bc06747d..f10f3e77acb7906cec758a30113cdda361c03a66 100644
--- a/src/ui/dialog/document-properties.h
+++ b/src/ui/dialog/document-properties.h
@@ -35,7 +35,7 @@
#include "object/sp-grid.h"
#include "ui/dialog/dialog-base.h"
#include "ui/widget/generic/popover-bin.h"
-#include "ui/widget/icon-combobox.h"
+#include "ui/widget/generic/icon-combobox.h"
#include "ui/widget/licensor.h"
#include "ui/widget/registered-widget.h"
#include "xml/helper-observer.h"
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index e5f5e3ecf05ddffc01409e227381d7eace160325..0b8bf8a56088b7f44ae54828690772efb297e1ea 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -42,7 +42,7 @@
#include
#include "display/control/ctrl-handle-manager.h"
-#include "ui/widget/icon-combobox.h"
+#include "ui/widget/generic/icon-combobox.h"
#include "ui/widget/handle-preview.h"
#if WITH_GSOURCEVIEW
@@ -1550,7 +1550,7 @@ void InkscapePreferences::symbolicThemeCheck()
}
static Cairo::RefPtr draw_color_preview(unsigned int rgb, unsigned int frame_rgb, int device_scale) {
- int size = Widget::IconComboBox::get_image_size();
+ int size = Widget::IconComboBox::get_default_image_size();
auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, size * device_scale, size * device_scale);
cairo_surface_set_device_scale(surface->cobj(), device_scale, device_scale);
auto ctx = Cairo::Context::create(surface);
diff --git a/src/ui/toolbar/arc-toolbar.cpp b/src/ui/toolbar/arc-toolbar.cpp
index 6ae5c88709fa42cbca609f2222155f498d1608da..9ca2839d66e779ca810e99a77e0d67d8852bae68 100644
--- a/src/ui/toolbar/arc-toolbar.cpp
+++ b/src/ui/toolbar/arc-toolbar.cpp
@@ -40,7 +40,6 @@
#include "selection.h"
#include "ui/builder-utils.h"
#include "ui/icon-names.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/ui/toolbar/gradient-toolbar.cpp b/src/ui/toolbar/gradient-toolbar.cpp
index 132a7d59c58e8f381b67a225e07019f5e007a854..187bcd9626b853f1b674e0419f22d94d66d7277b 100644
--- a/src/ui/toolbar/gradient-toolbar.cpp
+++ b/src/ui/toolbar/gradient-toolbar.cpp
@@ -21,6 +21,7 @@
#include
#include
#include
+#include <2geom/point.h>
#include "desktop.h"
#include "document-undo.h"
@@ -37,9 +38,11 @@
#include "ui/icon-names.h"
#include "ui/tools/gradient-tool.h"
#include "ui/util.h"
-#include "ui/widget/combo-tool-item.h"
+#include "ui/widget/drop-down-list.h"
+#include "ui/widget/gradient-editor.h"
#include "ui/widget/gradient-image.h"
#include "ui/widget/gradient-vector-selector.h"
+#include "ui/widget/paint-selector.h"
#include "ui/widget/spinbutton.h"
using Inkscape::DocumentUndo;
@@ -48,6 +51,11 @@ using Inkscape::UI::Tools::ToolBase;
namespace Inkscape::UI::Toolbar {
namespace {
+using GradientItem = Widget::IconComboBox::ListItem;
+constexpr Geom::Point GradientSize = Geom::Point{64, 16};
+using StopItem = Widget::IconComboBox::ListItem;
+constexpr Geom::Point StopSize = Geom::Point{32, 16};
+
void gr_apply_gradient_to_item(SPItem *item, SPGradient *gr, SPGradientType initialType, PaintTarget initialMode, PaintTarget mode)
{
auto style = item->style;
@@ -96,7 +104,7 @@ void gr_apply_gradient(Selection *selection, GrDrag *drag, SPGradient *gr)
}
}
-int gr_vector_list(Glib::RefPtr store, SPDesktop *desktop,
+int gr_vector_list(Glib::RefPtr> store, SPDesktop *desktop,
bool selection_empty, SPGradient *gr_selected, bool gr_multi)
{
int selected = -1;
@@ -112,63 +120,38 @@ int gr_vector_list(Glib::RefPtr store, SPDesktop *desktop,
}
}
- store->clear();
- Inkscape::UI::Widget::ComboToolItemColumns columns;
- Gtk::TreeModel::Row row;
+ store->remove_all();
+ Glib::RefPtr no_image;
if (labels_gradients.empty()) {
// The document has no gradients
- row = *(store->append());
- row[columns.col_label ] = _("No gradient");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(GradientItem::create(0, _("No gradient"), no_image));
return selected;
}
if (selection_empty) {
// Document has gradients, but nothing is currently selected.
- row = *(store->append());
- row[columns.col_label ] = _("Nothing selected");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(GradientItem::create(0, _("Nothing selected"), no_image));
return selected;
}
// Document has gradients and a selection.
if (gr_selected == nullptr) {
- row = *(store->append());
- row[columns.col_label ] = _("No gradient");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(GradientItem::create(0, _("No gradient"), no_image));
}
if (gr_multi) {
- row = *(store->append());
- row[columns.col_label ] = _("Multiple gradients");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(GradientItem::create(0, _("Multiple gradients"), no_image));
}
int idx = 0;
for (auto const &[label, gradient] : labels_gradients) {
- Glib::RefPtr pixbuf = sp_gradient_to_pixbuf_ref(gradient, 64, 16);
-
- row = *(store->append());
- row[columns.col_label ] = label;
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_pixbuf ] = pixbuf;
- row[columns.col_data ] = gradient;
- row[columns.col_sensitive] = true;
+ auto image = sp_gradient_to_surface(gradient, GradientSize.x(), GradientSize.y());
+ auto id = gradient->getId();
+ auto item = GradientItem::create(idx, label, to_texture(image));
+ item->uid = id ? id : "";
+ store->append(item);
if (gradient == gr_selected) {
selected = idx;
@@ -329,10 +312,16 @@ GradientToolbar::GradientToolbar(Glib::RefPtr const &builder)
, _offset_item{get_derived_widget(builder, "_offset_item")}
, _stops_add_btn{get_widget(builder, "_stops_add_btn")}
, _stops_delete_btn{get_widget(builder, "_stops_delete_btn")}
+ , _select_cb(get_derived_widget(builder, "gradient-list", _gradient_store, false))
+ , _spread_cb(get_derived_widget(builder, "spread-list"))
+ , _stop_cb(get_derived_widget(builder, "stop-list", _stop_store, false))
{
+ _select_cb.set_image_size(GradientSize);
+ _stop_cb.set_image_size(StopSize);
+
auto prefs = Preferences::get();
- // Setup the spin buttons.
+ // Set up the spin buttons.
setup_derived_spin_button(_offset_item, "stopoffset", 0);
// Values auto-calculated.
@@ -360,30 +349,10 @@ GradientToolbar::GradientToolbar(Glib::RefPtr const &builder)
auto fsmode = prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0 ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
_new_fillstroke_buttons[fsmode == Inkscape::FOR_FILL ? 0 : 1]->set_active();
- /* Gradient Select list */
- {
- UI::Widget::ComboToolItemColumns columns;
- auto store = Gtk::ListStore::create(columns);
- Gtk::TreeModel::Row row;
- row = *(store->append());
- row[columns.col_label ] = _("No gradient");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_sensitive] = true;
-
- _select_cb = UI::Widget::ComboToolItem::create(_("Select"), // Label
- "", // Tooltip
- "Not Used", // Icon
- store ); // Tree store
- _select_cb->use_icon( false );
- _select_cb->use_pixbuf( true );
- _select_cb->use_group_label( true );
- _select_cb->set_active( 0 );
- _select_cb->set_sensitive( false );
-
- get_widget(builder, "select_box").append(*_select_cb);
- _select_cb->signal_changed().connect(sigc::mem_fun(*this, &GradientToolbar::gradient_changed));
- }
+ _gradient_store->append(GradientItem::create(0, _("No gradient"), {}));
+ _select_cb.set_selected(0);
+ _select_cb.set_sensitive(false);
+ _select_cb.property_selected().signal_changed().connect([this]{ gradient_changed(_select_cb.get_selected()); });
// Configure the linked button.
_linked_btn.signal_toggled().connect(sigc::mem_fun(*this, &GradientToolbar::linked_changed));
@@ -396,67 +365,19 @@ GradientToolbar::GradientToolbar(Glib::RefPtr const &builder)
_stops_reverse_btn.set_sensitive(false);
// Gradient Spread type (how a gradient is drawn outside its nominal area)
- {
- UI::Widget::ComboToolItemColumns columns;
- Glib::RefPtr store = Gtk::ListStore::create(columns);
-
- std::vector spread_dropdown_items_list = {
- const_cast(C_("Gradient repeat type", "None")),
- _("Reflected"),
- _("Direct")
- };
-
- for (auto item: spread_dropdown_items_list) {
- Gtk::TreeModel::Row row = *(store->append());
- row[columns.col_label ] = item;
- row[columns.col_sensitive] = true;
- }
-
- _spread_cb = Gtk::manage(UI::Widget::ComboToolItem::create(_("Repeat"),
- // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute
- _("Whether to fill with flat color beyond the ends of the gradient vector "
- "(spreadMethod=\"pad\"), or repeat the gradient in the same direction "
- "(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite "
- "directions (spreadMethod=\"reflect\")"),
- "Not Used", store));
- _spread_cb->use_group_label(true);
-
- _spread_cb->set_active(0);
- _spread_cb->set_sensitive(false);
-
- _spread_cb->signal_changed().connect(sigc::mem_fun(*this, &GradientToolbar::spread_changed));
- get_widget(builder, "spread_box").append(*_spread_cb);
+ for (auto [mode, label, icon] : UI::Widget::sp_get_spread_repeats()) {
+ _spread_cb.add_row(icon, label, static_cast(mode));
}
+ _spread_cb.set_selected(0);
+ _spread_cb.set_sensitive(false);
- // Gradient Stop list
- {
- UI::Widget::ComboToolItemColumns columns;
-
- auto store = Gtk::ListStore::create(columns);
-
- Gtk::TreeModel::Row row;
-
- row = *(store->append());
- row[columns.col_label ] = _("No stops");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_sensitive] = true;
-
- _stop_cb =
- UI::Widget::ComboToolItem::create(_("Stops" ), // Label
- "", // Tooltip
- "Not Used", // Icon
- store ); // Tree store
-
- _stop_cb->use_icon( false );
- _stop_cb->use_pixbuf( true );
- _stop_cb->use_group_label( true );
- _stop_cb->set_active( 0 );
- _stop_cb->set_sensitive( false );
+ _spread_cb.signal_changed().connect([this](auto sel) { spread_changed(sel); });
- get_widget(builder, "stop_box").append(*_stop_cb);
- _stop_cb->signal_changed().connect(sigc::mem_fun(*this, &GradientToolbar::stop_changed));
- }
+ // Gradient Stop list
+ _stop_store->append(StopItem::create(0, _("No stops in gradient"), {}));
+ _stop_cb.set_selected(0);
+ _stop_cb.set_sensitive(false);
+ _stop_cb.signal_changed().connect([this](int sel){ stop_changed(sel); });
// Configure the stops add button.
_stops_add_btn.signal_clicked().connect(sigc::mem_fun(*this, &GradientToolbar::add_stop));
@@ -490,7 +411,12 @@ void GradientToolbar::setDesktop(SPDesktop *desktop)
// connect to selection modified and changed signals
_connection_changed = sel->connectChanged([this] (auto) { _update(); });
_connection_modified = sel->connectModified([this] (auto, auto) { _update(); });
- _connection_subselection_changed = desktop->connect_gradient_stop_selected([this] (auto) { _update(); });
+ _connection_subselection_changed = desktop->connect_gradient_stop_selected([this] (auto stop) {
+ if (_blocker.pending()) return;
+ _update();
+ auto guard = _blocker.block();
+ select_dragger_by_stop(stop, _desktop->getTool());
+ });
_update();
// connect to release and modified signals of the defs (i.e. when someone changes gradient)
@@ -560,16 +486,12 @@ void GradientToolbar::gradient_changed(int active)
*/
SPGradient *GradientToolbar::get_selected_gradient()
{
- int active = _select_cb->get_active();
-
- auto store = _select_cb->get_store();
- auto row = store->children()[active];
- UI::Widget::ComboToolItemColumns columns;
-
- void* pointer = row[columns.col_data];
- SPGradient *gr = static_cast(pointer);
+ auto item = _select_cb.current_item();
+ if (auto doc = _desktop->getDocument()) {
+ return item ? cast(doc->getObjectById(item->uid)) : nullptr;
+ }
- return gr;
+ return nullptr;
}
/**
@@ -609,16 +531,16 @@ void GradientToolbar::stop_changed(int active)
auto guard = _blocker.block();
- select_dragger_by_stop(get_selected_gradient(), _desktop->getTool());
+ auto stop = get_selected_stop();
+ select_dragger_by_stop(stop, _desktop->getTool());
}
-void GradientToolbar::select_dragger_by_stop(SPGradient *gradient, ToolBase *ev)
+void GradientToolbar::select_dragger_by_stop(SPStop* stop, ToolBase *ev)
{
if (!_blocker.pending()) {
std::cerr << "select_dragger_by_stop: should be blocked!" << std::endl;
}
-
- if (!ev || !gradient) {
+ if (!ev || !stop) {
return;
}
@@ -627,9 +549,9 @@ void GradientToolbar::select_dragger_by_stop(SPGradient *gradient, ToolBase *ev)
return;
}
- drag->selectByStop(get_selected_stop(), false, true);
+ drag->selectByStop(stop, false, true);
- stop_set_offset();
+ stop_set_offset(stop);
}
/**
@@ -637,12 +559,8 @@ void GradientToolbar::select_dragger_by_stop(SPGradient *gradient, ToolBase *ev)
*/
SPStop *GradientToolbar::get_selected_stop()
{
- int active = _stop_cb->get_active();
-
- auto store = _stop_cb->get_store();
- auto row = store->children()[active];
- UI::Widget::ComboToolItemColumns columns;
- void* pointer = row[columns.col_data];
+ auto item = _stop_cb.current_item();
+ void* pointer = item ? item->data : nullptr;
return static_cast(pointer);
}
@@ -651,27 +569,27 @@ SPStop *GradientToolbar::get_selected_stop()
*
* Set the offset widget value (based on which stop is selected)
*/
-void GradientToolbar::stop_set_offset()
+void GradientToolbar::stop_set_offset(SPStop* stop)
{
if (!_blocker.pending()) {
std::cerr << "gr_stop_set_offset: should be blocked!" << std::endl;
}
- auto stop = get_selected_stop();
if (!stop) {
- // std::cerr << "gr_stop_set_offset: no stop!" << std::endl;
return;
}
- SPStop *prev = nullptr;
- prev = stop->getPrevStop();
auto adj = _offset_item.get_adjustment();
- adj->set_lower(prev != nullptr ? prev->offset : 0);
-
- SPStop *next = nullptr;
- next = stop->getNextStop();
- adj->set_lower(next != nullptr ? next->offset : 1.0);
+ adj->freeze_notify();
+ adj->set_lower(0);
+ adj->set_upper(1);
+
+ auto prev = stop->getPrevStop();
+ auto next = stop->getNextStop();
+ adj->set_lower(prev ? prev->offset : 0);
+ adj->set_upper(next ? next->offset : 1.0);
adj->set_value(stop->offset);
+ adj->thaw_notify();
_offset_item.set_sensitive(true);
}
@@ -803,28 +721,27 @@ void GradientToolbar::_update()
gr_read_selection(selection, drag, gr_selected, gr_multi, spr_selected, spr_multi);
// Gradient selection menu
- auto store = _select_cb->get_store();
- int gradient = gr_vector_list (store, _desktop, selection->isEmpty(), gr_selected, gr_multi);
+ int gradient = gr_vector_list(_gradient_store, _desktop, selection->isEmpty(), gr_selected, gr_multi);
if (gradient < 0) {
// No selection or no gradients
- _select_cb->set_active(0);
- _select_cb->set_sensitive(false);
+ _select_cb.set_selected(0);
+ _select_cb.set_sensitive(false);
} else {
// Single gradient or multiple gradients
- _select_cb->set_active(gradient);
- _select_cb->set_sensitive(true);
+ _select_cb.set_selected(gradient);
+ _select_cb.set_sensitive(true);
}
// Spread menu
- _spread_cb->set_sensitive(gr_selected );
- _spread_cb->set_active(gr_selected ? (int)spr_selected : 0);
+ _spread_cb.set_sensitive(gr_selected );
+ _spread_cb.set_selected(gr_selected ? (int)spr_selected : 0);
_stops_add_btn.set_sensitive((gr_selected && !gr_multi && drag && !drag->selected.empty()));
_stops_delete_btn.set_sensitive((gr_selected && !gr_multi && drag && !drag->selected.empty()));
_stops_reverse_btn.set_sensitive((gr_selected != nullptr));
- _stop_cb->set_sensitive(gr_selected && !gr_multi);
+ _stop_cb.set_sensitive(gr_selected && !gr_multi);
_offset_item.set_sensitive(!gr_multi);
update_stop_list(gr_selected, nullptr, gr_multi);
@@ -843,60 +760,35 @@ int GradientToolbar::update_stop_list(SPGradient *gradient, SPStop *new_stop, bo
int selected = -1;
- auto store = _stop_cb->get_store();
- if (!store) {
- return selected;
- }
+ auto store = _stop_store;
- store->clear();
- UI::Widget::ComboToolItemColumns columns;
- Gtk::TreeModel::Row row;
+ store->remove_all();
+
+ Glib::RefPtr no_image;
if (gr_multi) {
- row = *(store->append());
- row[columns.col_label ] = _("Multiple gradients");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(StopItem::create(0, _("Multiple gradients"), no_image));
selected = 0;
return selected;
}
if (!gradient) {
// No valid gradient
- row = *(store->append());
- row[columns.col_label ] = _("No gradient");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(StopItem::create(0, _("No gradient"), no_image));
} else if (!gradient->hasStops()) {
// Has gradient but it has no stops
- row = *(store->append());
- row[columns.col_label ] = _("No stops in gradient");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_data ] = nullptr;
- row[columns.col_sensitive] = true;
+ store->append(StopItem::create(0, _("No stops in gradient"), no_image));
} else {
// Gradient has stops
+ int index = 0;
for (auto& ochild: gradient->children) {
- if (is(&ochild)) {
-
- auto stop = cast(&ochild);
- Glib::RefPtr pixbuf = sp_gradstop_to_pixbuf_ref(stop, 32, 16);
-
- Inkscape::XML::Node *repr = reinterpret_cast(&ochild)->getRepr();
- Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25);
-
- row = *(store->append());
- row[columns.col_label ] = label;
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_pixbuf ] = pixbuf;
- row[columns.col_data ] = stop;
- row[columns.col_sensitive] = true;
+ if (auto stop = cast(&ochild)) {
+ auto surface = sp_gradstop_to_surface(stop, StopSize.x(), StopSize.y());
+ auto id = stop->getId();
+ auto label = gr_ellipsize_text(id ? id : "", 25);
+ auto item = StopItem::create(index++, label, to_texture(surface));
+ item->data = stop;
+ store->append(item);
}
}
}
@@ -944,8 +836,8 @@ void GradientToolbar::select_stop_by_draggers(SPGradient *gradient, ToolBase *ev
GrDrag *drag = ev->get_drag();
if (!drag || drag->selected.empty()) {
- _stop_cb->set_active(0);
- stop_set_offset();
+ _stop_cb.set_selected(0);
+ stop_set_offset(get_selected_stop());
return;
}
@@ -989,14 +881,7 @@ void GradientToolbar::select_stop_by_draggers(SPGradient *gradient, ToolBase *ev
_offset_item.set_sensitive(false);
// Stop list always updated first... reinsert "Multiple stops" as first entry.
- UI::Widget::ComboToolItemColumns columns;
- auto store = _stop_cb->get_store();
-
- auto row = *(store->prepend());
- row[columns.col_label ] = _("Multiple stops");
- row[columns.col_tooltip ] = "";
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_sensitive] = true;
+ _stop_store->insert(0, StopItem::create(-1, _("Multiple stops"), {}));
selected = 0;
} else {
@@ -1004,12 +889,12 @@ void GradientToolbar::select_stop_by_draggers(SPGradient *gradient, ToolBase *ev
}
if (selected < 0) {
- _stop_cb->set_active (0);
- _stop_cb->set_sensitive (false);
+ _stop_cb.set_selected(0);
+ _stop_cb.set_sensitive(false);
} else {
- _stop_cb->set_active (selected);
- _stop_cb->set_sensitive (true);
- stop_set_offset();
+ _stop_cb.set_selected(selected);
+ _stop_cb.set_sensitive();
+ stop_set_offset(stop);
}
}
diff --git a/src/ui/toolbar/gradient-toolbar.h b/src/ui/toolbar/gradient-toolbar.h
index a2191b818209646caf7d7e9f2c19b46eab7eeb7d..1a2acd2da4ef9ca1e7d96b4d10dc17aa688094d9 100644
--- a/src/ui/toolbar/gradient-toolbar.h
+++ b/src/ui/toolbar/gradient-toolbar.h
@@ -17,8 +17,11 @@
#include "toolbar.h"
#include "ui/operation-blocker.h"
+#include "ui/widget/generic/icon-combobox.h"
namespace Gtk {
+class SingleSelection;
+class DropDown;
class Builder;
class Button;
class ToggleButton;
@@ -33,7 +36,7 @@ class Selection;
namespace UI {
namespace Tools { class ToolBase; }
namespace Widget {
-class ComboToolItem;
+class DropDownList;
class SpinButton;
} // namespace Widget
} // namespace UI
@@ -52,22 +55,20 @@ public:
private:
GradientToolbar(Glib::RefPtr const &builder);
+ using Store = Gio::ListStore;
+ Glib::RefPtr _gradient_store = Store::create();
+ Glib::RefPtr _stop_store = Store::create();
std::vector _new_type_buttons;
std::vector _new_fillstroke_buttons;
-
- UI::Widget::ComboToolItem *_select_cb;
+ UI::Widget::IconComboBox& _select_cb;
Gtk::ToggleButton &_linked_btn;
Gtk::Button &_stops_reverse_btn;
- UI::Widget::ComboToolItem *_spread_cb;
-
- UI::Widget::ComboToolItem *_stop_cb;
+ UI::Widget::IconComboBox& _spread_cb;
+ UI::Widget::IconComboBox& _stop_cb;
UI::Widget::SpinButton &_offset_item;
-
Gtk::Button &_stops_add_btn;
Gtk::Button &_stops_delete_btn;
-
bool _offset_adj_changed = false;
-
OperationBlocker _blocker;
void setup_derived_spin_button(UI::Widget::SpinButton &btn, Glib::ustring const &name, double default_value);
@@ -77,9 +78,9 @@ private:
SPGradient *get_selected_gradient();
void spread_changed(int active);
void stop_changed(int active);
- void select_dragger_by_stop(SPGradient *gradient, Tools::ToolBase *ev);
+ void select_dragger_by_stop(SPStop* stop, Tools::ToolBase *ev);
SPStop *get_selected_stop();
- void stop_set_offset();
+ void stop_set_offset(SPStop* stop);
void stop_offset_adjustment_changed();
void add_stop();
void remove_stop();
diff --git a/src/ui/toolbar/lpe-toolbar.cpp b/src/ui/toolbar/lpe-toolbar.cpp
index 367f221f2a77db317a23aabd4ae2de03cd485da7..d05e3341895f200b95a9fb69457664ac0b75f265 100644
--- a/src/ui/toolbar/lpe-toolbar.cpp
+++ b/src/ui/toolbar/lpe-toolbar.cpp
@@ -34,7 +34,6 @@
#include "ui/dialog/dialog-container.h"
#include "ui/tools/lpe-tool.h"
#include "ui/util.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/unit-tracker.h"
using Inkscape::UI::Widget::UnitTracker;
@@ -57,24 +56,16 @@ LPEToolbar::LPEToolbar(Glib::RefPtr const &builder)
, _measuring_btn(get_widget(builder, "_measuring_btn"))
, _open_lpe_dialog_btn(get_widget(builder, "_open_lpe_dialog_btn"))
, _tracker{std::make_unique(Util::UNIT_TYPE_LINEAR)}
+ , _line_segment_combo(get_derived_widget(builder, "line-type"))
{
auto prefs = Preferences::get();
// Combo box to choose line segment type
- UI::Widget::ComboToolItemColumns columns;
- auto store = Gtk::ListStore::create(columns);
-
for (auto item : {_("Closed"), _("Open start"), _("Open end"), _("Open both")}) {
- auto row = *store->append();
- row[columns.col_label ] = item;
- row[columns.col_sensitive] = true;
+ _line_segment_combo.append(item);
}
-
- _line_segment_combo = Gtk::manage(UI::Widget::ComboToolItem::create(_("Line Type"), _("Choose a line segment type"), "Not Used", store));
- _line_segment_combo->use_group_label(false);
- _line_segment_combo->set_active(0);
- _line_segment_combo->signal_changed().connect(sigc::mem_fun(*this, &LPEToolbar::change_line_segment_type));
- get_widget(builder, "line_segment_box").append(*_line_segment_combo);
+ _line_segment_combo.set_selected(0);
+ _line_segment_combo.signal_changed().connect([this] { change_line_segment_type(_line_segment_combo.get_selected()); });
// Configure mode buttons
int btn_index = 0;
@@ -294,18 +285,18 @@ void LPEToolbar::sel_changed(Selection *selection)
auto lpels = static_cast(lpe);
_currentlpe = lpe;
_currentlpeitem = lpeitem;
- _line_segment_combo->set_sensitive(true);
- _line_segment_combo->set_active( lpels->end_type.get_value() );
+ _line_segment_combo.set_sensitive();
+ _line_segment_combo.set_selected(lpels->end_type.get_value());
} else {
_currentlpe = nullptr;
_currentlpeitem = nullptr;
- _line_segment_combo->set_sensitive(false);
+ _line_segment_combo.set_sensitive(false);
}
} else {
_currentlpe = nullptr;
_currentlpeitem = nullptr;
- _line_segment_combo->set_sensitive(false);
+ _line_segment_combo.set_sensitive(false);
}
}
diff --git a/src/ui/toolbar/lpe-toolbar.h b/src/ui/toolbar/lpe-toolbar.h
index 85e6461121e90fcd9aae546769f6bdb74106ea64..81c1394626a5bdff02fed308b9ee273d61472bbd 100644
--- a/src/ui/toolbar/lpe-toolbar.h
+++ b/src/ui/toolbar/lpe-toolbar.h
@@ -44,8 +44,8 @@ class Selection;
namespace Tools { class ToolBase; }
namespace UI {
namespace Widget {
+class DropDownList;
class UnitMenu;
-class ComboToolItem;
class UnitTracker;
} // namespace Widget
} // namespace UI
@@ -74,7 +74,7 @@ private:
Gtk::ToggleButton &_bbox_from_selection_btn;
Gtk::ToggleButton &_measuring_btn;
Gtk::ToggleButton &_open_lpe_dialog_btn;
- UI::Widget::ComboToolItem *_line_segment_combo;
+ UI::Widget::DropDownList& _line_segment_combo;
UI::Widget::UnitMenu*_units_item;
OperationBlocker _blocker;
diff --git a/src/ui/toolbar/measure-toolbar.cpp b/src/ui/toolbar/measure-toolbar.cpp
index 6878effaecc1579f18d15d1874a050b4868283d2..dce1ed666cecac81452083a2fe2f3421f88cb1b5 100644
--- a/src/ui/toolbar/measure-toolbar.cpp
+++ b/src/ui/toolbar/measure-toolbar.cpp
@@ -34,7 +34,6 @@
#include "object/sp-namedview.h"
#include "ui/builder-utils.h"
#include "ui/tools/measure-tool.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/generic/spin-button.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/ui/toolbar/mesh-toolbar.cpp b/src/ui/toolbar/mesh-toolbar.cpp
index e554e7fb8d22f3705c2e51a248cd8f417645435a..721ea9b10b785653761c2e1f9996e71cd64a1be1 100644
--- a/src/ui/toolbar/mesh-toolbar.cpp
+++ b/src/ui/toolbar/mesh-toolbar.cpp
@@ -36,7 +36,7 @@
#include "ui/simple-pref-pusher.h"
#include "ui/tools/mesh-tool.h"
#include "ui/util.h"
-#include "ui/widget/combo-tool-item.h"
+#include "ui/widget/drop-down-list.h"
#include "ui/widget/spinbutton.h"
using Inkscape::DocumentUndo;
@@ -124,31 +124,15 @@ MeshToolbar::MeshToolbar(Glib::RefPtr const &builder)
, _edit_fill_btn{&get_widget(builder, "_edit_fill_btn")}
, _edit_stroke_btn{&get_widget(builder, "_edit_stroke_btn")}
, _show_handles_btn{&get_widget(builder, "show_handles_btn")}
+ , _select_type_item(get_derived_widget(builder, "type-selector"))
{
auto prefs = Preferences::get();
// Configure the types combo box.
- UI::Widget::ComboToolItemColumns columns;
- auto store = Gtk::ListStore::create(columns);
- Gtk::TreeModel::Row row;
-
- row = *store->append();
- row[columns.col_label] = C_("Type", "Coons");
- row[columns.col_sensitive] = true;
-
- row = *store->append();
- row[columns.col_label] = _("Bicubic");
- row[columns.col_sensitive] = true;
-
- _select_type_item = Gtk::manage(UI::Widget::ComboToolItem::create(
- _("Smoothing"),
- // TRANSLATORS: Type of Smoothing. See https://en.wikipedia.org/wiki/Coons_patch
- _("Coons: no smoothing. Bicubic: smoothing across patch boundaries."), "Not Used", store));
- _select_type_item->use_group_label(true);
- _select_type_item->set_active(0);
-
- _select_type_item->signal_changed().connect(sigc::mem_fun(*this, &MeshToolbar::type_changed));
- get_widget(builder, "select_type_box").append(*_select_type_item);
+ _select_type_item.append(C_("Type", "Coons"));
+ _select_type_item.append(_("Bicubic"));
+ _select_type_item.set_selected(0);
+ _select_type_item.signal_changed().connect([this] { type_changed(_select_type_item.get_selected()); });
// Setup the spin buttons.
setup_derived_spin_button(_row_item, "mesh_rows", 1, &MeshToolbar::row_changed);
@@ -354,11 +338,9 @@ void MeshToolbar::selection_changed()
bool ms_type_multi = false;
ms_read_selection(selection, ms_selected, ms_selected_multi, ms_type, ms_type_multi);
- if (_select_type_item) {
- _select_type_item->set_sensitive(!ms_type_multi);
- auto guard = _blocker.block();
- _select_type_item->set_active(ms_type);
- }
+ _select_type_item.set_sensitive(!ms_type_multi);
+ auto guard = _blocker.block();
+ _select_type_item.set_selected(ms_type);
}
}
diff --git a/src/ui/toolbar/mesh-toolbar.h b/src/ui/toolbar/mesh-toolbar.h
index e9e74e67e13daca99d50d1cd32ec1af1dd6c7e3c..fbbd74cabb6d6bc70583ff61f22cdb97a17ae536 100644
--- a/src/ui/toolbar/mesh-toolbar.h
+++ b/src/ui/toolbar/mesh-toolbar.h
@@ -33,7 +33,7 @@ namespace UI {
class SimplePrefPusher;
namespace Tools { class MeshTool; }
namespace Widget {
-class ComboToolItem;
+class DropDownList;
class SpinButton;
} // namespace Widget
} // namespace UI
@@ -56,7 +56,7 @@ private:
std::vector _new_type_buttons;
std::vector _new_fillstroke_buttons;
- UI::Widget::ComboToolItem *_select_type_item;
+ UI::Widget::DropDownList& _select_type_item;
Gtk::ToggleButton *_edit_fill_btn;
Gtk::ToggleButton *_edit_stroke_btn;
diff --git a/src/ui/toolbar/node-toolbar.cpp b/src/ui/toolbar/node-toolbar.cpp
index b3b58d1d4d640367a0b5af0fd93b47f69345811f..ec4861f0c4e133b67334693f0f8841660fb75848 100644
--- a/src/ui/toolbar/node-toolbar.cpp
+++ b/src/ui/toolbar/node-toolbar.cpp
@@ -40,7 +40,6 @@
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/path-manipulator.h"
#include "ui/tools/node-tool.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/ui/toolbar/paintbucket-toolbar.cpp b/src/ui/toolbar/paintbucket-toolbar.cpp
index fabe111c00f5c3a10a061cd7bd92845d9eb01f6b..f3191b486b2cb70c73a4dbe1c006d6c1e6ad6b96 100644
--- a/src/ui/toolbar/paintbucket-toolbar.cpp
+++ b/src/ui/toolbar/paintbucket-toolbar.cpp
@@ -33,7 +33,6 @@
#include "ui/builder-utils.h"
#include "ui/tools/flood-tool.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
@@ -48,6 +47,8 @@ PaintbucketToolbar::PaintbucketToolbar(Glib::RefPtr const &builder
, _tracker{std::make_unique(Inkscape::Util::UNIT_TYPE_LINEAR)}
, _threshold_item(get_derived_widget(builder, "_threshold_item"))
, _offset_item(get_derived_widget(builder, "_offset_item"))
+ , _channels_item(get_derived_widget(builder, "channel-list"))
+ , _autogap_item(get_derived_widget(builder, "autogap-list"))
{
auto prefs = Preferences::get();
@@ -61,24 +62,14 @@ PaintbucketToolbar::PaintbucketToolbar(Glib::RefPtr const &builder
// Channel
{
- UI::Widget::ComboToolItemColumns columns;
-
- Glib::RefPtr store = Gtk::ListStore::create(columns);
-
for (auto item : Inkscape::UI::Tools::FloodTool::channel_list) {
- Gtk::TreeModel::Row row = *store->append();
- row[columns.col_label ] = _(item);
- row[columns.col_sensitive] = true;
+ _channels_item.append(_(item));
}
- _channels_item = Gtk::manage(UI::Widget::ComboToolItem::create(_("Fill by"), "", "Not Used", store));
- _channels_item->use_group_label(true);
-
int channels = prefs->getInt("/tools/paintbucket/channels", 0);
- _channels_item->set_active(channels);
+ _channels_item.set_selected(channels);
- _channels_item->signal_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::channels_changed));
- get_widget(builder, "channels_box").append(*_channels_item);
+ _channels_item.signal_changed().connect([this] { channels_changed(_channels_item.get_selected()); });
// Create the units menu.
Glib::ustring stored_unit = prefs->getString("/tools/paintbucket/offsetunits");
@@ -90,24 +81,14 @@ PaintbucketToolbar::PaintbucketToolbar(Glib::RefPtr const &builder
// Auto Gap
{
- UI::Widget::ComboToolItemColumns columns;
-
- Glib::RefPtr store = Gtk::ListStore::create(columns);
-
for (auto item : Inkscape::UI::Tools::FloodTool::gap_list) {
- Gtk::TreeModel::Row row = *store->append();
- row[columns.col_label ] = g_dpgettext2(nullptr, "Flood autogap", item);
- row[columns.col_sensitive] = true;
+ _autogap_item.append(g_dpgettext2(nullptr, "Flood autogap", item));
}
- _autogap_item = Gtk::manage(UI::Widget::ComboToolItem::create(_("Close gaps"), Glib::ustring(), "Not Used", store));
- _autogap_item->use_group_label(true);
-
int autogap = prefs->getInt("/tools/paintbucket/autogap", 0);
- _autogap_item->set_active(autogap);
+ _autogap_item.set_selected(autogap);
- _autogap_item->signal_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::autogap_changed));
- get_widget(builder, "autogap_box").append(*_autogap_item);
+ _autogap_item.signal_changed().connect([this] { autogap_changed(_autogap_item.get_selected()); });
auto units_menu = _tracker->create_unit_dropdown();
get_widget(builder, "unit_menu_box").append(*units_menu);
@@ -179,8 +160,8 @@ void PaintbucketToolbar::defaults()
_threshold_item.get_adjustment()->set_value(15);
_offset_item.get_adjustment()->set_value(0.0);
- _channels_item->set_active(Inkscape::UI::Tools::FLOOD_CHANNELS_RGB);
- _autogap_item->set_active(0);
+ _channels_item.set_selected(Inkscape::UI::Tools::FLOOD_CHANNELS_RGB);
+ _autogap_item.set_selected(0);
}
} // namespace Inkscape::UI::Toolbar
diff --git a/src/ui/toolbar/paintbucket-toolbar.h b/src/ui/toolbar/paintbucket-toolbar.h
index df8b6f1cbd6f8b8588f2ad807567542d1e26281a..018ca981f1e456a3b0d093901a4a691374320f49 100644
--- a/src/ui/toolbar/paintbucket-toolbar.h
+++ b/src/ui/toolbar/paintbucket-toolbar.h
@@ -33,7 +33,7 @@
namespace Gtk { class Builder; }
namespace Inkscape::UI::Widget {
-class ComboToolItem;
+class DropDownList;
class UnitTracker;
class SpinButton;
} // namespace Inkscape::UI::Widget
@@ -55,8 +55,8 @@ private:
std::unique_ptr _tracker;
- UI::Widget::ComboToolItem *_channels_item;
- UI::Widget::ComboToolItem *_autogap_item;
+ UI::Widget::DropDownList& _channels_item;
+ UI::Widget::DropDownList& _autogap_item;
UI::Widget::SpinButton &_threshold_item;
UI::Widget::SpinButton &_offset_item;
diff --git a/src/ui/toolbar/pencil-toolbar.cpp b/src/ui/toolbar/pencil-toolbar.cpp
index 02d115ed10093d83512a05bbfab3117e12769503..f3953f32302e07b405db511ff697e2e1ba84a102 100644
--- a/src/ui/toolbar/pencil-toolbar.cpp
+++ b/src/ui/toolbar/pencil-toolbar.cpp
@@ -44,7 +44,6 @@
#include "ui/builder-utils.h"
#include "ui/tools/pen-tool.h"
#include "ui/util.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
namespace Inkscape::UI::Toolbar {
@@ -67,6 +66,10 @@ PencilToolbar::PencilToolbar(Glib::RefPtr const &builder, bool pen
, _flatten_simplify_btn(get_widget(builder, "_flatten_simplify_btn"))
, _shapescale_box(get_widget(builder, "_shapescale_box"))
, _shapescale_item(get_derived_widget(builder, "_shapescale_item"))
+ , _shape_box(get_widget(builder, "shape_box"))
+ , _shape_item(get_derived_widget(builder, "shape-list"))
+ , _cap_box(get_widget(builder, "powerstroke_cap_box"))
+ , _cap_item(get_derived_widget(builder, "cap-list"))
{
auto prefs = Preferences::get();
@@ -139,40 +142,23 @@ PencilToolbar::PencilToolbar(Glib::RefPtr const &builder, bool pen
_initMenuBtns();
}
-void PencilToolbar::add_powerstroke_cap(Glib::RefPtr const &builder)
-{
+void PencilToolbar::add_powerstroke_cap(Glib::RefPtr const &builder) {
// Powerstroke cap combo tool item.
- UI::Widget::ComboToolItemColumns columns;
-
- auto store = Gtk::ListStore::create(columns);
-
for (auto item : std::vector{C_("Cap", "Butt"), _("Square"), _("Round"), _("Peak"), _("Zero width")}) {
- Gtk::TreeModel::Row row = *store->append();
- row[columns.col_label] = item;
- row[columns.col_sensitive] = true;
+ _cap_item.append(item);
}
- _cap_item = Gtk::manage(UI::Widget::ComboToolItem::create(
- _("Caps"), _("Line endings when drawing with pressure-sensitive PowerPencil"), "Not Used", store));
-
auto prefs = Preferences::get();
int cap = prefs->getInt("/live_effects/powerstroke/powerpencilcap", 2);
- _cap_item->set_active(cap);
- _cap_item->use_group_label(true);
+ _cap_item.set_selected(cap);
- _cap_item->signal_changed().connect(sigc::mem_fun(*this, &PencilToolbar::change_cap));
-
- get_widget(builder, "powerstroke_cap_box").append(*_cap_item);
+ _cap_item.signal_changed().connect([this] { change_cap(_cap_item.get_selected()); });
}
void PencilToolbar::add_shape_option(Glib::RefPtr const &builder)
{
- UI::Widget::ComboToolItemColumns columns;
-
- auto store = Gtk::ListStore::create(columns);
-
- std::vector freehand_shape_dropdown_items_list = {(C_("Freehand shape", "None")),
+ std::array freehand_shape_dropdown_items_list = {(C_("Freehand shape", "None")),
_("Triangle in"),
_("Triangle out"),
_("Ellipse"),
@@ -181,21 +167,14 @@ void PencilToolbar::add_shape_option(Glib::RefPtr const &builder)
_("Last applied")};
for (auto item : freehand_shape_dropdown_items_list) {
- Gtk::TreeModel::Row row = *store->append();
- row[columns.col_label] = item;
- row[columns.col_sensitive] = true;
+ _shape_item.append(item);
}
- _shape_item = Gtk::manage(
- UI::Widget::ComboToolItem::create(_("Shape"), _("Shape of new paths drawn by this tool"), "Not Used", store));
- _shape_item->use_group_label(true);
-
int shape =
Preferences::get()->getInt(_tool_is_pencil ? "/tools/freehand/pencil/shape" : "/tools/freehand/pen/shape", 0);
- _shape_item->set_active(shape);
+ _shape_item.set_selected(shape);
- _shape_item->signal_changed().connect(sigc::mem_fun(*this, &PencilToolbar::change_shape));
- get_widget(builder, "shape_box").append(*_shape_item);
+ _shape_item.signal_changed().connect([this] { change_shape(_shape_item.get_selected()); });
}
void PencilToolbar::setup_derived_spin_button(UI::Widget::SpinButton &btn, Glib::ustring const &name,
@@ -317,7 +296,7 @@ void PencilToolbar::shapewidth_value_changed()
double width = _shapescale_item.get_adjustment()->get_value();
using namespace LivePathEffect;
- switch (_shape_item->get_active()) {
+ switch (_shape_item.get_selected()) {
case Tools::TRIANGLE_IN:
case Tools::TRIANGLE_OUT:
prefs->setDouble("/live_effects/powerstroke/width", width);
@@ -368,8 +347,8 @@ void PencilToolbar::use_pencil_pressure()
_minpressure_box.set_visible(pressure);
_maxpressure_box.set_visible(pressure);
- _cap_item->set_visible(pressure);
- _shape_item->set_visible(!pressure);
+ _cap_box.set_visible(pressure);
+ _shape_box.set_visible(!pressure);
_shapescale_box.set_visible(!pressure);
if (pressure) {
diff --git a/src/ui/toolbar/pencil-toolbar.h b/src/ui/toolbar/pencil-toolbar.h
index 03740e28fefbf6a8101b038a13f14cb1f20a5a04..90d79d17a292afe4ccc5f92e99e37b4a7bc2ef28 100644
--- a/src/ui/toolbar/pencil-toolbar.h
+++ b/src/ui/toolbar/pencil-toolbar.h
@@ -40,8 +40,8 @@ class ToggleButton;
namespace Inkscape {
namespace UI::Widget {
+class DropDownList;
class SpinButton;
-class ComboToolItem;
} // namespace UI::Widget
namespace XML { class Node; }
} // namespace Inkscape
@@ -70,12 +70,14 @@ private:
UI::Widget::SpinButton &_minpressure_item;
Gtk::Box &_maxpressure_box;
UI::Widget::SpinButton &_maxpressure_item;
- UI::Widget::ComboToolItem *_cap_item;
+ UI::Widget::DropDownList& _cap_item;
+ Gtk::Box& _cap_box;
UI::Widget::SpinButton &_tolerance_item;
Gtk::ToggleButton &_simplify_btn;
Gtk::Button &_flatten_simplify_btn;
- UI::Widget::ComboToolItem *_shape_item;
+ UI::Widget::DropDownList& _shape_item;
+ Gtk::Box& _shape_box;
Gtk::Box &_shapescale_box;
UI::Widget::SpinButton &_shapescale_item;
bool _set_shape = false;
diff --git a/src/ui/toolbar/rect-toolbar.cpp b/src/ui/toolbar/rect-toolbar.cpp
index c1bc5c9ff4403b6f4e1c95f3b0245d47ec1e8c3b..89750ab3c9cae026bff23ccc2ee7d71cd948cfb3 100644
--- a/src/ui/toolbar/rect-toolbar.cpp
+++ b/src/ui/toolbar/rect-toolbar.cpp
@@ -39,7 +39,6 @@
#include "selection.h"
#include "ui/builder-utils.h"
#include "ui/icon-names.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/ui/toolbar/star-toolbar.cpp b/src/ui/toolbar/star-toolbar.cpp
index fcfd31028b88753a38d45586694bf8e20bfb624a..c1d1a6c61c7c3ab79ff4ac16bda296c57cb4c403 100644
--- a/src/ui/toolbar/star-toolbar.cpp
+++ b/src/ui/toolbar/star-toolbar.cpp
@@ -39,7 +39,6 @@
#include "selection.h"
#include "ui/builder-utils.h"
#include "ui/icon-names.h"
-#include "ui/widget/combo-tool-item.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp
index 1e54040ddc51846e782112765ad3e5525312813b..1f342200ba7b3a285ea3f48b0b2ff5a23beecdc3 100644
--- a/src/ui/widget/color-notebook.cpp
+++ b/src/ui/widget/color-notebook.cpp
@@ -30,7 +30,7 @@
#include "ui/util.h"
#include "ui/widget/color-entry.h"
#include "ui/widget/color-page.h"
-#include "ui/widget/icon-combobox.h"
+#include "ui/widget/generic/icon-combobox.h"
static constexpr int XPAD = 2;
static constexpr int YPAD = 1;
diff --git a/src/ui/widget/color-picker-panel.cpp b/src/ui/widget/color-picker-panel.cpp
index 46386ef63d69aae73bd51a66679d88462ad87db1..db2200552a596bc436a284f7f139979cbac19ad2 100644
--- a/src/ui/widget/color-picker-panel.cpp
+++ b/src/ui/widget/color-picker-panel.cpp
@@ -18,7 +18,7 @@
#include "color-page.h"
#include "color-wheel.h"
#include "desktop.h"
-#include "icon-combobox.h"
+#include "generic/icon-combobox.h"
#include "generic/spin-button.h"
#include "inkscape.h"
#include "colors/color.h"
diff --git a/src/ui/widget/icon-combobox.cpp b/src/ui/widget/generic/icon-combobox.cpp
similarity index 86%
rename from src/ui/widget/icon-combobox.cpp
rename to src/ui/widget/generic/icon-combobox.cpp
index bc4266891fb3ed3e7d2b1db566690b809571b05e..592ff799f908f995bde4b75561659f48cb5da92d 100644
--- a/src/ui/widget/icon-combobox.cpp
+++ b/src/ui/widget/generic/icon-combobox.cpp
@@ -12,38 +12,22 @@
namespace Inkscape::UI::Widget {
-struct IconComboBox::ListItem : public Glib::Object {
- int id;
- Glib::ustring label;
- Glib::ustring short_name;
- Glib::ustring icon; // icon's name to load if icons have been enabled
- Glib::RefPtr image; // image to present instead of icon if icons are disabled
- bool is_visible = true;
-
- static Glib::RefPtr create(
- int id,
- Glib::ustring label,
- Glib::ustring short_name,
- Glib::ustring icon,
- Glib::RefPtr image
- ) {
- auto item = Glib::make_refptr_for_instance(new ListItem());
- item->id = id;
- item->label = label;
- item->short_name = short_name;
- item->icon = icon;
- item->image = image;
- return item;
- }
-private:
- ListItem() {}
-};
+IconComboBox::IconComboBox(Glib::RefPtr> store, bool use_icons, HeaderType header) {
+ construct(store, use_icons, header);
+}
-IconComboBox::IconComboBox(bool use_icons, HeaderType header)
-{
+IconComboBox::IconComboBox(bool use_icons, HeaderType header) {
+ construct({}, use_icons, header);
+}
+
+IconComboBox::IconComboBox(BaseObjectType* cobject, const Glib::RefPtr&, Glib::RefPtr> store, bool use_icons, HeaderType header): Gtk::DropDown(cobject) {
+ construct(store, use_icons, header);
+}
+
+void IconComboBox::construct(Glib::RefPtr> store, bool use_icons, HeaderType header) {
_factory = Gtk::SignalListItemFactory::create();
- auto set_up_image = [=](Gtk::Box& box, int size, bool center) {
+ auto set_up_image = [=](Gtk::Box& box, Geom::Point size, bool center) {
if (use_icons) {
auto icon = Gtk::make_managed();
icon->set_icon_size(Gtk::IconSize::NORMAL);
@@ -57,8 +41,7 @@ IconComboBox::IconComboBox(bool use_icons, HeaderType header)
else {
auto image = Gtk::make_managed();
image->set_layout_manager(Gtk::BinLayout::create());
- // int size = get_image_size();
- image->set_size_request(size, size);
+ image->set_size_request(size.x(), size.y());
image->set_can_shrink(true);
image->set_content_fit(Gtk::ContentFit::CONTAIN);
image->set_valign(Gtk::Align::CENTER);
@@ -71,7 +54,7 @@ IconComboBox::IconComboBox(bool use_icons, HeaderType header)
}
};
- _factory->signal_setup().connect([=](const Glib::RefPtr& list_item) {
+ _factory->signal_setup().connect([this, set_up_image](const Glib::RefPtr& list_item) {
auto box = Gtk::make_managed();
box->add_css_class("item-box");
box->set_orientation(Gtk::Orientation::HORIZONTAL);
@@ -120,7 +103,9 @@ IconComboBox::IconComboBox(bool use_icons, HeaderType header)
dynamic_cast(*first).set_from_icon_name(item->icon);
}
else {
- dynamic_cast(*first).set_paintable(item->image);
+ auto& picture = dynamic_cast(*first);
+ picture.set_paintable(item->image);
+ picture.set_visible(!!item->image);
}
label.set_label(item->label);
});
@@ -131,7 +116,7 @@ IconComboBox::IconComboBox(bool use_icons, HeaderType header)
// show only icon in closed combobox
_compact_factory = Gtk::SignalListItemFactory::create();
- _compact_factory->signal_setup().connect([=](const Glib::RefPtr& list_item) {
+ _compact_factory->signal_setup().connect([this, set_up_image](const Glib::RefPtr& list_item) {
auto box = Gtk::make_managed();
box->add_css_class("item-box");
box->set_orientation(Gtk::Orientation::HORIZONTAL);
@@ -181,7 +166,7 @@ IconComboBox::IconComboBox(bool use_icons, HeaderType header)
set_factory(_factory);
}
- _store = Gio::ListStore::create();
+ _store = store ? store : Gio::ListStore::create();
_filter = Gtk::BoolFilter::create({});
_filtered_model = Gtk::FilterListModel::create(_store, _filter);
_selection_model = Gtk::SingleSelection::create(_filtered_model);
diff --git a/src/ui/widget/generic/icon-combobox.h b/src/ui/widget/generic/icon-combobox.h
new file mode 100644
index 0000000000000000000000000000000000000000..fec1e5bfa2a2bae07c69ca973b417e09e5ad5fe8
--- /dev/null
+++ b/src/ui/widget/generic/icon-combobox.h
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#ifndef SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
+#define SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include <2geom/point.h>
+
+namespace Gtk {
+class Builder;
+}
+
+namespace Inkscape::UI::Widget {
+
+class IconComboBox : public Gtk::DropDown
+{
+public:
+ // Items in a store used by IconComboBox
+ struct ListItem;
+ // What to show in a closed dropdown:
+ enum HeaderType { ImageLabel, ImageOnly, LabelOnly };
+ // Custom drop down list with icons/images and labels
+ IconComboBox(bool use_icons = true, HeaderType header = ImageLabel);
+ // Ditto, but uses supplied store
+ IconComboBox(Glib::RefPtr> store, bool use_icons = true, HeaderType header = ImageLabel);
+ IconComboBox(BaseObjectType* cobject, const Glib::RefPtr& builder, Glib::RefPtr> store = {}, bool use_icons = true, HeaderType header = ImageLabel);
+ ~IconComboBox() override;
+
+ // helper methods to populate store
+ void add_row(Glib::ustring const &icon_name, Glib::ustring const &label, int id);
+ void add_row(const Glib::ustring& icon_name, const Glib::ustring& full_name, const Glib::ustring& short_name, int id);
+ void add_row(Cairo::RefPtr image, const Glib::ustring& label, int id);
+ // Set selected (aka active) item
+ void set_active_by_id(int id);
+ // Show/hide an item in store
+ void set_row_visible(int id, bool visible = true, bool refilter_items = true);
+ // Get selected item's ID
+ int get_active_row_id() const;
+ std::shared_ptr current_item();
+ // return signal to selection change event; it reports ID of current item
+ sigc::signal& signal_changed();
+ // get default image size
+ static int get_default_image_size() { return 16; }
+ // establish logical image size for all pictures in the list
+ void set_image_size(Geom::Point size) { _image_size = size; }
+ Geom::Point get_image_size() const { return _image_size; }
+ // add frame
+ void set_has_frame(bool frame);
+ // apply filter to show items after adding them
+ void refilter();
+
+private:
+ void construct(Glib::RefPtr> store, bool use_icons, HeaderType header);
+ bool is_item_visible(const Glib::RefPtr& item) const;
+ std::pair, int> find_by_id(int id, bool visible_only);
+
+ Geom::Point _image_size{16, 16};
+ Glib::RefPtr _factory;
+ Glib::RefPtr _compact_factory;
+ Glib::RefPtr _filtered_model;
+ Glib::RefPtr _selection_model;
+ Glib::RefPtr _filter;
+ Glib::RefPtr> _store;
+ sigc::signal _signal_current_changed = sigc::signal();
+};
+
+struct IconComboBox::ListItem : Glib::Object {
+ int id; // user-defined ID or index
+ Glib::ustring label; // label to show after icon/image
+ Glib::ustring short_name; // short name to use in a header (closed dropdown) when header type was 'LabelOnly'
+ Glib::ustring icon; // icon's name to load if icons have been enabled
+ Glib::RefPtr image; // image to present instead of icon if icons are disabled
+ bool is_visible = true; // true if item is to be visible/included
+ std::string uid; // user-defined unique ID (optional)
+ void* data = nullptr; // user-defined data (optional)
+
+ static Glib::RefPtr create(
+ int id,
+ Glib::ustring label,
+ Glib::RefPtr image
+ ) {
+ return create(id, label, {}, {}, image);
+ }
+ static Glib::RefPtr create(
+ int id,
+ Glib::ustring label,
+ Glib::ustring short_name,
+ Glib::ustring icon,
+ Glib::RefPtr image
+ ) {
+ auto item = Glib::make_refptr_for_instance(new ListItem());
+ item->id = id;
+ item->label = label;
+ item->short_name = short_name;
+ item->icon = icon;
+ item->image = image;
+ return item;
+ }
+private:
+ ListItem() {}
+};
+
+} // namespace Inkscape::UI::Widget
+
+#endif // SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/ui/widget/gradient-editor.cpp b/src/ui/widget/gradient-editor.cpp
index 0515e8cd01cc62bcf71aa4e4635dc65636aa5a4c..602cc6f86dba50333e65648f969c8f82e2b3cd64 100644
--- a/src/ui/widget/gradient-editor.cpp
+++ b/src/ui/widget/gradient-editor.cpp
@@ -36,23 +36,13 @@ namespace Inkscape::UI::Widget {
using namespace Inkscape::IO;
using Inkscape::UI::Widget::ColorNotebook;
-Glib::ustring get_repeat_icon(SPGradientSpread mode) {
- const char* ico = "";
- switch (mode) {
- case SP_GRADIENT_SPREAD_PAD:
- ico = "gradient-spread-pad";
- break;
- case SP_GRADIENT_SPREAD_REPEAT:
- ico = "gradient-spread-repeat";
- break;
- case SP_GRADIENT_SPREAD_REFLECT:
- ico = "gradient-spread-reflect";
- break;
- default:
- g_warning("Missing case in %s\n", __func__);
- break;
- }
- return ico;
+const std::array, 3>& sp_get_spread_repeats() {
+ static auto const repeats = std::to_array({std::tuple
+ {SP_GRADIENT_SPREAD_PAD , C_("Gradient repeat type", "None"), "gradient-spread-pad"},
+ {SP_GRADIENT_SPREAD_REPEAT , C_("Gradient repeat type", "Direct"), "gradient-spread-repeat"},
+ {SP_GRADIENT_SPREAD_REFLECT, C_("Gradient repeat type", "Reflected"), "gradient-spread-reflect"},
+ });
+ return repeats;
}
GradientEditor::GradientEditor(const char* prefs, Space::Type space, bool show_type_selector, bool show_colorwheel_expander):
@@ -137,13 +127,7 @@ GradientEditor::GradientEditor(const char* prefs, Space::Type space, bool show_t
});
// connect gradient repeat modes menu
- static auto const repeats = std::to_array({std::pair
- {SP_GRADIENT_SPREAD_PAD , _("None" )},
- {SP_GRADIENT_SPREAD_REPEAT , _("Direct" )},
- {SP_GRADIENT_SPREAD_REFLECT, _("Reflected")}
- });
- for (auto [mode, text] : repeats) {
- auto const icon = get_repeat_icon(mode);
+ for (auto [mode, text, icon] : sp_get_spread_repeats()) {
auto const item = Gtk::make_managed(text, false, icon);
item->signal_activate().connect([this, mode]{ set_repeat_mode(mode); });
_repeat_popover->append(*item);
@@ -345,7 +329,7 @@ void GradientEditor::set_repeat_mode(SPGradientSpread mode) {
}
void GradientEditor::set_repeat_icon(SPGradientSpread mode) {
- auto icon = get_repeat_icon(mode);
+ auto icon = std::get<2>(sp_get_spread_repeats()[mode]);
_repeat_mode_btn.set_icon_name(icon);
}
diff --git a/src/ui/widget/gradient-editor.h b/src/ui/widget/gradient-editor.h
index c25281a43bf9b60f09da7b904e4214bacbfe391b..2e4f114f900aaee5a925a3723e00e4f03f7d8fb1 100644
--- a/src/ui/widget/gradient-editor.h
+++ b/src/ui/widget/gradient-editor.h
@@ -117,6 +117,9 @@ private:
Gtk::MenuButton& _repeat_mode_btn;
};
+// SPGradientSpread modes, names and icons
+const std::array, 3>& sp_get_spread_repeats();
+
} // namespace Inkscape::UI::Widget
#endif // SEEN_GRADIENT_EDITOR_H
diff --git a/src/ui/widget/gradient-image.cpp b/src/ui/widget/gradient-image.cpp
index 73bab2ceccd3466719c52da42b3ea2e814d08301..c7b6a43363a93ce497bf65db172a2ab750ba9296 100644
--- a/src/ui/widget/gradient-image.cpp
+++ b/src/ui/widget/gradient-image.cpp
@@ -108,11 +108,20 @@ sp_gradient_to_pixbuf_ref (SPGradient *gr, int width, int height)
return Glib::wrap(sp_gradient_to_pixbuf(gr, width, height));
}
-Glib::RefPtr
-sp_gradstop_to_pixbuf_ref (SPStop *stop, int width, int height)
+Cairo::RefPtr sp_gradient_to_surface(SPGradient* gr, int width, int height) {
+ auto surface = Cairo::ImageSurface::create(Cairo::ImageSurface::Format::ARGB32, width, height);
+ auto ctx = Cairo::Context::create(surface);
+ sp_gradient_draw(gr, width, height, ctx->cobj());
+ surface->flush();
+
+ return surface;
+}
+
+Cairo::RefPtr sp_gradstop_to_surface(SPStop *stop, int width, int height)
{
- cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
- cairo_t *ct = cairo_create(s);
+ auto surface = Cairo::ImageSurface::create(Cairo::ImageSurface::Format::ARGB32, width, height);
+ auto ctx = Cairo::Context::create(surface);
+ cairo_t *ct = ctx->cobj();
/* Checkerboard background */
auto check = ink_cairo_pattern_create_checkerboard();
@@ -134,16 +143,9 @@ sp_gradstop_to_pixbuf_ref (SPStop *stop, int width, int height)
cairo_fill(ct);
}
- cairo_destroy(ct);
- cairo_surface_flush(s);
-
- Cairo::RefPtr sref = Cairo::RefPtr(new Cairo::Surface(s));
- Glib::RefPtr pixbuf =
- Gdk::Pixbuf::create(sref, 0, 0, width, height);
+ surface->flush();
- cairo_surface_destroy(s);
-
- return pixbuf;
+ return surface;
}
/*
diff --git a/src/ui/widget/gradient-image.h b/src/ui/widget/gradient-image.h
index 7b7747f2bdc872b2f37268320c37ad8226d11a2c..e224b72c5fc2b5051e3d51c25044bb78650b7c67 100644
--- a/src/ui/widget/gradient-image.h
+++ b/src/ui/widget/gradient-image.h
@@ -47,7 +47,8 @@ void sp_gradient_draw (SPGradient *gr, int width,
cairo_t *ct);
GdkPixbuf *sp_gradient_to_pixbuf (SPGradient *gr, int width, int height);
Glib::RefPtr sp_gradient_to_pixbuf_ref(SPGradient *gr, int width, int height);
-Glib::RefPtr sp_gradstop_to_pixbuf_ref(SPStop *gr, int width, int height);
+Cairo::RefPtr sp_gradient_to_surface(SPGradient* gr, int width, int height);
+Cairo::RefPtr sp_gradstop_to_surface(SPStop *stop, int width, int height);
#endif // SEEN_SP_GRADIENT_IMAGE_H
diff --git a/src/ui/widget/icon-combobox.h b/src/ui/widget/icon-combobox.h
deleted file mode 100644
index a8a57b518075dce98aa9e2c34baa8eb8f08a49a1..0000000000000000000000000000000000000000
--- a/src/ui/widget/icon-combobox.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#ifndef SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
-#define SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace Inkscape::UI::Widget {
-
-class IconComboBox : public Gtk::DropDown
-{
-public:
- enum HeaderType { ImageLabel, ImageOnly, LabelOnly };
- IconComboBox(bool use_icons = true, HeaderType header = ImageLabel);
- ~IconComboBox() override;
-
- void add_row(Glib::ustring const &icon_name, Glib::ustring const &label, int id);
- void add_row(const Glib::ustring& icon_name, const Glib::ustring& full_name, const Glib::ustring& short_name, int id);
- void add_row(Cairo::RefPtr image, const Glib::ustring& label, int id);
- void set_active_by_id(int id);
- void set_row_visible(int id, bool visible = true, bool refilter_items = true);
- int get_active_row_id() const;
- // return signal to selection change event; it reports ID of current item
- sigc::signal& signal_changed();
-
- static int get_image_size() { return 16; }
- void set_has_frame(bool frame);
- void refilter();
-
-private:
- struct ListItem;
- bool is_item_visible(const Glib::RefPtr& item) const;
- std::pair, int> find_by_id(int id, bool visible_only);
- std::shared_ptr current_item();
-
- Glib::RefPtr _factory;
- Glib::RefPtr _compact_factory;
- Glib::RefPtr _filtered_model;
- Glib::RefPtr _selection_model;
- Glib::RefPtr _filter;
- Glib::RefPtr> _store;
- sigc::signal _signal_current_changed = sigc::signal();
-};
-
-} // namespace Inkscape::UI::Widget
-
-#endif // SEEN_INKSCAPE_UI_WIDGET_ICONCOMBOBOX
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
diff --git a/src/ui/widget/multi-marker-color-plate.cpp b/src/ui/widget/multi-marker-color-plate.cpp
index 449113d19c5c167388e5fe9a5626d85a6db37a0b..97cd02186e7ed1792e6142ca4fd7db4a5c0e948e 100644
--- a/src/ui/widget/multi-marker-color-plate.cpp
+++ b/src/ui/widget/multi-marker-color-plate.cpp
@@ -13,7 +13,7 @@
#include "ui/widget/color-page.h"
#include "ui/widget/color-preview.h"
#include "ui/widget/color-slider.h"
-#include "ui/widget/icon-combobox.h"
+#include "ui/widget/generic/icon-combobox.h"
#include "ui/widget/generic/spin-button.h"
namespace Inkscape::UI::Widget {
diff --git a/src/ui/widget/multi-marker-color-plate.h b/src/ui/widget/multi-marker-color-plate.h
index fb390ff1f85318bfbfaf250ae4b7bcba7b3b51b4..6d0def114aa73471b6c96059ad938afd9225bd14 100644
--- a/src/ui/widget/multi-marker-color-plate.h
+++ b/src/ui/widget/multi-marker-color-plate.h
@@ -18,7 +18,7 @@
#include "colors/manager.h"
#include "ui/widget/color-page.h"
#include "ui/widget/color-preview.h"
-#include "ui/widget/icon-combobox.h"
+#include "ui/widget/generic/icon-combobox.h"
#include "ui/widget/ink-color-wheel.h"
#include "recolor-art.h"
diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h
index 2cc0d11594bdaca77cf7d61d90a92b085f89a99f..dfa20b8bc0f0427c8d61eaa6dea8d0dda1e17ce7 100644
--- a/src/ui/widget/unit-tracker.h
+++ b/src/ui/widget/unit-tracker.h
@@ -36,8 +36,6 @@ class ListStore;
namespace Inkscape::UI::Widget {
-class ComboToolItem;
-
class UnitTracker {
public:
UnitTracker(UnitType unit_type);