From c5488ffd0c0e61617f06cc09444e7b7d642d00a7 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 28 Oct 2012 22:25:22 +0100 Subject: [PATCH] Fix logo placement Graphs were not recognized as possible SAME_ROW elements. A Graph requesting FIXED_H (which only the logos did) is now packed into a (borderless) aspect frame. --- dialogs.c | 4 ++-- draw.c | 3 ++- gtk/xoptions.c | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dialogs.c b/dialogs.c index 0e15867..800e109 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2067,10 +2067,10 @@ Option mainOptions[] = { // description of main window in terms of generic dialo { 0, COMBO_CALLBACK, 0, NULL, (void*)&MenuCallback, NULL, NULL, DropDown, N_("Help") }, { 0, 0, 0, NULL, (void*)&SizeKludge, "", NULL, BarEnd, "" }, { 0, LR|T2T|BORDER|SAME_ROW, 0, NULL, NULL, "", NULL, Label, "1" }, // optional title in window -{ 50, LL|TT, 100, NULL, (void*) &LogoW, NULL, NULL, -1, "LogoW" }, // white logo +{ 50, LL|TT, 100, NULL, (void*) &LogoW, NULL, NULL, -1, "" }, // white logo { 12, L2L|T2T, 200, NULL, (void*) &CCB, NULL, NULL, Label, "White" }, // white clock { 13, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock -{ 50, RR|TT|SAME_ROW, 100, NULL, (void*) &LogoB, NULL, NULL, -1, "LogoB" }, // black logo +{ 50, RR|TT|SAME_ROW, 100, NULL, (void*) &LogoB, NULL, NULL, -1, "" }, // black logo { 0, LR|T2T|BORDER, 401, NULL, NULL, "", NULL, -1, "2" }, // backup for title in window (if no room for other) { 0, LR|T2T|BORDER, 270, NULL, NULL, "", NULL, Label, "message" }, // message field { 0, RR|TT|SAME_ROW, 125, NULL, NULL, "", NULL, BoxBegin, "" }, // (optional) button bar diff --git a/draw.c b/draw.c index f7cbe1b..30e6200 100644 --- a/draw.c +++ b/draw.c @@ -586,7 +586,8 @@ DrawLogo (Option *opt, void *logo) w = cairo_image_surface_get_width (img); h = cairo_image_surface_get_height (img); cr = cairo_create(DRAWABLE(opt)); - cairo_scale(cr, (float)appData.logoSize/w, appData.logoSize/(2.*h)); +// cairo_scale(cr, (float)appData.logoSize/w, appData.logoSize/(2.*h)); + cairo_scale(cr, (float)opt->max/w, (float)opt->value/h); cairo_set_source_surface (cr, img, 0, 0); cairo_paint (cr); cairo_destroy (cr); diff --git a/gtk/xoptions.c b/gtk/xoptions.c index c58bb26..01775e8 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1058,7 +1058,7 @@ static int SameRow (Option *opt) { return (opt->min & SAME_ROW && (opt->type == Button || opt->type == SaveButton || opt->type == Label - || opt->type == ListBox || opt->type == BoxBegin || opt->type == Icon)); + || opt->type == ListBox || opt->type == BoxBegin || opt->type == Icon || opt->type == Graph)); } static void @@ -1174,7 +1174,7 @@ printf("n=%d, h=%d, w=%d\n",n,height,width); if(SameRow(&option[i+1])) { GtkAttachOptions x = GTK_FILL; // make sure hbox is always available when we have more options on same row - hbox = gtk_hbox_new (option[i].type == Button && option[i].textValue, 0); + hbox = gtk_hbox_new (option[i].type == Button && option[i].textValue || option[i].type == Graph, 0); if(!currentCps && option[i].value > 80) x |= GTK_EXPAND; // only vertically extended widgets should size vertically if (strcmp(option[i].name, "") == 0 || option[i].type == Label || option[i].type == Button) // for Label and Button name is contained inside option @@ -1403,9 +1403,9 @@ printf("n=%d, h=%d, w=%d\n",n,height,width); g_signal_connect (graph, "button-press-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); g_signal_connect (graph, "button-release-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); g_signal_connect (graph, "motion-notify-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]); - if(0) { - GtkWidget *frame = gtk_aspect_frame_new(NULL, 0, 0, 1, FALSE); -// gtk_frame_set_shadow_type(frame, GTK_SHADOW_NONE); + if(option[i].min & FIX_H) { // logo + GtkWidget *frame = gtk_aspect_frame_new(NULL, 0.5, 0.5, option[i].max/(float)option[i].value, FALSE); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(frame), graph); graph = frame; } -- 1.7.0.4