App-PLab

 view release on metacpan or  search on metacpan

lib/App/PLab/ImageApp.pm  view on Meta::CPAN

   $self-> zoom( $x < $y ? $x : $y);
   $w-> sb_text("Zoom: ".$self->zoom);
}

sub IV_Size
{
   my ( $w, $self) = @_;
   $w-> iv_zbestfit( $self) if $self->{autoBestFit};
}

sub ivm_repaint
{
   my ( $w, $self) = @_;
   return unless $w-> {magnify};
   my $j = $w-> {magnify}-> {canvas};
   $j-> {override} = [ 0, 0];
   $j-> translate( 0, 0);
   $j-> clear;
   my @o = $self-> pointerPos;
   $j-> {override} = [ -$o[0] + 38, -$o[1] + 25];
   $j-> translate( 0, 0);
   $w-> IV_Paint( $self, $j);
   $j-> {override} = [ 0, 0];
   $j-> translate( 0, 0);
   $w-> {magnify}-> repaint;
}

sub iv_magnify
{
   my ( $w, $self) = @_;
   return if $w-> {magnify};
   my $x = $self-> insert( 'App::PLab::MagnifyingGlassWidget' );
   $x-> focus;
   $w-> IV-> capture(1);
   $w-> {magnify} = $x;
   $w-> ivm_repaint( $self, $self-> pointerPos);
}

sub iv_cancelmagnify
{
   my ( $w, $self) = @_;
   return unless $w->{magnify};
   $w->{magnify}-> destroy;
   $w->{magnify} = undef;
   $w-> IV-> capture(0);
}

# IV_END
# SB

sub sb_text
{
   my ( $w, $text, $color) = @_;
   my $self = $w-> StatusBar;
   $self-> color( defined $color ? cl::LightRed : cl::Fore);
   $self-> set(
      text  => $text,
      raise => 1,
   );
   $self-> update_view;
   $self-> { timer} = $self-> insert( Timer =>
      onTick  => sub {
         $_[0]-> stop;
         $_[0]-> owner-> set(
            text  => '',
            raise => 0,
         );
      },
   ) unless $self-> { timer};
   $self-> { timer}-> stop;
   $self-> { timer}-> timeout(  $w-> {ini}-> {statusDelay} * 1000);
   $self-> { timer}-> start;
}

# SB_END

sub profile_default
{
   my $def = $_[ 0]-> SUPER::profile_default;
   my %prf = (
      name       => 'MainWindow',
      size       => [ 531, 594],
      text       => $::application-> name,
      widgetClass=> wc::Dialog,
   );
   @$def{keys %prf} = values %prf;
   return $def;
}

sub init
{
   my $self = shift;
   my %profile = $self-> SUPER::init(@_);

   my $w = $self;
   my ($x, $y) = $w-> size;

   my $scale = $::application-> uiScaling;
   $scale = 1 if $scale < 1;

   $w-> insert( "Panel",
      text      => "",
      name      => "ToolBar",
      origin    => [ 2, $y - 2 - 38 * $scale],
      size      => [ $x - 4, 38 * $scale],
      raise     => 1,
      image     => App::PLab::ImageAppGlyphs::image( bga::tile_m),
      growMode  => gm::GrowHiX | gm::GrowLoY,
   );

   my %btn_profile = (
     glyphs      => 2,
     text        => "",
     selectable  => 0,
     transparent => 1,
     flat        => 1,
     size        => [ map { $_ * $scale } 36, 36],
     borderWidth => 1,
   );

   $w-> ToolBar-> insert(
      [ SpeedButton =>
         origin    => [1, 1],
         image     => App::PLab::ButtonGlyphs::icon( bg::fldropen),
         hint      => 'Open file',
         onClick   => sub { $w-> win_openfile; },
         %btn_profile,
      ],
      [ SpeedButton =>
         name    => "PrevImage",
         origin  => [42 * $scale, 1],
         image   => App::PLab::ImageAppGlyphs::icon( bga::prev),



( run in 1.707 second using v1.01-cache-2.11-cpan-9581c071862 )