21#include <glibmm/i18n.h>
34 _name =
"CanvasItemText";
44 , _text(
std::move(text))
47 _name =
"CanvasItemText";
128 buf.cr->translate(-
buf.rect.left(), -
buf.rect.top());
143 buf.cr->rectangle(x, y,
w, h);
145 double radius =
_bg_rad * (std::min(
w ,h) / 2);
146 buf.cr->arc(x +
w - radius, y + radius, radius, -M_PI_2, 0);
147 buf.cr->arc(x +
w - radius, y + h - radius, radius, 0, M_PI_2);
148 buf.cr->arc(x + radius, y + h - radius, radius, M_PI_2, M_PI);
149 buf.cr->arc(x + radius, y + radius, radius, M_PI, 3*M_PI_2);
151 buf.cr->set_line_width(2);
157 auto bx = x +
w / 2.0;
158 auto by = y + h / 2.0 + 1;
162 buf.cr->select_font_face(
_fontname, Cairo::ToyFontFace::Slant::NORMAL, Cairo::ToyFontFace::Weight::NORMAL);
173 defer([
this, text = std::move(text)] ()
mutable {
174 if (
_text == text)
return;
175 _text = std::move(text);
200 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, 1, 1);
201 auto context = Cairo::Context::create(
surface);
202 context->select_font_face(
_fontname, Cairo::ToyFontFace::Slant::NORMAL, Cairo::ToyFontFace::Weight::NORMAL);
void ink_cairo_set_source_rgba32(cairo_t *ct, guint32 rgba)
Cairo integration helpers.
Cairo::RefPtr< Cairo::ImageSurface > surface
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
Axis aligned, non-empty rectangle.
IntRect roundOutwards() const
Return the smallest integer rectangle which contains this one.
Geom::Rect get_text_size() const
Cairo::TextExtents _text_size
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 text.
void set_fontsize(double fontsize)
void set_border(double border)
Geom::Point _anchor_position
void set_anchor(Geom::Point const &anchor_pt)
Set the anchor point, x and y between 0.0 and 1.0.
void set_background(uint32_t background)
void _render(Inkscape::CanvasItemBuffer &buf) const override
Render text to screen via Cairo.
CanvasItemText(CanvasItemGroup *group)
Create a null control text.
void set_fixed_line(bool fixed_line)
void set_adjust(Geom::Point const &adjust_pt)
Geom::Rect load_text_extents()
Load the sizes of the text extent using the given font.
Geom::Point _adjust_offset
void set_text(Glib::ustring text)
void _update(bool propagate) override
Update and redraw control text.
void set_coord(Geom::Point const &p)
Set a text position.
Cairo::TextExtents _text_extent
void set_bg_radius(double rad)
Set a text position.
Geom::Affine const & affine() const
auto floor(Geom::Rect const &rect)
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)