Esempio n. 1
0
static void _progressbar_update_size(Enesim_Renderer *r)
{
	Progressbar *thiz;
	Enesim_Matrix t;
	double sa, ca;
	double width, height;

	thiz = _progressbar_get(r);
	eon_theme_widget_width_get(r, &width);
	eon_theme_widget_height_get(r, &height);
	width -= 2;
	height -= 2;

	enesim_renderer_rectangle_width_set(thiz->widget.rectangle, width);
	enesim_renderer_rectangle_height_set(thiz->widget.rectangle, height);

	sa = sin(-40 * M_PI / 180.0);
	ca = cos(-40 * M_PI / 180.0);
	t.xx = ca;               t.xy = sa;               t.xz = 0;
	t.yx = -sa / 2;    t.yy = ca / 2;     t.yz = 0;
	t.zx = 0;                t.zy = 0;                t.zz = 1;
	enesim_renderer_transformation_set(thiz->bar_content.pattern, &t);
	enesim_renderer_stripes_even_thickness_set(thiz->bar_content.shade, height / 4.0);
	enesim_renderer_stripes_odd_thickness_set(thiz->bar_content.shade, height / 4.0);
	t.xx = 1;               t.xy = 0;                t.xz = 0;
	t.yx = 0;               t.yy = 0.5;              t.yz = 0;
	t.zx = 0;               t.zy = 0;                t.zz = 1;
	enesim_renderer_transformation_set(thiz->bar_content.shade, &t);

	width = width * thiz->progression;
	enesim_renderer_rectangle_width_set(thiz->content.bar, width);
	enesim_renderer_rectangle_height_set(thiz->content.bar, height);
}
Esempio n. 2
0
static Eina_Bool _setup(Enesim_Renderer *r, Enesim_Log **error)
{
	Progressbar *thiz;
	Enesim_Matrix matrix;
	double ox, oy;

	thiz = _progressbar_get(r);
	/* the matrix */
	enesim_renderer_transformation_get(r, &matrix);
	enesim_renderer_transformation_set(thiz->widget.rectangle, &matrix);
	/* the origin */
	enesim_renderer_origin_get(r, &ox, &oy);
	enesim_renderer_origin_set(thiz->widget.rectangle, ox + 1, oy + 1);

	/* if we are at zero progression level just draw the background and not the bar */
	enesim_renderer_compound_layer_clear(thiz->widget.content);
	enesim_renderer_compound_layer_add(thiz->widget.content, thiz->content.background);
	if (thiz->progression > 0.0)
	{
		enesim_renderer_compound_layer_add(thiz->widget.content, thiz->content.bar);
	}
	_progressbar_update_size(r);

	return EINA_TRUE;
}
Esempio n. 3
0
/**
 * @example enesim_renderer_path07.c
 * Example usage of a path renderer
 * @image html enesim_renderer_path07.png
 */
Enesim_Renderer * enesim_example_renderer_renderer_get(
		Enesim_Example_Renderer_Options *options)
{
	Enesim_Renderer *r;
	Enesim_Matrix m;
	Enesim_Path *p;

	r = enesim_renderer_path_new();
	enesim_renderer_shape_stroke_color_set(r, 0xff000000);
	enesim_renderer_shape_stroke_weight_set(r, 0.1);
	enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE);

	p = enesim_renderer_path_path_get(r);
	enesim_path_move_to(p, 0.3, 0.3);
	enesim_path_cubic_to(p, 0.6, 1.1, 1.0, 0.9, 1.4, 0.3);
	enesim_path_unref(p);

	enesim_matrix_scale(&m, options->width/2, options->height/2);
	enesim_renderer_transformation_set(r, &m);

	return r;
}
/*----------------------------------------------------------------------------*
 *                              Gradient interface                            *
 *----------------------------------------------------------------------------*/
