]> www.fi.muni.cz Git - slotcarman.git/commitdiff
WIP: fullscreen mode
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Tue, 7 Dec 2010 17:59:52 +0000 (18:59 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Tue, 7 Dec 2010 17:59:52 +0000 (18:59 +0100)
SCX/GUI.pm
slotcarman.glade

index 0e01d17ddce05bc35d7fbd41a3a2bf456f50bb6b..4f02edc74a4c682c1d4173d7f687195a268549b7 100755 (executable)
@@ -9,22 +9,13 @@ use Encode;
 use Gtk2 '-init';
 use Glib qw(TRUE FALSE);
 
-use SCX::Reader;
+our $BASE_SIZE;
 
 sub new {
        my ($class, $args) = @_;
 
        my $self = {
-               throttle_images => [ 
-                       load_image_set('img/throttle%d.svg', 13, 100)
-               ],
-               fuel_images => [
-                       load_image_set('img/fuel%d.svg', 8, 60)
-               ],
-               car_images => load_image_dir('img/SCXCars', 100),
-               semaphore_images => [
-                       load_image_set('img/semaphore%d.svg', 5, 200)
-               ],
+               img_height => $args->{img_height} || 100,
                builder => Gtk2::Builder->new,
                semaphore_win => Gtk2::Window->new('popup'),
                semaphore_img => Gtk2::Image->new,
@@ -35,6 +26,8 @@ sub new {
        $self->{builder}->add_from_file('slotcarman.glade');
 
        $self->{builder}->connect_signals(undef);
+       $self->load_all_images;
+       $self->set_font_sizes;
 
        my $pixbuf = $self->{semaphore_images}->[0];
        $self->{semaphore_img}->set_from_pixbuf($pixbuf);
@@ -43,9 +36,14 @@ sub new {
        $self->{semaphore_win}->set_type_hint('splashscreen');
        $self->{semaphore_win}->set_position('center-on-parent');
        $self->{semaphore_win}->set_transient_for(
-               $self->{builder}->get_object('slotcarman')
+               $self->get_object('slotcarman')
        );
 
+       $self->get_object('image_car1')->signal_connect(
+               'size_allocate' => \&watch_resize,
+               $self,
+       );
+       
        return $self;
 }
 
@@ -59,8 +57,67 @@ sub show {
 
 sub delete_event { Gtk2->main_quit; }
 
+sub quit { Gtk2->main_quit; }
+
+sub fullscreen {
+       my ($self) = @_;
+
+       $self->get_object('slotcarman')->fullscreen;
+       my $h = $self->get_object('image_car1')->allocation->height;
+       print "h=$h\n";
+}
+       
+sub watch_resize {
+       my ($window, $rectangle, $self) = @_;
+       print "w=", $rectangle->width, ", h=", $rectangle->height, "\n";
+       # TODO
+}
+
 sub get_object { return shift->{builder}->get_object(@_); }
 
+sub set_font_sizes {
+       my ($self) = @_;
+
+       if ($self->{img_height} <= 80) {
+               $self->{label_font} = 10;
+               $self->{value_font} = 18;
+               $self->{lap_font} = 24;
+       } elsif ($self->{img_height} <= 100) {
+               $self->{label_font} = 12;
+               $self->{value_font} = 20;
+               $self->{lap_font} = 28;
+       } elsif ($self->{img_height} <= 120) {
+               $self->{label_font} = 14;
+               $self->{value_font} = 24;
+               $self->{lap_font} = 32;
+       } elsif ($self->{img_height} <= 150) {
+               $self->{label_font} = 16;
+               $self->{value_font} = 28;
+               $self->{lap_font} = 36;
+       } else {
+               $self->{label_font} = 18;
+               $self->{value_font} = 32;
+               $self->{lap_font} = 40;
+       }
+}
+
+sub load_all_images {
+       my ($self) = @_;
+
+       my $h = $self->{img_height};
+
+       $self->{throttle_images} = [
+               load_image_set('img/throttle%d.svg', 13, $h)
+       ];
+       $self->{fuel_images} = [
+                       load_image_set('img/fuel%d.svg', 8, int(0.6 * $h))
+       ];
+       $self->{car_images} = load_image_dir('img/SCXCars', $h),
+       $self->{semaphore_images} => [
+                       load_image_set('img/semaphore%d.svg', 5, 2 * $h)
+       ];
+};
+
 sub load_image_set {
        my ($pattern, $limit, $height) = @_;
 
index 4e1d0df142212d30acdb32349be5fce053ef3dcb..ce10796173d122317bf43cf8e78f6489dfe9ab2d 100644 (file)
             </child>
           </object>
           <packing>
+            <property name="expand">False</property>
             <property name="position">1</property>
           </packing>
         </child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">4</property>
                 <property name="bottom_attach">5</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">6</property>
                 <property name="bottom_attach">7</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">8</property>
                 <property name="bottom_attach">9</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">10</property>
                 <property name="bottom_attach">11</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">8</property>
                 <property name="top_attach">12</property>
                 <property name="bottom_attach">13</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">4</property>
                 <property name="bottom_attach">5</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">6</property>
                 <property name="bottom_attach">7</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">8</property>
                 <property name="bottom_attach">9</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">10</property>
                 <property name="bottom_attach">11</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">7</property>
                 <property name="top_attach">12</property>
                 <property name="bottom_attach">13</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">4</property>
                 <property name="bottom_attach">5</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">6</property>
                 <property name="bottom_attach">7</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">8</property>
                 <property name="bottom_attach">9</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">10</property>
                 <property name="bottom_attach">11</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="right_attach">4</property>
                 <property name="top_attach">12</property>
                 <property name="bottom_attach">13</property>
+                <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
             </child>
             <child>
                 <property name="visible">True</property>
               </object>
               <packing>
-                <property name="right_attach">7</property>
+                <property name="right_attach">8</property>
                 <property name="top_attach">7</property>
                 <property name="bottom_attach">8</property>
               </packing>
                 <property name="visible">True</property>
               </object>
               <packing>
-                <property name="right_attach">7</property>
+                <property name="right_attach">8</property>
                 <property name="top_attach">9</property>
                 <property name="bottom_attach">10</property>
               </packing>
                 <property name="visible">True</property>
               </object>
               <packing>
-                <property name="right_attach">7</property>
+                <property name="right_attach">8</property>
                 <property name="top_attach">11</property>
                 <property name="bottom_attach">12</property>
               </packing>
             <child>
               <placeholder/>
             </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="position">3</property>