summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2016-12-26 09:27:48 +0000
committerJabiertxof <jtx@jtx>2016-12-26 09:27:48 +0000
commit92a72b1e7d998b2ef0ee213488e6257d3da25bb2 (patch)
treee9cdab2262111aaad312d5bd441673985640cf6a /src
parentfixing things (diff)
parentFixes bug #1652465 on mirror and copy rotate LPE. (diff)
downloadinkscape-92a72b1e7d998b2ef0ee213488e6257d3da25bb2.tar.gz
inkscape-92a72b1e7d998b2ef0ee213488e6257d3da25bb2.zip
Update to trunk
(bzr r15295.1.39)
Diffstat (limited to 'src')
-rw-r--r--src/display/sp-canvas.cpp31
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp30
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp17
-rw-r--r--src/libnrtype/Layout-TNG.h8
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp10
-rw-r--r--src/live_effects/lpe-mirror_symmetry.cpp14
6 files changed, 76 insertions, 34 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 9201168ef..416c2c804 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -21,6 +21,8 @@
# include <config.h>
#endif
+#include <gdkmm/devicemanager.h>
+#include <gdkmm/display.h>
#include <gdkmm/rectangle.h>
#include <cairomm/region.h>
@@ -61,6 +63,14 @@ struct SPCanvasGroupClass {
SPCanvasItemClass parent_class;
};
+static void ungrab_default_client_pointer(guint32 const time = GDK_CURRENT_TIME)
+{
+ auto const display = Gdk::Display::get_default();
+ auto const dm = display->get_device_manager();
+ auto const device = dm->get_client_pointer();
+ device->ungrab(time);
+}
+
/**
* A group of items.
*/
@@ -321,10 +331,7 @@ void sp_canvas_item_dispose(GObject *object)
if (item == item->canvas->_grabbed_item) {
item->canvas->_grabbed_item = NULL;
-
- auto dm = gdk_display_get_device_manager(gdk_display_get_default());
- auto device = gdk_device_manager_get_client_pointer(dm);
- gdk_device_ungrab(device, GDK_CURRENT_TIME);
+ ungrab_default_client_pointer();
}
if (item == item->canvas->_focused_item) {
@@ -647,10 +654,7 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime)
}
item->canvas->_grabbed_item = NULL;
-
- auto dm = gdk_display_get_device_manager(gdk_display_get_default());
- auto device = gdk_device_manager_get_client_pointer(dm);
- gdk_device_ungrab(device, etime);
+ ungrab_default_client_pointer(etime);
}
/**
@@ -959,9 +963,7 @@ void SPCanvas::shutdownTransients()
if (_grabbed_item) {
_grabbed_item = NULL;
- auto dm = gdk_display_get_device_manager(gdk_display_get_default());
- auto device = gdk_device_manager_get_client_pointer(dm);
- gdk_device_ungrab(device, GDK_CURRENT_TIME);
+ ungrab_default_client_pointer();
}
removeIdle();
}
@@ -1685,11 +1687,12 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1)
// Save the mouse location
gint x, y;
- auto dm = gdk_display_get_device_manager(gdk_display_get_default());
- auto device = gdk_device_manager_get_client_pointer(dm);
+ auto const display = Gdk::Display::get_default();
+ auto const dm = display->get_device_manager();
+ auto const device = dm->get_client_pointer();
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)),
- device,
+ device->gobj(),
&x, &y, NULL);
setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y));
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index 6b1aba53f..e6da9ba63 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -1182,10 +1182,34 @@ unsigned Layout::Calculator::_buildSpansForPara(ParagraphInfo *para) const
for(input_index = para->first_input_index ; input_index < _flow._input_stream.size() ; input_index++) {
if (_flow._input_stream[input_index]->Type() == CONTROL_CODE) {
Layout::InputStreamControlCode const *control_code = static_cast<Layout::InputStreamControlCode const *>(_flow._input_stream[input_index]);
+
if ( control_code->code == SHAPE_BREAK
- || control_code->code == PARAGRAPH_BREAK)
+ || control_code->code == PARAGRAPH_BREAK) {
+
+ // Add span to be used to calculate line spacing of blank lines.
+ UnbrokenSpan new_span;
+ new_span.pango_item_index = -1;
+ new_span.input_index = input_index;
+
+ // No pango object, so find font and line height ourselves.
+ SPObject * object = static_cast<SPObject *>(control_code->source_cookie);
+ if (object) {
+ SPStyle * style = object->style;
+ if (style) {
+ new_span.font_size = style->font_size.computed * _flow.getTextLengthMultiplierDue();
+ font_factory * factory = font_factory::Default();
+ font_instance * font = factory->FaceFromStyle( style );
+ new_span.line_height_multiplier = _computeFontLineHeight( object->style );
+ new_span.line_height.set( font );
+ new_span.line_height *= new_span.font_size;
+ }
+ }
+ new_span.text_bytes = 0;
+ new_span.char_index_in_para = char_index_in_para;
+ para->unbroken_spans.push_back(new_span);
+ TRACE(("add empty span for break %lu\n", para->unbroken_spans.size() - 1));
break; // stop at the end of the paragraph
- else if (control_code->code == ARBITRARY_GAP) {
+ } else if (control_code->code == ARBITRARY_GAP) {
UnbrokenSpan new_span;
new_span.pango_item_index = -1;
new_span.input_index = input_index;
@@ -1619,8 +1643,8 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const &para,
*line_height = *strut_height;
for (std::vector<ChunkInfo>::const_iterator it_chunk = chunk_info->begin() ; it_chunk != chunk_info->end() ; it_chunk++) {
for (std::vector<BrokenSpan>::const_iterator it_span = it_chunk->broken_spans.begin() ; it_span != it_chunk->broken_spans.end() ; it_span++) {
- TRACE((" brokenspan line_height: %f\n", it_span->start.iter_span->line_height.emSize() ));
FontMetrics span_height = it_span->start.iter_span->line_height;
+ TRACE((" brokenspan line_height: %f\n", span_height.emSize() ));
span_height.computeEffective( it_span->start.iter_span->line_height_multiplier );
line_height->max( span_height );
}
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index df7adf5b4..a1a19f2b3 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -867,6 +867,23 @@ double Layout::getActualLength() const
}//namespace Text
}//namespace Inkscape
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics &f) {
+ out << " emSize: " << f.emSize()
+ << " ascent: " << f.ascent
+ << " descent: " << f.descent
+ << " xheight: " << f.xheight;
+ return out;
+}
+
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics *f) {
+ out << " emSize: " << f->emSize()
+ << " ascent: " << f->ascent
+ << " descent: " << f->descent
+ << " xheight: " << f->xheight;
+ return out;
+}
+
+
/*
Local Variables:
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index 8b46758f0..e06b8392f 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -629,7 +629,7 @@ public:
void reset() {
ascent = 0.8;
- descent = -0.2;
+ descent = 0.2;
xheight = 0.5;
ascent_max = 0.8;
descent_max = 0.2;
@@ -664,7 +664,7 @@ public:
// private:
double ascent; // Typographic ascent.
- double descent; // Typographic descent.
+ double descent; // Typographic descent. (Normally positive).
double xheight; // Height of 'x' measured from alphabetic baseline.
double ascent_max; // Maximum ascent of all glyphs in font.
double descent_max; // Maximum descent of all glyphs in font.
@@ -1189,6 +1189,10 @@ inline bool Layout::iterator::prevCharacter()
}//namespace Text
}//namespace Inkscape
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics &f);
+std::ostream &operator<<(std::ostream &out, const Inkscape::Text::Layout::FontMetrics *f);
+
+
#endif
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 153be031e..3dd35696a 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -50,8 +50,6 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
{
show_orig_path = true;
_provides_knotholder_entities = true;
- apply_to_clippath_and_mask = true;
-
// register all your parameters here, so Inkscape knows which parameters this effect has:
registerParameter(&copies_to_360);
registerParameter(&fuse_paths);
@@ -63,6 +61,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
num_copies.param_make_integer(true);
num_copies.param_set_range(0, 1000);
+ apply_to_clippath_and_mask = true;
}
LPECopyRotate::~LPECopyRotate()
@@ -170,17 +169,14 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem)
}
start_pos = origin + dir * Rotate(-rad_from_deg(starting_angle)) * dist_angle_handle;
rot_pos = origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle;
- if (near) {
+ near = Geom::are_near(start_pos, (Geom::Point)starting_point, 0.01);
+ if (!near) {
starting_point.param_setValue(start_pos, true);
}
previous_start_point = (Geom::Point)starting_point;
if ( fuse_paths || copies_to_360 ) {
rot_pos = origin;
}
-
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
void
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp
index 5464c2bad..bca3d5cc0 100644
--- a/src/live_effects/lpe-mirror_symmetry.cpp
+++ b/src/live_effects/lpe-mirror_symmetry.cpp
@@ -186,11 +186,14 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem)
end_point.param_setValue(point_b, true);
previous_center = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point);
center_point.param_setValue(previous_center, true);
+ return;
}
if ( mode == MT_X || mode == MT_Y ) {
- start_point.param_setValue(point_a, true);
- end_point.param_setValue(point_b, true);
- center_point.param_setValue(Geom::middle_point(point_a, point_b), true);
+ if (!are_near(previous_center, (Geom::Point)center_point, 0.01)) {
+ start_point.param_setValue(point_a, true);
+ end_point.param_setValue(point_b, true);
+ center_point.param_setValue(Geom::middle_point(point_a, point_b), true);
+ }
} else if ( mode == MT_FREE) {
if (are_near(previous_center, (Geom::Point)center_point, 0.01)) {
center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true);
@@ -207,7 +210,6 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem)
Geom::Point ep = Geom::Point(document->getWidth().value("px")/2.0, document->getHeight().value("px")) * transform;
end_point.param_setValue(ep, true);
center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true);
- previous_center = center_point;
} else { //horizontal page
SPDocument * document = SP_ACTIVE_DOCUMENT;
Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse();
@@ -216,10 +218,6 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem)
Geom::Point ep = Geom::Point(document->getWidth().value("px"), document->getHeight().value("px")/2.0) * transform;
end_point.param_setValue(ep, true);
center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true);
- previous_center = center_point;
- }
- if (!are_near(previous_center, (Geom::Point)center_point, 0.01)) {
- center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true);
}
previous_center = center_point;
}