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

88

 

1068

Measure Line DIFF r.15040

-

PasteBin

Lines
2391
الكلمات
7730
Size
86,5 ك.ب
Created
النوع
text/plain
General Public License v2 (GPLv2)
Please log in to leave a comment!