use Reaction::Class;
# declaring dependencies
-
use Reaction::UI::LayoutSet;
use Reaction::UI::RenderingContext;
return $class->new(%{$args||{}}, app => $app);
};
+ sub BUILD{
+ my $self = shift;
+ my $skin_name = $self->skin_name;
+ #XXX i guess we will add the path to installed reaction templates here
+ my $skin_path = $self->app->path_to('share','skin',$skin_name);
+ confess("'${skin_path}' is not a valid path for skin '${skin_name}'")
+ unless -d $skin_path;
+ }
+
implements 'render_window' => as {
my ($self, $window) = @_;
my $root_vp = $window->focus_stack->vp_head;
implements 'widget_class_for' => as {
my ($self, $layout_set) = @_;
- my $base = ref($self);
+ my $base = $self->blessed;
my $tail = $layout_set->widget_type;
- my $class = join('::', $base, 'Widget', $tail);
- Class::MOP::load_class($class);
- return $class;
+ # eventually more stuff will go here i guess?
+ my $app_name = ref $self->app || $self->app;
+
+ my @search_path = ($base, $app_name, 'Reaction::UI');
+ my @haystack = map { join '::', $_, 'Widget', $tail } @search_path;
+ for my $class (@haystack){
+ eval { Class::MOP::load_class($class) };
+ $@ ? next : return $class;
+ }
+ confess "Couldn't load widget '$tail': tried: @haystack";
};
implements 'layout_set_for' => as {
my ($self, $vp) = @_;
+ #print STDERR "Getting layoutset for VP ".(ref($vp) || "SC:".$vp)."\n";
my $lset_name = eval { $vp->layout };
confess "Couldn't call layout method on \$vp arg ${vp}: $@" if $@;
unless (length($lset_name)) {
- my $last = (split('::',ref($vp)))[-1];
- $lset_name = join('_', map { lc($_) } split(/(?=[A-Z])/, $last));
+ my $vp_class = ref($vp) || $vp;
+ my ($last) = ($vp_class =~ /.*(?:::ViewPort::)(.+?)$/);
+ my @fragments = split('::', $last);
+ $_ = join("_", split(/(?=[A-Z])/, $_)) for @fragments;
+ $lset_name = lc(join('/', @fragments));
+ #print STDERR "--- $vp_class is rendered as $lset_name\n";
}
my $cache = $self->_layout_set_cache;
return $cache->{$lset_name} ||= $self->create_layout_set($lset_name);
implements 'find_related_class' => as {
my ($self, $rel) = @_;
- my $own_class = ref($self)||$self;
+ my $own_class = ref($self) || $self;
confess View." is abstract, you must subclass it" if $own_class eq View;
foreach my $super ($own_class->meta->class_precedence_list) {
next if $super eq View;