summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f9a92ac)
raw | patch | inline | side by side (parent: f9a92ac)
author | joncruz <joncruz@users.sourceforge.net> | |
Tue, 3 Mar 2009 10:01:27 +0000 (10:01 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Tue, 3 Mar 2009 10:01:27 +0000 (10:01 +0000) |
src/interface.cpp | patch | blob | history | |
src/ui/dialog/swatches.cpp | patch | blob | history |
diff --git a/src/interface.cpp b/src/interface.cpp
index 77c1e36b7ea4d910ebac8ef69e90b5d9763ef072..e7a3d6f28399c88c5986a24933ec5c947d70d7ac 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
JPEG_DATA,
IMAGE_DATA,
APP_X_INKY_COLOR,
- APP_X_COLOR
+ APP_X_COLOR,
+ APP_X_NOCOLOR
} ui_drop_target_info;
static GtkTargetEntry ui_drop_target_entries [] = {
#if ENABLE_MAGIC_COLORS
{(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
+ {(gchar *)"application/x-inkscape-nocolor", 0, APP_X_NOCOLOR },
{(gchar *)"application/x-color", 0, APP_X_COLOR }
};
}
break;
+ case APP_X_NOCOLOR:
+ {
+ gchar* c = g_strdup("none"); // temp
+ int destX = 0;
+ int destY = 0;
+ gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
+ Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) );
+ Geom::Point const button_dt(desktop->w2d(where));
+ Geom::Point const button_doc(desktop->dt2doc(button_dt));
+
+ SPItem *item = desktop->item_at_point( where, true );
+
+ bool consumed = false;
+ if (desktop->event_context && desktop->event_context->get_drag()) {
+ consumed = desktop->event_context->get_drag()->dropColor(item, c, button_dt);
+ if (consumed) {
+ sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient"));
+ desktop->event_context->get_drag()->updateDraggers();
+ }
+ }
+
+ if (!consumed && item) {
+ bool fillnotstroke = (drag_context->action != GDK_ACTION_MOVE);
+ if (fillnotstroke &&
+ (SP_IS_SHAPE(item) || SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))) {
+ Path *livarot_path = Path_for_item(item, true, true);
+ livarot_path->ConvertWithBackData(0.04);
+
+ boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
+ if (position) {
+ Geom::Point nearest = get_point_on_Path(livarot_path, position->piece, position->t);
+ Geom::Point delta = nearest - button_doc;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ delta = desktop->d2w(delta);
+ double stroke_tolerance =
+ ( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
+ desktop->current_zoom() *
+ SP_OBJECT_STYLE (item)->stroke_width.computed *
+ to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5
+ : 0.0)
+ + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+
+ if (Geom::L2 (delta) < stroke_tolerance) {
+ fillnotstroke = false;
+ }
+ }
+ delete livarot_path;
+ }
+
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property( css, fillnotstroke ? "fill":"stroke", c );
+
+ sp_desktop_apply_css_recursive( item, css, true );
+ item->updateRepr();
+
+ sp_document_done( doc , SP_VERB_NONE,
+ _("Drop color"));
+ }
+ g_free(c);
+ }
+ break;
+
case SVG_DATA:
case SVG_XML_DATA: {
gchar *svgdata = (gchar *)data->data;
index dfb60c04e590a1d3c0f20026e88f904a17127811..ff4934912d5dbeaabd55aa8a99ae77a6888f6657 100644 (file)
APP_X_INKY_COLOR_ID = 0,
APP_X_INKY_COLOR = 0,
APP_X_COLOR,
+ APP_X_NOCOLOR,
TEXT_DATA
} colorFlavorType;
{"text/plain", 0, TEXT_DATA},
};
+static const GtkTargetEntry sourceNoColorEntries[] = {
+ {"application/x-inkscape-nocolor", 0, APP_X_NOCOLOR},
+ {"application/x-color", 0, APP_X_COLOR},
+ {"text/plain", 0, TEXT_DATA},
+};
+
void ColorItem::_dragGetColorData( GtkWidget *widget,
GdkDragContext *drag_context,
GtkSelectionData *data,
}
}
+// if ( found ) {
+// g_message("Found the color at entry %d in palette '%s'", index, paletteName.c_str() );
+// } else {
+// g_message("Unable to find the color");
+// }
+ int itemCount = 4 + 2 + 1 + paletteName.length();
+
+ guint16* tmp = new guint16[itemCount];
+ tmp[0] = (item->def.getR() << 8) | item->def.getR();
+ tmp[1] = (item->def.getG() << 8) | item->def.getG();
+ tmp[2] = (item->def.getB() << 8) | item->def.getB();
+ tmp[3] = 0xffff;
+ tmp[4] = (item->_isLive || !item->_listeners.empty() || (item->_linkSrc != 0) ) ? 1 : 0;
+
+ tmp[5] = index;
+ tmp[6] = paletteName.length();
+ for ( unsigned int i = 0; i < paletteName.length(); i++ ) {
+ tmp[7 + i] = paletteName[i];
+ }
+ gtk_selection_data_set( data,
+ typeXColor,
+ 16, // format
+ reinterpret_cast<const guchar*>(tmp),
+ itemCount * 2);
+ delete[] tmp;
+ } else if ( info == APP_X_NOCOLOR ) {
+ Glib::ustring paletteName;
+
+ // Find where this thing came from
+ bool found = false;
+ int index = 0;
+ for ( std::vector<JustForNow*>::iterator it = possible.begin(); it != possible.end() && !found; ++it ) {
+ JustForNow* curr = *it;
+ index = 0;
+ for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) {
+ if ( item == *zz ) {
+ found = true;
+ paletteName = curr->_name;
+ break;
+ } else {
+ index++;
+ }
+ }
+ }
+
// if ( found ) {
// g_message("Found the color at entry %d in palette '%s'", index, paletteName.c_str() );
// } else {
}
break;
}
+ case APP_X_NOCOLOR:
+ {
+// g_message("APP_X_NOCOLOR dropping through to x-color");
+ }
case APP_X_COLOR:
{
if ( data->length == 8 ) {
@@ -643,11 +699,19 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS
G_CALLBACK(handleButtonPress),
this);
- gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
- GDK_BUTTON1_MASK,
- sourceColorEntries,
- G_N_ELEMENTS(sourceColorEntries),
- GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
+ if ( isRemove() ) {
+ gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
+ GDK_BUTTON1_MASK,
+ sourceNoColorEntries,
+ G_N_ELEMENTS(sourceNoColorEntries),
+ GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
+ } else {
+ gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
+ GDK_BUTTON1_MASK,
+ sourceColorEntries,
+ G_N_ELEMENTS(sourceColorEntries),
+ GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
+ }
g_signal_connect( G_OBJECT(newBlot->gobj()),
"drag-data-get",