Alt-Tickit-Widgets-ObjectPad
view release on metacpan or search on metacpan
lib/Tickit/Style.pm view on Meta::CPAN
my $str = do { local $/; <$fh> };
_load_style( Tickit::Style::Parser->new->from_string( $str ) );
}
=head2 on_style_load
Tickit::Style::on_style_load( \&code )
Adds a CODE reference to be invoked after either C<load_style> or
C<load_style_file> are called. This may be useful to flush any caches or
invalidate any state that depends on style information.
=cut
sub on_style_load
{
my ( $code ) = @_;
push @ON_STYLE_LOAD, $code;
}
package # hide from indexer
lib/Tickit/Widget.pm view on Meta::CPAN
$widget->set_style( %defs )
Changes the widget's direct-applied style.
C<%defs> should contain style keys optionally suffixed with tags in the same
form as that given to the C<style> key to the constructor. Defined values will
add to or replace values already stored by the widget. Keys mapping to
C<undef> are deleted from the stored style.
Note that changing the direct applied style is moderately costly because it
must invalidate all of the cached style values and pens that depend on the
changed keys. For normal runtime changes of style, consider using a tag if
possible, because style caching takes tags into account, and simply changing
applied style tags does not invalidate the caches.
=cut
sub set_style
{
my $self = shift;
my %defs = @_;
my $new = Tickit::Style::_Tagset->new;
$new->add( $_, $defs{$_} ) for keys %defs;
lib/Tickit/Widget.pm view on Meta::CPAN
else {
$self->{style_direct} = $new;
}
$self->_style_changed_values( \%values, 1 );
}
sub _style_changed_values
{
my $self = shift;
my ( $values, $invalidate_caches ) = @_;
my @keys = keys %$values;
if( $invalidate_caches ) {
foreach my $keyset ( values %{ $self->{style_cache} } ) {
delete $keyset->{$_} for @keys;
}
}
my @new_values = $self->get_style_values( @keys );
# Remove unchanged keys
foreach ( 0 .. $#keys ) {
my $key = $keys[$_];
lib/Tickit/Widget.pm view on Meta::CPAN
my %changed_pens;
foreach my $key ( @keys ) {
PEN_ATTR_MAP->{$key} and
$changed_pens{""}++;
$key =~ m/^(.*)_([^_]+)$/ && PEN_ATTR_MAP->{$2} and
$changed_pens{$1}++;
}
if( $invalidate_caches ) {
foreach my $penset ( values %{ $self->{style_pen_cache} } ) {
delete $penset->{$_} for keys %changed_pens;
}
}
if( $changed_pens{""} ) {
$self->_update_pen( $self->get_style_pen );
}
my $reshape = 0;
( run in 1.262 second using v1.01-cache-2.11-cpan-a5abf4f5562 )