App-mirai
view release on metacpan or search on metacpan
lib/App/mirai/Tickit.pm view on Meta::CPAN
Opens a panel with details of the given L<Future>.
=cut
sub future_details {
my $f = shift;
my $elapsed = sprintf '%.3f', $f->elapsed // 0;
add_widgets {
vbox {
gridbox {
gridrow {
static 'Type';
static $f->type;
};
gridrow {
static 'Status';
static $f->status;
};
gridrow {
static 'Label';
static $f->label;
};
gridrow {
static 'Elapsed';
static $elapsed . 's';
};
gridrow {
static 'Created at';
static $f->created_at;
};
gridrow {
static 'Ready at';
static $f->ready_at;
};
};
hbox {
tree {
} data => [ Deps => [qw(x y z)] ],
'parent:expand' => 1
if $f->type ne 'leaf';
vbox {
static 'Creation stack', align => 0.5;
stack_table($f->creator_stack);
} 'parent:expand' => 1;
vbox {
static 'Marked ready stack', align => 0.5;
stack_table($f->ready_stack);
} 'parent:expand' => 1;
} 'parent:expand' => 1;
} style => { spacing => 1 },
'parent:label' => $f->label . ' (' . $f->status . ', ' . $elapsed . 's)',
'parent:top' => 3,
'parent:left' => 3,
'parent:lines' => 12;
} under => $widget{desktop}
}
=head2 app_about
Shows the C< About > dialog popup.
=cut
sub app_about {
my $vbox = shift;
my ($tw, $th) = map $vbox->window->$_, qw(cols lines);
my ($w, $h) = (34, 18);
float {
my $f = shift;
frame {
vbox {
customwidget {
App::mirai::Tickit::Widget::Logo->new
};
static 'A tool for debugging Futures', align => 0.5, 'parent:expand' => 1;
hbox {
static ' ', 'parent:expand' => 1;
button {
$f->remove;
} 'OK';
static ' ', 'parent:expand' => 1;
};
} style => { spacing => 1 };
} title => 'æªæ¥',
style => {
linetype => 'single'
}
} top => int(($th-$h)/2),
left => int(($tw-$w)/2),
right => int($tw - ($tw-$w)/2),
bottom => int($th - ($th-$h)/2);
}
sub session_path { $_[0]->user_path('last_session') }
=head2 app_menu
Populates menu items.
=cut
sub app_menu {
my ($self) = @_;
menubar {
submenu File => sub {
menuitem 'Open session' => sub { warn 'open' };
menuitem 'Save session' => sub {
my $sp = $self->session_path;
unlink $sp if -l $sp;
my $session = { };
my @win = @{$widget{desktop}->{widgets}};
for my $widget (@win) {
my $label = $widget->label;
$session->{$label} = {
geometry => [
map {;
$widget->window->rect->$_
} qw(top left lines cols)
]
};
( run in 2.787 seconds using v1.01-cache-2.11-cpan-364913b4093 )