Gtk2-Ex-Xor

 view release on metacpan or  search on metacpan

devel/lasso.pl  view on Meta::CPAN

                          });
  $button->signal_connect
    (toggled => sub {
       my $active = $button->get_active;
       print "$progname: hint toggled $active\n";
       $lasso->set (active => $active);
     });
}
{
  my $button = Gtk2::Button->new_with_label ('Start');
  $button->signal_connect (clicked => sub { $lasso->start; });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('End');
  $button->signal_connect (clicked => sub { $lasso->end; });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('Abort');
  $button->signal_connect (clicked => sub { $lasso->abort; });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('Swap');
  $button->signal_connect (clicked => sub { $lasso->swap_corners; });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('Redraw');
  $button->signal_connect (clicked => sub { $area->queue_draw; });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('Delayed Unmap');
  $button->set_tooltip_markup
    ("Click to unmap the DrawingArea widget after a delay of 2 seconds (use this to exercise grab_broken handling)");
  $button->signal_connect (clicked => sub {
                             Glib::Timeout->add (2000, # milliseconds
                                                 sub {
                                                   $area->unmap;
                                                   return 0; # Glib::SOURCE_REMOVE
                                                 });
                           });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $button = Gtk2::Button->new_with_label ('Delayed Iconify');
  $button->set_tooltip_markup
    ("Click to iconify the program after a delay of 2 seconds (use this to exercise grab_broken handling)");
  $button->signal_connect (clicked => sub {
                             Glib::Timeout->add (2000, # milliseconds
                                                 sub {
                                                   $toplevel->iconify;
                                                   return 0; # Glib::SOURCE_REMOVE
                                                 });
                           });
  $vbox->pack_start ($button, 0, 0, 0);
}
{
  my $combobox = Gtk2::ComboBox->new_text;
  $vbox->pack_start ($combobox, 0,0,0);
  $combobox->append_text ('hand1');
  $combobox->append_text ('invisible');
  $combobox->append_text ('undef');
  $combobox->append_text ('boat');
  $combobox->append_text ('umbrella');
  $combobox->append_text ('cross');
  $combobox->set_active (0);

  $combobox->signal_connect
    (changed => sub {
       my $type = $combobox->get_active_text;
       if ($type eq 'undef') { $type = undef; }
       $lasso->set (cursor => $type);
     });
  $lasso->signal_connect ('notify::cursor' => sub {
                            my $cursor = $lasso->get ('cursor');
                            print "$progname: lasso cursor '$cursor'\n";
                          });
}
{
  my $timer_id;
  my $idx = 0;
  my @widths = (500, 450, 400, 450);
  my $button = Gtk2::CheckButton->new_with_label ('Resizing');
  $button->set_tooltip_markup
    ("Check this to resize the DrawingArea under a timer, to test lasso recalc when some of it goes outside the new size");
  $vbox->pack_start ($button, 0,0,0);
  $button->signal_connect ('toggled' => sub {
                             if ($button->get_active) {
                               $timer_id ||= do {
                                 print "$progname: resizing start\n";
                                 Glib::Timeout->add (1000, \&resizing_timer);
                               };
                             } else {
                               if ($timer_id) {
                                 print "$progname: resizing stop\n";
                                 Glib::Source->remove ($timer_id);
                                 $timer_id = undef;
                               }
                             }
                           });
  sub resizing_timer {
    $idx++;
    if ($idx >= @widths) {
      $idx = 0;
    }
    my $width = $widths[$idx];
    print "$progname: resize to $width,$area_height\n";
    $area->set_size_request ($width, $area_height);
    return 1; # Glib::SOURCE_CONTINUE
  }
}
{
  my $timer_id;
  my $idx = 0;
  my @x = (0, 50, 100, 50);
  my $button = Gtk2::CheckButton->new_with_label ('Repositioning');
  $button->set_tooltip_markup
    ("Check this to resize the DrawingArea under a timer, to test lasso recalc when some of it goes outside the new size");
  $vbox->pack_start ($button, 0,0,0);
  $button->signal_connect ('toggled' => sub {
                             if ($button->get_active) {
                               $timer_id ||= do {
                                 print "$progname: repositioning start\n";
                                 Glib::Timeout->add (1000, \&repositioning_timer);
                               };
                             } else {
                               if ($timer_id) {
                                 print "$progname: repositioning stop\n";
                                 Glib::Source->remove ($timer_id);
                                 $timer_id = undef;



( run in 1.910 second using v1.01-cache-2.11-cpan-8dfa8b56332 )