Logo Search packages:      
Sourcecode: inkscape version File versions

int objects_query_strokecap ( GSList *  objects,
SPStyle style_res 
)

Write to style_res the stroke cap of a list of objects.

Definition at line 749 of file desktop-style.cpp.

References SPIPaint::isNone(), SPIEnum::set, SPStyle::stroke, SPStyle::stroke_linecap, and SPIEnum::value.

Referenced by sp_desktop_query_style_from_list().

{
    if (g_slist_length(objects) == 0) {
        /* No objects, set empty */
        return QUERY_STYLE_NOTHING;
    }

    int cap = -1;
    gdouble prev_cap = -1;
    bool same_cap = true;
    int n_stroked = 0;

    for (GSList const *i = objects; i != NULL; i = i->next) {
        SPObject *obj = SP_OBJECT (i->data);
        if (!SP_IS_ITEM(obj)) continue;
        SPStyle *style = SP_OBJECT_STYLE (obj);
        if (!style) continue;

        if ( style->stroke.isNone() ) {
            continue;
        }

        n_stroked ++;

        if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
            same_cap = false;
        prev_cap = style->stroke_linecap.value;

        cap = style->stroke_linecap.value;
    }

    style_res->stroke_linecap.value = cap;
    style_res->stroke_linecap.set = true;

    if (n_stroked == 0) {
        return QUERY_STYLE_NOTHING;
    } else if (n_stroked == 1) {
        return QUERY_STYLE_SINGLE;
    } else {
        if (same_cap)
            return QUERY_STYLE_MULTIPLE_SAME;
        else
            return QUERY_STYLE_MULTIPLE_DIFFERENT;
    }
}


Generated by  Doxygen 1.6.0   Back to index