=== modified file 'src/gradient-chemistry.cpp' --- src/gradient-chemistry.cpp 2012-05-25 23:32:52 +0000 +++ src/gradient-chemistry.cpp 2012-09-10 01:19:15 +0000 @@ -20,6 +20,9 @@ #include <2geom/transforms.h> #include <2geom/bezier-curve.h> +#include <2geom/crossing.h> +#include <2geom/line.h> +#include <2geom/angle.h> #include "style.h" #include "document-private.h" @@ -355,10 +358,42 @@ g_free(c); } } else if (SP_IS_LINEARGRADIENT(gr)) { - sp_repr_set_svg_double(repr, "x1", (center - Geom::Point(width/2, 0))[Geom::X]); - sp_repr_set_svg_double(repr, "y1", (center - Geom::Point(width/2, 0))[Geom::Y]); - sp_repr_set_svg_double(repr, "x2", (center + Geom::Point(width/2, 0))[Geom::X]); - sp_repr_set_svg_double(repr, "y2", (center + Geom::Point(width/2, 0))[Geom::Y]); + + // Assume horizontal line by default + Geom::Point p1 = center - Geom::Point(width/2, 0); + Geom::Point p2 = center + Geom::Point(width/2, 0); + + // Get the preferred gradient angle from prefs + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double angle = prefs->getDouble("/dialogs/gradienteditor/angle", 0.0); + Geom::Line grl(center, Geom::deg_to_rad(angle)); + + Geom::LineSegment bbl1(bbox->corner(0), bbox->corner(1)); + Geom::LineSegment bbl2(bbox->corner(1), bbox->corner(2)); + Geom::LineSegment bbl3(bbox->corner(2), bbox->corner(3)); + Geom::LineSegment bbl4(bbox->corner(3), bbox->corner(0)); + + // Find where our gradient line intersects the bounding box. + if (intersection(bbl1, grl)) { + //g_message("L1"); + p1 = bbl1.pointAt((*intersection(bbl1, grl)).ta); + p2 = bbl3.pointAt((*intersection(bbl3, grl)).ta); + } else if (intersection(bbl2, grl)) { + //g_message("L2"); + p2 = bbl2.pointAt((*intersection(bbl2, grl)).ta); + p1 = bbl4.pointAt((*intersection(bbl4, grl)).ta); + } + + if (angle < 0 || angle >= 180) { + std::swap(p1, p2); + //g_message("Swap"); + } + + sp_repr_set_svg_double(repr, "x1", p1[Geom::X]); + sp_repr_set_svg_double(repr, "y1", p1[Geom::Y]); + sp_repr_set_svg_double(repr, "x2", p2[Geom::X]); + sp_repr_set_svg_double(repr, "y2", p2[Geom::Y]); + } else { // Mesh // THIS IS BEING CALLED TWICE WHENEVER A NEW GRADIENT IS CREATED, WRITING HERE CAUSES PROBLEMS === modified file 'src/ui/dialog/inkscape-preferences.cpp' --- src/ui/dialog/inkscape-preferences.cpp 2012-08-30 00:36:57 +0000 +++ src/ui/dialog/inkscape-preferences.cpp 2012-09-10 01:20:18 +0000 @@ -478,6 +478,11 @@ _page_gradient.add_line( false, "", _misc_gradienteditor, "", _("When on, the Gradient Edit button in the Fill & Stroke dialog will show the legacy Gradient Editor dialog, when off the Gradient Tool will be used"), true); + _misc_gradientangle.init("/dialogs/gradienteditor/angle", -359, 359, 1, 90, 0, false, false); + _page_gradient.add_line( false, _("Linear gradient angle:"), _misc_gradientangle, "", + _("Default angle of new linear gradients (clockwise from horizontal"), false); + + //Dropper this->AddPage(_page_dropper, _("Dropper"), iter_tools, PREFS_PAGE_TOOLS_DROPPER); this->AddSelcueCheckbox(_page_dropper, "/tools/dropper", true); === modified file 'src/ui/dialog/inkscape-preferences.h' --- src/ui/dialog/inkscape-preferences.h 2012-08-30 00:36:57 +0000 +++ src/ui/dialog/inkscape-preferences.h 2012-09-09 05:30:27 +0000 @@ -300,6 +300,7 @@ UI::Widget::PrefCheckButton _misc_default_metadata; UI::Widget::PrefCheckButton _misc_forkvectors; UI::Widget::PrefCheckButton _misc_gradienteditor; + UI::Widget::PrefSpinButton _misc_gradientangle; UI::Widget::PrefCheckButton _misc_scripts; UI::Widget::PrefCheckButton _misc_namedicon_delay; === modified file 'src/widgets/dropper-toolbar.cpp' --- src/widgets/dropper-toolbar.cpp 2012-06-17 07:08:03 +0000 +++ src/widgets/dropper-toolbar.cpp 2012-09-09 02:24:17 +0000 @@ -60,12 +60,14 @@ #include "../helper/unit-tracker.h" #include "../pen-context.h" #include "../tools-switch.h" +#include "../ui/dialog/color-item.h" using Inkscape::UnitTracker; using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; +using Inkscape::UI::Dialogs::ColorItem; //######################## @@ -95,6 +97,49 @@ spinbutton_defocus(GTK_WIDGET(tbl)); } +void sp_dropper_add_hist(GObject* holder) +{ + EgeSelectOneAction *act = (EgeSelectOneAction *)g_object_get_data( holder, "history_action"); + //GtkTreeIter iter; + //GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)); + GtkListStore *model = (GtkListStore *)ege_select_one_action_get_model( act ); + + Glib::ustring str = "bill"; + ColorItem *ci = new ColorItem(128,240,32,str); + + //Gtk::Widget* thing = manage(ci->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, 16, 0.5)); + + Glib::RefPtr thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, 32, 32 ); + guint32 fillWith = (0xff000000 & (ci->def.getR() << 24)) + | (0x00ff0000 & (ci->def.getG() << 16)) + | (0x0000ff00 & (ci->def.getB() << 8)); + thumb->fill( fillWith ); + GdkPixbuf *pb =thumb->gobj(); + g_object_ref(G_OBJECT(pb)); + + GtkTreeIter iter; + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("Color 1"), + 1, pb, + -1 ); + + ColorItem *ci2 = new ColorItem(255,1,32,str); + Glib::RefPtr thumb2 = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, 32, 32 ); + guint32 fillWith2 = (0xff000000 & (ci2->def.getR() << 24)) + | (0x00ff0000 & (ci2->def.getG() << 16)) + | (0x0000ff00 & (ci2->def.getB() << 8)); + thumb2->fill( fillWith2 ); + GdkPixbuf *pb2 =thumb->gobj(); + g_object_ref(G_OBJECT(pb2)); + + + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("Color 2"), + 1, pb2, + -1 ); +} /** * Dropper auxiliary toolbar construction and setup. @@ -141,6 +186,38 @@ gtk_action_set_sensitive( GTK_ACTION(act), pickAlpha ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_dropper_set_alpha), holder ); } + + + /* Mode */ + { + GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, GDK_TYPE_PIXBUF ); + GtkTreeIter iter; + + EgeSelectOneAction* act = ege_select_one_action_new( "DropperHistoryAction", _("History"), (""), NULL, GTK_TREE_MODEL(model) ); + g_object_set( act, "short_label", _("History:"), NULL ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + g_object_set_data( holder, "history_action", act ); + + + Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); + + ege_select_one_action_set_appearance( act, "full" ); + //ege_select_one_action_set_appearance( act, "compact" ); + //ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); + //g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); + //ege_select_one_action_set_icon_column( act, 2 ); + //ege_select_one_action_set_icon_size( act, secondarySize ); + //ege_select_one_action_set_tooltip_column( act, 1 ); + + sp_dropper_add_hist(holder); + + //gint mode = prefs->getInt("/tools/tweak/mode", 0); + //ege_select_one_action_set_active( act, mode ); + //g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_tweak_mode_changed), holder ); + + //g_object_set_data( G_OBJECT(holder), "tweak_tool_mode", act); + } + } === modified file 'src/widgets/toolbox.cpp' --- src/widgets/toolbox.cpp 2012-08-15 19:20:02 +0000 +++ src/widgets/toolbox.cpp 2012-09-09 01:37:52 +0000 @@ -523,6 +523,7 @@ " " " " " " + " " " " " "