summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b57926)
raw | patch | inline | side by side (parent: 0b57926)
author | joncruz <joncruz@users.sourceforge.net> | |
Sun, 22 Mar 2009 08:41:00 +0000 (08:41 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sun, 22 Mar 2009 08:41:00 +0000 (08:41 +0000) |
src/ui/dialog/swatches.cpp | patch | blob | history |
index fdf320c06cf5c99880c1cc306a1b79a6f4e841d9..541f12627f5d0b9467d63e65c5383ddd08e5b3ff 100644 (file)
ColorItem* _linkSrc;
std::vector<ColorItem*> _listeners;
};
-
+
ColorItem::ColorItem(ege::PaintDef::ColorType type) :
static std::map<std::string, guint> mimeToInt;
static std::map<ColorItem*, guchar*> previewMap;
+static std::map<ColorItem*, SPGradient*> gradMap; // very temporary workaround.
void ColorItem::_dragGetColorData( GtkWidget */*widget*/,
GdkDragContext */*drag_context*/,
@@ -618,7 +619,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
guchar* px = previewMap[this];
int width = 128;
int height = 16;
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8,
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8,
width, height, width * 3,
0, // add delete function
0
break;
}
case ege::PaintDef::RGB: {
- gchar c[64];
- guint32 rgba = (def.getR() << 24) | (def.getG() << 16) | (def.getB() << 8) | 0xff;
- sp_svg_write_color(c, sizeof(c), rgba);
-
- sp_repr_css_set_property( css, attrName, c );
+ Glib::ustring colorspec;
+ if ( gradMap.find(this) == gradMap.end() ){
+ gchar c[64];
+ guint32 rgba = (def.getR() << 24) | (def.getG() << 16) | (def.getB() << 8) | 0xff;
+ sp_svg_write_color(c, sizeof(c), rgba);
+ colorspec = c;
+ } else {
+ SPGradient* grad = gradMap[this];
+ colorspec = "url(#";
+ colorspec += grad->id;
+ colorspec += ")";
+ }
+ sp_repr_css_set_property( css, attrName, colorspec.c_str() );
descr = secondary? _("Set stroke color from swatch") : _("Set fill color from swatch");
break;
}
ColorItem* item = new ColorItem( r, g, b, name );
item->ptr = this;
docPalette->_colors.push_back(item);
+ gradMap[item] = grad;
} else {
// Treat as gradient
Glib::ustring name( grad->id );
gint height = VBLOCK;
guchar* px = g_new( guchar, 3 * height * width );
nr_render_checkerboard_rgb( px, width, VBLOCK, 3 * width, 0, 0 );
-
+
sp_gradient_render_vector_block_rgb( grad,
px, width, height, 3 * width,
0, width, TRUE );
previewMap[item] = px;
+ gradMap[item] = grad;
}
}
}