1 package HTML5TV::Slides;
11 use Data::Dump qw/dump/;
15 my $current_slide = shift || die "need current slide coderef!";
18 current_slide => $current_slide,
25 $self->{current_slide}->( shift );
36 my $n_a = $1 if $a =~ m{(\d+)};
37 my $n_b = $1 if $b =~ m{(\d+)};
38 $n_a <=> $n_b || $a cmp $b
39 } glob("media/_editing/s/1/*")
42 my $slide = SDL::Surface->new( -name => $slide_paths[0] );
43 my $w = $slide->width;
44 my $h = $slide->height;
46 my @factors = ( qw/ 4 4 4 4 1 2 2 4 4 4 4 / );
48 my ( $x, $y ) = ( 0, 0 );
50 my $background = SDL::Color->new( -r => 0, -g => 0, -b => 0 );
51 my $overlay_color = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0x88 );
53 my $font = SDL::Tool::Font->new(
55 -ttfont => 'media/slides.ttf', # FIXME
57 -fg => $overlay_color,
61 foreach my $i ( 0 .. $#factors ) {
63 my $factor = $factors[$i] || die "no factor $i in ",dump @factors;
65 my $to = SDL::Rect->new(
66 -width => $w / $factor,
67 -height => $h / $factor,
72 my $pos = $self->current_slide($t) + $i - 5;
73 my $path = $slide_paths[ $pos ];
75 if ( $pos < 0 || ! $path ) {
77 $self->{app}->fill( $to, $background ) if $self->{app};
81 $path =~ s{/s/[124]/(\D*(\d+))}{/s/$factor/$1};
84 my $slide = SDL::Surface->new( -name => $path );
86 $font->print( $slide, 5, 5, $subtitles[$nr - 1]->[2] || $nr );
88 my $rect = SDL::Rect->new(
89 -width => $slide->width(),
90 -height => $slide->height(),
95 # warn "$x $y $path\n";
97 if ( ! $self->{app} ) {
99 $self->{app} = SDL::App->new(
101 -height => ( $h * 2 ) + 20,
108 $slide->blit( $rect, $self->{app}, $to );
112 $self->{app}->update( $to ) if $self->{app};
124 if ( $self->{app} ) {
128 my $w_1s = $w / $length;
134 my $bar_back = SDL::Color->new( -r => 0x88, -g => 0x88, -b => 0x88 );
135 my $rect = SDL::Rect->new(
142 $self->{app}->fill( $rect, $bar_back );
143 $self->{app}->update( $rect );
147 my $col_subtitle = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0x88 );
148 my $col_pos = SDL::Color->new( -r => 0x00, -g => 0xff, -b => 0x00 );
150 foreach my $s ( @subtitles ) {
151 my $s_x = int( $s->[0] * $w_1s + 0.9 );
152 my $s_w = int( abs( $s->[1] - $s->[0] ) * $w_1s + 0.9 );
154 # warn "$s_x $s_w ", $s->[2];
156 my $rect = SDL::Rect->new(
162 $self->{app}->fill( $rect, $col_subtitle );
163 # $self->{app}->update( $rect );
166 my $rect = SDL::Rect->new(
168 -height => $bar_h * 2,
169 -x => int( $t * $w_1s ),
172 $self->{app}->fill( $rect, $col_pos );
173 # $self->{app}->update( $rect );