void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) { g_return_if_fail(group != NULL); g_return_if_fail(NR_IS_ARENA_GROUP(group)); if (style) sp_style_ref(style); if (group->style) sp_style_unref(group->style); group->style = style; //if group has a filter if (style->filter.set && style->getFilter()) { if (!group->filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); group->filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter); } else { //no filter set for this group delete group->filter; group->filter = NULL; } if (style && style->enable_background.set && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { group->background_new = true; } }
static void sp_fill_style_widget_update_repr (SPWidget *spw, SPRepr *repr) { SPPaintSelector *psel; GtkWidget *fillrule; SPPaintSelectorMode pselmode; SPStyle *style; gfloat c[5]; if (g_object_get_data (G_OBJECT (spw), "update")) return; g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (TRUE)); #ifdef SP_FS_VERBOSE g_print ("FillStyleWidget: Set update flag\n"); #endif psel = SP_PAINT_SELECTOR(g_object_get_data (G_OBJECT (spw), "paint-selector")); style = sp_style_new (); sp_style_read_from_repr (style, repr); pselmode = sp_fill_style_determine_paint_selector_mode (style); #ifdef SP_FS_VERBOSE g_print ("FillStyleWidget: paint selector mode %d\n", pselmode); #endif switch (pselmode) { case SP_PAINT_SELECTOR_MODE_NONE: /* No paint at all */ sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_NONE); break; case SP_PAINT_SELECTOR_MODE_COLOR_RGB: sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_COLOR_RGB); sp_color_get_rgb_floatv (&style->fill.value.color, c); c[3] = SP_SCALE24_TO_FLOAT (style->fill_opacity.value); sp_paint_selector_set_color_rgba_floatv (psel, c); break; case SP_PAINT_SELECTOR_MODE_COLOR_CMYK: sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_COLOR_CMYK); sp_color_get_cmyk_floatv (&style->fill.value.color, c); c[4] = SP_SCALE24_TO_FLOAT (style->fill_opacity.value); sp_paint_selector_set_color_cmyka_floatv (psel, c); break; case SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR: break; default: break; } fillrule = GTK_WIDGET(g_object_get_data (G_OBJECT (spw), "fill-rule")); gtk_option_menu_set_history (GTK_OPTION_MENU (fillrule), (style->fill_rule.computed == ART_WIND_RULE_NONZERO) ? 0 : 1); sp_style_unref (style); g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (FALSE)); #ifdef SP_FS_VERBOSE g_print ("FillStyleWidget: Cleared update flag\n"); #endif }
DrawingItem::~DrawingItem() { _drawing.signal_item_deleted.emit(this); //if (!_children.empty()) { // g_warning("Removing item with children"); //} // remove from the set of cached items and delete cache setCached(false, true); if (_has_cache_iterator) { _drawing._candidate_items.erase(_cache_iterator); } // remove this item from parent's children list // due to the effect of clearChildren(), this only happens for the top-level deleted item if (_parent) { _markForRendering(); } switch (_child_type) { case CHILD_NORMAL: { ChildrenList::iterator ithis = _parent->_children.iterator_to(*this); _parent->_children.erase(ithis); } break; case CHILD_CLIP: // we cannot call setClip(NULL) or setMask(NULL), // because that would be an endless loop _parent->_clip = NULL; break; case CHILD_MASK: _parent->_mask = NULL; break; case CHILD_ROOT: _drawing._root = NULL; break; case CHILD_FILL_PATTERN: _parent->_fill_pattern = NULL; break; case CHILD_STROKE_PATTERN: _parent->_stroke_pattern = NULL; break; default: ; } if (_parent) { _parent->_markForUpdate(STATE_ALL, false); } clearChildren(); delete _transform; delete _stroke_pattern; delete _fill_pattern; delete _clip; delete _mask; delete _filter; if(_style) sp_style_unref(_style); }
/** * Process information related to the new style. * * Note: _style is not used by DrawingGlyphs which uses its parent style. */ void DrawingItem::setStyle(SPStyle *style, SPStyle *context_style) { // std::cout << "DrawingItem::setStyle: " << name() << " " << style // << " " << context_style << std::endl; if( style != _style ) { if (style) sp_style_ref(style); if (_style) sp_style_unref(_style); _style = style; } if (style && style->filter.set && style->getFilter()) { if (!_filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); _filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), _filter); } else { // no filter set for this group delete _filter; _filter = NULL; } if (style && style->enable_background.set) { if (style->enable_background.value == SP_CSS_BACKGROUND_NEW && !_background_new) { _background_new = true; _markForUpdate(STATE_BACKGROUND, true); } else if (style->enable_background.value == SP_CSS_BACKGROUND_ACCUMULATE && _background_new) { _background_new = false; _markForUpdate(STATE_BACKGROUND, true); } } if (context_style != NULL) { _context_style = context_style; } else if (_parent != NULL) { _context_style = _parent->_context_style; } _markForUpdate(STATE_ALL, false); }
void StyleSwatch::setStyle(SPCSSAttr *css) { if (_css) sp_repr_css_attr_unref (_css); if (!css) return; _css = sp_repr_css_attr_new(); sp_repr_css_merge(_css, css); gchar const *css_string = sp_repr_css_write_string (_css); SPStyle *temp_spstyle = sp_style_new(SP_ACTIVE_DOCUMENT); if (css_string) sp_style_merge_from_style_string (temp_spstyle, css_string); setStyle (temp_spstyle); sp_style_unref (temp_spstyle); }
Layout::InputStreamTextSource::~InputStreamTextSource() { sp_style_unref(style); }
DrawingGroup::~DrawingGroup() { if (_style) sp_style_unref(_style); }
void ObjectCompositeSettings::_subjectChanged() { if (!_subject) { return; } SPDesktop *desktop = _subject->getDesktop(); if (!desktop) { return; } if (_blocked) return; _blocked = true; SPStyle *query = sp_style_new (sp_desktop_document(desktop)); int result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY); switch (result) { case QUERY_STYLE_NOTHING: _opacity_vbox.set_sensitive(false); // gtk_widget_set_sensitive (opa, FALSE); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently case QUERY_STYLE_MULTIPLE_SAME: _opacity_vbox.set_sensitive(true); _opacity_scale.get_adjustment()->set_value(100 * SP_SCALE24_TO_FLOAT(query->opacity.value)); break; } //query now for current filter mode and average blurring of selection const int blend_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLEND); switch(blend_result) { case QUERY_STYLE_NOTHING: _fe_cb.set_sensitive(false); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_SAME: _fe_cb.set_blend_mode(query->filter_blend_mode.value); _fe_cb.set_sensitive(true); break; case QUERY_STYLE_MULTIPLE_DIFFERENT: // TODO: set text _fe_cb.set_sensitive(false); break; } if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) { int blur_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLUR); switch (blur_result) { case QUERY_STYLE_NOTHING: //no blurring _fe_cb.set_blur_sensitive(false); break; case QUERY_STYLE_SINGLE: case QUERY_STYLE_MULTIPLE_AVERAGED: case QUERY_STYLE_MULTIPLE_SAME: Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); if (bbox) { double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct? _fe_cb.set_blur_sensitive(true); //update blur widget value float radius = query->filter_gaussianBlur_deviation.value; float percent = radius * 400 / perimeter; // so that for a square, 100% == half side _fe_cb.set_blur_value(percent); } break; } } sp_style_unref(query); _blocked = false; }
static void sp_text_edit_dialog_read_selection ( GtkWidget *dlg, gboolean dostyle, gboolean docontent ) { if (g_object_get_data (G_OBJECT (dlg), "blocked")) return; g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (TRUE)); GtkWidget *notebook = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "notebook"); GtkWidget *textw = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "textw"); GtkWidget *fontsel = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "fontsel"); GtkWidget *preview = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "preview"); GtkWidget *apply = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "apply"); GtkWidget *def = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "default"); GtkTextBuffer *tb = (GtkTextBuffer*)g_object_get_data (G_OBJECT (dlg), "text"); SPItem *text = sp_ted_get_selected_text_item (); Inkscape::XML::Node *repr; if (text) { guint items = sp_ted_get_selected_text_count (); if (items == 1) { gtk_widget_set_sensitive (textw, TRUE); } else { gtk_widget_set_sensitive (textw, FALSE); } gtk_widget_set_sensitive (apply, FALSE); gtk_widget_set_sensitive (def, TRUE); if (docontent) { gchar *str; str = sp_te_get_string_multiline (text); if (str) { int pos; pos = 0; if (items == 1) { gtk_text_buffer_set_text (tb, str, strlen (str)); gtk_text_buffer_set_modified (tb, FALSE); } sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), str); g_free (str); } else { gtk_text_buffer_set_text (tb, "", 0); sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), NULL); } } // end of if (docontent) repr = SP_OBJECT_REPR (text); } else { gtk_widget_set_sensitive (textw, FALSE); gtk_widget_set_sensitive (apply, FALSE); gtk_widget_set_sensitive (def, FALSE); } if (dostyle) { // create temporary style SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection //int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); int result_family = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); int result_style = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); int result_numbers = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS); // If querying returned nothing, read the style from the text tool prefs (default style for new texts) // (Ok to not get a font specification - must just rely on the family and style in that case) if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) { sp_style_read_from_prefs(query, "/tools/text"); } // FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists // Get a font_instance using the font-specification attribute stored in SPStyle if available font_instance *font = font_factory::Default()->FaceFromStyle(query); if (font) { // the font is oversized, so we need to pass the true size separately sp_font_selector_set_font (SP_FONT_SELECTOR (fontsel), font, query->font_size.computed); sp_font_preview_set_font (SP_FONT_PREVIEW (preview), font, SP_FONT_SELECTOR(fontsel)); font->Unref(); font=NULL; } GtkWidget *b; if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) { if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_justify" ); } else { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_start" ); } } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_middle" ); } else { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_end" ); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), TRUE); if (query->writing_mode.computed == SP_CSS_WRITING_MODE_LR_TB) { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_STOCK_WRITING_MODE_LR ); } else { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), INKSCAPE_STOCK_WRITING_MODE_TB ); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b), TRUE); GtkWidget *combo = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "line_spacing" ); double height; if (query->line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL; else if (query->line_height.unit == SP_CSS_UNIT_PERCENT) height = query->line_height.value; else height = query->line_height.computed; gchar *sstr = g_strdup_printf ("%d%%", (int) floor(height * 100 + 0.5)); gtk_entry_set_text ((GtkEntry *) ((GtkCombo *) (combo))->entry, sstr); g_free(sstr); sp_style_unref(query); } g_object_set_data (G_OBJECT (dlg), "blocked", NULL); }