summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-04-10 09:24:37 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-04-10 09:24:37 +0000
commit850b66384422dd18e3d2be7bd75ae05498aa86e2 (patch)
tree8c64eab17ee23d0c459cd16416a8f678e86dd350
parentfixing error moving selected nodes (diff)
parentpatch by Damjan Velickovski for rotation snap degrees, Bug 525508 (diff)
downloadinkscape-850b66384422dd18e3d2be7bd75ae05498aa86e2.tar.gz
inkscape-850b66384422dd18e3d2be7bd75ae05498aa86e2.zip
Fixing problem whith changing node sselected - not solved
(bzr r11950.1.87)
-rw-r--r--share/extensions/dxf_outlines.inx9
-rwxr-xr-xshare/extensions/dxf_outlines.py30
-rw-r--r--src/display/drawing-image.cpp7
-rw-r--r--src/extension/implementation/script.cpp81
-rw-r--r--src/live_effects/lpe-bspline.cpp4
-rw-r--r--src/select-context.cpp4
-rw-r--r--src/style.cpp98
-rw-r--r--src/style.h36
-rw-r--r--src/ui/dialog/text-edit.cpp50
-rw-r--r--src/ui/dialog/text-edit.h10
-rw-r--r--src/xml/repr.h8
11 files changed, 262 insertions, 75 deletions
diff --git a/share/extensions/dxf_outlines.inx b/share/extensions/dxf_outlines.inx
index ccc660181..ad3aef17f 100644
--- a/share/extensions/dxf_outlines.inx
+++ b/share/extensions/dxf_outlines.inx
@@ -25,7 +25,12 @@
<_item value="cp1252">CP 1252</_item>
<_item value="utf_8">UTF 8</_item>
</param>
- <param name="visibleLayers" type="boolean" _gui-text="keep only visible layers">true</param>
+ <param name="layer_option" type="enum" _gui-text="Layer export selection">
+ <_item value="all">All (default)</_item>
+ <_item value="visible">Visible only</_item>
+ <_item value="name">By name match</_item>
+ </param>
+ <param name="layer_name" type="string" _gui-text="Layer match name"></param>
</page>
<page name="help" _gui-text="Help">
<_param name="inputhelp" type="description" xml:space="preserve">- AutoCAD Release 14 DXF format.
@@ -36,7 +41,7 @@
- clones (the crossreference to the original is lost)
- ROBO-Master spline output is a specialized spline readable only by ROBO-Master and AutoDesk viewers, not Inkscape.
- LWPOLYLINE output is a multiply-connected polyline, disable it to use a legacy version of the LINE output.
-- You can choose to export all layers or only visible ones</_param>
+- You can choose to export all layers, only visible ones or by name match (case insensitive and use comma ',' as separator)</_param>
</page>
</param>
<output>
diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py
index 57f4e4198..c5217f886 100755
--- a/share/extensions/dxf_outlines.py
+++ b/share/extensions/dxf_outlines.py
@@ -84,12 +84,17 @@ class MyEffect(inkex.Effect):
type="string", dest="tab")
self.OptionParser.add_option("--inputhelp", action="store",
type="string", dest="inputhelp")
- self.OptionParser.add_option("--visibleLayers", action="store",
- type="string", dest="visibleLayers")
+ self.OptionParser.add_option("--layer_option", action="store",
+ type="string", dest="layer_option",
+ default="all")
+ self.OptionParser.add_option("--layer_name", action="store",
+ type="string", dest="layer_name")
+
self.dxf = []
self.handle = 255 # handle for DXF ENTITY
self.layers = ['0']
self.layer = '0' # mandatory layer
+ self.layernames = []
self.csp_old = [[0.0,0.0]]*4 # previous spline
self.d = array([0], float) # knot vector
self.poly = [[0.0,0.0]] # LWPOLYLINE data
@@ -267,9 +272,12 @@ class MyEffect(inkex.Effect):
if style:
style = simplestyle.parseStyle(style)
if style.has_key('display'):
- if style['display'] == 'none' and self.options.visibleLayers == 'true':
+ if style['display'] == 'none' and self.options.layer_option and self.options.layer_option=='visible':
return
layer = group.get(inkex.addNS('label', 'inkscape'))
+ if self.options.layer_name and self.options.layer_option and self.options.layer_option=='name' and not layer.lower() in self.options.layer_name:
+ return
+
layer = layer.replace(' ', '_')
if layer in self.layers:
self.layer = layer
@@ -287,6 +295,14 @@ class MyEffect(inkex.Effect):
self.groupmat.pop()
def effect(self):
+ #Warn user if name match field is empty
+ if self.options.layer_option and self.options.layer_option=='name' and not self.options.layer_name:
+ inkex.errormsg(_("Error: Field 'Layer match name' must be filled when using 'By name match' option"))
+ inkex.sys.exit()
+ #Split user layer data into a list: "layerA,layerb,LAYERC" becomes ["layera", "layerb", "layerc"]
+ if self.options.layer_name:
+ self.options.layer_name = self.options.layer_name.lower().split(',')
+
#References: Minimum Requirements for Creating a DXF File of a 3D Model By Paul Bourke
# NURB Curves: A Guide for the Uninitiated By Philip J. Schneider
# The NURBS Book By Les Piegl and Wayne Tiller (Springer, 1995)
@@ -295,6 +311,9 @@ class MyEffect(inkex.Effect):
for node in self.document.getroot().xpath('//svg:g', namespaces=inkex.NSS):
if node.get(inkex.addNS('groupmode', 'inkscape')) == 'layer':
layer = node.get(inkex.addNS('label', 'inkscape'))
+ self.layernames.append(layer.lower())
+ if self.options.layer_name and self.options.layer_option and self.options.layer_option=='name' and not layer.lower() in self.options.layer_name:
+ continue
layer = layer.replace(' ', '_')
if layer and not layer in self.layers:
self.layers.append(layer)
@@ -315,6 +334,11 @@ class MyEffect(inkex.Effect):
if self.options.POLY == 'true':
self.LWPOLY_output()
self.dxf_add(dxf_templates.r14_footer)
+ #Warn user if layer data seems wrong
+ if self.options.layer_name and self.options.layer_option and self.options.layer_option=='name':
+ for layer in self.options.layer_name:
+ if not layer in self.layernames:
+ inkex.errormsg(_("Warning: Layer '%s' not found!") % (layer))
if __name__ == '__main__':
e = MyEffect()
diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp
index 3f1a86ee7..753249e60 100644
--- a/src/display/drawing-image.cpp
+++ b/src/display/drawing-image.cpp
@@ -121,6 +121,13 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar
if (!outline) {
if (!_pixbuf) return RENDER_OK;
+ // if (_style) {
+ // _style->image_rendering.computed
+ // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty
+ // http://www.w3.org/TR/css4-images/#the-image-rendering
+ // style.h/style.cpp
+ // }
+
Inkscape::DrawingContext::Save save(ct);
ct.transform(_ctm);
ct.newPath();
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 3ac1e06ab..69ce982d0 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -669,8 +669,13 @@ void Script::effect(Inkscape::Extension::Effect *module,
printf("TOO BAD TO LIVE!!!");
exit(1);
}
+ if (doc == NULL)
+ {
+ g_warning("Script::effect: View not defined");
+ return;
+ }
- SPDesktop *desktop = (SPDesktop *)doc;
+ SPDesktop *desktop = reinterpret_cast<SPDesktop *>(doc);
sp_namedview_document_from_window(desktop);
std::list<std::string> params;
@@ -696,16 +701,14 @@ void Script::effect(Inkscape::Extension::Effect *module,
return;
}
- if (desktop != NULL) {
- Inkscape::Util::GSListConstIterator<SPItem *> selected =
- sp_desktop_selection(desktop)->itemList();
- while ( selected != NULL ) {
- Glib::ustring selected_id;
- selected_id += "--id=";
- selected_id += (*selected)->getId();
- params.insert(params.begin(), selected_id);
- ++selected;
- }
+ Inkscape::Util::GSListConstIterator<SPItem *> selected =
+ sp_desktop_selection(desktop)->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer
+ while ( selected != NULL ) {
+ Glib::ustring selected_id;
+ selected_id += "--id=";
+ selected_id += (*selected)->getId();
+ params.insert(params.begin(), selected_id);
+ ++selected;
}
file_listener fileout;
@@ -728,30 +731,37 @@ void Script::effect(Inkscape::Extension::Effect *module,
g_unlink(tempfilename_out.c_str());
- /* Do something with mydoc.... */
if (mydoc) {
- doc->doc()->emitReconstructionStart();
- copy_doc(doc->doc()->rroot, mydoc->rroot);
- doc->doc()->emitReconstructionFinish();
- SPObject *layer = NULL;
-
- // Getting the named view from the document generated by the extension
- SPNamedView *nv = sp_document_namedview(mydoc, NULL);
-
- //Check if it has a default layer set up
- if ( nv != NULL){
- if( nv->default_layer_id != 0 ) {
- SPDocument *document = desktop->doc();
- //If so, get that layer
- layer = document->getObjectById(g_quark_to_string(nv->default_layer_id));
+ SPDocument* vd=doc->doc();
+ if (vd != NULL)
+ {
+ vd->emitReconstructionStart();
+ copy_doc(vd->rroot, mydoc->rroot);
+ vd->emitReconstructionFinish();
+ SPObject *layer = NULL;
+
+ // Getting the named view from the document generated by the extension
+ SPNamedView *nv = sp_document_namedview(mydoc, NULL);
+
+ //Check if it has a default layer set up
+ if ( nv != NULL)
+ {
+ if( nv->default_layer_id != 0 ) {
+ SPDocument *document = desktop->doc();
+ //If so, get that layer
+ if (document != NULL)
+ {
+ layer = document->getObjectById(g_quark_to_string(nv->default_layer_id));
+ }
+ }
+ }
+
+ sp_namedview_update_layers_from_document(desktop);
+ //If that layer exists,
+ if (layer) {
+ //set the current layer
+ desktop->setCurrentLayer(layer);
}
- }
-
- sp_namedview_update_layers_from_document(desktop);
- //If that layer exists,
- if (layer) {
- //set the current layer
- desktop->setCurrentLayer(layer);
}
mydoc->release();
}
@@ -778,6 +788,11 @@ void Script::effect(Inkscape::Extension::Effect *module,
*/
void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot)
{
+ if ((oldroot == NULL) ||(newroot == NULL))
+ {
+ g_warning("Error on copy_doc: NULL pointer input.");
+ return;
+ }
std::vector<Inkscape::XML::Node *> delete_list;
Inkscape::XML::Node * oldroot_namedview = NULL;
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 657b2ded3..e7adab071 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -373,10 +373,12 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue)
InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context);
Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints();
points.clear();
+ std::vector<Geom::Point>::iterator pbegin;
for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){
if ((*i)->selected()) {
Inkscape::UI::Node *n = static_cast<Inkscape::UI::Node*>(*i);
- points.insert(points.begin(),desktop->doc2dt(n->position()));
+ pbegin = points.begin();
+ points.insert(pbegin,desktop->doc2dt(n->position()));
}
}
}
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 2684cbc1e..9a88bcf20 100644
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -988,7 +988,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
} else if (MOD__CTRL) {
sp_selection_rotate(selection, 90);
} else if (snaps) {
- sp_selection_rotate(selection, 180/snaps);
+ sp_selection_rotate(selection, 180.0/snaps);
}
ret = TRUE;
break;
@@ -1000,7 +1000,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
} else if (MOD__CTRL) {
sp_selection_rotate(selection, -90);
} else if (snaps) {
- sp_selection_rotate(selection, -180/snaps);
+ sp_selection_rotate(selection, -180.0/snaps);
}
ret = TRUE;
break;
diff --git a/src/style.cpp b/src/style.cpp
index eef1c6ee5..ca89e6f65 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -313,27 +313,34 @@ static SPStyleEnum const enum_display[] = {
};
static SPStyleEnum const enum_shape_rendering[] = {
- {"auto", 0},
- {"optimizeSpeed", 0},
- {"crispEdges", 0},
- {"geometricPrecision", 0},
+ {"auto", SP_CSS_SHAPE_RENDERING_AUTO},
+ {"optimizeSpeed", SP_CSS_SHAPE_RENDERING_OPTIMIZESPEED},
+ {"crispEdges", SP_CSS_SHAPE_RENDERING_CRISPEDGES},
+ {"geometricPrecision", SP_CSS_SHAPE_RENDERING_GEOMETRICPRECISION},
{NULL, -1}
};
static SPStyleEnum const enum_color_rendering[] = {
- {"auto", 0},
- {"optimizeSpeed", 0},
- {"optimizeQuality", 0},
+ {"auto", SP_CSS_COLOR_RENDERING_AUTO},
+ {"optimizeSpeed", SP_CSS_COLOR_RENDERING_OPTIMIZESPEED},
+ {"optimizeQuality", SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY},
{NULL, -1}
};
-static SPStyleEnum const *const enum_image_rendering = enum_color_rendering;
+static SPStyleEnum const enum_image_rendering[] = {
+ {"auto", SP_CSS_IMAGE_RENDERING_AUTO},
+ {"optimizeSpeed", SP_CSS_IMAGE_RENDERING_OPTIMIZESPEED},
+ {"optimizeQuality", SP_CSS_IMAGE_RENDERING_OPTIMIZEQUALITY},
+ {"-inkscape-crisp-edges", SP_CSS_IMAGE_RENDERING_CRISPEDGES},
+ {"-inkscape-pixelated", SP_CSS_IMAGE_RENDERING_PIXELATED},
+ {NULL, -1}
+};
static SPStyleEnum const enum_text_rendering[] = {
- {"auto", 0},
- {"optimizeSpeed", 0},
- {"optimizeLegibility", 0},
- {"geometricPrecision", 0},
+ {"auto", SP_CSS_TEXT_RENDERING_AUTO},
+ {"optimizeSpeed", SP_CSS_TEXT_RENDERING_OPTIMIZESPEED},
+ {"optimizeLegibility", SP_CSS_TEXT_RENDERING_OPTIMIZELEGIBILITY},
+ {"geometricPrecision", SP_CSS_TEXT_RENDERING_GEOMETRICPRECISION},
{NULL, -1}
};
@@ -795,6 +802,12 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
/* clip-rule */
SPS_READ_PENUM_IF_UNSET(&style->clip_rule, repr, "clip-rule", enum_clip_rule, true);
+ /* color_rendering, image_rendering, shape_rendering, text_rendering */
+ SPS_READ_PENUM_IF_UNSET(&style->color_rendering, repr, "color_rendering", enum_color_rendering, true);
+ SPS_READ_PENUM_IF_UNSET(&style->image_rendering, repr, "image_rendering", enum_image_rendering, true);
+ SPS_READ_PENUM_IF_UNSET(&style->shape_rendering, repr, "shape_rendering", enum_shape_rendering, true);
+ SPS_READ_PENUM_IF_UNSET(&style->text_rendering, repr, "text_rendering", enum_text_rendering, true);
+
/* 3. Merge from parent */
if (object) {
if (object->parent) {
@@ -1115,11 +1128,8 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
case SP_PROP_BASELINE_SHIFT:
SPS_READ_IBASELINE_SHIFT_IF_UNSET(&style->baseline_shift, val);
break;
- /* Text (unimplemented) */
case SP_PROP_TEXT_RENDERING: {
- /* Ignore the hint. */
- SPIEnum dummy;
- SPS_READ_IENUM_IF_UNSET(&dummy, val, enum_text_rendering, true);
+ SPS_READ_IENUM_IF_UNSET(&style->text_rendering, val, enum_text_rendering, true);
break;
}
case SP_PROP_ALIGNMENT_BASELINE:
@@ -1240,9 +1250,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
g_warning("Unimplemented style property SP_PROP_COLOR_PROFILE: value: %s", val);
break;
case SP_PROP_COLOR_RENDERING: {
- /* Ignore the hint. */
- SPIEnum dummy;
- SPS_READ_IENUM_IF_UNSET(&dummy, val, enum_color_rendering, true);
+ SPS_READ_IENUM_IF_UNSET(&style->color_rendering, val, enum_color_rendering, true);
break;
}
case SP_PROP_FILL:
@@ -1261,9 +1269,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
}
break;
case SP_PROP_IMAGE_RENDERING: {
- /* Ignore the hint. */
- SPIEnum dummy;
- SPS_READ_IENUM_IF_UNSET(&dummy, val, enum_image_rendering, true);
+ SPS_READ_IENUM_IF_UNSET(&style->image_rendering, val, enum_image_rendering, true);
break;
}
case SP_PROP_MARKER:
@@ -1306,9 +1312,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
break;
case SP_PROP_SHAPE_RENDERING: {
- /* Ignore the hint. */
- SPIEnum dummy;
- SPS_READ_IENUM_IF_UNSET(&dummy, val, enum_shape_rendering, true);
+ SPS_READ_IENUM_IF_UNSET(&style->shape_rendering, val, enum_shape_rendering, true);
break;
}
@@ -1834,6 +1838,12 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent)
if (!style->clip_rule.set || style->clip_rule.inherit) {
style->clip_rule.computed = parent->clip_rule.computed;
}
+
+ /* Rendering */
+ if (!style->color_rendering.set || style->color_rendering.inherit) {
+ style->color_rendering.computed = parent->color_rendering.computed;
+ }
+
}
template <typename T>
@@ -2126,18 +2136,18 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare
&SPStyle::clip_rule,
&SPStyle::color_interpolation,
&SPStyle::color_interpolation_filters,
- //nyi: SPStyle::color_rendering,
+ &SPStyle::color_rendering,
&SPStyle::direction,
&SPStyle::fill_rule,
&SPStyle::font_style,
&SPStyle::font_variant,
- //nyi: SPStyle::image_rendering,
+ &SPStyle::image_rendering,
//nyi: SPStyle::pointer_events,
- //nyi: SPStyle::shape_rendering,
+ &SPStyle::shape_rendering,
&SPStyle::stroke_linecap,
&SPStyle::stroke_linejoin,
&SPStyle::text_anchor,
- //nyi: &SPStyle::text_rendering,
+ &SPStyle::text_rendering,
&SPStyle::visibility,
&SPStyle::writing_mode
};
@@ -2742,6 +2752,12 @@ sp_style_write_string(SPStyle const *const style, guint const flags)
/* clipping */
p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &style->clip_rule, NULL, flags);
+ /* rendering */
+ p += sp_style_write_ienum(p, c + BMAX - p, "color-rendering", enum_color_rendering, &style->color_rendering, NULL, flags);
+ p += sp_style_write_ienum(p, c + BMAX - p, "image-rendering", enum_image_rendering, &style->image_rendering, NULL, flags);
+ p += sp_style_write_ienum(p, c + BMAX - p, "shape-rendering", enum_shape_rendering, &style->shape_rendering, NULL, flags);
+ p += sp_style_write_ienum(p, c + BMAX - p, "text-rendering", enum_text_rendering, &style->text_rendering, NULL, flags);
+
/* fixme: */
p += sp_text_style_write(p, c + BMAX - p, style->text, flags);
@@ -2892,6 +2908,12 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to)
p += sp_style_write_ienum(p, c + BMAX - p, "clip-rule", enum_clip_rule, &from->clip_rule, &to->clip_rule, SP_STYLE_FLAG_IFDIFF);
+ /* rendering */
+ p += sp_style_write_ienum(p, c + BMAX - p, "color-rendering", enum_color_rendering, &from->color_rendering, &to->color_rendering, SP_STYLE_FLAG_IFDIFF);
+ p += sp_style_write_ienum(p, c + BMAX - p, "image-rendering", enum_image_rendering, &from->image_rendering, &to->image_rendering, SP_STYLE_FLAG_IFDIFF);
+ p += sp_style_write_ienum(p, c + BMAX - p, "shape-rendering", enum_shape_rendering, &from->shape_rendering, &to->shape_rendering, SP_STYLE_FLAG_IFDIFF);
+ p += sp_style_write_ienum(p, c + BMAX - p, "text-rendering", enum_text_rendering, &from->text_rendering, &to->text_rendering, SP_STYLE_FLAG_IFDIFF);
+
/** \todo
* The reason we use IFSET rather than IFDIFF is the belief that the IFDIFF
* flag is mainly only for attributes that don't handle explicit unset well.
@@ -3087,6 +3109,12 @@ sp_style_clear(SPStyle *style)
style->enable_background.inherit = false;
style->clip_rule.value = style->clip_rule.computed = SP_WIND_RULE_NONZERO;
+
+ style->color_rendering.value = style->color_rendering.computed = SP_CSS_COLOR_RENDERING_AUTO;
+ style->image_rendering.value = style->image_rendering.computed = SP_CSS_IMAGE_RENDERING_AUTO;
+ style->shape_rendering.value = style->shape_rendering.computed = SP_CSS_SHAPE_RENDERING_AUTO;
+ style->text_rendering.value = style->text_rendering.computed = SP_CSS_TEXT_RENDERING_AUTO;
+
}
@@ -4492,6 +4520,18 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->clip_rule.set) {
repr->setAttribute("clip-rule", NULL);
}
+ if (style->color_rendering.set) {
+ repr->setAttribute("color-rendering", NULL);
+ }
+ if (style->image_rendering.set) {
+ repr->setAttribute("image-rendering", NULL);
+ }
+ if (style->shape_rendering.set) {
+ repr->setAttribute("shape-rendering", NULL);
+ }
+ if (style->text_rendering.set) {
+ repr->setAttribute("text-rendering", NULL);
+ }
}
/**
diff --git a/src/style.h b/src/style.h
index 0710f5c8e..534a6ae70 100644
--- a/src/style.h
+++ b/src/style.h
@@ -378,6 +378,13 @@ struct SPStyle {
filter when the style is used for querying */
SPILength filter_gaussianBlur_deviation;
+ /** hints on how to render: e.g. speed vs. accuracy.
+ * As of April, 2013, only image_rendering used. */
+ SPIEnum color_rendering;
+ SPIEnum image_rendering;
+ SPIEnum shape_rendering;
+ SPIEnum text_rendering;
+
/** enable-background, used for defining where filter effects get
* their background image */
SPIEnum enable_background;
@@ -579,6 +586,35 @@ enum SPColorInterpolation {
SP_CSS_COLOR_INTERPOLATION_LINEARRGB
};
+enum SPColorRendering {
+ SP_CSS_COLOR_RENDERING_AUTO,
+ SP_CSS_COLOR_RENDERING_OPTIMIZESPEED,
+ SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY
+};
+
+/* Last two are CSS4 Image values... for the momement prefaced with -inkscape. */
+enum SPImageRendering {
+ SP_CSS_IMAGE_RENDERING_AUTO,
+ SP_CSS_IMAGE_RENDERING_OPTIMIZESPEED,
+ SP_CSS_IMAGE_RENDERING_OPTIMIZEQUALITY,
+ SP_CSS_IMAGE_RENDERING_CRISPEDGES,
+ SP_CSS_IMAGE_RENDERING_PIXELATED
+};
+
+enum SPShapeRendering {
+ SP_CSS_SHAPE_RENDERING_AUTO,
+ SP_CSS_SHAPE_RENDERING_OPTIMIZESPEED,
+ SP_CSS_SHAPE_RENDERING_CRISPEDGES,
+ SP_CSS_SHAPE_RENDERING_GEOMETRICPRECISION
+};
+
+enum SPTextRendering {
+ SP_CSS_TEXT_RENDERING_AUTO,
+ SP_CSS_TEXT_RENDERING_OPTIMIZESPEED,
+ SP_CSS_TEXT_RENDERING_OPTIMIZELEGIBILITY,
+ SP_CSS_TEXT_RENDERING_GEOMETRICPRECISION
+};
+
/// An SPTextStyle has a refcount, a font family, and a font name.
struct SPTextStyle {
int refcount;
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index c87e94fc6..9f3294275 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -59,7 +59,7 @@ extern "C" {
#include <glibmm/i18n.h>
#include <glibmm/markup.h>
#include "unit-constants.h"
-
+#include "sp-textpath.h"
namespace Inkscape {
namespace UI {
@@ -133,6 +133,30 @@ TextEdit::TextEdit()
layout_frame.set_padding(4,4,4,4);
layout_frame.add(layout_hbox);
+ // Text start Offset
+ {
+ startOffset = gtk_combo_box_text_new_with_entry ();
+ gtk_widget_set_size_request(startOffset, 90, -1);
+
+ const gchar *spacings[] = {"0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%", NULL};
+ for (int i = 0; spacings[i]; i++) {
+ gtk_combo_box_text_append_text(reinterpret_cast<GtkComboBoxText *>(startOffset), spacings[i]);
+ }
+ gtk_entry_set_text(reinterpret_cast<GtkEntry *>(gtk_bin_get_child(reinterpret_cast<GtkBin *>(startOffset))), "0%");
+
+ gtk_widget_set_tooltip_text(startOffset, _("Text path offset"));
+
+#if WITH_GTKMM_3_0
+ Gtk::Separator *sep = Gtk::manage(new Gtk::Separator());
+ sep->set_orientation(Gtk::ORIENTATION_VERTICAL);
+#else
+ Gtk::VSeparator *sep = Gtk::manage(new Gtk::VSeparator);
+#endif
+ layout_hbox.pack_start(*sep, false, false, 10);
+
+ layout_hbox.pack_start(*Gtk::manage(Glib::wrap(startOffset)), false, false);
+ }
+
/* Font preview */
preview_label.set_ellipsize(Pango::ELLIPSIZE_END);
preview_label.set_justify(Gtk::JUSTIFY_CENTER);
@@ -189,6 +213,7 @@ TextEdit::TextEdit()
g_signal_connect ( G_OBJECT (fontsel), "font_set", G_CALLBACK (onFontChange), this );
g_signal_connect ( G_OBJECT (spacing_combo), "changed", G_CALLBACK (onLineSpacingChange), this );
g_signal_connect ( G_OBJECT (text_buffer), "changed", G_CALLBACK (onTextChange), this );
+ g_signal_connect(startOffset, "changed", G_CALLBACK(onStartOffsetChange), this);
setasdefault_button.signal_clicked().connect(sigc::mem_fun(*this, &TextEdit::onSetDefault));
apply_button.signal_clicked().connect(sigc::mem_fun(*this, &TextEdit::onApply));
close_button.signal_clicked().connect(sigc::bind(_signal_response.make_slot(), GTK_RESPONSE_CLOSE));
@@ -263,8 +288,16 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
guint items = getSelectedTextCount ();
if (items == 1) {
gtk_widget_set_sensitive (text_view, TRUE);
+ gtk_widget_set_sensitive( startOffset, SP_IS_TEXT_TEXTPATH(text) );
+ if (SP_IS_TEXT_TEXTPATH(text)) {
+ SPTextPath *tp = SP_TEXTPATH(text->firstChild());
+ if (tp->getAttribute("startOffset")) {
+ gtk_entry_set_text(reinterpret_cast<GtkEntry *>(gtk_bin_get_child(reinterpret_cast<GtkBin *>(startOffset))), tp->getAttribute("startOffset"));
+ }
+ }
} else {
gtk_widget_set_sensitive (text_view, FALSE);
+ gtk_widget_set_sensitive( startOffset, FALSE );
}
apply_button.set_sensitive ( false );
setasdefault_button.set_sensitive ( true );
@@ -286,6 +319,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
text->getRepr(); // was being called but result ignored. Check this.
} else {
gtk_widget_set_sensitive (text_view, FALSE);
+ gtk_widget_set_sensitive( startOffset, FALSE );
apply_button.set_sensitive ( false );
setasdefault_button.set_sensitive ( false );
}
@@ -616,6 +650,19 @@ void TextEdit::onFontChange(SPFontSelector * /*fontsel*/, gchar* fontspec, TextE
}
+void TextEdit::onStartOffsetChange(GtkTextBuffer *text_buffer, TextEdit *self)
+{
+ SPItem *text = self->getSelectedTextItem();
+ if (text && SP_IS_TEXT_TEXTPATH(text))
+ {
+ SPTextPath *tp = SP_TEXTPATH(text->firstChild());
+ const gchar *sstr = gtk_combo_box_text_get_active_text(reinterpret_cast<GtkComboBoxText *>(self->startOffset));
+ tp->setAttribute("startOffset", sstr);
+
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "startOffset", SP_VERB_CONTEXT_TEXT, _("Set text style"));
+ }
+}
+
void TextEdit::onToggle()
{
if (blocked)
@@ -628,7 +675,6 @@ void TextEdit::onToggle()
//onApply();
}
setasdefault_button.set_sensitive ( true );
-
}
diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h
index f27fdfc87..0e3ebafa7 100644
--- a/src/ui/dialog/text-edit.h
+++ b/src/ui/dialog/text-edit.h
@@ -107,6 +107,14 @@ protected:
static void onFontChange (SPFontSelector *fontsel, gchar* fontspec, TextEdit *self);
/**
+ * Callback invoked when the user modifies the startOffset of text on a path.
+ *
+ * @param text_buffer pointer to the GtkTextBuffer with the text of the selected text object.
+ * @param self pointer to the current instance of the dialog.
+ */
+ static void onStartOffsetChange(GtkTextBuffer *text_buffer, TextEdit *self);
+
+ /**
* Get the selected text off the main canvas.
*
* @return SPItem pointer to the selected text object
@@ -191,6 +199,8 @@ private:
GtkWidget *spacing_combo;
+ GtkWidget *startOffset;
+
Gtk::Label preview_label;
Gtk::Label text_label;
diff --git a/src/xml/repr.h b/src/xml/repr.h
index 52f07d11f..e691eaa7f 100644
--- a/src/xml/repr.h
+++ b/src/xml/repr.h
@@ -98,9 +98,11 @@ void sp_repr_css_print(SPCSSAttr *css);
/* Utility finctions */
/// Remove \a repr from children of its parent node.
inline void sp_repr_unparent(Inkscape::XML::Node *repr) {
- Inkscape::XML::Node *parent=repr->parent();
- if (parent) {
- parent->removeChild(repr);
+ if (repr) {
+ Inkscape::XML::Node *parent=repr->parent();
+ if (parent) {
+ parent->removeChild(repr);
+ }
}
}