1. === modified file 'po/POTFILES.in'
  2. --- po/POTFILES.in 2016-05-30 12:34:46 +0000
  3. +++ po/POTFILES.in 2016-07-30 14:50:37 +0000
  4. @@ -154,6 +154,7 @@
  5. src/live_effects/lpe-rough-hatches.cpp
  6. src/live_effects/lpe-roughen.cpp
  7. src/live_effects/lpe-ruler.cpp
  8. +src/live_effects/lpe-measure-line.cpp
  9. src/live_effects/lpe-show_handles.cpp
  10. src/live_effects/lpe-simplify.cpp
  11. src/live_effects/lpe-sketch.cpp
  12. @@ -171,6 +172,7 @@
  13. src/live_effects/parameter/powerstrokepointarray.cpp
  14. src/live_effects/parameter/random.cpp
  15. src/live_effects/parameter/text.cpp
  16. +src/live_effects/parameter/fontbutton.cpp
  17. src/live_effects/parameter/togglebutton.cpp
  18. src/live_effects/parameter/transformedpoint.cpp
  19. src/live_effects/parameter/unit.cpp
  20. === modified file 'src/live_effects/CMakeLists.txt'
  21. --- src/live_effects/CMakeLists.txt 2015-07-24 19:53:33 +0000
  22. +++ src/live_effects/CMakeLists.txt 2016-07-29 21:22:57 +0000
  23. @@ -27,6 +27,7 @@
  24. lpe-lattice.cpp
  25. lpe-lattice2.cpp
  26. lpe-line_segment.cpp
  27. + lpe-measure-line.cpp
  28. lpe-mirror_symmetry.cpp
  29. lpe-offset.cpp
  30. lpe-parallel.cpp
  31. @@ -68,6 +69,7 @@
  32. parameter/powerstrokepointarray.cpp
  33. parameter/random.cpp
  34. parameter/text.cpp
  35. + parameter/fontbutton.cpp
  36. parameter/togglebutton.cpp
  37. parameter/transformedpoint.cpp
  38. parameter/unit.cpp
  39. @@ -105,6 +107,7 @@
  40. lpe-lattice.h
  41. lpe-lattice2.h
  42. lpe-line_segment.h
  43. + lpe-measure-line.h
  44. lpe-mirror_symmetry.h
  45. lpe-offset.h
  46. lpe-parallel.h
  47. @@ -148,6 +151,7 @@
  48. parameter/powerstrokepointarray.h
  49. parameter/random.h
  50. parameter/text.h
  51. + parameter/fontbutton.h
  52. parameter/togglebutton.h
  53. parameter/transformedpoint.h
  54. parameter/unit.h
  55. === modified file 'src/live_effects/Makefile_insert'
  56. --- src/live_effects/Makefile_insert 2015-07-24 19:53:33 +0000
  57. +++ src/live_effects/Makefile_insert 2016-07-21 18:04:54 +0000
  58. @@ -70,6 +70,8 @@
  59. live_effects/lpe-perspective_path.h \
  60. live_effects/lpe-perspective-envelope.cpp \
  61. live_effects/lpe-perspective-envelope.h \
  62. + live_effects/lpe-measure-line.cpp \
  63. + live_effects/lpe-measure-line.h \
  64. live_effects/lpe-mirror_symmetry.cpp \
  65. live_effects/lpe-mirror_symmetry.h \
  66. live_effects/lpe-circle_3pts.cpp \
  67. === modified file 'src/live_effects/effect-enum.h'
  68. --- src/live_effects/effect-enum.h 2015-01-27 22:09:47 +0000
  69. +++ src/live_effects/effect-enum.h 2016-07-21 18:55:39 +0000
  70. @@ -36,6 +36,7 @@
  71. CONSTRUCT_GRID,
  72. PERP_BISECTOR,
  73. TANGENT_TO_CURVE,
  74. + MEASURE_LINE,
  75. MIRROR_SYMMETRY,
  76. CIRCLE_3PTS,
  77. TRANSFORM_2PTS,
  78. === modified file 'src/live_effects/effect.cpp'
  79. --- src/live_effects/effect.cpp 2016-07-28 11:26:17 +0000
  80. +++ src/live_effects/effect.cpp 2016-07-30 16:41:13 +0000
  81. @@ -40,6 +40,7 @@
  82. #include "live_effects/lpe-lattice2.h"
  83. #include "live_effects/lpe-lattice.h"
  84. #include "live_effects/lpe-line_segment.h"
  85. +#include "live_effects/lpe-measure-line.h"
  86. #include "live_effects/lpe-mirror_symmetry.h"
  87. #include "live_effects/lpe-offset.h"
  88. #include "live_effects/lpe-parallel.h"
  89. @@ -151,6 +152,8 @@
  90. {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
  91. {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
  92. {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
  93. +/* 9.93 */
  94. + {MEASURE_LINE, N_("Measure Line"), "measure-line"},
  95. };
  96. const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
  97. @@ -319,6 +322,9 @@
  98. case TRANSFORM_2PTS:
  99. neweffect = static_cast<Effect*> ( new LPETransform2Pts(lpeobj) );
  100. break;
  101. + case MEASURE_LINE:
  102. + neweffect = static_cast<Effect*> ( new LPEMeasureLine(lpeobj) );
  103. + break;
  104. default:
  105. g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
  106. neweffect = NULL;
  107. @@ -364,6 +370,7 @@
  108. concatenate_before_pwd2(false),
  109. sp_lpe_item(NULL),
  110. current_zoom(1),
  111. + upd_params(true),
  112. sp_curve(NULL),
  113. provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
  114. is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
  115. @@ -447,7 +454,9 @@
  116. void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
  117. {
  118. }
  119. -
  120. +void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
  121. +{
  122. +}
  123. //secret impl methods (shhhh!)
  124. void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
  125. {
  126. @@ -691,7 +700,7 @@
  127. ++it;
  128. }
  129. -
  130. + upd_params = false;
  131. return dynamic_cast<Gtk::Widget *>(vbox);
  132. }
  133. === modified file 'src/live_effects/effect.h'
  134. --- src/live_effects/effect.h 2016-03-14 16:47:47 +0000
  135. +++ src/live_effects/effect.h 2016-07-30 16:40:47 +0000
  136. @@ -66,7 +66,7 @@
  137. virtual void doAfterEffect (SPLPEItem const* lpeitem);
  138. virtual void doOnRemove (SPLPEItem const* lpeitem);
  139. -
  140. + virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
  141. void writeParamsToSVG();
  142. virtual void acceptParamPath (SPPath const* param_path);
  143. @@ -122,6 +122,7 @@
  144. void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
  145. bool apply_to_clippath_and_mask;
  146. + bool upd_params;
  147. protected:
  148. Effect(LivePathEffectObject *lpeobject);
  149. === modified file 'src/live_effects/lpe-ellipse_5pts.cpp'
  150. --- src/live_effects/lpe-ellipse_5pts.cpp 2016-07-28 11:26:17 +0000
  151. +++ src/live_effects/lpe-ellipse_5pts.cpp 2016-07-29 09:29:42 +0000
  152. @@ -171,7 +171,7 @@
  153. // figure out if we have a slice, guarding against rounding errors
  154. - Path p(Geom::Point(cos(0), sin(0)));
  155. + Geom::Path p(Geom::Point(cos(0), sin(0)));
  156. double end = 2 * M_PI;
  157. for (s = 0; s < end; s += M_PI_2) {
  158. === modified file 'src/live_effects/lpe-extrude.cpp'
  159. --- src/live_effects/lpe-extrude.cpp 2016-07-28 11:26:17 +0000
  160. +++ src/live_effects/lpe-extrude.cpp 2016-07-29 09:50:56 +0000
  161. @@ -66,7 +66,7 @@
  162. using namespace Geom;
  163. // generate connecting lines (the 'sides' of the extrusion)
  164. - Path path(Point(0.,0.));
  165. + Geom::Path path(Point(0.,0.));
  166. path.appendNew<Geom::LineSegment>( extrude_vector.getVector() );
  167. Piecewise<D2<SBasis> > connector = path.toPwSb();
  168. === modified file 'src/live_effects/lpe-knot.cpp'
  169. --- src/live_effects/lpe-knot.cpp 2016-07-28 11:26:17 +0000
  170. +++ src/live_effects/lpe-knot.cpp 2016-07-29 09:52:43 +0000
  171. @@ -101,7 +101,7 @@
  172. Affine mat = from_basis( T, N, pt_and_dir[0] );
  173. mat = mat.inverse();
  174. - Path p = patha * mat;
  175. + Geom::Path p = patha * mat;
  176. std::vector<double> times;
  177. @@ -484,7 +484,7 @@
  178. // std::cout<<"fusing first and last component\n";
  179. ++beg_comp;
  180. --end_comp;
  181. - Path first = gpaths[i0].portion(dom.back());
  182. + Geom::Path first = gpaths[i0].portion(dom.back());
  183. //FIXME: stitching should not be necessary (?!?)
  184. first.setStitching(true);
  185. first.append(gpaths[i0].portion(dom.front()));
  186. === added file 'src/live_effects/lpe-measure-line.cpp'
  187. --- src/live_effects/lpe-measure-line.cpp 1970-01-01 00:00:00 +0000
  188. +++ src/live_effects/lpe-measure-line.cpp 2016-08-01 16:09:08 +0000
  189. @@ -0,0 +1,709 @@
  190. +/*
  191. + * Author(s):
  192. + * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
  193. + * Some code and ideas migrated from dimensioning.py by
  194. + * Johannes B. Rutzmoser, johannes.rutzmoser (at) googlemail (dot) com
  195. + * Copyright (C) 2014 Author(s)
  196. +
  197. + * Released under GNU GPL, read the file 'COPYING' for more information
  198. + */
  199. +#include "live_effects/lpe-measure-line.h"
  200. +#include <pangomm/fontdescription.h>
  201. +#include <libnrtype/font-lister.h>
  202. +#include "inkscape.h"
  203. +#include "xml/node.h"
  204. +#include "uri.h"
  205. +#include "uri-references.h"
  206. +#include "preferences.h"
  207. +#include "util/units.h"
  208. +#include "svg/svg-length.h"
  209. +#include "svg/svg-color.h"
  210. +#include "svg/svg.h"
  211. +#include "display/curve.h"
  212. +#include <2geom/affine.h>
  213. +#include "style.h"
  214. +#include "sp-root.h"
  215. +#include "sp-defs.h"
  216. +#include "sp-item.h"
  217. +#include "sp-shape.h"
  218. +#include "sp-path.h"
  219. +#include "desktop.h"
  220. +#include "document.h"
  221. +#include <iomanip>
  222. +
  223. +// TODO due to internal breakage in glibmm headers, this must be last:
  224. +#include <glibmm/i18n.h>
  225. +
  226. +using namespace Geom;
  227. +namespace Inkscape {
  228. +namespace LivePathEffect {
  229. +
  230. +static const Util::EnumData<OrientationMethod> OrientationMethodData[] = {
  231. + { OM_HORIZONTAL, N_("Horizontal"), "horizontal" },
  232. + { OM_VERTICAL, N_("Vertical"), "vertical" },
  233. + { OM_PARALLEL, N_("Parallel"), "parallel" }
  234. +};
  235. +static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationMethodData, OM_END);
  236. +
  237. +LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
  238. + Effect(lpeobject),
  239. + unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"),
  240. + fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this),
  241. + orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false),
  242. + curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1),
  243. + precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2),
  244. + position(_("Positon*"), _("Positon"), "position", &wr, this, 5),
  245. + text_distance(_("Text distance*"), _("Text distance"), "text_distance", &wr, this, 12),
  246. + helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0),
  247. + helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0),
  248. + scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0),
  249. + format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"measure unit"),
  250. + arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false),
  251. + flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false),
  252. + scale_insensitive(_("Scale insensitive*"), _("Scale insensitive to transforms in element, parents..."), "scale_insensitive", &wr, this, true),
  253. + local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true),
  254. + line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true),
  255. + rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true),
  256. + dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""),
  257. + helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""),
  258. + anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""),
  259. + arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""),
  260. + expanded(false)
  261. +{
  262. + registerParameter(&unit);
  263. + registerParameter(&fontbutton);
  264. + registerParameter(&orientation);
  265. + registerParameter(&curve_linked);
  266. + registerParameter(&precision);
  267. + registerParameter(&position);
  268. + registerParameter(&text_distance);
  269. + registerParameter(&helpline_distance);
  270. + registerParameter(&helpline_overlap);
  271. + registerParameter(&scale);
  272. + registerParameter(&format);
  273. + registerParameter(&arrows_outside);
  274. + registerParameter(&flip_side);
  275. + registerParameter(&scale_insensitive);
  276. + registerParameter(&local_locale);
  277. + registerParameter(&line_group_05);
  278. + registerParameter(&rotate_anotation);
  279. + registerParameter(&dimline_format);
  280. + registerParameter(&helperlines_format);
  281. + registerParameter(&anotation_format);
  282. + registerParameter(&arrows_format);
  283. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  284. + Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton");
  285. + if(fontbutton_value.empty()){
  286. + fontbutton_value = "Sans 10";
  287. + }
  288. + fontbutton.param_update_default(fontbutton_value);
  289. + scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0));
  290. + precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2));
  291. + position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0));
  292. + text_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/text_distance", 5.0));
  293. + helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0));
  294. + helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0));
  295. + Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit");
  296. + if(unit_value.empty()){
  297. + unit_value = "px";
  298. + }
  299. + unit.param_update_default(unit_value);
  300. + Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format");
  301. + if(format_value.empty()){
  302. + format_value = "{measure}{unit}";
  303. + }
  304. + format.param_update_default(format_value);
  305. + dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format"));
  306. + helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format"));
  307. + anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format"));
  308. + arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format"));
  309. + flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side"));
  310. + scale_insensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_insensitive"));
  311. + local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale"));
  312. + line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05"));
  313. + rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation"));
  314. + format.param_hide_canvas_text();
  315. + dimline_format.param_hide_canvas_text();
  316. + helperlines_format.param_hide_canvas_text();
  317. + anotation_format.param_hide_canvas_text();
  318. + arrows_format.param_hide_canvas_text();
  319. + precision.param_set_range(0, 100);
  320. + precision.param_set_increments(1, 1);
  321. + precision.param_set_digits(0);
  322. + precision.param_make_integer(true);
  323. + curve_linked.param_set_range(0, 999);
  324. + curve_linked.param_set_increments(1, 1);
  325. + curve_linked.param_set_digits(0);
  326. + curve_linked.param_make_integer(true);
  327. + precision.param_make_integer(true);
  328. + position.param_set_range(-999999.0, 999999.0);
  329. + position.param_set_increments(1, 1);
  330. + position.param_set_digits(2);
  331. + text_distance.param_set_range(-999999.0, 999999.0);
  332. + text_distance.param_set_increments(1, 1);
  333. + text_distance.param_set_digits(2);
  334. + helpline_distance.param_set_range(-999999.0, 999999.0);
  335. + helpline_distance.param_set_increments(1, 1);
  336. + helpline_distance.param_set_digits(2);
  337. + helpline_overlap.param_set_range(-999999.0, 999999.0);
  338. + helpline_overlap.param_set_increments(1, 1);
  339. + helpline_overlap.param_set_digits(2);
  340. +}
  341. +
  342. +LPEMeasureLine::~LPEMeasureLine() {}
  343. +
  344. +void
  345. +LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem)
  346. +{
  347. + if (!SP_IS_SHAPE(lpeitem)) {
  348. + g_warning("LPE measure line can only be applied to shapes (not groups).");
  349. + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
  350. + item->removeCurrentPathEffect(false);
  351. + }
  352. +}
  353. +
  354. +void
  355. +LPEMeasureLine::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
  356. +{
  357. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  358. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  359. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  360. + SVGElemRef->attach(SVGElem_uri);
  361. + SPObject *elemref = NULL;
  362. + Inkscape::XML::Node *rtext = NULL;
  363. + if (elemref = SVGElemRef->getObject()) {
  364. + rtext = elemref->getRepr();
  365. + if (!this->isVisible()) {
  366. + rtext->setAttribute("style", "display:none");
  367. + } else {
  368. + rtext->setAttribute("style", NULL);
  369. + }
  370. + }
  371. + }
  372. +}
  373. +
  374. +void
  375. +LPEMeasureLine::createArrowMarker(Glib::ustring mode)
  376. +{
  377. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  378. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  379. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + mode).c_str());
  380. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  381. + SVGElemRef->attach(SVGElem_uri);
  382. + SPObject *elemref = NULL;
  383. + Inkscape::XML::Node *arrow = NULL;
  384. + if (!(elemref = SVGElemRef->getObject())) {
  385. + arrow = xml_doc->createElement("svg:marker");
  386. + arrow->setAttribute("id", mode.c_str());
  387. + arrow->setAttribute("inkscape:stockid", mode.c_str());
  388. + arrow->setAttribute("orient", "auto");
  389. + arrow->setAttribute("refX", "0.0");
  390. + arrow->setAttribute("refY", "0.0");
  391. + arrow->setAttribute("style", "overflow:visible");
  392. + /* Create <path> */
  393. + Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path");
  394. + if (mode == (Glib::ustring)"ArrowDIN-start") {
  395. + arrow_path->setAttribute("d", "M -8,0 8,-2.11 8,2.11 z");
  396. + } else if (mode == (Glib::ustring)"ArrowDIN-end") {
  397. + arrow_path->setAttribute("d", "M 8,0 -8,2.11 -8,-2.11 z");
  398. + } else if (mode == (Glib::ustring)"ArrowDINout-start") {
  399. + 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");
  400. + } else {
  401. + 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");
  402. + }
  403. + arrow_path->setAttribute("id", (mode + (Glib::ustring)"_path").c_str());
  404. + SPCSSAttr *css = sp_repr_css_attr_new();
  405. + sp_repr_css_set_property (css, "fill","#000000");
  406. + sp_repr_css_set_property (css, "stroke","none" );
  407. + sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
  408. + Glib::ustring css_str;
  409. + sp_repr_css_write_string(css,css_str);
  410. + arrow_path->setAttribute("style", css_str.c_str());
  411. + arrow->addChild(arrow_path, NULL);
  412. + Inkscape::GC::release(arrow_path);
  413. + SPObject * arrow_obj = SP_OBJECT(desktop->getDocument()->getDefs()->appendChildRepr(arrow));
  414. + Inkscape::GC::release(arrow);
  415. + } else {
  416. + Inkscape::XML::Node *arrow= elemref->getRepr();
  417. + if (arrow) {
  418. + Inkscape::XML::Node *arrow_data = arrow->firstChild();
  419. + if (arrow_data) {
  420. + SPCSSAttr *css = sp_repr_css_attr_new();
  421. + sp_repr_css_set_property (css, "fill","#000000");
  422. + sp_repr_css_set_property (css, "stroke","none" );
  423. + sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
  424. + Glib::ustring css_str;
  425. + sp_repr_css_write_string(css,css_str);
  426. + arrow_data->setAttribute("style", css_str.c_str());
  427. + }
  428. + }
  429. + }
  430. + }
  431. +}
  432. +
  433. +void
  434. +LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angle, double fontsize, bool remove)
  435. +{
  436. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  437. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  438. + Inkscape::XML::Node *rtext = NULL;
  439. + double doc_w = desktop->getDocument()->getRoot()->width.value;
  440. + Geom::Scale scale = desktop->getDocument()->getDocumentScale();
  441. + SPNamedView *nv = desktop->getNamedView();
  442. + Glib::ustring display_unit = nv->display_units->abbr;
  443. + if (display_unit.empty()) {
  444. + display_unit = "px";
  445. + }
  446. + //only check constrain viewbox on X
  447. + doc_scale = Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units );
  448. + if( doc_scale > 0 ) {
  449. + doc_scale= 1.0/doc_scale;
  450. + } else {
  451. + doc_scale = 1.0;
  452. + }
  453. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  454. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  455. + SVGElemRef->attach(SVGElem_uri);
  456. + SPObject *elemref = NULL;
  457. + Inkscape::XML::Node *rtspan = NULL;
  458. + if (elemref = SVGElemRef->getObject()) {
  459. + if (remove) {
  460. + elemref->deleteObject();
  461. + return;
  462. + }
  463. + rtext = elemref->getRepr();
  464. + sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
  465. + sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
  466. + } else {
  467. + if (remove) {
  468. + return;
  469. + }
  470. + rtext = xml_doc->createElement("svg:text");
  471. + rtext->setAttribute("xml:space", "preserve");
  472. + rtext->setAttribute("id", ( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  473. + sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
  474. + sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
  475. + rtspan = xml_doc->createElement("svg:tspan");
  476. + rtspan->setAttribute("sodipodi:role", "line");
  477. + }
  478. + gchar * transform;
  479. + if (rotate_anotation) {
  480. + Geom::Affine affine = Geom::Affine(Geom::Translate(pos).inverse());
  481. + angle = std::fmod(angle, 2*M_PI);
  482. + if (angle < 0) angle += 2*M_PI;
  483. + if (angle >= rad_from_deg(90) && angle < rad_from_deg(270)) {
  484. + angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
  485. + if (angle < 0) angle += 2*M_PI;
  486. + }
  487. + affine *= Geom::Rotate(angle);
  488. + affine *= Geom::Translate(pos);
  489. + transform = sp_svg_transform_write(affine);
  490. + } else {
  491. + transform = NULL;
  492. + }
  493. + rtext->setAttribute("transform", transform);
  494. + SPCSSAttr *css = sp_repr_css_attr_new();
  495. + sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
  496. + Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
  497. + fontlister->fill_css( css, (Glib::ustring)fontbutton.param_getSVGValue() );
  498. + std::stringstream font_size;
  499. + font_size.imbue(std::locale::classic());
  500. + font_size << fontsize << "pt";
  501. +
  502. + sp_repr_css_set_property (css, "font-size",font_size.str().c_str());
  503. + sp_repr_css_set_property (css, "line-height","125%");
  504. + sp_repr_css_set_property (css, "letter-spacing","0");
  505. + sp_repr_css_set_property (css, "word-spacing", "0");
  506. + sp_repr_css_set_property (css, "text-align", "center");
  507. + sp_repr_css_set_property (css, "text-anchor", "middle");
  508. + sp_repr_css_set_property (css, "fill", "#000000");
  509. + sp_repr_css_set_property (css, "fill-opacity", "1");
  510. + sp_repr_css_set_property (css, "stroke", "none");
  511. + sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
  512. + Glib::ustring css_str;
  513. + sp_repr_css_write_string(css,css_str);
  514. + if (!rtspan) {
  515. + rtspan = rtext->firstChild();
  516. + }
  517. + rtext->setAttribute("style", css_str.c_str());
  518. + sp_repr_css_attr_unref (css);
  519. + if (!elemref) {
  520. + rtext->addChild(rtspan, NULL);
  521. + Inkscape::GC::release(rtspan);
  522. + }
  523. + length = Inkscape::Util::Quantity::convert(length / doc_scale, display_unit.c_str(), unit.get_abbreviation());
  524. + std::stringstream length_str;
  525. + length_str.precision(precision);
  526. + length_str.setf(std::ios::fixed, std::ios::floatfield);
  527. + if (local_locale) {
  528. + length_str.imbue(std::locale(""));
  529. + } else {
  530. + length_str.imbue(std::locale::classic());
  531. + }
  532. + length_str << std::fixed << length;
  533. + Glib::ustring label_value = Glib::ustring(format.param_getSVGValue());
  534. + size_t s = label_value.find((Glib::ustring)"{measure}",0);
  535. + if(s < label_value.length()) {
  536. + label_value.replace(s,s+9,length_str.str());
  537. + }
  538. + s = label_value.find((Glib::ustring)"{unit}",0);
  539. + if(s < label_value.length()) {
  540. + label_value.replace(s,s+6,unit.get_abbreviation());
  541. + }
  542. + Inkscape::XML::Node *rstring = NULL;
  543. + if (!elemref) {
  544. + rstring = xml_doc->createTextNode(label_value.c_str());
  545. + rtspan->addChild(rstring, NULL);
  546. + Inkscape::GC::release(rstring);
  547. + } else {
  548. + rstring = rtspan->firstChild();
  549. + rstring->setContent(label_value.c_str());
  550. + }
  551. + SPObject * text_obj = NULL;
  552. + if (!elemref) {
  553. + text_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(rtext));
  554. + Inkscape::GC::release(rtext);
  555. + }
  556. + }
  557. +}
  558. +
  559. +void
  560. +LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id, bool main, bool remove)
  561. +{
  562. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  563. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  564. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
  565. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  566. + SVGElemRef->attach(SVGElem_uri);
  567. + SPObject *elemref = NULL;
  568. + Inkscape::XML::Node *line = NULL;
  569. + if (!main) {
  570. + Geom::Ray ray(start, end);
  571. + Geom::Coord angle = ray.angle();
  572. + start = start + Point::polar(angle, helpline_distance );
  573. + end = end + Point::polar(angle, helpline_overlap );
  574. + }
  575. + Geom::Path line_path;
  576. + line_path.start(start);
  577. + line_path.appendNew<Geom::LineSegment>(end);
  578. + Geom::PathVector line_pathv;
  579. + line_pathv.push_back(line_path);
  580. + gchar * line_str = sp_svg_write_path( line_pathv );
  581. + line_pathv.clear();
  582. + if (elemref = SVGElemRef->getObject()) {
  583. + if (remove) {
  584. + elemref->deleteObject();
  585. + return;
  586. + }
  587. + line = elemref->getRepr();
  588. + line->setAttribute("d" , line_str);
  589. + } else {
  590. + if (remove) {
  591. + return;
  592. + }
  593. + line = xml_doc->createElement("svg:path");
  594. + line->setAttribute("id", id.c_str());
  595. + line->setAttribute("d" , line_str);
  596. + }
  597. + Glib::ustring style = (Glib::ustring)"stroke:#000000;fill:none;";
  598. + if (main) {
  599. + line->setAttribute("inkscape:label", "dinline");
  600. + if (arrows_outside) {
  601. + style = style + (Glib::ustring)"marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);";
  602. + } else {
  603. + style = style + (Glib::ustring)"marker-start:url(#ArrowDIN-start);marker-end:url(#ArrowDIN-end);";
  604. + }
  605. + } else {
  606. + line->setAttribute("inkscape:label", "dinhelpline");
  607. + }
  608. + std::stringstream stroke_w;
  609. + stroke_w.imbue(std::locale::classic());
  610. + if (line_group_05) {
  611. + double stroke_width = Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
  612. + stroke_w << stroke_width;
  613. + style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
  614. + } else {
  615. + double stroke_width = Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
  616. + stroke_w << stroke_width;
  617. + style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
  618. + }
  619. + SPCSSAttr *css = sp_repr_css_attr_new();
  620. + sp_repr_css_attr_add_from_string(css, style.c_str());
  621. + if (main) {
  622. + sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
  623. + } else {
  624. + sp_repr_css_attr_add_from_string(css, helperlines_format.param_getSVGValue());
  625. + }
  626. + Glib::ustring css_str;
  627. + sp_repr_css_write_string(css,css_str);
  628. + line->setAttribute("style", css_str.c_str());
  629. + SPObject * line_obj = NULL;
  630. + if (!elemref) {
  631. + line_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(line));
  632. + Inkscape::GC::release(line);
  633. + }
  634. + }
  635. +}
  636. +
  637. +void
  638. +LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
  639. +{
  640. + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  641. + SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem);
  642. + if (sp_path) {
  643. + Geom::PathVector pathvector = sp_path->get_original_curve()->get_pathvector();
  644. + if (arrows_outside) {
  645. + createArrowMarker((Glib::ustring)"ArrowDINout-start");
  646. + createArrowMarker((Glib::ustring)"ArrowDINout-end");
  647. + } else {
  648. + createArrowMarker((Glib::ustring)"ArrowDIN-start");
  649. + createArrowMarker((Glib::ustring)"ArrowDIN-end");
  650. + }
  651. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  652. + if (((Glib::ustring)format.param_getSVGValue()).empty()) {
  653. + format.param_setValue((Glib::ustring)"{measure}{unit}");
  654. + this->upd_params = true;
  655. + }
  656. + size_t ncurves = pathvector.curveCount();
  657. + curve_linked.param_set_range(0, ncurves);
  658. + Geom::Point start = pathvector.initialPoint();
  659. + Geom::Point end = pathvector.finalPoint();
  660. + if (curve_linked) { //!0
  661. + start = pathvector.pointAt(curve_linked -1);
  662. + end = pathvector.pointAt(curve_linked);
  663. + }
  664. + Geom::Point hstart = start;
  665. + Geom::Point hend = end;
  666. + bool remove = false;
  667. + if (Geom::are_near(hstart, hend)) {
  668. + remove = true;
  669. + }
  670. + if (orientation == OM_VERTICAL) {
  671. + Coord xpos = std::max(hstart[Geom::X],hend[Geom::X]);
  672. + if (flip_side) {
  673. + xpos = std::min(hstart[Geom::X],hend[Geom::X]);
  674. + }
  675. + hstart[Geom::X] = xpos;
  676. + hend[Geom::X] = xpos;
  677. + if (hstart[Geom::Y] > hend[Geom::Y]) {
  678. + swap(hstart,hend);
  679. + swap(start,end);
  680. + }
  681. + if (Geom::are_near(hstart[Geom::Y], hend[Geom::Y])) {
  682. + remove = true;
  683. + }
  684. + }
  685. + if (orientation == OM_HORIZONTAL) {
  686. + Coord ypos = std::max(hstart[Geom::Y],hend[Geom::Y]);
  687. + if (flip_side) {
  688. + ypos = std::min(hstart[Geom::Y],hend[Geom::Y]);
  689. + }
  690. + hstart[Geom::Y] = ypos;
  691. + hend[Geom::Y] = ypos;
  692. + if (hstart[Geom::X] < hend[Geom::X]) {
  693. + swap(hstart,hend);
  694. + swap(start,end);
  695. + }
  696. + if (Geom::are_near(hstart[Geom::X], hend[Geom::X])) {
  697. + remove = true;
  698. + }
  699. + }
  700. + double length = Geom::distance(hstart,hend) * scale;
  701. + Geom::Point pos = Geom::middle_point(hstart,hend);
  702. + Geom::Ray ray(hstart,hend);
  703. + Geom::Coord angle = ray.angle();
  704. + if (flip_side) {
  705. + angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
  706. + if (angle < 0) angle += 2*M_PI;
  707. + }
  708. + //We get the font size to offset the text to the middle
  709. + Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue());
  710. + double fontsize = fontdesc.get_size()/(double)Pango::SCALE;
  711. + fontsize *= desktop->doc()->getRoot()->c2p.inverse().expansionX();
  712. + Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
  713. + if (angle_cross < 0) angle_cross += 2*M_PI;
  714. + angle = std::fmod(angle, 2*M_PI);
  715. + if (angle < 0) angle += 2*M_PI;
  716. + if (angle >= rad_from_deg(90) && angle < rad_from_deg(270)) {
  717. + pos = pos - Point::polar(angle_cross, (position - text_distance) + fontsize/2.0);
  718. + } else {
  719. + pos = pos - Point::polar(angle_cross, (position + text_distance) - fontsize/2.0);
  720. + }
  721. + if (!scale_insensitive) {
  722. + Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot()));
  723. + length *= (affinetransform.expansionX() + affinetransform.expansionY()) / 2.0;
  724. + }
  725. + createTextLabel(pos, length, angle, fontsize, remove);
  726. + //LINE
  727. + double arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
  728. + if (line_group_05) {
  729. + arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
  730. + }
  731. + SPCSSAttr *css = sp_repr_css_attr_new();
  732. + sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
  733. + std::setlocale(LC_NUMERIC, std::locale::classic().name().c_str());
  734. + double width_line = atof(sp_repr_css_property(css,"stroke-width","-1"));
  735. + std::setlocale(LC_NUMERIC, std::locale("").name().c_str());
  736. + if (width_line > -0.0001) {
  737. + arrow_gap = 8 * Inkscape::Util::Quantity::convert(width_line/ doc_scale, "mm", display_unit.c_str());
  738. + }
  739. + if (flip_side) {
  740. + arrow_gap *= -1;
  741. + }
  742. + std::cout << arrow_gap << "arrow_gap\n";
  743. + angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
  744. + if (angle_cross < 0) angle_cross += 2*M_PI;
  745. + hstart = hstart - Point::polar(angle_cross, position);
  746. + Glib::ustring id = (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id");
  747. + createLine(start, hstart, id, false, remove);
  748. + hend = hend - Point::polar(angle_cross, position);
  749. + id = (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id");
  750. + createLine(end, hend, id, false, remove);
  751. + if (!arrows_outside) {
  752. + hstart = hstart + Point::polar(angle, arrow_gap);
  753. + hend = hend - Point::polar(angle, arrow_gap );
  754. + }
  755. + id = (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id");
  756. + createLine(hstart, hend, id, true, remove);
  757. + }
  758. + }
  759. +}
  760. +
  761. +void LPEMeasureLine::doOnRemove (SPLPEItem const* lpeitem)
  762. +{
  763. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  764. + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  765. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  766. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  767. + SVGElemRef->attach(SVGElem_uri);
  768. + SPObject *elemref = NULL;
  769. + if (elemref = SVGElemRef->getObject()) {
  770. + elemref->deleteObject();
  771. + }
  772. + Inkscape::URI SVGElem_uri2(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  773. + SVGElemRef->attach(SVGElem_uri2);
  774. + elemref = NULL;
  775. + if (elemref = SVGElemRef->getObject()) {
  776. + elemref->deleteObject();
  777. + }
  778. + Inkscape::URI SVGElem_uri3(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  779. + SVGElemRef->attach(SVGElem_uri3);
  780. + elemref = NULL;
  781. + if (elemref = SVGElemRef->getObject()) {
  782. + elemref->deleteObject();
  783. + }
  784. + Inkscape::URI SVGElem_uri4(((Glib::ustring)"#" + (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  785. + SVGElemRef->attach(SVGElem_uri4);
  786. + elemref = NULL;
  787. + if (elemref = SVGElemRef->getObject()) {
  788. + elemref->deleteObject();
  789. + }
  790. + }
  791. +}
  792. +
  793. +Gtk::Widget *LPEMeasureLine::newWidget()
  794. +{
  795. + // use manage here, because after deletion of Effect object, others might
  796. + // still be pointing to this widget.
  797. + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
  798. +
  799. + vbox->set_border_width(5);
  800. + vbox->set_homogeneous(false);
  801. + vbox->set_spacing(2);
  802. +
  803. + std::vector<Parameter *>::iterator it = param_vector.begin();
  804. + Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0));
  805. + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
  806. + vbox_expander->set_border_width(0);
  807. + vbox_expander->set_spacing(2);
  808. + while (it != param_vector.end()) {
  809. + if ((*it)->widget_is_visible) {
  810. + Parameter *param = *it;
  811. + Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
  812. + Glib::ustring *tip = param->param_getTooltip();
  813. + if (widg) {
  814. + if (param->param_key != "dimline_format" &&
  815. + param->param_key != "helperlines_format" &&
  816. + param->param_key != "arrows_format" &&
  817. + param->param_key != "anotation_format") {
  818. + vbox->pack_start(*widg, true, true, 2);
  819. + } else {
  820. + vbox_expander->pack_start(*widg, true, true, 2);
  821. + }
  822. + if (tip) {
  823. + widg->set_tooltip_text(*tip);
  824. + } else {
  825. + widg->set_tooltip_text("");
  826. + widg->set_has_tooltip(false);
  827. + }
  828. + }
  829. + }
  830. +
  831. + ++it;
  832. + }
  833. + Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default"))));
  834. + save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault));
  835. + button1->pack_start(*save_default, true, true, 2);
  836. + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override"))));
  837. + expander->add(*vbox_expander);
  838. + expander->set_expanded(expanded);
  839. + expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) );
  840. + vbox->pack_start(*expander, true, true, 2);
  841. + vbox->pack_start(*button1, true, true, 2);
  842. + return dynamic_cast<Gtk::Widget *>(vbox);
  843. +}
  844. +
  845. +void
  846. +LPEMeasureLine::onExpanderChanged()
  847. +{
  848. + expanded = expander->get_expanded();
  849. + if(expanded) {
  850. + expander->set_label (Glib::ustring(_("Hide DIM CSS style override")));
  851. + } else {
  852. + expander->set_label (Glib::ustring(_("Show DIM CSS style override")));
  853. + }
  854. +}
  855. +
  856. +Geom::PathVector
  857. +LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in)
  858. +{
  859. + return path_in;
  860. +}
  861. +
  862. +void
  863. +LPEMeasureLine::saveDefault()
  864. +{
  865. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  866. + prefs->setString("/live_effects/measure-line/fontbutton", (Glib::ustring)fontbutton.param_getSVGValue());
  867. + prefs->setDouble("/live_effects/measure-line/scale", scale);
  868. + prefs->setInt("/live_effects/measure-line/precision", precision);
  869. + prefs->setDouble("/live_effects/measure-line/position", position);
  870. + prefs->setDouble("/live_effects/measure-line/text_distance", text_distance);
  871. + prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance);
  872. + prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap);
  873. + prefs->setString("/live_effects/measure-line/unit", (Glib::ustring)unit.get_abbreviation());
  874. + prefs->setString("/live_effects/measure-line/format", (Glib::ustring)format.param_getSVGValue());
  875. + prefs->setString("/live_effects/measure-line/dimline_format", (Glib::ustring)dimline_format.param_getSVGValue());
  876. + prefs->setString("/live_effects/measure-line/helperlines_format", (Glib::ustring)helperlines_format.param_getSVGValue());
  877. + prefs->setString("/live_effects/measure-line/anotation_format", (Glib::ustring)anotation_format.param_getSVGValue());
  878. + prefs->setString("/live_effects/measure-line/arrows_format", (Glib::ustring)arrows_format.param_getSVGValue());
  879. + prefs->setBool("/live_effects/measure-line/flip_side", flip_side);
  880. + prefs->setBool("/live_effects/measure-line/scale_insensitive", scale_insensitive);
  881. + prefs->setBool("/live_effects/measure-line/local_locale", local_locale);
  882. + prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05);
  883. + prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation);
  884. +}
  885. +
  886. +}; //namespace LivePathEffect
  887. +}; /* namespace Inkscape */
  888. +
  889. +/*
  890. + Local Variables:
  891. + mode:c++
  892. + c-file-style:"stroustrup"
  893. + c-file-offset:((innamespace . 0)(inline-open . 0)(case-label . +))
  894. + indent-tabs-mode:nil
  895. + fill-column:99
  896. + End:
  897. +*/
  898. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  899. === added file 'src/live_effects/lpe-measure-line.h'
  900. --- src/live_effects/lpe-measure-line.h 1970-01-01 00:00:00 +0000
  901. +++ src/live_effects/lpe-measure-line.h 2016-08-01 14:15:18 +0000
  902. @@ -0,0 +1,96 @@
  903. +#ifndef INKSCAPE_LPE_MEASURE_LINE_H
  904. +#define INKSCAPE_LPE_MEASURE_LINE_H
  905. +
  906. +/*
  907. + * Author(s):
  908. + * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
  909. + *
  910. + * Copyright (C) 2014 Author(s)
  911. + *
  912. + * Released under GNU GPL, read the file 'COPYING' for more information
  913. + */
  914. +
  915. +#include "live_effects/effect.h"
  916. +#include "live_effects/parameter/enum.h"
  917. +#include "live_effects/parameter/fontbutton.h"
  918. +#include "live_effects/parameter/text.h"
  919. +#include "live_effects/parameter/unit.h"
  920. +#include "live_effects/parameter/bool.h"
  921. +#include "live_effects/parameter/originalpath.h"
  922. +#include <libnrtype/font-lister.h>
  923. +#include <2geom/angle.h>
  924. +#include <2geom/ray.h>
  925. +#include <2geom/point.h>
  926. +
  927. +namespace Inkscape {
  928. +namespace LivePathEffect {
  929. +
  930. +enum OrientationMethod {
  931. + OM_HORIZONTAL,
  932. + OM_VERTICAL,
  933. + OM_PARALLEL,
  934. + OM_END
  935. +};
  936. +
  937. +class LPEMeasureLine : public Effect {
  938. +public:
  939. + LPEMeasureLine(LivePathEffectObject *lpeobject);
  940. + virtual ~LPEMeasureLine();
  941. + virtual void doBeforeEffect (SPLPEItem const* lpeitem);
  942. + virtual void doOnApply(SPLPEItem const* lpeitem);
  943. + virtual void doOnRemove (SPLPEItem const* lpeitem);
  944. + virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
  945. + virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
  946. + void createLine(Geom::Point start,Geom::Point end,Glib::ustring id, bool main, bool remove);
  947. + void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, double fontsize, bool remove);
  948. + void onExpanderChanged();
  949. + void createArrowMarker(Glib::ustring mode);
  950. + void saveDefault();
  951. + virtual Gtk::Widget *newWidget();
  952. +private:
  953. + UnitParam unit;
  954. + FontButtonParam fontbutton;
  955. + EnumParam<OrientationMethod> orientation;
  956. + ScalarParam curve_linked;
  957. + ScalarParam precision;
  958. + ScalarParam position;
  959. + ScalarParam text_distance;
  960. + ScalarParam helpline_distance;
  961. + ScalarParam helpline_overlap;
  962. + ScalarParam scale;
  963. + TextParam format;
  964. + BoolParam arrows_outside;
  965. + BoolParam flip_side;
  966. + BoolParam scale_insensitive;
  967. + BoolParam local_locale;
  968. + BoolParam line_group_05;
  969. + BoolParam rotate_anotation;
  970. + TextParam dimline_format;
  971. + TextParam helperlines_format;
  972. + TextParam anotation_format;
  973. + TextParam arrows_format;
  974. + Glib::ustring display_unit;
  975. + bool expanded;
  976. + Gtk::Expander * expander;
  977. + double doc_scale;
  978. +/* Geom::Affine affine_over;*/
  979. + LPEMeasureLine(const LPEMeasureLine &);
  980. + LPEMeasureLine &operator=(const LPEMeasureLine &);
  981. +
  982. +};
  983. +
  984. +} //namespace LivePathEffect
  985. +} //namespace Inkscape
  986. +
  987. +#endif
  988. +
  989. +/*
  990. + Local Variables:
  991. + mode:c++
  992. + c-file-style:"stroustrup"
  993. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  994. + indent-tabs-mode:nil
  995. + fill-column:99
  996. + End:
  997. +*/
  998. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  999. === modified file 'src/live_effects/lpe-transform_2pts.cpp'
  1000. --- src/live_effects/lpe-transform_2pts.cpp 2016-07-28 11:26:17 +0000
  1001. +++ src/live_effects/lpe-transform_2pts.cpp 2016-07-24 16:00:12 +0000
  1002. @@ -90,7 +90,6 @@
  1003. {
  1004. using namespace Geom;
  1005. original_bbox(lpeitem);
  1006. -
  1007. point_a = Point(boundingbox_X.min(), boundingbox_Y.middle());
  1008. point_b = Point(boundingbox_X.max(), boundingbox_Y.middle());
  1009. SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  1010. === modified file 'src/live_effects/parameter/Makefile_insert'
  1011. --- src/live_effects/parameter/Makefile_insert 2015-03-02 01:29:50 +0000
  1012. +++ src/live_effects/parameter/Makefile_insert 2016-07-29 21:24:09 +0000
  1013. @@ -11,6 +11,8 @@
  1014. live_effects/parameter/random.h \
  1015. live_effects/parameter/point.cpp \
  1016. live_effects/parameter/point.h \
  1017. + live_effects/parameter/fontbutton.cpp \
  1018. + live_effects/parameter/fontbutton.h \
  1019. live_effects/parameter/enum.h \
  1020. live_effects/parameter/path-reference.cpp \
  1021. live_effects/parameter/path-reference.h \
  1022. === modified file 'src/live_effects/parameter/bool.cpp'
  1023. --- src/live_effects/parameter/bool.cpp 2015-10-18 19:13:13 +0000
  1024. +++ src/live_effects/parameter/bool.cpp 2016-07-24 23:27:14 +0000
  1025. @@ -36,6 +36,12 @@
  1026. param_setValue(defvalue);
  1027. }
  1028. +void
  1029. +BoolParam::param_update_default(bool const default_value)
  1030. +{
  1031. + defvalue = default_value;
  1032. +}
  1033. +
  1034. bool
  1035. BoolParam::param_readSVGValue(const gchar * strvalue)
  1036. {
  1037. === modified file 'src/live_effects/parameter/bool.h'
  1038. --- src/live_effects/parameter/bool.h 2015-10-18 19:13:13 +0000
  1039. +++ src/live_effects/parameter/bool.h 2016-07-24 23:26:29 +0000
  1040. @@ -36,7 +36,7 @@
  1041. void param_setValue(bool newvalue);
  1042. virtual void param_set_default();
  1043. -
  1044. + void param_update_default(bool const default_value);
  1045. bool get_value() const { return value; };
  1046. inline operator bool() const { return value; };
  1047. === modified file 'src/live_effects/parameter/enum.h'
  1048. --- src/live_effects/parameter/enum.h 2014-03-27 01:33:44 +0000
  1049. +++ src/live_effects/parameter/enum.h 2016-07-29 18:13:50 +0000
  1050. @@ -27,12 +27,14 @@
  1051. const Util::EnumDataConverter<E>& c,
  1052. Inkscape::UI::Widget::Registry* wr,
  1053. Effect* effect,
  1054. - E default_value)
  1055. + E default_value,
  1056. + bool sort = true)
  1057. : Parameter(label, tip, key, wr, effect)
  1058. {
  1059. enumdataconv = &c;
  1060. defvalue = default_value;
  1061. value = defvalue;
  1062. + sorted = sort;
  1063. };
  1064. virtual ~EnumParam() { };
  1065. @@ -40,12 +42,11 @@
  1066. virtual Gtk::Widget * param_newWidget() {
  1067. Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage (
  1068. new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
  1069. - param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
  1070. + param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) );
  1071. regenum->set_active_by_id(value);
  1072. regenum->combobox()->setProgrammatically = false;
  1073. regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
  1074. -
  1075. return dynamic_cast<Gtk::Widget *> (regenum);
  1076. };
  1077. @@ -86,6 +87,7 @@
  1078. E value;
  1079. E defvalue;
  1080. + bool sorted;
  1081. const Util::EnumDataConverter<E> * enumdataconv;
  1082. };
  1083. === added file 'src/live_effects/parameter/fontbutton.cpp'
  1084. --- src/live_effects/parameter/fontbutton.cpp 1970-01-01 00:00:00 +0000
  1085. +++ src/live_effects/parameter/fontbutton.cpp 2016-07-29 21:26:48 +0000
  1086. @@ -0,0 +1,92 @@
  1087. +/*
  1088. + * Authors:
  1089. + *
  1090. + * Released under GNU GPL, read the file 'COPYING' for more information
  1091. + */
  1092. +
  1093. +
  1094. +#include "ui/widget/registered-widget.h"
  1095. +#include "live_effects/parameter/fontbutton.h"
  1096. +#include "live_effects/effect.h"
  1097. +#include "ui/widget/font-button.h"
  1098. +#include "svg/svg.h"
  1099. +#include "svg/stringstream.h"
  1100. +#include "verbs.h"
  1101. +
  1102. +#include <glibmm/i18n.h>
  1103. +
  1104. +namespace Inkscape {
  1105. +
  1106. +namespace LivePathEffect {
  1107. +
  1108. +FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
  1109. + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
  1110. + Effect* effect, const Glib::ustring default_value )
  1111. + : Parameter(label, tip, key, wr, effect),
  1112. + value(default_value),
  1113. + defvalue(default_value)
  1114. +{
  1115. +}
  1116. +
  1117. +void
  1118. +FontButtonParam::param_set_default()
  1119. +{
  1120. + param_setValue(defvalue);
  1121. +}
  1122. +void
  1123. +FontButtonParam::param_update_default(const Glib::ustring default_value){
  1124. + defvalue = default_value;
  1125. +}
  1126. +
  1127. +bool
  1128. +FontButtonParam::param_readSVGValue(const gchar * strvalue)
  1129. +{
  1130. + Inkscape::SVGOStringStream os;
  1131. + os << strvalue;
  1132. + param_setValue((Glib::ustring)os.str());
  1133. + return true;
  1134. +}
  1135. +
  1136. +gchar *
  1137. +FontButtonParam::param_getSVGValue() const
  1138. +{
  1139. + return g_strdup(value.c_str());
  1140. +}
  1141. +
  1142. +Gtk::Widget *
  1143. +FontButtonParam::param_newWidget()
  1144. +{
  1145. + Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage(
  1146. + new Inkscape::UI::Widget::RegisteredFontButton( param_label,
  1147. + param_tooltip,
  1148. + param_key,
  1149. + *param_wr,
  1150. + param_effect->getRepr(),
  1151. + param_effect->getSPDoc() ) );
  1152. + Glib::ustring fontspec = param_getSVGValue();
  1153. + fontbuttonwdg->setValue( fontspec);
  1154. + fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter"));
  1155. + param_effect->upd_params = false;
  1156. + return dynamic_cast<Gtk::Widget *> (fontbuttonwdg);
  1157. +}
  1158. +
  1159. +void
  1160. +FontButtonParam::param_setValue(const Glib::ustring newvalue)
  1161. +{
  1162. + value = newvalue;
  1163. +}
  1164. +
  1165. +} /* namespace LivePathEffect */
  1166. +
  1167. +} /* namespace Inkscape */
  1168. +
  1169. +/*
  1170. + Local Variables:
  1171. + mode:c++
  1172. + c-file-style:"stroustrup"
  1173. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1174. + indent-tabs-mode:nil
  1175. + fill-column:99
  1176. + End:
  1177. +*/
  1178. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1179. === added file 'src/live_effects/parameter/fontbutton.h'
  1180. --- src/live_effects/parameter/fontbutton.h 1970-01-01 00:00:00 +0000
  1181. +++ src/live_effects/parameter/fontbutton.h 2016-07-29 20:44:37 +0000
  1182. @@ -0,0 +1,62 @@
  1183. +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
  1184. +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
  1185. +
  1186. +/*
  1187. + * Inkscape::LivePathEffectParameters
  1188. + *
  1189. + * Authors:
  1190. + * Released under GNU GPL, read the file 'COPYING' for more information
  1191. + */
  1192. +#include <glib.h>
  1193. +#include <gtkmm.h>
  1194. +#include "live_effects/parameter/parameter.h"
  1195. +
  1196. +namespace Inkscape {
  1197. +
  1198. +namespace LivePathEffect {
  1199. +
  1200. +class FontButtonParam : public Parameter {
  1201. +public:
  1202. + FontButtonParam( const Glib::ustring& label,
  1203. + const Glib::ustring& tip,
  1204. + const Glib::ustring& key,
  1205. + Inkscape::UI::Widget::Registry* wr,
  1206. + Effect* effect,
  1207. + const Glib::ustring default_value = "");
  1208. + virtual ~FontButtonParam() {}
  1209. +
  1210. + virtual Gtk::Widget * param_newWidget();
  1211. + virtual bool param_readSVGValue(const gchar * strvalue);
  1212. + void param_update_default(const Glib::ustring defvalue);
  1213. + virtual gchar * param_getSVGValue() const;
  1214. +
  1215. + void param_setValue(const Glib::ustring newvalue);
  1216. +
  1217. + virtual void param_set_default();
  1218. +
  1219. + const Glib::ustring get_value() const { return defvalue; };
  1220. +
  1221. +private:
  1222. + FontButtonParam(const FontButtonParam&);
  1223. + FontButtonParam& operator=(const FontButtonParam&);
  1224. + Glib::ustring value;
  1225. + Glib::ustring defvalue;
  1226. +
  1227. +};
  1228. +
  1229. +} //namespace LivePathEffect
  1230. +
  1231. +} //namespace Inkscape
  1232. +
  1233. +#endif
  1234. +
  1235. +/*
  1236. + Local Variables:
  1237. + mode:c++
  1238. + c-file-style:"stroustrup"
  1239. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1240. + indent-tabs-mode:nil
  1241. + fill-column:99
  1242. + End:
  1243. +*/
  1244. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1245. === modified file 'src/live_effects/parameter/parameter.cpp'
  1246. --- src/live_effects/parameter/parameter.cpp 2015-10-18 19:13:13 +0000
  1247. +++ src/live_effects/parameter/parameter.cpp 2016-07-30 16:08:21 +0000
  1248. @@ -4,11 +4,9 @@
  1249. * Released under GNU GPL, read the file 'COPYING' for more information
  1250. */
  1251. -#include "ui/widget/registered-widget.h"
  1252. -#include <glibmm/i18n.h>
  1253. +#include "live_effects/effect.h"
  1254. #include "live_effects/parameter/parameter.h"
  1255. -#include "live_effects/effect.h"
  1256. #include "svg/svg.h"
  1257. #include "xml/repr.h"
  1258. @@ -16,6 +14,8 @@
  1259. #include "verbs.h"
  1260. +#include <glibmm/i18n.h>
  1261. +
  1262. #define noLPEREALPARAM_DEBUG
  1263. namespace Inkscape {
  1264. @@ -101,9 +101,16 @@
  1265. param_set_value(defvalue);
  1266. }
  1267. +void
  1268. +ScalarParam::param_update_default(gdouble default_value)
  1269. +{
  1270. + defvalue = default_value;
  1271. +}
  1272. +
  1273. void
  1274. ScalarParam::param_set_value(gdouble val)
  1275. {
  1276. + param_effect->upd_params = true;
  1277. value = val;
  1278. if (integer)
  1279. value = round(value);
  1280. @@ -121,7 +128,7 @@
  1281. // Once again, in gtk2, this is not a problem. But in gtk3,
  1282. // widgets get allocated the amount of size they ask for,
  1283. // leading to excessively long widgets.
  1284. -
  1285. + param_effect->upd_params = true;
  1286. if (min >= -SCALARPARAM_G_MAXDOUBLE) {
  1287. this->min = min;
  1288. } else {
  1289. @@ -130,15 +137,15 @@
  1290. if (max <= SCALARPARAM_G_MAXDOUBLE) {
  1291. this->max = max;
  1292. } else {
  1293. - this->max = SCALARPARAM_G_MAXDOUBLE;
  1294. + this->max = SCALARPARAM_G_MAXDOUBLE;
  1295. }
  1296. -
  1297. param_set_value(value); // reset value to see whether it is in ranges
  1298. }
  1299. void
  1300. ScalarParam::param_make_integer(bool yes)
  1301. {
  1302. + param_effect->upd_params = true;
  1303. integer = yes;
  1304. digits = 0;
  1305. inc_step = 1;
  1306. @@ -169,6 +176,7 @@
  1307. if(!overwrite_widget){
  1308. rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
  1309. }
  1310. + param_effect->upd_params = false;
  1311. return dynamic_cast<Gtk::Widget *> (rsu);
  1312. } else {
  1313. return NULL;
  1314. @@ -178,12 +186,14 @@
  1315. void
  1316. ScalarParam::param_set_digits(unsigned digits)
  1317. {
  1318. + param_effect->upd_params = true;
  1319. this->digits = digits;
  1320. }
  1321. void
  1322. ScalarParam::param_set_increments(double step, double page)
  1323. {
  1324. + param_effect->upd_params = true;
  1325. inc_step = step;
  1326. inc_page = page;
  1327. }
  1328. === modified file 'src/live_effects/parameter/parameter.h'
  1329. --- src/live_effects/parameter/parameter.h 2015-10-18 19:13:13 +0000
  1330. +++ src/live_effects/parameter/parameter.h 2016-07-30 16:05:28 +0000
  1331. @@ -12,6 +12,7 @@
  1332. #include <glibmm/ustring.h>
  1333. #include <2geom/forward.h>
  1334. #include <2geom/pathvector.h>
  1335. +#include "ui/widget/registered-widget.h"
  1336. // In gtk2, this wasn't an issue; we could toss around
  1337. // G_MAXDOUBLE and not worry about size allocations. But
  1338. @@ -110,12 +111,12 @@
  1339. virtual gchar * param_getSVGValue() const;
  1340. virtual void param_set_default();
  1341. + void param_update_default(gdouble default_value);
  1342. void param_set_value(gdouble val);
  1343. void param_make_integer(bool yes = true);
  1344. void param_set_range(gdouble min, gdouble max);
  1345. void param_set_digits(unsigned digits);
  1346. void param_set_increments(double step, double page);
  1347. -
  1348. void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; };
  1349. void param_overwrite_widget(bool overwrite_widget);
  1350. === modified file 'src/live_effects/parameter/point.cpp'
  1351. --- src/live_effects/parameter/point.cpp 2016-01-17 19:18:53 +0000
  1352. +++ src/live_effects/parameter/point.cpp 2016-07-29 09:36:40 +0000
  1353. @@ -4,7 +4,6 @@
  1354. * Released under GNU GPL, read the file 'COPYING' for more information
  1355. */
  1356. -#include "ui/widget/registered-widget.h"
  1357. #include "live_effects/parameter/point.h"
  1358. #include "live_effects/effect.h"
  1359. #include "svg/svg.h"
  1360. @@ -30,7 +29,8 @@
  1361. : Parameter(label, tip, key, wr, effect),
  1362. defvalue(default_value),
  1363. liveupdate(live_update),
  1364. - knoth(NULL)
  1365. + knoth(NULL),
  1366. + _pointwdg(NULL)
  1367. {
  1368. knot_shape = SP_KNOT_SHAPE_DIAMOND;
  1369. knot_mode = SP_KNOT_MODE_XOR;
  1370. @@ -62,9 +62,9 @@
  1371. }
  1372. void
  1373. -PointParam::param_update_default(Geom::Point newpoint)
  1374. +PointParam::param_update_default(const Geom::Point default_point)
  1375. {
  1376. - defvalue = newpoint;
  1377. + defvalue = default_point;
  1378. }
  1379. void
  1380. @@ -81,6 +81,9 @@
  1381. if(knoth && liveupdate){
  1382. knoth->update_knots();
  1383. }
  1384. + if (_pointwdg) {
  1385. + _pointwdg->setValue( newpoint );
  1386. + }
  1387. }
  1388. bool
  1389. @@ -116,7 +119,7 @@
  1390. Gtk::Widget *
  1391. PointParam::param_newWidget()
  1392. {
  1393. - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
  1394. + _pointwdg = Gtk::manage(
  1395. new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
  1396. param_tooltip,
  1397. param_key,
  1398. @@ -126,15 +129,15 @@
  1399. // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
  1400. SPDesktop *desktop = SP_ACTIVE_DESKTOP;
  1401. Geom::Affine transf = desktop->doc2dt();
  1402. - pointwdg->setTransform(transf);
  1403. - pointwdg->setValue( *this );
  1404. - pointwdg->clearProgrammatically();
  1405. - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
  1406. + _pointwdg->setTransform(transf);
  1407. + _pointwdg->setValue( *this );
  1408. + _pointwdg->clearProgrammatically();
  1409. + _pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
  1410. Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
  1411. - static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
  1412. + static_cast<Gtk::HBox*>(hbox)->pack_start(*_pointwdg, true, true);
  1413. static_cast<Gtk::HBox*>(hbox)->show_all_children();
  1414. -
  1415. + param_effect->upd_params = false;
  1416. return dynamic_cast<Gtk::Widget *> (hbox);
  1417. }
  1418. @@ -191,13 +194,13 @@
  1419. PointParamKnotHolderEntity::knot_click(guint state)
  1420. {
  1421. if (state & GDK_CONTROL_MASK) {
  1422. - if (state & GDK_MOD1_MASK) {
  1423. - this->pparam->param_set_default();
  1424. - SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
  1425. - if(splpeitem){
  1426. - sp_lpe_item_update_patheffect(splpeitem, false, false);
  1427. - }
  1428. + if (state & GDK_MOD1_MASK) {
  1429. + this->pparam->param_set_default();
  1430. + SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
  1431. + if(splpeitem){
  1432. + sp_lpe_item_update_patheffect(splpeitem, false, false);
  1433. }
  1434. + }
  1435. }
  1436. }
  1437. === modified file 'src/live_effects/parameter/point.h'
  1438. --- src/live_effects/parameter/point.h 2016-01-17 19:18:53 +0000
  1439. +++ src/live_effects/parameter/point.h 2016-07-29 09:28:12 +0000
  1440. @@ -11,7 +11,7 @@
  1441. #include <glib.h>
  1442. #include <2geom/point.h>
  1443. -
  1444. +#include "ui/widget/registered-widget.h"
  1445. #include "live_effects/parameter/parameter.h"
  1446. #include "knot-holder-entity.h"
  1447. @@ -43,7 +43,7 @@
  1448. void param_set_default();
  1449. Geom::Point param_get_default() const;
  1450. void param_set_liveupdate(bool live_update);
  1451. - void param_update_default(Geom::Point newpoint);
  1452. + void param_update_default(const Geom::Point default_point);
  1453. virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
  1454. void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
  1455. @@ -62,6 +62,7 @@
  1456. SPKnotModeType knot_mode;
  1457. guint32 knot_color;
  1458. gchar *handle_tip;
  1459. + Inkscape::UI::Widget::RegisteredTransformedPoint * _pointwdg;
  1460. };
  1461. === modified file 'src/live_effects/parameter/text.cpp'
  1462. --- src/live_effects/parameter/text.cpp 2014-12-21 21:58:32 +0000
  1463. +++ src/live_effects/parameter/text.cpp 2016-07-31 22:44:32 +0000
  1464. @@ -31,12 +31,16 @@
  1465. Effect* effect, const Glib::ustring default_value )
  1466. : Parameter(label, tip, key, wr, effect),
  1467. value(default_value),
  1468. - defvalue(default_value)
  1469. + defvalue(default_value),
  1470. + _hide_canvas_text(false)
  1471. {
  1472. - SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this!
  1473. - canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
  1474. - sp_canvastext_set_text (canvas_text, default_value.c_str());
  1475. - sp_canvastext_set_coords (canvas_text, 0, 0);
  1476. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this!
  1477. + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
  1478. + sp_canvastext_set_text (canvas_text, default_value.c_str());
  1479. + sp_canvastext_set_coords (canvas_text, 0, 0);
  1480. + } else {
  1481. + _hide_canvas_text = true;
  1482. + }
  1483. }
  1484. void
  1485. @@ -46,9 +50,26 @@
  1486. }
  1487. void
  1488. +TextParam::param_update_default(Glib::ustring default_value)
  1489. +{
  1490. + defvalue = default_value;
  1491. +}
  1492. +
  1493. +void
  1494. +TextParam::param_hide_canvas_text()
  1495. +{
  1496. + if (!_hide_canvas_text) {
  1497. + sp_canvastext_set_text(canvas_text, " ");
  1498. + _hide_canvas_text = true;
  1499. + }
  1500. +}
  1501. +
  1502. +void
  1503. TextParam::setPos(Geom::Point pos)
  1504. {
  1505. - sp_canvastext_set_coords (canvas_text, pos);
  1506. + if (!_hide_canvas_text) {
  1507. + sp_canvastext_set_coords (canvas_text, pos);
  1508. + }
  1509. }
  1510. void
  1511. @@ -63,9 +84,10 @@
  1512. Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
  1513. Point n = -rot90(dir);
  1514. double angle = Geom::angle_between(dir, Point(1,0));
  1515. -
  1516. - sp_canvastext_set_coords(canvas_text, pos + n * length);
  1517. - sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
  1518. + if (!_hide_canvas_text) {
  1519. + sp_canvastext_set_coords(canvas_text, pos + n * length);
  1520. + sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
  1521. + }
  1522. }
  1523. void
  1524. @@ -73,7 +95,9 @@
  1525. {
  1526. anchor_x = x_value;
  1527. anchor_y = y_value;
  1528. - sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
  1529. + if (!_hide_canvas_text) {
  1530. + sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
  1531. + }
  1532. }
  1533. bool
  1534. @@ -94,8 +118,7 @@
  1535. {
  1536. Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText(
  1537. param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()));
  1538. -
  1539. - rsu->setText(value.c_str());
  1540. + rsu->setText(value);
  1541. rsu->setProgrammatically = false;
  1542. rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter"));
  1543. @@ -107,8 +130,9 @@
  1544. TextParam::param_setValue(const Glib::ustring newvalue)
  1545. {
  1546. value = newvalue;
  1547. -
  1548. - sp_canvastext_set_text (canvas_text, newvalue.c_str());
  1549. + if (!_hide_canvas_text) {
  1550. + sp_canvastext_set_text (canvas_text, newvalue.c_str());
  1551. + }
  1552. }
  1553. } /* namespace LivePathEffect */
  1554. === modified file 'src/live_effects/parameter/text.h'
  1555. --- src/live_effects/parameter/text.h 2014-03-27 01:33:44 +0000
  1556. +++ src/live_effects/parameter/text.h 2016-07-31 02:24:55 +0000
  1557. @@ -40,7 +40,9 @@
  1558. virtual gchar * param_getSVGValue() const;
  1559. void param_setValue(const Glib::ustring newvalue);
  1560. + void param_hide_canvas_text();
  1561. virtual void param_set_default();
  1562. + void param_update_default(Glib::ustring default_value);
  1563. void setPos(Geom::Point pos);
  1564. void setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
  1565. const double t, const double length, bool use_curvature = false);
  1566. @@ -53,7 +55,7 @@
  1567. TextParam& operator=(const TextParam&);
  1568. double anchor_x;
  1569. double anchor_y;
  1570. -
  1571. + bool _hide_canvas_text;
  1572. Glib::ustring value;
  1573. Glib::ustring defvalue;
  1574. === modified file 'src/live_effects/parameter/togglebutton.cpp'
  1575. --- src/live_effects/parameter/togglebutton.cpp 2016-07-24 15:05:29 +0000
  1576. +++ src/live_effects/parameter/togglebutton.cpp 2016-07-24 16:53:55 +0000
  1577. @@ -12,6 +12,7 @@
  1578. #include "live_effects/effect.h"
  1579. #include "svg/svg.h"
  1580. #include "svg/stringstream.h"
  1581. +#include "selection.h"
  1582. #include "widgets/icon.h"
  1583. #include "inkscape.h"
  1584. #include "verbs.h"
  1585. @@ -108,13 +109,14 @@
  1586. }else{
  1587. gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
  1588. }
  1589. +
  1590. checkwdg->add(*Gtk::manage(Glib::wrap(box_button)));
  1591. checkwdg->setActive(value);
  1592. checkwdg->setProgrammatically = false;
  1593. checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
  1594. _toggled_connection = checkwdg->signal_toggled().connect(sigc::mem_fun(*this, &ToggleButtonParam::toggled));
  1595. -
  1596. + param_effect->upd_params = false;
  1597. return checkwdg;
  1598. }
  1599. @@ -161,6 +163,12 @@
  1600. void
  1601. ToggleButtonParam::toggled() {
  1602. + //Force redraw for update widgets
  1603. + param_effect->upd_params = true;
  1604. + if (SP_ACTIVE_DESKTOP) {
  1605. + Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
  1606. + selection ->emitModified();
  1607. + }
  1608. _signal_toggled.emit();
  1609. }
  1610. === modified file 'src/live_effects/parameter/unit.cpp'
  1611. --- src/live_effects/parameter/unit.cpp 2014-03-27 01:33:44 +0000
  1612. +++ src/live_effects/parameter/unit.cpp 2016-07-24 23:34:35 +0000
  1613. @@ -54,6 +54,12 @@
  1614. param_set_value(*defunit);
  1615. }
  1616. +void
  1617. +UnitParam::param_update_default(const Glib::ustring default_unit)
  1618. +{
  1619. + defunit = unit_table.getUnit(default_unit);
  1620. +}
  1621. +
  1622. void
  1623. UnitParam::param_set_value(Inkscape::Util::Unit const &val)
  1624. {
  1625. === modified file 'src/live_effects/parameter/unit.h'
  1626. --- src/live_effects/parameter/unit.h 2014-03-27 01:33:44 +0000
  1627. +++ src/live_effects/parameter/unit.h 2016-07-24 23:34:56 +0000
  1628. @@ -33,6 +33,7 @@
  1629. virtual gchar * param_getSVGValue() const;
  1630. virtual void param_set_default();
  1631. void param_set_value(Inkscape::Util::Unit const &val);
  1632. + void param_update_default(const Glib::ustring default_unit);
  1633. const gchar *get_abbreviation() const;
  1634. virtual Gtk::Widget * param_newWidget();
  1635. === modified file 'src/selection.cpp'
  1636. --- src/selection.cpp 2016-07-28 11:26:17 +0000
  1637. +++ src/selection.cpp 2016-07-24 16:00:12 +0000
  1638. @@ -282,6 +282,11 @@
  1639. _emitChanged();
  1640. }
  1641. +void Selection::emitModified()
  1642. +{
  1643. + _emitChanged();
  1644. +}
  1645. +
  1646. std::vector<SPObject*> const &Selection::list() {
  1647. if(!_objs_vector.empty())
  1648. return _objs_vector;
  1649. === modified file 'src/selection.h'
  1650. --- src/selection.h 2016-07-28 11:26:17 +0000
  1651. +++ src/selection.h 2016-07-24 16:00:12 +0000
  1652. @@ -192,6 +192,11 @@
  1653. void clear();
  1654. /**
  1655. + * Emmit modified signal
  1656. + */
  1657. + void emitModified();
  1658. +
  1659. + /**
  1660. * Returns true if no items are selected.
  1661. */
  1662. bool isEmpty() const { return _objs.empty(); }
  1663. === modified file 'src/ui/CMakeLists.txt'
  1664. --- src/ui/CMakeLists.txt 2016-02-07 15:49:01 +0000
  1665. +++ src/ui/CMakeLists.txt 2016-07-29 21:24:51 +0000
  1666. @@ -128,6 +128,7 @@
  1667. widget/entity-entry.cpp
  1668. widget/entry.cpp
  1669. widget/filter-effect-chooser.cpp
  1670. + widget/font-button.cpp
  1671. widget/font-variants.cpp
  1672. widget/frame.cpp
  1673. widget/gimpcolorwheel.c
  1674. @@ -312,6 +313,7 @@
  1675. widget/entity-entry.h
  1676. widget/entry.h
  1677. widget/filter-effect-chooser.h
  1678. + widget/font-button.h
  1679. widget/font-variants.h
  1680. widget/frame.h
  1681. widget/gimpspinscale.h
  1682. === modified file 'src/ui/dialog/livepatheffect-editor.cpp'
  1683. --- src/ui/dialog/livepatheffect-editor.cpp 2016-07-28 11:26:17 +0000
  1684. +++ src/ui/dialog/livepatheffect-editor.cpp 2016-07-30 17:02:04 +0000
  1685. @@ -61,7 +61,7 @@
  1686. {
  1687. LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
  1688. lpeeditor->lpe_list_locked = false;
  1689. - lpeeditor->onSelectionChanged(selection);
  1690. + lpeeditor->onSelectionChanged(selection, true);
  1691. }
  1692. static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
  1693. @@ -98,7 +98,8 @@
  1694. button_up(),
  1695. button_down(),
  1696. current_desktop(NULL),
  1697. - current_lpeitem(NULL)
  1698. + current_lpeitem(NULL),
  1699. + current_lperef(NULL)
  1700. {
  1701. Gtk::Box *contents = _getContents();
  1702. contents->set_spacing(4);
  1703. @@ -206,6 +207,10 @@
  1704. void
  1705. LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
  1706. {
  1707. + if ( ! effect.upd_params ) {
  1708. + return;
  1709. + }
  1710. +
  1711. if (effectwidget) {
  1712. effectcontrol_vbox.remove(*effectwidget);
  1713. delete effectwidget;
  1714. @@ -265,9 +270,8 @@
  1715. button_down.set_sensitive(sensitive);
  1716. }
  1717. -
  1718. void
  1719. -LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
  1720. +LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_params)
  1721. {
  1722. if (lpe_list_locked) {
  1723. // this was triggered by selecting a row in the list, so skip reloading
  1724. @@ -291,6 +295,9 @@
  1725. if ( lpeitem->hasPathEffect() ) {
  1726. Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE();
  1727. if (lpe) {
  1728. + if (upd_params) {
  1729. + lpe->upd_params = true;
  1730. + }
  1731. showParams(*lpe);
  1732. lpe_list_locked = true;
  1733. selectInList(lpe);
  1734. @@ -494,6 +501,12 @@
  1735. SPItem *item = sel->singleItem();
  1736. SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
  1737. if ( lpeitem ) {
  1738. + if (current_lperef && current_lperef->lpeobject) {
  1739. + LivePathEffect::Effect * effect = current_lperef->lpeobject->get_lpe();
  1740. + if (effect) {
  1741. + effect->upd_params = true;
  1742. + }
  1743. + }
  1744. lpeitem->removeCurrentPathEffect(false);
  1745. DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
  1746. @@ -548,11 +561,17 @@
  1747. Gtk::TreeModel::iterator it = sel->get_selected();
  1748. LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
  1749. - if (lperef && current_lpeitem) {
  1750. + if (lperef && current_lpeitem && current_lperef != lperef) {
  1751. + //The last condition ignore Gtk::TreeModel may occasionally be changed emitted when nothing has happened
  1752. if (lperef->lpeobject->get_lpe()) {
  1753. lpe_list_locked = true; // prevent reload of the list which would lose selection
  1754. current_lpeitem->setCurrentPathEffect(lperef);
  1755. - showParams(*lperef->lpeobject->get_lpe());
  1756. + current_lperef = lperef;
  1757. + LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe();
  1758. + if (effect) {
  1759. + effect->upd_params = true;
  1760. + showParams(*effect);
  1761. + }
  1762. }
  1763. }
  1764. }
  1765. @@ -570,6 +589,14 @@
  1766. /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
  1767. * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
  1768. lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
  1769. + Inkscape::Selection *sel = _getSelection();
  1770. + if ( sel && !sel->isEmpty() ) {
  1771. + SPItem *item = sel->singleItem();
  1772. + SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
  1773. + if ( lpeitem ) {
  1774. + lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem);
  1775. + }
  1776. + }
  1777. DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
  1778. newValue ? _("Activate path effect") : _("Deactivate path effect"));
  1779. }
  1780. === modified file 'src/ui/dialog/livepatheffect-editor.h'
  1781. --- src/ui/dialog/livepatheffect-editor.h 2014-03-27 01:33:44 +0000
  1782. +++ src/ui/dialog/livepatheffect-editor.h 2016-07-24 16:00:12 +0000
  1783. @@ -45,7 +45,8 @@
  1784. static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); }
  1785. - void onSelectionChanged(Inkscape::Selection *sel);
  1786. + void onSelectionChanged(Inkscape::Selection *sel, bool upd_params = false);
  1787. + void onSelectionModified(Inkscape::Selection *sel);
  1788. virtual void on_effect_selection_changed();
  1789. void setDesktop(SPDesktop *desktop);
  1790. @@ -126,6 +127,8 @@
  1791. SPLPEItem * current_lpeitem;
  1792. + LivePathEffect::LPEObjectReference * current_lperef;
  1793. +
  1794. friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data);
  1795. LivePathEffectEditor(LivePathEffectEditor const &d);
  1796. === modified file 'src/ui/widget/Makefile_insert'
  1797. --- src/ui/widget/Makefile_insert 2015-05-17 09:20:36 +0000
  1798. +++ src/ui/widget/Makefile_insert 2016-07-29 21:25:30 +0000
  1799. @@ -33,6 +33,8 @@
  1800. ui/widget/entry.h \
  1801. ui/widget/filter-effect-chooser.h \
  1802. ui/widget/filter-effect-chooser.cpp \
  1803. + ui/widget/font-button.h \
  1804. + ui/widget/font-button.cpp \
  1805. ui/widget/font-variants.h \
  1806. ui/widget/font-variants.cpp \
  1807. ui/widget/gimpspinscale.c \
  1808. === modified file 'src/ui/widget/combo-enums.h'
  1809. --- src/ui/widget/combo-enums.h 2012-02-15 11:19:00 +0000
  1810. +++ src/ui/widget/combo-enums.h 2016-07-29 18:13:37 +0000
  1811. @@ -16,7 +16,6 @@
  1812. #include <gtkmm/liststore.h>
  1813. #include "attr-widget.h"
  1814. #include "util/enums.h"
  1815. -
  1816. #include <glibmm/i18n.h>
  1817. namespace Inkscape {
  1818. @@ -190,9 +189,11 @@
  1819. const Util::EnumDataConverter<E>& c,
  1820. Glib::ustring const &suffix = "",
  1821. Glib::ustring const &icon = "",
  1822. - bool mnemonic = true)
  1823. - : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
  1824. - { }
  1825. + bool mnemonic = true,
  1826. + bool sorted = true)
  1827. + : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
  1828. + {
  1829. + }
  1830. ComboBoxEnum<E>* getCombobox() {
  1831. return static_cast< ComboBoxEnum<E>* > (_widget);
  1832. === added file 'src/ui/widget/font-button.cpp'
  1833. --- src/ui/widget/font-button.cpp 1970-01-01 00:00:00 +0000
  1834. +++ src/ui/widget/font-button.cpp 2016-07-30 00:01:38 +0000
  1835. @@ -0,0 +1,58 @@
  1836. +/*
  1837. + *
  1838. + * Released under GNU GPL. Read the file 'COPYING' for more information.
  1839. + */
  1840. +
  1841. +#ifdef HAVE_CONFIG_H
  1842. +# include <config.h>
  1843. +#endif
  1844. +
  1845. +#include "font-button.h"
  1846. +#include <glibmm/i18n.h>
  1847. +
  1848. +namespace Inkscape {
  1849. +namespace UI {
  1850. +namespace Widget {
  1851. +
  1852. +FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip,
  1853. + Glib::ustring const &suffix,
  1854. + Glib::ustring const &icon,
  1855. + bool mnemonic)
  1856. + : Labelled(label, tooltip, new Gtk::FontButton("Sans 10"), suffix, icon, mnemonic)
  1857. +{
  1858. +}
  1859. +
  1860. +Glib::ustring FontButton::getValue() const
  1861. +{
  1862. + g_assert(_widget != NULL);
  1863. + return static_cast<Gtk::FontButton*>(_widget)->get_font_name();
  1864. +}
  1865. +
  1866. +
  1867. +void FontButton::setValue (Glib::ustring fontspec)
  1868. +{
  1869. + g_assert(_widget != NULL);
  1870. + static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec);
  1871. +}
  1872. +
  1873. +Glib::SignalProxy0<void> FontButton::signal_font_value_changed()
  1874. +{
  1875. + g_assert(_widget != NULL);
  1876. + return static_cast<Gtk::FontButton*>(_widget)->signal_font_set();
  1877. +}
  1878. +
  1879. +
  1880. +} // namespace Widget
  1881. +} // namespace UI
  1882. +} // namespace Inkscape
  1883. +
  1884. +/*
  1885. + Local Variables:
  1886. + mode:c++
  1887. + c-file-style:"stroustrup"
  1888. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1889. + indent-tabs-mode:nil
  1890. + fill-column:99
  1891. + End:
  1892. +*/
  1893. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  1894. === added file 'src/ui/widget/font-button.h'
  1895. --- src/ui/widget/font-button.h 1970-01-01 00:00:00 +0000
  1896. +++ src/ui/widget/font-button.h 2016-07-29 22:58:22 +0000
  1897. @@ -0,0 +1,63 @@
  1898. +/*
  1899. + *
  1900. + * Copyright (C) 2007 Author
  1901. + *
  1902. + * Released under GNU GPL. Read the file 'COPYING' for more information.
  1903. + */
  1904. +
  1905. +#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H
  1906. +#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H
  1907. +
  1908. +#include <gtkmm.h>
  1909. +#include "labelled.h"
  1910. +
  1911. +namespace Inkscape {
  1912. +namespace UI {
  1913. +namespace Widget {
  1914. +
  1915. +/**
  1916. + * A labelled font button for entering font values
  1917. + */
  1918. +class FontButton : public Labelled
  1919. +{
  1920. +public:
  1921. + /**
  1922. + * Construct a FontButton Widget.
  1923. + *
  1924. + * @param label Label.
  1925. + * @param suffix Suffix, placed after the widget (defaults to "").
  1926. + * @param icon Icon filename, placed before the label (defaults to "").
  1927. + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
  1928. + * indicates the next character should be used for the
  1929. + * mnemonic accelerator key (defaults to false).
  1930. + */
  1931. + FontButton( Glib::ustring const &label,
  1932. + Glib::ustring const &tooltip,
  1933. + Glib::ustring const &suffix = "",
  1934. + Glib::ustring const &icon = "",
  1935. + bool mnemonic = true);
  1936. +
  1937. + Glib::ustring getValue() const;
  1938. + void setValue (Glib::ustring fontspec);
  1939. + /**
  1940. + * Signal raised when the font button's value changes.
  1941. + */
  1942. + Glib::SignalProxy0<void> signal_font_value_changed();
  1943. +};
  1944. +
  1945. +} // namespace Widget
  1946. +} // namespace UI
  1947. +} // namespace Inkscape
  1948. +
  1949. +#endif // INKSCAPE_UI_WIDGET_RANDOM_H
  1950. +
  1951. +/*
  1952. + Local Variables:
  1953. + mode:c++
  1954. + c-file-style:"stroustrup"
  1955. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1956. + indent-tabs-mode:nil
  1957. + fill-column:99
  1958. + End:
  1959. +*/
  1960. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  1961. === modified file 'src/ui/widget/registered-enums.h'
  1962. --- src/ui/widget/registered-enums.h 2011-10-25 07:45:35 +0000
  1963. +++ src/ui/widget/registered-enums.h 2016-07-29 18:13:43 +0000
  1964. @@ -33,11 +33,11 @@
  1965. const Util::EnumDataConverter<E>& c,
  1966. Registry& wr,
  1967. Inkscape::XML::Node* repr_in = NULL,
  1968. - SPDocument *doc_in = NULL )
  1969. - : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
  1970. + SPDocument *doc_in = NULL,
  1971. + bool sorted = true )
  1972. + : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
  1973. {
  1974. RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
  1975. -
  1976. _changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
  1977. }
  1978. === modified file 'src/ui/widget/registered-widget.cpp'
  1979. --- src/ui/widget/registered-widget.cpp 2016-07-28 11:26:17 +0000
  1980. +++ src/ui/widget/registered-widget.cpp 2016-08-01 15:29:19 +0000
  1981. @@ -25,6 +25,7 @@
  1982. #include "ui/widget/scalar-unit.h"
  1983. #include "ui/widget/point.h"
  1984. #include "ui/widget/random.h"
  1985. +#include "ui/widget/font-button.h"
  1986. #include "widgets/spinbutton-events.h"
  1987. #include "xml/repr.h"
  1988. @@ -297,7 +298,6 @@
  1989. setProgrammatically = false;
  1990. return;
  1991. }
  1992. -
  1993. if (_wr->isUpdating()) {
  1994. return;
  1995. }
  1996. @@ -331,8 +331,6 @@
  1997. init_parent(key, wr, repr_in, doc_in);
  1998. setProgrammatically = false;
  1999. -
  2000. - setText("");
  2001. _activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate));
  2002. }
  2003. @@ -348,16 +346,12 @@
  2004. return;
  2005. }
  2006. _wr->setUpdating (true);
  2007. -
  2008. + Glib::ustring str(getText());
  2009. + set_sensitive(false);
  2010. Inkscape::SVGOStringStream os;
  2011. - os << getText();
  2012. -
  2013. - set_sensitive(false);
  2014. + os << str;
  2015. write_to_xml(os.str().c_str());
  2016. set_sensitive(true);
  2017. -
  2018. - setText(os.str().c_str());
  2019. -
  2020. _wr->setUpdating (false);
  2021. }
  2022. @@ -803,6 +797,47 @@
  2023. _wr->setUpdating (false);
  2024. }
  2025. +/*#########################################
  2026. + * Registered FONT-BUTTON
  2027. + */
  2028. +
  2029. +RegisteredFontButton::~RegisteredFontButton()
  2030. +{
  2031. + _signal_font_set.disconnect();
  2032. +}
  2033. +
  2034. +RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip,
  2035. + const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
  2036. + SPDocument* doc_in )
  2037. + : RegisteredWidget<FontButton>(label, tip)
  2038. +{
  2039. + init_parent(key, wr, repr_in, doc_in);
  2040. + _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
  2041. +}
  2042. +
  2043. +void
  2044. +RegisteredFontButton::setValue (Glib::ustring fontspec)
  2045. +{
  2046. + FontButton::setValue(fontspec);
  2047. +}
  2048. +
  2049. +void
  2050. +RegisteredFontButton::on_value_changed()
  2051. +{
  2052. +
  2053. + if (_wr->isUpdating())
  2054. + return;
  2055. +
  2056. + _wr->setUpdating (true);
  2057. +
  2058. + Inkscape::SVGOStringStream os;
  2059. + os << getValue();
  2060. +
  2061. + write_to_xml(os.str().c_str());
  2062. +
  2063. + _wr->setUpdating (false);
  2064. +}
  2065. +
  2066. } // namespace Dialog
  2067. } // namespace UI
  2068. } // namespace Inkscape
  2069. === modified file 'src/ui/widget/registered-widget.h'
  2070. --- src/ui/widget/registered-widget.h 2016-07-24 15:05:29 +0000
  2071. +++ src/ui/widget/registered-widget.h 2016-07-29 22:45:14 +0000
  2072. @@ -22,6 +22,7 @@
  2073. #include "ui/widget/text.h"
  2074. #include "ui/widget/random.h"
  2075. #include "ui/widget/unit-menu.h"
  2076. +#include "ui/widget/font-button.h"
  2077. #include "ui/widget/color-picker.h"
  2078. #include "inkscape.h"
  2079. @@ -77,6 +78,8 @@
  2080. RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
  2081. template< typename A, typename B, typename C, typename D, typename E , typename F>
  2082. RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
  2083. + template< typename A, typename B, typename C, typename D, typename E , typename F, typename G>
  2084. + RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); }
  2085. virtual ~RegisteredWidget() {};
  2086. @@ -418,6 +421,23 @@
  2087. void on_value_changed();
  2088. };
  2089. +class RegisteredFontButton : public RegisteredWidget<FontButton> {
  2090. +public:
  2091. + virtual ~RegisteredFontButton();
  2092. + RegisteredFontButton ( const Glib::ustring& label,
  2093. + const Glib::ustring& tip,
  2094. + const Glib::ustring& key,
  2095. + Registry& wr,
  2096. + Inkscape::XML::Node* repr_in = NULL,
  2097. + SPDocument *doc_in = NULL);
  2098. +
  2099. + void setValue (Glib::ustring fontspec);
  2100. +
  2101. +protected:
  2102. + sigc::connection _signal_font_set;
  2103. + void on_value_changed();
  2104. +};
  2105. +
  2106. } // namespace Widget
  2107. } // namespace UI
  2108. } // namespace Inkscape
  2109. === modified file 'src/ui/widget/scalar.cpp'
  2110. --- src/ui/widget/scalar.cpp 2014-03-27 01:33:44 +0000
  2111. +++ src/ui/widget/scalar.cpp 2016-07-30 15:23:12 +0000
  2112. @@ -126,10 +126,12 @@
  2113. static_cast<SpinButton*>(_widget)->set_range(min, max);
  2114. }
  2115. -void Scalar::setValue(double value)
  2116. +void Scalar::setValue(double value, bool setProg)
  2117. {
  2118. g_assert(_widget != NULL);
  2119. - setProgrammatically = true; // callback is supposed to reset back, if it cares
  2120. + if (setProg) {
  2121. + setProgrammatically = true; // callback is supposed to reset back, if it cares
  2122. + }
  2123. static_cast<SpinButton*>(_widget)->set_value(value);
  2124. }
  2125. === modified file 'src/ui/widget/scalar.h'
  2126. --- src/ui/widget/scalar.h 2012-04-30 22:04:12 +0000
  2127. +++ src/ui/widget/scalar.h 2016-07-30 15:23:27 +0000
  2128. @@ -139,7 +139,7 @@
  2129. /**
  2130. * Sets the value of the spin button.
  2131. */
  2132. - void setValue(double value);
  2133. + void setValue(double value, bool setProg = true);
  2134. /**
  2135. * Manually forces an update of the spin button.
  2136. === modified file 'src/ui/widget/text.cpp'
  2137. --- src/ui/widget/text.cpp 2012-02-26 16:54:08 +0000
  2138. +++ src/ui/widget/text.cpp 2016-07-31 21:49:31 +0000
  2139. @@ -28,13 +28,13 @@
  2140. {
  2141. }
  2142. -const char *Text::getText() const
  2143. +Glib::ustring const Text::getText() const
  2144. {
  2145. g_assert(_widget != NULL);
  2146. - return static_cast<Gtk::Entry*>(_widget)->get_text().c_str();
  2147. + return static_cast<Gtk::Entry*>(_widget)->get_text();
  2148. }
  2149. -void Text::setText(const char* text)
  2150. +void Text::setText(Glib::ustring const text)
  2151. {
  2152. g_assert(_widget != NULL);
  2153. setProgrammatically = true; // callback is supposed to reset back, if it cares
  2154. === modified file 'src/ui/widget/text.h'
  2155. --- src/ui/widget/text.h 2012-02-26 16:54:08 +0000
  2156. +++ src/ui/widget/text.h 2016-07-31 21:49:59 +0000
  2157. @@ -44,12 +44,12 @@
  2158. /**
  2159. * Get the text in the entry.
  2160. */
  2161. - const char* getText() const;
  2162. + Glib::ustring const getText() const;
  2163. /**
  2164. * Sets the text of the text entry.
  2165. */
  2166. - void setText(const char* text);
  2167. + void setText(Glib::ustring const text);
  2168. void update();
  2169. === modified file 'src/widgets/font-selector.cpp'
  2170. --- src/widgets/font-selector.cpp 2016-07-28 11:26:17 +0000
  2171. +++ src/widgets/font-selector.cpp 2016-07-22 19:59:31 +0000
  2172. @@ -19,9 +19,6 @@
  2173. # include "config.h"
  2174. #endif
  2175. -#include <libnrtype/font-lister.h>
  2176. -#include <libnrtype/font-instance.h>
  2177. -
  2178. #include <2geom/transforms.h>
  2179. #include <gtk/gtk.h>
  2180. @@ -34,29 +31,7 @@
  2181. /* SPFontSelector */
  2182. -struct SPFontSelector
  2183. -{
  2184. -#if GTK_CHECK_VERSION(3,0,0)
  2185. - GtkBox hbox;
  2186. -#else
  2187. - GtkHBox hbox;
  2188. -#endif
  2189. -
  2190. - unsigned int block_emit : 1;
  2191. -
  2192. - GtkWidget *family;
  2193. - GtkWidget *style;
  2194. - GtkWidget *size;
  2195. -
  2196. - GtkWidget *family_treeview;
  2197. - GtkWidget *style_treeview;
  2198. -
  2199. - NRNameList families;
  2200. - NRStyleList styles;
  2201. - gfloat fontsize;
  2202. - bool fontsize_dirty;
  2203. - Glib::ustring *fontspec;
  2204. -};
  2205. +
  2206. struct SPFontSelectorClass
  2207. @@ -274,6 +249,7 @@
  2208. if (fsel->fontspec) {
  2209. delete fsel->fontspec;
  2210. + fsel->fontspec = 0;
  2211. }
  2212. if (fsel->families.length > 0) {
  2213. === modified file 'src/widgets/font-selector.h'
  2214. --- src/widgets/font-selector.h 2014-08-18 20:19:55 +0000
  2215. +++ src/widgets/font-selector.h 2016-07-22 19:59:29 +0000
  2216. @@ -15,10 +15,33 @@
  2217. *
  2218. * Released under GNU GPL, read the file 'COPYING' for more information
  2219. */
  2220. -
  2221. +#include <libnrtype/font-lister.h>
  2222. +#include <libnrtype/font-instance.h>
  2223. #include <glib.h>
  2224. -struct SPFontSelector;
  2225. +struct SPFontSelector
  2226. +{
  2227. +#if GTK_CHECK_VERSION(3,0,0)
  2228. + GtkBox hbox;
  2229. +#else
  2230. + GtkHBox hbox;
  2231. +#endif
  2232. +
  2233. + unsigned int block_emit : 1;
  2234. +
  2235. + GtkWidget *family;
  2236. + GtkWidget *style;
  2237. + GtkWidget *size;
  2238. +
  2239. + GtkWidget *family_treeview;
  2240. + GtkWidget *style_treeview;
  2241. +
  2242. + NRNameList families;
  2243. + NRStyleList styles;
  2244. + gfloat fontsize;
  2245. + bool fontsize_dirty;
  2246. + Glib::ustring *fontspec;
  2247. +};
  2248. #define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ())
  2249. #define SP_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector))
  1. More ...
 
 

82

 

943

Measure Line DIFF r.15042

-

PasteBin

Lines
2397
Words
7749
Dimensione
86,9 KB
Creato
Tipo
text/plain
General Public License v2 (GPLv2)
Per favore accedi per lasciare un commento!