diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-10-14 20:24:55 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-10-14 20:24:55 +0000 |
| commit | 40cd3380a76c79cd09733ae01053750cf731b674 (patch) | |
| tree | bd33ff51aa43b539a56d339776986aa28835ccab /src/widgets | |
| parent | Working with rotate widget (diff) | |
| parent | Implement copying of objects with mesh gradients. (diff) | |
| download | inkscape-40cd3380a76c79cd09733ae01053750cf731b674.tar.gz inkscape-40cd3380a76c79cd09733ae01053750cf731b674.zip | |
Update to trunk
(bzr r15142.1.12)
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/fill-style.cpp | 9 | ||||
| -rw-r--r-- | src/widgets/paint-selector.cpp | 102 | ||||
| -rw-r--r-- | src/widgets/paint-selector.h | 5 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 22 |
4 files changed, 104 insertions, 34 deletions
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index c35519b68..636d892f8 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -37,6 +37,7 @@ #include "gradient-chemistry.h" #include "inkscape.h" #include "sp-linear-gradient.h" +#include "sp-mesh-gradient.h" #include "sp-pattern.h" #include "sp-radial-gradient.h" #include "style.h" @@ -295,6 +296,14 @@ void FillNStroke::performUpdate() SPRadialGradient *rg = SP_RADIALGRADIENT(server); psel->setGradientProperties( rg->getUnits(), rg->getSpread() ); +#ifdef WITH_MESH + } else if (SP_IS_MESHGRADIENT(server)) { + SPGradient *array = SP_MESHGRADIENT(server)->getArray(); + psel->setGradientMesh( array ); + + SPMeshGradient *mg = SP_MESHGRADIENT(server); + psel->setMeshProperties( mg->getUnits() ); +#endif } else if (SP_IS_PATTERN(server)) { SPPattern *pat = SP_PATTERN(server)->rootPattern(); psel->updatePatternList( pat ); diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index ddac90730..3e9f0687d 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -78,6 +78,9 @@ static void sp_paint_selector_set_mode_multiple(SPPaintSelector *psel); static void sp_paint_selector_set_mode_none(SPPaintSelector *psel); static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelector::Mode mode); static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSelector::Mode mode); +#ifdef WITH_MESH +static void sp_paint_selector_set_mode_mesh(SPPaintSelector *psel, SPPaintSelector::Mode mode); +#endif static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSelector::Mode mode); static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSelector::Mode mode); static void sp_paint_selector_set_mode_unset(SPPaintSelector *psel); @@ -95,12 +98,14 @@ static gchar const* modeStrings[] = { "MODE_SOLID_COLOR", "MODE_GRADIENT_LINEAR", "MODE_GRADIENT_RADIAL", +#ifdef WITH_MESH + "MODE_GRADIENT_MESH", +#endif "MODE_PATTERN", "MODE_SWATCH", "MODE_UNSET", ".", ".", - ".", }; #endif @@ -109,9 +114,6 @@ static bool isPaintModeGradient(SPPaintSelector::Mode mode) { bool isGrad = (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) || -#ifdef WITH_MESH - (mode == SPPaintSelector::MODE_GRADIENT_MESH) || -#endif (mode == SPPaintSelector::MODE_SWATCH); return isGrad; @@ -386,11 +388,13 @@ void SPPaintSelector::setMode(Mode mode) break; case MODE_GRADIENT_LINEAR: case MODE_GRADIENT_RADIAL: + sp_paint_selector_set_mode_gradient(this, mode); + break; #ifdef WITH_MESH case MODE_GRADIENT_MESH: -#endif - sp_paint_selector_set_mode_gradient(this, mode); + sp_paint_selector_set_mode_mesh(this, mode); break; +#endif case MODE_PATTERN: sp_paint_selector_set_mode_pattern(this, mode); break; @@ -488,17 +492,17 @@ void SPPaintSelector::setGradientRadial(SPGradient *vector) } #ifdef WITH_MESH -void SPPaintSelector::setGradientMesh(SPGradient *vector) +void SPPaintSelector::setGradientMesh(SPGradient *array) { #ifdef SP_PS_VERBOSE g_print("PaintSelector set GRADIENT MESH\n"); #endif - setMode(MODE_GRADIENT_RADIAL); + setMode(MODE_GRADIENT_MESH); - SPGradientSelector *gsel = getGradientFromData(this); + // SPGradientSelector *gsel = getGradientFromData(this); - gsel->setMode(SPGradientSelector::MODE_MESH); - gsel->setVector((vector) ? vector->document : 0, vector); + // gsel->setMode(SPGradientSelector::MODE_GRADIENT_MESH); + // gsel->setVector((mesh) ? mesh->document : 0, mesh); } #endif @@ -520,6 +524,25 @@ void SPPaintSelector::getGradientProperties( SPGradientUnits &units, SPGradientS spread = gsel->getSpread(); } +#ifdef WITH_MESH +void SPPaintSelector::setMeshProperties( SPGradientUnits units ) +{ + g_return_if_fail(mode == MODE_GRADIENT_MESH); + + // SPGradientSelector *gsel = getGradientFromData(this); + // gsel->setUnits(units); +} + +void SPPaintSelector::getMeshProperties( SPGradientUnits &units) const +{ + g_return_if_fail(mode == MODE_GRADIENT_MESH); + + // SPGradientSelector *gsel = getGradientFromData(this); + // units = gsel->getUnits(); +} +#endif + + /** * \post (alpha == NULL) || (*alpha in [0.0, 1.0]). */ @@ -730,11 +753,6 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe } else if (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) { sp_paint_selector_set_style_buttons(psel, psel->radial); } -#ifdef WITH_MESH - else { - sp_paint_selector_set_style_buttons(psel, psel->mesh); - } -#endif gtk_widget_set_sensitive(psel->style, TRUE); if ((psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (psel->mode == SPPaintSelector::MODE_GRADIENT_RADIAL)) { @@ -764,18 +782,58 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL); gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Radial gradient</b>")); } -#ifdef WITH_MESH - else { - SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_MESH); - gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Mesh gradient</b>")); - } -#endif #ifdef SP_PS_VERBOSE g_print("Gradient req\n"); #endif } +#ifdef WITH_MESH +static void sp_paint_selector_set_mode_mesh(SPPaintSelector *psel, SPPaintSelector::Mode mode) +{ + if (mode == SPPaintSelector::MODE_GRADIENT_MESH) { + sp_paint_selector_set_style_buttons(psel, psel->mesh); + } + gtk_widget_set_sensitive(psel->style, TRUE); + + GtkWidget *tbl = NULL; + + if (psel->mode == SPPaintSelector::MODE_GRADIENT_MESH) { + /* Already have mesh selector */ + tbl = GTK_WIDGET(g_object_get_data(G_OBJECT(psel->selector), "mesh-selector")); + } else { + sp_paint_selector_clear_frame(psel); + + /* We could create a new gradient selector once adapted for meshes. + But for the moment we just create an empty widget. */ + /* Create vbox */ + tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_set_homogeneous(GTK_BOX(tbl), FALSE); + gtk_widget_show(tbl); + + { + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); + auto l = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(l), _("Use the <b>Mesh tool</b> to create new and edit existing meshes. Mesh selection and copying not yet implemented.")); + gtk_label_set_line_wrap(GTK_LABEL(l), true); + gtk_widget_set_size_request(l, 180, -1); + gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); + gtk_box_pack_start(GTK_BOX(tbl), hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); + } + + gtk_widget_show_all(tbl); + + gtk_container_add(GTK_CONTAINER(psel->frame), tbl); + psel->selector = tbl; + g_object_set_data(G_OBJECT(psel->selector), "mesh-selector", tbl); + + gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Mesh gradient</b>")); + } + +} +#endif + static void sp_paint_selector_set_style_buttons(SPPaintSelector *psel, GtkWidget *active) { diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index dde14b6a6..815a6da0b 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -98,13 +98,16 @@ struct SPPaintSelector { void setGradientLinear( SPGradient *vector ); void setGradientRadial( SPGradient *vector ); #ifdef WITH_MESH - void setGradientMesh(SPGradient *vector); + void setGradientMesh(SPGradient *array); #endif void setSwatch( SPGradient *vector ); void setGradientProperties( SPGradientUnits units, SPGradientSpread spread ); void getGradientProperties( SPGradientUnits &units, SPGradientSpread &spread ) const; + void setMeshProperties( SPGradientUnits units ); + void getMeshProperties( SPGradientUnits &units ) const; + void pushAttrsToGradient( SPGradient *gr ) const; SPGradient *getGradientVector(); SPPattern * getPattern(); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 610d743a0..788ac4eb3 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1602,7 +1602,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje _(tooltip.c_str()), NULL, GTK_TREE_MODEL(model_size), - 4, // Width in characters + 4, // Width in characters 0, // Extra list width NULL, // Cell layout NULL, // Separator @@ -1624,7 +1624,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje _("Font style"), NULL, GTK_TREE_MODEL(model_style), - 12, // Width in characters + 12, // Width in characters 0, // Extra list width NULL, // Cell layout NULL, // Separator @@ -1654,7 +1654,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje _("Toggle Subscript"), // Label _("Toggle subscript"), // Tooltip "text_subscript", // Icon (inkId) - secondarySize ); // Icon size + secondarySize ); // Icon size gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_text_script_changed), holder ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/text/sub", false) ); @@ -1748,8 +1748,8 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje -1 ); EgeSelectOneAction* act = ege_select_one_action_new( "TextWritingModeAction", // Name - _("Writing mode"), // Label - _("Block progression"), // Tooltip + _("Writing mode"), // Label + _("Block progression"), // Tooltip NULL, // Icon name GTK_TREE_MODEL(model) ); // Model @@ -1841,7 +1841,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextLineHeightAction", /* name */ _("Line Height"), /* label */ _("Line:"), /* short label */ - _("Spacing between baselines (times font size)"), /* tooltip */ + _("Spacing between baselines"), /* tooltip */ "/tools/text/lineheight", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -1880,7 +1880,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextWordSpacingAction", /* name */ _("Word spacing"), /* label */ _("Word:"), /* short label */ - _("Spacing between words (px)"), /* tooltip */ + _("Spacing between words (px)"), /* tooltip */ "/tools/text/wordspacing", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -1911,7 +1911,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextLetterSpacingAction", /* name */ _("Letter spacing"), /* label */ _("Letter:"), /* short label */ - _("Spacing between letters (px)"), /* tooltip */ + _("Spacing between letters (px)"), /* tooltip */ "/tools/text/letterspacing", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -1942,7 +1942,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextDxAction", /* name */ _("Kerning"), /* label */ _("Kern:"), /* short label */ - _("Horizontal kerning (px)"), /* tooltip */ + _("Horizontal kerning (px)"), /* tooltip */ "/tools/text/dx", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -1973,7 +1973,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextDyAction", /* name */ _("Vertical Shift"), /* label */ _("Vert:"), /* short label */ - _("Vertical shift (px)"), /* tooltip */ + _("Vertical shift (px)"), /* tooltip */ "/tools/text/dy", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ @@ -2004,7 +2004,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "TextRotationAction", /* name */ _("Letter rotation"), /* label */ _("Rot:"), /* short label */ - _("Character rotation (degrees)"),/* tooltip */ + _("Character rotation (degrees)"), /* tooltip */ "/tools/text/rotation", /* preferences path */ 0.0, /* default */ GTK_WIDGET(desktop->canvas), /* focusTarget */ |
