From e9dd6221693019fa5e7c07269878fe66a1b94112 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Thu, 26 Mar 2009 23:09:42 +0000 Subject: [PATCH] fix copy/paste of color from gradient stops --- src/ui/clipboard.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 6ba3ca156..d95af5a8b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -201,7 +201,28 @@ void ClipboardManagerImpl::copy() if (desktop->event_context->get_drag()) { GrDrag *drag = desktop->event_context->get_drag(); if (drag->hasSelection()) { - _setClipboardColor(drag->getColor()); + guint32 col = drag->getColor(); + + // set the color as clipboard content (text in RRGGBBAA format) + _setClipboardColor(col); + + // create a style with this color on fill and opacity in master opacity, so it can be + // pasted on other stops or objects + if (_text_style) { + sp_repr_css_attr_unref(_text_style); + _text_style = NULL; + } + _text_style = sp_repr_css_attr_new(); + // print and set properties + gchar color_str[16]; + g_snprintf(color_str, 16, "#%06x", col >> 8); + sp_repr_css_set_property(_text_style, "fill", color_str); + float opacity = SP_RGBA32_A_F(col); + if (opacity > 1.0) opacity = 1.0; // safeguard + Inkscape::CSSOStringStream opcss; + opcss << opacity; + sp_repr_css_set_property(_text_style, "opacity", opcss.str().data()); + _discardInternalClipboard(); return; } -- 2.30.2