Generated reference › API — ICoreEssentials/UI/Media
kind: generated#api#icoreessentials-ui-media

API — ICoreEssentials/UI/Media

The public contract of 2 header(s) under src/ICoreEssentials/UI/Media — 1 class/struct definition(s), 11 declaration(s). Each section shows the header's banner and its public (and protected-virtual) surface exactly as the file writes it.

HeaderDefinesDeclarationsBases
ICoreSvg.hICoreSvg11
ICoreSvgWriter.h0

ICoreSvg.h#

src/ICoreEssentials/UI/Media/ICoreSvg.h

ICoreSvg#

ICoreSvg.h:43 · class · pImpl · 11 declaration(s)

ICoreSvg -- the editor's vector-art reader.

class ICoreSvg {
public:
    ICoreSvg();

    // Markup, not a path: this is what ICoreIcons::themedBlockArt hands back,
    // and it is how every block glyph in the editor is built.
    explicit ICoreSvg(const ICoreByteArray& contents);

    // A resource path (":/SVGs/...") or a file on disk.
    explicit ICoreSvg(const ICoreString& fileName);

    ~ICoreSvg();

    // Non-copyable: it owns a parsed document, and no call site copies one.
    ICoreSvg(const ICoreSvg&) = delete;
    ICoreSvg& operator=(const ICoreSvg&) = delete;

    // Did the markup parse? Every rasteriser below returns a null pixmap when
    // it did not -- a null icon leaves a row readable by its text, an empty box
    // does not.
    [[nodiscard]] bool isValid() const;

    // The drawing's own size, as authored. Empty when the markup did not parse,
    // which the one caller checks before using it to fit an aspect ratio.
    [[nodiscard]] ICoreSizeF defaultSize() const;

    // The whole drawing into a transparent square pixmap of `side * scale`
    // device pixels. `scale` is oversampling for art that will be scaled down
    // again by the widget that shows it -- the canvas auto-inserter renders at
    // 3x so its icons hold up when the canvas is zoomed in.
    [[nodiscard]] ICorePixmap toPixmap(int side, int scale = 1) const;

    // `side` LOGICAL pixels at `devicePixelRatio`, flooded with `tint`. The
    // returned pixmap carries the ratio, so a caller hands it straight to a
    // painter or an icon without scaling it again.
    [[nodiscard]] ICorePixmap toTintedPixmap(int side, const ICoreColor& tint,
                                             double devicePixelRatio) const;

    // The untinted twin of toTintedPixmap: the artwork in its own colours, at
    // the display's pixel ratio. A two-tone mark (the wordmark) cannot be
    // flooded, so tinting is not an option for it.
    //
    // Deliberately NOT an overload of toPixmap(side, scale) above. That one
    // multiplies the pixel COUNT and leaves the ratio at 1 -- a bigger image,
    // not a sharper one at the same size -- and the two would differ only in an
    // int versus a real, which is not a distinction a call site should have to
    // notice to get the right one.
    [[nodiscard]] ICorePixmap toPixmapForDisplay(int side, double devicePixelRatio) const;

    // Draw into a painter the caller already has, inside `target`.
    void render(ICorePainter& painter, const ICoreRect& target) const;

private:
    class Impl;                    // the two-line residue; state lives here
    std::unique_ptr<Impl> impl;
};

ICoreSvgWriter.h#

src/ICoreEssentials/UI/Media/ICoreSvgWriter.h

ICoreSvgWriter -- the vector-art writer. Chart export is its only consumer.

Split out of ICoreSvg.{h,cpp} (task P1.6), where it had nothing in common with the reader beyond the letters S, V and G.

⚠ THIS IS AN INVERTED API, NOT A WRAPPED ONE, and the reason is worth keeping (task P1.7). QSvgGenerator is a QPaintDevice, so the one thing a caller used to do with it --

ICoreSvgWriter svg; svg.setBounds(...); QPainter painter(&svg);

-- needed the generator's ADDRESS, as a QPaintDevice*. A handle getter cannot help there: the caller has to construct a QPainter on it, and QPainter is a Qt type a client may not name. So the painter is created

Declares no class of its own — see the file.