summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-10-14 14:25:28 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-10-14 14:25:28 +0000
commitd58f1115618f0458496b0e0a081238d5fda64ef5 (patch)
tree0d87bf8067744160cf824defc783f5ff73935399 /src/ui/dialog
parentPrevent returning references to local variable (diff)
downloadinkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.tar.gz
inkscape-d58f1115618f0458496b0e0a081238d5fda64ef5.zip
Re-Add blending modes UI using CSS instead filters
Diffstat (limited to 'src/ui/dialog')
-rw-r--r--src/ui/dialog/fill-and-stroke.cpp23
-rw-r--r--src/ui/dialog/filter-effects-dialog.h2
-rw-r--r--src/ui/dialog/objects.cpp60
3 files changed, 22 insertions, 63 deletions
diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp
index 2ac87186e..22dd407e7 100644
--- a/src/ui/dialog/fill-and-stroke.cpp
+++ b/src/ui/dialog/fill-and-stroke.cpp
@@ -41,18 +41,19 @@ namespace UI {
namespace Dialog {
FillAndStroke::FillAndStroke()
- : UI::Widget::Panel("/dialogs/fillstroke", SP_VERB_DIALOG_FILL_STROKE),
- _page_fill(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))),
- _page_stroke_paint(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))),
- _page_stroke_style(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))),
- _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke",
+ : UI::Widget::Panel("/dialogs/fillstroke", SP_VERB_DIALOG_FILL_STROKE)
+ , _page_fill(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true)))
+ , _page_stroke_paint(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true)))
+ , _page_stroke_style(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true)))
+ , _composite_settings(SP_VERB_DIALOG_FILL_STROKE, "fillstroke",
+ UI::Widget::SimpleFilterModifier::BLEND |
UI::Widget::SimpleFilterModifier::BLUR |
- UI::Widget::SimpleFilterModifier::OPACITY ),
- deskTrack(),
- targetDesktop(nullptr),
- fillWdgt(nullptr),
- strokeWdgt(nullptr),
- desktopChangeConn()
+ UI::Widget::SimpleFilterModifier::OPACITY)
+ , deskTrack()
+ , targetDesktop(nullptr)
+ , fillWdgt(nullptr)
+ , strokeWdgt(nullptr)
+ , desktopChangeConn()
{
Gtk::Box *contents = _getContents();
contents->set_spacing(2);
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 6f86df797..5c01a8395 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -23,7 +23,7 @@
#include <gtkmm/scrolledwindow.h>
#include "attributes.h"
-
+#include "display/nr-filter-types.h"
#include "ui/dialog/desktop-tracker.h"
#include "ui/widget/combo-enums.h"
#include "ui/widget/panel.h"
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index e0af43d52..e4655f4a3 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -585,20 +585,15 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
double opacity = (item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1);
opacity *= 100; // Display in percent.
_filter_modifier.set_opacity_value(opacity);
-
- SPFeBlend *spblend = nullptr;
+ // Set the blend mode
+ _filter_modifier.set_blend_mode(item->style->mix_blend_mode.set ? item->style->mix_blend_mode.value
+ : Inkscape::SP_CSS_BLEND_NORMAL);
SPGaussianBlur *spblur = nullptr;
if (item->style->getFilter()) {
-
for (auto& primitive_obj: item->style->getFilter()->children) {
if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) {
break;
}
- if (SP_IS_FEBLEND(&primitive_obj) && !spblend) {
- //Get the blend mode
- spblend = SP_FEBLEND(&primitive_obj);
- }
-
if (SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) {
//Get the blur value
spblur = SP_GAUSSIANBLUR(&primitive_obj);
@@ -606,9 +601,6 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
}
}
- //Set the blend mode
- _filter_modifier.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL);
-
//Set the blur value
double blur_value = 0;
if (spblur) {
@@ -1634,48 +1626,14 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl
//Since blur and blend are both filters, we need to set both at the same time
SPStyle *style = item->style;
g_assert(style != nullptr);
-
- if (blendmode != "normal") {
- gdouble radius = 0;
- if (item->style->getFilter()) {
- for (auto& primitive: item->style->getFilter()->children) {
- if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
- break;
- }
- // We should read in the current radius and use that!
- if (SP_IS_GAUSSIANBLUR(&primitive)) {
- Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX);
- if (bbox) {
- double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
- radius = _filter_modifier.get_blur_value() * perimeter / 400;
- }
- }
- }
- }
- if (radius != 0) {
- // The modify function expects radius to be in display pixels.
- Geom::Affine i2d (item->i2dt_affine());
- double expansion = i2d.descrim();
- radius *= expansion;
- }
- SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius);
- sp_style_set_property_url(item, "filter", filter, false);
+ SPCSSAttr *css = sp_css_attr_from_style(style, SP_STYLE_FLAG_ALWAYS | SP_STYLE_FLAG_IFSRC);
+ if (blendmode == "normal") {
+ sp_repr_css_unset_property(css, "mix-blend-mode");
} else {
- for (auto& primitive: item->style->getFilter()->children) {
- if (!SP_IS_FILTER_PRIMITIVE(&primitive)) {
- break;
- }
- if (SP_IS_FEBLEND(&primitive)) {
- primitive.deleteObject();
- break;
- }
- }
- if (!item->style->getFilter()->firstChild()) {
- remove_filter(item, false);
- }
+ sp_repr_css_set_property(css, "mix-blend-mode", blendmode.c_str());
}
-
- item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
+ sp_repr_css_change(item->getRepr(), css, "style");
+ sp_repr_css_attr_unref(css);
}
}