diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-07-25 01:06:47 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-07-25 01:06:47 +0000 |
| commit | 4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3 (patch) | |
| tree | 75853d8eec5e85fb93a2a798b57f072e3c9eeb99 /src/display | |
| parent | Replace direct use of Cairo contexts and surfaces in the rendering tree (diff) | |
| parent | Revert workarounds from 10501 - no longer necessary (diff) | |
| download | inkscape-4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3.tar.gz inkscape-4f3cc7cbb73a72e1ab10a587a3b81f8c8737fec3.zip | |
Merge from trunk
(bzr r10347.1.18)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/guideline.cpp | 56 | ||||
| -rw-r--r-- | src/display/guideline.h | 2 | ||||
| -rw-r--r-- | src/display/sodipodi-ctrl.cpp | 7 | ||||
| -rw-r--r-- | src/display/sodipodi-ctrlrect.cpp | 274 | ||||
| -rw-r--r-- | src/display/sodipodi-ctrlrect.h | 5 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 4 |
6 files changed, 138 insertions, 210 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index c1c3e7740..0d2905d23 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -13,12 +13,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/coord.h> #include <2geom/transforms.h> #include "sp-canvas-util.h" #include "sp-ctrlpoint.h" #include "guideline.h" #include "display/cairo-utils.h" +#include "inkscape.h" // for inkscape_active_desktop() +#include "desktop.h" +#include "sp-namedview.h" + static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); static void sp_guideline_destroy(GtkObject *object); @@ -112,45 +117,46 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); cairo_set_font_size(buf->ct, 10); - int px = round(gl->point_on_line[Geom::X]); - int py = round(gl->point_on_line[Geom::Y]); + Geom::Point normal_dt = /*unit_vector*/(gl->normal_to_line * gl->affine.withoutTranslation()); // note that normal_dt does not have unit length + Geom::Point point_on_line_dt = gl->point_on_line * gl->affine; if (gl->label) { + int px = round(point_on_line_dt[Geom::X]); + int py = round(point_on_line_dt[Geom::Y]); cairo_save(buf->ct); cairo_translate(buf->ct, px, py); - cairo_rotate(buf->ct, atan2(gl->normal_to_line[Geom::X], gl->normal_to_line[Geom::Y])); + cairo_rotate(buf->ct, atan2(normal_dt.cw())); cairo_translate(buf->ct, 0, -5); cairo_move_to(buf->ct, 0, 0); cairo_show_text(buf->ct, gl->label); cairo_restore(buf->ct); } - if (gl->is_vertical()) { - int position = round(gl->point_on_line[Geom::X]); + if ( Geom::are_near(normal_dt[Geom::Y], 0.) ) { // is vertical? + int position = round(point_on_line_dt[Geom::X]); cairo_move_to(buf->ct, position + 0.5, buf->rect.y0 + 0.5); cairo_line_to(buf->ct, position + 0.5, buf->rect.y1 - 0.5); cairo_stroke(buf->ct); - } else if (gl->is_horizontal()) { - int position = round(gl->point_on_line[Geom::Y]); + } else if ( Geom::are_near(normal_dt[Geom::X], 0.) ) { // is horizontal? + int position = round(point_on_line_dt[Geom::Y]); cairo_move_to(buf->ct, buf->rect.x0 + 0.5, position + 0.5); cairo_line_to(buf->ct, buf->rect.x1 - 0.5, position + 0.5); cairo_stroke(buf->ct); } else { - // render angled line, once intersection has been detected, draw from there. - Geom::Point parallel_to_line( gl->normal_to_line[Geom::Y], - /*should be minus, but inverted y axis*/ gl->normal_to_line[Geom::X]); + // render angled line. Once intersection has been detected, draw from there. + Geom::Point parallel_to_line( normal_dt.ccw() ); //try to intersect with left vertical of rect - double y_intersect_left = (buf->rect.x0 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_left = (buf->rect.x0 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; if ( (y_intersect_left >= buf->rect.y0) && (y_intersect_left <= buf->rect.y1) ) { // intersects with left vertical! - double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; sp_guideline_drawline (buf, buf->rect.x0, static_cast<gint>(round(y_intersect_left)), buf->rect.x1, static_cast<gint>(round(y_intersect_right)), gl->rgba); goto end; } //try to intersect with right vertical of rect - double y_intersect_right = (buf->rect.x1 - gl->point_on_line[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + gl->point_on_line[Geom::Y]; + double y_intersect_right = (buf->rect.x1 - point_on_line_dt[Geom::X]) * parallel_to_line[Geom::Y] / parallel_to_line[Geom::X] + point_on_line_dt[Geom::Y]; if ( (y_intersect_right >= buf->rect.y0) && (y_intersect_right <= buf->rect.y1) ) { // intersects with right vertical! sp_guideline_drawline (buf, buf->rect.x1, static_cast<gint>(round(y_intersect_right)), buf->rect.x0, static_cast<gint>(round(y_intersect_left)), gl->rgba); @@ -158,16 +164,16 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) } //try to intersect with top horizontal of rect - double x_intersect_top = (buf->rect.y0 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_top = (buf->rect.y0 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { // intersects with top horizontal! - double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_top)), buf->rect.y0, static_cast<gint>(round(x_intersect_bottom)), buf->rect.y1, gl->rgba); goto end; } //try to intersect with bottom horizontal of rect - double x_intersect_bottom = (buf->rect.y1 - gl->point_on_line[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + gl->point_on_line[Geom::X]; + double x_intersect_bottom = (buf->rect.y1 - point_on_line_dt[Geom::Y]) * parallel_to_line[Geom::X] / parallel_to_line[Geom::Y] + point_on_line_dt[Geom::X]; if ( (x_intersect_top >= buf->rect.x0) && (x_intersect_top <= buf->rect.x1) ) { // intersects with bottom horizontal! sp_guideline_drawline (buf, static_cast<gint>(round(x_intersect_bottom)), buf->rect.y1, static_cast<gint>(round(x_intersect_top)), buf->rect.y0, gl->rgba); @@ -186,16 +192,16 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, ((SPCanvasItemClass *) parent_class)->update(item, affine, flags); } - gl->point_on_line[Geom::X] = affine[4]; - gl->point_on_line[Geom::Y] = affine[5]; + gl->affine = affine; - sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line * affine.inverse()); + sp_ctrlpoint_set_coords(gl->origin, gl->point_on_line); sp_canvas_item_request_update(SP_CANVAS_ITEM (gl->origin)); + Geom::Point pol_transformed = gl->point_on_line*affine; if (gl->is_horizontal()) { - sp_canvas_update_bbox (item, -1000000, round(gl->point_on_line[Geom::Y] - 16), 1000000, round(gl->point_on_line[Geom::Y] + 1)); + sp_canvas_update_bbox (item, -1000000, round(pol_transformed[Geom::Y] - 16), 1000000, round(pol_transformed[Geom::Y] + 1)); } else if (gl->is_vertical()) { - sp_canvas_update_bbox (item, round(gl->point_on_line[Geom::X]), -1000000, round(gl->point_on_line[Geom::X] + 16), 1000000); + sp_canvas_update_bbox (item, round(pol_transformed[Geom::X]), -1000000, round(pol_transformed[Geom::X] + 16), 1000000); } else { //TODO: labels in angled guidelines are not showing up for some reason. sp_canvas_update_bbox (item, -1000000, -1000000, 1000000, 1000000); @@ -213,8 +219,8 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem *actual_item = item; - Geom::Point vec(gl->normal_to_line[Geom::X], - gl->normal_to_line[Geom::Y]); - double distance = Geom::dot((p - gl->point_on_line), vec); + Geom::Point vec = gl->normal_to_line * gl->affine.withoutTranslation(); + double distance = Geom::dot((p - gl->point_on_line * gl->affine), unit_vector(vec)); return MAX(fabs(distance)-1, 0); } @@ -250,8 +256,8 @@ void sp_guideline_set_label(SPGuideLine *gl, const char* label) void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line) { - sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl), Geom::Affine(Geom::Translate(point_on_line))); - sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl->origin), Geom::Affine(Geom::Translate(point_on_line))); + gl->point_on_line = point_on_line; + sp_canvas_item_request_update(SP_CANVAS_ITEM (gl)); } void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line) diff --git a/src/display/guideline.h b/src/display/guideline.h index a3966f76f..164244c46 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -25,6 +25,8 @@ class SPCtrlPoint; struct SPGuideLine { SPCanvasItem item; + Geom::Affine affine; + SPCtrlPoint *origin; // unlike 'item', this is only held locally guint32 rgba; diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 0ff7ca9f5..b4d2633bb 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -105,7 +105,12 @@ sp_ctrl_init (SPCtrl *ctrl) ctrl->stroked = 0; ctrl->fill_color = 0x000000ff; ctrl->stroke_color = 0x000000ff; - ctrl->_moved = false; + + // This way we make sure that the first sp_ctrl_update() call finishes properly; + // in subsequent calls it will not update anything it the control hasn't moved + // Consider for example the case in which a snap indicator is drawn at (0, 0); + // If moveto() is called then it will not set _moved to true because we're initially already at (0, 0) + ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen ctrl->box.x0 = ctrl->box.y0 = ctrl->box.x1 = ctrl->box.y1 = 0; ctrl->cache = NULL; diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index b516456e9..b4539841b 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -15,8 +15,8 @@ * */ -#include "sp-canvas-util.h" #include "sodipodi-ctrlrect.h" +#include "sp-canvas-util.h" #include "display/cairo-utils.h" /* @@ -83,77 +83,7 @@ static void sp_ctrlrect_destroy(GtkObject *object) (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); } } -#if 0 -/* FIXME: use definitions from somewhere else */ -#define RGBA_R(v) ((v) >> 24) -#define RGBA_G(v) (((v) >> 16) & 0xff) -#define RGBA_B(v) (((v) >> 8) & 0xff) -#define RGBA_A(v) ((v) & 0xff) - -static void sp_ctrlrect_hline(SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba, guint dashed) -{ - if (y >= buf->rect.y0 && y < buf->rect.y1) { - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const x0 = MAX(buf->rect.x0, xs); - gint const x1 = MIN(buf->rect.x1, xe + 1); - guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (gint x = x0; x < x1; x++) { - if (!dashed || ((x / DASH_LENGTH) % 2)) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - } - p += 4; - } - } -} -static void sp_ctrlrect_vline(SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba, guint dashed) -{ - if (x >= buf->rect.x0 && x < buf->rect.x1) { - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const y0 = MAX(buf->rect.y0, ys); - gint const y1 = MIN(buf->rect.y1, ye + 1); - guchar *p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (gint y = y0; y < y1; y++) { - if (!dashed || ((y / DASH_LENGTH) % 2)) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - } - p += buf->buf_rowstride; - } - } -} - -/** Fills the pixels in [xs, xe)*[ys,ye) clipped to the tile with rgb * a. */ -static void sp_ctrlrect_area(SPCanvasBuf *buf, gint xs, gint ys, gint xe, gint ye, guint32 rgba) -{ - guint const r = RGBA_R(rgba); - guint const g = RGBA_G(rgba); - guint const b = RGBA_B(rgba); - guint const a = RGBA_A(rgba); - gint const x0 = MAX(buf->rect.x0, xs); - gint const x1 = MIN(buf->rect.x1, xe + 1); - gint const y0 = MAX(buf->rect.y0, ys); - gint const y1 = MIN(buf->rect.y1, ye + 1); - for (gint y = y0; y < y1; y++) { - guchar *p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (gint x = x0; x < x1; x++) { - p[0] = INK_COMPOSE(r, a, p[0]); - p[1] = INK_COMPOSE(g, a, p[1]); - p[2] = INK_COMPOSE(b, a, p[2]); - p += 4; - } - } -} -#endif static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf) { @@ -174,8 +104,7 @@ void CtrlRect::init() _dashed = false; _shadow = 0; - _area.x0 = _area.y0 = 0; - _area.x1 = _area.y1 = 0; + _area = Geom::OptIntRect(); _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)); @@ -189,20 +118,25 @@ void CtrlRect::init() void CtrlRect::render(SPCanvasBuf *buf) { + using Geom::X; + using Geom::Y; + static double const dashes[2] = {4.0, 4.0}; - if ((_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) && - (_area.x0 < buf->rect.x1) && - (_area.y0 < buf->rect.y1) && - ((_area.x1 + _shadow_size) >= buf->rect.x0) && - ((_area.y1 + _shadow_size) >= buf->rect.y0)) + if (!_area) { + return; + } + Geom::IntRect area = *_area; + Geom::IntRect area_w_shadow (area[X].min(), area[Y].min(), + area[X].max() + _shadow_size, area[Y].max() + _shadow_size); + if ( area_w_shadow.intersects(buf->rect) ) { cairo_save(buf->ct); cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); cairo_set_line_width(buf->ct, 1); if (_dashed) cairo_set_dash(buf->ct, dashes, 2, 0); - cairo_rectangle(buf->ct, 0.5 + _area.x0, 0.5 + _area.y0, - _area.x1 - _area.x0, _area.y1 - _area.y0); + cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); if (_has_fill) { ink_cairo_set_source_rgba32(buf->ct, _fill_color); @@ -213,181 +147,161 @@ void CtrlRect::render(SPCanvasBuf *buf) if (_shadow_size > 0) { ink_cairo_set_source_rgba32(buf->ct, _shadow_color); - cairo_rectangle(buf->ct, 1 + _area.x1, _area.y0 + _shadow_size, - _shadow_size, _area.y1 - _area.y0 + 1); // right shadow - cairo_rectangle(buf->ct, _area.x0 + _shadow_size, 1 + _area.y1, - _area.x1 - _area.x0 - _shadow_size + 1, _shadow_size); + cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, + _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow + cairo_rectangle(buf->ct, area[X].min() + _shadow_size, 1 + area[Y].max(), + area[X].max() - area[X].min() - _shadow_size + 1, _shadow_size); cairo_fill(buf->ct); } cairo_restore(buf->ct); -#if 0 - /* Top */ - sp_ctrlrect_hline(buf, _area.y0, _area.x0, _area.x1, _border_color, _dashed); - /* Bottom */ - sp_ctrlrect_hline(buf, _area.y1, _area.x0, _area.x1, _border_color, _dashed); - /* Left */ - sp_ctrlrect_vline(buf, _area.x0, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed); - /* Right */ - sp_ctrlrect_vline(buf, _area.x1, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed); - if (_shadow_size > 0) { - /* Right shadow */ - sp_ctrlrect_area(buf, _area.x1 + 1, _area.y0 + _shadow_size, - _area.x1 + _shadow_size, _area.y1 + _shadow_size, _shadow_color); - /* Bottom shadow */ - sp_ctrlrect_area(buf, _area.x0 + _shadow_size, _area.y1 + 1, - _area.x1, _area.y1 + _shadow_size, _shadow_color); - } - if (_has_fill) { - /* Fill */ - sp_ctrlrect_area(buf, _area.x0 + 1, _area.y0 + 1, - _area.x1 - 1, _area.y1 - 1, _fill_color); - } -#endif } } void CtrlRect::update(Geom::Affine const &affine, unsigned int flags) { + using Geom::X; + using Geom::Y; + if (((SPCanvasItemClass *) parent_class)->update) { ((SPCanvasItemClass *) parent_class)->update(this, affine, flags); } sp_canvas_item_reset_bounds(this); - NRRectL _area_old; - _area_old.x0 = _area.x0; - _area_old.x1 = _area.x1; - _area_old.y0 = _area.y0; - _area_old.y1 = _area.y1; - Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine); - _area.x0 = (int) floor(bbox.min()[Geom::X] + 0.5); - _area.y0 = (int) floor(bbox.min()[Geom::Y] + 0.5); - _area.x1 = (int) floor(bbox.max()[Geom::X] + 0.5); - _area.y1 = (int) floor(bbox.max()[Geom::Y] + 0.5); + Geom::OptIntRect _area_old = _area; + Geom::IntRect area ( (int) floor(bbox.min()[Geom::X] + 0.5), + (int) floor(bbox.min()[Geom::Y] + 0.5), + (int) floor(bbox.max()[Geom::X] + 0.5), + (int) floor(bbox.max()[Geom::Y] + 0.5) ); + _area = area; + Geom::IntRect area_old(0,0,0,0); + if (_area_old) { // this weird construction is because the code below assumes _area_old to be 'valid' + area_old = *_area_old; + } gint _shadow_size_old = _shadow_size; _shadow_size = _shadow; // FIXME: we don't process a possible change in _has_fill if (_has_fill) { - if (_area_old.x0 != 0 || _area_old.x1 != 0 || _area_old.y0 != 0 || _area_old.y1 != 0) { + if (_area_old) { sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); } - if (_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) { + if (_area) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } else { // clear box, be smart about what part of the frame to redraw /* Top */ - if (_area.y0 != _area_old.y0) { // different level, redraw fully old and new - if (_area_old.x0 != _area_old.x1) + if (area[Y].min() != area_old[Y].min()) { // different level, redraw fully old and new + if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x1 + 1, _area_old.y0 + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].max() + 1, area_old[Y].min() + 1); - if (_area.x0 != _area.x1) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x1 + 1, _area.y0 + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].max() + 1, area[Y].min() + 1); } else { // same level, redraw only the ends - if (_area.x0 != _area_old.x0) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x0,_area.x0) - 1, _area.y0 - 1, - MAX(_area_old.x0,_area.x0) + 1, _area.y0 + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].min() - 1, + MAX(area_old[X].min(),area[X].min()) + 1, area[Y].min() + 1); } - if (_area.x1 != _area_old.x1) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x1,_area.x1) - 1, _area.y0 - 1, - MAX(_area_old.x1,_area.x1) + 1, _area.y0 + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].min() - 1, + MAX(area_old[X].max(),area[X].max()) + 1, area[Y].min() + 1); } } /* Left */ - if (_area.x0 != _area_old.x0) { // different level, redraw fully old and new - if (_area_old.y0 != _area_old.y1) + if (area[X].min() != area_old[X].min()) { // different level, redraw fully old and new + if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y0 - 1, - _area_old.x0 + 1, _area_old.y1 + 1); + area_old[X].min() - 1, area_old[Y].min() - 1, + area_old[X].min() + 1, area_old[Y].max() + 1); - if (_area.y0 != _area.y1) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y0 - 1, - _area.x0 + 1, _area.y1 + 1); + area[X].min() - 1, area[Y].min() - 1, + area[X].min() + 1, area[Y].max() + 1); } else { // same level, redraw only the ends - if (_area.y0 != _area_old.y0) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, MIN(_area_old.y0,_area.y0) - 1, - _area.x0 + 1, MAX(_area_old.y0,_area.y0) + 1); + area[X].min() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].min() + 1, MAX(area_old[Y].min(),area[Y].min()) + 1); } - if (_area.y1 != _area_old.y1) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area.x0 - 1, MIN(_area_old.y1,_area.y1) - 1, - _area.x0 + 1, MAX(_area_old.y1,_area.y1) + 1); + area[X].min() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].min() + 1, MAX(area_old[Y].max(),area[Y].max()) + 1); } } /* Right */ - if (_area.x1 != _area_old.x1 || _shadow_size_old != _shadow_size) { - if (_area_old.y0 != _area_old.y1) + if (area[X].max() != area_old[X].max() || _shadow_size_old != _shadow_size) { + if (area_old[Y].min() != area_old[Y].max()) sp_canvas_request_redraw(canvas, - _area_old.x1 - 1, _area_old.y0 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].max() - 1, area_old[Y].min() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area.y0 != _area.y1) + if (area[Y].min() != area[Y].max()) sp_canvas_request_redraw(canvas, - _area.x1 - 1, _area.y0 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].max() - 1, area[Y].min() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area.y0 != _area_old.y0) { + if (area[Y].min() != area_old[Y].min()) { sp_canvas_request_redraw(canvas, - _area.x1 - 1, MIN(_area_old.y0,_area.y0) - 1, - _area.x1 + _shadow_size + 1, MAX(_area_old.y0,_area.y0) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].min(),area[Y].min()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].min(),area[Y].min()) + _shadow_size + 1); } - if (_area.y1 != _area_old.y1) { + if (area[Y].max() != area_old[Y].max()) { sp_canvas_request_redraw(canvas, - _area.x1 - 1, MIN(_area_old.y1,_area.y1) - 1, - _area.x1 + _shadow_size + 1, MAX(_area_old.y1,_area.y1) + _shadow_size + 1); + area[X].max() - 1, MIN(area_old[Y].max(),area[Y].max()) - 1, + area[X].max() + _shadow_size + 1, MAX(area_old[Y].max(),area[Y].max()) + _shadow_size + 1); } } /* Bottom */ - if (_area.y1 != _area_old.y1 || _shadow_size_old != _shadow_size) { - if (_area_old.x0 != _area_old.x1) + if (area[Y].max() != area_old[Y].max() || _shadow_size_old != _shadow_size) { + if (area_old[X].min() != area_old[X].max()) sp_canvas_request_redraw(canvas, - _area_old.x0 - 1, _area_old.y1 - 1, - _area_old.x1 + _shadow_size + 1, _area_old.y1 + _shadow_size + 1); + area_old[X].min() - 1, area_old[Y].max() - 1, + area_old[X].max() + _shadow_size + 1, area_old[Y].max() + _shadow_size + 1); - if (_area.x0 != _area.x1) + if (area[X].min() != area[X].max()) sp_canvas_request_redraw(canvas, - _area.x0 - 1, _area.y1 - 1, - _area.x1 + _shadow_size + 1, _area.y1 + _shadow_size + 1); + area[X].min() - 1, area[Y].max() - 1, + area[X].max() + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } else { // same level, redraw only the ends - if (_area.x0 != _area_old.x0) { + if (area[X].min() != area_old[X].min()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x0,_area.x0) - 1, _area.y1 - 1, - MAX(_area_old.x0,_area.x0) + _shadow_size + 1, _area.y1 + _shadow_size + 1); + MIN(area_old[X].min(),area[X].min()) - 1, area[Y].max() - 1, + MAX(area_old[X].min(),area[X].min()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } - if (_area.x1 != _area_old.x1) { + if (area[X].max() != area_old[X].max()) { sp_canvas_request_redraw(canvas, - MIN(_area_old.x1,_area.x1) - 1, _area.y1 - 1, - MAX(_area_old.x1,_area.x1) + _shadow_size + 1, _area.y1 + _shadow_size + 1); + MIN(area_old[X].max(),area[X].max()) - 1, area[Y].max() - 1, + MAX(area_old[X].max(),area[X].max()) + _shadow_size + 1, area[Y].max() + _shadow_size + 1); } } } // update SPCanvasItem box - if (_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) { - x1 = _area.x0 - 1; - y1 = _area.y0 - 1; - x2 = _area.x1 + _shadow_size + 1; - y2 = _area.y1 + _shadow_size + 1; + if (_area) { + x1 = area[X].min() - 1; + y1 = area[Y].min() - 1; + x2 = area[X].max() + _shadow_size + 1; + y2 = area[Y].max() + _shadow_size + 1; } } diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index e69b6ba68..45f8523ed 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -18,7 +18,8 @@ #include <glib/gtypes.h> #include "sp-canvas-item.h" -#include "libnr/nr-rect-l.h" +#include <2geom/rect.h> +#include <2geom/int-rect.h> struct SPCanvasBuf; @@ -47,7 +48,7 @@ private: Geom::Rect _rect; bool _has_fill; bool _dashed; - NRRectL _area; + Geom::OptIntRect _area; gint _shadow_size; guint32 _border_color; guint32 _fill_color; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d7f34969f..71f608118 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1120,9 +1120,9 @@ sp_canvas_destroy (GtkObject *object) } shutdown_transients (canvas); - +#if ENABLE_LCMS canvas->cms_key.~ustring(); - +#endif if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); } |
