diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-10-10 12:09:34 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-10-10 12:09:34 +0000 |
| commit | d24c375037551aa9e0e76768b9e47d4a4819082b (patch) | |
| tree | d6f870fa5314f4f9cc7e8d6c869e411bb22ed649 /src | |
| parent | Fix some canvas problems and refactorization (diff) | |
| parent | merge a fix and refactor (diff) | |
| download | inkscape-d24c375037551aa9e0e76768b9e47d4a4819082b.tar.gz inkscape-d24c375037551aa9e0e76768b9e47d4a4819082b.zip | |
Update to trunk
(bzr r15142.1.9)
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/sp-gradient.cpp | 63 | ||||
| -rw-r--r-- | src/sp-gradient.h | 6 | ||||
| -rw-r--r-- | src/ui/previewholder.cpp | 4 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/button.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/eraser-toolbar.cpp | 69 |
7 files changed, 89 insertions, 68 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6a2af6b4b..5eaac4b51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -502,9 +502,6 @@ add_executable(inkview ${view_SRC}) add_dependencies(inkscape inkscape_version) -if(WITH_DBUS) - add_dependencies(inkscape inkscape_dbus) -endif() set(INKSCAPE_TARGET_LIBS # order from automake @@ -529,6 +526,10 @@ set(INKSCAPE_TARGET_LIBS # Build everything except main and inkview.c in a shared library. add_library(inkscape_base SHARED ${inkscape_SRC} ${sp_SRC}) +if(WITH_DBUS) + add_dependencies(inkscape_base inkscape_dbus) +endif() + # Link the inkscape_base library against all external dependencies target_link_libraries(inkscape_base ${INKSCAPE_TARGET_LIBS}) diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index d3e38485b..333316697 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -46,6 +46,7 @@ #include "sp-radial-gradient.h" #include "sp-mesh-gradient.h" #include "sp-mesh-row.h" +#include "sp-mesh-patch.h" #include "sp-stop.h" /// Has to be power of 2 Seems to be unused. @@ -229,8 +230,6 @@ SPGradient::SPGradient() : SPPaintServer(), units(), state(2), vector() { - this->has_patches = 0; - this->ref = new SPGradientReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(SPGradient::gradientRefChanged), this)); @@ -250,6 +249,7 @@ SPGradient::SPGradient() : SPPaintServer(), units(), this->spread_set = FALSE; this->has_stops = FALSE; + this->has_patches = FALSE; this->vector.built = false; this->vector.stops.clear(); @@ -275,6 +275,17 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) this->has_stops = TRUE; break; } + if (SP_IS_MESHROW(&ochild)) { + for (auto& ochild2: ochild.children) { + if (SP_IS_MESHPATCH(&ochild2)) { + this->has_patches = TRUE; + break; + } + } + if (this->has_patches == TRUE) { + break; + } + } } this->readAttr( "gradientUnits" ); @@ -470,6 +481,9 @@ void SPGradient::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *re } } } + if ( ochild && SP_IS_MESHROW(ochild) ) { + this->has_patches = TRUE; + } /// \todo Fixme: should we schedule "modified" here? this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -485,11 +499,23 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; + this->has_patches = FALSE; for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } + if (SP_IS_MESHROW(&ochild)) { + for (auto& ochild2: ochild.children) { + if (SP_IS_MESHPATCH(&ochild2)) { + this->has_patches = TRUE; + break; + } + } + if (this->has_patches == TRUE) { + break; + } + } } if ( this->getStopCount() == 0 ) { @@ -766,6 +792,14 @@ static bool has_stopsFN(SPGradient const *gr) } /** + * True if gradient has patches (i.e. a mesh). + */ +static bool has_patchesFN(SPGradient const *gr) +{ + return gr->hasPatches(); +} + +/** * True if gradient has spread set. */ static bool has_spread_set(SPGradient const *gr) @@ -793,6 +827,16 @@ SPGradient *SPGradient::getVector(bool force_vector) return src; } +SPGradient *SPGradient::getArray(bool force_vector) +{ + SPGradient * src = chase_hrefs(this, has_patchesFN); + + // if (force_vector) { + // src = sp_gradient_ensure_vector_normalized(src); + // } + return src; +} + /** * Returns the effective spread of given gradient (climbing up the refs chain if needed). * @@ -1031,6 +1075,7 @@ void SPGradient::rebuildArray() } array.read( SP_MESHGRADIENT( this ) ); + has_patches = array.patch_columns() > 0; } Geom::Affine @@ -1132,6 +1177,20 @@ sp_gradient_create_preview_pattern(SPGradient *gr, double width) cairo_pattern_add_color_stop_rgba(pat, i->offset, i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity); } + } else { + + // For the moment, use the top row of nodes for preview. + unsigned columns = gr->array.patch_columns(); + + double offset = 1.0/double(columns); + + pat = cairo_pattern_create_linear(0, 0, width, 0); + + for (unsigned i = 0; i < columns+1; ++i) { + SPMeshNode* node = gr->array.node( 0, i*3 ); + cairo_pattern_add_color_stop_rgba(pat, i*offset, + node->color.v.c[0], node->color.v.c[1], node->color.v.c[2], node->opacity); + } } return pat; diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 7348bb5ca..51ba3090c 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -158,6 +158,12 @@ public: */ SPGradient *getVector(bool force_private = false); + /** + * Returns private mesh of given gradient (the gradient at the end of the href chain which has + * patches), optionally normalizing it. + */ + SPGradient *getArray(bool force_private = false); + //static GType getType(); /** Forces vector to be built, if not present (i.e. changed) */ diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index ef11daa3b..6fec65124 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -256,7 +256,7 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation ) // g_message(" anchor:%d", _anchor); Gtk::VBox::on_size_allocate( allocation ); - if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { +/* if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { Gtk::Requisition req; Gtk::Requisition req_natural; _insides->get_preferred_size(req, req_natural); @@ -267,7 +267,7 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation ) } else { dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); } - } + }*/ } //void PreviewHolder::on_size_request( Gtk::Requisition* requisition ) diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 301a3b2e0..ebc6fe919 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1011,8 +1011,8 @@ SelectedStyle::update() _mode[i] = SS_RGRADIENT; #ifdef WITH_MESH } else if (SP_IS_MESHGRADIENT(server)) { - SPGradient *vector = SP_GRADIENT(server)->getVector(); - sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector); + SPGradient *array = SP_GRADIENT(server)->getArray(); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), array); place->add(_gradient_box_m[i]); place->set_tooltip_text(__mgradient[i]); _mode[i] = SS_MGRADIENT; diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 3f4f1207a..485300a25 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -41,8 +41,8 @@ static void sp_button_class_init(SPButtonClass *klass) GtkButtonClass *button_class = GTK_BUTTON_CLASS(klass); object_class->dispose = sp_button_dispose; - widget_class->get_preferred_width = sp_button_get_preferred_width; - widget_class->get_preferred_height = sp_button_get_preferred_height; + //widget_class->get_preferred_width = sp_button_get_preferred_width; + //widget_class->get_preferred_height = sp_button_get_preferred_height; button_class->clicked = sp_button_clicked; } diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index bcfa662a2..64aace4e7 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -87,6 +87,16 @@ static void sp_erc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl ) update_presets_list(tbl); } +static void sp_set_tbl_eraser_mode_visibility(GObject *const tbl, const guint eraser_mode) +{ + gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, "split") ), (eraser_mode == ERASER_MODE_CUT)); + + const gboolean visibility = (eraser_mode != ERASER_MODE_DELETE); + const std::array<const gchar *, 6> arr = {"cap_rounding", "mass", "thinning", "tremor", "usepressure", "width"}; + for (const gchar * str : arr) { + gtk_action_set_visible( GTK_ACTION( g_object_get_data(tbl, str) ), visibility ); + } +} static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) { @@ -96,34 +106,7 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt( "/tools/eraser/mode", eraser_mode ); } - GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") ); - GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") ); - GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") ); - GtkAction *usepressure = GTK_ACTION( g_object_get_data(tbl, "usepressure") ); - GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(tbl, "cap_rounding") ); - GtkAction *thinning = GTK_ACTION( g_object_get_data(tbl, "thinning") ); - GtkAction *tremor = GTK_ACTION( g_object_get_data(tbl, "tremor") ); - if (eraser_mode != ERASER_MODE_DELETE) { - if(eraser_mode == ERASER_MODE_CUT) { - gtk_action_set_visible( split, TRUE ); - } else { - gtk_action_set_visible( split, FALSE ); - } - gtk_action_set_visible(usepressure, TRUE ); - gtk_action_set_visible(tremor, TRUE ); - gtk_action_set_visible(cap_rounding, TRUE ); - gtk_action_set_visible(thinning, TRUE ); - gtk_action_set_visible( mass, TRUE ); - gtk_action_set_visible( width, TRUE ); - } else { - gtk_action_set_visible(usepressure, FALSE ); - gtk_action_set_visible(tremor, FALSE ); - gtk_action_set_visible(cap_rounding, FALSE ); - gtk_action_set_visible(thinning, FALSE ); - gtk_action_set_visible( split, FALSE ); - gtk_action_set_visible( mass, FALSE ); - gtk_action_set_visible( width, FALSE ); - } + sp_set_tbl_eraser_mode_visibility(tbl, eraser_mode); // only take action if run by the attr_changed listener if (!g_object_get_data( tbl, "freeze" )) { // in turn, prevent listener from responding @@ -305,35 +288,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toogle_break_apart), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); } - GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") ); - GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") ); - GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") ); - GtkAction *usepressure = GTK_ACTION( g_object_get_data(holder, "usepressure") ); - GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(holder, "cap_rounding") ); - GtkAction *thinning = GTK_ACTION( g_object_get_data(holder, "thinning") ); - GtkAction *tremor = GTK_ACTION( g_object_get_data(holder, "tremor") ); - if (eraser_mode != ERASER_MODE_DELETE) { - if(eraser_mode == ERASER_MODE_CUT) { - gtk_action_set_visible( split, TRUE ); - } else { - gtk_action_set_visible( split, FALSE ); - } - gtk_action_set_visible(usepressure, TRUE ); - gtk_action_set_visible(tremor, TRUE ); - gtk_action_set_visible(cap_rounding, TRUE ); - gtk_action_set_visible(thinning, TRUE ); - gtk_action_set_visible( mass, TRUE ); - gtk_action_set_visible( width, TRUE ); - } else { - gtk_action_set_visible(usepressure, FALSE ); - gtk_action_set_visible(tremor, FALSE ); - gtk_action_set_visible(cap_rounding, FALSE ); - gtk_action_set_visible(thinning, FALSE ); - gtk_action_set_visible( split, FALSE ); - gtk_action_set_visible( mass, FALSE ); - gtk_action_set_visible( width, FALSE ); - } - + sp_set_tbl_eraser_mode_visibility(holder, eraser_mode); } /* |