static Eina_Bool _egueb_svg_reference_gradient_linear_process(
		Egueb_Svg_Reference_Gradient *g)
{
	Egueb_Svg_Reference_Gradient_Linear *thiz;
	Egueb_Svg_Reference *r;
	Egueb_Svg_Length x1, y1, x2, y2;
	Egueb_Svg_Referenceable_Units units;
	Egueb_Dom_Node *doc = NULL;
	Enesim_Matrix m, transform;
	double gx1, gy1, gx2, gy2;

	DBG("Processing a linear gradient reference");
	/* get the final attributes */
	r = EGUEB_SVG_REFERENCE(g);
	egueb_svg_element_linear_gradient_deep_x1_get(r->referenceable, &x1);
	egueb_svg_element_linear_gradient_deep_y1_get(r->referenceable, &y1);
	egueb_svg_element_linear_gradient_deep_x2_get(r->referenceable, &x2);
	egueb_svg_element_linear_gradient_deep_y2_get(r->referenceable, &y2);
	egueb_svg_gradient_deep_units_get(r->referenceable, &units);
	egueb_svg_gradient_deep_transform_get(r->referenceable, &transform);

	if (units == EGUEB_SVG_REFERENCEABLE_UNITS_OBJECT_BOUNDING_BOX)
	{
		Enesim_Rectangle bounds;
		Egueb_Svg_Element *e_referencer;

		e_referencer = EGUEB_SVG_ELEMENT(r->referencer);
		/* check that the coordinates shold be set with (0,0) -> (1, 1) */
		gx1 = egueb_svg_coord_final_get(&x1, 1, 1);
		gy1 = egueb_svg_coord_final_get(&y1, 1, 1);
		gx2 = egueb_svg_coord_final_get(&x2, 1, 1);
		gy2 = egueb_svg_coord_final_get(&y2, 1, 1);

		egueb_svg_renderable_bounds_get(r->referencer, &bounds);
		enesim_matrix_values_set(&m, bounds.w, 0, bounds.x, 0, bounds.h, bounds.y, 0, 0, 1);
		DBG("Using the object bounding box %" ENESIM_RECTANGLE_FORMAT, ENESIM_RECTANGLE_ARGS(&bounds));
		/* transform the bounds using the context matrix */
		enesim_matrix_compose(&e_referencer->transform, &m, &m);
	}
	else
	{
		Egueb_Dom_Node *g_relative;
		Egueb_Svg_Element *ge_relative;
		double font_size;

		DBG("Using the user space on use");
		doc = egueb_dom_node_owner_document_get(r->referencer);
		if (!doc)
		{
			WARN("No document set");
			return EINA_FALSE;
		}
		font_size = egueb_svg_document_font_size_get(doc);
		egueb_dom_node_unref(doc);

		g_relative = egueb_svg_element_geometry_relative_get(r->referencer);
		if (!g_relative)
		{
			WARN("No relative geometry");
			return EINA_FALSE;
		}
		ge_relative = EGUEB_SVG_ELEMENT(g_relative);

		/* use the user space coordiantes */
		gx1 = egueb_svg_coord_final_get(&x1, ge_relative->viewbox.w, font_size);
		gy1 = egueb_svg_coord_final_get(&y1, ge_relative->viewbox.h, font_size);
		gx2 = egueb_svg_coord_final_get(&x2, ge_relative->viewbox.w, font_size);
		gy2 = egueb_svg_coord_final_get(&y2, ge_relative->viewbox.h, font_size);

		m = ge_relative->transform;
		egueb_dom_node_unref(g_relative);
	}
	/* Apply the gradient transform */
	if (enesim_matrix_type_get(&transform) != ENESIM_MATRIX_TYPE_IDENTITY)
		enesim_matrix_compose(&m, &transform, &m);

	/* set the renderer properties */
	thiz = EGUEB_SVG_REFERENCE_GRADIENT_LINEAR(r);
	enesim_renderer_transformation_set(thiz->r, &m);
	enesim_renderer_gradient_linear_x0_set(thiz->r, gx1);
	enesim_renderer_gradient_linear_y0_set(thiz->r, gy1);
	enesim_renderer_gradient_linear_x1_set(thiz->r, gx2);
	enesim_renderer_gradient_linear_y1_set(thiz->r, gy2);

	DBG("Coordinates x1 = %g, y1 = %g, x2 = %g, y2 = %g", gx1, gy1, gx2, gy2);
	DBG("Transformation %" ENESIM_MATRIX_FORMAT, ENESIM_MATRIX_ARGS(&m));

	return EINA_TRUE;
}