void ttk_button_draw(gfx_context_t * ctx, struct TTKButton * button) { if (button->width == 0) { return; } int hilight = button->hilight & 0xFF; int disabled = button->hilight & 0x100; /* Dark edge */ if (hilight < 3) { struct gradient_definition edge = {button->height, button->y, rgb(166,166,166), rgb(136,136,136)}; draw_rounded_rectangle_pattern(ctx, button->x, button->y, button->width, button->height, 4, gfx_vertical_gradient_pattern, &edge); } /* Sheen */ if (hilight < 2) { draw_rounded_rectangle(ctx, button->x + 1, button->y + 1, button->width - 2, button->height - 2, 3, rgb(238,238,238)); /* Button face - this should normally be a gradient */ if (hilight == 1) { struct gradient_definition face = {button->height-3, button->y + 2, rgb(240,240,240), rgb(230,230,230)}; draw_rounded_rectangle_pattern(ctx, button->x + 2, button->y + 2, button->width - 4, button->height - 3, 2, gfx_vertical_gradient_pattern, &face); } else { struct gradient_definition face = {button->height-3, button->y + 2, rgb(219,219,219), rgb(204,204,204)}; draw_rounded_rectangle_pattern(ctx, button->x + 2, button->y + 2, button->width - 4, button->height - 3, 2, gfx_vertical_gradient_pattern, &face); } } else if (hilight == 2) { struct gradient_definition face = {button->height-2, button->y + 1, rgb(180,180,180), rgb(160,160,160)}; draw_rounded_rectangle_pattern(ctx, button->x + 1, button->y + 1, button->width - 2, button->height - 2, 3, gfx_vertical_gradient_pattern, &face); } if (button->title[0] != '\033') { int label_width = draw_sdf_string_width(button->title, 16, SDF_FONT_THIN); int centered = (button->width - label_width) / 2; int centered_y = (button->height - 16) / 2; draw_sdf_string(ctx, button->x + centered + (hilight == 2), button->y + centered_y + (hilight == 2), button->title, 16, disabled ? rgb(120,120,120) : rgb(0,0,0), SDF_FONT_THIN); } else { sprite_t * icon = icon_get_16(button->title+1); int centered = button->x + (button->width - icon->width) / 2 + (hilight == 2); int centered_y = button->y + (button->height - icon->height) / 2 + (hilight == 2); if (disabled) { draw_sprite_alpha(ctx, icon, centered, centered_y, 0.5); } else { draw_sprite(ctx, icon, centered, centered_y); } } }
static void draw_dvdag_infotag(cairo_t *cr, dv_dag_node_t *node) { double line_height = 12; double padding = 4; int n = 6; /* number of lines */ double xx = node->vl->c + DV_RADIUS + padding; double yy = node->c - DV_RADIUS - 2*padding - line_height * (n - 1); // Cover rectangle double width = 450.0; double height = n * line_height + 3*padding; draw_rounded_rectangle(cr, node->vl->c + DV_RADIUS, node->c - DV_RADIUS - height, width, height); // Lines cairo_set_source_rgb(cr, 1.0, 1.0, 0.1); cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 12); // Line 1 /* TODO: adaptable string length */ char *s = (char *) dv_malloc( DV_STRING_LENGTH * sizeof(char) ); sprintf(s, "[%ld] %s lv=%d f=%d%d%d%d dc=%0.1lf c=%0.1lf", node - G->T, NODE_KIND_NAMES[node->pi->info.kind], node->lv, dv_is_union(node), dv_is_shrinked(node), dv_is_expanding(node), dv_is_shrinking(node), node->dc, node->c); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; // Line 2 sprintf(s, "%llu-%llu (%llu) est=%llu", node->pi->info.start.t, node->pi->info.end.t, node->pi->info.start.t - node->pi->info.end.t, node->pi->info.est); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; // Line 3 sprintf(s, "T=%llu/%llu,nodes=%ld/%ld/%ld,edges=%ld/%ld/%ld/%ld", node->pi->info.t_1, node->pi->info.t_inf, node->pi->info.logical_node_counts[dr_dag_node_kind_create_task], node->pi->info.logical_node_counts[dr_dag_node_kind_wait_tasks], node->pi->info.logical_node_counts[dr_dag_node_kind_end_task], node->pi->info.logical_edge_counts[dr_dag_edge_kind_end], node->pi->info.logical_edge_counts[dr_dag_edge_kind_create], node->pi->info.logical_edge_counts[dr_dag_edge_kind_create_cont], node->pi->info.logical_edge_counts[dr_dag_edge_kind_wait_cont]); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; // Line 4 sprintf(s, "by worker %d on cpu %d", node->pi->info.worker, node->pi->info.cpu); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; // Line 5 dv_free(s, DV_STRING_LENGTH * sizeof(char)); const char *ss = P->S->C + P->S->I[node->pi->info.start.pos.file_idx]; s = (char *) dv_malloc( strlen(ss) + 10 ); sprintf(s, "%s:%ld", ss, node->pi->info.start.pos.line); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; // Line 6 dv_free(s, strlen(ss) + 10); ss = P->S->C + P->S->I[node->pi->info.end.pos.file_idx]; s = (char *) dv_malloc( strlen(ss) + 10 ); sprintf(s, "%s:%ld", ss, node->pi->info.end.pos.line); cairo_move_to(cr, xx, yy); cairo_show_text(cr, s); yy += line_height; dv_free(s, strlen(ss) + 10); }