summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/CMakeLists.txt11
-rw-r--r--src/widgets/Makefile_insert10
-rw-r--r--src/widgets/arc-toolbar.cpp8
-rw-r--r--src/widgets/connector-toolbar.cpp14
-rw-r--r--src/widgets/desktop-widget.cpp80
-rw-r--r--src/widgets/desktop-widget.h4
-rw-r--r--src/widgets/eraser-toolbar.cpp82
-rw-r--r--src/widgets/fill-style.cpp12
-rw-r--r--src/widgets/gradient-selector.cpp21
-rw-r--r--src/widgets/gradient-toolbar.cpp69
-rw-r--r--src/widgets/gradient-vector.cpp11
-rw-r--r--src/widgets/measure-toolbar.cpp341
-rw-r--r--src/widgets/mesh-toolbar.cpp95
-rw-r--r--src/widgets/paint-selector.cpp10
-rw-r--r--src/widgets/pencil-toolbar.cpp129
-rw-r--r--src/widgets/rect-toolbar.cpp4
-rw-r--r--src/widgets/ruler.cpp344
-rw-r--r--src/widgets/select-toolbar.cpp159
-rw-r--r--src/widgets/sp-color-selector.cpp4
-rw-r--r--src/widgets/sp-color-selector.h4
-rw-r--r--src/widgets/sp-xmlview-attr-list.cpp2
-rw-r--r--src/widgets/spiral-toolbar.cpp4
-rw-r--r--src/widgets/spray-toolbar.cpp391
-rw-r--r--src/widgets/spray-toolbar.h2
-rw-r--r--src/widgets/star-toolbar.cpp24
-rw-r--r--src/widgets/stroke-style.cpp225
-rw-r--r--src/widgets/stroke-style.h11
-rw-r--r--src/widgets/text-toolbar.cpp270
-rw-r--r--src/widgets/toolbox.cpp96
-rw-r--r--src/widgets/tweak-toolbar.cpp26
30 files changed, 1950 insertions, 513 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index a3e9e14d0..c38bde5cf 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -11,7 +11,6 @@ set(widgets_SRC
measure-toolbar.cpp
mesh-toolbar.cpp
node-toolbar.cpp
- paintbucket-toolbar.cpp
pencil-toolbar.cpp
rect-toolbar.cpp
spiral-toolbar.cpp
@@ -67,7 +66,6 @@ set(widgets_SRC
measure-toolbar.h
mesh-toolbar.h
node-toolbar.h
- paintbucket-toolbar.h
pencil-toolbar.h
rect-toolbar.h
spiral-toolbar.h
@@ -114,3 +112,12 @@ set(widgets_SRC
# add_inkscape_lib(widgets_LIB "${widgets_SRC}")
add_inkscape_source("${widgets_SRC}")
+
+set ( widgets_paintbucket_SRC
+ paintbucket-toolbar.cpp
+ paintbucket-toolbar.h
+)
+
+if ("${HAVE_POTRACE}")
+ add_inkscape_source("${widgets_paintbucket_SRC}")
+endif()
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index f66be66ed..6913f4a58 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -58,8 +58,6 @@ ink_common_sources += \
widgets/node-toolbar.h \
widgets/paint-selector.cpp \
widgets/paint-selector.h \
- widgets/paintbucket-toolbar.cpp \
- widgets/paintbucket-toolbar.h \
widgets/pencil-toolbar.cpp \
widgets/pencil-toolbar.h \
widgets/rect-toolbar.cpp \
@@ -109,5 +107,13 @@ ink_common_sources += \
widgets/zoom-toolbar.h \
widgets/widget-sizes.h
+if HAVE_POTRACE
+
+ink_common_sources += \
+ widgets/paintbucket-toolbar.cpp \
+ widgets/paintbucket-toolbar.h
+
+endif
+
widgets/button.$(OBJEXT): helper/sp-marshal.h
widgets/menu.$(OBJEXT): helper/sp-marshal.h
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index 71418e238..7b872e8b1 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -98,7 +98,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
@@ -164,7 +164,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
if ( ege_select_one_action_get_active(act) != 0 ) {
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -175,7 +175,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
}
} else {
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -265,7 +265,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb
purge_repr_listener( tbl, tbl );
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_GENERICELLIPSE(item)) {
n_selected++;
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 1c99f283d..733fb34e8 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -98,7 +98,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
@@ -145,7 +145,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
@@ -200,17 +200,15 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
desktop->namedview->updateRepr();
bool modmade = false;
- GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop);
- for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) {
- SPItem *item = reinterpret_cast<SPItem *>(iter->data);
+ std::vector<SPItem *> items;
+ items = get_avoided_items(items, desktop->currentRoot(), desktop);
+ for (std::vector<SPItem *>::const_iterator iter = items.begin(); iter != items.end(); ++iter ) {
+ SPItem *item = *iter;
Geom::Affine m = Geom::identity();
avoid_item_move(&m, item);
modmade = true;
}
- if (items) {
- g_slist_free(items);
- }
if(modmade) {
DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
_("Change connector spacing"));
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index e19f56e48..1fdd3ca6d 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -70,6 +70,9 @@
#include "widget-sizes.h"
#include "verbs.h"
+#if GTK_CHECK_VERSION(3,0,0)
+# include <gtkmm/cssprovider.h>
+#endif
#include <gtkmm/paned.h>
#include <gtkmm/messagedialog.h>
@@ -107,6 +110,7 @@ static void sp_desktop_widget_realize (GtkWidget *widget);
static gint sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw);
static void sp_dtw_color_profile_event(EgeColorProfTracker *widget, SPDesktopWidget *dtw);
+static void sp_update_guides_lock( GtkWidget *button, gpointer data );
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
static void cms_adjust_toggled( GtkWidget *button, gpointer data );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
@@ -390,6 +394,19 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->tool_toolbox = ToolboxFactory::createToolToolbox();
ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 );
+ // Lock guides button
+ dtw->guides_lock = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
+ SP_BUTTON_TYPE_TOGGLE,
+ NULL,
+ INKSCAPE_ICON("object-locked"),
+ _("Toggle lock of all guides in the document"));
+#if GTK_CHECK_VERSION(3,0,0)
+ Glib::RefPtr<Gtk::CssProvider> guides_lock_style_provider = Gtk::CssProvider::create();
+ guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }");
+ Gtk::Widget * wnd = Glib::wrap(dtw->guides_lock);
+ Glib::RefPtr<Gtk::StyleContext> context = wnd->get_style_context();
+ context->add_provider(guides_lock_style_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
/* Horizontal ruler */
GtkWidget *eventbox = gtk_event_box_new ();
@@ -407,23 +424,31 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
GtkWidget *tbl = gtk_grid_new();
dtw->canvas_tbl = gtk_grid_new();
+ gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->guides_lock, 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1);
#else
GtkWidget *tbl = gtk_table_new(2, 3, FALSE);
dtw->canvas_tbl = gtk_table_new(3, 3, FALSE);
gtk_table_attach(GTK_TABLE(dtw->canvas_tbl),
- eventbox,
- 1, 2, 0, 1,
+ dtw->guides_lock,
+ 0, 1, 0, 1,
GTK_FILL, GTK_FILL,
0, 0);
+ gtk_table_attach(GTK_TABLE(dtw->canvas_tbl),
+ eventbox,
+ 1, 2, 0, 1,
+ GTK_FILL, GTK_FILL,
+ 0, 0);
#endif
-
+ g_signal_connect (G_OBJECT (dtw->guides_lock), "toggled", G_CALLBACK (sp_update_guides_lock), dtw);
gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 );
/* Vertical ruler */
eventbox = gtk_event_box_new ();
dtw->vruler = sp_ruler_new(GTK_ORIENTATION_VERTICAL);
+
+ /* Vertical ruler */
dtw->vruler_box = eventbox;
sp_ruler_set_unit (SP_RULER (dtw->vruler), pt);
gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(pt->name_plural.c_str()));
@@ -446,6 +471,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Horizontal scrollbar
dtw->hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, -4000.0, 4000.0, 10.0, 100.0, 4.0));
+
+
+
#if GTK_CHECK_VERSION(3,0,0)
dtw->hscrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (dtw->hadj));
gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1);
@@ -1015,6 +1043,7 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt
return FALSE;
}
+
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidget *dtw)
{
@@ -1036,6 +1065,27 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge
}
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
+void sp_update_guides_lock( GtkWidget */*button*/, gpointer data )
+{
+ SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data);
+
+ bool down = SP_BUTTON_IS_DOWN(dtw->guides_lock);
+
+ SPDocument *doc = dtw->desktop->getDocument();
+ SPNamedView *nv = dtw->desktop->getNamedView();
+ Inkscape::XML::Node *repr = nv->getRepr();
+
+ if ( down != nv->lockguides ) {
+ nv->lockguides = down;
+ sp_namedview_guides_toggle_lock(doc, repr);
+ if (down) {
+ dtw->setMessage (Inkscape::NORMAL_MESSAGE, _("Locked all guides"));
+ } else {
+ dtw->setMessage (Inkscape::NORMAL_MESSAGE, _("Unlocked all guides"));
+ }
+ }
+}
+
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
void cms_adjust_toggled( GtkWidget */*button*/, gpointer data )
{
@@ -1450,7 +1500,6 @@ sp_desktop_widget_maximize(SPDesktopWidget *dtw)
void
sp_desktop_widget_fullscreen(SPDesktopWidget *dtw)
{
-#ifdef HAVE_GTK_WINDOW_FULLSCREEN
GtkWindow *topw = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(dtw->canvas)));
if (GTK_IS_WINDOW(topw)) {
if (dtw->desktop->is_fullscreen()) {
@@ -1474,7 +1523,6 @@ sp_desktop_widget_fullscreen(SPDesktopWidget *dtw)
// widget layout is triggered by the resulting window_state_event
}
}
-#endif /* HAVE_GTK_WINDOW_FULLSCREEN */
}
/**
@@ -1549,9 +1597,11 @@ void SPDesktopWidget::layoutWidgets()
}
if (!prefs->getBool(pref_root + "rulers/state", true)) {
+ gtk_widget_hide (dtw->guides_lock);
gtk_widget_hide (dtw->hruler);
gtk_widget_hide (dtw->vruler);
} else {
+ gtk_widget_show_all (dtw->guides_lock);
gtk_widget_show_all (dtw->hruler);
gtk_widget_show_all (dtw->vruler);
}
@@ -1684,6 +1734,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
/* Once desktop is set, we can update rulers */
sp_desktop_widget_update_rulers (dtw);
+ sp_button_toggle_set_down( SP_BUTTON(dtw->guides_lock), namedview->lockguides );
sp_view_widget_set_view (SP_VIEW_WIDGET (dtw), dtw->desktop);
@@ -1813,9 +1864,9 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/bitmapautoreload/value", true)) {
- GSList const *imageList = (desktop->doc())->getResourceList("image");
- for (GSList const *p = imageList; p; p = p->next) {
- SPImage* image = SP_IMAGE(p->data);
+ std::set<SPObject *> imageList = (desktop->doc())->getResourceList("image");
+ for (std::set<SPObject *>::const_iterator it = imageList.begin(); it != imageList.end(); ++it) {
+ SPImage* image = SP_IMAGE(*it);
sp_image_refresh_if_outdated( image );
}
}
@@ -2039,11 +2090,13 @@ void
sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (gtk_widget_get_visible (dtw->hruler)) {
+ if (gtk_widget_get_visible (dtw->guides_lock)) {
+ gtk_widget_hide (dtw->guides_lock);
gtk_widget_hide (dtw->hruler);
gtk_widget_hide (dtw->vruler);
prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", false);
} else {
+ gtk_widget_show_all (dtw->guides_lock);
gtk_widget_show_all (dtw->hruler);
gtk_widget_show_all (dtw->vruler);
prefs->setBool(dtw->desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state", true);
@@ -2075,7 +2128,6 @@ bool sp_desktop_widget_color_prof_adj_enabled( SPDesktopWidget *dtw )
void sp_desktop_widget_toggle_color_prof_adj( SPDesktopWidget *dtw )
{
-
if ( gtk_widget_get_sensitive( dtw->cms_adjust ) ) {
if ( SP_BUTTON_IS_DOWN(dtw->cms_adjust) ) {
sp_button_toggle_set_down( SP_BUTTON(dtw->cms_adjust), FALSE );
@@ -2085,6 +2137,14 @@ void sp_desktop_widget_toggle_color_prof_adj( SPDesktopWidget *dtw )
}
}
+void sp_desktop_widget_toggle_guides_lock( SPDesktopWidget *dtw )
+{
+ if ( SP_BUTTON_IS_DOWN(dtw->guides_lock) ) {
+ sp_button_toggle_set_down( SP_BUTTON(dtw->guides_lock), FALSE );
+ } else {
+ sp_button_toggle_set_down( SP_BUTTON(dtw->guides_lock), TRUE );
+ }
+}
/* Unused
void
sp_spw_toggle_menubar (SPDesktopWidget *dtw, bool is_fullscreen)
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index 489217d9a..08966ad5f 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -49,6 +49,7 @@ void sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw);
void sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw);
void sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale);
void sp_desktop_widget_toggle_color_prof_adj( SPDesktopWidget *dtw );
+void sp_desktop_widget_toggle_guides_lock( SPDesktopWidget *dtw );
bool sp_desktop_widget_color_prof_adj_enabled( SPDesktopWidget *dtw );
void sp_dtw_desktop_activate (SPDesktopWidget *dtw);
@@ -87,6 +88,7 @@ struct SPDesktopWidget {
GtkWidget *hruler, *vruler;
GtkWidget *hruler_box, *vruler_box; // eventboxes for setting tooltips
+ GtkWidget *guides_lock;
GtkWidget *sticky_zoom;
GtkWidget *cms_adjust;
GtkWidget *coord_status;
@@ -181,6 +183,8 @@ struct SPDesktopWidget {
{ sp_desktop_widget_toggle_scrollbars (_dtw); }
virtual void toggleColorProfAdjust()
{ sp_desktop_widget_toggle_color_prof_adj(_dtw); }
+ virtual void toggleGuidesLock()
+ { sp_desktop_widget_toggle_guides_lock(_dtw); }
virtual bool colorProfAdjustEnabled()
{ return sp_desktop_widget_color_prof_adj_enabled(_dtw); }
virtual void updateZoom()
diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index 1f79b50f2..45989936f 100644
--- a/src/widgets/eraser-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -57,6 +57,13 @@ static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
update_presets_list(tbl);
}
+static void sp_erc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/eraser/mass", gtk_adjustment_get_value(adj) );
+ update_presets_list(tbl);
+}
+
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
@@ -65,7 +72,18 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/eraser/mode", eraserMode );
}
-
+ GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") );
+ GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") );
+ GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") );
+ if(eraserMode == TRUE){
+ gtk_action_set_visible( split, TRUE );
+ gtk_action_set_visible( mass, TRUE );
+ gtk_action_set_visible( width, TRUE );
+ } else {
+ gtk_action_set_visible( split, FALSE );
+ gtk_action_set_visible( mass, FALSE );
+ gtk_action_set_visible( width, FALSE );
+ }
// only take action if run by the attr_changed listener
if (!g_object_get_data( tbl, "freeze" )) {
// in turn, prevent listener from responding
@@ -82,11 +100,20 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
}
}
+static void sp_toogle_break_apart( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/eraser/break_apart", active);
+}
+
void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint eraserMode = FALSE;
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
-
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
@@ -113,29 +140,70 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_tooltip_column( act, 1 );
- /// @todo Convert to boolean?
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ eraserMode = prefs->getBool("/tools/eraser/mode") ? TRUE : FALSE;
ege_select_one_action_set_active( act, eraserMode );
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder );
}
{
/* Width */
- gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
- gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
+ gchar const* labels[] = {_("(no width)"),_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
+ gdouble values[] = {0, 1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
EgeAdjustmentAction *eact = create_adjustment_action( "EraserWidthAction",
_("Pen Width"), _("Width:"),
_("The width of the eraser pen (relative to the visible canvas area)"),
"/tools/eraser/width", 15,
GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-eraser",
- 1, 100, 1.0, 10.0,
+ 0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_erc_width_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ g_object_set_data( holder, "width", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
+ {
+ /* Mass */
+ gchar const* labels[] = {_("(no inertia)"), _("(slight smoothing, default)"), _("(noticeable lagging)"), 0, 0, _("(maximum inertia)")};
+ gdouble values[] = {0.0, 2, 10, 20, 50, 100};
+ EgeAdjustmentAction* eact = create_adjustment_action( "EraserMassAction",
+ _("Eraser Mass"), _("Mass:"),
+ _("Increase to make the eraser drag behind, as if slowed by inertia"),
+ "/tools/eraser/mass", 10.0,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0.0, 100, 1, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_erc_mass_value_changed, NULL /*unit tracker*/, 1, 0);
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ g_object_set_data( holder, "mass", eact );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+ /* Overlap */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "EraserBreakAppart",
+ _("Break appart cutted items"),
+ _("Break appart cutted itemss"),
+ INKSCAPE_ICON("distribute-randomize"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/eraser/break_apart", false) );
+ g_object_set_data( holder, "split", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toogle_break_apart), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") );
+ GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") );
+ GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") );
+ if(eraserMode == TRUE){
+ gtk_action_set_visible( split, TRUE );
+ gtk_action_set_visible( mass, TRUE );
+ gtk_action_set_visible( width, TRUE );
+ } else {
+ gtk_action_set_visible( split, FALSE );
+ gtk_action_set_visible( mass, FALSE );
+ gtk_action_set_visible( width, FALSE );
+ }
}
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp
index fa5eabab4..a96776894 100644
--- a/src/widgets/fill-style.cpp
+++ b/src/widgets/fill-style.cpp
@@ -68,7 +68,7 @@ namespace Inkscape {
class FillNStroke : public Gtk::VBox
{
public:
- FillNStroke( FillOrStroke kind );
+ FillNStroke( FillOrStroke k );
~FillNStroke();
void setFillrule( SPPaintSelector::FillRule mode );
@@ -125,9 +125,9 @@ Gtk::Widget *Inkscape::Widgets::createStyleWidget( FillOrStroke kind )
return filler;
}
-FillNStroke::FillNStroke( FillOrStroke kind ) :
+FillNStroke::FillNStroke( FillOrStroke k ) :
Gtk::VBox(),
- kind(kind),
+ kind(k),
desktop(0),
psel(0),
lastDrag(0),
@@ -570,7 +570,7 @@ void FillNStroke::updateFromPaint()
}
}
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
//FIXME: see above
if (kind == FILL) {
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -596,7 +596,7 @@ void FillNStroke::updateFromPaint()
// We have changed from another gradient type, or modified spread/units within
// this gradient type.
vector = sp_gradient_ensure_vector_normalized(vector);
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
//FIXME: see above
if (kind == FILL) {
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -642,7 +642,7 @@ void FillNStroke::updateFromPaint()
// cannot just call sp_desktop_set_style, because we don't want to touch those
// objects who already have the same root pattern but through a different href
// chain. FIXME: move this to a sp_item_set_pattern
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
Inkscape::XML::Node *selrepr = (*i)->getRepr();
if ( (kind == STROKE) && !selrepr) {
continue;
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 402f30846..604ecd108 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -17,10 +17,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/treeview.h>
#include "gradient-vector.h"
@@ -555,6 +551,10 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
if (gr) {
repr = gr->getRepr()->duplicate(xml_doc);
+ // Rename the new gradients id to be similar to the cloned gradients
+ Glib::ustring old_id = gr->getId();
+ rename_id(gr, old_id);
+ doc->getDefs()->getRepr()->addChild(repr, NULL);
} else {
repr = xml_doc->createElement("svg:linearGradient");
Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop");
@@ -567,17 +567,10 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
stop->setAttribute("style", "stop-color:#fff;stop-opacity:1;");
repr->appendChild(stop);
Inkscape::GC::release(stop);
+ doc->getDefs()->getRepr()->addChild(repr, NULL);
+ gr = SP_GRADIENT(doc->getObjectByRepr(repr));
}
-
- doc->getDefs()->getRepr()->addChild(repr, NULL);
-
- Glib::ustring old_id = gr->getId();
-
- gr = SP_GRADIENT(doc->getObjectByRepr(repr));
-
- // Rename the new gradients id to be similar to the cloned gradients
- rename_id(gr, old_id);
-
+
sp_gradient_vector_selector_set_gradient( SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, gr);
sel->selectGradientInTree(gr);
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index 6743dd23a..858aa05db 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -106,10 +106,10 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient
// GRADIENTFIXME: make this work for multiple selected draggers.
// First try selected dragger
- if (drag && drag->selected) {
- GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data);
- for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
- GrDraggable *draggable = static_cast<GrDraggable*>(i->data);
+ if (drag && !drag->selected.empty()) {
+ GrDragger *dragger = *(drag->selected.begin());
+ for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger
+ GrDraggable *draggable = *i;
gr_apply_gradient_to_item(draggable->item, gr, initialType, initialMode, draggable->fill_or_stroke);
}
return;
@@ -117,7 +117,7 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient
// If no drag or no dragger selected, act on selection
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode);
}
}
@@ -139,19 +139,18 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection
/* Clear old list, if there is any */
gtk_list_store_clear(store);
- GSList *gl = NULL;
- const GSList *gradients = document->getResourceList("gradient");
- for (const GSList *i = gradients; i != NULL; i = i->next) {
- SPGradient *grad = SP_GRADIENT(i->data);
+ std::vector<SPObject *> gl;
+ std::set<SPObject *> gradients = document->getResourceList( "gradient" );
+ for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) {
+ SPGradient *grad = SP_GRADIENT(*it);
if ( grad->hasStops() && !grad->isSolid() ) {
- gl = g_slist_prepend(gl, i->data);
+ gl.push_back(*it);
}
}
- gl = g_slist_reverse(gl);
guint pos = 0;
- if (!gl) {
+ if (gl.empty()) {
// The document has no gradients
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1);
@@ -180,9 +179,8 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection
}
guint idx = 0;
- while (gl) {
- SPGradient *gradient = SP_GRADIENT(gl->data);
- gl = g_slist_remove(gl, gradient);
+ for (std::vector<SPObject *>::const_iterator it = gl.begin(); it != gl.end(); ++it) {
+ SPGradient *gradient = SP_GRADIENT(*it);
Glib::ustring label = gr_prepare_label(gradient);
GdkPixbuf *pixb = sp_gradient_to_pixbuf(gradient, 64, 16);
@@ -219,7 +217,7 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr
SPGradient *gradient = 0;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;// get the items gradient, not the getVector() version
SPStyle *style = item->style;
SPPaintServer *server = 0;
@@ -255,11 +253,11 @@ void gr_read_selection( Inkscape::Selection *selection,
SPGradientSpread &spr_selected,
bool &spr_multi )
{
- if (drag && drag->selected) {
+ if (drag && !drag->selected.empty()) {
// GRADIENTFIXME: make this work for more than one selected dragger?
- GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data);
- for (GSList const* i = dragger->draggables; i; i = i->next) { // for all draggables of dragger
- GrDraggable *draggable = static_cast<GrDraggable *>(i->data);
+ GrDragger *dragger = *(drag->selected.begin());
+ for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger
+ GrDraggable *draggable = *i;
SPGradient *gradient = sp_item_gradient_get_vector(draggable->item, draggable->fill_or_stroke);
SPGradientSpread spread = sp_item_gradient_get_spread(draggable->item, draggable->fill_or_stroke);
@@ -287,7 +285,7 @@ void gr_read_selection( Inkscape::Selection *selection,
// If no selected dragger, read desktop selection
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
SPStyle *style = item->style;
@@ -394,10 +392,10 @@ static void gr_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe
}
InkAction *add = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_add_action");
- gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && drag->selected));
+ gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && !drag->selected.empty()));
InkAction *del = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_delete_action");
- gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && drag->selected));
+ gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && !drag->selected.empty()));
InkAction *reverse = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_reverse_action");
gtk_action_set_sensitive(GTK_ACTION(reverse), (gr_selected!= NULL));
@@ -649,7 +647,7 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool
GrDrag *drag = ev->get_drag();
- if (!drag || !drag->selected) {
+ if (!drag || drag->selected.empty()) {
blocked = TRUE;
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0);
gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data);
@@ -660,11 +658,10 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool
gint n = 0;
// for all selected draggers
- for (GList *i = drag->selected; i != NULL; i = i->next) {
- GrDragger *dragger = static_cast<GrDragger*>(i->data);
- // for all draggables of dragger
- for (GSList const* j = dragger->draggables; j != NULL; j = j->next) {
- GrDraggable *draggable = static_cast<GrDraggable*>(j->data);
+ for(std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { //for all draggables of dragger
+ GrDragger *dragger = *i;
+ for(std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { //for all draggables of dragger
+ GrDraggable *draggable = *j;
if (draggable->point_type != POINT_RG_FOCUS) {
n++;
@@ -766,25 +763,25 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S
}
/* Populate the combobox store */
- GSList *sl = NULL;
+ std::vector<SPObject *> sl;
if ( gradient->hasStops() ) {
for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
- sl = g_slist_append(sl, ochild);
+ sl.push_back(ochild);
}
}
}
- if (!sl) {
+ if (sl.empty()) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, _("No stops in gradient"), 1, NULL, 2, NULL, -1);
sensitive = FALSE;
} else {
- for (; sl != NULL; sl = sl->next){
- if (SP_IS_STOP(sl->data)){
- SPStop *stop = SP_STOP(sl->data);
- Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr();
+ for (std::vector<SPObject *>::const_iterator it = sl.begin(); it != sl.end(); ++it) {
+ if (SP_IS_STOP(*it)){
+ SPStop *stop = SP_STOP(*it);
+ Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(*it)->getRepr();
Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
GdkPixbuf *pb = cpv->toPixbuf(32, 16);
Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25);
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 259d4c9af..35c1e4a8d 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -298,11 +298,11 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
/* Pick up all gradients with vectors */
GSList *gl = NULL;
if (gvs->gr) {
- const GSList *gradients = gvs->gr->document->getResourceList("gradient");
- for (const GSList *curr = gradients; curr; curr = curr->next) {
- SPGradient* grad = SP_GRADIENT(curr->data);
+ std::set<SPObject *> gradients = gvs->gr->document->getResourceList("gradient");
+ for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) {
+ SPGradient* grad = SP_GRADIENT(*it);
if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) {
- gl = g_slist_prepend(gl, curr->data);
+ gl = g_slist_prepend(gl, *it);
}
}
}
@@ -842,7 +842,8 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
GtkWidget *vb, *w, *f;
- g_return_val_if_fail(!gradient || SP_IS_GRADIENT(gradient), NULL);
+ g_return_val_if_fail(gradient != NULL, NULL);
+ g_return_val_if_fail(SP_IS_GRADIENT(gradient), NULL);
#if GTK_CHECK_VERSION(3,0,0)
vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, PAD);
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 5a4785b1f..990989f4a 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -33,11 +33,16 @@
#include "measure-toolbar.h"
#include "desktop.h"
+#include "inkscape.h"
+#include "message-stack.h"
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "preferences.h"
#include "toolbox.h"
+#include "widgets/ink-action.h"
+#include "ui/icon-names.h"
+#include "ui/tools/measure-tool.h"
#include "ui/widget/unit-tracker.h"
using Inkscape::UI::Widget::UnitTracker;
@@ -45,11 +50,26 @@ using Inkscape::Util::Unit;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::UI::Tools::MeasureTool;
//########################
//## Measure Toolbox ##
//########################
+/** Temporary hack: Returns the node tool in the active desktop.
+ * Will go away during tool refactoring. */
+static MeasureTool *get_measure_tool()
+{
+ MeasureTool *tool = 0;
+ if (SP_ACTIVE_DESKTOP ) {
+ Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context;
+ if (SP_IS_MEASURE_CONTEXT(ec)) {
+ tool = static_cast<MeasureTool*>(ec);
+ }
+ }
+ return tool;
+}
+
static void
sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl)
{
@@ -57,17 +77,184 @@ sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl)
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt(Glib::ustring("/tools/measure/fontsize"),
+ prefs->setDouble(Glib::ustring("/tools/measure/fontsize"),
+ gtk_adjustment_get_value(adj));
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+ }
+}
+
+static void
+sp_measure_offset_value_changed(GtkAdjustment *adj, GObject *tbl)
+{
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
+
+ if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(Glib::ustring("/tools/measure/offset"),
gtk_adjustment_get_value(adj));
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
}
}
-static void measure_unit_changed(GtkAction* /*act*/, GObject* tbl)
+static void sp_measure_scale_value_changed(GtkAdjustment *adj, GObject *tbl)
+{
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
+
+ if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(Glib::ustring("/tools/measure/scale"),
+ gtk_adjustment_get_value(adj));
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+ }
+}
+
+static void
+sp_measure_precision_value_changed(GtkAdjustment *adj, GObject *tbl)
+{
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
+
+ if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(Glib::ustring("/tools/measure/precision"),
+ gtk_adjustment_get_value(adj));
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+ }
+}
+
+static void
+sp_measure_unit_changed(GtkAction* /*act*/, GObject* tbl)
{
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
Glib::ustring const unit = tracker->getActiveUnit()->abbr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setString("/tools/measure/unit", unit);
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+}
+
+static void
+sp_toggle_ignore_1st_and_last( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/measure/ignore_1st_and_last", active);
+ SPDesktop *desktop = static_cast<SPDesktop *>(data);
+ if ( active ) {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Start and end measures inactive."));
+ } else {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Start and end measures active."));
+ }
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+}
+
+static void
+sp_toggle_show_hidden( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/measure/show_hidden", active);
+ SPDesktop *desktop = static_cast<SPDesktop *>(data);
+ if ( active ) {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Show all crossings."));
+ } else {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Show visible crossings."));
+ }
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+}
+
+static void
+sp_toggle_all_layers( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/measure/all_layers", active);
+ SPDesktop *desktop = static_cast<SPDesktop *>(data);
+ if ( active ) {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Use all layers in the measure."));
+ } else {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Use current layer in the measure."));
+ }
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+}
+
+static void
+sp_toggle_show_in_between( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/measure/show_in_between", active);
+ SPDesktop *desktop = static_cast<SPDesktop *>(data);
+ if ( active ) {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Compute all elements."));
+ } else {
+ desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Compute max length."));
+ }
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->showCanvasItems();
+ }
+}
+static void
+sp_reverse_knots(void){
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->reverseKnots();
+ }
+}
+
+static void
+sp_to_mark_dimension(void){
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->toMarkDimension();
+ }
+}
+
+static void
+sp_to_guides(void){
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->toGuides();
+ }
+}
+
+static void
+sp_to_phantom(void){
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->toPhantom();
+ }
+}
+
+static void
+sp_to_item(void){
+ MeasureTool *mt = get_measure_tool();
+ if (mt) {
+ mt->toItem();
+ }
}
void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
@@ -79,22 +266,22 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G
g_object_set_data( holder, "tracker", tracker );
EgeAdjustmentAction *eact = 0;
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
/* Font Size */
{
eact = create_adjustment_action( "MeasureFontSizeAction",
_("Font Size"), _("Font Size:"),
_("The font size to be used in the measurement labels"),
- "/tools/measure/fontsize", 0.0,
+ "/tools/measure/fontsize", 10.0,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
- 10, 36, 1.0, 4.0,
+ 1.0, 36.0, 1.0, 4.0,
0, 0, 0,
- sp_measure_fontsize_value_changed);
- gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ sp_measure_fontsize_value_changed, NULL, 0 , 2);
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact));
}
-
- // units label
+ /* units label */
{
EgeOutputAction* act = ege_output_action_new( "measure_units_label", _("Units:"), _("The units to be used for the measurements"), 0 );
ege_output_action_set_use_markup( act, TRUE );
@@ -102,12 +289,146 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
}
- // units menu
+ /* units menu */
{
GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(measure_unit_changed), holder );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_measure_unit_changed), holder );
gtk_action_group_add_action( mainActions, act );
}
+
+ /* Precission */
+ {
+ eact = create_adjustment_action( "MeasurePrecisionAction",
+ _("Precision"), _("Precision:"),
+ _("Decimal precision of measure"),
+ "/tools/measure/precision", 2,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0, 10, 1, 0,
+ 0, 0, 0,
+ sp_measure_precision_value_changed, NULL, 0 ,0);
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact));
+ }
+
+ /* Scale */
+ {
+ eact = create_adjustment_action( "MeasureScaleAction",
+ _("Scale %"), _("Scale %:"),
+ _("Scale the results"),
+ "/tools/measure/scale", 100.0,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0.0, 90000.0, 1.0, 4.0,
+ 0, 0, 0,
+ sp_measure_scale_value_changed, NULL, 0 , 3);
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ }
+
+ /* Offset */
+ {
+ eact = create_adjustment_action( "MeasureOffsetAction",
+ _("Offset"), _("Offset:"),
+ _("The offset size"),
+ "/tools/measure/offset", 5.0,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0.0, 90000.0, 1.0, 4.0,
+ 0, 0, 0,
+ sp_measure_offset_value_changed, NULL, 0 , 2);
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ }
+
+ /* ignore_1st_and_last */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "MeasureIgnore1stAndLast",
+ _("Ignore first and last"),
+ _("Ignore first and last"),
+ INKSCAPE_ICON("draw-geometry-line-segment"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/measure/ignore_1st_and_last", true) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_ignore_1st_and_last), desktop) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* only visible */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "MeasureShowHidden",
+ _("Show hidden intersections"),
+ _("Show hidden intersections"),
+ INKSCAPE_ICON("object-hidden"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/measure/show_hidden", true) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_show_hidden), desktop) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* measure imbetweens */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "MeasureInBettween",
+ _("Show measures between items"),
+ _("Show measures between items"),
+ INKSCAPE_ICON("distribute-randomize"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/measure/show_in_between", true) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_show_in_between), desktop) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* measure only current layer */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "MeasureAllLayers",
+ _("Measure all layers"),
+ _("Measure all layers"),
+ INKSCAPE_ICON("dialog-layers"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/measure/all_layers", true) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_all_layers), desktop) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* toogle start end */
+ {
+ InkAction* act = ink_action_new( "MeasureReverse",
+ _("Reverse measure"),
+ _("Reverse measure"),
+ INKSCAPE_ICON("draw-geometry-mirror"),
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_reverse_knots), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* phantom measure */
+ {
+ InkAction* act = ink_action_new( "MeasureToPhantom",
+ _("Phantom measure"),
+ _("Phantom measure"),
+ INKSCAPE_ICON("selection-make-bitmap-copy"),
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_to_phantom), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* to guides */
+ {
+ InkAction* act = ink_action_new( "MeasureToGuides",
+ _("To guides"),
+ _("To guides"),
+ INKSCAPE_ICON("guides"),
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_to_guides), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* to mark dimensions */
+ {
+ InkAction* act = ink_action_new( "MeasureMarkDimension",
+ _("Mark Dimension"),
+ _("Mark Dimension"),
+ INKSCAPE_ICON("tool-pointer"),
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_to_mark_dimension), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* to item */
+ {
+ InkAction* act = ink_action_new( "MeasureToItem",
+ _("Convert to item"),
+ _("Convert to item"),
+ INKSCAPE_ICON("path-reverse"),
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_to_item), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
} // end of sp_measure_toolbox_prep()
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 1af55d9cd..3643ce00c 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -34,6 +34,7 @@
#include "widgets/gradient-image.h"
#include "style.h"
+#include "inkscape.h"
#include "preferences.h"
#include "document-private.h"
#include "document-undo.h"
@@ -66,6 +67,7 @@
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::UI::Tools::MeshTool;
static bool blocked = false;
@@ -88,7 +90,7 @@ void ms_read_selection( Inkscape::Selection *selection,
ms_type = SP_MESH_TYPE_COONS;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
SPStyle *style = item->style;
@@ -215,7 +217,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel
SPMesh *gradient = 0;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;// get the items gradient, not the getVector() version
SPStyle *style = item->style;
SPPaintServer *server = 0;
@@ -290,6 +292,9 @@ static void ms_col_changed(GtkAdjustment *adj, GObject * /*tbl*/ )
blocked = FALSE;
}
+/**
+ * Sets mesh type: Coons, Bicubic
+ */
static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget)
{
// std::cout << "ms_type_changed" << std::endl;
@@ -309,15 +314,54 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget)
gradient->type_set = true;
gradient->updateRepr();
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Set mesh type"));
}
}
+/** Temporary hack: Returns the mesh tool in the active desktop.
+ * Will go away during tool refactoring. */
+static MeshTool *get_mesh_tool()
+{
+ MeshTool *tool = 0;
+ if (SP_ACTIVE_DESKTOP ) {
+ Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context;
+ if (SP_IS_MESH_CONTEXT(ec)) {
+ tool = static_cast<MeshTool*>(ec);
+ }
+ }
+ return tool;
+}
+
+static void ms_toggle_sides(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_TOGGLE );
+ }
+}
+
+static void ms_make_elliptical(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_ARC );
+ }
+}
+
+static void ms_pick_colors(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_COLOR_PICK );
+ }
+}
+
static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
/**
* Mesh auxiliary toolbar construction and setup.
+ * Don't forget to add to XML in widgets/toolbox.cpp!
*
*/
void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
@@ -389,14 +433,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh rows */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshRowAction",
_("Rows"), _("Rows:"), _("Number of rows in new mesh"),
"/tools/mesh/mesh_rows", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_row_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -405,14 +449,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh columns */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshColumnAction",
_("Columns"), _("Columns:"), _("Number of columns in new mesh"),
"/tools/mesh/mesh_cols", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_col_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -466,7 +510,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
}
- /* Typeing method */
+ /* Type */
{
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
@@ -487,6 +531,41 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
g_object_set_data( holder, "mesh_select_type_action", act );
}
+
+ {
+ InkAction* act = ink_action_new( "MeshToggleSidesAction",
+ _("Toggle Sides"),
+ _("Toggle selected sides between Beziers and lines."),
+ INKSCAPE_ICON("node-segment-line"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Toggle side:"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_sides), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ {
+ InkAction* act = ink_action_new( "MeshMakeEllipticalAction",
+ _("Make elliptical"),
+ _("Make selected sides elliptical by changing length of handles. Works best if handles already approximate ellipse."),
+ INKSCAPE_ICON("node-segment-curve"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Make elliptical:"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_make_elliptical), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ {
+ InkAction* act = ink_action_new( "MeshPickColorsAction",
+ _("Pick colors:"),
+ _("Pick colors for selected corner nodes from underneath mesh."),
+ INKSCAPE_ICON("color-picker"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Pick Color"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_pick_colors), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+
}
static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 846ded511..602cad3c3 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -844,10 +844,10 @@ ink_pattern_list_get (SPDocument *source)
return NULL;
GSList *pl = NULL;
- GSList const *patterns = source->getResourceList("pattern");
- for (GSList *l = const_cast<GSList *>(patterns); l != NULL; l = l->next) {
- if (SP_PATTERN(l->data) == SP_PATTERN(l->data)->rootPattern()) { // only if this is a root pattern
- pl = g_slist_prepend(pl, l->data);
+ std::set<SPObject *> patterns = source->getResourceList("pattern");
+ for (std::set<SPObject *>::const_iterator it = patterns.begin(); it != patterns.end(); ++it) {
+ if (SP_PATTERN(*it) == SP_PATTERN(*it)->rootPattern()) { // only if this is a root pattern
+ pl = g_slist_prepend(pl, *it);
}
}
@@ -972,7 +972,7 @@ ink_pattern_menu(GtkWidget *combo)
}
- // Select the first item that is not a seperator
+ // Select the first item that is not a separator
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter)) {
gboolean sep = false;
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, COMBO_COL_SEP, &sep, -1);
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index 1214a378a..55127206c 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -28,11 +28,12 @@
# include "config.h"
#endif
+#include <gtkmm.h>
#include <glibmm/i18n.h>
+#include <list>
#include "pencil-toolbar.h"
#include "desktop.h"
-#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
@@ -43,9 +44,17 @@
#include "ui/tools/pen-tool.h"
#include "ui/uxmanager.h"
#include "widgets/spinbutton-events.h"
+#include <selection.h>
+#include "display/curve.h"
+#include "live_effects/effect.h"
+#include "live_effects/lpe-simplify.h"
+#include "live_effects/lpe-powerstroke.h"
+#include "live_effects/effect-enum.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
+#include "sp-lpe-item.h"
using Inkscape::UI::UXManager;
-using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
@@ -151,6 +160,13 @@ static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge)
prefs->setInt(freehand_tool_name(dataKludge) + "/shape", shape);
}
+static void freehand_simplify_lpe(InkToggleAction* itact, GObject *dataKludge) {
+ gint simplify = gtk_toggle_action_get_active( GTK_TOGGLE_ACTION(itact) );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(freehand_tool_name(dataKludge) + "/simplify", simplify);
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(dataKludge, "flatten_simplify") ), simplify );
+}
+
/**
* Generate the list of freehand advanced shape option entries.
*/
@@ -162,6 +178,7 @@ static GList * freehand_shape_dropdown_items_list() {
glist = g_list_append (glist, _("Triangle out"));
glist = g_list_append (glist, _("Ellipse"));
glist = g_list_append (glist, _("From clipboard"));
+ glist = g_list_append (glist, _("Bend from clipboard"));
glist = g_list_append (glist, _("Last applied"));
return glist;
@@ -220,6 +237,41 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj)
spinbutton_defocus(tbl);
}
+static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj)
+{
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop"));
+ std::vector<SPItem *> selected = desktop->getSelection()->itemList();
+ for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
+ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
+ if (lpeitem && lpeitem->hasPathEffect()){
+ PathEffectList lpelist = lpeitem->getEffectList();
+ std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
+ for (i = lpelist.begin(); i != lpelist.end(); ++i) {
+ LivePathEffectObject *lpeobj = (*i)->lpeobject;
+ if (lpeobj) {
+ Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
+ if (dynamic_cast<Inkscape::LivePathEffect::LPESimplify *>(lpe)) {
+ SPShape * shape = dynamic_cast<SPShape *>(lpeitem);
+ if(shape){
+ SPCurve * c = shape->getCurveBeforeLPE();
+ lpe->doEffect(c);
+ lpeitem->setCurrentPathEffect(*i);
+ if (lpelist.size() > 1){
+ lpeitem->removeCurrentPathEffect(true);
+ shape->setCurveBeforeLPE(c);
+ } else {
+ lpeitem->removeCurrentPathEffect(false);
+ shape->setCurve(c,0);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl)
{
// quit if run by the attr_changed listener
@@ -232,6 +284,51 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb
prefs->setDouble("/tools/freehand/pencil/tolerance",
gtk_adjustment_get_value(adj));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
+ std::vector<SPItem *> selected = desktop->getSelection()->itemList();
+ for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
+ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
+ if (lpeitem && lpeitem->hasPathEffect()){
+ Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY);
+ if(simplify){
+ Inkscape::LivePathEffect::LPESimplify *lpe_simplify = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(simplify->getLPEObj()->get_lpe());
+ if (lpe_simplify) {
+ double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
+ tol = tol/(100.0*(102.0-tol));
+ std::ostringstream ss;
+ ss << tol;
+ Inkscape::LivePathEffect::Effect* powerstroke = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE);
+ bool simplified = false;
+ if(powerstroke){
+ Inkscape::LivePathEffect::LPEPowerStroke *lpe_powerstroke = dynamic_cast<Inkscape::LivePathEffect::LPEPowerStroke*>(powerstroke->getLPEObj()->get_lpe());
+ if(lpe_powerstroke){
+ lpe_powerstroke->getRepr()->setAttribute("is_visible", "false");
+ sp_lpe_item_update_patheffect(lpeitem, false, false);
+ SPShape *sp_shape = dynamic_cast<SPShape *>(lpeitem);
+ if (sp_shape) {
+ guint previous_curve_length = sp_shape->getCurve()->get_segment_count();
+ lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
+ sp_lpe_item_update_patheffect(lpeitem, false, false);
+ simplified = true;
+ guint curve_length = sp_shape->getCurve()->get_segment_count();
+ std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data();
+ double factor = (double)curve_length/ (double)previous_curve_length;
+ for (size_t i = 0; i < ts.size(); i++) {
+ ts[i][Geom::X] = ts[i][Geom::X] * factor;
+ }
+ lpe_powerstroke->offset_points.param_setValue(ts);
+ }
+ lpe_powerstroke->getRepr()->setAttribute("is_visible", "true");
+ sp_lpe_item_update_patheffect(lpeitem, false, false);
+ }
+ }
+ if(!simplified){
+ lpe_simplify->getRepr()->setAttribute("threshold", ss.str());
+ }
+ }
+ }
+ }
+ }
}
/*
@@ -267,7 +364,7 @@ private:
void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
sp_add_freehand_mode_toggle(mainActions, holder, true);
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
/* Tolerance */
@@ -303,6 +400,32 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_pencil_tb_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
}
+ /* LPE simplify based tolerance */
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ InkToggleAction* itact = ink_toggle_action_new( "PencilLpeSimplify",
+ _("LPE based interactive simplify"),
+ _("LPE based interactive simplify"),
+ INKSCAPE_ICON("interactive_simplify"),
+ Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) );
+ g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
+ }
+ /* LPE simplify flatten */
+ {
+ InkAction* inky = ink_action_new( "PencilLpeSimplifyFlatten",
+ _("LPE simplify flatten"),
+ _("LPE simplify flatten"),
+ INKSCAPE_ICON("flatten_simplify"),
+ Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_simplify_flatten), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
+ g_object_set_data( holder, "flatten_simplify", inky );
+ if (!prefs->getInt("/tools/freehand/pencil/simplify", 0)) {
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(holder, "flatten_simplify") ), false );
+ }
+ }
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 96ba699dc..bc27d003c 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -107,7 +107,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
bool modmade = false;
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
if (SP_IS_RECT(*i)) {
if (gtk_adjustment_get_value(adj) != 0) {
(SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
@@ -244,7 +244,7 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO
purge_repr_listener( tbl, tbl );
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
if (SP_IS_RECT(*i)) {
n_selected++;
item = *i;
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index ab486eeeb..3a5e76277 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -41,8 +41,9 @@
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
-#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_X_SMALL
-#define MINIMUM_INCR 5
+#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_X_SMALL
+#define MINIMUM_INCR 5
+#define IMMEDIATE_REDRAW_THRESHOLD 20
using Inkscape::Util::unit_table;
@@ -71,11 +72,11 @@ typedef struct
GdkWindow *input_window;
cairo_surface_t *backing_store;
+ gboolean backing_store_valid;
+ GdkRectangle last_pos_rect;
+ guint pos_redraw_idle_id;
PangoLayout *layout;
gdouble font_scale;
-
- gint xsrc;
- gint ysrc;
GList *track_widgets;
} SPRulerPrivate;
@@ -132,18 +133,22 @@ static void sp_ruler_style_updated (GtkWidget *widget);
static void sp_ruler_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void sp_ruler_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
+ GtkStyle *prev_style);
#endif
static gboolean sp_ruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gboolean sp_ruler_draw (GtkWidget *widget,
- cairo_t *cr);
+ cairo_t *cr);
#if !GTK_CHECK_VERSION(3,0,0)
static gboolean sp_ruler_expose (GtkWidget *widget,
GdkEventExpose *event);
#endif
static void sp_ruler_draw_ticks (SPRuler *ruler);
+static GdkRectangle sp_ruler_get_pos_rect (SPRuler *ruler,
+ gdouble position);
+static gboolean sp_ruler_idle_queue_pos_redraw(gpointer data);
+static void sp_ruler_queue_pos_redraw (SPRuler *ruler);
static void sp_ruler_draw_pos (SPRuler *ruler,
cairo_t *cr);
static void sp_ruler_make_pixmap (SPRuler *ruler);
@@ -260,14 +265,23 @@ sp_ruler_init (SPRuler *ruler)
gtk_widget_set_has_window (GTK_WIDGET (ruler), FALSE);
- priv->orientation = GTK_ORIENTATION_HORIZONTAL;
- priv->unit = unit_table.getUnit("px");
- priv->lower = 0;
- priv->upper = 0;
- priv->position = 0;
- priv->max_size = 0;
- priv->backing_store = NULL;
- priv->font_scale = DEFAULT_RULER_FONT_SCALE;
+ priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ priv->unit = unit_table.getUnit("px");
+ priv->lower = 0;
+ priv->upper = 0;
+ priv->position = 0;
+ priv->max_size = 0;
+
+ priv->backing_store = NULL;
+ priv->backing_store_valid = FALSE;
+
+ priv->last_pos_rect.x = 0;
+ priv->last_pos_rect.y = 0;
+ priv->last_pos_rect.width = 0;
+ priv->last_pos_rect.height = 0;
+ priv->pos_redraw_idle_id = 0;
+
+ priv->font_scale = DEFAULT_RULER_FONT_SCALE;
#if GTK_CHECK_VERSION(3,0,0)
#if GTK_CHECK_VERSION(3,8,0)
@@ -299,6 +313,12 @@ sp_ruler_dispose (GObject *object)
while (priv->track_widgets)
sp_ruler_remove_track_widget (ruler, GTK_WIDGET(priv->track_widgets->data));
+ if (priv->pos_redraw_idle_id)
+ {
+ g_source_remove (priv->pos_redraw_idle_id);
+ priv->pos_redraw_idle_id = 0;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -343,6 +363,7 @@ sp_ruler_set_range (SPRuler *ruler,
}
g_object_thaw_notify (G_OBJECT (ruler));
+ priv->backing_store_valid = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (ruler));
}
@@ -513,7 +534,9 @@ sp_ruler_unrealize(GtkWidget *widget)
cairo_surface_destroy (priv->backing_store);
priv->backing_store = NULL;
}
-
+
+ priv->backing_store_valid = FALSE;
+
if (priv->layout)
{
g_object_unref (priv->layout);
@@ -689,7 +712,6 @@ sp_ruler_expose (GtkWidget *widget,
cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
- cairo_translate (cr, allocation.x, allocation.y);
gboolean result = sp_ruler_draw (widget, cr);
@@ -733,6 +755,8 @@ sp_ruler_make_pixmap (SPRuler *ruler)
CAIRO_CONTENT_COLOR,
allocation.width,
allocation.height);
+
+ priv->backing_store_valid = FALSE;
}
static void
@@ -743,118 +767,22 @@ sp_ruler_draw_pos (SPRuler *ruler,
#if GTK_CHECK_VERSION(3,0,0)
GtkStyleContext *context = gtk_widget_get_style_context (widget);
- GtkBorder border;
GdkRGBA color;
#else
GtkStyle *style = gtk_widget_get_style (widget);
GtkStateType state = gtk_widget_get_state (widget);
- gint xthickness;
- gint ythickness;
#endif
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
- GtkAllocation allocation;
- gint x, y;
- gint width, height;
- gint bs_width, bs_height;
+ GdkRectangle pos_rect;
if (! gtk_widget_is_drawable (widget))
return;
- gtk_widget_get_allocation(widget, &allocation);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_style_context_get_border (context, static_cast<GtkStateFlags>(0), &border);
-#else
- xthickness = style->xthickness;
- ythickness = style->ythickness;
-#endif
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- width = allocation.width;
-#if GTK_CHECK_VERSION(3,0,0)
- height = allocation.height - (border.top + border.bottom);
-#else
- height = allocation.height - ythickness * 2;
-#endif
-
- bs_width = height / 2 + 2;
- bs_width |= 1; /* make sure it's odd */
- bs_height = bs_width / 2 + 1;
- }
- else
- {
-#if GTK_CHECK_VERSION(3,0,0)
- width = allocation.width - (border.left + border.right);
-#else
- width = allocation.width - xthickness * 2;
-#endif
- height = allocation.height;
-
- bs_height = width / 2 + 2;
- bs_height |= 1; /* make sure it's odd */
- bs_width = bs_height / 2 + 1;
- }
+ pos_rect = sp_ruler_get_pos_rect (ruler, sp_ruler_get_position (ruler));
- if ((bs_width > 0) && (bs_height > 0))
+ if ((pos_rect.width > 0) && (pos_rect.height > 0))
{
- gdouble lower;
- gdouble upper;
- gdouble position;
- gdouble increment;
-
- if (! cr)
- {
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
- cairo_translate (cr, allocation.x, allocation.y);
- cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height);
- cairo_clip (cr);
-
- cairo_translate (cr, allocation.x, allocation.y);
-
- /* If a backing store exists, restore the ruler */
- if (priv->backing_store)
- {
- cairo_set_source_surface (cr, priv->backing_store, 0, 0);
- cairo_rectangle (cr, priv->xsrc, priv->ysrc, bs_width, bs_height);
- cairo_fill (cr);
- }
- }
- else
- {
- cairo_reference (cr);
- }
-
- position = sp_ruler_get_position (ruler);
-
- sp_ruler_get_range (ruler, &lower, &upper, NULL);
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- increment = (gdouble) width / (upper - lower);
-
-#if GTK_CHECK_VERSION(3,0,0)
- x = ROUND ((position - lower) * increment) + (border.left - bs_width) / 2 - 1;
- y = (height + bs_height) / 2 + border.top;
-#else
- x = ROUND ((position - lower) * increment) + (xthickness - bs_width) / 2 - 1;
- y = (height + bs_height) / 2 + ythickness;
-#endif
- }
- else
- {
- increment = (gdouble) height / (upper - lower);
-
-#if GTK_CHECK_VERSION(3,0,0)
- x = (width + bs_width) / 2 + border.left;
- y = ROUND ((position - lower) * increment) + (border.top - bs_height) / 2 - 1;
-#else
- x = (width + bs_width) / 2 + xthickness;
- y = ROUND ((position - lower) * increment) + (ythickness - bs_height) / 2 - 1;
-#endif
- }
-
#if GTK_CHECK_VERSION(3,0,0)
gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
&color);
@@ -863,26 +791,28 @@ sp_ruler_draw_pos (SPRuler *ruler,
gdk_cairo_set_source_color (cr, &style->fg[state]);
#endif
- cairo_move_to (cr, x, y);
+ cairo_move_to (cr, pos_rect.x, pos_rect.y);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- cairo_line_to (cr, x + bs_width / 2.0, y + bs_height);
- cairo_line_to (cr, x + bs_width, y);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width / 2.0,
+ pos_rect.y + pos_rect.height);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width,
+ pos_rect.y);
}
else
{
- cairo_line_to (cr, x + bs_width, y + bs_height / 2.0);
- cairo_line_to (cr, x, y + bs_height);
+ cairo_line_to (cr, pos_rect.x + pos_rect.width,
+
+ pos_rect.y + pos_rect.height / 2.0);
+ cairo_line_to (cr, pos_rect.x,
+ pos_rect.y + pos_rect.height);
}
cairo_fill (cr);
-
- cairo_destroy (cr);
-
- priv->xsrc = x;
- priv->ysrc = y;
}
+
+ priv->last_pos_rect = pos_rect;
}
/**
@@ -1096,6 +1026,7 @@ sp_ruler_set_unit (SPRuler *ruler,
priv->unit = unit;
g_object_notify(G_OBJECT(ruler), "unit");
+ priv->backing_store_valid = FALSE;
gtk_widget_queue_draw (GTK_WIDGET (ruler));
}
}
@@ -1131,10 +1062,39 @@ sp_ruler_set_position (SPRuler *ruler,
if (priv->position != position)
{
- priv->position = position;
- g_object_notify (G_OBJECT (ruler), "position");
-
- sp_ruler_draw_pos (ruler, NULL);
+ GdkRectangle rect;
+ gint xdiff, ydiff;
+
+ priv->position = position;
+ g_object_notify (G_OBJECT (ruler), "position");
+
+ rect = sp_ruler_get_pos_rect (ruler, priv->position);
+
+ xdiff = rect.x - priv->last_pos_rect.x;
+ ydiff = rect.y - priv->last_pos_rect.y;
+
+ /*
+ * If the position has changed far enough, queue a redraw immediately.
+ * Otherwise, we only queue a redraw in a low priority idle handler, to
+ * allow for other things (like updating the canvas) to run.
+ *
+ * TODO: This might not be necessary any more in GTK3 with the frame
+ * clock. Investigate this more after the port to GTK3.
+ */
+ if (priv->last_pos_rect.width != 0 &&
+ priv->last_pos_rect.height != 0 &&
+ (ABS (xdiff) > IMMEDIATE_REDRAW_THRESHOLD ||
+ ABS (ydiff) > IMMEDIATE_REDRAW_THRESHOLD))
+ {
+ sp_ruler_queue_pos_redraw (ruler);
+ }
+ else if (! priv->pos_redraw_idle_id)
+ {
+ priv->pos_redraw_idle_id =
+ g_idle_add_full (G_PRIORITY_LOW,
+ sp_ruler_idle_queue_pos_redraw,
+ ruler, NULL);
+ }
}
}
@@ -1154,7 +1114,7 @@ sp_ruler_get_position (SPRuler *ruler)
static gboolean
sp_ruler_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
+ GdkEventMotion *event)
{
SPRuler *ruler = SP_RULER(widget);
@@ -1347,7 +1307,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
if (ideal_length > ++length)
length = ideal_length;
- if (lower < upper)
+ if (lower < upper)
{
start = floor (lower / subd_incr) * subd_incr;
end = ceil (upper / subd_incr) * subd_incr;
@@ -1413,16 +1373,16 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_get_extents (layout, &logical_rect, NULL);
#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr,
+ cairo_move_to (cr,
pos + 2,
border.top + PANGO_PIXELS (logical_rect.y - digit_offset));
#else
- cairo_move_to (cr,
+ cairo_move_to (cr,
pos + 2,
ythickness + PANGO_PIXELS (logical_rect.y - digit_offset));
#endif
- pango_cairo_show_layout(cr, layout);
+ pango_cairo_show_layout(cr, layout);
}
else
{
@@ -1435,15 +1395,15 @@ sp_ruler_draw_ticks (SPRuler *ruler)
pango_layout_get_extents (layout, NULL, &logical_rect);
#if GTK_CHECK_VERSION(3,0,0)
- cairo_move_to (cr,
+ cairo_move_to (cr,
border.left + 1,
pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
#else
- cairo_move_to (cr,
+ cairo_move_to (cr,
xthickness + 1,
pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
#endif
- pango_cairo_show_layout (cr, layout);
+ pango_cairo_show_layout (cr, layout);
}
}
}
@@ -1454,10 +1414,118 @@ sp_ruler_draw_ticks (SPRuler *ruler)
cairo_fill (cr);
+ priv->backing_store_valid = TRUE;
+
out:
cairo_destroy (cr);
}
+static GdkRectangle
+sp_ruler_get_pos_rect (SPRuler *ruler,
+ gdouble position)
+{
+ GtkWidget *widget = GTK_WIDGET (ruler);
+ GtkStyle *style = gtk_widget_get_style (widget);
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ GtkAllocation allocation;
+ gint width, height;
+ gint xthickness;
+ gint ythickness;
+ gdouble upper, lower;
+ gdouble increment;
+ GdkRectangle rect = { 0, 0, 0, 0 };
+
+ if (! gtk_widget_is_drawable (widget))
+ return rect;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ width = allocation.width;
+ height = allocation.height - ythickness * 2;
+
+ rect.width = height / 2 + 2;
+ rect.width |= 1; /* make sure it's odd */
+ rect.height = rect.width / 2 + 1;
+ }
+ else
+ {
+ width = allocation.width - xthickness * 2;
+ height = allocation.height;
+
+ rect.height = width / 2 + 2;
+ rect.height |= 1; /* make sure it's odd */
+ rect.width = rect.height / 2 + 1;
+ }
+
+ sp_ruler_get_range (ruler, &lower, &upper, NULL);
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ increment = (gdouble) width / (upper - lower);
+
+ rect.x = ROUND ((position - lower) * increment) + (xthickness - rect.width) / 2 - 1;
+ rect.y = (height + rect.height) / 2 + ythickness;
+ }
+ else
+ {
+ increment = (gdouble) height / (upper - lower);
+
+ rect.x = (width + rect.width) / 2 + xthickness;
+ rect.y = ROUND ((position - lower) * increment) + (ythickness - rect.height) / 2 - 1;
+ }
+
+ rect.x += allocation.x;
+ rect.y += allocation.y;
+
+ return rect;
+}
+
+static gboolean
+sp_ruler_idle_queue_pos_redraw (gpointer data)
+{
+ SPRuler *ruler = (SPRuler *)data;
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+
+ sp_ruler_queue_pos_redraw (ruler);
+
+ gboolean ret = g_source_remove(priv->pos_redraw_idle_id);
+ priv->pos_redraw_idle_id = 0;
+
+ return ret;
+}
+
+static void
+sp_ruler_queue_pos_redraw (SPRuler *ruler)
+{
+ SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
+ const GdkRectangle rect = sp_ruler_get_pos_rect (ruler, priv->position);
+
+ gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
+ rect.x,
+ rect.y,
+ rect.width,
+ rect.height);
+
+ if (priv->last_pos_rect.width != 0 || priv->last_pos_rect.height != 0)
+ {
+ gtk_widget_queue_draw_area (GTK_WIDGET(ruler),
+ priv->last_pos_rect.x,
+ priv->last_pos_rect.y,
+ priv->last_pos_rect.width,
+ priv->last_pos_rect.height);
+
+ priv->last_pos_rect.x = 0;
+ priv->last_pos_rect.y = 0;
+ priv->last_pos_rect.width = 0;
+ priv->last_pos_rect.height = 0;
+ }
+}
+
static PangoLayout*
sp_ruler_create_layout (GtkWidget *widget,
const gchar *text)
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index e49c4c00a..3cd6c0e28 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -136,13 +136,13 @@ sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *
}
static void
-sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
+sp_object_layout_any_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- if (g_object_get_data(G_OBJECT(spw), "update")) {
+ if (g_object_get_data(tbl, "update")) {
return;
}
- UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
if ( !tracker || tracker->isUpdating() ) {
/*
* When only units are being changed, don't treat changes
@@ -150,7 +150,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
*/
return;
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(TRUE));
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
Inkscape::Selection *selection = desktop->getSelection();
@@ -168,7 +168,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Geom::OptRect bbox_user = selection->bounds(bbox_type);
if ( !bbox_user ) {
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(FALSE));
return;
}
@@ -181,10 +181,10 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Unit const *unit = tracker->getActiveUnit();
g_return_if_fail(unit != NULL);
- GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) );
- GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) );
- GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) );
- GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) );
+ GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( tbl, "X" ) );
+ GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( tbl, "Y" ) );
+ GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( tbl, "width" ) );
+ GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( tbl, "height" ) );
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px");
@@ -205,7 +205,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
}
// Keep proportions if lock is on
- GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") );
+ GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "lock") );
if ( gtk_toggle_action_get_active(lock) ) {
if (adj == a_h) {
x1 = x0 + yrel * bbox_user->dimensions()[Geom::X];
@@ -265,68 +265,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
desktop->getCanvas()->endForcedFullRedraws();
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
-}
-
-static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker )
-{
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true);
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits);
-#else
- Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
-#endif
- inkSpinner->addUnitTracker(unit_tracker);
- inkSpinner = Gtk::manage( inkSpinner );
- GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() );
- return widget;
-}
-
-// TODO create_adjustment_action appears to be a rogue tile copy from toolbox.cpp. Resolve it to be unified:
-
-static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
- gchar const *label,
- gchar const *shortLabel,
- gchar const *data,
- gdouble lower,
- GtkWidget* focusTarget,
- UnitTracker* tracker,
- GtkWidget* spw,
- gchar const *tooltip,
- gboolean altx )
-{
- static bool init = false;
- if ( !init ) {
- init = true;
- ege_adjustment_action_set_compact_tool_factory( createCustomSlider );
- }
-
- GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, lower, 1e6, SPIN_STEP, SPIN_PAGE_STEP, 0 ) );
- if (tracker) {
- tracker->addAdjustment(adj);
- }
- if ( spw ) {
- g_object_set_data( G_OBJECT(spw), data, adj );
- }
-
- EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3, tracker );
- if ( shortLabel ) {
- g_object_set( act, "short_label", Q_(shortLabel), NULL );
- }
-
- g_signal_connect( G_OBJECT(adj), "value_changed", G_CALLBACK(sp_object_layout_any_value_changed), spw );
- if ( focusTarget ) {
- ege_adjustment_action_set_focuswidget( act, focusTarget );
- }
-
- if ( altx ) { // this spinbutton will be activated by alt-x
- g_object_set( G_OBJECT(act), "self-id", "altx", NULL );
- }
-
- // Using a cast just to make sure we pass in the right kind of function pointer
- g_object_set( G_OBJECT(act), "tool-post", static_cast<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
-
- return act;
+ g_object_set_data(tbl, "update", GINT_TO_POINTER(FALSE));
}
// toggle button callbacks and updaters
@@ -497,21 +436,60 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
// four spinbuttons
- eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X",
- -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Horizontal coordinate of selection"), TRUE );
+ eact = create_adjustment_action(
+ /* name= */ "XAction",
+ /* label= */ C_("Select toolbar", "X position"),
+ /* shortLabel= */ C_("Select toolbar", "X:"),
+ /* tooltip= */ C_("Select toolbar", "Horizontal coordinate of selection"),
+ /* path= */ "/tools/select/X",
+ /* def(default) */ 0.0,
+ /* focusTarget= */ GTK_WIDGET(desktop->canvas),
+ /* dataKludge= */ G_OBJECT(spw),
+ /* altx, altx_mark */ TRUE, "altx",
+ /* lower, uppper, step, page */ -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
+ /* descrLabels, descrValues, descrCount */ 0, 0, 0,
+ /* callback= */ sp_object_layout_any_value_changed,
+ /* unit_tracker= */ tracker,
+ /* climb, digits, factor */ SPIN_STEP, 3, 1);
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
- eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y",
- -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Vertical coordinate of selection"), FALSE );
+ eact = create_adjustment_action(
+ /* name= */ "YAction",
+ /* label= */ C_("Select toolbar", "Y position"),
+ /* shortLabel= */ C_("Select toolbar", "Y:"),
+ /* tooltip= */ C_("Select toolbar", "Vertical coordinate of selection"),
+ /* path= */ "/tools/select/Y",
+ /* def(default) */ 0.0,
+ /* focusTarget= */ GTK_WIDGET(desktop->canvas),
+ /* dataKludge= */ G_OBJECT(spw),
+ /* altx, altx_mark */ TRUE, "altx",
+ /* lower, uppper, step, page */ -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
+ /* descrLabels, descrValues, descrCount */ 0, 0, 0,
+ /* callback= */ sp_object_layout_any_value_changed,
+ /* unit_tracker= */ tracker,
+ /* climb, digits, factor */ SPIN_STEP, 3, 1);
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
- eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width",
- 0.0, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Width of selection"), FALSE );
+ eact = create_adjustment_action(
+ /* name= */ "WidthAction",
+ /* label= */ C_("Select toolbar", "Width"),
+ /* shortLabel= */ C_("Select toolbar", "W:"),
+ /* tooltip= */ C_("Select toolbar", "Width of selection"),
+ /* path= */ "/tools/select/width",
+ /* def(default) */ 0.0,
+ /* focusTarget= */ GTK_WIDGET(desktop->canvas),
+ /* dataKludge= */ G_OBJECT(spw),
+ /* altx, altx_mark */ TRUE, "altx",
+ /* lower, uppper, step, page */ 0.0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
+ /* descrLabels, descrValues, descrCount */ 0, 0, 0,
+ /* callback= */ sp_object_layout_any_value_changed,
+ /* unit_tracker= */ tracker,
+ /* climb, digits, factor */ SPIN_STEP, 3, 1);
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
@@ -528,9 +506,22 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
}
- eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height",
- 0.0, GTK_WIDGET(desktop->canvas), tracker, spw,
- _("Height of selection"), FALSE );
+ eact = create_adjustment_action(
+ /* name= */ "HeightAction",
+ /* label= */ C_("Select toolbar", "Height"),
+ /* shortLabel= */ C_("Select toolbar", "H:"),
+ /* tooltip= */ C_("Select toolbar", "Height of selection"),
+ /* path= */ "/tools/select/height",
+ /* def(default) */ 0.0,
+ /* focusTarget= */ GTK_WIDGET(desktop->canvas),
+ /* dataKludge= */ G_OBJECT(spw),
+ /* altx, altx_mark */ TRUE, "altx",
+ /* lower, uppper, step, page */ 0.0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
+ /* descrLabels, descrValues, descrCount */ 0, 0, 0,
+ /* callback= */ sp_object_layout_any_value_changed,
+ /* unit_tracker= */ tracker,
+ /* climb, digits, factor */ SPIN_STEP, 3, 1);
+
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
contextActions->push_back( GTK_ACTION(eact) );
diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp
index dad0a18b0..93eaaee8b 100644
--- a/src/widgets/sp-color-selector.cpp
+++ b/src/widgets/sp-color-selector.cpp
@@ -7,10 +7,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <math.h>
#include <gtk/gtk.h>
#include <glibmm/i18n.h>
diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h
index 308a5519c..75cb79b00 100644
--- a/src/widgets/sp-color-selector.h
+++ b/src/widgets/sp-color-selector.h
@@ -5,10 +5,6 @@
# include <config.h>
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtk/gtk.h>
#include "color.h"
diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp
index dd763aea5..a4c00db7c 100644
--- a/src/widgets/sp-xmlview-attr-list.cpp
+++ b/src/widgets/sp-xmlview-attr-list.cpp
@@ -145,6 +145,7 @@ void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gcha
break;
}
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list->store), &iter);
+ // cppcheck-suppress nullPointer // a string was copied in n by gtk_tree_model_get
if (n) {
g_free(n);
}
@@ -181,6 +182,7 @@ event_attr_changed (Inkscape::XML::Node * /*repr*/,
}
row++;
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(list->store), &iter);
+ // cppcheck-suppress nullPointer // a string was copied in n by gtk_tree_model_get
if (n) {
g_free(n);
}
diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp
index 751a60f06..7e7398091 100644
--- a/src/widgets/spiral-toolbar.cpp
+++ b/src/widgets/spiral-toolbar.cpp
@@ -80,7 +80,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
bool modmade = false;
std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
SPItem *item = *i;
if (SP_IS_SPIRAL(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -196,7 +196,7 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection,
purge_repr_listener( tbl, tbl );
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
SPItem *item = *i;
if (SP_IS_SPIRAL(item)) {
n_selected++;
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 183814b7e..9e142a8db 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -15,10 +15,11 @@
* Tavmjong Bah <tavmjong@free.fr>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
+ * Jabiertxo Arraiza <jabier.arraiza@marker.es>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
- * Copyright (C) 1999-2011 authors
+ * Copyright (C) 1999-2015 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -28,19 +29,23 @@
# include "config.h"
#endif
-#include <glibmm/i18n.h>
+#include <gtkmm.h>
#include "spray-toolbar.h"
#include "desktop.h"
-#include "document-undo.h"
+#include "inkscape.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
#include "preferences.h"
#include "toolbox.h"
+#include "ui/dialog/clonetiler.h"
+#include "ui/dialog/dialog-manager.h"
+#include "ui/dialog/panel-dialog.h"
#include "ui/icon-names.h"
-using Inkscape::DocumentUndo;
+#include <glibmm/i18n.h>
+
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
@@ -53,6 +58,88 @@ using Inkscape::UI::PrefPusher;
//## Spray ##
//########################
+static void sp_stb_update_widgets( GObject *tbl )
+{
+ GtkAction* offset = GTK_ACTION( g_object_get_data(tbl, "offset") );
+ GtkAction* spray_scale = GTK_ACTION( g_object_get_data(tbl, "spray_scale") );
+ GtkAdjustment *adj_offset = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(offset) );
+ GtkAdjustment *adj_scale = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(spray_scale) );
+ GtkAction *no_overlap_action = GTK_ACTION( g_object_get_data(tbl, "no_overlap") );
+ GtkToggleAction *no_overlap = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "no_overlap") );
+ GtkAction *picker_action = GTK_ACTION( g_object_get_data(tbl, "picker") );
+ GtkToggleAction *picker = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "picker") );
+ GtkToggleAction *usepressurescale = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "usepressurescale") );
+ GtkAction *pick_fill = GTK_ACTION( g_object_get_data(tbl, "pick_fill") );
+ GtkAction *pick_stroke = GTK_ACTION( g_object_get_data(tbl, "pick_stroke") );
+ GtkAction *pick_inverse_value = GTK_ACTION( g_object_get_data(tbl, "pick_inverse_value") );
+ GtkAction *pick_center = GTK_ACTION( g_object_get_data(tbl, "pick_center") );
+ gtk_adjustment_set_value( adj_offset, 100.0 );
+ if (gtk_toggle_action_get_active(no_overlap) && gtk_action_get_visible(no_overlap_action)) {
+ gtk_action_set_visible( offset, true );
+ } else {
+ gtk_action_set_visible( offset, false );
+ }
+ if (gtk_toggle_action_get_active(usepressurescale)) {
+ gtk_adjustment_set_value( adj_scale, 0.0 );
+ gtk_action_set_sensitive( spray_scale, false );
+ } else {
+ gtk_action_set_sensitive( spray_scale, true );
+ }
+ if(gtk_toggle_action_get_active(picker) && gtk_action_get_visible(picker_action)){
+ gtk_action_set_visible( pick_fill, true );
+ gtk_action_set_visible( pick_stroke, true );
+ gtk_action_set_visible( pick_inverse_value, true );
+ gtk_action_set_visible( pick_center, true );
+ } else {
+ gtk_action_set_visible( pick_fill, false );
+ gtk_action_set_visible( pick_stroke, false );
+ gtk_action_set_visible( pick_inverse_value, false );
+ gtk_action_set_visible( pick_center, false );
+ }
+}
+
+static void sp_spray_init( GObject *tbl){
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int mode = prefs->getInt("/tools/spray/mode", 0);
+ bool show = true;
+ if(mode == 3 || mode == 2){
+ show = false;
+ }
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "no_overlap") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "over_no_transparent") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "over_transparent") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_no_overlap") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_stroke") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_fill") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_inverse_value") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_center") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "picker") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "offset") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_fill") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_stroke") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_inverse_value") ), show );
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "pick_center") ), show );
+ if(mode == 2){
+ show = true;
+ }
+ gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "spray_rotation") ), show );
+ sp_stb_update_widgets( tbl );
+}
+
+Inkscape::UI::Dialog::CloneTiler *get_clone_tiler_panel(SPDesktop *desktop)
+{
+ if (Inkscape::UI::Dialog::PanelDialogBase *panel_dialog =
+ dynamic_cast<Inkscape::UI::Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("CloneTiler"))) {
+ try {
+ Inkscape::UI::Dialog::CloneTiler &clone_tiler =
+ dynamic_cast<Inkscape::UI::Dialog::CloneTiler &>(panel_dialog->getPanel());
+ return &clone_tiler;
+ } catch (std::exception &e) { }
+ }
+
+ return 0;
+}
+
static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -74,11 +161,12 @@ static void sp_spray_standard_deviation_value_changed( GtkAdjustment *adj, GObje
gtk_adjustment_get_value(adj));
}
-static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject * /*tbl*/ )
+static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject * tbl )
{
int mode = ege_select_one_action_get_active( act );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/spray/mode", mode);
+ sp_spray_init(tbl);
}
static void sp_spray_population_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )
@@ -102,12 +190,105 @@ static void sp_spray_scale_value_changed( GtkAdjustment *adj, GObject * /*tbl*/
gtk_adjustment_get_value(adj));
}
+static void sp_spray_offset_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/spray/offset",
+ gtk_adjustment_get_value(adj));
+}
+
+static void sp_toggle_no_overlap( GtkToggleAction* act, gpointer data)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/no_overlap", active);
+ GObject *tbl = G_OBJECT(data);
+ sp_stb_update_widgets(tbl);
+}
+
+static void sp_toggle_pressure_scale( GtkToggleAction* act, gpointer data)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/usepressurescale", active);
+ if(active == true){
+ prefs->setDouble("/tools/spray/scale_variation", 0);
+ }
+ GObject *tbl = G_OBJECT(data);
+ sp_stb_update_widgets( tbl );
+}
+
+static void sp_toggle_over_no_transparent( GtkToggleAction* act, gpointer data)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/over_no_transparent", active);
+}
+
+static void sp_toggle_over_transparent( GtkToggleAction* act, gpointer data)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/over_transparent", active);
+}
+
+
+static void sp_toggle_picker( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/picker", active);
+ if(active == true){
+ prefs->setBool("/dialogs/clonetiler/dotrace", false);
+ SPDesktop *dt = SP_ACTIVE_DESKTOP;
+ if (Inkscape::UI::Dialog::CloneTiler *ct = get_clone_tiler_panel(dt)){
+ dt->_dlg_mgr->showDialog("CloneTiler");
+ ct->show_page_trace();
+ }
+ }
+ GObject *tbl = G_OBJECT(data);
+ sp_stb_update_widgets(tbl);
+}
+
+static void sp_toggle_pick_center( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/pick_center", active);
+}
+
+static void sp_toggle_pick_fill( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/pick_fill", active);
+}
+
+static void sp_toggle_pick_stroke( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/pick_stroke", active);
+}
+
+static void sp_toggle_pick_no_overlap( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/pick_no_overlap", active);
+}
+
+static void sp_toggle_pick_inverse_value( GtkToggleAction* act, gpointer data )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gboolean active = gtk_toggle_action_get_active(act);
+ prefs->setBool("/tools/spray/pick_inverse_value", active);
+}
void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
{
/* Width */
gchar const* labels[] = {_("(narrow spray)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad spray)")};
@@ -115,15 +296,28 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayWidthAction",
_("Width"), _("Width:"), _("The width of the spray area (relative to the visible canvas area)"),
"/tools/spray/width", 15,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-spray",
+ GTK_WIDGET(desktop->canvas), holder, true, "altx-spray",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_width_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
}
+
+ /* Use Pressure Width button */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPressureWidthAction",
+ _("Pressure"),
+ _("Use the pressure of the input device to alter the width of spray area"),
+ INKSCAPE_ICON("draw-use-pressure"),
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurewidth");
+ g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
+ }
+
{
/* Mean */
gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")};
@@ -131,13 +325,13 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction",
_("Focus"), _("Focus:"), _("0 to spray a spot; increase to enlarge the ring radius"),
"/tools/spray/mean", 0,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-mean",
+ GTK_WIDGET(desktop->canvas), holder, true, "spray-mean",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_mean_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
}
{
@@ -147,18 +341,18 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction",
C_("Spray tool", "Scatter"), C_("Spray tool", "Scatter:"), _("Increase to scatter sprayed objects"),
"/tools/spray/standard_deviation", 70,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-standard_deviation",
+ GTK_WIDGET(desktop->canvas), holder, true, "spray-standard_deviation",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_standard_deviation_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
}
/* Mode */
{
- GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
+ GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
@@ -174,6 +368,7 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
1, _("Spray clones of the initial selection"),
2, INKSCAPE_ICON("spray-mode-clone"),
-1 );
+
#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
@@ -182,6 +377,14 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
2, INKSCAPE_ICON("spray-mode-union"),
-1 );
#endif
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Delete sprayed items"),
+ 1, _("Delete sprayed items from selection"),
+ 2, INKSCAPE_ICON("draw-eraser"),
+ -1 );
+
EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act, "short_label", _("Mode:"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
@@ -208,25 +411,25 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Amount"), _("Amount:"),
_("Adjusts the number of items sprayed per click"),
"/tools/spray/population", 70,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-population",
+ GTK_WIDGET(desktop->canvas), holder, true, "spray-population",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_population_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
g_object_set_data( holder, "spray_population", eact );
}
- /* Use Pressure button */
+ /* Use Pressure Population button */
{
- InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction",
+ InkToggleAction* act = ink_toggle_action_new( "SprayPressurePopulationAction",
_("Pressure"),
_("Use the pressure of the input device to alter the amount of sprayed objects"),
INKSCAPE_ICON("draw-use-pressure"),
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
- PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure");
+ PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurepopulation");
g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
}
@@ -239,13 +442,13 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
// xgettext:no-c-format
_("Variation of the rotation of the sprayed objects; 0% for the same rotation than the original object"),
"/tools/spray/rotation_variation", 0,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-rotation",
+ GTK_WIDGET(desktop->canvas), holder, true, "spray-rotation",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_rotation_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
g_object_set_data( holder, "spray_rotation", eact );
}
@@ -257,18 +460,162 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
// xgettext:no-c-format
_("Variation in the scale of the sprayed objects; 0% for the same scale than the original object"),
"/tools/spray/scale_variation", 0,
- GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-scale",
+ GTK_WIDGET(desktop->canvas), holder, true, "spray-scale",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_spray_scale_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_sensitive( GTK_ACTION(eact), true );
g_object_set_data( holder, "spray_scale", eact );
}
+ /* Use Pressure Scale button */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPressureScaleAction",
+ _("Pressure"),
+ _("Use the pressure of the input device to alter the scale of new items"),
+ INKSCAPE_ICON("draw-use-pressure"),
+ Inkscape::ICON_SIZE_DECORATION);
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressurescale", false) );
+ g_object_set_data( holder, "usepressurescale", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pressure_scale), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* Picker */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickColorAction",
+ _("Pick color from the drawing. You can use clonetiler trace dialog for advanced effects. In clone mode original fill or stroke colors must be unset."),
+ _("Pick color from the drawing. You can use clonetiler trace dialog for advanced effects. In clone mode original fill or stroke colors must be unset."),
+ INKSCAPE_ICON("color-picker"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/picker", false) );
+ g_object_set_data( holder, "picker", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_picker), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Pick from center */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickCenterAction",
+ _("Pick from center instead average area."),
+ _("Pick from center instead average area."),
+ INKSCAPE_ICON("snap-bounding-box-center"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pick_center", true) );
+ g_object_set_data( holder, "pick_center", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_center), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+ /* Inverse Value Size */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickInverseValueAction",
+ _("Inverted pick value, retaining color in advanced trace mode"),
+ _("Inverted pick value, retaining color in advanced trace mode"),
+ INKSCAPE_ICON("object-tweak-shrink"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pick_inverse_value", false) );
+ g_object_set_data( holder, "pick_inverse_value", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_inverse_value), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Pick Fill */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickFillAction",
+ _("Apply picked color to fill"),
+ _("Apply picked color to fill"),
+ INKSCAPE_ICON("paint-solid"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pick_fill", false) );
+ g_object_set_data( holder, "pick_fill", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_fill), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Pick Stroke */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickStrokeAction",
+ _("Apply picked color to stroke"),
+ _("Apply picked color to stroke"),
+ INKSCAPE_ICON("no-marker"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pick_stroke", false) );
+ g_object_set_data( holder, "pick_stroke", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_stroke), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Pick No Overlap */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPickNoOverlapAction",
+ _("No overlap between colors"),
+ _("No overlap between colors"),
+ INKSCAPE_ICON("symbol-bigger"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pick_no_overlap", false) );
+ g_object_set_data( holder, "pick_no_overlap", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_no_overlap), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Over Transparent */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayOverTransparentAction",
+ _("Apply over transparent areas"),
+ _("Apply over transparent areas"),
+ INKSCAPE_ICON("object-hidden"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/over_transparent", true) );
+ g_object_set_data( holder, "over_transparent", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_over_transparent), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Over No Transparent */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayOverNoTransparentAction",
+ _("Apply over no transparent areas"),
+ _("Apply over no transparent areas"),
+ INKSCAPE_ICON("object-visible"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/over_no_transparent", true) );
+ g_object_set_data( holder, "over_no_transparent", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_over_no_transparent), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Overlap */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayNoOverlapAction",
+ _("Prevent overlapping objects"),
+ _("Prevent overlapping objects"),
+ INKSCAPE_ICON("distribute-randomize"),
+ secondarySize );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/no_overlap", false) );
+ g_object_set_data( holder, "no_overlap", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_no_overlap), holder) ;
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ /* Offset */
+ {
+ gchar const* labels[] = {_("(minimum offset)"), 0, 0, 0, _("(default)"), 0, 0, _("(maximum offset)")};
+ gdouble values[] = {0, 25, 50, 75, 100, 150, 200, 1000};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayToolOffsetAction",
+ _("Offset %"), _("Offset %:"),
+ _("Increase to segregate objects more (value in percent)"),
+ "/tools/spray/offset", 100,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
+ 0, 1000, 1, 4,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_offset_value_changed, NULL, 0 , 0);
+ g_object_set_data( holder, "offset", eact );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ }
+ sp_spray_init(holder);
}
diff --git a/src/widgets/spray-toolbar.h b/src/widgets/spray-toolbar.h
index d1d5c7b4c..30d8233ca 100644
--- a/src/widgets/spray-toolbar.h
+++ b/src/widgets/spray-toolbar.h
@@ -21,7 +21,7 @@
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
- * Copyright (C) 1999-2011 authors
+ * Copyright (C) 1999-2015 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 96005d7df..982a3c854 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -84,7 +84,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -129,7 +129,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
bool modmade = false;
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -182,11 +182,11 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
bool modmade = false;
if ( prop_action ) {
- gtk_action_set_sensitive( prop_action, !flat );
+ gtk_action_set_visible( prop_action, !flat );
}
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -225,7 +225,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -265,7 +265,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
Inkscape::XML::Node *repr = item->getRepr();
@@ -319,10 +319,10 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n
EgeSelectOneAction* flat_action = EGE_SELECT_ONE_ACTION( g_object_get_data( G_OBJECT(tbl), "flat_action" ) );
if ( flatsides && !strcmp(flatsides,"false") ) {
ege_select_one_action_set_active( flat_action, 1 );
- gtk_action_set_sensitive( prop_action, TRUE );
+ gtk_action_set_visible( prop_action, TRUE );
} else {
ege_select_one_action_set_active( flat_action, 0 );
- gtk_action_set_sensitive( prop_action, FALSE );
+ gtk_action_set_visible( prop_action, FALSE );
}
} else if ((!strcmp(name, "sodipodi:r1") || !strcmp(name, "sodipodi:r2")) && (!isFlatSided) ) {
adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "proportion"));
@@ -368,7 +368,7 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
purge_repr_listener( tbl, tbl );
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (SP_IS_STAR(item)) {
n_selected++;
@@ -415,7 +415,7 @@ static void sp_stb_defaults( GtkWidget * /*widget*/, GObject *dataKludge )
ege_select_one_action_set_active( flat_action, flat ? 0 : 1 );
GtkAction* sb2 = GTK_ACTION( g_object_get_data( dataKludge, "prop_action" ) );
- gtk_action_set_sensitive( sb2, !flat );
+ gtk_action_set_visible( sb2, !flat );
adj = GTK_ADJUSTMENT( g_object_get_data( dataKludge, "magnitude" ) );
gtk_adjustment_set_value(adj, mag);
@@ -521,9 +521,9 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
}
if ( !isFlatSided ) {
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_visible( GTK_ACTION(eact), TRUE );
} else {
- gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
+ gtk_action_set_visible( GTK_ACTION(eact), FALSE );
}
/* Roundedness */
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index d05b3b994..84a6e77ad 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -221,6 +221,67 @@ StrokeStyle::StrokeStyle() :
#endif
i++;
+ /* Dash */
+ spw_label(table, _("Dashes:"), 0, i, NULL); //no mnemonic for now
+ //decide what to do:
+ // implement a set_mnemonic_source function in the
+ // SPDashSelector class, so that we do not have to
+ // expose any of the underlying widgets?
+ dashSelector = Gtk::manage(new SPDashSelector);
+
+ dashSelector->show();
+
+#if WITH_GTKMM_3_0
+ dashSelector->set_hexpand();
+ dashSelector->set_halign(Gtk::ALIGN_FILL);
+ dashSelector->set_valign(Gtk::ALIGN_CENTER);
+ table->attach(*dashSelector, 1, i, 3, 1);
+#else
+ table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
+#endif
+
+ dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
+
+ i++;
+
+ /* Drop down marker selectors*/
+ // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes
+ // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
+
+ spw_label(table, _("Markers:"), 0, i, NULL);
+
+ hb = spw_hbox(table, 1, 1, i);
+ i++;
+
+ startMarkerCombo = Gtk::manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START));
+ startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape"));
+ startMarkerConn = startMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START));
+ startMarkerCombo->show();
+
+ hb->pack_start(*startMarkerCombo, true, true, 0);
+
+ midMarkerCombo = Gtk::manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID));
+ midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
+ midMarkerConn = midMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID));
+ midMarkerCombo->show();
+
+ hb->pack_start(*midMarkerCombo, true, true, 0);
+
+ endMarkerCombo = Gtk::manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END));
+ endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape"));
+ endMarkerConn = endMarkerCombo->signal_changed().connect(
+ sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
+ sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END));
+ endMarkerCombo->show();
+
+ hb->pack_start(*endMarkerCombo, true, true, 0);
+
+ i++;
+
/* Join type */
// TRANSLATORS: The line join style specifies the shape to be used at the
// corners of paths. It can be "miter", "round" or "bevel".
@@ -230,14 +291,6 @@ StrokeStyle::StrokeStyle() :
Gtk::RadioButtonGroup joinGrp;
- joinMiter = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-miter"),
- hb, STROKE_STYLE_BUTTON_JOIN, "miter");
-
- // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner.
- // For an example, draw a triangle with a large stroke width and modify the
- // "Join" option (in the Fill and Stroke dialog).
- joinMiter->set_tooltip_text(_("Miter join"));
-
joinRound = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-round"),
hb, STROKE_STYLE_BUTTON_JOIN, "round");
@@ -254,7 +307,13 @@ StrokeStyle::StrokeStyle() :
// "Join" option (in the Fill and Stroke dialog).
joinBevel->set_tooltip_text(_("Bevel join"));
- i++;
+ joinMiter = makeRadioButton(joinGrp, INKSCAPE_ICON("stroke-join-miter"),
+ hb, STROKE_STYLE_BUTTON_JOIN, "miter");
+
+ // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner.
+ // For an example, draw a triangle with a large stroke width and modify the
+ // "Join" option (in the Fill and Stroke dialog).
+ joinMiter->set_tooltip_text(_("Miter join"));
/* Miterlimit */
// TRANSLATORS: Miter limit: only for "miter join", this limits the length
@@ -265,8 +324,6 @@ StrokeStyle::StrokeStyle() :
// when they become too long.
//spw_label(t, _("Miter _limit:"), 0, i);
- hb = spw_hbox(table, 3, 1, i);
-
#if WITH_GTKMM_3_0
miterLimitAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(4.0, 0.0, 100.0, 0.1, 10.0, 0.0));
miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2);
@@ -277,7 +334,6 @@ StrokeStyle::StrokeStyle() :
miterLimitSpin->set_tooltip_text(_("Maximum length of the miter (in units of stroke width)"));
miterLimitSpin->show();
- spw_label(table, _("Miter _limit:"), 0, i, miterLimitSpin);
sp_dialog_defocus_on_enter_cpp(miterLimitSpin);
hb->pack_start(*miterLimitSpin, false, false, 0);
@@ -288,6 +344,7 @@ StrokeStyle::StrokeStyle() :
#else
miterLimitAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB));
#endif
+
i++;
/* Cap type */
@@ -322,64 +379,43 @@ StrokeStyle::StrokeStyle() :
i++;
- /* Dash */
- spw_label(table, _("Dashes:"), 0, i, NULL); //no mnemonic for now
- //decide what to do:
- // implement a set_mnemonic_source function in the
- // SPDashSelector class, so that we do not have to
- // expose any of the underlying widgets?
- dashSelector = Gtk::manage(new SPDashSelector);
-
- dashSelector->show();
+ /* Paint order */
+ // TRANSLATORS: Paint order determines the order the 'fill', 'stroke', and 'markers are painted.
+ spw_label(table, _("Order:"), 0, i, NULL);
-#if WITH_GTKMM_3_0
- dashSelector->set_hexpand();
- dashSelector->set_halign(Gtk::ALIGN_FILL);
- dashSelector->set_valign(Gtk::ALIGN_CENTER);
- table->attach(*dashSelector, 1, i, 3, 1);
-#else
- table->attach(*dashSelector, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
-#endif
+ hb = spw_hbox(table, 4, 1, i);
- dashSelector->changed_signal.connect(sigc::mem_fun(*this, &StrokeStyle::lineDashChangedCB));
+ Gtk::RadioButtonGroup paintOrderGrp;
- i++;
+ paintOrderFSM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fsm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "normal");
+ paintOrderFSM->set_tooltip_text(_("Fill, Stroke, Markers"));
- /* Drop down marker selectors*/
- // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes
- // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
+ paintOrderSFM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-sfm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke fill markers");
+ paintOrderSFM->set_tooltip_text(_("Stroke, Fill, Markers"));
- spw_label(table, _("Markers:"), 0, i, NULL);
+ paintOrderFMS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fms"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "fill markers stroke");
+ paintOrderFMS->set_tooltip_text(_("Fill, Markers, Stroke"));
- hb = spw_hbox(table, 1, 1, i);
i++;
- startMarkerCombo = Gtk::manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START));
- startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape"));
- startMarkerConn = startMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START));
- startMarkerCombo->show();
+ hb = spw_hbox(table, 4, 1, i);
- hb->pack_start(*startMarkerCombo, true, true, 0);
+ paintOrderMFS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-mfs"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers fill stroke");
+ paintOrderMFS->set_tooltip_text(_("Markers, Fill, Stroke"));
- midMarkerCombo = Gtk::manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID));
- midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
- midMarkerConn = midMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID));
- midMarkerCombo->show();
+ paintOrderSMF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-smf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke markers fill");
+ paintOrderSMF->set_tooltip_text(_("Stroke, Markers, Fill"));
- hb->pack_start(*midMarkerCombo, true, true, 0);
+ paintOrderMSF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-msf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers stroke fill");
+ paintOrderMSF->set_tooltip_text(_("Markers, Stroke, Fill"));
- endMarkerCombo = Gtk::manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END));
- endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape"));
- endMarkerConn = endMarkerCombo->signal_changed().connect(
- sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>(
- sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END));
- endMarkerCombo->show();
-
- hb->pack_start(*endMarkerCombo, true, true, 0);
+ i++;
setDesktop(desktop);
updateLine();
@@ -480,7 +516,7 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw,
Inkscape::Selection *selection = spw->desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using <path>
continue;
@@ -802,6 +838,43 @@ StrokeStyle::setCapType (unsigned const captype)
}
/**
+ * Sets the cap type for a line, and updates the stroke style widget's buttons
+ */
+void
+StrokeStyle::setPaintOrder (gchar const *paint_order)
+{
+ Gtk::RadioButton *tb = paintOrderFSM;
+
+ SPIPaintOrder temp;
+ temp.read( paint_order );
+
+ if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL) {
+
+ if (temp.layer[0] == SP_CSS_PAINT_ORDER_FILL) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderFSM;
+ } else {
+ tb = paintOrderFMS;
+ }
+ } else if (temp.layer[0] == SP_CSS_PAINT_ORDER_STROKE) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_FILL) {
+ tb = paintOrderSFM;
+ } else {
+ tb = paintOrderSMF;
+ }
+ } else {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderMSF;
+ } else {
+ tb = paintOrderMFS;
+ }
+ }
+
+ }
+ setPaintOrderButtons(tb);
+}
+
+/**
* Callback for when stroke style widget is updated, including markers, cap type,
* join type, etc.
*/
@@ -825,6 +898,9 @@ StrokeStyle::updateLine()
int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKECAP);
int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEJOIN);
+
+ int result_order = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_PAINTORDER);
+
SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke;
if (!sel || sel->isEmpty()) {
@@ -902,6 +978,13 @@ StrokeStyle::updateLine()
setCapButtons(NULL);
}
+ if (result_order != QUERY_STYLE_MULTIPLE_DIFFERENT &&
+ result_order != QUERY_STYLE_NOTHING ) {
+ setPaintOrder (query.paint_order.value);
+ } else {
+ setPaintOrder (NULL);
+ }
+
if (!sel || sel->isEmpty())
return;
@@ -981,7 +1064,7 @@ StrokeStyle::scaleLine()
int ndash;
dashSelector->get_dash(&ndash, &dash, &offset);
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
/* Set stroke width */
double width;
if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
@@ -1109,6 +1192,11 @@ void StrokeStyle::buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw)
sp_repr_css_set_property(css, "stroke-linecap", tb->get_stroke_style());
sp_desktop_set_style (spw->desktop, css);
spw->setCapButtons(tb);
+ break;
+ case STROKE_STYLE_BUTTON_ORDER:
+ sp_repr_css_set_property(css, "paint-order", tb->get_stroke_style());
+ sp_desktop_set_style (spw->desktop, css);
+ //spw->setPaintButtons(tb);
}
sp_repr_css_attr_unref(css);
@@ -1143,6 +1231,21 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active)
/**
+ * Updates the paint order style toggle buttons
+ */
+void
+StrokeStyle::setPaintOrderButtons(Gtk::ToggleButton *active)
+{
+ paintOrderFSM->set_active(active == paintOrderFSM);
+ paintOrderSFM->set_active(active == paintOrderSFM);
+ paintOrderFMS->set_active(active == paintOrderFMS);
+ paintOrderMFS->set_active(active == paintOrderMFS);
+ paintOrderSMF->set_active(active == paintOrderSMF);
+ paintOrderMSF->set_active(active == paintOrderMSF);
+}
+
+
+/**
* Updates the marker combobox to highlight the appropriate marker and scroll to
* that marker.
*/
@@ -1156,7 +1259,7 @@ StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects)
};
bool all_texts = true;
- for(std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();++i){
if (!SP_IS_TEXT (*i)) {
all_texts = false;
break;
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index 2605e1acf..d83067a4a 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -127,7 +127,8 @@ private:
/** List of valid types for the stroke-style radio-button widget */
enum StrokeStyleButtonType {
STROKE_STYLE_BUTTON_JOIN, ///< A button to set the line-join style
- STROKE_STYLE_BUTTON_CAP ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_CAP, ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_ORDER ///< A button to set the paint-order style
};
/**
@@ -158,8 +159,10 @@ private:
void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style);
void setJoinType (unsigned const jointype);
void setCapType (unsigned const captype);
+ void setPaintOrder (gchar const *paint_order);
void setJoinButtons(Gtk::ToggleButton *active);
void setCapButtons(Gtk::ToggleButton *active);
+ void setPaintOrderButtons(Gtk::ToggleButton *active);
void scaleLine();
void setScaledDash(SPCSSAttr *css, int ndash, double *dash, double offset, double scale);
void setMarkerColor(SPObject *marker, int loc, SPItem *item);
@@ -204,6 +207,12 @@ private:
StrokeStyleButton *capButt;
StrokeStyleButton *capRound;
StrokeStyleButton *capSquare;
+ StrokeStyleButton *paintOrderFSM;
+ StrokeStyleButton *paintOrderSFM;
+ StrokeStyleButton *paintOrderFMS;
+ StrokeStyleButton *paintOrderMFS;
+ StrokeStyleButton *paintOrderSMF;
+ StrokeStyleButton *paintOrderMSF;
SPDashSelector *dashSelector;
gboolean update;
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 7b22e4af7..c49f0bc05 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -54,12 +54,17 @@
#include "ui/icon-names.h"
#include "ui/tools/text-tool.h"
#include "ui/tools/tool-base.h"
+#include "ui/widget/unit-tracker.h"
+#include "util/units.h"
#include "verbs.h"
#include "xml/repr.h"
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
+using Inkscape::Util::unit_table;
//#define DEBUG_TEXT
@@ -155,7 +160,7 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb
act->active = 0; // New family is always at top of list.
}
- std::pair<Glib::ustring,Glib::ustring> ui = fontlister->set_font_family( act->active );
+ fontlister->set_font_family( act->active );
// active text set in sp_text_toolbox_selection_changed()
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -373,7 +378,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
// move the x of all texts to preserve the same bbox
Inkscape::Selection *selection = desktop->getSelection();
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
if (SP_IS_TEXT(*i)) {
SPItem *item = *i;
@@ -504,8 +509,14 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
{
- // quit if run by the _changed callbacks
- if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
+
+ if ( !tracker || tracker->isUpdating() || g_object_get_data(tbl, "freeze")) {
+ /*
+ * When only units are being changed, don't treat changes
+ * to adjuster values as object changes.
+ * or quit if run by the _changed callbacks
+ */
return;
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
@@ -514,7 +525,18 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
// Set css line height.
SPCSSAttr *css = sp_repr_css_attr_new ();
Inkscape::CSSOStringStream osfs;
- osfs << gtk_adjustment_get_value(adj)*100 << "%";
+
+ gdouble value = gtk_adjustment_get_value(adj);
+
+ Unit const *unit = tracker->getActiveUnit();
+
+ // Value can only be in px or percent or naked pc (e.g. 0.7 for 70%)
+ if (unit->abbr != "%") {
+ value = unit->convert(value, "px");
+ unit = unit_table.getUnit("px");
+ }
+
+ osfs << value << unit->abbr;
sp_repr_css_set_property (css, "line-height", osfs.str().c_str());
// Apply line-height to selected objects.
@@ -526,7 +548,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
Inkscape::Selection *selection = desktop->getSelection();
bool modmade = false;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
if (SP_IS_TEXT (*i)) {
(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
modmade = true;
@@ -737,7 +759,7 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject *tbl )
+static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
// quit if run by the _changed callbacks
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
@@ -752,13 +774,73 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject *
{
case 0:
{
- sp_repr_css_set_property (css, "writing-mode", "lr");
+ sp_repr_css_set_property (css, "writing-mode", "lr-tb");
break;
}
case 1:
{
- sp_repr_css_set_property (css, "writing-mode", "tb");
+ sp_repr_css_set_property (css, "writing-mode", "tb-rl");
+ break;
+ }
+
+ case 2:
+ {
+ sp_repr_css_set_property (css, "writing-mode", "vertical-lr");
+ break;
+ }
+}
+
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+
+ // If querying returned nothing, update default style.
+ if (result_numbers == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ }
+
+ sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
+ if(result_numbers != QUERY_STYLE_NOTHING)
+ {
+ DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change writing mode"));
+ }
+ sp_repr_css_attr_unref (css);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
+{
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ int mode = ege_select_one_action_get_active( act );
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ switch (mode)
+ {
+ case 0:
+ {
+ sp_repr_css_set_property (css, "text-orientation", "auto");
+ break;
+ }
+
+ case 1:
+ {
+ sp_repr_css_set_property (css, "text-orientation", "upright");
+ break;
+ }
+
+ case 2:
+ {
+ sp_repr_css_set_property (css, "text-orientation", "sideways");
break;
}
}
@@ -871,7 +953,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
// Find out if we have flowed text now so we can use it several places
gboolean isFlow = false;
std::vector<SPItem*> itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
// const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
// std::cout << " " << id << std::endl;
if( SP_IS_FLOWTEXT(*i)) {
@@ -893,13 +975,17 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTSTYLE);
int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
int result_baseline = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_BASELINES);
+ int result_wmode = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_WRITINGMODES);
/*
* If no text in selection (querying returned nothing), read the style from
* the /tools/text preferencess (default style for new texts). Return if
* tool bar already set to these preferences.
*/
- if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
+ if (result_family == QUERY_STYLE_NOTHING ||
+ result_style == QUERY_STYLE_NOTHING ||
+ result_numbers == QUERY_STYLE_NOTHING ||
+ result_wmode == QUERY_STYLE_NOTHING ) {
// There are no texts in selection, read from preferences.
query.readFromPrefs("/tools/text");
#ifdef DEBUG_TEXT
@@ -1009,21 +1095,31 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
// Line height (spacing)
double height;
+
+ Unit const *lh_unit;
+ UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) );
+
if (query.line_height.normal) {
- height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
+ lh_unit = unit_table.getUnit("%");
+ height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL * 100;
+ } else if (query.line_height.unit == SP_CSS_UNIT_PERCENT) {
+ lh_unit = unit_table.getUnit("%");
+ height = query.line_height.value * 100;
} else {
- if (query.line_height.unit == SP_CSS_UNIT_PERCENT) {
- height = query.line_height.value;
- } else {
- height = query.line_height.computed;
- }
+ lh_unit = tracker->getActiveUnit();
+ // Can get unit like this: unit_table.getUnit(query.line_height.unit);
+ height = Inkscape::Util::Quantity::convert(query.line_height.computed, "px", lh_unit);
}
+ // Set before value is set
+ tracker->setActiveUnit(lh_unit);
+
GtkAction* lineHeightAction = GTK_ACTION( g_object_get_data( tbl, "TextLineHeightAction" ) );
GtkAdjustment *lineHeightAdjustment =
ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION( lineHeightAction ));
gtk_adjustment_set_value( lineHeightAdjustment, height );
+ height = gtk_adjustment_get_value( lineHeightAdjustment );
// Word spacing
double wordSpacing;
@@ -1047,13 +1143,42 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
gtk_adjustment_set_value( letterSpacingAdjustment, letterSpacing );
+ // Writing mode
+ int activeButton2 = 0;
+ if (query.writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) activeButton2 = 0;
+ if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_RL) activeButton2 = 1;
+ if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_LR) activeButton2 = 2;
+
+ EgeSelectOneAction* writingModeAction =
+ EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextWritingModeAction" ) );
+ ege_select_one_action_set_active( writingModeAction, activeButton2 );
+
// Orientation
- int activeButton2 = (query.writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB ? 0 : 1);
+ int activeButton3 = 0;
+ if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_MIXED ) activeButton3 = 0;
+ if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_UPRIGHT ) activeButton3 = 1;
+ if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_SIDEWAYS) activeButton3 = 2;
EgeSelectOneAction* textOrientationAction =
EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextOrientationAction" ) );
- ege_select_one_action_set_active( textOrientationAction, activeButton2 );
+ ege_select_one_action_set_active( textOrientationAction, activeButton3 );
+
+ // Disable text orientation for horizontal text.. See above for why this nonsense
+ model = GTK_LIST_STORE( ege_select_one_action_get_model( textOrientationAction ) );
+
+ path = gtk_tree_path_new_from_string("0");
+ gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
+ gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
+
+ path = gtk_tree_path_new_from_string("1");
+ gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
+ gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
+
+ path = gtk_tree_path_new_from_string("2");
+ gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
+ gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
+ ege_select_one_action_update_sensitive( textOrientationAction );
}
@@ -1165,7 +1290,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p
SPDocument *document = desktop->getDocument();
std::vector<SPItem*> x,y;
std::vector<SPItem*> allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y);
- for(std::vector<SPItem*>::const_reverse_iterator i=allList.rbegin();i!=allList.rend();i++){
+ for(std::vector<SPItem*>::const_reverse_iterator i=allList.rbegin();i!=allList.rend(); ++i){
SPItem *item = *i;
SPStyle *style = item->style;
@@ -1197,6 +1322,15 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p
static void text_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
+static void destroy_tracker( GObject* obj, gpointer /*user_data*/ )
+{
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(obj, "tracker"));
+ if ( tracker ) {
+ delete tracker;
+ g_object_set_data( obj, "tracker", 0 );
+ }
+}
+
// Define all the "widgets" in the toolbar.
void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -1387,7 +1521,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_align_mode_changed), holder );
}
- /* Orientation (Left to Right, Top to Bottom */
+ /* Writing mode (Horizontal, Vertical-LR, Vertical-RL) */
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
@@ -1402,14 +1536,73 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
- 0, _("Vertical"),
- 1, _("Vertical text"),
+ 0, _("Vertical — RL"),
+ 1, _("Vertical text — lines: right to left"),
2, INKSCAPE_ICON("format-text-direction-vertical"),
-1 );
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Vertical — LR"),
+ 1, _("Vertical text — lines: left to right"), // Mongolian!
+ 2, INKSCAPE_ICON("format-text-direction-vertical-lr"),
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "TextWritingModeAction", // Name
+ _("Writing mode"), // Label
+ _("Block progression"), // Tooltip
+ NULL, // Icon name
+ GTK_TREE_MODEL(model) ); // Model
+
+ g_object_set( act, "short_label", "NotUsed", NULL );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "TextWritingModeAction", act );
+
+ ege_select_one_action_set_appearance( act, "full" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
+ ege_select_one_action_set_icon_column( act, 2 );
+ ege_select_one_action_set_icon_size( act, secondarySize );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+
+ gint mode = prefs->getInt("/tools/text/writing_mode", 0);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_writing_mode_changed), holder );
+ }
+
+ /* Text (glyph) orientation (Auto (mixed), Upright, Sideways) */
+ {
+ GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
+
+ GtkTreeIter iter;
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Auto"),
+ 1, _("Auto glyph orientation"),
+ 2, INKSCAPE_ICON("text-orientation-auto"),
+ 3, true,
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Upright"),
+ 1, _("Upright glyph orientation"),
+ 2, INKSCAPE_ICON("text-orientation-upright"),
+ 3, true,
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Sideways"),
+ 1, _("Sideways glyph orientation"),
+ 2, INKSCAPE_ICON("text-orientation-sideways"),
+ 3, true,
+ -1 );
+
EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name
- _("Orientation"), // Label
- _("Text orientation"), // Tooltip
+ _("Text orientation"), // Label
+ _("Text (glyph) orientation in vertical text."), // Tooltip
NULL, // Icon name
GTK_TREE_MODEL(model) ); // Model
@@ -1423,10 +1616,11 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
ege_select_one_action_set_icon_column( act, 2 );
ege_select_one_action_set_icon_size( act, secondarySize );
ege_select_one_action_set_tooltip_column( act, 1 );
+ ege_select_one_action_set_sensitive_column( act, 3 );
- gint mode = prefs->getInt("/tools/text/orientation", 0);
+ gint mode = prefs->getInt("/tools/text/text_orientation", 0);
ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_mode_changed), holder );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder );
}
/* Line height */
@@ -1435,22 +1629,29 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
gchar const* labels[] = {_("Smaller spacing"), 0, 0, 0, 0, C_("Text tool", "Normal"), 0, 0, 0, 0, 0, _("Larger spacing")};
gdouble values[] = { 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1,2, 1.3, 1.4, 1.5, 2.0};
+ // Add the units menu.
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ tracker->prependUnit(unit_table.getUnit("%"));
+
+ g_object_set_data( holder, "tracker", tracker );
+ g_signal_connect( holder, "destroy", G_CALLBACK(destroy_tracker), holder );
+
EgeAdjustmentAction *eact = create_adjustment_action(
"TextLineHeightAction", /* name */
_("Line Height"), /* label */
_("Line:"), /* short label */
- _("Spacing between lines (times font size)"), /* tooltip */
+ _("Spacing between baselines"), /* tooltip */
"/tools/text/lineheight", /* preferences path */
- 0.0, /* default */
+ 125, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
- 0.0, 10.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
+ 0.0, 1e6, 1.0, 10.0, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_lineheight_value_changed, /* callback */
- NULL, /* unit tracker */
- 0.1, /* step (used?) */
+ tracker, /* unit tracker */
+ 1.0, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
);
@@ -1458,6 +1659,11 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
g_object_set_data( holder, "TextLineHeightAction", eact );
g_object_set( G_OBJECT(eact), "iconId", "text_line_spacing", NULL );
+
+ GtkAction* act = tracker->createAction( "TextLineHeightUnitAction", _("Units"), ("") );
+ gtk_action_group_add_action( mainActions, act );
+ g_object_set_data( holder, "TextLineHeightUnitAction", act );
+
}
/* Word spacing */
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index d56b91f5e..f4d7ebf25 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -16,10 +16,11 @@
* Tavmjong Bah <tavmjong@free.fr>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
+ * Jabiertxo Arraiza <jabier.arraiza@marker.es>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
- * Copyright (C) 1999-2011 authors
+ * Copyright (C) 1999-2015 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -54,6 +55,7 @@
#include "ui/tools-switch.h"
#include "../ui/icon-names.h"
#include "../ui/widget/style-swatch.h"
+#include "../ui/widget/unit-tracker.h"
#include "../verbs.h"
#include "../widgets/button.h"
#include "../widgets/spinbutton-events.h"
@@ -78,7 +80,11 @@
#include "measure-toolbar.h"
#include "node-toolbar.h"
#include "rect-toolbar.h"
-#include "paintbucket-toolbar.h"
+
+#if HAVE_POTRACE
+# include "paintbucket-toolbar.h"
+#endif
+
#include "pencil-toolbar.h"
#include "select-toolbar.h"
#include "spray-toolbar.h"
@@ -150,7 +156,9 @@ static struct {
{ "/tools/calligraphic", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS },
{ "/tools/lpetool", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS },
{ "/tools/eraser", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
+#if HAVE_POTRACE
{ "/tools/paintbucket", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
+#endif
{ "/tools/text", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
{ "/tools/connector","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
{ "/tools/gradient", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS },
@@ -211,8 +219,10 @@ static struct {
SP_VERB_INVALID, 0, 0},
{ "/tools/mesh", "mesh_toolbox", 0, sp_mesh_toolbox_prep, "MeshToolbar",
SP_VERB_INVALID, 0, 0},
+#if HAVE_POTRACE
{ "/tools/paintbucket", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar",
SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")},
+#endif
{ NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL }
};
@@ -309,14 +319,28 @@ static gchar const * ui_descr =
" <toolitem action='SprayModeAction' />"
" <separator />"
" <toolitem action='SprayWidthAction' />"
+ " <toolitem action='SprayPressureWidthAction' />"
" <toolitem action='SprayPopulationAction' />"
- " <toolitem action='SprayPressureAction' />"
+ " <toolitem action='SprayPressurePopulationAction' />"
" <separator />"
" <toolitem action='SprayRotationAction' />"
" <toolitem action='SprayScaleAction' />"
+ " <toolitem action='SprayPressureScaleAction' />"
" <separator />"
" <toolitem action='SprayStandard_deviationAction' />"
" <toolitem action='SprayMeanAction' />"
+ " <separator />"
+ " <toolitem action='SprayOverNoTransparentAction' />"
+ " <toolitem action='SprayOverTransparentAction' />"
+ " <toolitem action='SprayPickNoOverlapAction' />"
+ " <toolitem action='SprayNoOverlapAction' />"
+ " <toolitem action='SprayToolOffsetAction' />"
+ " <separator />"
+ " <toolitem action='SprayPickColorAction' />"
+ " <toolitem action='SprayPickFillAction' />"
+ " <toolitem action='SprayPickStrokeAction' />"
+ " <toolitem action='SprayPickInverseValueAction' />"
+ " <toolitem action='SprayPickCenterAction' />"
" </toolbar>"
" <toolbar name='ZoomToolbar'>"
@@ -339,9 +363,24 @@ static gchar const * ui_descr =
" <toolbar name='MeasureToolbar'>"
" <toolitem action='MeasureFontSizeAction' />"
" <separator />"
+ " <toolitem action='MeasurePrecisionAction' />"
+ " <separator />"
+ " <toolitem action='MeasureScaleAction' />"
+ " <separator />"
+ " <toolitem action='MeasureOffsetAction' />"
+ " <separator />"
" <toolitem action='measure_units_label' />"
" <toolitem action='MeasureUnitsAction' />"
- " </toolbar>"
+ " <toolitem action='MeasureIgnore1stAndLast' />"
+ " <toolitem action='MeasureInBettween' />"
+ " <toolitem action='MeasureShowHidden' />"
+ " <toolitem action='MeasureAllLayers' />"
+ " <toolitem action='MeasureReverse' />"
+ " <toolitem action='MeasureToPhantom' />"
+ " <toolitem action='MeasureToGuides' />"
+ " <toolitem action='MeasureMarkDimension' />"
+ " <toolitem action='MeasureToItem' />"
+ " </toolbar>"
" <toolbar name='StarToolbar'>"
" <separator />"
@@ -398,6 +437,8 @@ static gchar const * ui_descr =
" <toolitem action='FreehandModeActionPencil' />"
" <separator />"
" <toolitem action='PencilToleranceAction' />"
+ " <toolitem action='PencilLpeSimplify' />"
+ " <toolitem action='PencilLpeSimplifyFlatten' />"
" <separator />"
" <toolitem action='PencilResetAction' />"
" <separator />"
@@ -438,6 +479,7 @@ static gchar const * ui_descr =
" <separator />"
" </toolbar>"
+#if HAVE_POTRACE
" <toolbar name='PaintbucketToolbar'>"
" <toolitem action='ChannelsAction' />"
" <separator />"
@@ -450,11 +492,15 @@ static gchar const * ui_descr =
" <separator />"
" <toolitem action='PaintbucketResetAction' />"
" </toolbar>"
+#endif
" <toolbar name='EraserToolbar'>"
" <toolitem action='EraserModeAction' />"
" <separator />"
" <toolitem action='EraserWidthAction' />"
+ " <toolitem action='EraserBreakAppart' />"
+ " <separator />"
+ " <toolitem action='EraserMassAction' />"
" </toolbar>"
" <toolbar name='TextToolbar'>"
@@ -470,12 +516,15 @@ static gchar const * ui_descr =
" <toolitem action='TextSubscriptAction' />"
" <separator />"
" <toolitem action='TextLineHeightAction' />"
+ " <toolitem action='TextLineHeightUnitAction' />"
" <toolitem action='TextLetterSpacingAction' />"
" <toolitem action='TextWordSpacingAction' />"
" <toolitem action='TextDxAction' />"
" <toolitem action='TextDyAction' />"
" <toolitem action='TextRotationAction' />"
" <separator />"
+ " <toolitem action='TextWritingModeAction' />"
+ " <separator />"
" <toolitem action='TextOrientationAction' />"
" </toolbar>"
@@ -517,9 +566,12 @@ static gchar const * ui_descr =
// " <toolitem action='MeshEditFillAction' />"
// " <toolitem action='MeshEditStrokeAction' />"
// " <toolitem action='MeshShowHandlesAction' />"
+ " <toolitem action='MeshToggleSidesAction' />"
+ " <toolitem action='MeshMakeEllipticalAction' />"
+ " <toolitem action='MeshPickColorsAction' />"
+ " <separator />"
" <toolitem action='MeshWarningAction' />"
" <toolitem action='MeshSmoothAction' />"
- " <separator />"
" </toolbar>"
" <toolbar name='DropperToolbar'>"
@@ -897,8 +949,12 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
};
Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
-
Glib::RefPtr<Gtk::ActionGroup> mainActions;
+ if (desktop == NULL)
+ {
+ return mainActions;
+ }
+
if ( groups.find(desktop) != groups.end() ) {
mainActions = groups[desktop];
}
@@ -906,10 +962,7 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
if ( !mainActions ) {
mainActions = Gtk::ActionGroup::create("main");
groups[desktop] = mainActions;
- if (desktop)
- {
- desktop->connectDestroy(&desktopDestructHandler);
- }
+ desktop->connectDestroy(&desktopDestructHandler);
}
for ( guint i = 0; i < G_N_ELEMENTS(verbsToUse); i++ ) {
@@ -1071,6 +1124,10 @@ EgeAdjustmentAction * create_adjustment_action( gchar const *name,
g_object_set_data( dataKludge, prefs->getEntry(path).getEntryName().data(), adj );
}
+ if (unit_tracker) {
+ unit_tracker->addAdjustment(adj);
+ }
+
// Using a cast just to make sure we pass in the right kind of function pointer
g_object_set( G_OBJECT(act), "tool-post", static_cast<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
@@ -1289,8 +1346,11 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
" <toolitem action='ToolSpray' />"
" <toolitem action='ToolEraser' />"
+#if HAVE_POTRACE
" <!-- Fill -->"
" <toolitem action='ToolPaintBucket' />"
+#endif
+
" <toolitem action='ToolGradient' />"
#ifdef WITH_MESH
" <toolitem action='ToolMesh' />"
@@ -1417,8 +1477,11 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_table_attach( GTK_TABLE(holder), swatch_, 1, 2, 0, 1, (GtkAttachOptions)(GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), AUX_BETWEEN_BUTTON_GROUPS, AUX_SPACING );
#endif
}
-
- gtk_widget_show_all( holder );
+ if(i==0){
+ gtk_widget_show_all( holder );
+ } else {
+ gtk_widget_show_now( holder );
+ }
sp_set_font_size_smaller( holder );
gtk_size_group_add_widget( grouper, holder );
@@ -1439,7 +1502,7 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg
for (int i = 0 ; aux_toolboxes[i].type_name ; i++ ) {
GtkWidget *sub_toolbox = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbox), aux_toolboxes[i].data_name));
if (tname && !strcmp(tname, aux_toolboxes[i].type_name)) {
- gtk_widget_show_all(sub_toolbox);
+ gtk_widget_show_now(sub_toolbox);
g_object_set_data(G_OBJECT(toolbox), "shows", sub_toolbox);
} else {
gtk_widget_hide(sub_toolbox);
@@ -1509,13 +1572,12 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
SPDesktop *dt = reinterpret_cast<SPDesktop*>(ptr);
SPNamedView *nv = dt->getNamedView();
- SPDocument *doc = nv->document;
-
- if (dt == NULL || nv == NULL) {
- g_warning("No desktop or namedview specified (in toggle_snap_callback)!");
+ if (nv == NULL) {
+ g_warning("No namedview specified (in toggle_snap_callback)!");
return;
}
+ SPDocument *doc = nv->document;
Inkscape::XML::Node *repr = nv->getRepr();
if (repr == NULL) {
diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp
index a5d90fc3d..a185ea956 100644
--- a/src/widgets/tweak-toolbar.cpp
+++ b/src/widgets/tweak-toolbar.cpp
@@ -82,12 +82,12 @@ static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
for (size_t i = 0; i < G_N_ELEMENTS(names); ++i) {
GtkAction *act = GTK_ACTION(g_object_get_data( tbl, names[i] ));
if (act) {
- gtk_action_set_sensitive(act, flag);
+ gtk_action_set_visible(act, flag);
}
}
GtkAction *fid = GTK_ACTION(g_object_get_data( tbl, "tweak_fidelity"));
if (fid) {
- gtk_action_set_sensitive(fid, !flag);
+ gtk_action_set_visible(fid, !flag);
}
}
@@ -276,7 +276,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
ege_output_action_set_use_markup( act, TRUE );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
+ gtk_action_set_visible (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_channels_label", act);
}
@@ -288,12 +288,12 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
NULL,
Inkscape::ICON_SIZE_DECORATION );
//TRANSLATORS: "H" here stands for hue
- g_object_set( act, "short_label", _("H"), NULL );
+ g_object_set( act, "short_label", C_("Hue", "H"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doh), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doh", true) );
if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
+ gtk_action_set_visible (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_doh", act);
}
@@ -304,12 +304,12 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
NULL,
Inkscape::ICON_SIZE_DECORATION );
//TRANSLATORS: "S" here stands for Saturation
- g_object_set( act, "short_label", _("S"), NULL );
+ g_object_set( act, "short_label", C_("Saturation", "S"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dos), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dos", true) );
if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
+ gtk_action_set_visible (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_dos", act );
}
@@ -320,12 +320,12 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
NULL,
Inkscape::ICON_SIZE_DECORATION );
//TRANSLATORS: "L" here stands for Lightness
- g_object_set( act, "short_label", _("L"), NULL );
+ g_object_set( act, "short_label", C_("Lightness", "L"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dol), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dol", true) );
if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
+ gtk_action_set_visible (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_dol", act );
}
@@ -336,12 +336,12 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
NULL,
Inkscape::ICON_SIZE_DECORATION );
//TRANSLATORS: "O" here stands for Opacity
- g_object_set( act, "short_label", _("O"), NULL );
+ g_object_set( act, "short_label", C_("Opacity", "O"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doo), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doo", true) );
if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
+ gtk_action_set_visible (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_doo", act );
}
@@ -358,9 +358,9 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
labels, values, G_N_ELEMENTS(labels),
sp_tweak_fidelity_value_changed, NULL /*unit tracker*/, 0.01, 0, 100 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
- gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ gtk_action_set_visible( GTK_ACTION(eact), TRUE );
if (mode == Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT || mode == Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
- gtk_action_set_sensitive (GTK_ACTION(eact), FALSE);
+ gtk_action_set_visible (GTK_ACTION(eact), FALSE);
}
g_object_set_data( holder, "tweak_fidelity", eact );
}