]> Pileus Git - grits/commitdiff
Convert to GtkAllocation
authorAndy Spencer <andy753421@gmail.com>
Sun, 20 Jan 2013 06:44:25 +0000 (06:44 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 21 Jan 2013 04:50:51 +0000 (04:50 +0000)
src/grits-opengl.c
src/objects/grits-marker.c
src/plugins/env.c

index 6a5ea32ecf0001e91e9796da5b945256fb20efd6..c4c7dacb4039fd8e3dbf7257e4e64f618aacbfc4 100644 (file)
@@ -68,8 +68,10 @@ static void _set_projection(GritsOpenGL *opengl)
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
 
-       double width  = GTK_WIDGET(opengl)->allocation.width;
-       double height = GTK_WIDGET(opengl)->allocation.height;
+       GtkAllocation alloc;
+       gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+       double width  = alloc.width;
+       double height = alloc.height;
        double ang    = atan((height/2)/FOV_DIST)*2;
        double atmos  = 100000;
        double near   = MAX(elev*0.75 - atmos, 50); // View 100km of atmosphere
@@ -219,9 +221,11 @@ static gint run_picking(GritsOpenGL *opengl, GdkEvent *event,
 
 static gboolean run_mouse_move(GritsOpenGL *opengl, GdkEventMotion *event)
 {
-       gdouble height = GTK_WIDGET(opengl)->allocation.height;
+       GtkAllocation alloc;
+       gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+
        gdouble gl_x   = event->x;
-       gdouble gl_y   = height - event->y;
+       gdouble gl_y   = alloc.height - event->y;
        gdouble delta  = opengl->pickmode ? 200 : 2;
 
        if (opengl->pickmode) {
@@ -322,11 +326,11 @@ static void _draw_level(gpointer _level, gpointer _opengl)
 
        /* Start ortho */
        if (level->num >= GRITS_LEVEL_HUD) {
+               GtkAllocation alloc;
+               gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
                glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
                glMatrixMode(GL_MODELVIEW);  glPushMatrix(); glLoadIdentity();
-               gint win_width  = GTK_WIDGET(opengl)->allocation.width;
-               gint win_height = GTK_WIDGET(opengl)->allocation.height;
-               glOrtho(0, win_width, win_height, 0, 1000, -1000);
+               glOrtho(0, alloc.width, alloc.height, 0, 1000, -1000);
        }
 
        /* Draw unsorted objects without depth testing,
index 35103538dfa6975454932adc822c9a1f8f8b7d70..40d45f4e57fa8ee2363085f276090f993f3b146a 100644 (file)
@@ -256,11 +256,12 @@ static void grits_marker_draw(GritsObject *_marker, GritsOpenGL *opengl)
                                point->lat, point->lon, point->elev,
                                &px, &py, &pz);
 
-               gint win_height = GTK_WIDGET(opengl)->allocation.height;
                if (pz > 1)
                        return;
 
-               glTranslated(px, win_height-py, 0);
+               GtkAllocation alloc;
+               gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+               glTranslated(px, alloc.height-py, 0);
                glRotatef(marker->angle, 0, 0, -1);
                glTranslated(-marker->xoff, -marker->yoff, 0);
        } else {
index 4b6ed795db783d4a6b47c70ada7612fb8c3a2f3a..658881d3f5749cbe691c8e130cf050ea65e37f5a 100644 (file)
@@ -195,11 +195,11 @@ static void compass_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer
        grits_viewer_get_rotation(env->viewer, &x, &y, &z);
 
        /* Setup projection */
-       gint win_width  = GTK_WIDGET(opengl)->allocation.width;
-       gint win_height = GTK_WIDGET(opengl)->allocation.height;
-       float scale     = CLAMP(MIN(win_width,win_height)/2.0 * 0.1, 40, 100);
+       GtkAllocation alloc;
+       gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+       float scale     = CLAMP(MIN(alloc.width,alloc.height)/2.0 * 0.1, 40, 100);
        float offset    = scale + 20;
-       glTranslatef(win_width - offset, offset, 0);
+       glTranslatef(alloc.width - offset, offset, 0);
 
        /* Setup state */
        glClear(GL_DEPTH_BUFFER_BIT);
@@ -226,8 +226,8 @@ static gboolean compass_click(GritsCallback *compass, GdkEvent *evnet, GritsView
 /* Info */
 static void info_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer _env)
 {
-       gint win_width  = GTK_WIDGET(opengl)->allocation.width;
-       gint win_height = GTK_WIDGET(opengl)->allocation.height;
+       GtkAllocation alloc;
+       gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
 
        /* Create cairo  surface */
        guint            tex     = 0;
@@ -292,7 +292,7 @@ static void info_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer _e
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, tex);
        glDisable(GL_CULL_FACE);
-       glTranslatef(win_width - width, win_height - height, 0);
+       glTranslatef(alloc.width - width, alloc.height - height, 0);
        glBegin(GL_QUADS);
        glTexCoord2f(1, 0); glVertex3f(width, 0     , 0); // 0 - 3    0
        glTexCoord2f(1, 1); glVertex3f(width, height, 0); // 1 - |    |