13#include <glibmm/convert.h>
14#include <glibmm/main.h>
15#include <gdkmm/pixbuf.h>
60 auto drawing = std::make_shared<Inkscape::Drawing>();
123 static Glib::RefPtr<Gdk::Pixbuf> preview_loading;
124 if (!preview_loading || new_size) {
127 auto path = Glib::filename_from_utf8(path_utf8);
128 preview_loading = Gdk::Pixbuf::create_from_file(path,
size,
size);
130 if (preview_loading) {
131 set_pixbuf(preview_loading);
178 _render_idle = Glib::signal_timeout().connect([
this]() {
Cairo integration helpers.
Cairo::RefPtr< Cairo::ImageSurface > surface
Axis-aligned rectangle that can be empty.
Axis aligned, non-empty rectangle.
bool hasZeroArea(Coord eps=EPSILON) const
Check whether the rectangle has zero area up to specified tolerance.
SVG drawing item for display.
void setItem(SPItem const *item)
void resetPixels(bool new_size=false)
Inkscape::auto_connection _render_idle
~ExportPreview() override
void setSize(int newSize)
void setBox(Geom::Rect const &bbox)
void setDrawing(std::shared_ptr< PreviewDrawing > drawing)
void setBackgroundColor(std::uint32_t bg_color)
std::shared_ptr< PreviewDrawing > _drawing
void setPreview(Cairo::RefPtr< Cairo::ImageSurface >)
Callback when the rendering is complete.
sigc::connection refresh_conn
PreviewDrawing(SPDocument *document)
A preview drawing object is responsible for constructing a drawing and showing it's contents.
std::vector< SPItem const * > _shown_items
void construct()
Construct the drawing, when needed.
std::shared_ptr< Inkscape::Drawing > _drawing
Inkscape::auto_connection _construct_idle
bool render(ExportPreview *widget, std::uint32_t bg, SPItem const *item, unsigned size, Geom::OptRect const &dboxIn)
Render the drawing into a cairo image surface.
void set_shown_items(std::vector< SPItem const * > &&list={})
Limit the preview to just these items.
bool connected() const noexcept
Returns whether the connection is still active.
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
Base class for visual SVG elements.
Geom::OptRect documentVisualBounds() const
Get item's visual bbox in document coordinate system.
Inkscape::DrawingItem * invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags)
Inkscape::DrawingItem * get_arenaitem(unsigned key) const
Return the arenaitem corresponding to the given item in the display with the given key.
static unsigned int display_key_new(unsigned numkeys)
Allocates unique integer keys.
void invoke_hide_except(unsigned key, const std::vector< SPItem const * > &to_keep)
Invoke hide on all non-group items, except for the list of items to keep.
Util::ptr_shared get_path(Domain domain, Type type, char const *filename, char const *extra)
Cairo::RefPtr< Cairo::ImageSurface > render_preview(SPDocument *doc, std::shared_ptr< Inkscape::Drawing > drawing, uint32_t bg, Inkscape::DrawingItem *item, unsigned width_in, unsigned height_in, Geom::Rect const &dboxIn)
Launch a background task to render a drawing to a surface.
Utility functions for previewing icon representation.
Inkscape::IO::Resource - simple resource API.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPRoot: SVG <svg> implementation.