diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /src/object/sp-solid-color.cpp | |
parent | Initial commit. (diff) | |
download | inkscape-upstream.tar.xz inkscape-upstream.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/object/sp-solid-color.cpp')
-rw-r--r-- | src/object/sp-solid-color.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/object/sp-solid-color.cpp b/src/object/sp-solid-color.cpp new file mode 100644 index 0000000..53c206b --- /dev/null +++ b/src/object/sp-solid-color.cpp @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * @solid color class. + */ +/* Authors: + * Tavmjong Bah <tavjong@free.fr> + * + * Copyright (C) 2014 Tavmjong Bah + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ +#include <cairo.h> + +#include "sp-solid-color.h" + +#include "attributes.h" +#include "style.h" + + +/* + * Solid Color + */ +SPSolidColor::SPSolidColor() : SPPaintServer() { +} + +SPSolidColor::~SPSolidColor() = default; + +void SPSolidColor::build(SPDocument* doc, Inkscape::XML::Node* repr) { + SPPaintServer::build(doc, repr); + + this->readAttr( "style" ); + this->readAttr( "solid-color" ); + this->readAttr( "solid-opacity" ); +} + +/** + * Virtual build: set solidcolor attributes from its associated XML node. + */ + +void SPSolidColor::set(SPAttributeEnum key, const gchar* value) { + + if (SP_ATTRIBUTE_IS_CSS(key)) { + style->clear(key); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } else { + SPPaintServer::set(key, value); + } +} + +/** + * Virtual set: set attribute to value. + */ + +Inkscape::XML::Node* SPSolidColor::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:solidColor"); + } + + SPObject::write(xml_doc, repr, flags); + + return repr; +} + +cairo_pattern_t* SPSolidColor::pattern_new(cairo_t * /*ct*/, Geom::OptRect const & /*bbox*/, double opacity) { + + auto *c = &(this->style->solid_color); + cairo_pattern_t *cp = cairo_pattern_create_rgba ( c->value.color.v.c[0], c->value.color.v.c[1], c->value.color.v.c[2], SP_SCALE24_TO_FLOAT(this->style->solid_opacity.value) * opacity ); + + return cp; +} + + +/** + * Virtual write: write object attributes to repr. + */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |