Fix:gui_internal:Next round of improvements
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 16 Jun 2008 16:40:18 +0000 (16:40 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 16 Jun 2008 16:40:18 +0000 (16:40 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1127 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/graphics.c
navit/graphics.h
navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
navit/gui/internal/gui_internal.c

index 4b1de83..5044b4a 100644 (file)
@@ -371,6 +371,17 @@ void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font,
 //# Comment: 
 //# Authors: Martin Schaller (04/2008)
 //##############################################################################################################
+void graphics_overlay_disable(struct graphics *this_, int disable)
+{
+       if (this_->meth.overlay_disable)
+               this_->meth.overlay_disable(this_->priv, disable);
+}
+
+//##############################################################################################################
+//# Description: 
+//# Comment: 
+//# Authors: Martin Schaller (04/2008)
+//##############################################################################################################
 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img)
 {
        this_->meth.draw_image(this_->priv, gc->priv, p, img->priv);
index 9d7a7e0..191fc70 100644 (file)
@@ -67,6 +67,8 @@ struct graphics_methods {
        void (*register_motion_callback)(struct graphics_priv *gr, void (*callback)(void *data, struct point *p), void *data);
        void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
        void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret);
+       void (*overlay_disable)(struct graphics_priv *gr, int disable);
+       void (*register_key_callback)(struct graphics_priv *gr, void (*callback)(void *data, struct point *p), void *data);
 };
 
 
@@ -146,6 +148,7 @@ void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct
 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
 void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy);
 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret);
+void graphics_overlay_disable(struct graphics *this_, int disable);
 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
 void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
 int graphics_ready(struct graphics *this_);
index 68a8ba7..74962f2 100644 (file)
@@ -36,6 +36,7 @@
 #include "graphics.h"
 #include "color.h"
 #include "item.h"
+#include "window.h"
 #include "plugin.h"
 
 struct graphics_priv {
@@ -43,6 +44,7 @@ struct graphics_priv {
        int button_timeout;
        GtkWidget *widget;
        GtkWidget *win;
+       struct window window;
        GdkDrawable *drawable;
        GdkDrawable *background;
        int background_ready;
@@ -55,6 +57,7 @@ struct graphics_priv {
        int win_h;
        int library_init;
        int visible;
+       int overlay_disabled;
        struct graphics_priv *parent;
        struct graphics_priv *overlays;
        struct graphics_priv *next;
@@ -66,8 +69,11 @@ struct graphics_priv {
        void *motion_callback_data;
        void (*button_callback)(void *data, int press, int button, struct point *p);
        void *button_callback_data;
+       void (*key_callback)(void *data, int key);
+       void *key_callback_data;
 };
 
+
 struct graphics_font_priv {
         FT_Face face;
 };
@@ -649,7 +655,8 @@ overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, int wi
 
        if (! parent->drawable)
                return;
-
+       if (parent->overlay_disabled || overlay->overlay_disabled)
+               return;
        w=overlay->width;
        if (w < 0)
                w+=parent->width;
@@ -873,6 +880,12 @@ motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data)
 
 static struct graphics_priv *graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth);
 
+static void
+overlay_disable(struct graphics_priv *gr, int disabled)
+{
+       gr->overlay_disabled=disabled;
+}
+
 static struct graphics_priv *
 overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h)
 {
@@ -894,6 +907,17 @@ static int gtk_argc;
 static char **gtk_argv={NULL};
 
 
+static int
+graphics_gtk_drawing_area_fullscreen(struct window *w, int on)
+{
+       struct graphics_priv *gr=w->priv;
+       if (on)
+                gtk_window_fullscreen(GTK_WINDOW(gr->win));
+       else
+                gtk_window_unfullscreen(GTK_WINDOW(gr->win));
+       return 1;
+}              
+
 static void *
 get_data(struct graphics_priv *this, char *type)
 {
@@ -908,7 +932,9 @@ get_data(struct graphics_priv *this, char *type)
                gtk_widget_realize(this->win);
                gtk_container_add(GTK_CONTAINER(this->win), this->widget);
                gtk_widget_show_all(this->win);
-               return this->win;
+               this->window.fullscreen=graphics_gtk_drawing_area_fullscreen;
+               this->window.priv=this;
+               return &this->window;
        }
        return NULL;
 }
