scrollbar handling.legacy
| @@ -41,7 +41,7 @@ int main(int argc, char **argv) | |||||
| GlMapView *glmapview = new GlMapView(builder); | GlMapView *glmapview = new GlMapView(builder); | ||||
| /* Show window. We're good to go! */ | /* Show window. We're good to go! */ | ||||
| gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(builder, "window1"))); | |||||
| gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(builder, "window"))); | |||||
| g_object_unref(G_OBJECT(builder)); | g_object_unref(G_OBJECT(builder)); | ||||
| new DebugFps(); | new DebugFps(); | ||||
| @@ -2,7 +2,7 @@ | |||||
| <interface> | <interface> | ||||
| <requires lib="gtk+" version="2.16"/> | <requires lib="gtk+" version="2.16"/> | ||||
| <!-- interface-naming-policy project-wide --> | <!-- interface-naming-policy project-wide --> | ||||
| <object class="GtkWindow" id="window1"> | |||||
| <object class="GtkWindow" id="window"> | |||||
| <property name="title" translatable="yes">Deus Hax Editor</property> | <property name="title" translatable="yes">Deus Hax Editor</property> | ||||
| <signal name="delete_event" handler="gtk_main_quit"/> | <signal name="delete_event" handler="gtk_main_quit"/> | ||||
| <child> | <child> | ||||
| @@ -63,6 +63,8 @@ | |||||
| <property name="visible">True</property> | <property name="visible">True</property> | ||||
| <property name="use_underline">True</property> | <property name="use_underline">True</property> | ||||
| <property name="use_stock">True</property> | <property name="use_stock">True</property> | ||||
| <property name="always_show_image">True</property> | |||||
| <signal name="activate" handler="gtk_main_quit"/> | |||||
| </object> | </object> | ||||
| </child> | </child> | ||||
| </object> | </object> | ||||
| @@ -134,6 +136,8 @@ | |||||
| <property name="visible">True</property> | <property name="visible">True</property> | ||||
| <property name="use_underline">True</property> | <property name="use_underline">True</property> | ||||
| <property name="use_stock">True</property> | <property name="use_stock">True</property> | ||||
| <property name="always_show_image">True</property> | |||||
| <signal name="activate" handler="gtk_widget_show" object="aboutdialog"/> | |||||
| </object> | </object> | ||||
| </child> | </child> | ||||
| </object> | </object> | ||||
| @@ -244,4 +248,38 @@ | |||||
| <property name="page_increment">10</property> | <property name="page_increment">10</property> | ||||
| <property name="page_size">10</property> | <property name="page_size">10</property> | ||||
| </object> | </object> | ||||
| <object class="GtkAboutDialog" id="aboutdialog"> | |||||
| <property name="border_width">5</property> | |||||
| <property name="modal">True</property> | |||||
| <property name="window_position">center</property> | |||||
| <property name="type_hint">normal</property> | |||||
| <property name="program_name">Deus Hax Editor</property> | |||||
| <property name="copyright" translatable="yes">© 2010 Sam Hocevar <sam@hocevar.net></property> | |||||
| <property name="website">http://deushax.zoy.org/</property> | |||||
| <signal name="close" handler="gtk_widget_hide" object="aboutdialog"/> | |||||
| <signal name="response" handler="gtk_widget_hide" object="aboutdialog"/> | |||||
| <signal name="delete_event" handler="gtk_widget_hide" object="aboutdialog"/> | |||||
| <signal name="delete_event" handler="gtk_true"/> | |||||
| <child internal-child="vbox"> | |||||
| <object class="GtkVBox" id="dialog-vbox1"> | |||||
| <property name="visible">True</property> | |||||
| <property name="orientation">vertical</property> | |||||
| <property name="spacing">2</property> | |||||
| <child> | |||||
| <placeholder/> | |||||
| </child> | |||||
| <child internal-child="action_area"> | |||||
| <object class="GtkHButtonBox" id="dialog-action_area1"> | |||||
| <property name="visible">True</property> | |||||
| <property name="layout_style">end</property> | |||||
| </object> | |||||
| <packing> | |||||
| <property name="expand">False</property> | |||||
| <property name="pack_type">end</property> | |||||
| <property name="position">0</property> | |||||
| </packing> | |||||
| </child> | |||||
| </object> | |||||
| </child> | |||||
| </object> | |||||
| </interface> | </interface> | ||||
| @@ -69,12 +69,13 @@ void GlMapView::LoadMap(char const *path) | |||||
| { | { | ||||
| // FIXME: detect when the map viewer is killed | // FIXME: detect when the map viewer is killed | ||||
| mapviewer = new MapViewer(path); | mapviewer = new MapViewer(path); | ||||
| UpdateAdjustments(); | |||||
| } | } | ||||
| gboolean GlMapView::IdleTick() | gboolean GlMapView::IdleTick() | ||||
| { | { | ||||
| // FIXME: do not do anything if the previous tick was too recent? | // FIXME: do not do anything if the previous tick was too recent? | ||||
| ticking = TRUE; | ticking = TRUE; | ||||
| if (mapviewer) | if (mapviewer) | ||||
| @@ -91,37 +92,12 @@ gboolean GlMapView::IdleTick() | |||||
| gboolean GlMapView::Setup() | gboolean GlMapView::Setup() | ||||
| { | { | ||||
| if (mapviewer) | |||||
| { | |||||
| /* Manage adjustments */ | |||||
| struct { GtkAdjustment *adj; float map_size, sw_size; } s[2] = | |||||
| { | |||||
| { hadj, mapviewer->GetWidth(), glarea->allocation.width }, | |||||
| { vadj, mapviewer->GetHeight(), glarea->allocation.height }, | |||||
| }; | |||||
| for (int i = 0; i < 2; i++) | |||||
| { | |||||
| gtk_adjustment_set_lower(s[i].adj, 0); | |||||
| gtk_adjustment_set_upper(s[i].adj, s[i].map_size); | |||||
| gtk_adjustment_set_step_increment(s[i].adj, 1); | |||||
| gtk_adjustment_set_page_increment(s[i].adj, s[i].sw_size); | |||||
| gtk_adjustment_set_page_size(s[i].adj, s[i].sw_size); | |||||
| float val = gtk_adjustment_get_value(s[i].adj); | |||||
| if (val + s[i].sw_size > s[i].map_size) | |||||
| { | |||||
| gtk_adjustment_set_value(s[i].adj, | |||||
| s[i].map_size - s[i].sw_size); | |||||
| gtk_adjustment_value_changed(s[i].adj); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Set up display */ | /* Set up display */ | ||||
| if (gtk_gl_area_make_current(GTK_GL_AREA(glarea))) | if (gtk_gl_area_make_current(GTK_GL_AREA(glarea))) | ||||
| Video::Setup(glarea->allocation.width, glarea->allocation.height); | Video::Setup(glarea->allocation.width, glarea->allocation.height); | ||||
| UpdateAdjustments(); | |||||
| return TRUE; | return TRUE; | ||||
| } | } | ||||
| @@ -154,6 +130,38 @@ gboolean GlMapView::Draw(GdkEventExpose *event) | |||||
| return TRUE; | return TRUE; | ||||
| } | } | ||||
| gboolean GlMapView::UpdateAdjustments() | |||||
| { | |||||
| float w = mapviewer ? mapviewer->GetWidth() : glarea->allocation.width; | |||||
| float h = mapviewer ? mapviewer->GetHeight() : glarea->allocation.height; | |||||
| /* Manage adjustments */ | |||||
| struct { GtkAdjustment *adj; float map_size, sw_size; } s[2] = | |||||
| { | |||||
| { hadj, w, glarea->allocation.width }, | |||||
| { vadj, h, glarea->allocation.height }, | |||||
| }; | |||||
| for (int i = 0; i < 2; i++) | |||||
| { | |||||
| gtk_adjustment_set_lower(s[i].adj, 0); | |||||
| gtk_adjustment_set_upper(s[i].adj, s[i].map_size); | |||||
| gtk_adjustment_set_step_increment(s[i].adj, 1); | |||||
| gtk_adjustment_set_page_increment(s[i].adj, s[i].sw_size); | |||||
| gtk_adjustment_set_page_size(s[i].adj, s[i].sw_size); | |||||
| float val = gtk_adjustment_get_value(s[i].adj); | |||||
| if (val + s[i].sw_size > s[i].map_size) | |||||
| { | |||||
| gtk_adjustment_set_value(s[i].adj, | |||||
| s[i].map_size - s[i].sw_size); | |||||
| gtk_adjustment_value_changed(s[i].adj); | |||||
| } | |||||
| } | |||||
| return TRUE; | |||||
| } | |||||
| gboolean GlMapView::MouseButton(GdkEventButton *event) | gboolean GlMapView::MouseButton(GdkEventButton *event) | ||||
| { | { | ||||
| if (event->type == GDK_BUTTON_PRESS && event->button == 2) | if (event->type == GDK_BUTTON_PRESS && event->button == 2) | ||||
| @@ -20,6 +20,7 @@ private: | |||||
| gboolean Setup(); | gboolean Setup(); | ||||
| gboolean Destroy(); | gboolean Destroy(); | ||||
| gboolean Draw(GdkEventExpose *event); | gboolean Draw(GdkEventExpose *event); | ||||
| gboolean UpdateAdjustments(); | |||||
| gboolean MouseButton(GdkEventButton *event); | gboolean MouseButton(GdkEventButton *event); | ||||
| gboolean MouseMotion(GdkEventMotion *event); | gboolean MouseMotion(GdkEventMotion *event); | ||||