NAME

Term::Fabulous::Role::HasRange - A widget whose range comes from a layout in one piece

SYNOPSIS

use Object::Pad 0.825;

class My::Dial :isa(Term::Fabulous::Widget::Display) :does(Term::Fabulous::Role::HasRange) :strict(params) {
	field $range;    # a Term::Fabulous::Range

	method range_properties :common () { return qw(min max step) }

	method set_range (%range) {
		$range->set_range(%range);
		$self->mark_changed;
		return $self;
	}
}

DESCRIPTION

The widgets that pick a value from a Term::Fabulous::Range (Term::Fabulous::Widget::Slider, Term::Fabulous::Widget::StarRating, Term::Fabulous::Widget::ProgressBar) compose this role, so that a KDL layout may give the parts of their range in any order: the parts are collected and handed to set_range in one call, before the other properties (the value among them) are applied. A range is checked as a whole, so min 300; max 400; works on a widget whose range was 0..100, which applying min alone could not.

REQUIRED METHODS

range_properties

method range_properties :common () { return qw(min max step) }

A class method: the names of the layout properties that make the range. Each must also be a layout property of the class (see "layout_properties" in Term::Fabulous::Role::CanParseLayout).

set_range

method set_range (%range) { ... }

Changes the range parts given, checked as a whole. Called with the range properties the layout gave, by their names.

METHODS

apply_layout_settings

Applies the range properties with "set_range" in one call, then the other settings as Term::Fabulous::Role::CanParseLayout does.

SEE ALSO

Term::Fabulous::Range, Term::Fabulous::Manual::KDL.