[GRASS-SVN] r58916 - grass/branches/develbranch_6/lib/display

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 6 16:49:00 PST 2014


Author: hamish
Date: 2014-02-06 16:48:59 -0800 (Thu, 06 Feb 2014)
New Revision: 58916

Modified:
   grass/branches/develbranch_6/lib/display/popup.c
Log:
rendering tweaks to get border line to align with fill box, and better match box size to text string length

Modified: grass/branches/develbranch_6/lib/display/popup.c
===================================================================
--- grass/branches/develbranch_6/lib/display/popup.c	2014-02-07 00:14:24 UTC (rev 58915)
+++ grass/branches/develbranch_6/lib/display/popup.c	2014-02-07 00:48:59 UTC (rev 58916)
@@ -92,7 +92,7 @@
     char *panel;
     int dots_per_line, dots_per_char, height, width;
 
-    /* Figure the number of options and the max length of options */
+    /* Figure the number of options and the max string length of options */
     max_len = 0;
     for (n_options = 0; options[n_options] != NULL; n_options++) {
 	len = strlen(options[n_options]);
@@ -103,24 +103,25 @@
     /* Figure the dots per line and dots_per_char */
     height = R_screen_bot() - R_screen_top();
     width = R_screen_rite() - R_screen_left();
-    dots_per_line = height * percent_per_line / 100;
-    dots_per_char = width / (max_len + 2);
+    dots_per_line = height * percent_per_line / 100.;
+    dots_per_char = width / (max_len + 2.);
+
     /* we want the box to fit into window horizontally */
+    t = R_screen_bot() - (R_screen_bot() - R_screen_top()) * top / 100.;
+    l = R_screen_left() + (R_screen_rite() - R_screen_left()) * left / 100.;
 
-    t = R_screen_bot() - (R_screen_bot() - R_screen_top()) * top / 100;
-    l = R_screen_left() + (R_screen_rite() - R_screen_left()) * left / 100;
-
     /* Figure the bottom and right of the window */
-    text_size = (int)(.8 * (float)dots_per_line);
+    text_size = (int)(.8 * dots_per_line);
     if (text_size > dots_per_char)
 	text_size = dots_per_char;
 
     text_raise = (dots_per_line - text_size + 1) / 2;
     if (text_raise == 0)
 	text_raise = 1;
-    b = Y_BORDER + t + dots_per_line * n_options;
-    r = 2 * X_BORDER + l + text_size * max_len;
 
+    b = Y_BORDER + t + (dots_per_line * n_options) + 1;
+    r = 2 * X_BORDER + l + (text_size * 0.8) * max_len;
+
     /* Adjust, if necessary, to make sure window is all on screen */
     if (t < R_screen_top()) {
 	b = b + (R_screen_top() - t);
@@ -164,11 +165,11 @@
 
     /* Draw border */
     R_standard_color(text_colr);
-    R_move_abs(l + 1, t + 1);
-    R_cont_abs(r - 1, t + 1);
+    R_move_abs(l + 0, t + 0);
+    R_cont_abs(r - 1, t + 0);
     R_cont_abs(r - 1, b - 1);
-    R_cont_abs(l + 1, b - 1);
-    R_cont_abs(l + 1, t + 1);
+    R_cont_abs(l + 0, b - 1);
+    R_cont_abs(l + 0, t + 0);
 
     /* Prepare for text */
     R_text_size(text_size, text_size);
@@ -195,16 +196,18 @@
 	int n;
 
 	R_get_location_with_pointer(&x, &y, &button);
-	if (x > r
-	    || x < l || y < t + Y_BORDER + dots_per_line || y > b - Y_BORDER)
+	if (x > r || x < l
+	    || y < t + Y_BORDER + dots_per_line || y > b - Y_BORDER)
 	    continue;
 
 	n = y - t - Y_BORDER;
 	if (n % dots_per_line == 0)
 	    continue;
 
+	/* cleanup */
 	R_panel_restore(panel);
 	R_panel_delete(panel);
+
 	return (n / dots_per_line);
     }
 }



More information about the grass-commit mailing list