Beispiel #1
0
static void controls_render(GpsdViewerOsd *self, OsmGpsMap *map)
{
    GpsdViewerOsdPrivate *priv = self->priv;
    GpsdViewerOsdControls *controls = self->priv->controls;

    if(!controls->surface || controls->rendered)
        return;

    controls->rendered = TRUE;

    GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(map));
    GdkColor bg = style->bg[GTK_STATE_NORMAL];
    GdkColor fg = style->fg[GTK_STATE_NORMAL];
    //GdkColor da = GTK_WIDGET(map)->style->fg[GTK_STATE_INSENSITIVE];

    // **** first fill with transparency 
    g_assert(controls->surface);
    cairo_t *cr = cairo_create(controls->surface);
    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0);
    cairo_paint(cr);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);

    gint x = 1;
    gint y = 1;

    /* --------- draw dpad ----------- */
    if (priv->show_dpad) {
        gint gps_w = (priv->show_gps_in_dpad ? priv->dpad_radius/2 : 0);
        osd_render_dpad(cr, x, y, priv->dpad_radius, gps_w, priv->gpsd_viewer_osd_shadow, &bg, &fg);
        if (priv->show_gps_in_dpad) {
            gint gps_x = x+priv->dpad_radius-(gps_w/2);
            gint gps_y = y+priv->dpad_radius-(gps_w/2);
            osd_render_gps(cr, gps_x, gps_y, gps_w, &bg, &fg);
        }
        y += (2*priv->dpad_radius);
        y += priv->gpsd_viewer_osd_pad;
    }

    /* --------- draw zoom ----------- */
    if (priv->show_zoom) {
        gint gps_w = (priv->show_gps_in_zoom ? priv->dpad_radius/2 : 0);
        osd_render_zoom(cr, x, y, priv->zoom_w, priv->zoom_h, gps_w, priv->gpsd_viewer_osd_shadow, &bg, &fg);
        if (priv->show_gps_in_zoom) {
            gint gps_x = x+(priv->zoom_w/2);
            gint gps_y = y+(priv->zoom_h/2)-(gps_w/2);
            osd_render_gps(cr, gps_x, gps_y, gps_w, &bg, &fg);
        }
        y += priv->zoom_h;
    }

}
Beispiel #2
0
static void
osd_render(osm_gps_map_osd_t *osd)
{
    osd_priv_t *priv = (osd_priv_t*)osd->priv;

    /* this function is actually called pretty often since the */
    /* OSD contents may have changed (due to a coordinate/zoom change). */
    /* The different OSD parts have to make sure that they don't */
    /* render unneccessarily often and thus waste CPU power */

    if(!priv->select_toggle.surface) {
        priv->select_toggle.surface =
            cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H);

        osd_render_toggle(osd);
    }

    if(!priv->zoom.surface) {
        priv->zoom.surface =
            cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H);

        osd_render_zoom(osd);
    }
}