]> Pileus Git - grits/blobdiff - src/plugins/env.c
Add pointer code
[grits] / src / plugins / env.c
index 658881d3f5749cbe691c8e130cf050ea65e37f5a..e01ca63487cea546fc5e7db301af4fbc9c340310 100644 (file)
@@ -202,10 +202,7 @@ static void compass_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer
        glTranslatef(alloc.width - offset, offset, 0);
 
        /* Setup state */
-       glClear(GL_DEPTH_BUFFER_BIT);
        glEnable(GL_COLOR_MATERIAL);
-       glEnable(GL_DEPTH_TEST);
-       glDisable(GL_CULL_FACE);
        glEnable(GL_POLYGON_SMOOTH);
        glEnable(GL_LINE_SMOOTH);
 
@@ -229,39 +226,30 @@ static void info_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer _e
        GtkAllocation alloc;
        gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
 
-       /* Create cairo  surface */
+       /* Create cairo surface */
        guint            tex     = 0;
-       const gchar     *label0  = "Location: %7.3lf°, %8.3lf°, %4.0fm";
-       const gchar     *label1  = "Cursor:   %7.3lf°, %8.3lf°, %4.0fm";
-       gdouble          width   = 300;
+       gdouble          width   = 600;
        gdouble          height  = 200;
        cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
        cairo_t         *cairo   = cairo_create(surface);
 
-       /* Text */
-       gdouble lat, lon, elev;
+       /* Setup text */
+       gdouble lat, lon, elev, plat=0, plon=0, pelev=0;
        grits_viewer_get_location(GRITS_VIEWER(opengl), &lat, &lon, &elev);
-       gchar *text0 = g_strdup_printf(label0, lat, lon, elev);
-       gchar *text1 = g_strdup_printf(label1, lat, lon, elev);
-
-       /* Draw outline */
-       cairo_set_line_width(cairo, 3);
-       cairo_set_source_rgba(cairo, 0, 0, 0, 0.75);
-       cairo_move_to(cairo, 2, 20); cairo_text_path(cairo, text0);
-       cairo_move_to(cairo, 2, 40); cairo_text_path(cairo, text1);
-       cairo_stroke(cairo);
-
-       /* Draw filler */
-       cairo_set_source_rgba(cairo, 1, 1, 1, 1);
-       cairo_move_to(cairo, 2, 20); cairo_show_text(cairo, text0);
-       cairo_move_to(cairo, 2, 40); cairo_show_text(cairo, text1);
+       grits_viewer_get_pointer(GRITS_VIEWER(opengl), &plat, &plon, &pelev);
+       const gchar *template =
+               "Location: %7.3lf°, %8.3lf°, %4.0fm\n"
+               "Cursor:   %7.3lf°, %8.3lf°, %4.0fm\n" ;
+       gchar *string = g_strdup_printf(template,
+                lat,  lon,  elev,
+               plat, plon, pelev);
 
        /* Setup pango */
        PangoLayout          *layout = pango_cairo_create_layout(cairo);
-       PangoFontDescription *font   = pango_font_description_from_string("Mono 9");
+       PangoFontDescription *font   = pango_font_description_from_string("Mono 14");
        pango_layout_set_font_description(layout, font);
        pango_font_description_free(font);
-       pango_layout_set_text(layout, text0, -1);
+       pango_layout_set_text(layout, string, -1);
        pango_cairo_update_layout(cairo, layout);
        cairo_set_line_join(cairo, CAIRO_LINE_JOIN_ROUND);
        cairo_move_to(cairo, 2, 40);
@@ -299,6 +287,9 @@ static void info_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer _e
        glTexCoord2f(0, 1); glVertex3f(0    , height, 0); // 2 - |    |
        glTexCoord2f(0, 0); glVertex3f(0    , 0     , 0); // 3 - 2----1
        glEnd();
+
+       /* cleanup */
+       g_free(string);
 }
 
 /***********
@@ -333,10 +324,10 @@ GritsPluginEnv *grits_plugin_env_new(GritsViewer *viewer, GritsPrefs *prefs)
        env->refs = g_list_prepend(env->refs, compass);
 
        /* Add info */
-       //GritsCallback *info = grits_callback_new(info_expose, env);
-       //grits_viewer_add(viewer, GRITS_OBJECT(info), GRITS_LEVEL_HUD, FALSE);
-       //env->refs = g_list_prepend(env->refs, info);
-       (void)info_expose;
+       GritsCallback *info = grits_callback_new(info_expose, env);
+       grits_viewer_add(viewer, GRITS_OBJECT(info), GRITS_LEVEL_HUD, TRUE);
+       env->refs = g_list_prepend(env->refs, info);
+       //(void)info_expose;
 
        /* Add background */
        //GritsTile *background = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST);