forked from enlightenment/efl
evas_vg_load_svg: Support "display" attribute.
Summary: If the display attribute is "none", VG object is not show. The default is "inline" which means visible and "none" means invisible. Depending on the type of node, additional functionality may be required. refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/display Test Plan: [SVG] <svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg"> <!-- Here the yellow rectangle is displayed --> <g display="none"> <rect x="0" y="0" width="100" height="100" fill="skyblue"></rect> </g> <rect x="20" y="20" width="60" height="60" fill="yellow"></rect> <!-- Here the yellow rectangle is not displayed --> <rect x="120" y="0" width="100" height="100" fill="skyblue"></rect> <rect x="140" y="20" width="60" height="60" fill="yellow" display="none"></rect> </svg> [C CODE] int main(int argc, char **argv) { setenv("ECTOR_BACKEND", "default", 1); elm_init(argc, argv); Evas_Object *win = elm_win_util_standard_add(NULL, "test"); evas_object_smart_callback_add(win, "delete,request", win_del, 0); elm_win_autodel_set(win, 1); Evas *evas = evas_object_evas_get(win); Evas_Object *vg = evas_object_vg_add(evas); evas_object_show(vg); Evas_Object *container = evas_vg_container_add(vg); evas_object_vg_root_node_set(vg, container); Evas_Object *svg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, container); efl_file_simple_load(svg, "./test.svg", NULL); efl_gfx_entity_size_set(svg, EINA_SIZE2D(600, 600)); efl_gfx_entity_visible_set(svg, EINA_TRUE); evas_object_size_hint_weight_set(svg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(svg, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_win_resize_object_add(win, vg); evas_object_resize(win, WIDTH, HEIGHT); evas_object_show(win); elm_run(); elm_shutdown(); return 0; } Reviewers: Hermet, smohanty, kimcinoo Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9640
This commit is contained in:
parent
b0737c7434
commit
e850e3e5dc
|
@ -911,6 +911,16 @@ _handle_transform_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, cons
|
|||
node->transform = _parse_transformation_matrix(value);
|
||||
}
|
||||
|
||||
static void
|
||||
_handle_display_attr(Evas_SVG_Loader *loader EINA_UNUSED, Svg_Node* node, const char *value)
|
||||
{
|
||||
//TODO : The display attribute can have various values as well as "none".
|
||||
// The default is "inline" which means visible and "none" means invisible.
|
||||
// Depending on the type of node, additional functionality may be required.
|
||||
// refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/display
|
||||
if (!strcmp(value, "none")) node->display = EINA_FALSE;
|
||||
else node->display = EINA_TRUE;
|
||||
}
|
||||
|
||||
typedef void (*Style_Method)(Evas_SVG_Loader *loader, Svg_Node *node, const char *value);
|
||||
|
||||
|
@ -932,7 +942,8 @@ static const struct {
|
|||
STYLE_DEF(stroke-linejoin, stroke_linejoin),
|
||||
STYLE_DEF(stroke-linecap, stroke_linecap),
|
||||
STYLE_DEF(stroke-opacity, stroke_opacity),
|
||||
STYLE_DEF(transform, transform)
|
||||
STYLE_DEF(transform, transform),
|
||||
STYLE_DEF(display, display)
|
||||
};
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -1030,6 +1041,9 @@ _create_node(Svg_Node *parent, Svg_Node_Type type)
|
|||
node->style->stroke.join = EFL_GFX_JOIN_MITER;
|
||||
node->style->stroke.scale = 1.0;
|
||||
|
||||
// default display is true("inline").
|
||||
node->display = EINA_TRUE;
|
||||
|
||||
node->parent = parent;
|
||||
node->type = type;
|
||||
node->child = NULL;
|
||||
|
|
|
@ -283,6 +283,7 @@ struct _Svg_Node
|
|||
Eina_Stringshare *id;
|
||||
Svg_Style_Property *style;
|
||||
Eina_Matrix3 *transform;
|
||||
Eina_Bool display;
|
||||
union
|
||||
{
|
||||
Svg_G_Node g;
|
||||
|
|
|
@ -441,6 +441,7 @@ vg_common_svg_node_eet(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_vg_node, Svg_Node, "id", id, EET_T_STRING);
|
||||
EET_DATA_DESCRIPTOR_ADD_SUB(_eet_vg_node, Svg_Node, "style", style, _eet_style_property_node);
|
||||
EET_DATA_DESCRIPTOR_ADD_SUB(_eet_vg_node, Svg_Node, "transform", transform, _eet_matrix3_node);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_eet_vg_node, Svg_Node, "display", display, EET_T_INT);
|
||||
|
||||
return _eet_vg_node;
|
||||
}
|
||||
|
@ -715,6 +716,8 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg, Efl_VG *parent, Vg_File_Data *vg_
|
|||
// apply the transformation
|
||||
if (node->transform) efl_canvas_vg_node_transformation_set(vg, node->transform);
|
||||
|
||||
if (!node->display) efl_gfx_entity_visible_set(vg, EINA_FALSE);
|
||||
|
||||
if ((node->type == SVG_NODE_G) || (node->type == SVG_NODE_DOC)) return;
|
||||
|
||||
// apply the fill style property
|
||||
|
|
Loading…
Reference in New Issue