App-GUI-Cellgraph
view release on metacpan or search on metacpan
lib/App/GUI/Cellgraph/Frame/Tab/Color.pm view on Meta::CPAN
$self->{'current_state'} = $state;
$self->{'browser'}->set_data( $self->{'state_colors'}[$self->{'current_state'}]->values(as => 'hash'), 'silent' );
}
sub init { $_[0]->set_settings( { 0 => '#FFFFFF', 1 => '#000000', tilt => 1, delta_S => 0, delta_L => 0 } ) }
sub get_settings {
my ($self) = @_;
my $data = {
tilt => $self->{'widget'}{'tilt'}->GetValue,
delta_S => $self->{'widget'}{'delta_S'}->GetValue,
delta_L => $self->{'widget'}{'delta_L'}->GetValue,
};
$data->{$_} = $self->{'state_colors'}[$_]->values(as => 'hex_string') for 0 .. $self->{'last_state'};
$data;
}
sub get_state {
my ($self) = @_;
my $data = $self-> get_settings;
$data->{'objects'} = $self->{'state_colors'};
$data;
}
sub set_settings {
my ($self, $data) = @_;
return unless ref $data eq 'HASH' and exists $data->{'tilt'};
$self->{'widget'}{$_}->SetValue( $data->{$_} ) for qw/tilt delta_S delta_L/;
$data->{$_} = $data->{$_} // $default_color_def for 0 .. $self->{'last_state'};
$self->{'state_colors'}[$_] = color( $data->{$_} ) for 0 .. $self->{'last_state'};
$self->set_all_colors( @{$self->{'state_colors'}} );
$self->{'objects'} = $self->{'state_colors'};
}
sub get_current_color {
my ($self) = @_;
$self->{'state_colors'}[$self->{'current_state'}];
}
sub set_current_color {
my ($self, $color) = @_;
return unless ref $color eq 'HASH';
$self->{'state_colors'}[$self->{'current_state'}] = color( $color );
$self->{'state_pic'}[$self->{'current_state'}]->set_color( $color );
$self->{'browser'}->set_data( $color );
$self->{'call_back'}->( 'color' ); # update whole app
}
sub set_all_colors {
my ($self, @color) = @_;
return unless @color;
map { return if ref $_ ne 'Graphics::Toolkit::Color' } @color;
$self->{'state_colors'}[$_] = $color[$_] for 0 .. $#color;
$self->{'state_pic'}[$_]->set_color( $self->{'state_colors'}[$_]->values(as => 'hash') ) for 0 .. $self->{'last_state'};
$self->select_state;
$self->{'call_back'}->( 'color' ); # update whole app
}
sub get_all_colors { @{$_[0]->{'state_colors'}} }
sub get_active_colors { @{$_[0]->{'state_colors'}}[ 0 .. $_[0]->{'state_count'} - 1] }
sub update_config {
my ($self) = @_;
$self->{'config'}->set_value('color', $self->{'picker'}->get_config);
$self->{'config'}->set_value('color_set', $self->{'setpicker'}->get_config);
}
1;
( run in 1.164 second using v1.01-cache-2.11-cpan-5735350b133 )