00001 #ifndef _MAP_PREVIEW_WIDGET_H_ 00002 #define _MAP_PREVIEW_WIDGET_H_ 00003 00004 #include "math/matrix.h" 00005 #include <gtk/gtkwidget.h> 00006 #include "igl.h" 00007 #include "irender.h" 00008 #include "scenelib.h" 00009 00010 typedef struct _GdkEventExpose GdkEventExpose; 00011 00012 namespace ui 00013 { 00023 class MapPreview 00024 { 00025 // Top-level widget 00026 GtkWidget* _widget; 00027 00028 // GL widget 00029 GtkWidget* _glWidget; 00030 00031 // Current distance between camera and preview 00032 GLfloat _camDist; 00033 00034 // Current rotation matrix 00035 Matrix4 _rotation; 00036 00037 // The root node of the scene to be rendered 00038 scene::Node* _root; 00039 00040 Shader* _stateSelect1; 00041 Shader* _stateSelect2; 00042 00043 private: 00044 00045 static float getRadius(scene::Node* root); 00046 00047 public: 00048 MapPreview (); 00049 00050 ~MapPreview (); 00051 00059 void setSize (int size); 00060 00065 void initialisePreview (); 00066 00069 operator GtkWidget* () 00070 { 00071 return _widget; 00072 } 00073 00074 // Get/set the map root to render 00075 void setRootNode (scene::Node* root); 00076 scene::Node* getRootNode (); 00077 00078 // Updates the view 00079 void draw (); 00080 00081 private: 00082 // GTK Callbacks 00083 static void onExpose (GtkWidget*, GdkEventExpose*, MapPreview*); 00084 static void onMouseMotion (GtkWidget*, GdkEventMotion*, MapPreview*); 00085 static void onMouseScroll (GtkWidget*, GdkEventScroll*, MapPreview*); 00086 }; 00087 00088 } // namespace ui 00089 00090 #endif /* _MAP_PREVIEW_WIDGET_H_ */