Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
translucency-group.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Render some items as translucent in a document rendering stack.
4 *
5 * Author:
6 * Martin Owens <doctormo@geek-2.com>
7 *
8 * Copyright (C) 2021-2024 Martin Owens
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#include "translucency-group.h"
14
16
17#include "document.h"
18#include "object/sp-item.h"
19#include "object/sp-root.h"
20#include "style.h"
21
22namespace Inkscape::Display {
23
24static double TRANSLUCENCY_AMOUNT = 0.2;
25
27 : _dkey(dkey)
28{}
29
34{
35 if (item == _solid_item)
36 return;
37
38 // Set the target item, this prevents rerunning rendering.
40
41 // Reset all the items in the list.
42 for (auto &item : _translucent_items) {
43 if (auto arenaitem = item->get_arenaitem(_dkey)) {
44 arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(item->style->opacity.value));
45 }
46 }
47 _translucent_items.clear();
48
49 if (item) {
51
52 for (auto &item : _translucent_items) {
55 }
56 }
57}
58
63{
64 if (parent == _solid_item)
65 return;
66 if (parent->isAncestorOf(_solid_item)) {
67 for (auto &child: parent->children) {
68 if (auto item = cast<SPItem>(&child)) {
70 }
71 }
72 } else {
73 _translucent_items.push_back(parent);
74 }
75}
76
77} /* namespace Inkscape::Display */
78
79/*
80 Local Variables:
81 mode:c++
82 c-file-style:"stroustrup"
83 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
84 indent-tabs-mode:nil
85 fill-column:99
86 End:
87*/
88// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
void _generateTranslucentItems(SPItem *parent)
Generate a new list of sibling items (recursive)
std::vector< SPItem * > _translucent_items
void setSolidItem(SPItem *item)
Set a specific item as the solid item, all other items are made translucent.
SVG drawing item for display.
void setOpacity(float opacity)
SPRoot * getRoot()
Returns our SPRoot.
Definition document.h:200
Base class for visual SVG elements.
Definition sp-item.h:109
Inkscape::DrawingItem * get_arenaitem(unsigned key) const
Return the arenaitem corresponding to the given item in the display with the given key.
Definition sp-item.cpp:1856
SPDocument * document
Definition sp-object.h:188
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Definition sp-object.h:248
T< SPAttr::OPACITY, SPIScale24 > opacity
opacity
Definition style.h:216
static char const *const parent
Definition dir-util.cpp:70
Canvas item belonging to an SVG drawing element.
SPItem * item
Rendering-related code.
Definition desktop.h:133
static double TRANSLUCENCY_AMOUNT
Ocnode * child[8]
Definition quantize.cpp:33
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPRoot: SVG <svg> implementation.
SPStyle - a style object for SPItem objects.
Render some items as translucent in a document rendering stack.