@@ -934,6 +960,13 @@ register_button_callback(struct graphics_priv *this, void (*callback)(void *data
        this->button_callback_data=data;
 }
 
+static void
+register_key_callback(struct graphics_priv *this, void (*callback)(void *data, int press, int button, struct point *p), void *data)
+{
+       this->key_callback=callback;
+       this->key_callback_data=data;
+}
+
 static struct graphics_methods graphics_methods = {
        graphics_destroy,
        draw_mode,
@@ -960,6 +993,8 @@ static struct graphics_methods graphics_methods = {
        register_motion_callback,
        image_free,
        get_text_bbox,
+       overlay_disable,
+       register_key_callback,
 };
 
 static struct graphics_priv *
index 6662c93..d225e90 100644 (file)
@@ -48,6 +48,7 @@
 #include "layout.h"
 #include "callback.h"
 #include "vehicle.h"
+#include "window.h"
 #include "config.h"
 
 #define STATE_VISIBLE 1
@@ -127,6 +128,7 @@ struct widget {
 //##############################################################################################################
 struct gui_priv {
         struct navit *nav;
+       struct window *win;
        struct graphics *gra;
        struct graphics_gc *background;
        struct graphics_gc *background2;
@@ -134,6 +136,7 @@ struct gui_priv {
        struct graphics_gc *foreground;
        int spacing;
        int font_size;
+       int fullscreen;
        struct graphics_font *font;
        int icon_xs, icon_s, icon_l;
        int pressed;
@@ -1018,6 +1021,13 @@ gui_internal_cmd_layout(struct gui_priv *this, struct widget *wm)
        gui_internal_menu_render(this);
 }
 
+static void
+gui_internal_cmd_fullscreen(struct gui_priv *this, struct widget *wm)
+{
+       this->fullscreen=!this->fullscreen;
+       this->win->fullscreen(this->win, this->fullscreen);
+}
+
 
 static void
 gui_internal_cmd_display(struct gui_priv *this, struct widget *wm)
@@ -1029,6 +1039,10 @@ gui_internal_cmd_display(struct gui_priv *this, struct widget *wm)
                gui_internal_button_new_with_callback(this, "Layout",
                        image_new_l(this, "gui_display"), gravity_center|orientation_vertical,
                        gui_internal_cmd_layout, NULL));
+       gui_internal_widget_append(w,
+               gui_internal_button_new_with_callback(this, "Fullscreen",
+                       image_new_l(this, "gui_display"), gravity_center|orientation_vertical,
+                       gui_internal_cmd_fullscreen, NULL));
        gui_internal_menu_render(this);
 }
 
@@ -1223,6 +1237,7 @@ static void gui_internal_button(void *data, int pressed, int button, struct poin
                if (!navit_handle_button(this->nav, pressed, button, p, NULL) || button >=4) // Maybe there's a better way to do this
                        return;
                navit_block(this->nav, 1);
+               graphics_overlay_disable(gra, 1);
                // draw menu
                this->root.p.x=0;
                this->root.p.y=0;
@@ -1244,6 +1259,7 @@ static void gui_internal_button(void *data, int pressed, int button, struct poin
                gui_internal_highlight(this, NULL);
                graphics_draw_mode(gra, draw_mode_end);
                if (! this->root.children) {
+                       graphics_overlay_disable(gra, 0);
                        if (!navit_block(this->nav, 0)) {
                                if (this->redraw)
                                        navit_draw(this->nav);
@@ -1281,7 +1297,7 @@ static void gui_internal_resize(void *data, int w, int h)
 //##############################################################################################################
 static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
 {
-       void *graphics;
+       struct window *win;
 #if 0
        struct color cb={0x7fff,0x7fff,0x7fff,0xffff};
 #endif
@@ -1291,10 +1307,11 @@ static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra
        struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
        struct transformation *trans=navit_get_trans(this->nav);
        
-       graphics=graphics_get_data(gra, "window");
-        if (! graphics)
+       win=graphics_get_data(gra, "window");
+        if (! win)
                 return 1;
        this->gra=gra;
+       this->win=win;
        transform_get_size(trans, &this->root.w, &this->root.h);
        graphics_register_resize_callback(gra, gui_internal_resize, this);
        graphics_register_button_callback(gra, gui_internal_button, this);