diff --git a/Makefile.am b/Makefile.am index 67e5118..a44fbd6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ bin_PROGRAMS = screentest screentest_SOURCES = main.c main.h callbacks.c callbacks.h test_basic.c \ test_blink.c test_grid.c test_horizontal.c test_text.c \ - test_vertical.c test_lcdalign.c gettext.h + test_vertical.c test_lcdalign.c test_bright_pixels.c gettext.h screentest_LDADD = $(GLIB_LIBS) $(GTK_LIBS) diff --git a/screentest.ui b/screentest.ui index a7e6cfa..efb76ed 100644 --- a/screentest.ui +++ b/screentest.ui @@ -157,6 +157,16 @@ + + + True + Bright Pixels + True + True + basic + + + diff --git a/test_basic.c b/test_basic.c index d3b1ef3..912fa6e 100644 --- a/test_basic.c +++ b/test_basic.c @@ -3,6 +3,7 @@ * https://tobix.github.io/screentest/ * Copyright (C) 2001 Jan "Yenya" Kasprzak * Copyright (C) 2006-2017 Tobias Gruetzmacher + * Copyright (C) 2021 Apr Thorsten Kattanek * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -67,11 +68,12 @@ static void basic_draw(GtkWidget * widget) gint w, h; gint i, b, d; gint maxwidth, maxheight; - gint widths[6]; + gint widths[7]; static gchar *text[] = { "Screentest v" VERSION, "(C) 2001 Jan \"Yenya\" Kasprzak ", "(C) 2006-2017 Tobias Gruetzmacher ", + "(C) 2021 Apr Thorsten Kattanek ", N_("Left Button - param cycle, if any"), N_("Middle Button - color cycle"), N_("Right Button - menu"), @@ -89,14 +91,14 @@ static void basic_draw(GtkWidget * widget) d = h / 4; maxheight = 0; - for (i = 0; i < 5; i++) { + for (i = 0; i < 7; i++) { int x = gdk_string_height(font, gettext(text[i])); if (x > maxheight) maxheight = x; } maxwidth = 0; - for (i = 0; i < 6; i++) { + for (i = 0; i < 7; i++) { widths[i] = gdk_string_width(font, gettext(text[i])); if (widths[i] > maxwidth) maxwidth = widths[i]; @@ -105,13 +107,13 @@ static void basic_draw(GtkWidget * widget) maxwidth += 20; maxheight = 3 * maxheight / 2; gdk_draw_rectangle(win, gc, FALSE, (w - maxwidth) / 2, - d / 2 - 2 * maxheight, maxwidth, 4 * maxheight); + d / 2 - 2 * maxheight, maxwidth, 5 * maxheight); gdk_draw_rectangle(win, gc, FALSE, (w - maxwidth) / 2, h - d / 2 - 2 * maxheight, maxwidth, 4 * maxheight); gdk_draw_rectangle(win, backgc, TRUE, (w - maxwidth) / 2 + 1, d / 2 - 2 * maxheight + 1, maxwidth - 1, - 4 * maxheight - 1); + 5 * maxheight - 1); gdk_draw_rectangle(win, backgc, TRUE, (w - maxwidth) / 2 + 1, h - d / 2 - 2 * maxheight + 1, maxwidth - 1, 4 * maxheight - 1); @@ -122,13 +124,15 @@ static void basic_draw(GtkWidget * widget) d / 2 + maxheight / 3, gettext(text[1])); gdk_draw_string(win, font, gc, (w - widths[2]) / 2, d / 2 + 4 * maxheight / 3, gettext(text[2])); - gdk_draw_string(win, font, gc, (w - widths[3]) / 2, - h - d / 2 - 2 * maxheight / 3, gettext(text[3])); + d / 2 + 7 * maxheight / 3, gettext(text[3])); + gdk_draw_string(win, font, gc, (w - widths[4]) / 2, - h - d / 2 + maxheight / 3, gettext(text[4])); + h - d / 2 - 2 * maxheight / 3, gettext(text[4])); gdk_draw_string(win, font, gc, (w - widths[5]) / 2, - h - d / 2 + 4 * maxheight / 3, gettext(text[5])); + h - d / 2 + maxheight / 3, gettext(text[5])); + gdk_draw_string(win, font, gc, (w - widths[6]) / 2, + h - d / 2 + 4 * maxheight / 3, gettext(text[6])); b = 7 * d / 4; draw_boxes(win, fgcolors, COLOR_MAX, (w - b) / 2, diff --git a/test_bright_pixels.c b/test_bright_pixels.c new file mode 100644 index 0000000..b601517 --- /dev/null +++ b/test_bright_pixels.c @@ -0,0 +1,63 @@ +/* + * Screentest - CRT/LCD monitor testing utility. + * https://tobix.github.io/screentest/ + * Copyright (C) 2011-2017 Tobias Gruetzmacher + * Copyright (C) 2021 Apr Thorsten Kattanek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include "callbacks.h" + +#define COLOR_COUNT 5 +static const int color_cycle[COLOR_COUNT]={COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_WHITE,COLOR_BLACK}; +static int current_color_idx; + +static void bright_pixels_init(G_GNUC_UNUSED GtkWidget * widget) +{ + current_color_idx = 0; +} + +static void bright_pixels_cycle(G_GNUC_UNUSED GtkWidget * widget) +{ + current_color_idx++; + if(current_color_idx == COLOR_COUNT) + current_color_idx = 0; +} + +static void bright_pixels_draw(GtkWidget * widget) +{ + GdkWindow *win = gtk_widget_get_window(widget); + gint w, h; + + gdk_drawable_get_size(win, &w, &h); + gdk_gc_set_rgb_fg_color(gc, &fgcolors[color_cycle[current_color_idx]]); + gdk_draw_rectangle(win, gc, 1, 0, 0, w, h); + + gdk_gc_set_rgb_fg_color(gc, &fgcolors[COLOR_WHITE]); +} + +G_MODULE_EXPORT struct test_ops bright_pixels_ops = { + .init = bright_pixels_init, + .draw = bright_pixels_draw, + .cycle = bright_pixels_cycle, + .close = NULL +};