X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FMod%2FLayer.pm;h=1b915b98f4ee107a88c3638bed7ac96440da9a0c;hb=4f696c03a66ef6b52ee7b9b3c74a71d5abc64f7e;hp=6b3f73de0967e2e2e5149632370ac5832fb40b06;hpb=5adf00c880491bac3bd793a07431cf161c03643f;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Mod/Layer.pm b/lib/LaTeX/TikZ/Mod/Layer.pm index 6b3f73d..1b915b9 100644 --- a/lib/LaTeX/TikZ/Mod/Layer.pm +++ b/lib/LaTeX/TikZ/Mod/Layer.pm @@ -9,27 +9,46 @@ LaTeX::TikZ::Mod::Layer - A modifier that specifies a drawing layer. =head1 VERSION -Version 0.01 +Version 0.03 =cut -our $VERSION = '0.01'; +our $VERSION = '0.03'; -use List::Util (); +use Scalar::Util (); +use List::Util (); use LaTeX::TikZ::Mod::Formatted; -use Any::Moose; -use Any::Moose 'Util::TypeConstraints'; +use LaTeX::TikZ::Interface; + +use Mouse; +use Mouse::Util::TypeConstraints; + +=head1 RELATIONSHIPS + +This class consumes the L role, and as such implements the L, L, L and L methods. + +=cut with 'LaTeX::TikZ::Mod'; +=head1 ATTRIBUTES + +=head2 C + +=cut + has 'name' => ( is => 'ro', isa => 'Str', required => 1, ); +=head2 C + +=cut + subtype 'LaTeX::TikZ::Mod::LevelList' => as 'ArrayRef[LaTeX::TikZ::Mod::Layer]'; @@ -51,6 +70,10 @@ has '_above' => ( sub above { @{$_[0]->_above} } +=head2 C + +=cut + has '_below' => ( is => 'ro', isa => 'LaTeX::TikZ::Mod::LevelList', @@ -69,6 +92,10 @@ has '_score' => ( builder => '_build_score', ); +=head1 METHODS + +=cut + my %layers; around 'new' => sub { @@ -91,7 +118,9 @@ around 'new' => sub { sub BUILD { my ($self) = @_; - $layers{$self->name} = $self; + my $name = $self->name; + $layers{$name} = $self; + Scalar::Util::weaken($layers{$name}); } sub DEMOLISH { @@ -100,13 +129,25 @@ sub DEMOLISH { delete $layers{$self->name}; } +=head2 C + +=cut + sub tag { my ($self) = @_; ref($self) . '/' . $self->name; } -sub cover { $_[0]->name eq $_[1]->name } +=head2 C + +=cut + +sub covers { $_[0]->name eq $_[1]->name } + +=head2 C + +=cut { our %score; @@ -157,6 +198,10 @@ sub cover { $_[0]->name eq $_[1]->name } $score{$name} } +=head2 C + +=cut + sub declare { shift; @@ -181,6 +226,10 @@ sub cover { $_[0]->name eq $_[1]->name } } } +=head2 C + +=cut + sub apply { my ($self) = @_; @@ -190,17 +239,23 @@ sub apply { ) } -use LaTeX::TikZ::Interface layer => sub { - shift; +LaTeX::TikZ::Interface->register( + layer => sub { + shift; - my $name = shift; - __PACKAGE__->new(name => $name, @_); -}; + my $name = shift; + __PACKAGE__->new(name => $name, @_); + }, +); __PACKAGE__->meta->make_immutable( inline_constructor => 0, ); +=head1 SEE ALSO + +L, L. + =head1 AUTHOR Vincent Pit, C<< >>, L. @@ -220,7 +275,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2010 Vincent Pit, all rights reserved. +Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.