Commit 3cbfdef2c6f524d23303bafe628c85d2168f659d

Authored by Perry Werneck
1 parent 83eab83e
Exists in master and in 1 other branch develop

Visual adjustments.

Showing 1 changed file with 91 additions and 15 deletions   Show diff stats
src/terminal/drawing/oia.c
... ... @@ -258,10 +258,8 @@ static void setup_double_char_position(GdkRectangle *rect, G_GNUC_UNUSED v3270Fo
258 258 static int draw_centered_char(cairo_t *cr, v3270FontInfo *metrics, int x, int y, const gchar chr)
259 259 {
260 260 char str[2] = { chr, 0 };
261   -// cairo_text_extents_t extents;
262 261  
263 262 cairo_set_scaled_font(cr,metrics->scaled);
264   -// cairo_text_extents(cr,str,&extents);
265 263  
266 264 v3270_draw_text_at(cr, x, y, metrics, str);
267 265  
... ... @@ -293,33 +291,95 @@ static void draw_undera(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGB
293 291  
294 292 }
295 293  
  294 +static void draw_boxed_char(cairo_t *cr, const GdkRectangle *rect, v3270FontInfo *metrics, const char *str) {
  295 +
  296 + cairo_status_t status;
  297 + cairo_glyph_t * glyphs = NULL;
  298 + int num_glyphs = 0;
  299 + cairo_text_cluster_t * clusters = NULL;
  300 + int num_clusters = 0;
  301 + cairo_text_cluster_flags_t cluster_flags;
  302 + double x = ((double) rect->x);
  303 + double y = (rect->y+metrics->height);
  304 +
  305 + status = cairo_scaled_font_text_to_glyphs(
  306 + metrics->scaled,
  307 + x+1,
  308 + y,
  309 + str, strlen(str),
  310 + &glyphs,
  311 + &num_glyphs,
  312 + &clusters,
  313 + &num_clusters,
  314 + &cluster_flags
  315 + );
  316 +
  317 + if (status == CAIRO_STATUS_SUCCESS) {
  318 + cairo_show_text_glyphs(
  319 + cr,
  320 + str,
  321 + strlen(str),
  322 + glyphs,
  323 + num_glyphs,
  324 + clusters,
  325 + num_clusters,
  326 + cluster_flags
  327 + );
  328 + }
  329 +
  330 + if(glyphs)
  331 + cairo_glyph_free(glyphs);
  332 +
  333 + if(clusters)
  334 + cairo_text_cluster_free(clusters);
  335 +
  336 + // https://www.cairographics.org/FAQ/#sharp_lines
  337 + cairo_set_line_width(cr, 1);
  338 + cairo_move_to(cr,rect->x + 0.5, rect->y + 0.5);
  339 + cairo_line_to(cr,rect->x + 0.5, rect->y + rect->height + 0.5);
  340 + cairo_line_to(cr,rect->x + rect->width + 0.5, rect->y + rect->height + 0.5);
  341 + cairo_line_to(cr,rect->x + rect->width + 0.5, rect->y + 0.5);
  342 + cairo_close_path(cr);
  343 +
  344 + cairo_stroke(cr);
  345 +
  346 +}
  347 +
296 348 void v3270_draw_connection(cairo_t *cr, H3270 *host, v3270FontInfo *metrics, GdkRGBA *color, const GdkRectangle *rect)
297 349 {
298   - gchar str = ' ';
299   -
300 350 gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND);
301 351 cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
302 352 cairo_fill(cr);
  353 + cairo_stroke(cr);
303 354  
304 355 gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_FOREGROUND);
305   - cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
306   - cairo_stroke(cr);
307 356  
308   - if(lib3270_get_oia_box_solid(host))
  357 + //cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
  358 +
  359 + if(lib3270_get_oia_box_solid(host))
309 360 {
310 361 cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
311 362 cairo_fill(cr);
  363 + cairo_stroke(cr);
312 364 return;
313 365 }
314 366  
  367 + const gchar *str = " ";
315 368 if(lib3270_in_ansi(host))
316   - str = 'N';
  369 + str = "N";
317 370 else if(lib3270_in_sscp(host))
318   - str = 'S';
  371 + str = "S";
319 372 else
320   - str = '?';
  373 + str = "?";
  374 +
  375 + draw_boxed_char(
  376 + cr,
  377 + rect,
  378 + metrics,
  379 + str
  380 + );
321 381  
322   - draw_centered_char(cr,metrics,rect->x,rect->y,str);
  382 +// draw_centered_char(cr,metrics,rect->x,rect->y,str[0]);
323 383  
324 384 }
325 385  
... ... @@ -553,9 +613,6 @@ static void draw_insert(cairo_t *cr, H3270 *host, GdkRGBA *color, GdkRectangle *
553 613  
554 614 }
555 615  
556   -// v3270_draw_oia(cr, terminal->host, rect.y, cols, &terminal->font, terminal->color,terminal->oia_rect);
557   -// void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, v3270FontInfo *metrics, GdkRGBA *color, GdkRectangle *rect)
558   -
559 616 void v3270_draw_oia(v3270 *terminal, cairo_t *cr, int row, int cols)
560 617 {
561 618 static const struct _right_fields
... ... @@ -611,11 +668,29 @@ void v3270_draw_oia(v3270 *terminal, cairo_t *cr, int row, int cols)
611 668  
612 669 gdk_cairo_set_source_rgba(cr,terminal->color+V3270_COLOR_OIA_FOREGROUND);
613 670  
  671 + {
  672 + GdkRectangle rect = {
  673 + .x = lCol,
  674 + .y = row,
  675 + .width = terminal->font.width+2,
  676 + .height = terminal->font.spacing.value
  677 + };
  678 +
  679 + draw_boxed_char(
  680 + cr,
  681 + &rect,
  682 + &terminal->font,
  683 + "4"
  684 + );
  685 + }
  686 +
  687 + /*
614 688 draw_centered_char(cr,&terminal->font,lCol,row,'4');
615 689  
616 690 cairo_stroke(cr);
617 691 cairo_rectangle(cr, lCol, row, terminal->font.width+2, terminal->font.spacing.value);
618 692 cairo_stroke(cr);
  693 + */
619 694  
620 695 lCol += (terminal->font.width+5);
621 696  
... ... @@ -631,8 +706,9 @@ void v3270_draw_oia(v3270 *terminal, cairo_t *cr, int row, int cols)
631 706 // Connection indicator
632 707 terminal->oia.rect[V3270_OIA_CONNECTION].x = lCol;
633 708 terminal->oia.rect[V3270_OIA_CONNECTION].y = row;
634   - terminal->oia.rect[V3270_OIA_CONNECTION].width = terminal->font.width+3;
  709 + terminal->oia.rect[V3270_OIA_CONNECTION].width = terminal->font.width;
635 710 terminal->oia.rect[V3270_OIA_CONNECTION].height = terminal->font.spacing.value;
  711 +
636 712 v3270_draw_connection(cr,terminal->host,&terminal->font,terminal->color,terminal->oia.rect+V3270_OIA_CONNECTION);
637 713  
638 714 lCol += (4 + terminal->oia.rect[V3270_OIA_CONNECTION].width);
... ...