/*============================================================================* * Global * *============================================================================*/ Egueb_Dom_Node * eon_theme_mars_radio_new(void) { Eon_Theme_Mars_Radio *thiz; Egueb_Dom_Node *n; Egueb_Dom_String *s; Enesim_Renderer_Compound_Layer *l; thiz = calloc(1, sizeof(Eon_Theme_Mars_Radio)); /* the radio button */ thiz->button = enesim_renderer_circle_new(); enesim_renderer_circle_radius_set(thiz->button, 3); enesim_renderer_shape_draw_mode_set(thiz->button, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); thiz->border = enesim_renderer_circle_new(); enesim_renderer_circle_radius_set(thiz->border, 7); enesim_renderer_shape_stroke_weight_set(thiz->border, 2); enesim_renderer_shape_draw_mode_set(thiz->border, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE_FILL); enesim_renderer_shape_fill_renderer_set(thiz->border, enesim_renderer_ref(thiz->button)); /* the button and the content */ thiz->radio = enesim_renderer_compound_new(); l = enesim_renderer_compound_layer_new(); enesim_renderer_compound_layer_renderer_set(l, enesim_renderer_ref(thiz->border)); enesim_renderer_compound_layer_rop_set(l, ENESIM_ROP_BLEND); enesim_renderer_compound_layer_add(thiz->radio, l); /* the widget area */ thiz->area = enesim_renderer_rectangle_new(); enesim_renderer_shape_draw_mode_set(thiz->area, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); enesim_renderer_shape_fill_renderer_set(thiz->area, enesim_renderer_ref(thiz->radio)); /* the blur effect for disabled buttons */ thiz->blur = enesim_renderer_blur_new(); enesim_renderer_blur_radius_x_set(thiz->blur, 3); enesim_renderer_blur_radius_y_set(thiz->blur, 3); thiz->proxy = enesim_renderer_proxy_new(); enesim_renderer_proxy_proxied_set(thiz->proxy, enesim_renderer_ref(thiz->area)); n = eon_theme_element_button_new(&_descriptor, thiz); /* the attributes */ s = egueb_dom_string_new_with_static_chars("border-color"); thiz->border_color = egueb_css_attr_color_new(s, NULL, EINA_TRUE, EINA_TRUE, EINA_FALSE); s = egueb_dom_string_new_with_static_chars("button-color"); thiz->button_color = egueb_css_attr_color_new(s, NULL, EINA_TRUE, EINA_TRUE, EINA_FALSE); egueb_dom_element_attribute_node_set(n, egueb_dom_node_ref(thiz->border_color), NULL); egueb_dom_element_attribute_node_set(n, egueb_dom_node_ref(thiz->button_color), NULL); thiz->n = n; return n; }
/*============================================================================* * API * *============================================================================*/ EAPI Eon_Theme_Widget * eon_theme_basic_scrollbar_new(void) { Eon_Theme_Widget *t; Eon_Basic_Scrollbar *thiz; Enesim_Renderer *r; thiz = calloc(1, sizeof(Eon_Basic_Scrollbar)); if (!thiz) return NULL; r = enesim_renderer_background_new(); if (!r) goto background_err; enesim_renderer_rop_set(r, ENESIM_BLEND); enesim_renderer_background_color_set(r, 0xffff0000); thiz->background = r; r = enesim_renderer_compound_new(); if (!r) goto compound_err; thiz->compound = r; enesim_renderer_compound_layer_add(r, thiz->background); r = enesim_renderer_rectangle_new(); if (!r) goto shape_err; thiz->shape = r; enesim_renderer_shape_fill_renderer_set(r, thiz->compound); enesim_renderer_shape_stroke_weight_set(r, 1.0); enesim_renderer_shape_stroke_color_set(r, 0xff000000); enesim_renderer_shape_draw_mode_set(r, ENESIM_SHAPE_DRAW_MODE_STROKE_FILL); enesim_renderer_rop_set(r, ENESIM_BLEND); t = eon_theme_scrollbar_new(&_descriptor, thiz); if (!t) goto base_err; return t; base_err: enesim_renderer_unref(thiz->shape); shape_err: enesim_renderer_unref(thiz->compound); compound_err: enesim_renderer_unref(thiz->background); background_err: free(thiz); return NULL; }
EAPI Enesim_Renderer * echart_line_renderer_get(const Echart_Line *line) { const Echart_Chart *chart; const Echart_Data *data; const Echart_Data_Item *absciss; const Echart_Data_Item *item; Enesim_Renderer *c; Enesim_Renderer *r; Enesim_Renderer *r_first; Enesim_Renderer_Compound_Layer *l; Enesim_Text_Font *f; Enesim_Text_Engine *e; Enesim_Rectangle geom; Enesim_Path *p; Enesim_Color color; Eina_Rectangle rect_first; Eina_Rectangle rect; const char *title; double avmin; double avmax; int grid_x_nbr; int grid_y_nbr; int sub_grid_x_nbr; int sub_grid_y_nbr; int x_area; int y_area; int w_area; int h_area; int w; int h; unsigned int i; unsigned int j; if (!line) return NULL; chart = line->chart; if (line->stacked) data = echart_data_stacked_get(echart_chart_data_get(chart)); else data = echart_chart_data_get(chart); if (!data) { ERR("A chart must have at least a data"); return NULL; } if (echart_data_items_count(data) < 2) { ERR("Data must have at least 2 items"); return NULL; } echart_chart_size_get(chart, &w, &h); c = enesim_renderer_compound_new(); e = enesim_text_engine_default_get(); f = enesim_text_font_new_description_from(e, "arial", 16); enesim_text_engine_unref(e); /* background */ r = enesim_renderer_rectangle_new(); enesim_renderer_rectangle_position_set(r, 0, 0); enesim_renderer_rectangle_size_set(r, w, h); enesim_renderer_shape_fill_color_set(r, echart_chart_background_color_get(chart)); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); l = enesim_renderer_compound_layer_new(); enesim_renderer_compound_layer_renderer_set(l, r); enesim_renderer_compound_layer_rop_set(l, ENESIM_ROP_FILL); enesim_renderer_compound_layer_add(c, l); /* title */ h_area = 0; title = echart_data_title_get(data); if (title) { r = enesim_renderer_text_span_new(); enesim_renderer_color_set(r, 0xff000000); enesim_renderer_text_span_text_set(r, title); enesim_renderer_text_span_font_set(r, f); enesim_renderer_shape_destination_geometry_get(r, &geom); enesim_renderer_origin_set(r, (w - geom.w) / 2, 0); enesim_rectangle_normalize(&geom, &rect); h_area = rect.h; ECHART_RENDERER_LAYER_ADD(c, l, r); } /* abscisses */ absciss = echart_data_absciss_get(data); echart_data_item_interval_get(absciss, &avmin, &avmax); r_first = _echart_line_text_renderer_from_double(f, *(double *)eina_list_nth(echart_data_item_values_get(absciss), 0)); enesim_renderer_shape_destination_geometry_get(r_first, &geom); enesim_renderer_origin_set(r_first, 0, h - geom.h); enesim_rectangle_normalize(&geom, &rect_first); x_area = rect_first.w / 2 + 1; y_area = rect_first.h; ECHART_RENDERER_LAYER_ADD(c, l, r_first); r = _echart_line_text_renderer_from_double(f, *(double *)eina_list_nth(echart_data_item_values_get(absciss), eina_list_count(echart_data_item_values_get(absciss)) - 1)); enesim_renderer_shape_destination_geometry_get(r, &geom); enesim_renderer_origin_set(r, w - geom.w, h - geom.h); enesim_rectangle_normalize(&geom, &rect); w_area = w - (rect_first.w + rect.w) / 2; if (y_area < rect.h) y_area = rect.h; ECHART_RENDERER_LAYER_ADD(c, l, r); for (i = 1; i < eina_list_count(echart_data_item_values_get(absciss)) - 1; i++) { double d1; r = _echart_line_text_renderer_from_double(f, *(double *)eina_list_nth(echart_data_item_values_get(absciss), i)); d1 = *(double *)eina_list_nth(echart_data_item_values_get(absciss), i); d1 = x_area + w_area * (d1 - avmin) / (avmax - avmin); enesim_renderer_shape_destination_geometry_get(r, &geom); enesim_renderer_origin_set(r, d1 - geom.w / 2, h - geom.h); enesim_rectangle_normalize(&geom, &rect); if (y_area < rect.h) y_area = rect.h; ECHART_RENDERER_LAYER_ADD(c, l, r); } h_area = h - y_area - h_area; /* grid */ echart_chart_grid_nbr_get(chart, &grid_x_nbr, &grid_y_nbr); for (i = 0; i < (unsigned int)grid_x_nbr; i++) { r = enesim_renderer_line_new(); enesim_renderer_line_coords_set(r, x_area + (i * w_area) / (double)(grid_x_nbr - 1), h - y_area, x_area + (i * w_area) / (double)(grid_x_nbr - 1), h - h_area - y_area); enesim_renderer_shape_stroke_weight_set(r, 1); if (i == 0) enesim_renderer_shape_stroke_color_set(r, 0xff000000); else enesim_renderer_shape_stroke_color_set(r, echart_chart_grid_color_get(chart)); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE); ECHART_RENDERER_LAYER_ADD(c, l, r); } for (i = 0; i < (unsigned int)grid_y_nbr; i++) { r = enesim_renderer_line_new(); enesim_renderer_line_coords_set(r, x_area + 1, h - y_area - (i * h_area) / (double)(grid_y_nbr - 1), x_area + w_area, h - y_area - (i * h_area) / (double)(grid_y_nbr - 1)); enesim_renderer_shape_stroke_weight_set(r, 1); if (i == 0) enesim_renderer_shape_stroke_color_set(r, 0xff000000); else enesim_renderer_shape_stroke_color_set(r, echart_chart_grid_color_get(chart)); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE); ECHART_RENDERER_LAYER_ADD(c, l, r); } /* sub grid */ echart_chart_sub_grid_nbr_get(chart, &sub_grid_x_nbr, &sub_grid_y_nbr); for (i = 0; i < (unsigned int)grid_x_nbr; i++) { for (j = 1; (int)j < (sub_grid_x_nbr - 1); j++) { p = enesim_path_new(); enesim_path_move_to(p, x_area + w_area * (j + i * (sub_grid_x_nbr - 1)) / (double)((grid_x_nbr - 1) * (sub_grid_x_nbr - 1)), h - h_area - y_area + 1); enesim_path_line_to(p, x_area + w_area * (j + i * (sub_grid_x_nbr - 1)) / (double)((grid_x_nbr - 1) * (sub_grid_x_nbr - 1)), h - y_area); r = enesim_renderer_path_new(); enesim_renderer_path_path_set(r, p); enesim_renderer_shape_stroke_weight_set(r, 1); enesim_renderer_shape_stroke_dash_add_simple(r, 10, 8); enesim_renderer_shape_stroke_color_set(r, echart_chart_sub_grid_color_get(chart)); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE); ECHART_RENDERER_LAYER_ADD(c, l, r); } } for (i = 0; i < (unsigned int)grid_y_nbr; i++) { for (j = 1; (int)j < (sub_grid_y_nbr - 1); j++) { p = enesim_path_new(); enesim_path_move_to(p, x_area + 1, h - y_area - h_area * (j + i * (sub_grid_y_nbr - 1)) / (double)((grid_y_nbr - 1) * (sub_grid_y_nbr - 1))); enesim_path_line_to(p, x_area + w_area, h - y_area - h_area * (j + i * (sub_grid_y_nbr - 1)) / (double)((grid_y_nbr - 1) * (sub_grid_y_nbr - 1))); r = enesim_renderer_path_new(); enesim_renderer_path_path_set(r, p); enesim_renderer_shape_stroke_weight_set(r, 1); enesim_renderer_shape_stroke_dash_add_simple(r, 10, 8); enesim_renderer_shape_stroke_color_set(r, echart_chart_sub_grid_color_get(chart)); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE); ECHART_RENDERER_LAYER_ADD(c, l, r); } } /* area */ if (line->area) { for (j = 1; j < echart_data_items_count(data); j++) { double vmin; double vmax; double d1; double d2; uint8_t ca, cr, cg, cb; item = echart_data_items_get(data, j); echart_data_item_interval_get(item, &vmin, &vmax); p = enesim_path_new(); enesim_path_move_to(p, x_area + 1, h - y_area); for (i = 0; i < eina_list_count(echart_data_item_values_get(item)); i++) { d1 = *(double *)eina_list_nth(echart_data_item_values_get(absciss), i); d1 = x_area + 1 + (w_area - 1) * (d1 - avmin) / (avmax - avmin); d2 = *(double *)eina_list_nth(echart_data_item_values_get(item), i); d2 = (h_area - 1) * (d2 - vmin) / (vmax - vmin); enesim_path_line_to(p, d1, h - y_area - d2); } enesim_path_line_to(p, x_area + w_area, h - y_area); enesim_path_close(p); r = enesim_renderer_path_new(); enesim_renderer_path_path_set(r, p); enesim_argb_components_to(echart_data_item_color_get(item).area, &ca, &cr, &cg, &cb); ca = 220; enesim_color_components_from(&color, ca, cr, cg, cb); enesim_renderer_shape_fill_color_set(r, color); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); ECHART_RENDERER_LAYER_ADD(c, l, r); } } /* line */ for (j = 1; j < echart_data_items_count(data); j++) { double vmin; double vmax; double d1; double d2; item = echart_data_items_get(data, j); echart_data_item_interval_get(item, &vmin, &vmax); printf("\n%d %f %f\n\n", j, vmin, vmax); p = enesim_path_new(); for (i = 0; i < eina_list_count(echart_data_item_values_get(item)); i++) { d1 = *(double *)eina_list_nth(echart_data_item_values_get(absciss), i); d1 = x_area + 1 + (w_area - 1) * (d1 - avmin) / (avmax - avmin); d2 = *(double *)eina_list_nth(echart_data_item_values_get(item), i); d2 = h_area * (d2) / (vmax); if (i == 0) enesim_path_move_to(p, d1, h - y_area - d2); else enesim_path_line_to(p, d1, h - y_area - d2); printf("%d %d %f\n", j, i, h - y_area - d2); } r = enesim_renderer_path_new(); enesim_renderer_path_path_set(r, p); enesim_renderer_shape_stroke_weight_set(r, 1); enesim_renderer_shape_stroke_color_set(r, echart_data_item_color_get(item).line); enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE); ECHART_RENDERER_LAYER_ADD(c, l, r); } return c; }
Enesim_Renderer * eon_theme_basic_progressbar_new(void) { Progressbar *thiz; Enesim_Renderer *r; thiz = calloc(1, sizeof(Progressbar)); if (!thiz) return NULL; /* first the bar content */ r = enesim_renderer_stripes_new(); if (!r) goto bar_content_pattern_err; thiz->bar_content.pattern = r; enesim_renderer_stripes_even_color_set(r, 0xffa1ff38); enesim_renderer_stripes_odd_color_set(r, 0xffb3ff00); enesim_renderer_stripes_even_thickness_set(r, 3); enesim_renderer_stripes_odd_thickness_set(r, 5); r = enesim_renderer_stripes_new(); if (!r) goto bar_content_shade_err; thiz->bar_content.shade = r; enesim_renderer_stripes_even_color_set(r, 0); enesim_renderer_stripes_odd_color_set(r, 0x33000000); enesim_renderer_stripes_even_thickness_set(r, 1); enesim_renderer_stripes_odd_thickness_set(r, 1); /* now the bar itself */ r = enesim_renderer_compound_new(); if (!r) goto bar_content_err; thiz->bar.content = r; enesim_renderer_compound_layer_add(r, thiz->bar_content.pattern); enesim_renderer_rop_set(thiz->bar_content.pattern, ENESIM_FILL); enesim_renderer_compound_layer_add(r, thiz->bar_content.shade); enesim_renderer_rop_set(thiz->bar_content.shade, ENESIM_BLEND); /* now the content */ r = enesim_renderer_rectangle_new(); if (!r) goto content_bar_err; thiz->content.bar = r; enesim_renderer_rectangle_corners_set(r, EINA_TRUE, EINA_TRUE, EINA_TRUE, EINA_TRUE); enesim_renderer_rectangle_corner_radius_set(r, 5); enesim_renderer_shape_stroke_weight_set(r, 2); enesim_renderer_shape_stroke_color_set(r, 0xffa1ff38); enesim_renderer_shape_fill_renderer_set(r, thiz->bar.content); enesim_renderer_shape_draw_mode_set(r, ENESIM_SHAPE_DRAW_MODE_STROKE_FILL); r = enesim_renderer_background_new(); if (!r) goto content_background_err; thiz->content.background = r; enesim_renderer_background_color_set(r, 0xffcccccc); /* now the widget */ r = enesim_renderer_compound_new(); if (!r) goto widget_content_err; thiz->widget.content = r; enesim_renderer_compound_layer_add(r, thiz->content.background); enesim_renderer_rop_set(thiz->content.background, ENESIM_FILL); enesim_renderer_compound_layer_add(r, thiz->content.bar); enesim_renderer_rop_set(thiz->content.bar, ENESIM_BLEND); r = enesim_renderer_rectangle_new(); if (!r) goto widget_rectangle_err; thiz->widget.rectangle = r; enesim_renderer_rectangle_corners_set(r, EINA_TRUE, EINA_TRUE, EINA_TRUE, EINA_TRUE); enesim_renderer_rectangle_corner_radius_set(r, 5); enesim_renderer_shape_stroke_weight_set(r, 2); enesim_renderer_shape_stroke_color_set(r, 0xff555555); enesim_renderer_shape_fill_renderer_set(r, thiz->widget.content); enesim_renderer_shape_draw_mode_set(r, ENESIM_SHAPE_DRAW_MODE_STROKE_FILL); r = eon_theme_progressbar_new(&_descriptor, thiz); if (!r) goto renderer_err; return r; renderer_err: enesim_renderer_unref(thiz->widget.rectangle); widget_rectangle_err: enesim_renderer_unref(thiz->widget.content); widget_content_err: enesim_renderer_unref(thiz->content.background); content_background_err: enesim_renderer_unref(thiz->content.bar); content_bar_err: enesim_renderer_unref(thiz->bar.content); bar_content_err: enesim_renderer_unref(thiz->bar_content.shade); bar_content_shade_err: enesim_renderer_unref(thiz->bar_content.pattern); bar_content_pattern_err: free(thiz); return NULL; }