19#include <cairo/cairo.h>
20#include <cairomm/pattern.h>
36 _name =
"CanvasItemRect:Null";
47 _name =
"CanvasItemRect";
57 if (
_rect == rect)
return;
80 std::cerr <<
"CanvasItemRect::contains: Non-zero tolerance not implemented!" << std::endl;
116 auto const &aff =
affine();
129 buf.cr->translate(-
buf.rect.left(), -
buf.rect.top());
132 cairo_set_operator(
buf.cr->cobj(), CAIRO_OPERATOR_DIFFERENCE);
154 buf.cr->begin_new_path();
155 for (
int i = 0; i < 4; ++i) {
156 auto pt = rect.corner(i) * aff;
157 buf.cr->line_to(pt.x(), pt.y());
159 buf.cr->close_path();
162 static std::valarray<double> dashes = {4.0, 4.0};
164 buf.cr->set_dash(dashes, -0.5);
173 buf.cr->stroke_preserve();
180 buf.cr->stroke_preserve();
186 buf.cr->fill_preserve();
192 buf.cr->fill_preserve();
197 buf.cr->set_dash(dashes, 3.5);
199 buf.cr->stroke_preserve();
202 buf.cr->begin_new_path();
272 }
else if (
size > 120) {
void ink_cairo_draw_drop_shadow(const Cairo::RefPtr< Cairo::Context > &ctx, const Geom::Rect &rect, double size, guint32 color, double color_alpha)
Draw drop shadow around the 'rect' with given 'size' and 'color'; shadow extends to the right and bot...
void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba)
Cairo integration helpers.
Coord descrim() const
Calculate the descriminant.
bool contains(GenericRect< C > const &r) const
Check whether the rectangle includes all points in the given rectangle.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
void set_rect(Geom::Rect const &rect)
Set a control rect.
void set_is_page(bool is_page)
void set_dashed(bool dash=true)
CanvasItemRect(CanvasItemGroup *group)
Create an null control rect.
void _render(Inkscape::CanvasItemBuffer &buf) const override
Render rect to screen via Cairo.
void set_fill(uint32_t color) override
double get_shadow_size() const
void visit_page_rects(std::function< void(Geom::Rect const &)> const &) const override
Run a callback for each rectangle that should be filled and painted in the background.
bool contains(Geom::Point const &p, double tolerance=0) override
Returns true if point p (in canvas units) is within tolerance (canvas units) distance of rect.
void set_inverted(bool inverted=false)
void _update(bool propagate) override
Update and redraw control rect.
void set_shadow(uint32_t color, int width)
double get_effective_outline() const
Get the effective outline.
Cairo::RefPtr< Cairo::Pattern > _fill_pattern
Geom::Affine const & affine() const
UI::Widget::Canvas * get_canvas() const
Geom::Affine const & doc2dt() const
constexpr uint32_t SP_RGBA32_A_U(uint32_t v)
constexpr double SP_RGBA32_A_F(uint32_t v)
Editable view implementation.
Specific geometry functions for Inkscape, not provided my lib2geom.
auto floor(Geom::Rect const &rect)
void shift(T &a, T &b, T const &c)
Affine identity()
Create an identity matrix.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
Helper class to stream background task notifications as a series of messages.
Class used when rendering canvas items.
Cairo::RectangleInt geom_to_cairo(const Geom::IntRect &rect)