Changeset 163


Ignore:
Timestamp:
Aug 22, 2010, 6:02:21 PM (10 years ago)
Author:
sam
Message:

Add an about dialogue and fix an initialisation bug in the map viewer
scrollbar handling.

Location:
trunk/src/gtk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gtk/editor.cpp

    r162 r163  
    4242
    4343    /* Show window. We're good to go! */
    44     gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(builder, "window1")));
     44    gtk_widget_show_all(GTK_WIDGET(gtk_builder_get_object(builder, "window")));
    4545    g_object_unref(G_OBJECT(builder));
    4646
  • trunk/src/gtk/editor.xml

    r162 r163  
    33  <requires lib="gtk+" version="2.16"/>
    44  <!-- interface-naming-policy project-wide -->
    5   <object class="GtkWindow" id="window1">
     5  <object class="GtkWindow" id="window">
    66    <property name="title" translatable="yes">Deus Hax Editor</property>
    77    <signal name="delete_event" handler="gtk_main_quit"/>
     
    6464                        <property name="use_underline">True</property>
    6565                        <property name="use_stock">True</property>
     66                        <property name="always_show_image">True</property>
     67                        <signal name="activate" handler="gtk_main_quit"/>
    6668                      </object>
    6769                    </child>
     
    135137                        <property name="use_underline">True</property>
    136138                        <property name="use_stock">True</property>
     139                        <property name="always_show_image">True</property>
     140                        <signal name="activate" handler="gtk_widget_show" object="aboutdialog"/>
    137141                      </object>
    138142                    </child>
     
    245249    <property name="page_size">10</property>
    246250  </object>
     251  <object class="GtkAboutDialog" id="aboutdialog">
     252    <property name="border_width">5</property>
     253    <property name="modal">True</property>
     254    <property name="window_position">center</property>
     255    <property name="type_hint">normal</property>
     256    <property name="program_name">Deus Hax Editor</property>
     257    <property name="copyright" translatable="yes">&#xA9; 2010 Sam Hocevar &lt;sam@hocevar.net&gt;</property>
     258    <property name="website">http://deushax.zoy.org/</property>
     259    <signal name="close" handler="gtk_widget_hide" object="aboutdialog"/>
     260    <signal name="response" handler="gtk_widget_hide" object="aboutdialog"/>
     261    <signal name="delete_event" handler="gtk_widget_hide" object="aboutdialog"/>
     262    <signal name="delete_event" handler="gtk_true"/>
     263    <child internal-child="vbox">
     264      <object class="GtkVBox" id="dialog-vbox1">
     265        <property name="visible">True</property>
     266        <property name="orientation">vertical</property>
     267        <property name="spacing">2</property>
     268        <child>
     269          <placeholder/>
     270        </child>
     271        <child internal-child="action_area">
     272          <object class="GtkHButtonBox" id="dialog-action_area1">
     273            <property name="visible">True</property>
     274            <property name="layout_style">end</property>
     275          </object>
     276          <packing>
     277            <property name="expand">False</property>
     278            <property name="pack_type">end</property>
     279            <property name="position">0</property>
     280          </packing>
     281        </child>
     282      </object>
     283    </child>
     284  </object>
    247285</interface>
  • trunk/src/gtk/glmapview.cpp

    r162 r163  
    7070    // FIXME: detect when the map viewer is killed
    7171    mapviewer = new MapViewer(path);
     72
     73    UpdateAdjustments();
    7274}
    7375
     
    7577{
    7678    // FIXME: do not do anything if the previous tick was too recent?
    77 
    7879    ticking = TRUE;
    7980
     
    9293gboolean GlMapView::Setup()
    9394{
    94     if (mapviewer)
    95     {
    96         /* Manage adjustments */
    97         struct { GtkAdjustment *adj; float map_size, sw_size; } s[2] =
    98         {
    99             { hadj, mapviewer->GetWidth(), glarea->allocation.width },
    100             { vadj, mapviewer->GetHeight(), glarea->allocation.height },
    101         };
    102 
    103         for (int i = 0; i < 2; i++)
    104         {
    105             gtk_adjustment_set_lower(s[i].adj, 0);
    106             gtk_adjustment_set_upper(s[i].adj, s[i].map_size);
    107             gtk_adjustment_set_step_increment(s[i].adj, 1);
    108             gtk_adjustment_set_page_increment(s[i].adj, s[i].sw_size);
    109             gtk_adjustment_set_page_size(s[i].adj, s[i].sw_size);
    110 
    111             float val = gtk_adjustment_get_value(s[i].adj);
    112             if (val + s[i].sw_size > s[i].map_size)
    113             {
    114                 gtk_adjustment_set_value(s[i].adj,
    115                                          s[i].map_size - s[i].sw_size);
    116                 gtk_adjustment_value_changed(s[i].adj);
    117             }
    118         }
    119     }
    120 
    12195    /* Set up display */
    12296    if (gtk_gl_area_make_current(GTK_GL_AREA(glarea)))
    12397        Video::Setup(glarea->allocation.width, glarea->allocation.height);
     98
     99    UpdateAdjustments();
    124100
    125101    return TRUE;
     
    150126            ;
    151127        Ticker::ClampFps(1000.0f / FPS);
     128    }
     129
     130    return TRUE;
     131}
     132
     133gboolean GlMapView::UpdateAdjustments()
     134{
     135    float w = mapviewer ? mapviewer->GetWidth() : glarea->allocation.width;
     136    float h = mapviewer ? mapviewer->GetHeight() : glarea->allocation.height;
     137
     138    /* Manage adjustments */
     139    struct { GtkAdjustment *adj; float map_size, sw_size; } s[2] =
     140    {
     141        { hadj, w, glarea->allocation.width },
     142        { vadj, h, glarea->allocation.height },
     143    };
     144
     145    for (int i = 0; i < 2; i++)
     146    {
     147        gtk_adjustment_set_lower(s[i].adj, 0);
     148        gtk_adjustment_set_upper(s[i].adj, s[i].map_size);
     149        gtk_adjustment_set_step_increment(s[i].adj, 1);
     150        gtk_adjustment_set_page_increment(s[i].adj, s[i].sw_size);
     151        gtk_adjustment_set_page_size(s[i].adj, s[i].sw_size);
     152
     153        float val = gtk_adjustment_get_value(s[i].adj);
     154        if (val + s[i].sw_size > s[i].map_size)
     155        {
     156            gtk_adjustment_set_value(s[i].adj,
     157                                     s[i].map_size - s[i].sw_size);
     158            gtk_adjustment_value_changed(s[i].adj);
     159        }
    152160    }
    153161
  • trunk/src/gtk/glmapview.h

    r162 r163  
    2121    gboolean Destroy();
    2222    gboolean Draw(GdkEventExpose *event);
     23    gboolean UpdateAdjustments();
    2324    gboolean MouseButton(GdkEventButton *event);
    2425    gboolean MouseMotion(GdkEventMotion *event);
Note: See TracChangeset for help on using the changeset viewer.