diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-10-08 02:22:03 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-10-08 02:22:03 +0000 |
| commit | f3840fe9d0d423f6ddf5a68d776a903d57ffb7b5 (patch) | |
| tree | c8e28b27f5885928ccf866a69eb6cbc99fde599c /src | |
| parent | Update to experimental r13565 (diff) | |
| parent | Some template cleanup... (diff) | |
| download | inkscape-f3840fe9d0d423f6ddf5a68d776a903d57ffb7b5.tar.gz inkscape-f3840fe9d0d423f6ddf5a68d776a903d57ffb7b5.zip | |
Update to experimental r13598
(bzr r13341.5.17)
Diffstat (limited to 'src')
207 files changed, 1396 insertions, 1980 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2c95d2b0..008a888e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,6 +42,7 @@ set(sp_SRC sp-line.cpp sp-linear-gradient.cpp sp-lpe-item.cpp + sp-marker.cpp sp-mask.cpp sp-mesh-array.cpp sp-mesh-gradient.cpp @@ -125,6 +126,7 @@ set(sp_SRC sp-line.h sp-linear-gradient.h sp-lpe-item.h + sp-marker.h sp-marker-loc.h sp-mask.h sp-mesh-array.h @@ -190,11 +192,7 @@ set(inkscape_SRC document-undo.cpp document.cpp doxygen-main.cpp - draw-anchor.cpp - ege-adjustment-action.cpp ege-color-prof-tracker.cpp - ege-output-action.cpp - ege-select-one-action.cpp event-log.cpp extract-uri.cpp file.cpp @@ -210,8 +208,6 @@ set(inkscape_SRC help.cpp id-clash.cpp # ige-mac-menu.c - ink-action.cpp - ink-comboboxentry-action.cpp inkscape.cpp inkscape.rc interface.cpp @@ -225,12 +221,10 @@ set(inkscape_SRC line-geometry.cpp line-snapper.cpp main-cmdlineact.cpp - marker.cpp media.cpp message-context.cpp message-stack.cpp mod360.cpp - object-edit.cpp object-hierarchy.cpp object-snapper.cpp path-chemistry.cpp @@ -253,7 +247,6 @@ set(inkscape_SRC selection.cpp seltrans-handles.cpp seltrans.cpp - shape-editor.cpp shortcuts.cpp snap-preferences.cpp snap.cpp @@ -267,7 +260,6 @@ set(inkscape_SRC svg-view.cpp text-chemistry.cpp text-editing.cpp - tools-switch.cpp transf_mat_3x4.cpp unclump.cpp unicoderange.cpp @@ -313,11 +305,7 @@ set(inkscape_SRC document-subset.h document-undo.h document.h - draw-anchor.h - ege-adjustment-action.h ege-color-prof-tracker.h - ege-output-action.h - ege-select-one-action.h enums.h event-log.h event.h @@ -344,8 +332,6 @@ set(inkscape_SRC icon-size.h id-clash.h # ige-mac-menu.h - ink-action.h - ink-comboboxentry-action.h inkscape-version.h inkscape.h interface.h @@ -372,7 +358,6 @@ set(inkscape_SRC mod360-test.h mod360.h number-opt-number.h - object-edit.h object-hierarchy.h object-snapper.h path-chemistry.h @@ -403,7 +388,6 @@ set(inkscape_SRC selection.h seltrans-handles.h seltrans.h - shape-editor.h shortcuts.h snap-candidate.h snap-enums.h @@ -428,8 +412,6 @@ set(inkscape_SRC text-chemistry.h text-editing.h text-tag-attributes.h - tool-factory.h - tools-switch.h transf_mat_3x4.h unclump.h undo-stack-observer.h diff --git a/src/Makefile_insert b/src/Makefile_insert index 20695ed77..541bd20ca 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -37,11 +37,7 @@ ink_common_sources += \ document-subset.cpp document-subset.h \ document-undo.cpp document-undo.h \ doxygen-main.cpp \ - draw-anchor.cpp draw-anchor.h \ - ege-adjustment-action.cpp ege-adjustment-action.h \ ege-color-prof-tracker.cpp ege-color-prof-tracker.h \ - ege-output-action.cpp ege-output-action.h \ - ege-select-one-action.cpp ege-select-one-action.h \ enums.h \ event-log.cpp event-log.h event.h \ extract-uri.cpp extract-uri.h \ @@ -67,12 +63,7 @@ ink_common_sources += \ helper/pixbuf-ops.h \ icon-size.h \ id-clash.cpp id-clash.h \ - ink-action.cpp \ - ink-action.h \ - ink-comboboxentry-action.cpp \ - ink-comboboxentry-action.h \ inkscape.cpp inkscape.h \ - interface.cpp interface.h \ isinf.h \ knot.cpp knot.h \ knot-enums.h \ @@ -86,14 +77,12 @@ ink_common_sources += \ line-snapper.cpp line-snapper.h \ macros.h \ main-cmdlineact.cpp main-cmdlineact.h \ - marker.cpp marker.h \ media.cpp media.h \ menus-skeleton.h \ message-context.cpp message-context.h \ message.h \ message-stack.cpp message-stack.h \ mod360.cpp mod360.h \ - object-edit.cpp object-edit.h \ object-hierarchy.cpp object-hierarchy.h \ object-snapper.cpp object-snapper.h \ path-chemistry.cpp path-chemistry.h \ @@ -120,7 +109,6 @@ ink_common_sources += \ selection-describer.cpp selection-describer.h \ seltrans.cpp seltrans.h \ seltrans-handles.cpp seltrans-handles.h \ - shape-editor.cpp shape-editor.h \ shortcuts.cpp shortcuts.h \ snap.cpp snap.h \ snap-enums.h snap-candidate.h \ @@ -168,6 +156,7 @@ ink_common_sources += \ sp-line.cpp sp-line.h \ splivarot.cpp splivarot.h \ sp-lpe-item.cpp sp-lpe-item.h \ + sp-marker.cpp sp-marker.h \ sp-marker-loc.h \ sp-mask.cpp sp-mask.h \ sp-metadata.cpp sp-metadata.h \ @@ -222,8 +211,6 @@ ink_common_sources += \ text-chemistry.cpp text-chemistry.h \ text-editing.cpp text-editing.h \ text-tag-attributes.h \ - tool-factory.h \ - tools-switch.cpp tools-switch.h \ transf_mat_3x4.cpp transf_mat_3x4.h \ unclump.cpp unclump.h \ undo-stack-observer.h \ diff --git a/src/color-profile.cpp b/src/color-profile.cpp index aa0750c00..28550b75d 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -19,6 +19,7 @@ #include <gtk/gtk.h> #endif // DEBUG_LCMS +#include <unistd.h> #include <cstring> #include <string> #include <io/sys.h> @@ -910,7 +911,7 @@ Glib::ustring getNameFromProfile(cmsHPROFILE profile) if ( name && !g_utf8_validate(name, -1, NULL) ) { name = _("(invalid UTF-8 string)"); } - nameStr = (name) ? name : _("None"); + nameStr = (name) ? name : C_("Profile name", "None"); #elif HAVE_LIBLCMS2 cmsUInt32Number byteLen = cmsGetProfileInfo(profile, cmsInfoDescription, "en", "US", NULL, 0); if (byteLen > 0) { diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 332de3630..5d8ea8b9f 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -40,7 +40,7 @@ #include "display/sp-canvas.h" #include "sp-guide.h" #include "sp-namedview.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "verbs.h" #include "widgets/desktop-widget.h" #include "xml/repr.h" @@ -295,7 +295,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) // here must be exactly on the guide line though, otherwise // small errors will occur once we snap, see // https://bugs.launchpad.net/inkscape/+bug/333762 - drag_origin = Geom::projection(event_dt, Geom::Line(guide->point_on_line, guide->angle())); + drag_origin = Geom::projection(event_dt, Geom::Line(guide->getPoint(), guide->angle())); if (event->button.state & GDK_SHIFT_MASK) { // with shift we rotate the guide @@ -336,7 +336,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) // be forced to be on the guide. If we don't snap however, then // the origin should still be constrained to the guide. So let's do // that explicitly first: - Geom::Line line(guide->point_on_line, guide->angle()); + Geom::Line line(guide->getPoint(), guide->angle()); Geom::Coord t = line.nearestPoint(motion_dt); motion_dt = line.pointAt(t); if (!(event->motion.state & GDK_SHIFT_MASK)) { @@ -344,10 +344,15 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { // cannot use shift here to disable snapping, because we already use it for rotating the guide + Geom::Point temp; if (drag_type == SP_DRAG_ROTATE) { - m.guideFreeSnap(motion_dt, guide->point_on_line, true, false); + temp = guide->getPoint(); + m.guideFreeSnap(motion_dt, temp, true, false); + guide->moveto(temp, false); } else { - m.guideFreeSnap(motion_dt, guide->normal_to_line, false, true); + temp = guide->getNormal(); + m.guideFreeSnap(motion_dt, temp, false, true); + guide->set_normal(temp, false); } } m.unSetup(); @@ -355,12 +360,12 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) switch (drag_type) { case SP_DRAG_TRANSLATE: { - sp_guide_moveto(*guide, motion_dt, false); + guide->moveto(motion_dt, false); break; } case SP_DRAG_ROTATE: { - Geom::Point pt = motion_dt - guide->point_on_line; + Geom::Point pt = motion_dt - guide->getPoint(); Geom::Angle angle(pt); if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -368,7 +373,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) bool const relative_snaps = prefs->getBool("/options/relativeguiderotationsnap/value", false); if (snaps) { if (relative_snaps) { - Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle orig_angle(guide->getNormal()); Geom::Angle snap_angle = angle - orig_angle; double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); angle = (M_PI / snaps) * sections + orig_angle.radians0(); @@ -378,16 +383,16 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } } } - sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), false); + guide->set_normal(Geom::Point::polar(angle).cw(), false); break; } case SP_DRAG_MOVE_ORIGIN: { - sp_guide_moveto(*guide, motion_dt, false); + guide->moveto(motion_dt, false); break; } case SP_DRAG_NONE: - g_assert_not_reached(); + assert(false); break; } moved = true; @@ -412,7 +417,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) // be forced to be on the guide. If we don't snap however, then // the origin should still be constrained to the guide. So let's // do that explicitly first: - Geom::Line line(guide->point_on_line, guide->angle()); + Geom::Line line(guide->getPoint(), guide->angle()); Geom::Coord t = line.nearestPoint(event_dt); event_dt = line.pointAt(t); if (!(event->button.state & GDK_SHIFT_MASK)) { @@ -420,10 +425,15 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) { // cannot use shift here to disable snapping, because we already use it for rotating the guide + Geom::Point temp; if (drag_type == SP_DRAG_ROTATE) { - m.guideFreeSnap(event_dt, guide->point_on_line, true, false); + temp = guide->getPoint(); + m.guideFreeSnap(event_dt, temp, true, false); + guide->moveto(temp, false); } else { - m.guideFreeSnap(event_dt, guide->normal_to_line, false, true); + temp = guide->getNormal(); + m.guideFreeSnap(event_dt, temp, false, true); + guide->set_normal(temp, false); } } m.unSetup(); @@ -432,12 +442,12 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) switch (drag_type) { case SP_DRAG_TRANSLATE: { - sp_guide_moveto(*guide, event_dt, true); + guide->moveto(event_dt, true); break; } case SP_DRAG_ROTATE: { - Geom::Point pt = event_dt - guide->point_on_line; + Geom::Point pt = event_dt - guide->getPoint(); Geom::Angle angle(pt); if (event->motion.state & GDK_CONTROL_MASK) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -445,7 +455,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) bool const relative_snaps = prefs->getBool("/options/relativeguiderotationsnap/value", false); if (snaps) { if (relative_snaps) { - Geom::Angle orig_angle(guide->normal_to_line); + Geom::Angle orig_angle(guide->getNormal()); Geom::Angle snap_angle = angle - orig_angle; double sections = floor(snap_angle.radians0() * snaps / M_PI + .5); angle = (M_PI / snaps) * sections + orig_angle.radians0(); @@ -455,24 +465,24 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) } } } - sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), true); + guide->set_normal(Geom::Point::polar(angle).cw(), true); break; } case SP_DRAG_MOVE_ORIGIN: { - sp_guide_moveto(*guide, event_dt, true); + guide->moveto(event_dt, true); break; } case SP_DRAG_NONE: - g_assert_not_reached(); + assert(false); break; } DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Move guide")); } else { /* Undo movement of any attached shapes. */ - sp_guide_moveto(*guide, guide->point_on_line, false); - sp_guide_set_normal(*guide, guide->normal_to_line, false); + guide->moveto(guide->getPoint(), false); + guide->set_normal(guide->getNormal(), false); sp_guide_remove(guide); DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Delete guide")); @@ -487,7 +497,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) break; case GDK_ENTER_NOTIFY: { - sp_guideline_set_color(SP_GUIDELINE(item), guide->hicolor); + sp_guideline_set_color(SP_GUIDELINE(item), guide->getHiColor()); // set move or rotate cursor Geom::Point const event_w(event->crossing.x, event->crossing.y); @@ -512,13 +522,13 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) #endif } - char *guide_description = sp_guide_description(guide); + char *guide_description = guide->description(); desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description); g_free(guide_description); break; } case GDK_LEAVE_NOTIFY: - sp_guideline_set_color(SP_GUIDELINE(item), guide->color); + sp_guideline_set_color(SP_GUIDELINE(item), guide->getColor()); // restore event context's cursor gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(sp_desktop_canvas(desktop))), desktop->event_context->cursor); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 2c20524a2..ce8a06f29 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -41,7 +41,6 @@ #include "sp-tspan.h" #include "xml/repr.h" #include "xml/sp-css-attr.h" -#include "libnrtype/font-style-to-pos.h" #include "sp-path.h" #include "ui/tools/tool-base.h" @@ -1099,7 +1098,10 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) texts ++; if (set && - font_style_to_pos(*style_res).signature() != font_style_to_pos(*style).signature() ) { + ( ( style_res->font_weight.computed != style->font_weight.computed ) || + ( style_res->font_style.computed != style->font_style.computed ) || + ( style_res->font_stretch.computed != style->font_stretch.computed ) || + ( style_res->font_variant.computed != style->font_variant.computed ) ) ) { different = true; // different styles } diff --git a/src/desktop.cpp b/src/desktop.cpp index 542f1618b..288ca1fbf 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -55,7 +55,7 @@ #include "document-undo.h" #include "event-log.h" #include "helper/action-context.h" -#include "interface.h" +#include "ui/interface.h" #include "layer-fns.h" #include "layer-manager.h" #include "layer-model.h" @@ -71,7 +71,7 @@ #include "sp-namedview.h" #include "sp-root.h" #include "sp-defs.h" -#include "tool-factory.h" +#include "ui/tool-factory.h" #include "widgets/desktop-widget.h" #include "xml/repr.h" #include "helper/action.h" //sp_action_perform diff --git a/src/desktop.h b/src/desktop.h index 2c0275b51..496cc30eb 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -72,6 +72,8 @@ typedef struct _GdkEventAny GdkEventAny; struct _GdkEventWindowState; typedef struct _GdkEventWindowState GdkEventWindowState; +struct InkscapeApplication; + namespace Inkscape { class LayerModel; class MessageContext; diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 3a8358174..2632d69db 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -22,7 +22,7 @@ #include "knot.h" #include "preferences.h" #include <glibmm/i18n.h> -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "enums.h" namespace Inkscape { diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 4870b33b0..3b7b7bd4f 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -38,7 +38,7 @@ typedef struct _SPCanvasItemClass SPCanvasItemClass; typedef union _GdkEvent GdkEvent; typedef struct _GdkCursor GdkCursor; -#define SP_TYPE_CANVAS_ITEM (SPCanvasItem::getType()) +#define SP_TYPE_CANVAS_ITEM (sp_canvas_item_get_type()) #define SP_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem)) #define SP_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CANVAS_ITEM, SPCanvasItemClass)) #define SP_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS_ITEM)) @@ -51,7 +51,6 @@ typedef struct _GdkCursor GdkCursor; */ struct SPCanvasItem { GInitiallyUnowned parent_instance; - static GType getType(); SPCanvas *canvas; SPCanvasItem *parent; @@ -74,6 +73,8 @@ struct SPCanvasItem { bool in_destruction; }; +GType sp_canvas_item_get_type(); + /** * The vtable of an SPCanvasItem. */ diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3dc4a7504..305b0950a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -61,8 +61,6 @@ struct SPCanvasGroupClass { * A group of Items. */ struct SPCanvasGroup { - static GType getType(); - /** * Adds an item to a canvas group. */ @@ -113,17 +111,8 @@ struct SPCanvasGroup { GList *items; GList *last; - - static SPCanvasItemClass *parentClass; }; -SPCanvasItemClass *SPCanvasGroup::parentClass; - -GType sp_canvas_group_get_type() -{ - return SPCanvasGroup::getType(); -} - /** * The SPCanvas vtable. */ @@ -161,19 +150,6 @@ enum { LAST_SIGNAL }; -void sp_canvas_item_base_class_init(SPCanvasItemClass *klass); -void sp_canvas_item_base_class_finalize(SPCanvasItemClass *klass); - -/** - * Initializes the SPCanvasItem vtable and the "event" signal. - */ -void sp_canvas_item_class_init(SPCanvasItemClass *klass); - -/** - * Callback for initialization of SPCanvasItem. - */ -void sp_canvas_item_init(SPCanvasItem *item, SPCanvasItemClass *klass); - /** * Callback that removes item from all referers and destroys it. */ @@ -181,7 +157,6 @@ void sp_canvas_item_dispose(GObject *object); void sp_canvas_item_finalize(GObject *object); void sp_canvas_item_real_destroy(SPCanvasItem *object); -static gpointer parent_class = NULL; static guint object_signals[LAST_SIGNAL] = { 0 }; /** @@ -358,45 +333,12 @@ public: static void requestCanvasUpdate(SPCanvas *canvas); }; -GType SPCanvasItem::getType() -{ - static GType object_type = 0; - - if (!object_type) { - static GTypeInfo const object_info = { - sizeof(SPCanvasItemClass), - reinterpret_cast<GBaseInitFunc>(sp_canvas_item_base_class_init), - reinterpret_cast<GBaseFinalizeFunc>(sp_canvas_item_base_class_finalize), - reinterpret_cast<GClassInitFunc>(sp_canvas_item_class_init), - NULL, // class_finalize - NULL, // class_data - sizeof(SPCanvasItem), - 16, // n_preallocs - reinterpret_cast<GInstanceInitFunc>(sp_canvas_item_init), - NULL // value_table - }; - - object_type = g_type_register_static(G_TYPE_INITIALLY_UNOWNED, - "SPCanvasItem", &object_info, GTypeFlags(0)); - } - - return object_type; -} - -namespace { - -void sp_canvas_item_base_class_init(SPCanvasItemClass * /*klass*/) -{ -} - -void sp_canvas_item_base_class_finalize(SPCanvasItemClass * /*klass*/) -{ -} +G_DEFINE_TYPE(SPCanvasItem, sp_canvas_item, G_TYPE_INITIALLY_UNOWNED); -void sp_canvas_item_class_init(SPCanvasItemClass *klass) +static void +sp_canvas_item_class_init(SPCanvasItemClass *klass) { GObjectClass *gobject_class = (GObjectClass *) klass; - parent_class = g_type_class_ref (G_TYPE_OBJECT); item_signals[ITEM_EVENT] = g_signal_new ("event", G_TYPE_FROM_CLASS (klass), @@ -421,7 +363,8 @@ void sp_canvas_item_class_init(SPCanvasItemClass *klass) G_TYPE_NONE, 0); } -void sp_canvas_item_init(SPCanvasItem *item, SPCanvasItemClass * /*klass*/) +static void +sp_canvas_item_init(SPCanvasItem *item) { item->xform = Geom::Affine(Geom::identity()); item->ctrlType = Inkscape::CTRL_TYPE_UNKNOWN; @@ -434,15 +377,13 @@ void sp_canvas_item_init(SPCanvasItem *item, SPCanvasItemClass * /*klass*/) item->in_destruction = false; } -} // namespace - SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...) { va_list args; g_return_val_if_fail(parent != NULL, NULL); g_return_val_if_fail(SP_IS_CANVAS_GROUP(parent), NULL); - g_return_val_if_fail(g_type_is_a(type, SPCanvasItem::getType()), NULL); + g_return_val_if_fail(g_type_is_a(type, SP_TYPE_CANVAS_ITEM), NULL); SPCanvasItem *item = SP_CANVAS_ITEM(g_object_new(type, NULL)); @@ -554,7 +495,7 @@ void sp_canvas_item_dispose(GObject *object) item->in_destruction = false; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_canvas_item_parent_class)->dispose(object); } void sp_canvas_item_real_destroy(SPCanvasItem *object) @@ -574,7 +515,7 @@ void sp_canvas_item_finalize(GObject *gobject) "and must be removed with g_object_ref_sink()."); } - G_OBJECT_CLASS (parent_class)->finalize (gobject); + G_OBJECT_CLASS (sp_canvas_item_parent_class)->finalize (gobject); } } // namespace @@ -982,37 +923,12 @@ gint sp_canvas_item_order (SPCanvasItem * item) } // SPCanvasGroup +G_DEFINE_TYPE(SPCanvasGroup, sp_canvas_group, SP_TYPE_CANVAS_ITEM); -/** - * Registers SPCanvasGroup class with Gtk and returns its type number. - */ -GType SPCanvasGroup::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCanvasGroupClass), - 0, // base_init - 0, // base_finalize - reinterpret_cast<GClassInitFunc>(SPCanvasGroup::classInit), - 0, // class_finalize - 0, // class_data - sizeof(SPCanvasGroup), - 0, // n_preallocs - reinterpret_cast<GInstanceInitFunc>(SPCanvasGroup::init), - 0 // value_table - }; - type = g_type_register_static(SPCanvasItem::getType(), "SPCanvasGroup", &info, static_cast<GTypeFlags>(0)); - } - return type; -} - -void SPCanvasGroup::classInit(SPCanvasGroupClass *klass) +static void sp_canvas_group_class_init(SPCanvasGroupClass *klass) { SPCanvasItemClass *item_class = reinterpret_cast<SPCanvasItemClass *>(klass); - parentClass = reinterpret_cast<SPCanvasItemClass*>(g_type_class_peek_parent(klass)); - item_class->destroy = SPCanvasGroup::destroy; item_class->update = SPCanvasGroup::update; item_class->render = SPCanvasGroup::render; @@ -1020,7 +936,7 @@ void SPCanvasGroup::classInit(SPCanvasGroupClass *klass) item_class->viewbox_changed = SPCanvasGroup::viewboxChanged; } -void SPCanvasGroup::init(SPCanvasGroup * /*group*/) +static void sp_canvas_group_init(SPCanvasGroup * /*group*/) { // Nothing here } @@ -1040,8 +956,8 @@ void SPCanvasGroup::destroy(SPCanvasItem *object) sp_canvas_item_destroy(child); } - if (SP_CANVAS_ITEM_CLASS(parentClass)->destroy) { - (* SP_CANVAS_ITEM_CLASS(parentClass)->destroy)(object); + if (SP_CANVAS_ITEM_CLASS(sp_canvas_group_parent_class)->destroy) { + (* SP_CANVAS_ITEM_CLASS(sp_canvas_group_parent_class)->destroy)(object); } } @@ -1238,7 +1154,7 @@ sp_canvas_init(SPCanvas *canvas) canvas->pick_event.crossing.y = 0; // Create the root item as a special case - canvas->root = SP_CANVAS_ITEM(g_object_new(SPCanvasGroup::getType(), NULL)); + canvas->root = SP_CANVAS_ITEM(g_object_new(SP_TYPE_CANVAS_GROUP, NULL)); canvas->root->canvas = canvas; g_object_ref (canvas->root); diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 57222f1cc..d4015bafb 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -241,7 +241,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) Inkscape::Event *log=(Inkscape::Event *)doc->priv->undo->data; doc->priv->undo = g_slist_remove (doc->priv->undo, log); sp_repr_undo_log (log->event); - doc->_updateDocument(); + //doc->_updateDocument(); doc->priv->redo = g_slist_prepend (doc->priv->redo, log); doc->setModifiedSinceSave(); diff --git a/src/document-undo.h b/src/document-undo.h index 2236626c8..85b44d562 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -9,6 +9,7 @@ typedef struct _GObject GObject; class SPDesktop; class SPDocument; +struct InkscapeApplication; namespace Inkscape { diff --git a/src/document.cpp b/src/document.cpp index dd18186d4..5aad4ca5e 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -228,7 +228,6 @@ SPDocument::~SPDocument() { // This is at the end of the destructor, because preceding code adds new orphans to the queue collectOrphans(); - //delete this->_whiteboard_session_manager; } sigc::connection SPDocument::connectDestroy(sigc::signal<void>::slot_type slot) diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index a5f0e6467..3d0f49a20 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -112,8 +112,13 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat _deps.push_back(new Dependency(child_repr)); } /* dependency */ if (!strcmp(chname, "script")) { - _deps.push_back(new Dependency(child_repr->firstChild())); - } /* check command as a dependency (see LP #505920) */ + for (Inkscape::XML::Node *child = child_repr->firstChild(); child != NULL ; child = child->next()) { + if (child->type() == Inkscape::XML::ELEMENT_NODE) { + _deps.push_back(new Dependency(child)); + break; + } /* skip non-element nodes (see LP #1372200) */ + } + } /* check command as a dependency (see LP #505920) */ if (!strcmp(chname, "options")) { silent = !strcmp( child_repr->attribute("silent"), "true" ); } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 0fec68c06..8196e34fb 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -42,7 +42,7 @@ #include "sp-item.h" #include "sp-item-group.h" #include "style.h" -#include "marker.h" +#include "sp-marker.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" #include "sp-root.h" diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 9a5a78a34..4b070cbaa 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -63,6 +63,7 @@ namespace Internal { static uint32_t ICMmode = 0; // not used yet, but code to read it from EMF implemented static uint32_t BLTmode = 0; +float faraway = 10000000; // used in "exclude" clips, hopefully well outside any real drawing! Emf::Emf (void) // The null constructor { @@ -1040,13 +1041,30 @@ Emf::pix_to_abs_size(PEMF_CALLBACK_DATA d, double px) return ppx; } -/* returns "x,y" (without the quotes) in inkscape coordinates for a pair of EMF x,y coordinates +/* snaps coordinate pairs made up of values near +/-faraway, +/-faraway to exactly faraway. + This eliminates coordinate drift on repeated clipping cycles which use exclude. + It should not affect internals of normal drawings because the value of faraway is so large. +*/ +void +Emf::snap_to_faraway_pair(double *x, double *y) +{ + if((abs(abs(*x) - faraway)/faraway <= 1e-4) && (abs(abs(*y) - faraway)/faraway <= 1e-4)){ + *x = (*x > 0 ? faraway : -faraway); + *y = (*y > 0 ? faraway : -faraway); + } +} + +/* returns "x,y" (without the quotes) in inkscape coordinates for a pair of EMF x,y coordinates. + Since exclude clip can go through here, it calls snap_to_faraway_pair for numerical stability. */ std::string Emf::pix_to_xy(PEMF_CALLBACK_DATA d, double x, double y){ std::stringstream cxform; - cxform << pix_to_x_point(d,x,y); + double tx = pix_to_x_point(d,x,y); + double ty = pix_to_y_point(d,x,y); + snap_to_faraway_pair(&tx,&ty); + cxform << tx; cxform << ","; - cxform << pix_to_y_point(d,x,y); + cxform << ty; return(cxform.str()); } @@ -2221,7 +2239,6 @@ std::cout << "BEFORE DRAW" U_RECTL rc = pEmr->rclClip; SVGOStringStream tmp_path; - float faraway = 10000000; // hopefully well outside any real drawing! //outer rect, clockwise tmp_path << "M " << faraway << "," << faraway << " "; tmp_path << "L " << faraway << "," << -faraway << " "; @@ -3466,6 +3483,8 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) return NULL; } + d.dc[0].font_name = strdup("Arial"); // Default font, set only on lowest level, it copies up from there EMF spec says device can pick whatever it wants + // set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing. d.defs += "\n"; @@ -3513,7 +3532,7 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.dc[0].style.stroke_dasharray.values.clear(); - for(int i=0; i<=d.level;i++){ + for(int i=0; i<=EMF_MAX_DC; i++){ if(d.dc[i].font_name)free(d.dc[i].font_name); } diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h index 302d5c474..c64299093 100644 --- a/src/extension/internal/emf-inout.h +++ b/src/extension/internal/emf-inout.h @@ -65,7 +65,7 @@ typedef struct emf_device_context { textAlign(0) // worldTransform, cur { - font_name = strdup("Arial"); // Default font, EMF spec says device can pick whatever it wants + font_name = NULL; sizeWnd = sizel_set( 0.0, 0.0 ); sizeView = sizel_set( 0.0, 0.0 ); winorg = point32_set( 0.0, 0.0 ); @@ -218,6 +218,7 @@ protected: static double pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py); static double pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py); static double pix_to_abs_size(PEMF_CALLBACK_DATA d, double px); + static void snap_to_faraway_pair(double *x, double *y); static std::string pix_to_xy(PEMF_CALLBACK_DATA d, double x, double y); static void select_pen(PEMF_CALLBACK_DATA d, int index); static void select_extpen(PEMF_CALLBACK_DATA d, int index); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index e054829b5..0f43fbca1 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -55,6 +55,7 @@ #include "sp-radial-gradient.h" #include "sp-linear-gradient.h" #include "display/cairo-utils.h" +#include "sp-shape.h" #include "splivarot.h" // pieces for union on shapes #include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path @@ -143,6 +144,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // width and height in px _width = doc->getWidth().value("px"); _height = doc->getHeight().value("px"); + _doc_unit_scale = Inkscape::Util::Quantity::convert(1, (doc->getDefaultUnit()), "px"); // initialize a few global variables hbrush = hbrushOld = hpen = 0; @@ -298,6 +300,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) unsigned int PrintEmf::finish(Inkscape::Extension::Print * /*mod*/) { + do_clip_if_present(NULL); // Terminate any open clip. char *rec; if (!et) { return 0; @@ -969,19 +972,145 @@ U_TRIVERTEX PrintEmf::make_trivertex(Geom::Point Pt, U_COLORREF uc){ return(tv); } +/* Examine clip. If there is a (new) one then apply it. If there is one and it is the + same as the preceding one, leave the preceding one active. If style is NULL + terminate the current clip, if any, and return. +*/ +void PrintEmf::do_clip_if_present(SPStyle const *style){ + char *rec; + static SPClipPath *scpActive = NULL; + if(!style){ + if(scpActive){ // clear the existing clip + rec = U_EMRRESTOREDC_set(-1); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRRESTOREDC_set"); + } + scpActive=NULL; + } + } else { + /* The current implementation converts only one level of clipping. If there were more + clips further up the stack they should be combined with the pathvector using "and". Since this + comes up rarely, and would involve a lot of searching (all the way up the stack for every + draw operation), it has not yet been implemented. + + Note, to debug this section of code use print statements on sp_svg_write_path(combined_pathvector). + */ + /* find the first clip_ref at object or up the stack. There may not be one. */ + SPClipPath *scp = NULL; + SPItem *item = SP_ITEM(style->object); + while(1) { + scp = (item->clip_ref ? item->clip_ref->getObject() : NULL); + if(scp)break; + item = SP_ITEM(item->parent); + if(!item || SP_IS_ROOT(item))break; // this will never be a clipping path + } + + if(scp != scpActive){ // change or remove the clipping + if(scpActive){ // clear the existing clip + rec = U_EMRRESTOREDC_set(-1); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRRESTOREDC_set"); + } + scpActive = NULL; + } + + if (scp) { // set the new clip + /* because of units and who knows what other transforms that might be applied above we + need the full transform all the way to the root. + */ + Geom::Affine tf = item->transform; + SPItem *scan_item = item; + while(1) { + scan_item = SP_ITEM(scan_item->parent); + if(!scan_item)break; + tf *= scan_item->transform; + } + tf *= Geom::Scale(_doc_unit_scale);; // Transform must be in PIXELS, no matter what the document unit is. + + /* find the clipping path */ + Geom::PathVector combined_pathvector; + Geom::Affine tfc; // clipping transform, generally not the same as item transform + for(item = SP_ITEM(scp->firstChild()); item; item=SP_ITEM(item->getNext())){ + if (SP_IS_GROUP(item)) { // not implemented + // return sp_group_render(item); + combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc); + } else if (SP_IS_SHAPE(item)) { + combined_pathvector = merge_PathVector_with_shape(combined_pathvector, item, tfc); + } else { // not implemented + } + } + + if (!combined_pathvector.empty()) { // if clipping path isn't empty, define EMF clipping record + scpActive = scp; // remember for next time + // the sole purpose of this SAVEDC is to let us clear the clipping region later. + rec = U_EMRSAVEDC_set(); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::image at U_EMRSAVEDC_set"); + } + (void) draw_pathv_to_EMF(combined_pathvector, tf); + rec = U_EMRSELECTCLIPPATH_set(U_RGN_OR); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::do_clip_if_present at U_EMRSELECTCLIPPATH_set"); + } + } + else { + scpActive = NULL; // no valid path available to draw, so no DC was saved, so no signal to restore + } + } // change or remove clipping + } // scp exists + } // style exists +} + +Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &combined_pathvector, SPItem const *item, const Geom::Affine &transform) +{ + Geom::PathVector new_combined_pathvector; + if(!SP_IS_GROUP(item))return(new_combined_pathvector); // sanity test, only a group should be passed in, return empty if something else happens + + new_combined_pathvector = combined_pathvector; + SPGroup *group = SP_GROUP(item); + Geom::Affine tfc = item->transform * transform; + for(SPItem *item = SP_ITEM(group->firstChild()); item; item=SP_ITEM(item->getNext())){ + if (SP_IS_GROUP(item)) { + new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG + } else if (SP_IS_SHAPE(item)) { + new_combined_pathvector = merge_PathVector_with_shape(new_combined_pathvector, item, tfc); + } else { // not implemented + } + } + return new_combined_pathvector; +} + +Geom::PathVector PrintEmf::merge_PathVector_with_shape(Geom::PathVector const &combined_pathvector, SPItem const *item, const Geom::Affine &transform) +{ + Geom::PathVector new_combined_pathvector; + if(!SP_IS_SHAPE(item))return(new_combined_pathvector); // sanity test, only a shape should be passed in, return empty if something else happens + + Geom::Affine tfc = item->transform * transform; + SPShape *shape = SP_SHAPE(item); + if (shape->_curve) { + Geom::PathVector const & new_vect = shape->_curve->get_pathvector(); + if(combined_pathvector.empty()){ + new_combined_pathvector = new_vect * tfc; + } + else { + new_combined_pathvector = sp_pathvector_boolop(new_vect * tfc, combined_pathvector, bool_op_union , (FillRule) fill_oddEven, (FillRule) fill_oddEven); + } + } + return new_combined_pathvector; +} + unsigned int PrintEmf::fill( Inkscape::Extension::Print * /*mod*/, Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style, Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { + char *rec; using Geom::X; using Geom::Y; - - //SPItem *item = SP_ITEM(style->object); - //SPClipPath *scp = (item->clip_ref ? item->clip_ref->getObject() : NULL); - Geom::Affine tf = m_tr_stack.top(); + do_clip_if_present(style); // If clipping is needed set it up + use_fill = true; use_stroke = false; @@ -1095,7 +1224,6 @@ unsigned int PrintEmf::fill( } } else if (gv.mode == DRAW_LINEAR_GRADIENT) { if(is_Rect){ - char *rec; int gMode; Geom::Point ul, ur, lr; Geom::Point outUL, outLR; // UL,LR corners of a stop rectangle, in OUTPUT coordinates @@ -1284,6 +1412,7 @@ unsigned int PrintEmf::stroke( char *rec = NULL; Geom::Affine tf = m_tr_stack.top(); + do_clip_if_present(style); // If clipping is needed set it up use_stroke = true; // use_fill was set in ::fill, if it is needed @@ -1568,12 +1697,14 @@ unsigned int PrintEmf::image( unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ - SPStyle const * /*style*/) /** provides indirect link to image object */ + SPStyle const *style) /** provides indirect link to image object */ { double x1, y1, dw, dh; char *rec = NULL; Geom::Affine tf = m_tr_stack.top(); + do_clip_if_present(style); // If clipping is needed set it up + rec = U_EMRSETSTRETCHBLTMODE_set(U_COLORONCOLOR); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::image at EMRHEADER"); @@ -1658,28 +1789,14 @@ unsigned int PrintEmf::image( return 0; } -// may also be called with a simple_shape or an empty path, whereupon it just returns without doing anything -unsigned int PrintEmf::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) -{ - Geom::Affine tf = transform; - char *rec = NULL; - - simple_shape = print_simple_shape(pathv, tf); - if (simple_shape || pathv.empty()) { - if (use_fill) { - destroy_brush(); // these must be cleared even if nothing is drawn or hbrush,hpen fill up - } - if (use_stroke) { - destroy_pen(); - } - return TRUE; - } +unsigned int PrintEmf::draw_pathv_to_EMF(Geom::PathVector const &pathv, const Geom::Affine &transform) { + char *rec; /* inkscape to EMF scaling is done below, but NOT the rotation/translation transform, that is handled by the EMF MODIFYWORLDTRANSFORM record */ - - Geom::PathVector pv = pathv_to_linear_and_cubic_beziers(pathv * tf); + + Geom::PathVector pv = pathv_to_linear_and_cubic_beziers(pathv * transform); rec = U_EMRBEGINPATH_set(); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { @@ -1781,6 +1898,27 @@ unsigned int PrintEmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::print_pathv at U_EMRENDPATH_set"); } + return(0); +} + +// may also be called with a simple_shape or an empty path, whereupon it just returns without doing anything +unsigned int PrintEmf::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) +{ + Geom::Affine tf = transform; + char *rec = NULL; + + simple_shape = print_simple_shape(pathv, tf); + if (simple_shape || pathv.empty()) { + if (use_fill) { + destroy_brush(); // these must be cleared even if nothing is drawn or hbrush,hpen fill up + } + if (use_stroke) { + destroy_pen(); + } + return TRUE; + } + + (void) draw_pathv_to_EMF(pathv, tf); // explicit FILL/STROKE commands are needed for each sub section of the path if (use_fill && !use_stroke) { @@ -1819,6 +1957,7 @@ unsigned int PrintEmf::text(Inkscape::Extension::Print * /*mod*/, char const *te return 0; } + do_clip_if_present(style); // If clipping is needed set it up char *rec = NULL; int ccount, newfont; int fix90n = 0; diff --git a/src/extension/internal/emf-print.h b/src/extension/internal/emf-print.h index 9a1251b38..5bad48de5 100644 --- a/src/extension/internal/emf-print.h +++ b/src/extension/internal/emf-print.h @@ -69,6 +69,10 @@ public: protected: static void smuggle_adxkyrtl_out(const char *string, uint32_t **adx, double *ky, int *rtl, int *ndx, float scale); + void do_clip_if_present(SPStyle const *style); + Geom::PathVector merge_PathVector_with_group(Geom::PathVector const &combined_pathvector, SPItem const *item, const Geom::Affine &transform); + Geom::PathVector merge_PathVector_with_shape(Geom::PathVector const &combined_pathvector, SPItem const *item, const Geom::Affine &transform); + unsigned int draw_pathv_to_EMF(Geom::PathVector const &pathv, const Geom::Affine &transform); Geom::Path pathv_to_simple_polygon(Geom::PathVector const &pathv, int *vertices); Geom::Path pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle); Geom::Point get_pathrect_corner(Geom::Path pathRect, double angle, int corner); diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index f092b21ef..e96fd6437 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -354,8 +354,15 @@ void ImageResolution::readmagick(char const *fn) { return; } + std::string const type = image.magick(); x_ = image.xResolution(); y_ = image.yResolution(); + +// TODO: find out why the hell the following convertion is necessary + if (type == "BMP") { + x_ = Inkscape::Util::Quantity::convert(x_, "in", "cm"); + y_ = Inkscape::Util::Quantity::convert(y_, "in", "cm"); + } if (x_ != 0 && y_ != 0) { ok_ = true; diff --git a/src/extension/internal/metafile-inout.cpp b/src/extension/internal/metafile-inout.cpp index 162ad8b7d..824934b3e 100644 --- a/src/extension/internal/metafile-inout.cpp +++ b/src/extension/internal/metafile-inout.cpp @@ -30,7 +30,7 @@ #include "style.h" #include "document.h" #include "util/units.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-namedview.h" #include "document-undo.h" #include "inkscape.h" @@ -202,7 +202,7 @@ void Metafile::setViewBoxIfMissing(SPDocument *doc) { // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); - ShapeEditor::blockSetItem(true); + Inkscape::UI::ShapeEditor::blockSetItem(true); double dh; if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard dh = SP_ACTIVE_DOCUMENT->getHeight().value("px"); @@ -222,8 +222,8 @@ void Metafile::setViewBoxIfMissing(SPDocument *doc) { prefs->setBool("/options/transform/pattern", true); prefs->setBool("/options/transform/gradient", true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh)); - ShapeEditor::blockSetItem(false); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh), true); + Inkscape::UI::ShapeEditor::blockSetItem(false); // restore options prefs->setBool("/options/transform/stroke", transform_stroke); diff --git a/src/extension/internal/metafile-print.h b/src/extension/internal/metafile-print.h index a21f9de58..d184b72b7 100644 --- a/src/extension/internal/metafile-print.h +++ b/src/extension/internal/metafile-print.h @@ -69,6 +69,8 @@ protected: double _width; double _height; + double _doc_unit_scale; // to pixels, regardless of the document units + U_RECTL rc; uint32_t htextalignment; diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 71e6dc6ae..7a504add0 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -123,12 +123,11 @@ void SvgBuilder::_init() { _height = 0; // Fill _availableFontNames (Bug LP #179589) (code cfr. FontLister) - FamilyToStylesMap familyStyleMap; - font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap); - for (FamilyToStylesMap::iterator iter = familyStyleMap.begin(); - iter != familyStyleMap.end(); - ++iter) { - _availableFontNames.push_back(iter->first.c_str()); + std::vector<PangoFontFamily *> families; + font_factory::Default()->GetUIFamilies(families); + for ( std::vector<PangoFontFamily *>::iterator iter = families.begin(); + iter != families.end(); ++iter ) { + _availableFontNames.push_back(pango_font_family_get_name(*iter)); } _transp_group_stack = NULL; diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index c03e7efe0..72c1c8bd3 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -3063,6 +3063,8 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) return NULL; } + d.dc[0].font_name = strdup("Arial"); // Default font, set only on lowest level, it copies up from there WMF spec says device can pick whatever it wants + // set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing. d.defs += "\n"; @@ -3105,7 +3107,7 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.dc[0].style.stroke_dasharray.values.clear(); - for(int i=0; i<=d.level;i++){ + for(int i=0; i<=WMF_MAX_DC; i++){ if(d.dc[i].font_name)free(d.dc[i].font_name); } diff --git a/src/extension/internal/wmf-inout.h b/src/extension/internal/wmf-inout.h index 27ec14358..5a0a760dd 100644 --- a/src/extension/internal/wmf-inout.h +++ b/src/extension/internal/wmf-inout.h @@ -65,7 +65,7 @@ typedef struct wmf_device_context { textAlign(0) // worldTransform, cur { - font_name = strdup("Arial"); // Default font, WMF spec says device can pick whatever it wants + font_name = NULL; sizeWnd = point16_set( 0.0, 0.0 ); sizeView = point16_set( 0.0, 0.0 ); winorg = point16_set( 0.0, 0.0 ); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index af31f32b6..0ea15a5cd 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -90,6 +90,10 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co if (_effect != NULL && !_effect->no_live_preview) { if (_param_preview == NULL) { XML::Document * doc = sp_repr_read_mem(live_param_xml, strlen(live_param_xml), NULL); + if (doc == NULL) { + std::cout << "Error encountered loading live parameter XML !!!" << std::endl; + return; + } _param_preview = Parameter::make(doc->root(), _effect); } diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 651964912..6a95717f2 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -20,7 +20,7 @@ # include <config.h> #endif -#include <interface.h> +#include "ui/interface.h" #include <unistd.h> #include <glibmm/miscutils.h> @@ -556,7 +556,7 @@ build_from_file(gchar const *filename) } /** - * \return The module created + * \return The module created, or NULL if buffer is invalid * \brief This function creates a module from a buffer holding an * XML description. * \param buffer The buffer holding the XML description of the module. @@ -568,6 +568,7 @@ Extension * build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp) { Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), INKSCAPE_EXTENSION_URI); + g_return_val_if_fail(doc != NULL, NULL); Extension *ext = build_from_reprdoc(doc, in_imp); Inkscape::GC::release(doc); return ext; diff --git a/src/file.cpp b/src/file.cpp index 4e46a6e16..2afb932b8 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -46,7 +46,7 @@ #include "id-clash.h" #include "inkscape.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "io/sys.h" #include "message.h" #include "message-stack.h" diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp index 037c66922..ae11aa64f 100644 --- a/src/filter-enums.cpp +++ b/src/filter-enums.cpp @@ -119,7 +119,7 @@ const EnumDataConverter<Inkscape::Filters::FilterComponentTransferType> Componen const EnumData<Inkscape::Filters::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeData[Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_ENDTYPE] = { {Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE, _("Duplicate"), "duplicate"}, {Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_WRAP, _("Wrap"), "wrap"}, - {Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_NONE, _("None"), "none"} + {Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_NONE, C_("Convolve matrix, edge mode", "None"), "none"} }; const EnumDataConverter<Inkscape::Filters::FilterConvolveMatrixEdgeMode> ConvolveMatrixEdgeModeConverter(ConvolveMatrixEdgeModeData, Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_ENDTYPE); diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 20c95459d..960caed67 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -48,7 +48,7 @@ Inkscape::GuideSnapper::LineList Inkscape::GuideSnapper::_getSnapLines(Geom::Poi for (GSList const *l = _snapmanager->getNamedView()->guides; l != NULL; l = l->next) { SPGuide const *g = SP_GUIDE(l->data); if (g != guide_to_ignore) { - s.push_back(std::make_pair(g->normal_to_line, g->point_on_line)); + s.push_back(std::pair<Geom::Point, Geom::Point>(g->getNormal(), g->getPoint())); } } diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index d44b2207b..acb2be4da 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -19,7 +19,7 @@ #include <boost/scoped_ptr.hpp> #include <2geom/transforms.h> -#include "interface.h" +#include "ui/interface.h" #include "helper/png-write.h" #include "display/cairo-utils.h" #include "display/drawing.h" diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index a7ebe7423..32e50b537 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -18,7 +18,7 @@ #endif #include <png.h> -#include "interface.h" +#include "ui/interface.h" #include <2geom/rect.h> #include <2geom/transforms.h> #include <glib.h> diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 58a8a7dfc..17c4c53a7 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -28,7 +28,7 @@ #include "sp-gradient.h" #include "document-private.h" #include "sp-pattern.h" -#include "marker.h" +#include "sp-marker.h" #include "desktop-handles.h" #include "inkscape.h" diff --git a/src/knot.cpp b/src/knot.cpp index 49b4dbb54..4118873c1 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -27,7 +27,9 @@ #include "preferences.h" #include "message-stack.h" #include "message-context.h" +#include "ui/tools-switch.h" #include "ui/tools/tool-base.h" +#include "ui/tools/node-tool.h" #include <gtk/gtk.h> using Inkscape::DocumentUndo; @@ -261,6 +263,10 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot consumed = TRUE; } } + if (tools_isactive(knot->desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context); + nt->update_helperpath(); + } break; case GDK_MOTION_NOTIFY: if (grabbed && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { @@ -293,6 +299,10 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot sp_knot_handler_request_position(event, knot); moved = TRUE; } + if (tools_isactive(knot->desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(knot->desktop->event_context); + nt->update_helperpath(); + } break; case GDK_ENTER_NOTIFY: knot->setFlag(SP_KNOT_MOUSEOVER, TRUE); diff --git a/src/knotholder.h b/src/knotholder.h index d33adb610..f1bacebe5 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -22,6 +22,9 @@ #include <sigc++/connection.h> namespace Inkscape { +namespace UI { +class ShapeEditor; +} namespace XML { class Node; } @@ -58,9 +61,9 @@ public: bool knot_mouseover() const; - friend class ShapeEditor; - friend class Inkscape::LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity; - friend class Inkscape::LivePathEffect::FilletPointArrayParamKnotHolderEntity; + friend class Inkscape::UI::ShapeEditor; // FIXME why? + friend class Inkscape::LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity; // why? + friend class Inkscape::LivePathEffect::FilletPointArrayParamKnotHolderEntity; // why? protected: diff --git a/src/libnrtype/CMakeLists.txt b/src/libnrtype/CMakeLists.txt index 84979d7ea..05fd01a03 100644 --- a/src/libnrtype/CMakeLists.txt +++ b/src/libnrtype/CMakeLists.txt @@ -3,14 +3,12 @@ set(nrtype_SRC FontFactory.cpp FontInstance.cpp font-lister.cpp - font-style-to-pos.cpp Layout-TNG.cpp Layout-TNG-Compute.cpp Layout-TNG-Input.cpp Layout-TNG-OutIter.cpp Layout-TNG-Output.cpp Layout-TNG-Scanline-Makers.cpp - nr-type-pos-def.cpp nr-type-primitives.cpp TextWrapper.cpp @@ -25,9 +23,7 @@ set(nrtype_SRC font-glyph.h font-instance.h font-lister.h - font-style-to-pos.h font-style.h - nr-type-pos-def.h nr-type-primitives.h one-box.h one-glyph.h diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index c5e68e264..c8f5e1fef 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -97,6 +97,7 @@ font_factory::font_factory(void) : fontSize(512), loadedPtr(new FaceMapType()) { + // std::cout << pango_version_string() << std::endl; #ifdef USE_PANGO_WIN32 #else pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP(fontServer), @@ -129,13 +130,6 @@ font_factory::~font_factory(void) delete tmp; loadedPtr = 0; } - - // Delete the pango font pointers in the string to instance map - PangoStringToDescrMap::iterator it = fontInstanceMap.begin(); - while (it != fontInstanceMap.end()) { - pango_font_description_free((*it).second); - ++it; - } } @@ -248,248 +242,6 @@ Glib::ustring font_factory::GetUIStyleString(PangoFontDescription const *fontDes return style; } -/** - Replace font family leaving style alone (if possible). - @param fontSpec the given font - @param newFamily - @return the changed fontspec, if the property can not be set return an empty string - The routine first searches for an exact match. - If no exact match found, calls FontSpecificationBestMatch(). -*/ -Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring & fontSpec, const Glib::ustring & newFamily) -{ - Glib::ustring newFontSpec; - - // Although we are using the string from pango_font_description_to_string for the - // font specification, we definitely cannot just set the new family in the - // PangoFontDescription structure and ask for a new string. This is because - // what constitutes a "family" in our own UI may be different from how Pango - // sees it. - - // Find the PangoFontDescription associated with the old font specification string. - PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); - - - if (it != fontInstanceMap.end()) { - // Description found! - - // Make copy - PangoFontDescription *descr = pango_font_description_copy((*it).second); - - // Grab the old UI Family string from the descr - Glib::ustring uiFamily = GetUIFamilyString(descr); - - // Replace the UI Family name with the new family name - std::size_t found = fontSpec.find(uiFamily); - if (found != Glib::ustring::npos) { - - // Add comma to end of newFamily... commas at end don't hurt but are - // required if the last part of a family name is a valid font style - // (e.g. "Arial Black"). - Glib::ustring newFamilyComma = newFamily; - if( *newFamilyComma.rbegin() != ',' ) { - newFamilyComma += ","; - } - newFontSpec = fontSpec; - newFontSpec.erase(found, uiFamily.size()); - newFontSpec.insert(found, newFamilyComma); - - // If the new font specification does not exist in the reference maps, - // search for the next best match for the faces in that style - it = fontInstanceMap.find(newFontSpec); - if (it == fontInstanceMap.end()) { - - // Search for best match, empty string returned if not found. - newFontSpec = FontSpecificationBestMatch( newFontSpec ); - - } - } - - pango_font_description_free(descr); - } - - return newFontSpec; -} - -/** - Apply style property to the given font - @param fontSpec the given font - @param turnOn true to set italic style - @return the changed fontspec, if the property can not be set return an empty string - The routine first searches for an exact match to "FontFamily Italic" or - "Font Family Oblique" (turnOn is true) or "FontFamily" (turnOn is false). - If no exact match found, calls FontSpecificationBestMatch(). -*/ -Glib::ustring font_factory::FontSpecificationSetItalic(const Glib::ustring & fontSpec, bool turnOn) -{ - Glib::ustring newFontSpec; - - // Find the PangoFontDescription associated with the font specification string. - PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); - - if (it != fontInstanceMap.end()) { - // Description found! - - // Make copy. - PangoFontDescription *descr = pango_font_description_copy((*it).second); - - PangoStyle style; - if (turnOn) { - // First try Oblique, we'll try Italic later - style = PANGO_STYLE_OBLIQUE; - } else { - style = PANGO_STYLE_NORMAL; - } - - pango_font_description_set_style(descr, style); - - newFontSpec = ConstructFontSpecification(descr); - - bool exactMatchFound = true; - if (fontInstanceMap.find(newFontSpec) == fontInstanceMap.end()) { - - exactMatchFound = false; - if (turnOn) { - // Next try Italic - style = PANGO_STYLE_ITALIC; - pango_font_description_set_style(descr, style); - - exactMatchFound = true; - if (fontInstanceMap.find(newFontSpec) == fontInstanceMap.end()) { - exactMatchFound = false; - } - } - } - - // Search for best match, empty string returned if not found. - if( !exactMatchFound ) { - newFontSpec = FontSpecificationBestMatch( newFontSpec ); - } - - pango_font_description_free(descr); - } - - return newFontSpec; // Empty if not found. -} - -/** - Apply weight property to the given font - @param fontSpec the given font - @param turnOn true to set bold - @return the changed fontspec, if the property can not be set return an empty string - This routine first searches for an exact match, if none found - it calls FontSpecificationBestMatch(). -*/ -Glib::ustring font_factory::FontSpecificationSetBold(const Glib::ustring & fontSpec, bool turnOn) -{ - Glib::ustring newFontSpec; - - // Find the PangoFontDescription associated with the font specification string. - PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); - - if (it != fontInstanceMap.end()) { - // Description found! - - // Make copy. - PangoFontDescription *descr = pango_font_description_copy((*it).second); - - - PangoWeight weight; - if (turnOn) { - weight = PANGO_WEIGHT_BOLD; - } else { - weight = PANGO_WEIGHT_NORMAL; - } - - pango_font_description_set_weight(descr, weight); - - newFontSpec = ConstructFontSpecification(descr); - - if (fontInstanceMap.find(newFontSpec) == fontInstanceMap.end()) { - // Search for best match, empty string returned if not found. - newFontSpec = FontSpecificationBestMatch( newFontSpec ); - } - - pango_font_description_free(descr); - } - - return newFontSpec; // Empty if not found. -} - -/** - Use pango_font_description_better_match() to find best font match. - This handles cases like Century Schoolbook L where the "normal" - font is Century Schoolbook L Medium so just removing Italic - from the font name doesn't yield the correct name. - @param fontSpec the given font - @return the changed fontspec, if the property can not be set return an empty string -*/ -// http://library.gnome.org/devel/pango/1.28/pango-Fonts.html#pango-font-description-better-match -Glib::ustring font_factory::FontSpecificationBestMatch(const Glib::ustring & fontSpec ) -{ - - Glib::ustring newFontSpec; - - // Look for exact match - PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec); - - // If there is no exact match, look for the best match. - if (it != fontInstanceMap.end()) { - - newFontSpec = fontSpec; - - } else { - - PangoFontDescription *fontDescr = pango_font_description_from_string(fontSpec.c_str()); - PangoFontDescription *bestMatchDescr = NULL; - - // Grab the UI Family string from the descr - Glib::ustring family = GetUIFamilyString(fontDescr); - Glib::ustring bestMatchDescription; - - bool setFirstFamilyMatch = false; - for (it = fontInstanceMap.begin(); it != fontInstanceMap.end(); ++it) { - - Glib::ustring currentFontSpec = (*it).first; - Glib::ustring currentFamily = GetUIFamilyString((*it).second); - - // Save some time by only looking at the right family. - // Must use family name rather than fontSpec - // (otherwise DejaVu Sans matches DejaVu Sans Mono). - if (currentFamily == family) { - if (!setFirstFamilyMatch) { - // This ensures that the closest match is at least within the correct - // family rather than the first font in the list - bestMatchDescr = pango_font_description_copy((*it).second); - bestMatchDescription = currentFontSpec; - setFirstFamilyMatch = true; - } else { - // Get the font description that corresponds, and - // then see if we've found a better match - PangoFontDescription *possibleMatch = pango_font_description_copy((*it).second); - - if (pango_font_description_better_match( - fontDescr, bestMatchDescr, possibleMatch)) { - - pango_font_description_free(bestMatchDescr); - bestMatchDescr = possibleMatch; - bestMatchDescription = currentFontSpec; - } else { - pango_font_description_free(possibleMatch); - } - } - } - } // for - - newFontSpec = bestMatchDescription; // If NULL, then no match found - - pango_font_description_free(fontDescr); - pango_font_description_free(bestMatchDescr); - - } - - return newFontSpec; -} ///// @@ -508,9 +260,15 @@ static int StyleNameValue( const Glib::ustring &style ) } // Determines order in which styles are presented (sorted by CSS style values) -static bool StyleNameCompareInternal(const StyleNames &style1, const StyleNames &style2) +//static bool StyleNameCompareInternal(const StyleNames &style1, const StyleNames &style2) +//{ +// return( StyleNameValue( style1.CssName ) < StyleNameValue( style2.CssName ) ); +//} + +static gint StyleNameCompareInternalGlib(gconstpointer a, gconstpointer b) { - return( StyleNameValue( style1.CssName ) < StyleNameValue( style2.CssName ) ); + return( StyleNameValue( ((StyleNames *)a)->CssName ) < + StyleNameValue( ((StyleNames *)b)->CssName ) ? -1 : 1 ); } static bool ustringPairSort(std::pair<PangoFontFamily*, Glib::ustring> const& first, std::pair<PangoFontFamily*, Glib::ustring> const& second) @@ -558,6 +316,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) // If the face has a name, describe it, and then use the // description to get the UI family and face strings const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]); + // std::cout << "Display Name: " << displayName << std::endl; if (displayName == NULL || *displayName == '\0') { continue; } @@ -566,7 +325,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) if (faceDescr) { Glib::ustring familyUIName = GetUIFamilyString(faceDescr); Glib::ustring styleUIName = GetUIStyleString(faceDescr); - + // std::cout << familyUIName << " " << styleUIName << " " << displayName << std::endl; // Disable synthesized (faux) font faces except for CSS generic faces if (pango_font_face_is_synthesized(faces[currentFace]) ) { if (familyUIName.compare( "sans-serif" ) != 0 && @@ -578,7 +337,48 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) } } - if (!familyUIName.empty() && !styleUIName.empty()) { + // Pango breaks the 1 to 1 mapping between Pango weights and CSS weights by + // adding Semi-Light (as of 1.36.7), Book (as of 1.24), and Ultra-Heavy (as of + // 1.24). We need to map these weights to CSS weights. Book and Ultra-Heavy + // are rarely used. Semi-Light (350) is problematic as it is halfway between + // Light (300) and Normal (400) and if care is not taken it is converted to + // Normal, rather than Light. + // + // Note: The ultimate solution to handling various weight in the same + // font family is to support the @font rules from CSS. + // + // Additional notes, helpful for debugging: + // Pango's FC backend: + // Weights defined in fontconfig/fontconfig.h + // String equivalents in src/fcfreetype.c + // Weight set from os2->usWeightClass + // Use Fontforge: Element->Font Info...->OS/2->Misc->Weight Class to check font weight + size_t f = styleUIName.find( "Book" ); + if( f != Glib::ustring::npos ) { + styleUIName.replace( f, 4, "Normal" ); + } + f = styleUIName.find( "Semi-Light" ); + if( f != Glib::ustring::npos ) { + styleUIName.replace( f, 10, "Light" ); + } + f = styleUIName.find( "Ultra-Heavy" ); + if( f != Glib::ustring::npos ) { + styleUIName.replace( f, 11, "Heavy" ); + } + + bool exists = false; + for(GList *temp = ret; temp; temp = temp->next) { + if( ((StyleNames*)temp->data)->CssName.compare( styleUIName ) == 0 ) { + exists = true; + std::cerr << "Warning: Font face with same CSS values already added: " + << familyUIName << " " << styleUIName + << " (" << ((StyleNames*)temp->data)->DisplayName + << ", " << displayName << ")" << std::endl; + break; + } + } + + if (!exists && !familyUIName.empty() && !styleUIName.empty()) { // Add the style information ret = g_list_append(ret, new StyleNames(styleUIName, displayName)); } @@ -586,112 +386,12 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) pango_font_description_free(faceDescr); } g_free(faces); + + // Sort the style lists + ret = g_list_sort( ret, StyleNameCompareInternalGlib ); return ret; } -void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) -{ - g_assert(map); - - if (map) { - - // Gather the family names as listed by Pango - PangoFontFamily** families = NULL; - int numFamilies = 0; - pango_font_map_list_families(fontServer, &families, &numFamilies); - - for (int currentFamily=0; currentFamily < numFamilies; currentFamily++) { - - // Gather the styles for this family - PangoFontFace** faces = NULL; - int numFaces = 0; - pango_font_family_list_faces(families[currentFamily], &faces, &numFaces); - - for (int currentFace=0; currentFace < numFaces; currentFace++) { - - // If the face has a name, describe it, and then use the - // description to get the UI family and face strings - - const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]); - if (displayName == NULL) { - continue; - } - - PangoFontDescription *faceDescr = pango_font_face_describe(faces[currentFace]); - if (faceDescr) { - Glib::ustring familyUIName = GetUIFamilyString(faceDescr); - Glib::ustring styleUIName = GetUIStyleString(faceDescr); - - // Disable synthesized (faux) font faces except for CSS generic faces - if (pango_font_face_is_synthesized(faces[currentFace]) ) { - if( familyUIName.compare( "sans-serif" ) != 0 && - familyUIName.compare( "serif" ) != 0 && - familyUIName.compare( "monospace" ) != 0 && - familyUIName.compare( "fantasy" ) != 0 && - familyUIName.compare( "cursive" ) != 0 ) { - //std::cout << "faux: " << familyUIName << " | " << styleUIName << std::endl; - continue; - } - } - - if (!familyUIName.empty() && !styleUIName.empty()) { - - // Find the right place to put the style information, adding - // a map entry for the family name if it doesn't yet exist - - FamilyToStylesMap::iterator iter = map->find(familyUIName); - - // Insert new family - if (iter == map->end()) { - map->insert(std::make_pair(familyUIName, std::list<StyleNames>())); - } - - // Insert into the style list and save the info in the reference maps - // only if the style does not yet exist - - bool exists = false; - std::list<StyleNames> &styleList = (*map)[familyUIName]; - - for (std::list<StyleNames>::iterator it=styleList.begin(); - it != styleList.end(); - ++it) { - if ( (*it).CssName == styleUIName) { - exists = true; - break; - } - } - - if (!exists) { - styleList.push_back( StyleNames(styleUIName,displayName) ); - - // Add the string info needed in the reference maps - fontStringMap.insert( - std::make_pair( - Glib::ustring(familyUIName) + Glib::ustring(styleUIName), - ConstructFontSpecification(faceDescr))); - fontInstanceMap.insert( - std::make_pair(ConstructFontSpecification(faceDescr), faceDescr)); - - } else { - pango_font_description_free(faceDescr); - } - } else { - pango_font_description_free(faceDescr); - } - } - } - g_free(faces); - faces = 0; - } - g_free(families); - families = 0; - - // Sort the style lists - for (FamilyToStylesMap::iterator iter = map->begin() ; iter != map->end(); ++iter) { - (*iter).second.sort(StyleNameCompareInternal); - } - } -} font_instance* font_factory::FaceFromStyle(SPStyle const *style) { @@ -712,15 +412,131 @@ font_instance* font_factory::FaceFromStyle(SPStyle const *style) // If that failed, try using the CSS information in the style if (!font) { - font = Face(style->font_family.value, font_style_to_pos(*style)); + PangoFontDescription *temp_descr = pango_font_description_new(); + + pango_font_description_set_family(temp_descr, style->font_family.value); + + // This duplicates Layout::EnumConversionItem... perhaps we can share code? + switch ( style->font_style.computed ) { + case SP_CSS_FONT_STYLE_ITALIC: + pango_font_description_set_style(temp_descr, PANGO_STYLE_ITALIC); + break; - // That was a hatchet job... so we need to check if this font exists!! - Glib::ustring fontSpec = font_factory::Default()->ConstructFontSpecification(font); - Glib::ustring newFontSpec = FontSpecificationBestMatch( fontSpec ); - if( fontSpec != newFontSpec ) { - font->Unref(); - font = FaceFromFontSpecification( newFontSpec.c_str() ); + case SP_CSS_FONT_STYLE_OBLIQUE: + pango_font_description_set_style(temp_descr, PANGO_STYLE_OBLIQUE); + break; + + case SP_CSS_FONT_STYLE_NORMAL: + default: + pango_font_description_set_style(temp_descr, PANGO_STYLE_NORMAL); + break; + } + + switch( style->font_weight.computed ) { + case SP_CSS_FONT_WEIGHT_100: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_THIN); + break; + + case SP_CSS_FONT_WEIGHT_200: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRALIGHT); + break; + + case SP_CSS_FONT_WEIGHT_300: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_LIGHT); + break; + + case SP_CSS_FONT_WEIGHT_400: + case SP_CSS_FONT_WEIGHT_NORMAL: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); + break; + + case SP_CSS_FONT_WEIGHT_500: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_MEDIUM); + break; + + case SP_CSS_FONT_WEIGHT_600: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_SEMIBOLD); + break; + + case SP_CSS_FONT_WEIGHT_700: + case SP_CSS_FONT_WEIGHT_BOLD: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOLD); + break; + + case SP_CSS_FONT_WEIGHT_800: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRABOLD); + break; + + case SP_CSS_FONT_WEIGHT_900: + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_HEAVY); + break; + + case SP_CSS_FONT_WEIGHT_LIGHTER: + case SP_CSS_FONT_WEIGHT_BOLDER: + default: + g_warning("FaceFromStyle: Unrecognized font_weight.computed value"); + pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); + break; } + // PANGO_WIEGHT_ULTRAHEAVY not used (not CSS2) + + switch (style->font_stretch.computed) { + case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_ULTRA_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_CONDENSED); + break; + + case SP_CSS_FONT_STRETCH_NORMAL: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); + break; + + case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_EXPANDED); + break; + + case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_ULTRA_EXPANDED); + + case SP_CSS_FONT_STRETCH_WIDER: + case SP_CSS_FONT_STRETCH_NARROWER: + default: + g_warning("FaceFromStyle: Unrecognized font_stretch.computed value"); + pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); + break; + } + + switch ( style->font_variant.computed ) { + case SP_CSS_FONT_VARIANT_SMALL_CAPS: + pango_font_description_set_variant(temp_descr, PANGO_VARIANT_SMALL_CAPS); + break; + + case SP_CSS_FONT_VARIANT_NORMAL: + default: + pango_font_description_set_variant(temp_descr, PANGO_VARIANT_NORMAL); + break; + } + + font = Face(temp_descr); + pango_font_description_free(temp_descr); } } @@ -736,37 +552,6 @@ font_instance *font_factory::FaceFromDescr(char const *family, char const *style return res; } -font_instance* font_factory::FaceFromUIStrings(char const *uiFamily, char const *uiStyle) -{ - font_instance *fontInstance = NULL; - - g_assert(uiFamily && uiStyle); - if (uiFamily && uiStyle) { - - // If font list, take only first font in list - gchar** tokens = g_strsplit( uiFamily, ",", 0 ); - g_strstrip( tokens[0] ); - - Glib::ustring uiString = Glib::ustring(tokens[0]) + Glib::ustring(uiStyle); - - g_strfreev( tokens ); - - UIStringToPangoStringMap::iterator uiToPangoIter = fontStringMap.find(uiString); - - if (uiToPangoIter != fontStringMap.end ()) { - PangoStringToDescrMap::iterator pangoToDescrIter = fontInstanceMap.find((*uiToPangoIter).second); - if (pangoToDescrIter != fontInstanceMap.end()) { - // We found the pango description - now we can make a font_instance - PangoFontDescription *tempDescr = pango_font_description_copy((*pangoToDescrIter).second); - fontInstance = Face(tempDescr); - pango_font_description_free(tempDescr); - } - } - } - - return fontInstance; -} - font_instance* font_factory::FaceFromPangoString(char const *pangoString) { font_instance *fontInstance = NULL; @@ -774,25 +559,15 @@ font_instance* font_factory::FaceFromPangoString(char const *pangoString) g_assert(pangoString); if (pangoString) { - PangoFontDescription *descr = NULL; - // First attempt to find the font specification in the reference map - PangoStringToDescrMap::iterator it = fontInstanceMap.find(Glib::ustring(pangoString)); - if (it != fontInstanceMap.end()) { - descr = pango_font_description_copy((*it).second); - } - - // Or create a font description from the string - this may fail or + // Create a font description from the string - this may fail or // produce unexpected results if the string does not have a good format - if (!descr) { - descr = pango_font_description_from_string(pangoString); - } - - if (descr && (sp_font_description_get_family(descr) != NULL)) { - fontInstance = Face(descr); - } + PangoFontDescription *descr = pango_font_description_from_string(pangoString); if (descr) { + if (sp_font_description_get_family(descr) != NULL) { + fontInstance = Face(descr); + } pango_font_description_free(descr); } } @@ -907,70 +682,6 @@ font_instance *font_factory::Face(char const *family, int variant, int style, in return res; } -font_instance *font_factory::Face(char const *family, NRTypePosDef apos) -{ - PangoFontDescription *temp_descr = pango_font_description_new(); - - pango_font_description_set_family(temp_descr, family); - - if ( apos.variant == NR_POS_VARIANT_SMALLCAPS ) { - pango_font_description_set_variant(temp_descr, PANGO_VARIANT_SMALL_CAPS); - } else { - pango_font_description_set_variant(temp_descr, PANGO_VARIANT_NORMAL); - } - - if ( apos.italic ) { - pango_font_description_set_style(temp_descr, PANGO_STYLE_ITALIC); - } else if ( apos.oblique ) { - pango_font_description_set_style(temp_descr, PANGO_STYLE_OBLIQUE); - } else { - pango_font_description_set_style(temp_descr, PANGO_STYLE_NORMAL); - } - - if ( apos.weight <= NR_POS_WEIGHT_THIN ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_THIN); - } else if ( apos.weight <= NR_POS_WEIGHT_ULTRA_LIGHT ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRALIGHT); - } else if ( apos.weight <= NR_POS_WEIGHT_LIGHT ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_LIGHT); - } else if ( apos.weight <= NR_POS_WEIGHT_BOOK ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOOK); - } else if ( apos.weight <= NR_POS_WEIGHT_NORMAL ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_NORMAL); - } else if ( apos.weight <= NR_POS_WEIGHT_MEDIUM ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_MEDIUM); - } else if ( apos.weight <= NR_POS_WEIGHT_SEMIBOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_SEMIBOLD); - } else if ( apos.weight <= NR_POS_WEIGHT_BOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_BOLD); - } else if ( apos.weight <= NR_POS_WEIGHT_ULTRA_BOLD ) { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_ULTRABOLD); - } else { - pango_font_description_set_weight(temp_descr, PANGO_WEIGHT_HEAVY); - } - // PANGO_WIEGHT_ULTRAHEAVY not used (not CSS2) - - if ( apos.stretch <= NR_POS_STRETCH_ULTRA_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_SEMI_CONDENSED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_CONDENSED); - } else if ( apos.stretch <= NR_POS_STRETCH_NORMAL ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_NORMAL); - } else if ( apos.stretch <= NR_POS_STRETCH_SEMI_EXPANDED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_SEMI_EXPANDED); - } else if ( apos.stretch <= NR_POS_STRETCH_EXPANDED ) { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXPANDED); - } else { - pango_font_description_set_stretch(temp_descr, PANGO_STRETCH_EXTRA_EXPANDED); - } - - font_instance *res = Face(temp_descr); - pango_font_description_free(temp_descr); - return res; -} - void font_factory::UnrefFace(font_instance *who) { if ( who ) { @@ -1022,24 +733,6 @@ void font_factory::AddInCache(font_instance *who) } /* - { - std::cout << " Printing out fontInstanceMap: " << std::endl; - PangoStringToDescrMap::iterator it = fontInstanceMap.begin(); - while (it != fontInstanceMap.end()) { - - PangoFontDescription *descr = pango_font_description_copy((*it).second); - - // Grab the UI Family string from the descr - Glib::ustring uiFamily = GetUIFamilyString(descr); - Glib::ustring uiStyle = GetUIStyleString(descr); - std::cout << " " << uiFamily << " " << uiStyle << std::endl; - - it++; - } - } -*/ - -/* Local Variables: mode:c++ c-file-style:"stroustrup" diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index c48ae831a..46df0181a 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -21,9 +21,7 @@ #include <pango/pango.h> #include "nr-type-primitives.h" -#include "nr-type-pos-def.h" -#include "font-style-to-pos.h" -#include "style.h" +#include "../style.h" /* Freetype */ #ifdef USE_PANGO_WIN32 @@ -114,18 +112,6 @@ public: Glib::ustring GetUIFamilyString(PangoFontDescription const *fontDescr); Glib::ustring GetUIStyleString(PangoFontDescription const *fontDescr); - /// Modifiers for the font specification (returns new font specification) - Glib::ustring ReplaceFontSpecificationFamily(const Glib::ustring & fontSpec, const Glib::ustring & newFamily); - Glib::ustring FontSpecificationSetItalic(const Glib::ustring & fontSpec, bool turnOn); - Glib::ustring FontSpecificationSetBold(const Glib::ustring & fontSpec, bool turnOn); - - Glib::ustring FontSpecificationBestMatch(const Glib::ustring& fontSpec ); - - // Gathers all strings needed for UI while storing pango information in - // fontInstanceMap and fontStringMap - // don't use this function, it's too slow - void GetUIFamiliesAndStyles(FamilyToStylesMap *map); - // Helpfully inserts all font families into the provided vector void GetUIFamilies(std::vector<PangoFontFamily *>& out); // Retrieves style information about a family in a newly allocated GList. @@ -144,7 +130,6 @@ public: int variant=PANGO_VARIANT_NORMAL, int style=PANGO_STYLE_NORMAL, int weight=PANGO_WEIGHT_NORMAL, int stretch=PANGO_STRETCH_NORMAL, int size=10, int spacing=0); - font_instance* Face(char const *family, NRTypePosDef apos); /// Semi-private: tells the font_factory taht the font_instance 'who' has died and should be removed from loadedFaces void UnrefFace(font_instance* who); @@ -155,19 +140,37 @@ public: private: void* loadedPtr; + + // The following two commented out maps were an attempt to allow Inkscape to use font faces + // that could not be distinguished by CSS values alone. In practice, they never were that + // useful as PangoFontDescription, which is used throughout our code, cannot distinguish + // between faces anymore than raw CSS values (with the exception of two additional weight + // values). + // + // During various works, for example to handle font-family lists and fonts that are not + // installed on the system, the code has become less reliant on these maps. And in the work to + // catch style information to speed up start up times, the maps were not being filled. + // I've removed all code that used these maps as of Oct 2014 in the experimental branch. + // The commented out maps are left here as a reminder of the path that was attempted. + // + // One possible method to keep track of font faces would be to use the 'display name', keeping + // pointers to the appropriate PangoFontFace. The font_factory loadedFaces map indexing would + // have to be changed to incorporate 'display name' (InkscapeFontDescription?). + + // These two maps are used for translating between what's in the UI and a pango // font description. This is necessary because Pango cannot always // reproduce these structures from the names it gave us in the first place. // Key: A string produced by font_factory::ConstructFontSpecification // Value: The associated PangoFontDescription - typedef std::map<Glib::ustring, PangoFontDescription *> PangoStringToDescrMap; - PangoStringToDescrMap fontInstanceMap; + // typedef std::map<Glib::ustring, PangoFontDescription *> PangoStringToDescrMap; + // PangoStringToDescrMap fontInstanceMap; // Key: Family name in UI + Style name in UI // Value: The associated string that should be produced with font_factory::ConstructFontSpecification - typedef std::map<Glib::ustring, Glib::ustring> UIStringToPangoStringMap; - UIStringToPangoStringMap fontStringMap; + // typedef std::map<Glib::ustring, Glib::ustring> UIStringToPangoStringMap; + // UIStringToPangoStringMap fontStringMap; }; diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 20eca6740..a5572c517 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -239,151 +239,6 @@ void font_instance::Unref(void) } } -unsigned int font_instance::Name(gchar *str, unsigned int size) -{ - return Attribute("name", str, size); -} - -unsigned int font_instance::Family(gchar *str, unsigned int size) -{ - return Attribute("family", str, size); -} - -unsigned int font_instance::PSName(gchar *str, unsigned int size) -{ - return Attribute("psname", str, size); -} - -unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int size) -{ - if ( descr == NULL ) { - if ( size > 0 ) { - str[0]=0; - } - return 0; - } - char* res=NULL; - bool free_res=false; - - if ( strcmp(key,"name") == 0 ) { - PangoFontDescription* td=pango_font_description_copy(descr); - pango_font_description_unset_fields (td, PANGO_FONT_MASK_SIZE); - res=pango_font_description_to_string (td); - pango_font_description_free(td); - free_res=true; - } else if ( strcmp(key,"psname") == 0 ) { -#ifndef USE_PANGO_WIN32 - res = (char *) FT_Get_Postscript_Name (theFace); // that's the main method, seems to always work -#endif - free_res=false; - if (res == NULL) { // a very limited workaround, only bold, italic, and oblique will work - PangoStyle style=pango_font_description_get_style(descr); - bool i = (style == PANGO_STYLE_ITALIC); - bool o = (style == PANGO_STYLE_OBLIQUE); - PangoWeight weight=pango_font_description_get_weight(descr); - bool b = (weight >= PANGO_WEIGHT_BOLD); - - res = g_strdup_printf ("%s%s%s%s", - sp_font_description_get_family(descr), - (b || i || o) ? "-" : "", - (b) ? "Bold" : "", - (i) ? "Italic" : ((o) ? "Oblique" : "") ); - free_res = true; - } - } else if ( strcmp(key,"family") == 0 ) { - res=(char*)sp_font_description_get_family(descr); - free_res=false; - } else if ( strcmp(key,"style") == 0 ) { - PangoStyle v=pango_font_description_get_style(descr); - if ( v == PANGO_STYLE_ITALIC ) { - res=(char*)"italic"; - } else if ( v == PANGO_STYLE_OBLIQUE ) { - res=(char*)"oblique"; - } else { - res=(char*)"normal"; - } - free_res=false; - } else if ( strcmp(key,"weight") == 0 ) { - PangoWeight v=pango_font_description_get_weight(descr); - if ( v <= PANGO_WEIGHT_THIN ) { - res=(char*)"100"; - } else if ( v <= PANGO_WEIGHT_ULTRALIGHT ) { - res=(char*)"200"; - } else if ( v <= PANGO_WEIGHT_LIGHT ) { - res=(char*)"300"; - } else if ( v <= PANGO_WEIGHT_BOOK ) { - res=(char*)"380"; - } else if ( v <= PANGO_WEIGHT_NORMAL ) { - res=(char*)"normal"; - } else if ( v <= PANGO_WEIGHT_MEDIUM ) { - res=(char*)"500"; - } else if ( v <= PANGO_WEIGHT_SEMIBOLD ) { - res=(char*)"600"; - } else if ( v <= PANGO_WEIGHT_BOLD ) { - res=(char*)"bold"; - } else if ( v <= PANGO_WEIGHT_ULTRABOLD ) { - res=(char*)"800"; - } else { // HEAVY NB: Pango defines ULTRAHEAVY = 1000 but not CSS2 - res=(char*)"900"; - } - free_res=false; - } else if ( strcmp(key,"stretch") == 0 ) { - PangoStretch v=pango_font_description_get_stretch(descr); - if ( v <= PANGO_STRETCH_EXTRA_CONDENSED ) { - res=(char*)"extra-condensed"; - } else if ( v <= PANGO_STRETCH_CONDENSED ) { - res=(char*)"condensed"; - } else if ( v <= PANGO_STRETCH_SEMI_CONDENSED ) { - res=(char*)"semi-condensed"; - } else if ( v <= PANGO_STRETCH_NORMAL ) { - res=(char*)"normal"; - } else if ( v <= PANGO_STRETCH_SEMI_EXPANDED ) { - res=(char*)"semi-expanded"; - } else if ( v <= PANGO_STRETCH_EXPANDED ) { - res=(char*)"expanded"; - } else { - res=(char*)"extra-expanded"; - } - free_res=false; - } else if ( strcmp(key,"variant") == 0 ) { - PangoVariant v=pango_font_description_get_variant(descr); - if ( v == PANGO_VARIANT_SMALL_CAPS ) { - res=(char*)"small-caps"; - } else { - res=(char*)"normal"; - } - free_res=false; - } else { - res = NULL; - free_res=false; - } - if ( res == NULL ) { - if ( size > 0 ) { - str[0] = 0; - } - return 0; - } - - if (res) { - unsigned int len=strlen(res); - unsigned int rlen=(size-1<len)?size-1:len; - if ( str ) { - if ( rlen > 0 ) { - memcpy(str, res, rlen); - } - if ( size > 0 ) { - str[rlen] = 0; - } - } - if (free_res) { - g_free(res); - res = 0; - } - return len; - } - return 0; -} - void font_instance::InitTheFace() { if (theFace == NULL && pFont != NULL) { diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 77534e706..61a141cc3 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -511,6 +511,9 @@ static char const *weight_to_text(PangoWeight w) case PANGO_WEIGHT_THIN : return "thin"; case PANGO_WEIGHT_ULTRALIGHT: return "ultralight"; case PANGO_WEIGHT_LIGHT : return "light"; +#if PANGO_VERSION_CHECK(1,36,6) + case PANGO_WEIGHT_SEMILIGHT : return "semilight"; +#endif case PANGO_WEIGHT_BOOK : return "book"; case PANGO_WEIGHT_NORMAL : return "normalweight"; case PANGO_WEIGHT_MEDIUM : return "medium"; diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert index 0ce8f1fd5..ab9465daa 100644 --- a/src/libnrtype/Makefile_insert +++ b/src/libnrtype/Makefile_insert @@ -2,13 +2,9 @@ ink_common_sources += \ libnrtype/boundary-type.h \ - libnrtype/font-style-to-pos.cpp \ - libnrtype/font-style-to-pos.h \ libnrtype/font-glyph.h \ libnrtype/font-instance.h \ libnrtype/font-style.h \ - libnrtype/nr-type-pos-def.cpp \ - libnrtype/nr-type-pos-def.h \ libnrtype/nr-type-primitives.cpp \ libnrtype/nr-type-primitives.h \ libnrtype/FontFactory.cpp \ diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 75106617b..2c7d1ce46 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -65,12 +65,6 @@ public: // for generating slanted cursors for oblique fonts Geom::OptRect BBox(int glyph_id); - // attribute queries - unsigned Name(gchar *str, unsigned size); - unsigned PSName(gchar *str, unsigned size); - unsigned Family(gchar *str, unsigned size); - unsigned Attribute(gchar const *key, gchar *str, unsigned size); - private: void FreeTheFace(); diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 6f25ab5f9..fad06cd00 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -648,6 +648,11 @@ void FontLister::fill_css(SPCSSAttr *css, Glib::ustring fontspec) case PANGO_WEIGHT_LIGHT: sp_repr_css_set_property(css, "font-weight", "300"); break; +#if PANGO_VERSION_CHECK(1,36,6) + case PANGO_WEIGHT_SEMILIGHT: + sp_repr_css_set_property(css, "font-weight", "350"); + break; +#endif case PANGO_WEIGHT_BOOK: sp_repr_css_set_property(css, "font-weight", "380"); break; @@ -814,7 +819,7 @@ Glib::ustring FontLister::fontspec_from_style(SPStyle *style) switch (style->font_stretch.computed) { case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: - fontspec += " extra-condensed"; + fontspec += " ultra-condensed"; break; case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: @@ -1004,7 +1009,7 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri } GList *styles = row[FontList.styles]; for (GList *l = styles; l; l = l->next) { - Glib::ustring fontspec = family + ", " + (char *)l->data; + Glib::ustring fontspec = family + ", " + ((StyleNames *)l->data)->CssName; PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str()); //font_description_dump( candidate ); //std::cout << " " << font_description_better_match( target, best, candidate ) << std::endl; diff --git a/src/libnrtype/font-style-to-pos.cpp b/src/libnrtype/font-style-to-pos.cpp deleted file mode 100644 index 02f5ef37c..000000000 --- a/src/libnrtype/font-style-to-pos.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "font-style-to-pos.h" -#include <style.h> - -/* 'lighter' and 'darker' have to be resolved earlier */ -/** -Given a style struct (CSS representation), sets the corresponding fields in a NRTypePosDef. - */ -NRTypePosDef -font_style_to_pos (SPStyle const &style) -{ - NRTypePosDef ret; - - switch (style.font_weight.computed) { - case SP_CSS_FONT_WEIGHT_100: - ret.weight = NR_POS_WEIGHT_CSS100; - break; - - case SP_CSS_FONT_WEIGHT_200: - ret.weight = NR_POS_WEIGHT_CSS200; - break; - - case SP_CSS_FONT_WEIGHT_300: - ret.weight = NR_POS_WEIGHT_CSS300; - break; - - case SP_CSS_FONT_WEIGHT_400: - case SP_CSS_FONT_WEIGHT_NORMAL: - ret.weight = NR_POS_WEIGHT_CSS400; - break; - - case SP_CSS_FONT_WEIGHT_500: - ret.weight = NR_POS_WEIGHT_CSS500; - break; - - case SP_CSS_FONT_WEIGHT_600: - ret.weight = NR_POS_WEIGHT_CSS600; - break; - - case SP_CSS_FONT_WEIGHT_700: - case SP_CSS_FONT_WEIGHT_BOLD: - ret.weight = NR_POS_WEIGHT_CSS700; - break; - - case SP_CSS_FONT_WEIGHT_800: - ret.weight = NR_POS_WEIGHT_CSS800; - break; - - case SP_CSS_FONT_WEIGHT_900: - ret.weight = NR_POS_WEIGHT_CSS900; - break; - - case SP_CSS_FONT_WEIGHT_LIGHTER: - case SP_CSS_FONT_WEIGHT_BOLDER: - default: - g_warning("Unrecognized font_weight.computed value"); - ret.weight = NR_POS_WEIGHT_NORMAL; - break; - } - - switch (style.font_style.computed) { - case SP_CSS_FONT_STYLE_ITALIC: - ret.italic = 1; - break; - - case SP_CSS_FONT_STYLE_OBLIQUE: - ret.oblique = 1; - break; - - case SP_CSS_FONT_STYLE_NORMAL: - default: - ret.italic = 0; - ret.oblique = 0; - break; - } - - switch (style.font_stretch.computed) { - case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: - case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: - ret.stretch = NR_POS_STRETCH_EXTRA_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_CONDENSED: - case SP_CSS_FONT_STRETCH_NARROWER: - ret.stretch = NR_POS_STRETCH_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: - ret.stretch = NR_POS_STRETCH_SEMI_CONDENSED; - break; - - case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: - ret.stretch = NR_POS_STRETCH_SEMI_EXPANDED; - break; - - case SP_CSS_FONT_STRETCH_EXPANDED: - case SP_CSS_FONT_STRETCH_WIDER: - ret.stretch = NR_POS_STRETCH_EXPANDED; - break; - - case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: - case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: - ret.stretch = NR_POS_STRETCH_EXTRA_EXPANDED; - break; - - default: - ret.stretch = NR_POS_STRETCH_NORMAL; - break; - } - - switch (style.font_variant.computed) { - case SP_CSS_FONT_VARIANT_SMALL_CAPS: - ret.variant = NR_POS_VARIANT_SMALLCAPS; - break; - default: - ret.variant = NR_POS_VARIANT_NORMAL; - break; - } - - return ret; -} diff --git a/src/libnrtype/font-style-to-pos.h b/src/libnrtype/font-style-to-pos.h deleted file mode 100644 index 41ba6cf72..000000000 --- a/src/libnrtype/font-style-to-pos.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SEEN_FONT_STYLE_TO_POS_H -#define SEEN_FONT_STYLE_TO_POS_H - -#include <libnrtype/nr-type-pos-def.h> - -class SPStyle; - -NRTypePosDef font_style_to_pos(SPStyle const &style); - -#endif // SEEN_FONT_STYLE_TO_POS_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libnrtype/nr-type-pos-def.cpp b/src/libnrtype/nr-type-pos-def.cpp deleted file mode 100644 index fef04039e..000000000 --- a/src/libnrtype/nr-type-pos-def.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include "nr-type-pos-def.h" -#include <glib.h> -#include <string.h> - -/** - * Given a font name or style name, returns a constant describing its - * apparent style (normal/italic/oblique). -*/ -int -parse_name_for_style (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint style; - // first dab at i18n... french and german - if (strstr (c, "italic") || strstr (c, "italique") || strstr (c, "kursiv")) { - style = NR_POS_STYLE_ITALIC; - } else if (strstr (c, "oblique")) { - style = NR_POS_STYLE_OBLIQUE; - } else { - style = NR_POS_STYLE_NORMAL; - } - - g_free (c); - return style; -} - - -/** - * Given a font name or style name, returns a constant describing its - * apparent weight. -*/ -int -parse_name_for_weight (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint weight; - if (strstr (c, "thin")) { - weight = NR_POS_WEIGHT_THIN; - } else if (strstr (c, "extra light")) { - weight = NR_POS_WEIGHT_EXTRA_LIGHT; - } else if (strstr (c, "ultra light")) { - weight = NR_POS_WEIGHT_ULTRA_LIGHT; - } else if (strstr (c, "light")) { - weight = NR_POS_WEIGHT_LIGHT; - } else if (strstr (c, "book")) { - weight = NR_POS_WEIGHT_BOOK; - } else if (strstr (c, "medium")) { - weight = NR_POS_WEIGHT_MEDIUM; - } else if (strstr (c, "semi bold")) { - weight = NR_POS_WEIGHT_SEMIBOLD; - } else if (strstr (c, "semibold")) { - weight = NR_POS_WEIGHT_SEMIBOLD; - } else if (strstr (c, "demi bold")) { - weight = NR_POS_WEIGHT_DEMIBOLD; - } else if (strstr (c, "demibold") || strstr (c, "demi")) { - weight = NR_POS_WEIGHT_DEMIBOLD; - } else if (strstr (c, "ultra bold")) { - weight = NR_POS_WEIGHT_ULTRA_BOLD; - } else if (strstr (c, "extra bold") || strstr (c, "xbold") || strstr (c, "xtrabold")) { - weight = NR_POS_WEIGHT_EXTRA_BOLD; - } else if (strstr (c, "black") || strstr (c, "heavy")) { - weight = NR_POS_WEIGHT_BLACK; - } else if (strstr (c, "bold")) { - /* Must come after the checks for `blah bold'. */ - weight = NR_POS_WEIGHT_BOLD; - } else { - weight = NR_POS_WEIGHT_NORMAL; - } - - g_free (c); - return weight; -} - -/** - * Given a font name or style name, returns a constant describing its - * apparent stretch. -*/ -int -parse_name_for_stretch (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint stretch; - if (strstr (c, "ultra narrow") || strstr (c, "ultra condensed") || strstr (c, "extra condensed")) { - stretch = NR_POS_STRETCH_EXTRA_CONDENSED; - } else if (strstr (c, "ultra wide") || strstr (c, "ultra expanded") || strstr (c, "ultra extended") || strstr (c, "extra expanded")) { - stretch = NR_POS_STRETCH_EXTRA_EXPANDED; - } else if (strstr (c, "semi condensed") || strstr (c, "semicondensed")) { - stretch = NR_POS_STRETCH_SEMI_CONDENSED; - } else if (strstr (c, "semi extended") || strstr (c, "semiextended")) { - stretch = NR_POS_STRETCH_SEMI_EXPANDED; - } else if (strstr (c, "narrow") || strstr (c, "condensed")) { - stretch = NR_POS_STRETCH_CONDENSED; - } else if (strstr (c, "wide") || strstr (c, "expanded") || strstr (c, "extended")) { - stretch = NR_POS_STRETCH_EXPANDED; - } else { - stretch = NR_POS_STRETCH_NORMAL; - } - - g_free (c); - return stretch; -} - -/** - * Given a font name or style name, returns a constant describing its - * apparent variant (normal/smallcaps). -*/ -int -parse_name_for_variant (char const *cc) -{ - g_assert ( cc != NULL ); - gchar *c = g_ascii_strdown (cc, -1); - - gint variant; - if (strstr (c, "small caps") || strstr (c, "smallcaps") || strstr (c, "caps")) { - variant = NR_POS_VARIANT_SMALLCAPS; - } else { - variant = NR_POS_VARIANT_NORMAL; - } - - g_free (c); - return variant; -} - -/** - * Given a style constant, returns the CSS value for font-style. -*/ -const char * -style_to_css (int style) -{ - switch (style) { - case NR_POS_STYLE_NORMAL: - return "normal"; - break; - case NR_POS_STYLE_ITALIC: - return "italic"; - break; - case NR_POS_STYLE_OBLIQUE: - return "oblique"; - break; - default: - break; - } - return NULL; -} - - -/** - * Given a weight constant, returns the CSS value for font-weight. -*/ -const char * -weight_to_css (int weight) -{ - switch (weight) { - case NR_POS_WEIGHT_THIN: - return "100"; - break; - case NR_POS_WEIGHT_EXTRA_LIGHT: - return "200"; - break; - case NR_POS_WEIGHT_LIGHT: - return "300"; - break; - case NR_POS_WEIGHT_BOOK: - return "normal"; - break; - case NR_POS_WEIGHT_MEDIUM: - return "500"; - break; - case NR_POS_WEIGHT_SEMIBOLD: - return "600"; - break; - case NR_POS_WEIGHT_BOLD: - return "bold"; - break; - case NR_POS_WEIGHT_EXTRA_BOLD: - return "800"; - break; - case NR_POS_WEIGHT_BLACK: - return "900"; - break; - default: - break; - } - return NULL; -} - -/** - * Given a stretch constant, returns the CSS value for font-stretch. -*/ -const char * -stretch_to_css (int stretch) -{ - switch (stretch) { - case NR_POS_STRETCH_EXTRA_CONDENSED: - return "extra-condensed"; - break; - case NR_POS_STRETCH_CONDENSED: - return "condensed"; - break; - case NR_POS_STRETCH_SEMI_CONDENSED: - return "semi-condensed"; - break; - case NR_POS_STRETCH_NORMAL: - return "normal"; - break; - case NR_POS_STRETCH_SEMI_EXPANDED: - return "semi-expanded"; - break; - case NR_POS_STRETCH_EXPANDED: - return "expanded"; - break; - case NR_POS_STRETCH_EXTRA_EXPANDED: - return "extra-expanded"; - break; - default: - break; - } - return NULL; -} - -/** - * Given a variant constant, returns the CSS value for font-variant. -*/ -const char * -variant_to_css (int stretch) -{ - switch (stretch) { - case NR_POS_VARIANT_SMALLCAPS: - return "small-caps"; - break; - case NR_POS_VARIANT_NORMAL: - return "normal"; - break; - default: - break; - } - return NULL; -} - - -/** - * Constructor for NRTypePostDef. Sets the italic, oblique, weight, - * stretch, and variant. - */ -NRTypePosDef::NRTypePosDef(char const *description) { - // we cannot use strcasestr, it's linux only... so we must lowercase the string first - g_assert ( description != NULL ); - gchar *c = g_ascii_strdown (description, -1); - - /* copied from nr-type-directory.cpp:nr_type_calculate_position. */ - - italic = (strstr (c, "italic") != NULL); - oblique = (strstr (c, "oblique") != NULL); - - weight = parse_name_for_weight (c); - - stretch = parse_name_for_stretch (c); - - variant = parse_name_for_variant (c); - - g_free (c); -} diff --git a/src/libnrtype/nr-type-pos-def.h b/src/libnrtype/nr-type-pos-def.h deleted file mode 100644 index ab9f5b45c..000000000 --- a/src/libnrtype/nr-type-pos-def.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef __NR_TYPE_POS_DEF_H__ -#define __NR_TYPE_POS_DEF_H__ - -#define NR_POS_STYLE_NORMAL 0 -#define NR_POS_STYLE_ITALIC 1 -#define NR_POS_STYLE_OBLIQUE 2 - -#define NR_POS_WEIGHT_THIN 32 -#define NR_POS_WEIGHT_EXTRA_LIGHT 64 -#define NR_POS_WEIGHT_ULTRA_LIGHT 64 -#define NR_POS_WEIGHT_LIGHT 96 -#define NR_POS_WEIGHT_BOOK 128 -#define NR_POS_WEIGHT_NORMAL 128 -#define NR_POS_WEIGHT_MEDIUM 144 -#define NR_POS_WEIGHT_SEMIBOLD 160 -#define NR_POS_WEIGHT_DEMIBOLD 160 -#define NR_POS_WEIGHT_BOLD 192 -#define NR_POS_WEIGHT_ULTRA_BOLD 224 -#define NR_POS_WEIGHT_EXTRA_BOLD 224 -#define NR_POS_WEIGHT_BLACK 255 - -#define NR_POS_STRETCH_ULTRA_CONDENSED 48 -#define NR_POS_STRETCH_EXTRA_CONDENSED 48 -#define NR_POS_STRETCH_CONDENSED 88 -#define NR_POS_STRETCH_SEMI_CONDENSED 108 -#define NR_POS_STRETCH_NORMAL 128 -#define NR_POS_STRETCH_SEMI_EXPANDED 148 -#define NR_POS_STRETCH_EXPANDED 168 -#define NR_POS_STRETCH_EXTRA_EXPANDED 228 -#define NR_POS_STRETCH_ULTRA_EXPANDED 228 - -// This is an enumerate, rather than on/off property, -// for I sincerely hope the vocabulary of this property will be -// extended by the W3C in the future to allow for more fancy fonts -#define NR_POS_VARIANT_NORMAL 0 -#define NR_POS_VARIANT_SMALLCAPS 1 - -/* Mapping from CSS weight numbers. - - for i in `seq 9`; do - if [ $i -le 4 ]; then w=$((32 * $i)); - elif [ $i = 5 ]; then w=144; - elif [ $i -lt 9 ]; then w=$((32 * $(($i - 1)))); - else w=255; - fi; - printf '#define NR_POS_WEIGHT_CSS%d00\t\t%3d\n' $i $w; - done - - This calculation approximately matches the old to-and-from-text code, - I don't claim it to be reasonable. ("approximately": some of the old - code wrote strings like "semi" and "heavy" that weren't being parsed - at the other end, and it had CSS100 darker than CSS200.) - */ -#define NR_POS_WEIGHT_CSS100 32 -#define NR_POS_WEIGHT_CSS200 64 -#define NR_POS_WEIGHT_CSS300 96 -#define NR_POS_WEIGHT_CSS400 128 -#define NR_POS_WEIGHT_CSS500 144 -#define NR_POS_WEIGHT_CSS600 160 -#define NR_POS_WEIGHT_CSS700 192 -#define NR_POS_WEIGHT_CSS800 224 -#define NR_POS_WEIGHT_CSS900 255 - - -class NRTypePosDef { -public: - unsigned int italic : 1; - unsigned int oblique : 1; - unsigned int weight : 8; - unsigned int stretch : 8; - unsigned int variant : 8; - /* These can probably be made sensible sizes rather than bitfields; for the moment we'll - keep the old definition. */ - -public: - NRTypePosDef() : - italic(0), - oblique(0), - weight(NR_POS_WEIGHT_NORMAL), - stretch(NR_POS_STRETCH_NORMAL), - variant(NR_POS_VARIANT_NORMAL) - { } - - NRTypePosDef(char const *description); - - bool signature() {return this->italic + - this->oblique * 255 + - this->weight * 255 * 255 + - this->stretch * 255 * 255 * 255 + - this->variant * 255 * 255 * 255 * 255;}; -}; - -int parse_name_for_style (char const *c); -int parse_name_for_weight (char const *c); -int parse_name_for_stretch (char const *c); -int parse_name_for_variant (char const *c); -const char *style_to_css (int style); -const char *weight_to_css (int weight); -const char *stretch_to_css (int stretch); -const char *variant_to_css (int variant); - -#endif /* __NR_TYPE_POS_DEF_H__ */ diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 87562ddc4..22f688873 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -74,7 +74,7 @@ #include "xml/document.h" #include <glibmm/i18n.h> #include "ui/tools/pen-tool.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "message-stack.h" #include "desktop.h" #include "knotholder.h" diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index eaf9fe4a6..33171b184 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -76,6 +76,9 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) { // get the item bounding box original_bbox(lpeitem); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } Geom::Piecewise<Geom::D2<Geom::SBasis> > diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index d45afb0d9..5ba0d697b 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,9 +39,11 @@ #include "desktop-handles.h" #include "verbs.h" #include "sp-lpe-item.h" +#include "sp-namedview.h" #include "display/sp-canvas.h" #include <typeinfo> #include <vector> +#include "util/units.h" // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -80,6 +82,13 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : LPEBSpline::~LPEBSpline() {} +void LPEBSpline::doBeforeEffect (SPLPEItem const* lpeitem) +{ + if(!hp.empty()){ + hp.clear(); + } +} + void LPEBSpline::createAndApply(const char *name, SPDocument *doc, SPItem *item) { if (!SP_IS_SHAPE(item)) { @@ -109,6 +118,14 @@ void LPEBSpline::doEffect(SPCurve *curve) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); + double radiusHelperNodes = 6.0; + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop){ + radiusHelperNodes /= SP_ACTIVE_DESKTOP->current_zoom(); + SPNamedView *nv = sp_desktop_namedview(desktop); + radiusHelperNodes = Inkscape::Util::Quantity::convert(radiusHelperNodes, "px", nv->doc_units->abbr); + } + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { if (path_it->empty()) @@ -228,6 +245,9 @@ void LPEBSpline::doEffect(SPCurve *curve) node = curve_it1->finalPoint(); } nCurve->curveto(pointAt1, pointAt2, node); + if(!are_near(node,curve_it1->finalPoint())){ + drawHandle(node, radiusHelperNodes); + } } ++curve_it1; ++curve_it2; @@ -239,9 +259,29 @@ void LPEBSpline::doEffect(SPCurve *curve) curve->append(nCurve, false); nCurve->reset(); delete nCurve; + Geom::PathVector const pathv = curve->get_pathvector(); + hp.push_back(pathv[0]); } } +void +LPEBSpline::drawHandle(Geom::Point p, double radiusHelperNodes) +{ + char const * svgd = "M 1,0.5 A 0.5,0.5 0 0 1 0.5,1 0.5,0.5 0 0 1 0,0.5 0.5,0.5 0 0 1 0.5,0 0.5,0.5 0 0 1 1,0.5 Z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + Geom::Affine aff = Geom::Affine(); + aff *= Geom::Scale(radiusHelperNodes); + pathv *= aff; + pathv += p - Geom::Point(0.5*radiusHelperNodes, 0.5*radiusHelperNodes); + hp.push_back(pathv[0]); +} + +void +LPEBSpline::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +{ + hp_vec.push_back(hp); +} + Gtk::Widget *LPEBSpline::newWidget() { // use manage here, because after deletion of Effect object, others might diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index f37741a4a..e066015ad 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -24,6 +24,9 @@ public: return SUPPRESS_FLASH; } virtual void doEffect(SPCurve *curve); + virtual void doBeforeEffect(SPLPEItem const* lpeitem); + void drawHandle(Geom::Point p, double radiusHelperNodes); + void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec); void doBSplineFromWidget(SPCurve *curve, double value); bool nodeIsSelected(Geom::Point nodePoint); @@ -43,6 +46,7 @@ private: BoolParam ignoreCusp; BoolParam onlySelected; ScalarParam weight; + Geom::PathVector hp; LPEBSpline(const LPEBSpline &); LPEBSpline &operator=(const LPEBSpline &); diff --git a/src/live_effects/lpe-envelope-perspective.cpp b/src/live_effects/lpe-envelope-perspective.cpp index 6d3441d93..378ef5a92 100644 --- a/src/live_effects/lpe-envelope-perspective.cpp +++ b/src/live_effects/lpe-envelope-perspective.cpp @@ -19,7 +19,7 @@ #include "helper/geom.h" #include "display/curve.h" #include "svg/svg.h" -#include <tools-switch.h> +#include "ui/tools-switch.h" #include <gsl/gsl_linalg.h> #include "desktop.h" @@ -350,6 +350,9 @@ LPEEnvelopePerspective::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); setDefaults(); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } void diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 4f5623fba..05a672ae8 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -32,7 +32,7 @@ LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) : bend_path2(_("Right bend path:"), _("Right path along which to bend the original path"), "bendpath2", &wr, this, "M0,0 L1,0"), bend_path3(_("Bottom bend path:"), _("Bottom path along which to bend the original path"), "bendpath3", &wr, this, "M0,0 L1,0"), bend_path4(_("Left bend path:"), _("Left path along which to bend the original path"), "bendpath4", &wr, this, "M0,0 L1,0"), - xx(_("E_nable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true), + xx(_("_Enable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true), yy(_("_Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true) { registerParameter( dynamic_cast<Parameter *>(&yy) ); @@ -54,6 +54,9 @@ LPEEnvelope::doBeforeEffect (SPLPEItem const* lpeitem) { // get the item bounding box original_bbox(lpeitem); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } Geom::Piecewise<Geom::D2<Geom::SBasis> > diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 857e9d9cc..b267c92ed 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -29,7 +29,7 @@ // for programmatically updating knots #include "selection.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/selectable-control-point.h" #include "ui/tool/node.h" @@ -42,6 +42,14 @@ using namespace Geom; namespace Inkscape { namespace LivePathEffect { +static const Util::EnumData<FilletMethod> FilletMethodData[FM_END] = { + { FM_AUTO, N_("Auto"), "auto" }, + { FM_ARC, N_("Force arc"), "arc" }, + { FM_BEZIER, N_("Force bezier"), "bezier" } +}; +static const Util::EnumDataConverter<FilletMethod> +FMConverter(FilletMethodData, FM_END); + const double tolerance = 0.001; const double gapHelper = 0.00001; @@ -52,14 +60,15 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false), only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false), flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"), "flexible", &wr, this, false), - force_arcs(_("Use arcs in cubic curves"), _("Use arcs in cubic curves"), "force_arcs", &wr, this, false), use_knot_distance(_("Use knots distance instead radius"), _("Use knots distance instead radius"), "use_knot_distance", &wr, this, false), unit(_("Unit"), _("Unit"), "unit", &wr, this), + method(_("Method"), _("Fillets methods"), "method", FMConverter, &wr, this, FM_AUTO), radius(_("Radius (unit or %)"), _("Radius, in unit or %"), "radius", &wr, this, 0.), helper_size(_("Helper size with direction"), _("Helper size with direction"), "helper_size", &wr, this, 0) { registerParameter(&fillet_chamfer_values); registerParameter(&unit); + registerParameter(&method); registerParameter(&radius); registerParameter(&helper_size); registerParameter(&flexible); @@ -67,7 +76,6 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : registerParameter(&ignore_radius_0); registerParameter(&only_selected); registerParameter(&hide_knots); - registerParameter(&force_arcs); radius.param_set_range(0., infinity()); radius.param_set_increments(1, 1); @@ -447,7 +455,11 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) { if (SP_IS_SHAPE(lpeItem)) { - fillet_chamfer_values.set_helper_size(helper_size); + if(hide_knots){ + fillet_chamfer_values.set_helper_size(0); + } else { + fillet_chamfer_values.set_helper_size(helper_size); + } fillet_chamfer_values.set_use_distance(use_knot_distance); fillet_chamfer_values.set_unit(unit.get_abbreviation()); SPCurve *c = SP_IS_PATH(lpeItem) ? static_cast<SPPath const *>(lpeItem) @@ -591,14 +603,14 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) } path_out.appendNew<Geom::LineSegment>(endArcPoint); } else if (type == 2) { - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed)) || force_arcs){ + if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ ccwToggle = ccwToggle?0:1; path_out.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); }else{ path_out.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); } } else { - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed)) || force_arcs){ + if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ path_out.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); } else { path_out.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint); diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index 49b407b71..873684101 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -33,6 +33,12 @@ namespace Inkscape { namespace LivePathEffect { +enum FilletMethod { + FM_AUTO, + FM_ARC, + FM_BEZIER, + FM_END +}; class LPEFilletChamfer : public Effect { public: @@ -67,9 +73,9 @@ private: BoolParam ignore_radius_0; BoolParam only_selected; BoolParam flexible; - BoolParam force_arcs; BoolParam use_knot_distance; UnitParam unit; + EnumParam<FilletMethod> method; ScalarParam radius; ScalarParam helper_size; diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 8136569e8..a241a8a2e 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -176,6 +176,9 @@ void LPELattice::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } void diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index 13759f126..7036b0cfa 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -32,7 +32,7 @@ #include <2geom/d2.h> #include <2geom/piecewise.h> #include <2geom/transforms.h> -#include <tools-switch.h> +#include "ui/tools-switch.h" #include "desktop.h" // TODO: should be factored out (see below) @@ -254,6 +254,9 @@ LPELattice2::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); setDefaults(); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } void diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 4d4837d8d..0bb67a4a2 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -43,6 +43,14 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() } void +LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) +{ + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); +} + +void LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index c01d1bf6f..a4a2b86c0 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -30,6 +30,8 @@ public: virtual void doOnApply (SPLPEItem const* lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); private: diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index 192bd17ca..dc91775b7 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -55,6 +55,14 @@ static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2, pwd2.continuousConcat(cap_pwd2); } +void +LPEOffset::doBeforeEffect (SPLPEItem const* lpeitem) +{ + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); +} + Geom::Piecewise<Geom::D2<Geom::SBasis> > LPEOffset::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { diff --git a/src/live_effects/lpe-offset.h b/src/live_effects/lpe-offset.h index 9966fd45d..997311c7d 100644 --- a/src/live_effects/lpe-offset.h +++ b/src/live_effects/lpe-offset.h @@ -28,6 +28,8 @@ public: virtual void doOnApply (SPLPEItem const* lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); private: diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index fb5ac5363..8097de783 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -91,6 +91,9 @@ LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) SP_LPE_ITEM(lpeitem)->removeCurrentPathEffect(false); return; } + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { diff --git a/src/live_effects/lpe-powerstroke-interpolators.h b/src/live_effects/lpe-powerstroke-interpolators.h index 3cde0b4b3..e3ab37e27 100644 --- a/src/live_effects/lpe-powerstroke-interpolators.h +++ b/src/live_effects/lpe-powerstroke-interpolators.h @@ -206,7 +206,6 @@ private: SpiroInterpolator& operator=(const SpiroInterpolator&); }; - // Quick mockup for testing the behavior for powerstroke controlpoint interpolation class CentripetalCatmullRomInterpolator : public Interpolator { public: diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index b1951d978..58d733b53 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -226,10 +226,10 @@ enum LineJoinType { static const Util::EnumData<unsigned> LineJoinTypeData[] = { {LINEJOIN_BEVEL, N_("Beveled"), "bevel"}, {LINEJOIN_ROUND, N_("Rounded"), "round"}, - {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, +// {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, // disabled because doesn't work well + {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, {LINEJOIN_MITER, N_("Miter"), "miter"}, {LINEJOIN_SPIRO, N_("Spiro"), "spiro"}, - {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, }; static const Util::EnumDataConverter<unsigned> LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData)); @@ -482,8 +482,9 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom:: break; } case LINEJOIN_EXTRP_MITER_ARC: { - Geom::Circle circle1 = Geom::touching_circle(reverse(B[prev_i]),0.); - Geom::Circle circle2 = Geom::touching_circle(B[i],0.); + // Extrapolate using the curvature at the end of the path segments to join + Geom::Circle circle1 = Geom::touching_circle(reverse(B[prev_i]), 0.0); + Geom::Circle circle2 = Geom::touching_circle(B[i], 0.0); Geom::Point points[2]; int solutions = circle_circle_intersection(circle1, circle2, points[0], points[1]); if (solutions == 2) { diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index b9d575e06..ffd5433bf 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -71,11 +71,14 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) LPERoughen::~LPERoughen() {} -void LPERoughen::doBeforeEffect(SPLPEItem const */*lpeitem*/) +void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { displaceX.resetRandomizer(); displaceY.resetRandomizer(); srand(1); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } Gtk::Widget *LPERoughen::newWidget() diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 7e99b47bf..d5ec726bd 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -38,7 +38,7 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); virtual Geom::Point randomize(); - virtual void doBeforeEffect(SPLPEItem const */*lpeitem*/); + virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t); virtual SPCurve *jitter(const Geom::Curve *A); virtual Geom::Point tpoint(Geom::Point A, Geom::Point B, double t = 0.5); diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 788ab593a..fd611c78d 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -29,7 +29,7 @@ static const Util::EnumData<MarkDirType> MarkDirData[] = { static const Util::EnumDataConverter<MarkDirType> MarkDirTypeConverter(MarkDirData, sizeof(MarkDirData)/sizeof(*MarkDirData)); static const Util::EnumData<BorderMarkType> BorderMarkData[] = { - {BORDERMARK_NONE , N_("None"), "none"}, + {BORDERMARK_NONE , NC_("Border mark", "None"), "none"}, {BORDERMARK_START , N_("Start"), "start"}, {BORDERMARK_END , N_("End"), "end"}, {BORDERMARK_BOTH , N_("Both"), "both"}, diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index a817f30f1..c191fbbe6 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -65,6 +65,9 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem) hp.clear(); } bbox = SP_ITEM(lpeitem)->visualBounds(); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 8b0b716fe..7c1913076 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -264,6 +264,9 @@ LPEVonKoch::doBeforeEffect (SPLPEItem const* lpeitem) tmp_pathv.push_back(tmp_path); ref_path.set_new_value(tmp_pathv,true); } + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); } diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index bb00ef045..e2b1aba61 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -8,11 +8,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glibmm.h> - -#include "ui/dialog/lpe-fillet-chamfer-properties.h" -#include "live_effects/parameter/filletchamferpointarray.h" - #include <2geom/piecewise.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis-geometric.h> @@ -384,25 +379,29 @@ void FilletChamferPointArrayParam::updateCanvasIndicators() std::vector<Point> ts = data(); hp.clear(); unsigned int i = 0; - Piecewise<D2<SBasis> > const &n = get_pwd2_normal(); for (std::vector<Point>::const_iterator point_it = ts.begin(); point_it != ts.end(); ++point_it) { - double Xvalue = to_time(i, (*point_it)[X]); - double XPlusValue = to_time(i, -helper_size) - i; - if (Xvalue == i) { + double Xvalue = to_time(i, (*point_it)[X]) -i; + if (Xvalue == 0) { i++; continue; } - Point canvas_point = last_pwd2.valueAt(Xvalue) + 0 * n.valueAt(Xvalue); - Point start_point = last_pwd2.valueAt(Xvalue + XPlusValue) + - helper_size * n.valueAt(Xvalue + XPlusValue); - Point end_point = last_pwd2.valueAt(Xvalue + XPlusValue) - - helper_size * n.valueAt(Xvalue + XPlusValue); - Geom::Path arrow; - arrow.start(start_point); - arrow.appendNew<Geom::LineSegment>(canvas_point); - arrow.appendNew<Geom::LineSegment>(end_point); - hp.push_back(arrow); + Geom::Point ptA = last_pwd2[i].valueAt(Xvalue); + Geom::Point derivA = unit_vector(derivative(last_pwd2[i]).valueAt(Xvalue)); + Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); + derivA = derivA * rot; + Geom::Point C = ptA - derivA * helper_size; + Geom::Point D = ptA + derivA * helper_size; + Geom::Ray ray1(C, D); + char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + Geom::Affine aff = Geom::Affine(); + aff *= Geom::Scale(helper_size); + aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + pathv *= aff; + pathv += last_pwd2[i].valueAt(Xvalue); + hp.push_back(pathv[0]); + hp.push_back(pathv[1]); i++; } } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 8095056b7..2a14d4208 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -28,8 +28,8 @@ #include "document-undo.h" // needed for on-canvas editting: -#include "tools-switch.h" -#include "shape-editor.h" +#include "ui/tools-switch.h" +#include "ui/shape-editor.h" #include "desktop-handles.h" #include "selection.h" // clipboard support @@ -143,7 +143,7 @@ gchar * PathParam::param_getSVGValue() const { if (href) { - return href; + return g_strdup(href); } else { gchar * svgd = sp_svg_write_path( _pathvector ); return svgd; diff --git a/src/live_effects/parameter/pointreseteable.cpp b/src/live_effects/parameter/pointreseteable.cpp index ec36fc035..c0f8858b8 100644 --- a/src/live_effects/parameter/pointreseteable.cpp +++ b/src/live_effects/parameter/pointreseteable.cpp @@ -15,7 +15,7 @@ #include "verbs.h" #include "knotholder.h" #include <glibmm/i18n.h> -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/node-tool.h" // needed for on-canvas editting: diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 427be8065..851b12ef8 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -68,13 +68,16 @@ PowerStrokePointArrayParam::param_newWidget() */ } - -void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) +void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) { -// param_set_and_write_new_value( (*this) * postmul ); + std::vector<Geom::Point> result; + for (std::vector<Geom::Point>::const_iterator point_it = _vector.begin(); point_it != _vector.end(); ++point_it) { + Geom::Coord A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2); + result.push_back(Geom::Point((*point_it)[Geom::X], A)); + } + param_set_and_write_new_value(result); } - /** call this method to recalculate the controlpoints such that they stay at the same location relative to the new path. Useful after adding/deleting nodes to the path.*/ void PowerStrokePointArrayParam::recalculate_controlpoints_for_new_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 911bbc82d..70b22e27e 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -31,7 +31,7 @@ public: virtual Gtk::Widget * param_newWidget(); - virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); + virtual void param_transform_multiply(Geom::Affine const& postmul, bool /*set*/); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 88fc27abd..03b37b51c 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -85,7 +85,7 @@ TextParam::param_readSVGValue(const gchar * strvalue) gchar * TextParam::param_getSVGValue() const { - return (gchar *) value.c_str(); + return g_strdup(value.c_str()); } Gtk::Widget * diff --git a/src/main.cpp b/src/main.cpp index e57231d17..a60ed1f25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,7 +64,7 @@ #include "layer-model.h" #include "selection.h" #include "sp-object.h" -#include "interface.h" +#include "ui/interface.h" #include "print.h" #include "color.h" #include "sp-item.h" diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 0f7aa6368..9ff6df3bf 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -677,7 +677,7 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(IntermSnapResults &isr, (*p_inters) = dt->doc2dt(*p_inters); // Construct a snapped point Geom::Coord dist = Geom::L2(p.getPoint() - *p_inters); - SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);; + SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, false, k->target_bbox); // Store the snapped point if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it isr.points.push_back(s); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 1ea142839..fa872ead1 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -37,11 +37,11 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "dir-util.h" #include "layer-model.h" #include "selection.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "desktop-handles.h" #include "message-stack.h" #include "sp-item-transform.h" -#include "marker.h" +#include "sp-marker.h" #include "sp-use.h" #include "sp-textpath.h" #include "sp-tspan.h" @@ -112,7 +112,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-item-group.h" // For clippath editing -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/node-tool.h" #include "ui/clipboard.h" @@ -762,7 +762,7 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) sp_selection_group_impl(p, group, xml_doc, doc); DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, - _("Group")); + C_("Verb", "Group")); selection->set(group); Inkscape::GC::release(group); @@ -4063,6 +4063,10 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { // Collect all clipped paths and masks within a single group Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc); + if(copy->attribute("inkscape:original-d")) + { + copy->setAttribute("d", copy->attribute("inkscape:original-d")); + } items_to_move = g_slist_prepend(items_to_move, copy); } diff --git a/src/snap.cpp b/src/snap.cpp index fb87aae6b..8138e4546 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -430,7 +430,7 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED); IntermSnapResults isr; - Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); + Inkscape::Snapper::SnapConstraint cl(guideline.getPoint(), Geom::rot90(guideline.getNormal())); SnapperList snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 7de65ccc3..72fe86daf 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -673,6 +673,21 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) return xform; } + SPObject *region = NULL; + for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { + if (SP_IS_FLOWREGION(o)) { + region = o; + break; + } + } + if (region) { + if (SP_IS_RECT(region->firstChild())) { + SPRect *rect = SP_RECT(region->firstChild()); + rect->set_i2d_affine(xform * rect->i2dt_affine()); + rect->doWriteTransform(rect->getRepr(), rect->transform, NULL, true); + } + } + Geom::Affine ret(xform); ret[0] /= ex; ret[1] /= ex; @@ -693,7 +708,7 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); - return ret; + return Geom::Affine(); } /* diff --git a/src/sp-guide-constraint.h b/src/sp-guide-constraint.h index ebc3b01ce..29f47f45a 100644 --- a/src/sp-guide-constraint.h +++ b/src/sp-guide-constraint.h @@ -29,10 +29,8 @@ public: } }; - #endif // SEEN_SP_GUIDE_CONSTRAINT_H - /* Local Variables: mode:c++ diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 0e83c2acf..581c8a440 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -46,117 +46,38 @@ using Inkscape::DocumentUndo; using std::vector; -//enum { -// PROP_0, -// PROP_COLOR, -// PROP_HICOLOR -//}; -// -//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - #include "sp-factory.h" namespace { - SPObject* createGuide() { - return new SPGuide(); - } - - bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); -} - -//static void sp_guide_class_init(SPGuideClass *gc) -//{ -// GObjectClass *gobject_class = (GObjectClass *) gc; -// -// gobject_class->set_property = sp_guide_set_property; -// gobject_class->get_property = sp_guide_get_property; -// -// g_object_class_install_property(gobject_class, -// PROP_COLOR, -// g_param_spec_uint("color", "Color", "Color", -// 0, -// 0xffffffff, -// 0xff000000, -// (GParamFlags) G_PARAM_READWRITE)); -// -// g_object_class_install_property(gobject_class, -// PROP_HICOLOR, -// g_param_spec_uint("hicolor", "HiColor", "HiColor", -// 0, -// 0xffffffff, -// 0xff000000, -// (GParamFlags) G_PARAM_READWRITE)); -//} -// CPPIFY: properties! - -SPGuide::SPGuide() : SPObject() { - this->label = NULL; - this->views = NULL; - - this->normal_to_line = Geom::Point(0.,1.); - this->point_on_line = Geom::Point(0.,0.); - this->color = 0x0000ff7f; - this->hicolor = 0xff00007f; -} - -SPGuide::~SPGuide() { -} - -guint32 SPGuide::getColor() const { - return color; -} + SPObject* createGuide() { + return new SPGuide(); + } -guint32 SPGuide::getHiColor() const { - return hicolor; + bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide); } -void SPGuide::setColor(guint32 c) { - color = c; - - for (GSList *l = this->views; l != NULL; l = l->next) { - sp_guideline_set_color(SP_GUIDELINE(l->data), this->color); - } -} +SPGuide::SPGuide() + : SPObject() + , label(NULL) + , views(NULL) + , normal_to_line(Geom::Point(0.,1.)) + , point_on_line(Geom::Point(0.,0.)) + , color(0x0000ff7f) + , hicolor(0xff00007f) +{} + +void SPGuide::setColor(guint32 c) +{ + color = c; -void SPGuide::setHiColor(guint32 h) { - this->hicolor = h; + for (GSList *l = this->views; l != NULL; l = l->next) { + sp_guideline_set_color(SP_GUIDELINE(l->data), this->color); + } } -//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) -//{ -// SPGuide &guide = *SP_GUIDE(object); -// -// switch (prop_id) { -// case PROP_COLOR: -// guide.color = g_value_get_uint(value); -// for (GSList *l = guide.views; l != NULL; l = l->next) { -// sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color); -// } -// break; -// -// case PROP_HICOLOR: -// guide.hicolor = g_value_get_uint(value); -// break; -// } -//} -// -//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/) -//{ -// SPGuide const &guide = *SP_GUIDE(object); -// -// switch (prop_id) { -// case PROP_COLOR: -// g_value_set_uint(value, guide.color); -// break; -// case PROP_HICOLOR: -// g_value_set_uint(value, guide.hicolor); -// break; -// } -//} - -void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPObject::build(document, repr); +void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) +{ + SPObject::build(document, repr); this->readAttr( "inkscape:label" ); this->readAttr( "orientation" ); @@ -166,7 +87,8 @@ void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { document->addResource("guide", this); } -void SPGuide::release() { +void SPGuide::release() +{ while (this->views) { sp_guideline_delete(SP_GUIDELINE(this->views->data)); this->views = g_slist_remove(this->views, this->views->data); @@ -191,67 +113,67 @@ void SPGuide::set(unsigned int key, const gchar *value) { this->label = NULL; } - sp_guide_set_label(*this, this->label, false); + this->set_label(this->label, false); break; case SP_ATTR_ORIENTATION: - { - if (value && !strcmp(value, "horizontal")) { - /* Visual representation of a horizontal line, constrain vertically (y coordinate). */ - this->normal_to_line = Geom::Point(0., 1.); - } else if (value && !strcmp(value, "vertical")) { - this->normal_to_line = Geom::Point(1., 0.); - } else if (value) { - gchar ** strarray = g_strsplit(value, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) { - Geom::Point direction(newx, newy); - direction.normalize(); - this->normal_to_line = direction; - } else { - // default to vertical line for bad arguments - this->normal_to_line = Geom::Point(1., 0.); - } + { + if (value && !strcmp(value, "horizontal")) { + /* Visual representation of a horizontal line, constrain vertically (y coordinate). */ + this->normal_to_line = Geom::Point(0., 1.); + } else if (value && !strcmp(value, "vertical")) { + this->normal_to_line = Geom::Point(1., 0.); + } else if (value) { + gchar ** strarray = g_strsplit(value, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) { + Geom::Point direction(newx, newy); + direction.normalize(); + this->normal_to_line = direction; } else { // default to vertical line for bad arguments this->normal_to_line = Geom::Point(1., 0.); } - sp_guide_set_normal(*this, this->normal_to_line, false); + } else { + // default to vertical line for bad arguments + this->normal_to_line = Geom::Point(1., 0.); } - break; + this->set_normal(this->normal_to_line, false); + } + break; case SP_ATTR_POSITION: - { - if (value) { - gchar ** strarray = g_strsplit(value, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - this->point_on_line = Geom::Point(newx, newy); - } else if (success == 1) { - // before 0.46 style guideline definition. - const gchar *attr = this->getRepr()->attribute("orientation"); - if (attr && !strcmp(attr, "horizontal")) { - this->point_on_line = Geom::Point(0, newx); - } else { - this->point_on_line = Geom::Point(newx, 0); - } + { + if (value) { + gchar ** strarray = g_strsplit(value, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + this->point_on_line = Geom::Point(newx, newy); + } else if (success == 1) { + // before 0.46 style guideline definition. + const gchar *attr = this->getRepr()->attribute("orientation"); + if (attr && !strcmp(attr, "horizontal")) { + this->point_on_line = Geom::Point(0, newx); + } else { + this->point_on_line = Geom::Point(newx, 0); } - } else { - // default to (0,0) for bad arguments - this->point_on_line = Geom::Point(0,0); } - // update position in non-committing way - // fixme: perhaps we need to add an update method instead, and request_update here - sp_guide_moveto(*this, this->point_on_line, false); + } else { + // default to (0,0) for bad arguments + this->point_on_line = Geom::Point(0,0); } - break; + // update position in non-committing way + // fixme: perhaps we need to add an update method instead, and request_update here + this->moveto(this->point_on_line, false); + } + break; default: SPObject::set(key, value); - break; + break; } } @@ -276,15 +198,15 @@ SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::P return guide; } -void -sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts) { +void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts) +{ for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) { SPGuide::createSPGuide(doc, (*i).first, (*i).second); } } -void -sp_guide_create_guides_around_page(SPDesktop *dt) { +void sp_guide_create_guides_around_page(SPDesktop *dt) +{ SPDocument *doc=sp_desktop_document(dt); std::list<std::pair<Geom::Point, Geom::Point> > pts; @@ -303,8 +225,8 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page")); } -void -sp_guide_delete_all_guides(SPDesktop *dt) { +void sp_guide_delete_all_guides(SPDesktop *dt) +{ SPDocument *doc=sp_desktop_document(dt); const GSList *current; while ( (current = doc->getResourceList("guide")) ) { @@ -325,6 +247,14 @@ void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) views = g_slist_prepend(views, item); } +void SPGuide::showSPGuide() +{ + for (GSList *v = views; v != NULL; v = v->next) { + sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); + sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); + } +} + void SPGuide::hideSPGuide(SPCanvas *canvas) { g_assert(canvas != NULL); @@ -338,7 +268,15 @@ void SPGuide::hideSPGuide(SPCanvas *canvas) } } - g_assert_not_reached(); + assert(false); +} + +void SPGuide::hideSPGuide() +{ + for (GSList *v = views; v != NULL; v = v->next) { + sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); + sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); + } } void SPGuide::sensitize(SPCanvas *canvas, bool sensitive) @@ -353,7 +291,7 @@ void SPGuide::sensitize(SPCanvas *canvas, bool sensitive) } } - g_assert_not_reached(); + assert(false); } Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const @@ -371,11 +309,9 @@ double SPGuide::getDistanceFrom(Geom::Point const &pt) const * true indicates a "committing" version: in response to button release event after * dragging a guideline, or clicking OK in guide editing dialog. */ -void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit) +void SPGuide::moveto(Geom::Point const point_on_line, bool const commit) { - g_assert(SP_IS_GUIDE(&guide)); - - for (GSList *l = guide.views; l != NULL; l = l->next) { + for (GSList *l = views; l != NULL; l = l->next) { sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line); } @@ -383,16 +319,16 @@ void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { //XML Tree being used here directly while it shouldn't be. - sp_repr_set_point(guide.getRepr(), "position", point_on_line); + sp_repr_set_point(getRepr(), "position", point_on_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) - for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()), - iEnd(guide.attached_items.end()); + for (vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), + iEnd(attached_items.end()); i != iEnd; ++i) { SPGuideAttachment const &att = *i; - sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit); + sp_item_notify_moveto(*att.item, this, att.snappoint_ix, position, commit); } */ } @@ -402,11 +338,9 @@ void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const * true indicates a "committing" version: in response to button release event after * dragging a guideline, or clicking OK in guide editing dialog. */ -void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit) +void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit) { - g_assert(SP_IS_GUIDE(&guide)); - - for (GSList *l = guide.views; l != NULL; l = l->next) { + for (GSList *l = this->views; l != NULL; l = l->next) { sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line); } @@ -414,47 +348,45 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { //XML Tree being used directly while it shouldn't be - sp_repr_set_point(guide.getRepr(), "orientation", normal_to_line); + sp_repr_set_point(getRepr(), "orientation", normal_to_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) - for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()), - iEnd(guide.attached_items.end()); + for (vector<SPGuideAttachment>::const_iterator i(attached_items.begin()), + iEnd(attached_items.end()); i != iEnd; ++i) { SPGuideAttachment const &att = *i; - sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit); + sp_item_notify_moveto(*att.item, this, att.snappoint_ix, position, commit); } */ } -void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit) +void SPGuide::set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit) { - g_assert(SP_IS_GUIDE(&guide)); - guide.color = (r << 24) | (g << 16) | (b << 8) | 0x7f; + this->color = (r << 24) | (g << 16) | (b << 8) | 0x7f; - if (guide.views){ - sp_guideline_set_color(SP_GUIDELINE(guide.views->data), guide.color); + if (views) { + sp_guideline_set_color(SP_GUIDELINE(views->data), this->color); } - if (commit){ + if (commit) { std::ostringstream os; os << "rgb(" << r << "," << g << "," << b << ")"; //XML Tree being used directly while it shouldn't be - guide.getRepr()->setAttribute("inkscape:color", os.str().c_str()); + getRepr()->setAttribute("inkscape:color", os.str().c_str()); } } -void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) +void SPGuide::set_label(const char* label, bool const commit) { - g_assert(SP_IS_GUIDE(&guide)); - if (guide.views){ - sp_guideline_set_label(SP_GUIDELINE(guide.views->data), label); + if (views) { + sp_guideline_set_label(SP_GUIDELINE(views->data), label); } - if (commit){ + if (commit) { //XML Tree being used directly while it shouldn't be - guide.getRepr()->setAttribute("inkscape:label", label); + getRepr()->setAttribute("inkscape:label", label); } } @@ -464,33 +396,33 @@ void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit) * * The caller is responsible for freeing the string. */ -char *sp_guide_description(SPGuide const *guide, const bool verbose) +char* SPGuide::description(bool const verbose) const { using Geom::X; using Geom::Y; - char *descr = 0; - if ( !guide->document ) { + char *descr = NULL; + if ( !this->document ) { // Guide has probably been deleted and no longer has an attached namedview. - descr = g_strdup_printf("%s", _("Deleted")); + descr = g_strdup(_("Deleted")); } else { - SPNamedView *namedview = sp_document_namedview(guide->document, NULL); + SPNamedView *namedview = sp_document_namedview(this->document, NULL); - Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(guide->point_on_line[X], "px"); - Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(guide->point_on_line[Y], "px"); + Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(this->point_on_line[X], "px"); + Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(this->point_on_line[Y], "px"); GString *position_string_x = g_string_new(x_q.string(namedview->doc_units).c_str()); GString *position_string_y = g_string_new(y_q.string(namedview->doc_units).c_str()); gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete")); - if ( are_near(guide->normal_to_line, Geom::Point(1., 0.)) || - are_near(guide->normal_to_line, -Geom::Point(1., 0.)) ) { + if ( are_near(this->normal_to_line, Geom::Point(1., 0.)) || + are_near(this->normal_to_line, -Geom::Point(1., 0.)) ) { descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); - } else if ( are_near(guide->normal_to_line, Geom::Point(0., 1.)) || - are_near(guide->normal_to_line, -Geom::Point(0., 1.)) ) { + } else if ( are_near(this->normal_to_line, Geom::Point(0., 1.)) || + are_near(this->normal_to_line, -Geom::Point(0., 1.)) ) { descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); } else { - double const radians = guide->angle(); + double const radians = this->angle(); double const degrees = Geom::rad_to_deg(radians); int const degrees_int = (int) round(degrees); descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"), @@ -537,4 +469,4 @@ void sp_guide_remove(SPGuide *guide) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-guide.h b/src/sp-guide.h index cd67df222..382ea56f0 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -20,11 +20,14 @@ #include "sp-guide-attachment.h" typedef unsigned int guint32; -typedef void (*GCallback) (void); +extern "C" { + typedef void (*GCallback) (void); + typedef struct _GSList GSList; +} +class SPDesktop; struct SPCanvas; struct SPCanvasGroup; -class SPDesktop; #define SP_GUIDE(obj) (dynamic_cast<SPGuide*>((SPObject*)obj)) #define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj) != NULL) @@ -32,51 +35,65 @@ class SPDesktop; /* Represents the constraint on p that dot(g.direction, p) == g.position. */ class SPGuide : public SPObject { public: - SPGuide(); - virtual ~SPGuide(); + SPGuide(); + virtual ~SPGuide() {} - char* label; - Geom::Point normal_to_line; - Geom::Point point_on_line; + void set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit); + void setColor(guint32 c); + void setHiColor(guint32 h) { hicolor = h; } - guint32 color; - guint32 hicolor; - GSList *views; - std::vector<SPGuideAttachment> attached_items; + guint32 getColor() const { return color; } + guint32 getHiColor() const { return hicolor; } + Geom::Point getPoint() const { return point_on_line; } + Geom::Point getNormal() const { return normal_to_line; } - guint32 getColor() const; - guint32 getHiColor() const; - void setColor(guint32 c); - void setHiColor(guint32 h); + void moveto(Geom::Point const point_on_line, bool const commit); + void set_normal(Geom::Point const normal_to_line, bool const commit); + + void set_label(const char* label, bool const commit); + char const* getLabel() const { return label; } - inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; - inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; - inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }; static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2); + void showSPGuide(SPCanvasGroup *group, GCallback handler); void hideSPGuide(SPCanvas *canvas); + void showSPGuide(); // argument-free versions + void hideSPGuide(); + void sensitize(SPCanvas *canvas, bool sensitive); - Geom::Point getPositionFrom(Geom::Point const &pt) const; + + bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; + bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; + + char* description(bool const verbose = true) const; + + double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); } double getDistanceFrom(Geom::Point const &pt) const; + Geom::Point getPositionFrom(Geom::Point const &pt) const; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - virtual void set(unsigned int key, const char* value); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const char* value); + + char* label; + GSList *views; // contains an object of type SPGuideline (see display/guideline.cpp for definition) + Geom::Point normal_to_line; + Geom::Point point_on_line; + + guint32 color; + guint32 hicolor; +public: + std::vector<SPGuideAttachment> attached_items; // unused }; +// These functions rightfully belong to SPDesktop. What gives?! void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); void sp_guide_delete_all_guides(SPDesktop *dt); -void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit); -void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit); -void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit); -void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit); void sp_guide_remove(SPGuide *guide); -char *sp_guide_description(SPGuide const *guide, const bool verbose = true); - #endif // SEEN_SP_GUIDE_H /* diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 79604446a..b2af3842e 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -656,14 +656,61 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) } } -// Recursively scale child items around a point -void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) +// Recursively (or not) scale child items around a point +void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse) { if ( hasChildren() ) { for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { if ( SP_IS_ITEM(o) ) { if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { - SP_GROUP(o)->scaleChildItemsRec(sc, p); + /* Using recursion breaks clipping because transforms are applied + in coordinates for draws but nothing in defs is changed + instead change the transform on the entire group, and the transform + is applied after any references to clipping paths. However NOT using + recursion apparently breaks as of r13544 other parts of Inkscape + involved with showing/modifying units. So offer both for use + in different contexts. + */ + if(noRecurse) { + // used for EMF import + SPItem *item = SP_ITEM(o); + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + Geom::Affine tAff = item->i2dt_affine() * final; + item->set_i2d_affine(tAff); + tAff = item->transform; + // Eliminate common rounding error affecting EMF/WMF input. + // When the rounding error persists it converts the simple + // transform=scale() to transform=matrix(). + if(std::abs(tAff[4]) < 1.0e-5 && std::abs(tAff[5]) < 1.0e-5){ + tAff[4] = 0.0; + tAff[5] = 0.0; + } + item->doWriteTransform(item->getRepr(), tAff, NULL, true); + } else { + // used for other import + SPItem *item = NULL; + if (SP_ITEM(o)->clip_ref->getObject()) { + item = SP_ITEM(SP_ITEM(o)->clip_ref->getObject()->firstChild()); + } + if (item != NULL) { + Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() + Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); + item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } + item = NULL; + if (SP_ITEM(o)->mask_ref->getObject()) { + item = SP_ITEM(SP_ITEM(o)->mask_ref->getObject()->firstChild()); + } + if (item != NULL) { + Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt() + Geom::Affine ti2doc = SP_ITEM(o)->i2doc_affine(); + item->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } + SP_GROUP(o)->scaleChildItemsRec(sc, p, false); + } } else { SPItem *item = SP_ITEM(o); Geom::OptRect bbox = item->desktopVisualBounds(); @@ -690,7 +737,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) if (SP_IS_PERSP3D(item)) { persp3d_apply_affine_transformation(SP_PERSP3D(item), final); - } else if ((SP_IS_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { + } else if (SP_IS_TEXT_TEXTPATH(item) && !item->transform.isIdentity()) { // Save and reset current transform Geom::Affine tmp(item->transform); item->transform = Geom::Affine(); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 97423630d..15bb58f22 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -61,7 +61,7 @@ public: LayerMode layerDisplayMode(unsigned int display_key) const; void setLayerDisplayMode(unsigned int display_key, LayerMode mode); void translateChildItems(Geom::Translate const &tr); - void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p); + void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse); int getItemCount() const; virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 90fd676ee..dcc91fd0b 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -22,7 +22,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin { return_if_fail(SP_IS_ITEM(&item)); return_if_fail( unsigned(snappoint_ix) < 8 ); - Geom::Point const dir( mv_g.normal_to_line ); + Geom::Point const dir( mv_g.getNormal() ); double const dir_lensq(dot(dir, dir)); return_if_fail( dir_lensq != 0 ); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 4785dc588..b1a22fd8c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -44,6 +44,7 @@ #include "sp-rect.h" #include "sp-use.h" #include "sp-text.h" +#include "sp-textpath.h" #include "sp-item-rm-unsatisfied-cns.h" #include "sp-pattern.h" #include "sp-paint-server.h" @@ -1447,10 +1448,11 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra // onSetTransform cannot be pure due to the fact that not all visible Items are transformable. if ( // run the object's set_transform (i.e. embed transform) only if: - !preserve && // user did not chose to preserve all transforms + SP_IS_TEXT_TEXTPATH(this) || + (!preserve && // user did not chose to preserve all transforms (!clip_ref || !clip_ref->getObject()) && // the object does not have a clippath (!mask_ref || !mask_ref->getObject()) && // the object does not have a mask - !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) + !(!transform.isTranslation() && style && style->getFilter())) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = this->set_transform(transform); diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 8ca6e6490..a2a935951 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -36,14 +36,14 @@ #include "message-stack.h" #include "inkscape.h" #include "desktop.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-ellipse.h" #include "display/curve.h" #include "svg/svg.h" #include <2geom/pathvector.h> #include "sp-clippath.h" #include "sp-mask.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/node-tool.h" #include "ui/tools/tool-base.h" @@ -56,7 +56,6 @@ static void lpeobject_ref_modified(SPObject *href, guint flags, SPLPEItem *lpeit static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem); static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem); -static void sp_lpe_item_apply_to_clip_or_mask_group(SPGroup * group, SPItem * item); typedef std::list<std::string> HRefList; static std::string patheffectlist_write_svg(PathEffectList const & list); @@ -344,6 +343,16 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) { g_return_if_fail(lpeitem != NULL); + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) + { + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = lpeitem->clip_ref->getObject(); + if(clipPath) + { + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + } if (SP_IS_GROUP(lpeitem)) { GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { @@ -367,6 +376,18 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) g_return_if_fail(lpeitem != NULL); if (SP_IS_GROUP(lpeitem)) { + if (!lpeitem->hasPathEffectRecursive()) { + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = lpeitem->clip_ref->getObject(); + if(clipPath) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + } + } GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast<SPObject *>(iter->data); @@ -378,6 +399,16 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) else if (SP_IS_PATH(lpeitem)) { Inkscape::XML::Node *repr = lpeitem->getRepr(); if (!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) { + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = lpeitem->clip_ref->getObject(); + if(clipPath) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + } repr->setAttribute("d", repr->attribute("inkscape:original-d")); repr->setAttribute("inkscape:original-d", NULL); } @@ -613,12 +644,8 @@ bool SPLPEItem::hasPathEffectRecursive() const return hasPathEffect(); } } - -//The next 3 functions are because the revert of the bug 1241902 -//for the moment not used - void -sp_lpe_item_apply_to_clippath(SPItem * item) +SPLPEItem::apply_to_clippath(SPItem *item) { SPClipPath *clipPath = item->clip_ref->getObject(); if(clipPath) { @@ -630,11 +657,18 @@ sp_lpe_item_apply_to_clippath(SPItem * item) } else if(SP_IS_SHAPE(clip_data)) { clip_curve = SP_SHAPE(clip_data)->getCurve(); } else if(SP_IS_GROUP(clip_data)) { - sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(clip_data), item); + apply_to_clip_or_mask_group(SP_ITEM(clip_data), item); return; } if(clip_curve) { - bool success = SP_LPE_ITEM(item)->performPathEffect(clip_curve); + bool success = false; + if(SP_IS_GROUP(this)){ + clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); + success = this->performPathEffect(clip_curve); + clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); + } else { + success = this->performPathEffect(clip_curve); + } Inkscape::XML::Node *reprClip = clip_data->getRepr(); if (success) { gchar *str = sp_svg_write_path(clip_curve->get_pathvector()); @@ -654,10 +688,17 @@ sp_lpe_item_apply_to_clippath(SPItem * item) clip_curve->unref(); } } + if(SP_IS_GROUP(item)){ + GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( GSList const *iter = item_list; iter; iter = iter->next ) { + SPObject *subitem = static_cast<SPObject *>(iter->data); + apply_to_clippath(SP_ITEM(subitem)); + } + } } void -sp_lpe_item_apply_to_mask(SPItem * item) +SPLPEItem::apply_to_mask(SPItem *item) { SPMask *mask = item->mask_ref->getObject(); if(mask) { @@ -669,11 +710,18 @@ sp_lpe_item_apply_to_mask(SPItem * item) } else if(SP_IS_SHAPE(mask_data)) { mask_curve = SP_SHAPE(mask_data)->getCurve(); } else if(SP_IS_GROUP(mask_data)) { - sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(mask_data), item); + apply_to_clip_or_mask_group(SP_ITEM(mask_data), item); return; } if(mask_curve) { - bool success = SP_LPE_ITEM(item)->performPathEffect(mask_curve); + bool success = false; + if(SP_IS_GROUP(this)){ + mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); + success = this->performPathEffect(mask_curve); + mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); + } else { + success = this->performPathEffect(mask_curve); + } Inkscape::XML::Node *reprmask = mask_data->getRepr(); if (success) { gchar *str = sp_svg_write_path(mask_curve->get_pathvector()); @@ -693,16 +741,26 @@ sp_lpe_item_apply_to_mask(SPItem * item) mask_curve->unref(); } } + if(SP_IS_GROUP(item)){ + GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( GSList const *iter = item_list; iter; iter = iter->next ) { + SPObject *subitem = static_cast<SPObject *>(iter->data); + apply_to_mask(SP_ITEM(subitem)); + } + } } -static void -sp_lpe_item_apply_to_clip_or_mask_group(SPGroup *group, SPItem *item) +void +SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) { - GSList *item_list = sp_item_group_item_list(group); + if (!SP_IS_GROUP(group)) { + return; + } + GSList *item_list = sp_item_group_item_list(SP_GROUP(group)); for ( GSList *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast<SPObject *>(iter->data); if (SP_IS_GROUP(subitem)) { - sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(subitem), item); + apply_to_clip_or_mask_group(SP_ITEM(subitem), item); } else if (SP_IS_SHAPE(subitem)) { SPCurve * c = NULL; @@ -712,7 +770,14 @@ sp_lpe_item_apply_to_clip_or_mask_group(SPGroup *group, SPItem *item) c = SP_SHAPE(subitem)->getCurve(); } if (c) { - bool success = SP_LPE_ITEM(item)->performPathEffect(c); + bool success = false; + if(SP_IS_GROUP(group)){ + c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); + success = this->performPathEffect(c); + c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); + } else { + success = this->performPathEffect(c); + } Inkscape::XML::Node *repr = subitem->getRepr(); if (success) { gchar *str = sp_svg_write_path(c->get_pathvector()); diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index fbac467fd..9c052b7b1 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -90,14 +90,14 @@ public: void removeAllPathEffects(bool keep_paths); void addPathEffect(char *value, bool reset); void addPathEffect(LivePathEffectObject * new_lpeobj); - + void apply_to_mask(SPItem * item); + void apply_to_clippath(SPItem * item); + void apply_to_clip_or_mask_group(SPItem * group, SPItem * item); bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); void editNextParamOncanvas(SPDesktop *dt); }; -void sp_lpe_item_apply_to_mask(SPItem * item); -void sp_lpe_item_apply_to_clippath(SPItem * item); void sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write); // careful, class already has method with *very* similar name! #endif /* !SP_LPE_ITEM_H_SEEN */ diff --git a/src/marker.cpp b/src/sp-marker.cpp index a4cbc30ca..e955594ab 100644 --- a/src/marker.cpp +++ b/src/sp-marker.cpp @@ -24,7 +24,7 @@ #include "display/drawing-group.h" #include "xml/repr.h" #include "attributes.h" -#include "marker.h" +#include "sp-marker.h" #include "document.h" #include "document-private.h" #include "preferences.h" diff --git a/src/marker.h b/src/sp-marker.h index b58523251..b58523251 100644 --- a/src/marker.h +++ b/src/sp-marker.h diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 1d9fa06a3..8b28347f1 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -956,14 +956,10 @@ static void sp_namedview_setup_guides(SPNamedView *nv) static void sp_namedview_show_single_guide(SPGuide* guide, bool show) { - for (GSList *v = guide->views; v != NULL; v = v->next) { - if (show) { - sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); - sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); - } else { - sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); - sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); - } + if (show) { + guide->showSPGuide(); + } else { + guide->hideSPGuide(); } } @@ -1156,9 +1152,9 @@ Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedvie void SPNamedView::translateGuides(Geom::Translate const &tr) { for (GSList *l = guides; l != NULL; l = l->next) { SPGuide &guide = *SP_GUIDE(l->data); - Geom::Point point_on_line = guide.point_on_line; + Geom::Point point_on_line = guide.getPoint(); point_on_line *= tr; - sp_guide_moveto(guide, point_on_line, true); + guide.moveto(point_on_line, true); } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index d76bd9780..2259088ba 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -35,7 +35,7 @@ #include "print.h" #include "document.h" #include "style.h" -#include "marker.h" +#include "sp-marker.h" #include "sp-path.h" #include "preferences.h" #include "attributes.h" diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 3bb1e16d0..93d81e47b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -30,7 +30,6 @@ #include <2geom/affine.h> #include <libnrtype/FontFactory.h> #include <libnrtype/font-instance.h> -#include <libnrtype/font-style-to-pos.h> #include <glibmm/i18n.h> #include "svg/svg.h" @@ -357,21 +356,10 @@ const char* SPText::displayName() const { } gchar* SPText::description() const { - SPStyle *style = this->style; - - font_instance *tf = font_factory::Default()->FaceFromStyle(style); - char *n; + SPStyle *style = this->style; - if (tf) { - char name_buf[256]; - tf->Family(name_buf, sizeof(name_buf)); - n = xml_quote_strdup(name_buf); - tf->Unref(); - } else { - /* TRANSLATORS: For description of font with no name. */ - n = g_strdup(_("<no name found>")); - } + char *n = xml_quote_strdup( style->font_family.value ); Inkscape::Util::Quantity q = Inkscape::Util::Quantity(style->font_size.computed, "px"); GString *xs = g_string_new(q.string(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units).c_str()); @@ -384,9 +372,8 @@ gchar* SPText::description() const { } char *ret = ( SP_IS_TEXT_TEXTPATH(this) - ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs->str) - : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs->str) ); - g_free(n); + ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs->str) + : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs->str) ); return ret; } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 8bb2a7150..1a75a6f29 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -25,7 +25,7 @@ #include "sp-path.h" #include "sp-shape.h" #include "sp-image.h" -#include "marker.h" +#include "sp-marker.h" #include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 56908f58e..98a5a224c 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -3,7 +3,12 @@ set(ui_SRC clipboard.cpp control-manager.cpp dialog-events.cpp + draw-anchor.cpp + interface.cpp + object-edit.cpp previewholder.cpp + shape-editor.cpp + tools-switch.cpp uxmanager.cpp cache/svg_preview_cache.cpp @@ -91,7 +96,6 @@ set(ui_SRC dialog/print.cpp dialog/symbols.cpp dialog/xml-tree.cpp - # dialog/session-player.cpp dialog/spellcheck.cpp dialog/svg-fonts-dialog.cpp dialog/swatches.cpp @@ -103,9 +107,6 @@ set(ui_SRC dialog/pixelartdialog.cpp dialog/transformation.cpp dialog/undo-history.cpp - # dialog/whiteboard-connect.cpp - # dialog/whiteboard-sharewithchat.cpp - # dialog/whiteboard-sharewithuser.cpp widget/anchor-selector.cpp widget/button.cpp @@ -158,10 +159,16 @@ set(ui_SRC control-manager.h control-types.h dialog-events.h + draw-anchor.h icon-names.h + interface.h + object-edit.h previewable.h previewfillable.h previewholder.h + shape-editor.h + tool-factory.h + tools-switch.h uxmanager.h cache/svg_preview_cache.h diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index 94064d0cf..7aeb4a83d 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -8,10 +8,21 @@ ink_common_sources += \ ui/control-types.h \ ui/dialog-events.cpp \ ui/dialog-events.h \ + ui/draw-anchor.cpp \ + ui/draw-anchor.h \ ui/icon-names.h \ + ui/interface.cpp \ + ui/interface.h \ + ui/object-edit.cpp \ + ui/object-edit.h \ ui/previewable.h \ ui/previewfillable.h \ ui/previewholder.cpp \ ui/previewholder.h \ + ui/shape-editor.cpp \ + ui/shape-editor.h \ + ui/tool-factory.h \ + ui/tools-switch.cpp \ + ui/tools-switch.h \ ui/uxmanager.cpp \ ui/uxmanager.h diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 1209b19cd..40500cf15 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -76,7 +76,7 @@ #include "svg/css-ostringstream.h" // used in copy #include "ui/tools/text-tool.h" #include "text-editing.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "path-chemistry.h" #include "util/units.h" #include "helper/png-write.h" diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index dbb7c1244..c538968d6 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -38,7 +38,7 @@ #include "sp-item-transform.h" #include "sp-text.h" #include "text-editing.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/icon-names.h" #include "ui/tools/node-tool.h" #include "ui/tool/multi-path-manipulator.h" diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index dd6be2604..8d3d2b57c 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -38,7 +38,7 @@ #include "util/units.h" #include "helper/window.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "macros.h" #include "message-stack.h" #include "preferences.h" diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index 28f9243c8..8cb205a35 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -12,6 +12,7 @@ typedef struct _GtkWidget GtkWidget; class SPDesktop; +struct InkscapeApplication; namespace Inkscape { diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 5c0437133..7b1b36908 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -72,13 +72,13 @@ inline Dialog *create() { return PanelDialog<B>::template create<T>(); } /** * This class is provided as a container for Inkscape's various - * dialogs. This allows Inkscape::Application to treat the various + * dialogs. This allows InkscapeApplication to treat the various * dialogs it invokes, as abstractions. * * DialogManager is essentially a cache of dialogs. It lets us * initialize dialogs lazily - instead of constructing them during * application startup, they're constructed the first time they're - * actually invoked by Inkscape::Application. The constructed + * actually invoked by InkscapeApplication. The constructed * dialog is held here after that, so future invokations of the * dialog don't need to get re-constructed each time. The memory for * the dialogs are then reclaimed when the DialogManager is destroyed. diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 13e828337..6dabcfb6b 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -28,7 +28,7 @@ #include "desktop-handles.h" #include "shortcuts.h" #include "preferences.h" -#include "interface.h" +#include "ui/interface.h" #include "verbs.h" #include "ui/tool/event-utils.h" diff --git a/src/ui/dialog/dialog.h b/src/ui/dialog/dialog.h index 90501550b..9c7efd47b 100644 --- a/src/ui/dialog/dialog.h +++ b/src/ui/dialog/dialog.h @@ -18,6 +18,7 @@ #include "floating-behavior.h" class SPDesktop; +struct InkscapeApplication; namespace Inkscape { class Selection; diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index f65b298c9..50a6db208 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -18,7 +18,7 @@ #include "dock-behavior.h" #include "inkscape.h" #include "desktop.h" -#include "interface.h" +#include "ui/interface.h" #include "widgets/icon.h" #include "ui/widget/dock.h" #include "verbs.h" diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index c7fcbbfc4..93e5eb51b 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -31,13 +31,13 @@ #include "inkscape.h" #include "io/sys.h" #include "preferences.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-namedview.h" #include "sp-root.h" #include "sp-script.h" #include "style.h" #include "svg/stringstream.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" @@ -1747,7 +1747,8 @@ void DocumentProperties::onDocUnitChange() doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(-viewscale*doc->getRoot()->viewBox.min()[Geom::X] + (doc->getWidth().value("px") - viewscale*doc->getRoot()->viewBox.width())/2, viewscale*doc->getRoot()->viewBox.min()[Geom::Y] + - (doc->getHeight().value("px") + viewscale*doc->getRoot()->viewBox.height())/2)); + (doc->getHeight().value("px") + viewscale*doc->getRoot()->viewBox.height())/2), + false); ShapeEditor::blockSetItem(false); } prefs->setBool("/options/transform/stroke", transform_stroke); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 188135e2b..6d5d894ef 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -65,7 +65,7 @@ #include "ui/dialog-events.h" #include "preferences.h" #include "verbs.h" -#include "interface.h" +#include "ui/interface.h" #include "sp-root.h" #include "extension/output.h" diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index cd5491c24..9bdddc0e0 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -25,7 +25,7 @@ #include "verbs.h" #include "preferences.h" -#include "interface.h" +#include "ui/interface.h" #include "extension/extension.h" #include "extension/db.h" diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 310630f3e..17cf835cd 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -21,9 +21,11 @@ #include <config.h> #endif +#include <iostream> + #include "filedialogimpl-gtkmm.h" #include "ui/dialog-events.h" -#include "interface.h" +#include "ui/interface.h" #include "io/sys.h" #include "path-prefix.h" #include "preferences.h" @@ -40,6 +42,8 @@ #include <glibmm/i18n.h> #include <glibmm/miscutils.h> +#include <glibmm/regex.h> + #include "document.h" #include "extension/input.h" #include "extension/output.h" @@ -191,6 +195,40 @@ void SVGPreview::showImage(Glib::ustring &theFileName) { Glib::ustring fileName = theFileName; + // Let's get real width and height from SVG file. These are template + // files so we assume they are well formed. + + // std::cout << "SVGPreview::showImage: " << theFileName << std::endl; + std::ifstream input(theFileName.c_str()); + + std::string width; + std::string height; + + if( !input ) { + std::cerr << "SVGPreview::showImage: Failed to open file: " << theFileName << std::endl; + } else { + + std::string token; + + Glib::MatchInfo match_info; + Glib::RefPtr<Glib::Regex> regex1 = Glib::Regex::create("width=\"(.*)\""); + Glib::RefPtr<Glib::Regex> regex2 = Glib::Regex::create("height=\"(.*)\""); + + while( !input.eof() && (height.empty() || width.empty()) ) { + + input >> token; + // std::cout << "|" << token << "|" << std::endl; + + if (regex1->match(token, match_info)) { + width = match_info.fetch(1).raw(); + } + + if (regex2->match(token, match_info)) { + height = match_info.fetch(1).raw(); + } + + } + } /*##################################### # LET'S HAVE SOME FUN WITH SVG! @@ -270,7 +308,7 @@ void SVGPreview::showImage(Glib::ustring &theFileName) " style=\"font-size:24.000000;font-style:normal;font-weight:normal;" " fill:#000000;fill-opacity:1.0000000;stroke:none;" " font-family:Sans\"\n" - " x=\"10\" y=\"26\">%d x %d</text>\n" //# VALUES HERE + " x=\"10\" y=\"26\">%s x %s</text>\n" //# VALUES HERE "</svg>\n\n"; // if (!Glib::get_charset()) //If we are not utf8 @@ -280,7 +318,7 @@ void SVGPreview::showImage(Glib::ustring &theFileName) /* FIXME: Do proper XML quoting for fileName. */ gchar *xmlBuffer = g_strdup_printf(xformat, previewWidth, previewHeight, imgX, imgY, scaledImgWidth, scaledImgHeight, - fileName.c_str(), rectX, rectY, rectWidth, rectHeight, imgWidth, imgHeight); + fileName.c_str(), rectX, rectY, rectWidth, rectHeight, width.c_str(), height.c_str() ); // g_message("%s\n", xmlBuffer); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index c2367c2a2..bd44846a3 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -546,7 +546,7 @@ public: _matrix(SP_ATTR_VALUES, _("This matrix determines a linear transform on color space. Each line affects one of the color components. Each column determines how much of each color component from the input is passed to the output. The last column does not depend on input colors, so can be used to adjust a constant component value.")), _saturation("", 0, 0, 1, 0.1, 0.01, 2, SP_ATTR_VALUES), _angle("", 0, 0, 360, 0.1, 0.01, 1, SP_ATTR_VALUES), - _label(_("None"), Gtk::ALIGN_START), + _label(C_("Label", "None"), Gtk::ALIGN_START), _use_stored(false), _saturation_store(0), _angle_store(0) diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 9b814bb9f..1a4823e4a 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -33,7 +33,7 @@ #include "ui/dialog-events.h" #include "verbs.h" -#include "interface.h" +#include "ui/interface.h" #include "preferences.h" #include "sp-text.h" #include "sp-flowtext.h" diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index f286588b2..11db14801 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -29,7 +29,7 @@ #include "inkscape.h" #include "desktop.h" #include "ui/dialog-events.h" -#include "interface.h" +#include "ui/interface.h" #include "preferences.h" #include "verbs.h" diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 76c26a3cb..4519a905f 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -100,7 +100,7 @@ void GuidelinePropertiesDialog::_onOK() double rad_angle = Geom::deg_to_rad( deg_angle ); normal = Geom::rot90(Geom::Point::polar(rad_angle, 1.0)); } - sp_guide_set_normal(*_guide, normal, true); + _guide->set_normal(normal, true); double const points_x = _spin_button_x.getValue("px"); double const points_y = _spin_button_y.getValue("px"); @@ -108,11 +108,11 @@ void GuidelinePropertiesDialog::_onOK() if (!_mode) newpos += _oldpos; - sp_guide_moveto(*_guide, newpos, true); + _guide->moveto(newpos, true); const gchar* name = g_strdup( _label_entry.getEntry()->get_text().c_str() ); - sp_guide_set_label(*_guide, name, true); + _guide->set_label(name, true); g_free((gpointer) name); #if WITH_GTKMM_3_0 @@ -124,7 +124,7 @@ void GuidelinePropertiesDialog::_onOK() #endif //TODO: why 257? verify this! - sp_guide_set_color(*_guide, r, g, b, true); + _guide->set_color(r, g, b, true); DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); @@ -295,16 +295,17 @@ void GuidelinePropertiesDialog::_setup() { signal_response().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_response)); // initialize dialog - _oldpos = _guide->point_on_line; + _oldpos = _guide->getPoint(); if (_guide->isVertical()) { _oldangle = 90; } else if (_guide->isHorizontal()) { _oldangle = 0; } else { - _oldangle = Geom::rad_to_deg( std::atan2( - _guide->normal_to_line[Geom::X], _guide->normal_to_line[Geom::Y] ) ); + _oldangle = Geom::rad_to_deg( std::atan2( - _guide->getNormal()[Geom::X], _guide->getNormal()[Geom::Y] ) ); } { + // FIXME holy crap!!! Inkscape::XML::Node *repr = _guide->getRepr(); const gchar *guide_id = repr->attribute("id"); gchar *label = g_strdup_printf(_("Guideline ID: %s"), guide_id); @@ -312,7 +313,7 @@ void GuidelinePropertiesDialog::_setup() { g_free(label); } { - gchar *guide_description = sp_guide_description(_guide, false); + gchar *guide_description = _guide->description(false); gchar *label = g_strdup_printf(_("Current: %s"), guide_description); g_free(guide_description); _label_descr.set_markup(label); @@ -320,15 +321,15 @@ void GuidelinePropertiesDialog::_setup() { } // init name entry - _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + _label_entry.getEntry()->set_text(_guide->getLabel() ? _guide->getLabel() : ""); #if WITH_GTKMM_3_0 Gdk::RGBA c; - c.set_rgba(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + c.set_rgba(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); _color.set_rgba(c); #else Gdk::Color c; - c.set_rgb_p(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + c.set_rgb_p(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); _color.set_color(c); #endif diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2b1198ba0..e113b325f 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -19,6 +19,7 @@ #include "inkscape-preferences.h" #include <glibmm/i18n.h> +#include <glibmm/markup.h> #include <glibmm/miscutils.h> #include <gtkmm/main.h> #include <gtkmm/frame.h> @@ -330,7 +331,7 @@ void InkscapePreferences::initPageTools() _page_selector.add_line( true, "", _t_sel_trans_outl, "", _("Show only a box outline of the objects when moving or transforming")); _page_selector.add_group_header( _("Per-object selection cue")); - _t_sel_cue_none.init ( _("None"), "/options/selcue/value", Inkscape::SelCue::NONE, false, 0); + _t_sel_cue_none.init ( C_("Selection cue", "None"), "/options/selcue/value", Inkscape::SelCue::NONE, false, 0); _page_selector.add_line( true, "", _t_sel_cue_none, "", _("No per-object selection indication")); _t_sel_cue_mark.init ( _("Mark"), "/options/selcue/value", Inkscape::SelCue::MARK, true, &_t_sel_cue_none); @@ -525,11 +526,11 @@ void InkscapePreferences::initPageUI() _("Mongolian (mn)"), _("Nepali (ne)"), _("Norwegian Bokmål (nb)"), _("Norwegian Nynorsk (nn)"), _("Panjabi (pa)"), _("Polish (pl)"), _("Portuguese (pt)"), _("Portuguese/Brazil (pt_BR)"), _("Romanian (ro)"), _("Russian (ru)"), _("Serbian (sr)"), _("Serbian in Latin script (sr@latin)"), _("Slovak (sk)"), _("Slovenian (sl)"), _("Spanish (es)"), _("Spanish/Mexico (es_MX)"), - _("Swedish (sv)"),_("Telugu (te_IN)"), _("Thai (th)"), _("Turkish (tr)"), _("Ukrainian (uk)"), _("Vietnamese (vi)")}; + _("Swedish (sv)"),_("Telugu (te)"), _("Thai (th)"), _("Turkish (tr)"), _("Ukrainian (uk)"), _("Vietnamese (vi)")}; Glib::ustring langValues[] = {"", "sq", "am", "ar", "hy", "az", "eu", "be", "bg", "bn", "bn_BD", "br", "ca", "ca@valencia", "zh_CN", "zh_TW", "hr", "cs", "da", "nl", "dz", "de", "el", "en", "en_AU", "en_CA", "en_GB", "en_US@piglatin", "eo", "et", "fa", "fi", "fr", "ga", "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "lv", "mk", "mn", "ne", "nb", "nn", "pa", - "pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te_IN", "th", "tr", "uk", "vi" }; + "pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te", "th", "tr", "uk", "vi" }; { // sorting languages according to translated name @@ -641,7 +642,7 @@ void InkscapePreferences::initPageUI() _win_save_viewport.init ( _("Save and restore documents viewport"), "/options/savedocviewport/value", true); _win_zoom_resize.init ( _("Zoom when window is resized"), "/options/stickyzoom/value", false); _win_show_close.init ( _("Show close button on dialogs"), "/dialogs/showclose", false); - _win_ontop_none.init ( _("None"), "/options/transientpolicy/value", 0, false, 0); + _win_ontop_none.init ( C_("Dialog on top", "None"), "/options/transientpolicy/value", 0, false, 0); _win_ontop_normal.init ( _("Normal"), "/options/transientpolicy/value", 1, true, &_win_ontop_none); _win_ontop_agressive.init ( _("Aggressive"), "/options/transientpolicy/value", 2, false, &_win_ontop_none); @@ -1259,7 +1260,7 @@ void InkscapePreferences::initPageBehavior() _page_steps.add_line( false, "", _steps_compass, "", _("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise")); int const num_items = 17; - Glib::ustring labels[num_items] = {"90", "60", "45", "36", "30", "22.5", "18", "15", "12", "10", "7.5", "6", "3", "2", "1", "0.5", _("None")}; + Glib::ustring labels[num_items] = {"90", "60", "45", "36", "30", "22.5", "18", "15", "12", "10", "7.5", "6", "3", "2", "1", "0.5", C_("Rotation angle", "None")}; int values[num_items] = {2, 3, 4, 5, 6, 8, 10, 12, 15, 18, 24, 30, 60, 90, 180, 360, 0}; _steps_rot_snap.set_size_request(_sb_width); _steps_rot_snap.init("/options/rotationsnapsperpi/value", labels, values, num_items, 12); @@ -1835,7 +1836,7 @@ void InkscapePreferences::initPageSpellcheck() AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist); - languages.push_back(Glib::ustring(_("None"))); + languages.push_back(Glib::ustring(C_("Spellchecker language", "None"))); langValues.push_back(Glib::ustring("")); const AspellDictInfo *entry; @@ -2054,7 +2055,8 @@ void InkscapePreferences::on_pagelist_selection_changed() if (!_init) { prefs->setInt("/dialogs/preferences/page", row[_page_list_columns._col_id]); } - _page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>"); + Glib::ustring col_name_escaped = Glib::Markup::escape_text( row[_page_list_columns._col_name] ); + _page_title.set_markup("<span size='large'><b>" + col_name_escaped + "</b></span>"); _page_frame.add(*_current_page); _current_page->show(); while (Gtk::Main::events_pending()) diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 4be6716a5..8343cd6fe 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -1622,7 +1622,7 @@ void InputDialogImpl::ConfPanel::setAxis(gint count) if (barNum < count) { row[axisColumns.value] = Glib::ustring::format(barNum+1); } else { - row[axisColumns.value] = _("None"); + row[axisColumns.value] = C_("Input device axe", "None"); } } diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 07a27c96e..93d5dfbd5 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -43,7 +43,7 @@ #include "sp-root.h" #include "sp-shape.h" #include "style.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "ui/widget/layertypeicon.h" diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 607087f6d..c4dd9df98 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -25,7 +25,7 @@ #include "path-prefix.h" #include "filedialogimpl-gtkmm.h" -#include "interface.h" +#include "ui/interface.h" #include "gc-core.h" #include "ui/dialog-events.h" #include "io/sys.h" diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 2d25f54d7..5113f172a 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -385,8 +385,8 @@ void PixelArtDialogImpl::vectorize() if ( input.pixbuf->get_width() > 256 || input.pixbuf->get_height() > 256 ) { - char *msg = _("Image looks too big. Process may take a while and is" - " wise to save your document before continue." + char *msg = _("Image looks too big. Process may take a while and it is" + " wise to save your document before continuing." "\n\nContinue the procedure (without saving)?"); Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK_CANCEL, true); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index a887a7355..9faa8a2cb 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -23,9 +23,9 @@ #include "selection.h" #include "desktop.h" #include "desktop-handles.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/text-tool.h" -#include "interface.h" +#include "ui/interface.h" #include "preferences.h" #include "sp-text.h" #include "sp-flowtext.h" diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ff94aad5d..fca1f7b30 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -24,7 +24,7 @@ #include "extension/db.h" #include "extension/effect.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "file.h" #include "path-prefix.h" #include "preferences.h" diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index e44809c65..0f4a6f7f1 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -32,7 +32,6 @@ extern "C" { #include <gtkmm/stock.h> #include <libnrtype/font-instance.h> -#include <libnrtype/font-style-to-pos.h> #include <libnrtype/font-lister.h> #include <xml/repr.h> @@ -52,7 +51,7 @@ extern "C" { #include "ui/icon-names.h" #include "preferences.h" #include "verbs.h" -#include "interface.h" +#include "ui/interface.h" #include "svg/css-ostringstream.h" #include "widgets/icon.h" #include "widgets/font-selector.h" diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 9a8c188b2..7ab6c78ba 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -30,7 +30,7 @@ #include "ui/tools/tool-base.h" #include "helper/window.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "macros.h" #include "message-context.h" #include "message-stack.h" diff --git a/src/draw-anchor.cpp b/src/ui/draw-anchor.cpp index 6b02bb607..84c919018 100644 --- a/src/draw-anchor.cpp +++ b/src/ui/draw-anchor.cpp @@ -13,7 +13,7 @@ */ -#include "draw-anchor.h" +#include "ui/draw-anchor.h" #include "desktop.h" #include "desktop-handles.h" #include "ui/tools/tool-base.h" diff --git a/src/draw-anchor.h b/src/ui/draw-anchor.h index 1f7b55920..1f7b55920 100644 --- a/src/draw-anchor.h +++ b/src/ui/draw-anchor.h diff --git a/src/interface.cpp b/src/ui/interface.cpp index 0099e8a83..7abbb5934 100644 --- a/src/interface.cpp +++ b/src/ui/interface.cpp @@ -39,7 +39,7 @@ #include "shortcuts.h" #include "document.h" #include "desktop-handles.h" -#include "interface.h" +#include "ui/interface.h" #include "desktop.h" #include "selection.h" #include "selection-chemistry.h" diff --git a/src/interface.h b/src/ui/interface.h index 6fb74046f..6fb74046f 100644 --- a/src/interface.h +++ b/src/ui/interface.h diff --git a/src/object-edit.cpp b/src/ui/object-edit.cpp index 14a5bd3d5..cc96727f8 100644 --- a/src/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -33,7 +33,7 @@ #include "sp-pattern.h" #include "sp-path.h" #include <glibmm/i18n.h> -#include "object-edit.h" +#include "ui/object-edit.h" #include "xml/repr.h" #include <2geom/math-utils.h> #include "knot-holder-entity.h" @@ -55,6 +55,7 @@ static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop) } // namespace namespace Inkscape { +namespace UI { KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) { @@ -88,7 +89,8 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) return knotholder; } -} // Inkscape +} +} // namespace Inkscape /* SPRect */ diff --git a/src/object-edit.h b/src/ui/object-edit.h index ba59e46cd..75f3ce12b 100644 --- a/src/object-edit.h +++ b/src/ui/object-edit.h @@ -14,12 +14,13 @@ #include "knotholder.h" -namespace Inkscape -{ +namespace Inkscape { +namespace UI { KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); } +} class RectKnotHolder : public KnotHolder { public: diff --git a/src/shape-editor.cpp b/src/ui/shape-editor.cpp index 7915fe533..0b9fc24c5 100644 --- a/src/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -18,13 +18,16 @@ #include "document.h" #include "gc-anchored.h" #include "knotholder.h" -#include "object-edit.h" +#include "ui/object-edit.h" #include "sp-item.h" #include "sp-object.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "xml/node-event-vector.h" -using Inkscape::createKnotHolder; +//using Inkscape::createKnotHolder; + +namespace Inkscape { +namespace UI { bool ShapeEditor::_blockSetItem = false; @@ -159,6 +162,9 @@ bool ShapeEditor::knot_mouseover() const { return false; } +} // namespace UI +} // namespace Inkscape + /* Local Variables: mode:c++ diff --git a/src/shape-editor.h b/src/ui/shape-editor.h index d2611b111..142a2493b 100644 --- a/src/shape-editor.h +++ b/src/ui/shape-editor.h @@ -12,13 +12,14 @@ * */ -namespace Inkscape { namespace XML { class Node; } } - class KnotHolder; class LivePathEffectObject; class SPDesktop; class SPItem; +namespace Inkscape { namespace XML { class Node; } +namespace UI { + class ShapeEditor { public: @@ -51,6 +52,9 @@ private: Inkscape::XML::Node *knotholder_listener_attached_for; }; +} // namespace UI +} // namespace Inkscape + #endif // SEEN_SHAPE_EDITOR_H diff --git a/src/tool-factory.h b/src/ui/tool-factory.h index 726706732..726706732 100644 --- a/src/tool-factory.h +++ b/src/ui/tool-factory.h diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index c52bd4c07..4abc901d2 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -27,10 +27,11 @@ #include "ui/tool/event-utils.h" #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" +#include "ui/tools/node-tool.h" +#include "ui/tools-switch.h" #include <gdk/gdkkeysyms.h> #include <cmath> - namespace { Inkscape::ControlType nodeTypeToCtrlType(Inkscape::UI::NodeType type) @@ -329,6 +330,10 @@ bool Handle::grabbed(GdkEventMotion *) void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) { + if (tools_isactive(_desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context); + nt->update_helperpath(); + } Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; @@ -1222,6 +1227,10 @@ bool Node::grabbed(GdkEventMotion *event) void Node::dragged(Geom::Point &new_pos, GdkEventMotion *event) { + if (tools_isactive(_desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(_desktop->event_context); + nt->update_helperpath(); + } // For a note on how snapping is implemented in Inkscape, see snap.h. SnapManager &sm = _desktop->namedview->snap_manager; // even if we won't really snap, we might still call the one of the diff --git a/src/tools-switch.cpp b/src/ui/tools-switch.cpp index a3e117dfa..79d6b8930 100644 --- a/src/tools-switch.cpp +++ b/src/ui/tools-switch.cpp @@ -10,10 +10,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include <gtkmm.h> // prevents deprecation warnings #include <cstring> #include <string> @@ -25,40 +22,42 @@ #include <xml/repr.h> -#include "ui/tools/select-tool.h" -#include "ui/tools/node-tool.h" -#include "ui/tools/tweak-tool.h" -#include "ui/tools/spray-tool.h" -#include "sp-path.h" -#include "ui/tools/rect-tool.h" -#include "sp-rect.h" -#include "ui/tools/box3d-tool.h" +#include "ui/tools-switch.h" + #include "box3d.h" -#include "ui/tools/arc-tool.h" #include "sp-ellipse.h" -#include "ui/tools/tweak-tool.h" +#include "sp-flowtext.h" +#include "sp-offset.h" +#include "sp-path.h" +#include "sp-rect.h" #include "sp-star.h" -#include "ui/tools/spiral-tool.h" #include "sp-spiral.h" +#include "sp-text.h" + +// TODO: How many of these are actually needed? +#include "ui/tools/arc-tool.h" +#include "ui/tools/box3d-tool.h" #include "ui/tools/calligraphic-tool.h" +#include "ui/tools/connector-tool.h" +#include "ui/tools/dropper-tool.h" #include "ui/tools/eraser-tool.h" +#include "ui/tools/flood-tool.h" +#include "ui/tools/gradient-tool.h" +#include "ui/tools/lpe-tool.h" +#include "ui/tools/measure-tool.h" +#include "ui/tools/mesh-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tools/pen-tool.h" #include "ui/tools/pencil-tool.h" -#include "ui/tools/lpe-tool.h" +#include "ui/tools/rect-tool.h" +#include "ui/tools/select-tool.h" +#include "ui/tools/spiral-tool.h" +#include "ui/tools/spray-tool.h" #include "ui/tools/text-tool.h" -#include "sp-text.h" -#include "sp-flowtext.h" -#include "ui/tools/gradient-tool.h" -#include "ui/tools/mesh-tool.h" +#include "ui/tools/tweak-tool.h" #include "ui/tools/zoom-tool.h" -#include "ui/tools/measure-tool.h" -#include "ui/tools/dropper-tool.h" -#include "ui/tools/connector-tool.h" -#include "ui/tools/flood-tool.h" -#include "sp-offset.h" -#include "message-context.h" -#include "tools-switch.h" +#include "message-context.h" static char const *const tool_names[] = { NULL, @@ -86,6 +85,8 @@ static char const *const tool_names[] = { "/tools/lpetool", NULL }; + +// TODO: HEY! these belong to the tools themselves! static char const *const tool_msg[] = { NULL, N_("<b>Click</b> to Select and Transform objects, <b>Drag</b> to select many objects."), diff --git a/src/tools-switch.h b/src/ui/tools-switch.h index 280837e87..280837e87 100644 --- a/src/tools-switch.h +++ b/src/ui/tools-switch.h diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 9fd68f1b9..4f64ade25 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -40,7 +40,7 @@ #include "desktop-style.h" #include "context-fns.h" #include "verbs.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "ui/tools/tool-base.h" #include "ui/tools/arc-tool.h" @@ -48,7 +48,7 @@ using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index b998267c2..0a20a0842 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -47,12 +47,12 @@ #include "box3d-side.h" #include "document-private.h" #include "line-geometry.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "verbs.h" using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 64097e834..d297fe5e1 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -82,7 +82,7 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 19759b733..776bc9c89 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -109,7 +109,7 @@ using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 99d42a211..6c55f7484 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -52,7 +52,7 @@ using Inkscape::DocumentUndo; static GdkCursor *cursor_dropper_fill = NULL; static GdkCursor *cursor_dropper_stroke = NULL; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 4106785e7..bf4015b4c 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -84,7 +84,7 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 3fb56b2ad..5745fc9cc 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -50,7 +50,7 @@ #include "preferences.h" #include "rubberband.h" #include "selection.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-defs.h" #include "sp-item.h" #include "splivarot.h" @@ -74,7 +74,7 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 46ab53eef..6434c30d2 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -30,7 +30,7 @@ #include "desktop-handles.h" #include "desktop-style.h" #include "document.h" -#include "draw-anchor.h" +#include "ui/draw-anchor.h" #include "macros.h" #include "message-stack.h" #include "ui/tools/pen-tool.h" diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 4f9a7b59b..9c853917e 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -51,7 +51,7 @@ using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index e9b9421f1..1fd1ebf8c 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -28,7 +28,7 @@ #include "desktop.h" #include "message-context.h" #include "preferences.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "selection.h" #include "desktop-handles.h" #include "document.h" @@ -59,7 +59,7 @@ SubtoolEntry lpesubtools[] = { }; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index feeb68288..6b5cbeccd 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -49,7 +49,7 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; using Inkscape::Util::unit_table; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 7d6d3bc23..8a1fb7c72 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -53,7 +53,7 @@ using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 0b98bacc1..e2bb85d11 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -23,7 +23,7 @@ #include "live_effects/lpeobject.h" #include "message-context.h" #include "selection.h" -#include "shape-editor.h" // temporary! +#include "ui/shape-editor.h" // temporary! #include "live_effects/effect.h" #include "display/curve.h" #include "sp-clippath.h" @@ -107,7 +107,7 @@ using Inkscape::ControlManager; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 2c5ffc182..92937a135 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -26,7 +26,7 @@ #include "desktop-handles.h" #include "selection.h" #include "selection-chemistry.h" -#include "draw-anchor.h" +#include "ui/draw-anchor.h" #include "message-stack.h" #include "message-context.h" #include "preferences.h" @@ -40,7 +40,7 @@ #include <glibmm/i18n.h> #include "macros.h" #include "context-fns.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/control-manager.h" // we include the necessary files for BSpline & Spiro #include "live_effects/effect.h" @@ -70,7 +70,7 @@ #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> -#include "tool-factory.h" +#include "ui/tool-factory.h" #include "live_effects/effect.h" diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index ca6dffc12..3ea2ae843 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -23,7 +23,7 @@ #include "desktop-handles.h" #include "selection.h" #include "selection-chemistry.h" -#include "draw-anchor.h" +#include "ui/draw-anchor.h" #include "message-stack.h" #include "message-context.h" #include "sp-path.h" @@ -43,7 +43,7 @@ #include "display/sp-canvas.h" #include "display/curve.h" #include "livarot/Path.h" -#include "tool-factory.h" +#include "ui/tool-factory.h" #include "ui/tool/event-utils.h" namespace Inkscape { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 819671dd6..de91dcff4 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -40,13 +40,13 @@ #include "xml/node-event-vector.h" #include "preferences.h" #include "context-fns.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "verbs.h" #include "display/sp-canvas-item.h" using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 83bef17c9..394b0b369 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -41,7 +41,7 @@ #include "desktop-handles.h" #include "sp-root.h" #include "preferences.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "message-stack.h" #include "selection-describer.h" #include "seltrans.h" @@ -49,7 +49,7 @@ #include "display/sp-canvas.h" #include "display/sp-canvas-item.h" #include "display/drawing-item.h" -#include "tool-factory.h" +#include "ui/tool-factory.h" using Inkscape::DocumentUndo; diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 83712457a..18c3e4e2d 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -39,13 +39,13 @@ #include "xml/node-event-vector.h" #include "preferences.h" #include "context-fns.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "verbs.h" #include "display/sp-canvas-item.h" using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 29f1b9a73..933da6fb1 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -84,7 +84,7 @@ using namespace std; // Please enable again when working on 1.0 #define ENABLE_SPRAY_MODE_SINGLE_PATH -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index ed28c0a8d..7604ba04e 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -41,7 +41,7 @@ #include "xml/repr.h" #include "xml/node-event-vector.h" #include "context-fns.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "verbs.h" #include "display/sp-canvas-item.h" @@ -49,7 +49,7 @@ using Inkscape::DocumentUndo; -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index b60a39e5d..a72748733 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -40,7 +40,7 @@ #include "rubberband.h" #include "selection-chemistry.h" #include "selection.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-flowtext.h" #include "sp-namedview.h" #include "sp-text.h" @@ -52,7 +52,7 @@ #include "xml/node-event-vector.h" #include "xml/repr.h" #include <gtk/gtk.h> -#include "tool-factory.h" +#include "ui/tool-factory.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index c28b86416..37ca5eeea 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -44,9 +44,9 @@ #include "desktop-style.h" #include "sp-namedview.h" #include "selection.h" -#include "interface.h" +#include "ui/interface.h" #include "macros.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "preferences.h" #include "message-context.h" #include "gradient-drag.h" @@ -55,7 +55,7 @@ #include "selcue.h" #include "ui/tools/lpe-tool.h" #include "ui/tool/control-point.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "sp-guide.h" #include "color.h" #include "knot.h" diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index b27de9030..7a6ab83e7 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -30,7 +30,6 @@ namespace Glib { class GrDrag; class SPDesktop; class SPItem; -class ShapeEditor; namespace Inkscape { class MessageContext; @@ -42,6 +41,9 @@ namespace Inkscape { namespace Inkscape { namespace UI { + +class ShapeEditor; + namespace Tools { class ToolBase; diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 75650d3af..340f64a0b 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -91,7 +91,7 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 9f99cfe2e..b3fb78c8f 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -25,7 +25,7 @@ #include "selection-chemistry.h" #include "ui/tools/zoom-tool.h" -#include "tool-factory.h" +#include "ui/tool-factory.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp index 2afdc02a6..bc6bdcf22 100644 --- a/src/ui/widget/highlight-picker.cpp +++ b/src/ui/widget/highlight-picker.cpp @@ -11,14 +11,14 @@ # include "config.h" #endif +#include <gtkmm/icontheme.h> + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include <glibmm/threads.h> #endif #include "display/cairo-utils.h" -#include <gtkmm/icontheme.h> - #include "highlight-picker.h" #include "widgets/icon.h" #include "widgets/toolbox.h" diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp index 2f06225bc..97aa30aa6 100644 --- a/src/ui/widget/insertordericon.cpp +++ b/src/ui/widget/insertordericon.cpp @@ -7,6 +7,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "ui/widget/insertordericon.h" + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -15,8 +17,6 @@ #include <glibmm/threads.h> #endif -#include "ui/widget/insertordericon.h" - #include <gtkmm/icontheme.h> #include "widgets/icon.h" diff --git a/src/ui/widget/insertordericon.h b/src/ui/widget/insertordericon.h index 4b4b51de2..e6c2e1c5b 100644 --- a/src/ui/widget/insertordericon.h +++ b/src/ui/widget/insertordericon.h @@ -13,9 +13,9 @@ #include "config.h" #endif -#include <glibmm/property.h> #include <gtkmm/cellrendererpixbuf.h> #include <gtkmm/widget.h> +#include <glibmm/property.h> namespace Inkscape { namespace UI { diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 26d83fdc3..5a723a2fd 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -30,6 +30,7 @@ #include "ui/widget/spinbutton.h" class SPDesktop; +struct InkscapeApplication; namespace Inkscape { diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index b9466e07a..5680cac30 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -45,6 +45,8 @@ namespace Gtk { class MenuItem; } +struct InkscapeApplication; + namespace Inkscape { class Selection; diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a0a163286..d3adb6307 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -180,7 +180,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _na[i].show_all(); __na[i] = (_("Nothing selected")); - _none[i].set_markup (C_("Fill and stroke", "<i>None</i>")); + if (i == SS_FILL) { + _none[i].set_markup (C_("Fill", "<i>None</i>")); + } else { + _none[i].set_markup (C_("Stroke", "<i>None</i>")); + } sp_set_font_size_smaller (GTK_WIDGET(_none[i].gobj())); _none[i].show_all(); __none[i] = (i == SS_FILL)? (C_("Fill and stroke", "No fill")) : (C_("Fill and stroke", "No stroke")); diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 67eb1f48d..c6318db25 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -13,7 +13,7 @@ */ #include "unit-tracker.h" -#include "ege-select-one-action.h" +#include "widgets/ege-select-one-action.h" #define COLUMN_STRING 0 diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 41f8dfe7d..f09e0d956 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -22,7 +22,7 @@ #include "ui/tools/tool-base.h" #include "xml/repr.h" #include "perspective-line.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "snap.h" #include "sp-namedview.h" #include "ui/control-manager.h" diff --git a/src/verbs.cpp b/src/verbs.cpp index be5f0f4f1..577407412 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -53,7 +53,7 @@ #include "helper/action-context.h" #include "help.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "layer-fns.h" #include "layer-manager.h" #include "message-stack.h" @@ -62,7 +62,7 @@ #include "ui/tools/select-tool.h" #include "selection-chemistry.h" #include "seltrans.h" -#include "shape-editor.h" +#include "ui/shape-editor.h" #include "shortcuts.h" #include "sp-defs.h" #include "sp-flowtext.h" @@ -70,7 +70,7 @@ #include "splivarot.h" #include "sp-namedview.h" #include "text-chemistry.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/dialog/align-and-distribute.h" #include "ui/dialog/clonetiler.h" #include "ui/dialog/dialog-manager.h" @@ -1435,7 +1435,7 @@ void LayerVerb::perform(SPAction *action, void *data) dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer.")); } else { dt->toggleLayerSolo( dt->currentLayer() ); - DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); + DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_SOLO, _("Toggle layer solo")); } break; } @@ -1459,7 +1459,7 @@ void LayerVerb::perform(SPAction *action, void *data) dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer.")); } else { dt->toggleLockOtherLayers( dt->currentLayer() ); - DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers")); + DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers")); } break; } @@ -2429,7 +2429,7 @@ void LockAndHideVerb::perform(SPAction *action, void *data) Verb *Verb::_base_verbs[] = { // Header new Verb(SP_VERB_INVALID, NULL, NULL, NULL, NULL, NULL), - new Verb(SP_VERB_NONE, "None", N_("None"), N_("Does nothing"), NULL, NULL), + new Verb(SP_VERB_NONE, "None", NC_("Verb", "None"), N_("Does nothing"), NULL, NULL), // File new FileVerb(SP_VERB_FILE_NEW, "FileNew", N_("Default"), N_("Create new document from the default template"), diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index fe4433153..072b905a2 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -24,6 +24,9 @@ set(widgets_SRC desktop-widget.cpp eek-preview.cpp ege-paint-def.cpp + ege-adjustment-action.cpp + ege-output-action.cpp + ege-select-one-action.cpp fill-style.cpp font-selector.cpp gradient-image.cpp @@ -31,6 +34,8 @@ set(widgets_SRC gradient-toolbar.cpp gradient-vector.cpp icon.cpp + ink-action.cpp + ink-comboboxentry-action.cpp paint-selector.cpp ruler.cpp select-toolbar.cpp @@ -80,6 +85,9 @@ set(widgets_SRC desktop-widget.h eek-preview.h ege-paint-def.h + ege-adjustment-action.h + ege-output-action.h + ege-select-one-action.h fill-n-stroke-factory.h fill-style.h font-selector.h @@ -88,6 +96,8 @@ set(widgets_SRC gradient-toolbar.h gradient-vector.h icon.h + ink-action.h + ink-comboboxentry-action.h paint-selector.h ruler.h select-toolbar.h diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert index 97713cbee..dc4c12967 100644 --- a/src/widgets/Makefile_insert +++ b/src/widgets/Makefile_insert @@ -19,8 +19,14 @@ ink_common_sources += \ widgets/dropper-toolbar.h \ widgets/eek-preview.cpp \ widgets/eek-preview.h \ + widgets/ege-adjustment-action.cpp \ + widgets/ege-adjustment-action.h \ widgets/ege-paint-def.cpp \ widgets/ege-paint-def.h \ + widgets/ege-output-action.cpp \ + widgets/ege-output-action.h \ + widgets/ege-select-one-action.cpp \ + widgets/ege-select-one-action.h \ widgets/eraser-toolbar.cpp \ widgets/eraser-toolbar.h \ widgets/fill-style.cpp \ @@ -38,6 +44,10 @@ ink_common_sources += \ widgets/gradient-vector.h \ widgets/icon.cpp \ widgets/icon.h \ + widgets/ink-action.cpp \ + widgets/ink-action.h \ + widgets/ink-comboboxentry-action.cpp \ + widgets/ink-comboboxentry-action.h \ widgets/lpe-toolbar.cpp \ widgets/lpe-toolbar.h \ widgets/measure-toolbar.cpp \ diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 1005de70d..ca582924b 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -34,10 +34,10 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ege-select-one-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ege-select-one-action.h" +#include "widgets/ink-action.h" #include "mod360.h" #include "preferences.h" #include "selection.h" diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index 052eb230b..f6e303d58 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -36,8 +36,8 @@ #include "desktop.h" #include "document-undo.h" #include "document.h" -#include "ege-adjustment-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ink-action.h" #include "inkscape.h" #include "persp3d.h" #include "selection.h" diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index cda97654e..1776e28c4 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -16,7 +16,7 @@ #include "button.h" #include "helper/action-context.h" -#include "interface.h" +#include "ui/interface.h" #include "shortcuts.h" #include "helper/action.h" diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp index 9c0393cd9..4ae6427ad 100644 --- a/src/widgets/calligraphy-toolbar.cpp +++ b/src/widgets/calligraphy-toolbar.cpp @@ -34,9 +34,9 @@ #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" -#include "ink-action.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/icon-names.h" diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 9bbc1bbb4..6ce926dc1 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -35,10 +35,10 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" +#include "widgets/ege-adjustment-action.h" #include "enums.h" #include "graphlayout.h" -#include "ink-action.h" +#include "widgets/ink-action.h" #include "inkscape.h" #include "preferences.h" #include "selection.h" diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 9b7ac2f42..ef3b29478 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -38,7 +38,7 @@ #include "display/canvas-arena.h" #include "document.h" #include "ege-color-prof-tracker.h" -#include "ege-select-one-action.h" +#include "widgets/ege-select-one-action.h" #include <extension/db.h> #include "file.h" #include "helper/action.h" @@ -46,7 +46,7 @@ #include "util/units.h" #include "ui/widget/unit-tracker.h" #include "inkscape.h" -#include "interface.h" +#include "ui/interface.h" #include "macros.h" #include "preferences.h" #include "sp-image.h" diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp index 478d0c1a4..45ed9ead4 100644 --- a/src/widgets/dropper-toolbar.cpp +++ b/src/widgets/dropper-toolbar.cpp @@ -32,8 +32,8 @@ #include "dropper-toolbar.h" #include "document-undo.h" -#include "ege-output-action.h" -#include "ink-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ink-action.h" #include "preferences.h" #include "widgets/spinbutton-events.h" diff --git a/src/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp index 9491468dc..d89a6e3f1 100644 --- a/src/ege-adjustment-action.cpp +++ b/src/widgets/ege-adjustment-action.cpp @@ -46,7 +46,7 @@ #include <gdk/gdkkeysyms.h> #include "icon-size.h" -#include "ege-adjustment-action.h" +#include "widgets/ege-adjustment-action.h" #include "ui/widget/gimpspinscale.h" #include "ui/icon-names.h" diff --git a/src/ege-adjustment-action.h b/src/widgets/ege-adjustment-action.h index 8cfaa3e52..8cfaa3e52 100644 --- a/src/ege-adjustment-action.h +++ b/src/widgets/ege-adjustment-action.h diff --git a/src/ege-output-action.cpp b/src/widgets/ege-output-action.cpp index 9a7d7e318..5dece8e91 100644 --- a/src/ege-output-action.cpp +++ b/src/widgets/ege-output-action.cpp @@ -43,7 +43,7 @@ #include <gtk/gtk.h> -#include "ege-output-action.h" +#include "widgets/ege-output-action.h" static void ege_output_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); diff --git a/src/ege-output-action.h b/src/widgets/ege-output-action.h index 0f4e21805..0f4e21805 100644 --- a/src/ege-output-action.h +++ b/src/widgets/ege-output-action.h diff --git a/src/ege-select-one-action.cpp b/src/widgets/ege-select-one-action.cpp index 3facf7242..ab86c49f8 100644 --- a/src/ege-select-one-action.cpp +++ b/src/widgets/ege-select-one-action.cpp @@ -43,7 +43,7 @@ #include <gtk/gtk.h> -#include "ege-select-one-action.h" +#include "widgets/ege-select-one-action.h" enum { CHANGED = 0, diff --git a/src/ege-select-one-action.h b/src/widgets/ege-select-one-action.h index 0c5cecaa3..0c5cecaa3 100644 --- a/src/ege-select-one-action.h +++ b/src/widgets/ege-select-one-action.h diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index 14e7cbf4e..f547cbd8b 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -35,9 +35,9 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" -#include "ink-action.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/icon-names.h" diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index f5a99f3e7..b6378b251 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -22,12 +22,12 @@ #include "desktop.h" #include "document-undo.h" #include "document.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-select-one-action.h" #include "gradient-chemistry.h" #include "gradient-drag.h" #include "gradient-toolbar.h" -#include "ink-action.h" +#include "widgets/ink-action.h" #include "macros.h" #include "preferences.h" #include "selection.h" @@ -1109,7 +1109,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GtkTreeIter iter; gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, 0, _("None"), 1, SP_GRADIENT_SPREAD_PAD, -1 ); + gtk_list_store_set( model, &iter, 0, C_("Gradient repeat type", "None"), 1, SP_GRADIENT_SPREAD_PAD, -1 ); gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Reflected"), 1, SP_GRADIENT_SPREAD_REFLECT, -1 ); diff --git a/src/ink-action.cpp b/src/widgets/ink-action.cpp index dd1fe5484..5941c31e4 100644 --- a/src/ink-action.cpp +++ b/src/widgets/ink-action.cpp @@ -3,7 +3,7 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> -#include "ink-action.h" +#include "widgets/ink-action.h" #include "widgets/button.h" diff --git a/src/ink-action.h b/src/widgets/ink-action.h index ac5cb9873..ac5cb9873 100644 --- a/src/ink-action.h +++ b/src/widgets/ink-action.h diff --git a/src/ink-comboboxentry-action.cpp b/src/widgets/ink-comboboxentry-action.cpp index 6ae2a8485..5c59f6961 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/widgets/ink-comboboxentry-action.cpp @@ -30,7 +30,7 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> -#include "ink-comboboxentry-action.h" +#include "widgets/ink-comboboxentry-action.h" #include "ui/icon-names.h" // Must handle both tool and menu items! diff --git a/src/ink-comboboxentry-action.h b/src/widgets/ink-comboboxentry-action.h index 04b66e8fe..04b66e8fe 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/widgets/ink-comboboxentry-action.h diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 7ad88b856..a85f3ae78 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -33,15 +33,15 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-select-one-action.h" +#include "widgets/ege-select-one-action.h" #include "helper/action-context.h" #include "helper/action.h" -#include "ink-action.h" +#include "widgets/ink-action.h" #include "live_effects/effect.h" #include "preferences.h" #include "selection.h" #include "sp-namedview.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/lpe-tool.h" #include "ui/widget/unit-tracker.h" #include "util/units.h" diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp index 46d3bd4e0..1a4678332 100644 --- a/src/widgets/measure-toolbar.cpp +++ b/src/widgets/measure-toolbar.cpp @@ -34,8 +34,8 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" #include "preferences.h" #include "toolbox.h" #include "ui/widget/unit-tracker.h" diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 73e450926..897d84278 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -50,11 +50,11 @@ #include "selection.h" #include "ui/icon-names.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ege-select-one-action.h" -#include "ink-action.h" -#include "ink-comboboxentry-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ege-select-one-action.h" +#include "widgets/ink-action.h" +#include "widgets/ink-comboboxentry-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index ace78f8f5..467325d08 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -34,8 +34,8 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ink-action.h" #include "inkscape.h" #include "preferences.h" #include "selection-chemistry.h" @@ -270,7 +270,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D } // quit if run by the attr_changed listener - if (g_object_get_data( tbl, "freeze" )) { + if (g_object_get_data( tbl, "freeze" ) || tracker->isUpdating()) { return; } diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp index 8ddaccf64..d8edeb9f6 100644 --- a/src/widgets/paintbucket-toolbar.cpp +++ b/src/widgets/paintbucket-toolbar.cpp @@ -33,8 +33,8 @@ #include "paintbucket-toolbar.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-select-one-action.h" #include "preferences.h" #include "toolbox.h" #include "ui/icon-names.h" diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index cf09a4d34..1214a378a 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -33,12 +33,12 @@ #include "pencil-toolbar.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" -#include "ink-action.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 "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/icon-names.h" #include "ui/tools/pen-tool.h" #include "ui/uxmanager.h" @@ -157,7 +157,7 @@ static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) static GList * freehand_shape_dropdown_items_list() { GList *glist = NULL; - glist = g_list_append (glist, _("None")); + glist = g_list_append (glist, const_cast<gchar *>(C_("Freehand shape", "None"))); glist = g_list_append (glist, _("Triangle in")); glist = g_list_append (glist, _("Triangle out")); glist = g_list_append (glist, _("Ellipse")); diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 48808fe70..e1ce01eaf 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -34,9 +34,9 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ink-action.h" #include "inkscape.h" #include "preferences.h" #include "selection.h" @@ -97,7 +97,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * } // quit if run by the attr_changed listener - if (g_object_get_data( tbl, "freeze" )) { + if (g_object_get_data( tbl, "freeze" ) || tracker->isUpdating()) { return; } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 18976b329..5f107c5a8 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -26,10 +26,10 @@ #include "display/sp-canvas.h" #include "document-undo.h" #include "document.h" -#include "ege-adjustment-action.h" +#include "widgets/ege-adjustment-action.h" #include "helper/action-context.h" #include "helper/action.h" -#include "ink-action.h" +#include "widgets/ink-action.h" #include "inkscape.h" #include "message-stack.h" #include "preferences.h" diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 87cb7cae3..c7fa96efd 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -38,7 +38,7 @@ #include "../profile-manager.h" #include "color-profile.h" #include "cms-system.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/tools/tool-base.h" using Inkscape::CMSSystem; diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index 9a1a93a45..a53062cf4 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -24,12 +24,10 @@ #define SP_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_WIDGET)) #define SP_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_WIDGET)) - namespace Inkscape { class Selection; class SPWidgetImpl; - } struct SPWidget { diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 710be9440..e85b024ed 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -34,9 +34,9 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ink-action.h" #include "preferences.h" #include "selection.h" #include "sp-spiral.h" diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp index 788ce6475..183814b7e 100644 --- a/src/widgets/spray-toolbar.cpp +++ b/src/widgets/spray-toolbar.cpp @@ -33,9 +33,9 @@ #include "spray-toolbar.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" -#include "ink-action.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/icon-names.h" diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 0f8c31be8..6213263fc 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -34,10 +34,10 @@ #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ege-select-one-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ege-select-one-action.h" +#include "widgets/ink-action.h" #include "selection.h" #include "sp-star.h" #include "toolbox.h" diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 9572f6426..24288299f 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -31,7 +31,7 @@ #include "preferences.h" #include "path-prefix.h" #include "io/sys.h" -#include "marker.h" +#include "sp-marker.h" #include "sp-defs.h" #include "sp-root.h" #include "ui/cache/svg_preview_cache.h" @@ -385,7 +385,7 @@ void MarkerComboBox::add_markers (GSList *marker_list, SPDocument *source, gbool if (history) { // add "None" Gtk::TreeModel::Row row = *(marker_store->prepend()); - row[marker_columns.label] = _("None"); + row[marker_columns.label] = C_("Marker", "None"); row[marker_columns.stock] = false; row[marker_columns.marker] = g_strdup("None"); row[marker_columns.image] = NULL; diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 464e7d2d1..15e394097 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -44,7 +44,7 @@ #include "helper/stock-items.h" #include "inkscape.h" #include "io/sys.h" -#include "marker.h" +#include "sp-marker.h" #include "preferences.h" #include "path-prefix.h" #include "selection.h" diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 88f698bc4..d62bb8027 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -36,10 +36,10 @@ #include "desktop.h" #include "document-undo.h" #include "document.h" -#include "ege-adjustment-action.h" -#include "ege-select-one-action.h" -#include "ink-action.h" -#include "ink-comboboxentry-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-select-one-action.h" +#include "widgets/ink-action.h" +#include "widgets/ink-comboboxentry-action.h" #include "inkscape.h" #include "preferences.h" #include "selection-chemistry.h" diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 939546f78..9e55d1cf6 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -43,20 +43,20 @@ #include "../desktop-handles.h" #include "../desktop-style.h" #include "document-undo.h" -#include "../ege-adjustment-action.h" -#include "../ege-output-action.h" -#include "../ege-select-one-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ege-select-one-action.h" #include "../graphlayout.h" #include "../helper/action.h" #include "../helper/action-context.h" #include "icon.h" -#include "../ink-action.h" -#include "../ink-comboboxentry-action.h" +#include "ink-action.h" +#include "ink-comboboxentry-action.h" #include "../inkscape.h" -#include "../interface.h" +#include "ui/interface.h" #include "../shortcuts.h" #include "../sp-namedview.h" -#include "../tools-switch.h" +#include "ui/tools-switch.h" #include "../ui/icon-names.h" #include "../ui/widget/style-swatch.h" #include "../verbs.h" diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp index 050d7fb5e..a5d90fc3d 100644 --- a/src/widgets/tweak-toolbar.cpp +++ b/src/widgets/tweak-toolbar.cpp @@ -33,10 +33,10 @@ #include "tweak-toolbar.h" #include "desktop.h" #include "document-undo.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ege-select-one-action.h" -#include "ink-action.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" +#include "widgets/ege-select-one-action.h" +#include "widgets/ink-action.h" #include "preferences.h" #include "toolbox.h" #include "ui/icon-names.h" |
