=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2016-05-30 12:34:46 +0000
+++ po/POTFILES.in 2016-07-30 14:50:37 +0000
@@ -154,6 +154,7 @@
src/live_effects/lpe-rough-hatches.cpp
src/live_effects/lpe-roughen.cpp
src/live_effects/lpe-ruler.cpp
+src/live_effects/lpe-measure-line.cpp
src/live_effects/lpe-show_handles.cpp
src/live_effects/lpe-simplify.cpp
src/live_effects/lpe-sketch.cpp
@@ -171,6 +172,7 @@
src/live_effects/parameter/powerstrokepointarray.cpp
src/live_effects/parameter/random.cpp
src/live_effects/parameter/text.cpp
+src/live_effects/parameter/fontbutton.cpp
src/live_effects/parameter/togglebutton.cpp
src/live_effects/parameter/transformedpoint.cpp
src/live_effects/parameter/unit.cpp
=== modified file 'src/live_effects/CMakeLists.txt'
--- src/live_effects/CMakeLists.txt 2015-07-24 19:53:33 +0000
+++ src/live_effects/CMakeLists.txt 2016-07-29 21:22:57 +0000
@@ -27,6 +27,7 @@
lpe-lattice.cpp
lpe-lattice2.cpp
lpe-line_segment.cpp
+ lpe-measure-line.cpp
lpe-mirror_symmetry.cpp
lpe-offset.cpp
lpe-parallel.cpp
@@ -68,6 +69,7 @@
parameter/powerstrokepointarray.cpp
parameter/random.cpp
parameter/text.cpp
+ parameter/fontbutton.cpp
parameter/togglebutton.cpp
parameter/transformedpoint.cpp
parameter/unit.cpp
@@ -105,6 +107,7 @@
lpe-lattice.h
lpe-lattice2.h
lpe-line_segment.h
+ lpe-measure-line.h
lpe-mirror_symmetry.h
lpe-offset.h
lpe-parallel.h
@@ -148,6 +151,7 @@
parameter/powerstrokepointarray.h
parameter/random.h
parameter/text.h
+ parameter/fontbutton.h
parameter/togglebutton.h
parameter/transformedpoint.h
parameter/unit.h
=== modified file 'src/live_effects/Makefile_insert'
--- src/live_effects/Makefile_insert 2015-07-24 19:53:33 +0000
+++ src/live_effects/Makefile_insert 2016-07-21 18:04:54 +0000
@@ -70,6 +70,8 @@
live_effects/lpe-perspective_path.h \
live_effects/lpe-perspective-envelope.cpp \
live_effects/lpe-perspective-envelope.h \
+ live_effects/lpe-measure-line.cpp \
+ live_effects/lpe-measure-line.h \
live_effects/lpe-mirror_symmetry.cpp \
live_effects/lpe-mirror_symmetry.h \
live_effects/lpe-circle_3pts.cpp \
=== modified file 'src/live_effects/effect-enum.h'
--- src/live_effects/effect-enum.h 2015-01-27 22:09:47 +0000
+++ src/live_effects/effect-enum.h 2016-07-21 18:55:39 +0000
@@ -36,6 +36,7 @@
CONSTRUCT_GRID,
PERP_BISECTOR,
TANGENT_TO_CURVE,
+ MEASURE_LINE,
MIRROR_SYMMETRY,
CIRCLE_3PTS,
TRANSFORM_2PTS,
=== modified file 'src/live_effects/effect.cpp'
--- src/live_effects/effect.cpp 2016-07-28 11:26:17 +0000
+++ src/live_effects/effect.cpp 2016-07-30 16:41:13 +0000
@@ -40,6 +40,7 @@
#include "live_effects/lpe-lattice2.h"
#include "live_effects/lpe-lattice.h"
#include "live_effects/lpe-line_segment.h"
+#include "live_effects/lpe-measure-line.h"
#include "live_effects/lpe-mirror_symmetry.h"
#include "live_effects/lpe-offset.h"
#include "live_effects/lpe-parallel.h"
@@ -151,6 +152,8 @@
{FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
{ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
{BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
+/* 9.93 */
+ {MEASURE_LINE, N_("Measure Line"), "measure-line"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
@@ -319,6 +322,9 @@
case TRANSFORM_2PTS:
neweffect = static_cast<Effect*> ( new LPETransform2Pts(lpeobj) );
break;
+ case MEASURE_LINE:
+ neweffect = static_cast<Effect*> ( new LPEMeasureLine(lpeobj) );
+ break;
default:
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
@@ -364,6 +370,7 @@
concatenate_before_pwd2(false),
sp_lpe_item(NULL),
current_zoom(1),
+ upd_params(true),
sp_curve(NULL),
provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
@@ -447,7 +454,9 @@
void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
{
}
-
+void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
+{
+}
//secret impl methods (shhhh!)
void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
{
@@ -691,7 +700,7 @@
++it;
}
-
+ upd_params = false;
return dynamic_cast<Gtk::Widget *>(vbox);
}
=== modified file 'src/live_effects/effect.h'
--- src/live_effects/effect.h 2016-03-14 16:47:47 +0000
+++ src/live_effects/effect.h 2016-07-30 16:40:47 +0000
@@ -66,7 +66,7 @@
virtual void doAfterEffect (SPLPEItem const* lpeitem);
virtual void doOnRemove (SPLPEItem const* lpeitem);
-
+ virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
void writeParamsToSVG();
virtual void acceptParamPath (SPPath const* param_path);
@@ -122,6 +122,7 @@
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
bool apply_to_clippath_and_mask;
+ bool upd_params;
protected:
Effect(LivePathEffectObject *lpeobject);
=== modified file 'src/live_effects/lpe-ellipse_5pts.cpp'
--- src/live_effects/lpe-ellipse_5pts.cpp 2016-07-28 11:26:17 +0000
+++ src/live_effects/lpe-ellipse_5pts.cpp 2016-07-29 09:29:42 +0000
@@ -171,7 +171,7 @@
// figure out if we have a slice, guarding against rounding errors
- Path p(Geom::Point(cos(0), sin(0)));
+ Geom::Path p(Geom::Point(cos(0), sin(0)));
double end = 2 * M_PI;
for (s = 0; s < end; s += M_PI_2) {
=== modified file 'src/live_effects/lpe-extrude.cpp'
--- src/live_effects/lpe-extrude.cpp 2016-07-28 11:26:17 +0000
+++ src/live_effects/lpe-extrude.cpp 2016-07-29 09:50:56 +0000
@@ -66,7 +66,7 @@
using namespace Geom;
// generate connecting lines (the 'sides' of the extrusion)
- Path path(Point(0.,0.));
+ Geom::Path path(Point(0.,0.));
path.appendNew<Geom::LineSegment>( extrude_vector.getVector() );
Piecewise<D2<SBasis> > connector = path.toPwSb();
=== modified file 'src/live_effects/lpe-knot.cpp'
--- src/live_effects/lpe-knot.cpp 2016-07-28 11:26:17 +0000
+++ src/live_effects/lpe-knot.cpp 2016-07-29 09:52:43 +0000
@@ -101,7 +101,7 @@
Affine mat = from_basis( T, N, pt_and_dir[0] );
mat = mat.inverse();
- Path p = patha * mat;
+ Geom::Path p = patha * mat;
std::vector<double> times;
@@ -484,7 +484,7 @@
// std::cout<<"fusing first and last component\n";
++beg_comp;
--end_comp;
- Path first = gpaths[i0].portion(dom.back());
+ Geom::Path first = gpaths[i0].portion(dom.back());
//FIXME: stitching should not be necessary (?!?)
first.setStitching(true);
first.append(gpaths[i0].portion(dom.front()));
=== added file 'src/live_effects/lpe-measure-line.cpp'
--- src/live_effects/lpe-measure-line.cpp 1970-01-01 00:00:00 +0000
+++ src/live_effects/lpe-measure-line.cpp 2016-07-31 15:33:26 +0000
@@ -0,0 +1,596 @@
+/*
+ * Author(s):
+ * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ * Some code and ideas migrated from dimensioning.py by
+ * Johannes B. Rutzmoser, johannes.rutzmoser (at) googlemail (dot) com
+ * Copyright (C) 2014 Author(s)
+
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include "live_effects/lpe-measure-line.h"
+#include <pangomm/fontdescription.h>
+#include <libnrtype/font-lister.h>
+#include "inkscape.h"
+#include "xml/node.h"
+#include "uri.h"
+#include "uri-references.h"
+#include "preferences.h"
+#include "util/units.h"
+#include "svg/svg-length.h"
+#include "svg/svg-color.h"
+#include "svg/svg.h"
+#include "display/curve.h"
+#include <2geom/affine.h>
+#include "style.h"
+#include "sp-root.h"
+#include "sp-defs.h"
+#include "sp-item.h"
+#include "sp-shape.h"
+#include "sp-path.h"
+#include "desktop.h"
+#include "document.h"
+#include <iomanip>
+
+// TODO due to internal breakage in glibmm headers, this must be last:
+#include <glibmm/i18n.h>
+
+using namespace Geom;
+namespace Inkscape {
+namespace LivePathEffect {
+
+static const Util::EnumData<OrientationMethod> OrientationMethodData[] = {
+ { OM_HORIZONTAL, N_("Horizontal"), "horizontal" },
+ { OM_VERTICAL, N_("Vertical"), "vertical" },
+ { OM_PARALLEL, N_("Parallel"), "parallel" }
+};
+static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationMethodData, OM_END);
+
+LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this),
+ orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false),
+ curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1),
+ scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0),
+ precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2),
+ position(_("Positon*"), _("Positon"), "position", &wr, this, 5),
+ text_distance(_("Text distance*"), _("Text distance"), "text_distance", &wr, this, 12),
+ helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0),
+ helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0),
+ unit(_("Unit*"), _("Unit"), "unit", &wr, this),
+ format(_("Format*"), _("Format the number ex:measure+ +unit"), "format", &wr, this, "measure+unit"),
+ arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false),
+ flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false),
+ scale_insensitive(_("Scale insensitive*"), _("Scale insensitive to transforms in element, parents..."), "scale_insensitive", &wr, this, true),
+ local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true),
+ line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true),
+ rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true)
+{
+ registerParameter(&fontbutton);
+ registerParameter(&orientation);
+ registerParameter(&curve_linked);
+ registerParameter(&scale);
+ registerParameter(&precision);
+ registerParameter(&position);
+ registerParameter(&text_distance);
+ registerParameter(&helpline_distance);
+ registerParameter(&helpline_overlap);
+ registerParameter(&unit);
+ registerParameter(&format);
+ registerParameter(&arrows_outside);
+ registerParameter(&flip_side);
+ registerParameter(&scale_insensitive);
+ registerParameter(&local_locale);
+ registerParameter(&line_group_05);
+ registerParameter(&rotate_anotation);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ fontbutton.param_update_default(prefs->getString("/live_effects/measure-line/fontbutton"));
+ scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0));
+ precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2));
+ position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0));
+ text_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/text_distance", 5.0));
+ helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0));
+ helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0));
+ unit.param_update_default(prefs->getString("/live_effects/measure-line/unit"));
+ format.param_update_default(prefs->getString("/live_effects/measure-line/format"));
+ flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side"));
+ scale_insensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_insensitive"));
+ local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale"));
+ line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05"));
+ rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation"));
+ format.param_hide_canvas_text();
+ precision.param_set_range(0, 100);
+ precision.param_set_increments(1, 1);
+ precision.param_set_digits(0);
+ precision.param_make_integer(true);
+ curve_linked.param_set_range(0, 999);
+ curve_linked.param_set_increments(1, 1);
+ curve_linked.param_set_digits(0);
+ curve_linked.param_make_integer(true);
+ precision.param_make_integer(true);
+ position.param_set_range(-999999.0, 999999.0);
+ position.param_set_increments(1, 1);
+ position.param_set_digits(2);
+ text_distance.param_set_range(-999999.0, 999999.0);
+ text_distance.param_set_increments(1, 1);
+ text_distance.param_set_digits(2);
+ helpline_distance.param_set_range(-999999.0, 999999.0);
+ helpline_distance.param_set_increments(1, 1);
+ helpline_distance.param_set_digits(2);
+ helpline_overlap.param_set_range(-999999.0, 999999.0);
+ helpline_overlap.param_set_increments(1, 1);
+ helpline_overlap.param_set_digits(2);
+}
+
+LPEMeasureLine::~LPEMeasureLine() {}
+
+void
+LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem)
+{
+ if (!SP_IS_SHAPE(lpeitem)) {
+ g_warning("LPE measure line can only be applied to shapes (not groups).");
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ item->removeCurrentPathEffect(false);
+ }
+}
+
+void
+LPEMeasureLine::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
+{
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
+ SVGElemRef->attach(SVGElem_uri);
+ SPObject *elemref = NULL;
+ Inkscape::XML::Node *rtext = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ rtext = elemref->getRepr();
+ if (!this->isVisible()) {
+ rtext->setAttribute("style", "display:none");
+ } else {
+ rtext->setAttribute("style", NULL);
+ }
+ }
+ }
+}
+
+void
+LPEMeasureLine::createArrowMarker(Glib::ustring mode)
+{
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + mode).c_str());
+ Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
+ SVGElemRef->attach(SVGElem_uri);
+ SPObject *elemref = NULL;
+ Inkscape::XML::Node *arrow = NULL;
+ if (!(elemref = SVGElemRef->getObject())) {
+ arrow = xml_doc->createElement("svg:marker");
+ arrow->setAttribute("id", mode.c_str());
+ arrow->setAttribute("inkscape:stockid", mode.c_str());
+ arrow->setAttribute("orient", "auto");
+ arrow->setAttribute("refX", "0.0");
+ arrow->setAttribute("refY", "0.0");
+ arrow->setAttribute("style", "overflow:visible");
+ /* Create <path> */
+ Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path");
+ if (mode == (Glib::ustring)"ArrowDIN-start") {
+ arrow_path->setAttribute("d", "M -8,0 8,-2.11 8,2.11 z");
+ } else if (mode == (Glib::ustring)"ArrowDIN-end") {
+ arrow_path->setAttribute("d", "M 8,0 -8,2.11 -8,-2.11 z");
+ } else if (mode == (Glib::ustring)"ArrowDINout-start") {
+ arrow_path->setAttribute("d", "M 0,0 -16,2.11 -16,0.5 -26,0.5 -26,-0.5 -16,-0.5 -16,-2.11 z");
+ } else {
+ arrow_path->setAttribute("d", "M 0,0 16,2.11 16,0.5 26,0.5 26,-0.5 16,-0.5 16,-2.11 z");
+ }
+ arrow_path->setAttribute("id", (mode + (Glib::ustring)"_path").c_str());
+ arrow_path->setAttribute("style", "fill:#000000;stroke:none");
+ arrow->addChild(arrow_path, NULL);
+ Inkscape::GC::release(arrow_path);
+ SPObject * arrow_obj = SP_OBJECT(desktop->getDocument()->getDefs()->appendChildRepr(arrow));
+ Inkscape::GC::release(arrow);
+ }
+ }
+}
+
+void
+LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angle, double fontsize, bool remove)
+{
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Node *rtext = NULL;
+ double doc_w = desktop->getDocument()->getRoot()->width.value;
+// Glib::ustring doc_unit = unit_table.getUnit(desktop->getDocument()->getRoot()->width.unit)->abbr;
+// if (doc_unit == "") {
+// doc_unit = "px";
+// } else if (doc_unit == "%" && desktop->getDocument()->getRoot()->viewBox_set) {
+// doc_w_unit = "px";
+// doc_w = desktop->getDocument()->getRoot()->viewBox.width();
+// }
+// doc_unit = Inkscape::Util::unit_table.getUnit(desktop->doc()->getRoot()->height.unit)->abbr;
+// if (doc_unit.empty()) {
+// doc_unit = "px";
+// }
+ Geom::Scale scale = desktop->getDocument()->getDocumentScale();
+ SPNamedView *nv = desktop->getNamedView();
+ Glib::ustring display_unit = nv->display_units->abbr;
+ if (display_unit.empty()) {
+ display_unit = "px";
+ }
+ //only check constrain viewbox on X
+ doc_scale = Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units );
+ if( doc_scale > 0 ) {
+ doc_scale= 1.0/doc_scale;
+ } else {
+ doc_scale = 1.0;
+ }
+ Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
+ SVGElemRef->attach(SVGElem_uri);
+ SPObject *elemref = NULL;
+ Inkscape::XML::Node *rtspan = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ if (remove) {
+ elemref->deleteObject();
+ return;
+ }
+ rtext = elemref->getRepr();
+ sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
+ sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
+ } else {
+ if (remove) {
+ return;
+ }
+ rtext = xml_doc->createElement("svg:text");
+ rtext->setAttribute("xml:space", "preserve");
+ rtext->setAttribute("id", ( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
+ sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
+ rtspan = xml_doc->createElement("svg:tspan");
+ rtspan->setAttribute("sodipodi:role", "line");
+ }
+ gchar * transform;
+ if (rotate_anotation) {
+ Geom::Affine affine = Geom::Affine(Geom::Translate(pos).inverse());
+ affine *= Geom::Rotate(angle);
+ affine *= Geom::Translate(pos);
+ transform = sp_svg_transform_write(affine);
+ } else {
+ transform = NULL;
+ }
+ rtext->setAttribute("transform", transform);
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
+ fontlister->fill_css( css, (Glib::ustring)fontbutton.param_getSVGValue() );
+ std::stringstream font_size;
+ font_size.imbue(std::locale::classic());
+ font_size << fontsize << "pt";
+ sp_repr_css_set_property (css, "font-size", font_size.str().c_str());
+ sp_repr_css_set_property (css, "line-height", "125%");
+ sp_repr_css_set_property (css, "letter-spacing", "0");
+ sp_repr_css_set_property (css, "word-spacing", "0");
+ sp_repr_css_set_property (css, "text-align", "center");
+ sp_repr_css_set_property (css, "text-anchor", "middle");
+ sp_repr_css_set_property (css, "fill", "#000000");
+ sp_repr_css_set_property (css, "fill-opacity", "1");
+ sp_repr_css_set_property (css, "stroke", "none");
+ Glib::ustring css_str;
+ sp_repr_css_write_string(css,css_str);
+ if (!rtspan) {
+ rtspan = rtext->firstChild();
+ }
+ rtspan->setAttribute("style", css_str.c_str());
+ sp_repr_css_attr_unref (css);
+ if (!elemref) {
+ rtext->addChild(rtspan, NULL);
+ Inkscape::GC::release(rtspan);
+ }
+ length = Inkscape::Util::Quantity::convert(length / doc_scale, display_unit.c_str(), unit.get_abbreviation());
+ std::stringstream length_str;
+ length_str.precision(precision);
+ length_str.setf(std::ios::fixed, std::ios::floatfield);
+ if (local_locale) {
+ length_str.imbue(std::locale(""));
+ } else {
+ length_str.imbue(std::locale::classic());
+ }
+ length_str << std::fixed << length;
+ length_str << unit.get_abbreviation();
+ Inkscape::XML::Node *rstring = NULL;
+ if (!elemref) {
+ rstring = xml_doc->createTextNode(length_str.str().c_str());
+ rtspan->addChild(rstring, NULL);
+ Inkscape::GC::release(rstring);
+ } else {
+ rstring = rtspan->firstChild();
+ rstring->setContent(length_str.str().c_str());
+ }
+ SPObject * text_obj = NULL;
+ if (!elemref) {
+ text_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(rtext));
+ Inkscape::GC::release(rtext);
+ }
+ }
+}
+
+void
+LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id, bool main, bool remove)
+{
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
+ Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
+ SVGElemRef->attach(SVGElem_uri);
+ SPObject *elemref = NULL;
+ Inkscape::XML::Node *line = NULL;
+ if (!main) {
+ Geom::Ray ray(start, end);
+ Geom::Coord angle = ray.angle();
+ start = start + Point::polar(angle, helpline_distance );
+ end = end + Point::polar(angle, helpline_overlap );
+ }
+ Geom::Path line_path;
+ line_path.start(start);
+ line_path.appendNew<Geom::LineSegment>(end);
+ Geom::PathVector line_pathv;
+ line_pathv.push_back(line_path);
+ gchar * line_str = sp_svg_write_path( line_pathv );
+ line_pathv.clear();
+ if (elemref = SVGElemRef->getObject()) {
+ if (remove) {
+ elemref->deleteObject();
+ return;
+ }
+ line = elemref->getRepr();
+ line->setAttribute("d" , line_str);
+ } else {
+ if (remove) {
+ return;
+ }
+ line = xml_doc->createElement("svg:path");
+ line->setAttribute("id", id.c_str());
+ line->setAttribute("d" , line_str);
+ }
+ Glib::ustring style = (Glib::ustring)"stroke:#000000;fill:none;";
+ if (main) {
+ line->setAttribute("inkscape:label", "dinline");
+ if (arrows_outside) {
+ style = style + (Glib::ustring)"marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);";
+ } else {
+ style = style + (Glib::ustring)"marker-start:url(#ArrowDIN-start);marker-end:url(#ArrowDIN-end);";
+ }
+ } else {
+ line->setAttribute("inkscape:label", "dinhelpline");
+ }
+ std::stringstream stroke_w;
+ stroke_w.imbue(std::locale::classic());
+ if (line_group_05) {
+ double stroke_width = Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
+ stroke_w << stroke_width;
+ style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
+ } else {
+ double stroke_width = Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
+ stroke_w << stroke_width;
+ style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
+ }
+ line->setAttribute("style", style.c_str());
+ SPObject * line_obj = NULL;
+ if (!elemref) {
+ line_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(line));
+ Inkscape::GC::release(line);
+ }
+ }
+}
+
+void
+LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
+{
+ SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
+ SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem);
+ if (sp_path) {
+ Geom::PathVector pathvector = sp_path->get_original_curve()->get_pathvector();
+ if (arrows_outside) {
+ createArrowMarker((Glib::ustring)"ArrowDINout-start");
+ createArrowMarker((Glib::ustring)"ArrowDINout-end");
+ } else {
+ createArrowMarker((Glib::ustring)"ArrowDIN-start");
+ createArrowMarker((Glib::ustring)"ArrowDIN-end");
+ }
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ size_t ncurves = pathvector.curveCount();
+ curve_linked.param_set_range(0, ncurves);
+ Geom::Point start = pathvector.initialPoint();
+ Geom::Point end = pathvector.finalPoint();
+ if (curve_linked) { //!0
+ start = pathvector.pointAt(curve_linked -1);
+ end = pathvector.pointAt(curve_linked);
+ }
+ Geom::Point hstart = start;
+ Geom::Point hend = end;
+ bool remove = false;
+ if (Geom::are_near(hstart, hend)) {
+ remove = true;
+ }
+ if (orientation == OM_VERTICAL) {
+ Coord xpos = std::max(hstart[Geom::X],hend[Geom::X]);
+ if (flip_side) {
+ xpos = std::min(hstart[Geom::X],hend[Geom::X]);
+ }
+ hstart[Geom::X] = xpos;
+ hend[Geom::X] = xpos;
+ if (hstart[Geom::Y] > hend[Geom::Y]) {
+ swap(hstart,hend);
+ swap(start,end);
+ }
+ if (Geom::are_near(hstart[Geom::Y], hend[Geom::Y])) {
+ remove = true;
+ }
+ }
+ if (orientation == OM_HORIZONTAL) {
+ Coord ypos = std::max(hstart[Geom::Y],hend[Geom::Y]);
+ if (flip_side) {
+ ypos = std::min(hstart[Geom::Y],hend[Geom::Y]);
+ }
+ hstart[Geom::Y] = ypos;
+ hend[Geom::Y] = ypos;
+ if (hstart[Geom::X] < hend[Geom::X]) {
+ swap(hstart,hend);
+ swap(start,end);
+ }
+ if (Geom::are_near(hstart[Geom::X], hend[Geom::X])) {
+ remove = true;
+ }
+ }
+ double length = Geom::distance(hstart,hend) * scale;
+ Geom::Point pos = Geom::middle_point(hstart,hend);
+ Geom::Ray ray(hstart,hend);
+ Geom::Coord angle = ray.angle();
+ if (flip_side) {
+ angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
+ if (angle < 0) angle += 2*M_PI;
+ }
+ Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
+ if (angle_cross < 0) angle_cross += 2*M_PI;
+ //We get the font size to offset the text to the middle
+ Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue());
+ double fontsize = fontdesc.get_size()/Pango::SCALE;
+ fontsize *= desktop->doc()->getRoot()->c2p.inverse().expansionX();
+ pos = pos - Point::polar(angle_cross, (position + text_distance) - fontsize/2.0);
+ if (!scale_insensitive) {
+ Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot()));
+ length *= (affinetransform.expansionX() + affinetransform.expansionY()) / 2.0;
+ }
+ createTextLabel(pos, length, angle, fontsize, remove);
+ //LINE
+ double arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
+ if (line_group_05) {
+ arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
+ }
+ if (flip_side) {
+ arrow_gap *= -1;
+ }
+ angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
+ if (angle_cross < 0) angle_cross += 2*M_PI;
+ hstart = hstart - Point::polar(angle_cross, position);
+ Glib::ustring id = (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id");
+ createLine(start, hstart, id, false, remove);
+ hend = hend - Point::polar(angle_cross, position);
+ id = (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id");
+ createLine(end, hend, id, false, remove);
+ if (!arrows_outside) {
+ hstart = hstart + Point::polar(angle, arrow_gap);
+ hend = hend - Point::polar(angle, arrow_gap );
+ }
+ id = (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id");
+ createLine(hstart, hend, id, true, remove);
+ }
+ }
+}
+
+void LPEMeasureLine::doOnRemove (SPLPEItem const* lpeitem)
+{
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
+ SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
+ Inkscape::URI SVGElem_uri(( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
+ SVGElemRef->attach(SVGElem_uri);
+ SPObject *elemref = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ elemref->deleteObject();
+ }
+ Inkscape::URI SVGElem_uri2(( (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ SVGElemRef->attach(SVGElem_uri2);
+ elemref = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ elemref->deleteObject();
+ }
+ Inkscape::URI SVGElem_uri3(( (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ SVGElemRef->attach(SVGElem_uri3);
+ elemref = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ elemref->deleteObject();
+ }
+ Inkscape::URI SVGElem_uri4(( (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ SVGElemRef->attach(SVGElem_uri4);
+ elemref = NULL;
+ if (elemref = SVGElemRef->getObject()) {
+ elemref->deleteObject();
+ }
+ }
+}
+
+Gtk::Widget *LPEMeasureLine::newWidget()
+{
+ // use manage here, because after deletion of Effect object, others might
+ // still be pointing to this widget.
+ Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
+
+ vbox->set_border_width(5);
+ vbox->set_homogeneous(false);
+ vbox->set_spacing(2);
+
+ std::vector<Parameter *>::iterator it = param_vector.begin();
+ Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0));
+ while (it != param_vector.end()) {
+ if ((*it)->widget_is_visible) {
+ Parameter *param = *it;
+ Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
+ Glib::ustring *tip = param->param_getTooltip();
+ if (widg) {
+ vbox->pack_start(*widg, true, true, 2);
+ if (tip) {
+ widg->set_tooltip_text(*tip);
+ } else {
+ widg->set_tooltip_text("");
+ widg->set_has_tooltip(false);
+ }
+ }
+ }
+
+ ++it;
+ }
+ Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default"))));
+ save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault));
+ button1->pack_start(*save_default, true, true, 2);
+ vbox->pack_start(*button1, true, true, 2);
+ return dynamic_cast<Gtk::Widget *>(vbox);
+}
+
+Geom::PathVector
+LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in)
+{
+ return path_in;
+}
+
+void
+LPEMeasureLine::saveDefault()
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setString("/live_effects/measure-line/fontbutton", (Glib::ustring)fontbutton.param_getSVGValue());
+ prefs->setDouble("/live_effects/measure-line/scale", scale);
+ prefs->setInt("/live_effects/measure-line/precision", precision);
+ prefs->setDouble("/live_effects/measure-line/position", position);
+ prefs->setDouble("/live_effects/measure-line/text_distance", text_distance);
+ prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance);
+ prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap);
+ prefs->setString("/live_effects/measure-line/unit", (Glib::ustring)unit.get_abbreviation());
+ prefs->setString("/live_effects/measure-line/format", (Glib::ustring)format.param_getSVGValue());
+ prefs->setBool("/live_effects/measure-line/flip_side", flip_side);
+ prefs->setBool("/live_effects/measure-line/scale_insensitive", scale_insensitive);
+ prefs->setBool("/live_effects/measure-line/local_locale", local_locale);
+ prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05);
+ prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation);
+}
+
+}; //namespace LivePathEffect
+}; /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offset:((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 :
=== added file 'src/live_effects/lpe-measure-line.h'
--- src/live_effects/lpe-measure-line.h 1970-01-01 00:00:00 +0000
+++ src/live_effects/lpe-measure-line.h 2016-07-31 14:37:23 +0000
@@ -0,0 +1,89 @@
+#ifndef INKSCAPE_LPE_MEASURE_LINE_H
+#define INKSCAPE_LPE_MEASURE_LINE_H
+
+/*
+ * Author(s):
+ * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ *
+ * Copyright (C) 2014 Author(s)
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/effect.h"
+#include "live_effects/parameter/enum.h"
+#include "live_effects/parameter/fontbutton.h"
+#include "live_effects/parameter/text.h"
+#include "live_effects/parameter/unit.h"
+#include "live_effects/parameter/bool.h"
+#include "live_effects/parameter/originalpath.h"
+#include <libnrtype/font-lister.h>
+#include <2geom/angle.h>
+#include <2geom/ray.h>
+#include <2geom/point.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+enum OrientationMethod {
+ OM_HORIZONTAL,
+ OM_VERTICAL,
+ OM_PARALLEL,
+ OM_END
+};
+
+class LPEMeasureLine : public Effect {
+public:
+ LPEMeasureLine(LivePathEffectObject *lpeobject);
+ virtual ~LPEMeasureLine();
+ virtual void doBeforeEffect (SPLPEItem const* lpeitem);
+ virtual void doOnApply(SPLPEItem const* lpeitem);
+ virtual void doOnRemove (SPLPEItem const* lpeitem);
+ virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
+ virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
+ void createLine(Geom::Point start,Geom::Point end,Glib::ustring id, bool main, bool remove);
+ void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, double fontsize, bool remove);
+ void createArrowMarker(Glib::ustring mode);
+ void saveDefault();
+ virtual Gtk::Widget *newWidget();
+private:
+ FontButtonParam fontbutton;
+ EnumParam<OrientationMethod> orientation;
+ ScalarParam curve_linked;
+ ScalarParam scale;
+ ScalarParam precision;
+ ScalarParam position;
+ ScalarParam text_distance;
+ ScalarParam helpline_distance;
+ ScalarParam helpline_overlap;
+ UnitParam unit;
+ TextParam format;
+ BoolParam arrows_outside;
+ BoolParam flip_side;
+ BoolParam scale_insensitive;
+ BoolParam local_locale;
+ BoolParam line_group_05;
+ BoolParam rotate_anotation;
+ Glib::ustring display_unit;
+ double doc_scale;
+/* Geom::Affine affine_over;*/
+ LPEMeasureLine(const LPEMeasureLine &);
+ LPEMeasureLine &operator=(const LPEMeasureLine &);
+
+};
+
+} //namespace LivePathEffect
+} //namespace Inkscape
+
+#endif
+
+/*
+ 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 :
=== modified file 'src/live_effects/lpe-transform_2pts.cpp'
--- src/live_effects/lpe-transform_2pts.cpp 2016-07-28 11:26:17 +0000
+++ src/live_effects/lpe-transform_2pts.cpp 2016-07-24 16:00:12 +0000
@@ -90,7 +90,6 @@
{
using namespace Geom;
original_bbox(lpeitem);
-
point_a = Point(boundingbox_X.min(), boundingbox_Y.middle());
point_b = Point(boundingbox_X.max(), boundingbox_Y.middle());
SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
=== modified file 'src/live_effects/parameter/Makefile_insert'
--- src/live_effects/parameter/Makefile_insert 2015-03-02 01:29:50 +0000
+++ src/live_effects/parameter/Makefile_insert 2016-07-29 21:24:09 +0000
@@ -11,6 +11,8 @@
live_effects/parameter/random.h \
live_effects/parameter/point.cpp \
live_effects/parameter/point.h \
+ live_effects/parameter/fontbutton.cpp \
+ live_effects/parameter/fontbutton.h \
live_effects/parameter/enum.h \
live_effects/parameter/path-reference.cpp \
live_effects/parameter/path-reference.h \
=== modified file 'src/live_effects/parameter/bool.cpp'
--- src/live_effects/parameter/bool.cpp 2015-10-18 19:13:13 +0000
+++ src/live_effects/parameter/bool.cpp 2016-07-24 23:27:14 +0000
@@ -36,6 +36,12 @@
param_setValue(defvalue);
}
+void
+BoolParam::param_update_default(bool const default_value)
+{
+ defvalue = default_value;
+}
+
bool
BoolParam::param_readSVGValue(const gchar * strvalue)
{
=== modified file 'src/live_effects/parameter/bool.h'
--- src/live_effects/parameter/bool.h 2015-10-18 19:13:13 +0000
+++ src/live_effects/parameter/bool.h 2016-07-24 23:26:29 +0000
@@ -36,7 +36,7 @@
void param_setValue(bool newvalue);
virtual void param_set_default();
-
+ void param_update_default(bool const default_value);
bool get_value() const { return value; };
inline operator bool() const { return value; };
=== modified file 'src/live_effects/parameter/enum.h'
--- src/live_effects/parameter/enum.h 2014-03-27 01:33:44 +0000
+++ src/live_effects/parameter/enum.h 2016-07-29 18:13:50 +0000
@@ -27,12 +27,14 @@
const Util::EnumDataConverter<E>& c,
Inkscape::UI::Widget::Registry* wr,
Effect* effect,
- E default_value)
+ E default_value,
+ bool sort = true)
: Parameter(label, tip, key, wr, effect)
{
enumdataconv = &c;
defvalue = default_value;
value = defvalue;
+ sorted = sort;
};
virtual ~EnumParam() { };
@@ -40,12 +42,11 @@
virtual Gtk::Widget * param_newWidget() {
Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage (
new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
- param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
+ param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) );
regenum->set_active_by_id(value);
regenum->combobox()->setProgrammatically = false;
regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
-
return dynamic_cast<Gtk::Widget *> (regenum);
};
@@ -86,6 +87,7 @@
E value;
E defvalue;
+ bool sorted;
const Util::EnumDataConverter<E> * enumdataconv;
};
=== added file 'src/live_effects/parameter/fontbutton.cpp'
--- src/live_effects/parameter/fontbutton.cpp 1970-01-01 00:00:00 +0000
+++ src/live_effects/parameter/fontbutton.cpp 2016-07-29 21:26:48 +0000
@@ -0,0 +1,92 @@
+/*
+ * Authors:
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+#include "ui/widget/registered-widget.h"
+#include "live_effects/parameter/fontbutton.h"
+#include "live_effects/effect.h"
+#include "ui/widget/font-button.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include "verbs.h"
+
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const Glib::ustring default_value )
+ : Parameter(label, tip, key, wr, effect),
+ value(default_value),
+ defvalue(default_value)
+{
+}
+
+void
+FontButtonParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+void
+FontButtonParam::param_update_default(const Glib::ustring default_value){
+ defvalue = default_value;
+}
+
+bool
+FontButtonParam::param_readSVGValue(const gchar * strvalue)
+{
+ Inkscape::SVGOStringStream os;
+ os << strvalue;
+ param_setValue((Glib::ustring)os.str());
+ return true;
+}
+
+gchar *
+FontButtonParam::param_getSVGValue() const
+{
+ return g_strdup(value.c_str());
+}
+
+Gtk::Widget *
+FontButtonParam::param_newWidget()
+{
+ Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage(
+ new Inkscape::UI::Widget::RegisteredFontButton( param_label,
+ param_tooltip,
+ param_key,
+ *param_wr,
+ param_effect->getRepr(),
+ param_effect->getSPDoc() ) );
+ Glib::ustring fontspec = param_getSVGValue();
+ fontbuttonwdg->setValue( fontspec);
+ fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter"));
+ param_effect->upd_params = false;
+ return dynamic_cast<Gtk::Widget *> (fontbuttonwdg);
+}
+
+void
+FontButtonParam::param_setValue(const Glib::ustring newvalue)
+{
+ value = newvalue;
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ 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 :
=== added file 'src/live_effects/parameter/fontbutton.h'
--- src/live_effects/parameter/fontbutton.h 1970-01-01 00:00:00 +0000
+++ src/live_effects/parameter/fontbutton.h 2016-07-29 20:44:37 +0000
@@ -0,0 +1,62 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Authors:
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include <glib.h>
+#include <gtkmm.h>
+#include "live_effects/parameter/parameter.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class FontButtonParam : public Parameter {
+public:
+ FontButtonParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const Glib::ustring default_value = "");
+ virtual ~FontButtonParam() {}
+
+ virtual Gtk::Widget * param_newWidget();
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ void param_update_default(const Glib::ustring defvalue);
+ virtual gchar * param_getSVGValue() const;
+
+ void param_setValue(const Glib::ustring newvalue);
+
+ virtual void param_set_default();
+
+ const Glib::ustring get_value() const { return defvalue; };
+
+private:
+ FontButtonParam(const FontButtonParam&);
+ FontButtonParam& operator=(const FontButtonParam&);
+ Glib::ustring value;
+ Glib::ustring defvalue;
+
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ 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 :
=== modified file 'src/live_effects/parameter/parameter.cpp'
--- src/live_effects/parameter/parameter.cpp 2015-10-18 19:13:13 +0000
+++ src/live_effects/parameter/parameter.cpp 2016-07-30 16:08:21 +0000
@@ -4,11 +4,9 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/widget/registered-widget.h"
-#include <glibmm/i18n.h>
+#include "live_effects/effect.h"
#include "live_effects/parameter/parameter.h"
-#include "live_effects/effect.h"
#include "svg/svg.h"
#include "xml/repr.h"
@@ -16,6 +14,8 @@
#include "verbs.h"
+#include <glibmm/i18n.h>
+
#define noLPEREALPARAM_DEBUG
namespace Inkscape {
@@ -101,9 +101,16 @@
param_set_value(defvalue);
}
+void
+ScalarParam::param_update_default(gdouble default_value)
+{
+ defvalue = default_value;
+}
+
void
ScalarParam::param_set_value(gdouble val)
{
+ param_effect->upd_params = true;
value = val;
if (integer)
value = round(value);
@@ -121,7 +128,7 @@
// Once again, in gtk2, this is not a problem. But in gtk3,
// widgets get allocated the amount of size they ask for,
// leading to excessively long widgets.
-
+ param_effect->upd_params = true;
if (min >= -SCALARPARAM_G_MAXDOUBLE) {
this->min = min;
} else {
@@ -130,15 +137,15 @@
if (max <= SCALARPARAM_G_MAXDOUBLE) {
this->max = max;
} else {
- this->max = SCALARPARAM_G_MAXDOUBLE;
+ this->max = SCALARPARAM_G_MAXDOUBLE;
}
-
param_set_value(value); // reset value to see whether it is in ranges
}
void
ScalarParam::param_make_integer(bool yes)
{
+ param_effect->upd_params = true;
integer = yes;
digits = 0;
inc_step = 1;
@@ -169,6 +176,7 @@
if(!overwrite_widget){
rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
}
+ param_effect->upd_params = false;
return dynamic_cast<Gtk::Widget *> (rsu);
} else {
return NULL;
@@ -178,12 +186,14 @@
void
ScalarParam::param_set_digits(unsigned digits)
{
+ param_effect->upd_params = true;
this->digits = digits;
}
void
ScalarParam::param_set_increments(double step, double page)
{
+ param_effect->upd_params = true;
inc_step = step;
inc_page = page;
}
=== modified file 'src/live_effects/parameter/parameter.h'
--- src/live_effects/parameter/parameter.h 2015-10-18 19:13:13 +0000
+++ src/live_effects/parameter/parameter.h 2016-07-30 16:05:28 +0000
@@ -12,6 +12,7 @@
#include <glibmm/ustring.h>
#include <2geom/forward.h>
#include <2geom/pathvector.h>
+#include "ui/widget/registered-widget.h"
// In gtk2, this wasn't an issue; we could toss around
// G_MAXDOUBLE and not worry about size allocations. But
@@ -110,12 +111,12 @@
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
+ void param_update_default(gdouble default_value);
void param_set_value(gdouble val);
void param_make_integer(bool yes = true);
void param_set_range(gdouble min, gdouble max);
void param_set_digits(unsigned digits);
void param_set_increments(double step, double page);
-
void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; };
void param_overwrite_widget(bool overwrite_widget);
=== modified file 'src/live_effects/parameter/point.cpp'
--- src/live_effects/parameter/point.cpp 2016-01-17 19:18:53 +0000
+++ src/live_effects/parameter/point.cpp 2016-07-29 09:36:40 +0000
@@ -4,7 +4,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/widget/registered-widget.h"
#include "live_effects/parameter/point.h"
#include "live_effects/effect.h"
#include "svg/svg.h"
@@ -30,7 +29,8 @@
: Parameter(label, tip, key, wr, effect),
defvalue(default_value),
liveupdate(live_update),
- knoth(NULL)
+ knoth(NULL),
+ _pointwdg(NULL)
{
knot_shape = SP_KNOT_SHAPE_DIAMOND;
knot_mode = SP_KNOT_MODE_XOR;
@@ -62,9 +62,9 @@
}
void
-PointParam::param_update_default(Geom::Point newpoint)
+PointParam::param_update_default(const Geom::Point default_point)
{
- defvalue = newpoint;
+ defvalue = default_point;
}
void
@@ -81,6 +81,9 @@
if(knoth && liveupdate){
knoth->update_knots();
}
+ if (_pointwdg) {
+ _pointwdg->setValue( newpoint );
+ }
}
bool
@@ -116,7 +119,7 @@
Gtk::Widget *
PointParam::param_newWidget()
{
- Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
+ _pointwdg = Gtk::manage(
new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
param_tooltip,
param_key,
@@ -126,15 +129,15 @@
// TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
Geom::Affine transf = desktop->doc2dt();
- pointwdg->setTransform(transf);
- pointwdg->setValue( *this );
- pointwdg->clearProgrammatically();
- pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
+ _pointwdg->setTransform(transf);
+ _pointwdg->setValue( *this );
+ _pointwdg->clearProgrammatically();
+ _pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
- static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
+ static_cast<Gtk::HBox*>(hbox)->pack_start(*_pointwdg, true, true);
static_cast<Gtk::HBox*>(hbox)->show_all_children();
-
+ param_effect->upd_params = false;
return dynamic_cast<Gtk::Widget *> (hbox);
}
@@ -191,13 +194,13 @@
PointParamKnotHolderEntity::knot_click(guint state)
{
if (state & GDK_CONTROL_MASK) {
- if (state & GDK_MOD1_MASK) {
- this->pparam->param_set_default();
- SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
- if(splpeitem){
- sp_lpe_item_update_patheffect(splpeitem, false, false);
- }
+ if (state & GDK_MOD1_MASK) {
+ this->pparam->param_set_default();
+ SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if(splpeitem){
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
}
+ }
}
}
=== modified file 'src/live_effects/parameter/point.h'
--- src/live_effects/parameter/point.h 2016-01-17 19:18:53 +0000
+++ src/live_effects/parameter/point.h 2016-07-29 09:28:12 +0000
@@ -11,7 +11,7 @@
#include <glib.h>
#include <2geom/point.h>
-
+#include "ui/widget/registered-widget.h"
#include "live_effects/parameter/parameter.h"
#include "knot-holder-entity.h"
@@ -43,7 +43,7 @@
void param_set_default();
Geom::Point param_get_default() const;
void param_set_liveupdate(bool live_update);
- void param_update_default(Geom::Point newpoint);
+ void param_update_default(const Geom::Point default_point);
virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
@@ -62,6 +62,7 @@
SPKnotModeType knot_mode;
guint32 knot_color;
gchar *handle_tip;
+ Inkscape::UI::Widget::RegisteredTransformedPoint * _pointwdg;
};
=== modified file 'src/live_effects/parameter/text.cpp'
--- src/live_effects/parameter/text.cpp 2014-12-21 21:58:32 +0000
+++ src/live_effects/parameter/text.cpp 2016-07-31 02:24:26 +0000
@@ -31,7 +31,8 @@
Effect* effect, const Glib::ustring default_value )
: Parameter(label, tip, key, wr, effect),
value(default_value),
- defvalue(default_value)
+ defvalue(default_value),
+ _hide_canvas_text(false)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this!
canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
@@ -46,9 +47,24 @@
}
void
+TextParam::param_update_default(Glib::ustring default_value)
+{
+ defvalue = default_value;
+}
+
+void
+TextParam::param_hide_canvas_text()
+{
+ _hide_canvas_text = true;
+ sp_canvastext_set_text (canvas_text,"");
+}
+
+void
TextParam::setPos(Geom::Point pos)
{
- sp_canvastext_set_coords (canvas_text, pos);
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_coords (canvas_text, pos);
+ }
}
void
@@ -63,9 +79,10 @@
Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
Point n = -rot90(dir);
double angle = Geom::angle_between(dir, Point(1,0));
-
- sp_canvastext_set_coords(canvas_text, pos + n * length);
- sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_coords(canvas_text, pos + n * length);
+ sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
+ }
}
void
@@ -73,7 +90,9 @@
{
anchor_x = x_value;
anchor_y = y_value;
- sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
+ }
}
bool
@@ -107,8 +126,9 @@
TextParam::param_setValue(const Glib::ustring newvalue)
{
value = newvalue;
-
- sp_canvastext_set_text (canvas_text, newvalue.c_str());
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_text (canvas_text, newvalue.c_str());
+ }
}
} /* namespace LivePathEffect */
=== modified file 'src/live_effects/parameter/text.h'
--- src/live_effects/parameter/text.h 2014-03-27 01:33:44 +0000
+++ src/live_effects/parameter/text.h 2016-07-31 02:24:55 +0000
@@ -40,7 +40,9 @@
virtual gchar * param_getSVGValue() const;
void param_setValue(const Glib::ustring newvalue);
+ void param_hide_canvas_text();
virtual void param_set_default();
+ void param_update_default(Glib::ustring default_value);
void setPos(Geom::Point pos);
void setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
const double t, const double length, bool use_curvature = false);
@@ -53,7 +55,7 @@
TextParam& operator=(const TextParam&);
double anchor_x;
double anchor_y;
-
+ bool _hide_canvas_text;
Glib::ustring value;
Glib::ustring defvalue;
=== modified file 'src/live_effects/parameter/togglebutton.cpp'
--- src/live_effects/parameter/togglebutton.cpp 2016-07-24 15:05:29 +0000
+++ src/live_effects/parameter/togglebutton.cpp 2016-07-24 16:53:55 +0000
@@ -12,6 +12,7 @@
#include "live_effects/effect.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
+#include "selection.h"
#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
@@ -108,13 +109,14 @@
}else{
gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
}
+
checkwdg->add(*Gtk::manage(Glib::wrap(box_button)));
checkwdg->setActive(value);
checkwdg->setProgrammatically = false;
checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
_toggled_connection = checkwdg->signal_toggled().connect(sigc::mem_fun(*this, &ToggleButtonParam::toggled));
-
+ param_effect->upd_params = false;
return checkwdg;
}
@@ -161,6 +163,12 @@
void
ToggleButtonParam::toggled() {
+ //Force redraw for update widgets
+ param_effect->upd_params = true;
+ if (SP_ACTIVE_DESKTOP) {
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
+ selection ->emitModified();
+ }
_signal_toggled.emit();
}
=== modified file 'src/live_effects/parameter/unit.cpp'
--- src/live_effects/parameter/unit.cpp 2014-03-27 01:33:44 +0000
+++ src/live_effects/parameter/unit.cpp 2016-07-24 23:34:35 +0000
@@ -54,6 +54,12 @@
param_set_value(*defunit);
}
+void
+UnitParam::param_update_default(const Glib::ustring default_unit)
+{
+ defunit = unit_table.getUnit(default_unit);
+}
+
void
UnitParam::param_set_value(Inkscape::Util::Unit const &val)
{
=== modified file 'src/live_effects/parameter/unit.h'
--- src/live_effects/parameter/unit.h 2014-03-27 01:33:44 +0000
+++ src/live_effects/parameter/unit.h 2016-07-24 23:34:56 +0000
@@ -33,6 +33,7 @@
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
void param_set_value(Inkscape::Util::Unit const &val);
+ void param_update_default(const Glib::ustring default_unit);
const gchar *get_abbreviation() const;
virtual Gtk::Widget * param_newWidget();
=== modified file 'src/selection.cpp'
--- src/selection.cpp 2016-07-28 11:26:17 +0000
+++ src/selection.cpp 2016-07-24 16:00:12 +0000
@@ -282,6 +282,11 @@
_emitChanged();
}
+void Selection::emitModified()
+{
+ _emitChanged();
+}
+
std::vector<SPObject*> const &Selection::list() {
if(!_objs_vector.empty())
return _objs_vector;
=== modified file 'src/selection.h'
--- src/selection.h 2016-07-28 11:26:17 +0000
+++ src/selection.h 2016-07-24 16:00:12 +0000
@@ -192,6 +192,11 @@
void clear();
/**
+ * Emmit modified signal
+ */
+ void emitModified();
+
+ /**
* Returns true if no items are selected.
*/
bool isEmpty() const { return _objs.empty(); }
=== modified file 'src/ui/CMakeLists.txt'
--- src/ui/CMakeLists.txt 2016-02-07 15:49:01 +0000
+++ src/ui/CMakeLists.txt 2016-07-29 21:24:51 +0000
@@ -128,6 +128,7 @@
widget/entity-entry.cpp
widget/entry.cpp
widget/filter-effect-chooser.cpp
+ widget/font-button.cpp
widget/font-variants.cpp
widget/frame.cpp
widget/gimpcolorwheel.c
@@ -312,6 +313,7 @@
widget/entity-entry.h
widget/entry.h
widget/filter-effect-chooser.h
+ widget/font-button.h
widget/font-variants.h
widget/frame.h
widget/gimpspinscale.h
=== modified file 'src/ui/dialog/livepatheffect-editor.cpp'
--- src/ui/dialog/livepatheffect-editor.cpp 2016-07-28 11:26:17 +0000
+++ src/ui/dialog/livepatheffect-editor.cpp 2016-07-30 17:02:04 +0000
@@ -61,7 +61,7 @@
{
LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
lpeeditor->lpe_list_locked = false;
- lpeeditor->onSelectionChanged(selection);
+ lpeeditor->onSelectionChanged(selection, true);
}
static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
@@ -98,7 +98,8 @@
button_up(),
button_down(),
current_desktop(NULL),
- current_lpeitem(NULL)
+ current_lpeitem(NULL),
+ current_lperef(NULL)
{
Gtk::Box *contents = _getContents();
contents->set_spacing(4);
@@ -206,6 +207,10 @@
void
LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
{
+ if ( ! effect.upd_params ) {
+ return;
+ }
+
if (effectwidget) {
effectcontrol_vbox.remove(*effectwidget);
delete effectwidget;
@@ -265,9 +270,8 @@
button_down.set_sensitive(sensitive);
}
-
void
-LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
+LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_params)
{
if (lpe_list_locked) {
// this was triggered by selecting a row in the list, so skip reloading
@@ -291,6 +295,9 @@
if ( lpeitem->hasPathEffect() ) {
Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE();
if (lpe) {
+ if (upd_params) {
+ lpe->upd_params = true;
+ }
showParams(*lpe);
lpe_list_locked = true;
selectInList(lpe);
@@ -494,6 +501,12 @@
SPItem *item = sel->singleItem();
SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
if ( lpeitem ) {
+ if (current_lperef && current_lperef->lpeobject) {
+ LivePathEffect::Effect * effect = current_lperef->lpeobject->get_lpe();
+ if (effect) {
+ effect->upd_params = true;
+ }
+ }
lpeitem->removeCurrentPathEffect(false);
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
@@ -548,11 +561,17 @@
Gtk::TreeModel::iterator it = sel->get_selected();
LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
- if (lperef && current_lpeitem) {
+ if (lperef && current_lpeitem && current_lperef != lperef) {
+ //The last condition ignore Gtk::TreeModel may occasionally be changed emitted when nothing has happened
if (lperef->lpeobject->get_lpe()) {
lpe_list_locked = true; // prevent reload of the list which would lose selection
current_lpeitem->setCurrentPathEffect(lperef);
- showParams(*lperef->lpeobject->get_lpe());
+ current_lperef = lperef;
+ LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe();
+ if (effect) {
+ effect->upd_params = true;
+ showParams(*effect);
+ }
}
}
}
@@ -570,6 +589,14 @@
/* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
* So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
+ Inkscape::Selection *sel = _getSelection();
+ if ( sel && !sel->isEmpty() ) {
+ SPItem *item = sel->singleItem();
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
+ lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem);
+ }
+ }
DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
newValue ? _("Activate path effect") : _("Deactivate path effect"));
}
=== modified file 'src/ui/dialog/livepatheffect-editor.h'
--- src/ui/dialog/livepatheffect-editor.h 2014-03-27 01:33:44 +0000
+++ src/ui/dialog/livepatheffect-editor.h 2016-07-24 16:00:12 +0000
@@ -45,7 +45,8 @@
static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); }
- void onSelectionChanged(Inkscape::Selection *sel);
+ void onSelectionChanged(Inkscape::Selection *sel, bool upd_params = false);
+ void onSelectionModified(Inkscape::Selection *sel);
virtual void on_effect_selection_changed();
void setDesktop(SPDesktop *desktop);
@@ -126,6 +127,8 @@
SPLPEItem * current_lpeitem;
+ LivePathEffect::LPEObjectReference * current_lperef;
+
friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data);
LivePathEffectEditor(LivePathEffectEditor const &d);
=== modified file 'src/ui/widget/Makefile_insert'
--- src/ui/widget/Makefile_insert 2015-05-17 09:20:36 +0000
+++ src/ui/widget/Makefile_insert 2016-07-29 21:25:30 +0000
@@ -33,6 +33,8 @@
ui/widget/entry.h \
ui/widget/filter-effect-chooser.h \
ui/widget/filter-effect-chooser.cpp \
+ ui/widget/font-button.h \
+ ui/widget/font-button.cpp \
ui/widget/font-variants.h \
ui/widget/font-variants.cpp \
ui/widget/gimpspinscale.c \
=== modified file 'src/ui/widget/combo-enums.h'
--- src/ui/widget/combo-enums.h 2012-02-15 11:19:00 +0000
+++ src/ui/widget/combo-enums.h 2016-07-29 18:13:37 +0000
@@ -16,7 +16,6 @@
#include <gtkmm/liststore.h>
#include "attr-widget.h"
#include "util/enums.h"
-
#include <glibmm/i18n.h>
namespace Inkscape {
@@ -190,9 +189,11 @@
const Util::EnumDataConverter<E>& c,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
- bool mnemonic = true)
- : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
- { }
+ bool mnemonic = true,
+ bool sorted = true)
+ : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
+ {
+ }
ComboBoxEnum<E>* getCombobox() {
return static_cast< ComboBoxEnum<E>* > (_widget);
=== added file 'src/ui/widget/font-button.cpp'
--- src/ui/widget/font-button.cpp 1970-01-01 00:00:00 +0000
+++ src/ui/widget/font-button.cpp 2016-07-30 00:01:38 +0000
@@ -0,0 +1,58 @@
+/*
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "font-button.h"
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip,
+ Glib::ustring const &suffix,
+ Glib::ustring const &icon,
+ bool mnemonic)
+ : Labelled(label, tooltip, new Gtk::FontButton("Sans 10"), suffix, icon, mnemonic)
+{
+}
+
+Glib::ustring FontButton::getValue() const
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_widget)->get_font_name();
+}
+
+
+void FontButton::setValue (Glib::ustring fontspec)
+{
+ g_assert(_widget != NULL);
+ static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec);
+}
+
+Glib::SignalProxy0<void> FontButton::signal_font_value_changed()
+{
+ g_assert(_widget != NULL);
+ return static_cast<Gtk::FontButton*>(_widget)->signal_font_set();
+}
+
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ 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 :
=== added file 'src/ui/widget/font-button.h'
--- src/ui/widget/font-button.h 1970-01-01 00:00:00 +0000
+++ src/ui/widget/font-button.h 2016-07-29 22:58:22 +0000
@@ -0,0 +1,63 @@
+/*
+ *
+ * Copyright (C) 2007 Author
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+
+#include <gtkmm.h>
+#include "labelled.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * A labelled font button for entering font values
+ */
+class FontButton : public Labelled
+{
+public:
+ /**
+ * Construct a FontButton Widget.
+ *
+ * @param label Label.
+ * @param suffix Suffix, placed after the widget (defaults to "").
+ * @param icon Icon filename, placed before the label (defaults to "").
+ * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to false).
+ */
+ FontButton( Glib::ustring const &label,
+ Glib::ustring const &tooltip,
+ Glib::ustring const &suffix = "",
+ Glib::ustring const &icon = "",
+ bool mnemonic = true);
+
+ Glib::ustring getValue() const;
+ void setValue (Glib::ustring fontspec);
+ /**
+ * Signal raised when the font button's value changes.
+ */
+ Glib::SignalProxy0<void> signal_font_value_changed();
+};
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_RANDOM_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 :
=== modified file 'src/ui/widget/registered-enums.h'
--- src/ui/widget/registered-enums.h 2011-10-25 07:45:35 +0000
+++ src/ui/widget/registered-enums.h 2016-07-29 18:13:43 +0000
@@ -33,11 +33,11 @@
const Util::EnumDataConverter<E>& c,
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
- SPDocument *doc_in = NULL )
- : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
+ SPDocument *doc_in = NULL,
+ bool sorted = true )
+ : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
{
RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
-
_changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
}
=== modified file 'src/ui/widget/registered-widget.cpp'
--- src/ui/widget/registered-widget.cpp 2016-07-28 11:26:17 +0000
+++ src/ui/widget/registered-widget.cpp 2016-07-31 02:52:27 +0000
@@ -25,6 +25,7 @@
#include "ui/widget/scalar-unit.h"
#include "ui/widget/point.h"
#include "ui/widget/random.h"
+#include "ui/widget/font-button.h"
#include "widgets/spinbutton-events.h"
#include "xml/repr.h"
@@ -297,7 +298,6 @@
setProgrammatically = false;
return;
}
-
if (_wr->isUpdating()) {
return;
}
@@ -803,6 +803,47 @@
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered FONT-BUTTON
+ */
+
+RegisteredFontButton::~RegisteredFontButton()
+{
+ _signal_font_set.disconnect();
+}
+
+RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<FontButton>(label, tip)
+{
+ init_parent(key, wr, repr_in, doc_in);
+ _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
+}
+
+void
+RegisteredFontButton::setValue (Glib::ustring fontspec)
+{
+ FontButton::setValue(fontspec);
+}
+
+void
+RegisteredFontButton::on_value_changed()
+{
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Inkscape::SVGOStringStream os;
+ os << getValue();
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
=== modified file 'src/ui/widget/registered-widget.h'
--- src/ui/widget/registered-widget.h 2016-07-24 15:05:29 +0000
+++ src/ui/widget/registered-widget.h 2016-07-29 22:45:14 +0000
@@ -22,6 +22,7 @@
#include "ui/widget/text.h"
#include "ui/widget/random.h"
#include "ui/widget/unit-menu.h"
+#include "ui/widget/font-button.h"
#include "ui/widget/color-picker.h"
#include "inkscape.h"
@@ -77,6 +78,8 @@
RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
template< typename A, typename B, typename C, typename D, typename E , typename F>
RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
+ template< typename A, typename B, typename C, typename D, typename E , typename F, typename G>
+ RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); }
virtual ~RegisteredWidget() {};
@@ -418,6 +421,23 @@
void on_value_changed();
};
+class RegisteredFontButton : public RegisteredWidget<FontButton> {
+public:
+ virtual ~RegisteredFontButton();
+ RegisteredFontButton ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL);
+
+ void setValue (Glib::ustring fontspec);
+
+protected:
+ sigc::connection _signal_font_set;
+ void on_value_changed();
+};
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
=== modified file 'src/ui/widget/scalar.cpp'
--- src/ui/widget/scalar.cpp 2014-03-27 01:33:44 +0000
+++ src/ui/widget/scalar.cpp 2016-07-30 15:23:12 +0000
@@ -126,10 +126,12 @@
static_cast<SpinButton*>(_widget)->set_range(min, max);
}
-void Scalar::setValue(double value)
+void Scalar::setValue(double value, bool setProg)
{
g_assert(_widget != NULL);
- setProgrammatically = true; // callback is supposed to reset back, if it cares
+ if (setProg) {
+ setProgrammatically = true; // callback is supposed to reset back, if it cares
+ }
static_cast<SpinButton*>(_widget)->set_value(value);
}
=== modified file 'src/ui/widget/scalar.h'
--- src/ui/widget/scalar.h 2012-04-30 22:04:12 +0000
+++ src/ui/widget/scalar.h 2016-07-30 15:23:27 +0000
@@ -139,7 +139,7 @@
/**
* Sets the value of the spin button.
*/
- void setValue(double value);
+ void setValue(double value, bool setProg = true);
/**
* Manually forces an update of the spin button.
=== modified file 'src/widgets/font-selector.cpp'
--- src/widgets/font-selector.cpp 2016-07-28 11:26:17 +0000
+++ src/widgets/font-selector.cpp 2016-07-22 19:59:31 +0000
@@ -19,9 +19,6 @@
# include "config.h"
#endif
-#include <libnrtype/font-lister.h>
-#include <libnrtype/font-instance.h>
-
#include <2geom/transforms.h>
#include <gtk/gtk.h>
@@ -34,29 +31,7 @@
/* SPFontSelector */
-struct SPFontSelector
-{
-#if GTK_CHECK_VERSION(3,0,0)
- GtkBox hbox;
-#else
- GtkHBox hbox;
-#endif
-
- unsigned int block_emit : 1;
-
- GtkWidget *family;
- GtkWidget *style;
- GtkWidget *size;
-
- GtkWidget *family_treeview;
- GtkWidget *style_treeview;
-
- NRNameList families;
- NRStyleList styles;
- gfloat fontsize;
- bool fontsize_dirty;
- Glib::ustring *fontspec;
-};
+
struct SPFontSelectorClass
@@ -274,6 +249,7 @@
if (fsel->fontspec) {
delete fsel->fontspec;
+ fsel->fontspec = 0;
}
if (fsel->families.length > 0) {
=== modified file 'src/widgets/font-selector.h'
--- src/widgets/font-selector.h 2014-08-18 20:19:55 +0000
+++ src/widgets/font-selector.h 2016-07-22 19:59:29 +0000
@@ -15,10 +15,33 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+#include <libnrtype/font-lister.h>
+#include <libnrtype/font-instance.h>
#include <glib.h>
-struct SPFontSelector;
+struct SPFontSelector
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkBox hbox;
+#else
+ GtkHBox hbox;
+#endif
+
+ unsigned int block_emit : 1;
+
+ GtkWidget *family;
+ GtkWidget *style;
+ GtkWidget *size;
+
+ GtkWidget *family_treeview;
+ GtkWidget *style_treeview;
+
+ NRNameList families;
+ NRStyleList styles;
+ gfloat fontsize;
+ bool fontsize_dirty;
+ Glib::ustring *fontspec;
+};
#define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ())
#define SP_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector))
-
Please log in to leave a comment!