App-GUI-Juliagraph
view release on metacpan or search on metacpan
lib/App/GUI/Juliagraph/Frame/Tab/Color.pm view on Meta::CPAN
my $old_marker_state = ($self->{'current_color_nr'} < $self->{'active_color_count'}) ? 'passive' : 'disabled';
$self->{'color_marker'}[$self->{'current_color_nr'}]->set_state( $old_marker_state );
$self->{'color_marker'}[ $nr ]->set_state('active');
$self->{'current_color_nr'} = $nr;
$self->{'browser'}->set_data( $self->{'used_colors'}[$self->{'current_color_nr'}]->values(as => 'hash'), 'silent' );
}
sub init { $_[0]->set_settings( $default_settings ) }
sub set_settings {
my ($self, $settings) = @_;
return unless ref $settings eq 'HASH' and exists $settings->{'tilt'};
$self->{'widget'}{$_}->SetValue( $settings->{$_} // $default_settings->{$_} ) for qw/tilt delta_S delta_L/;
$self->set_all_colors( grep {defined $_} map {$settings->{$_}} 1 .. $self->{'color_count'} );
}
sub get_state { $_[0]->get_settings }
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->{'used_colors'}[$_-1]->values(as => 'hex_string') for 1 .. $self->{'color_count'};
$data;
}
sub get_current_color {
my ($self) = @_;
$self->{'used_colors'}[$self->{'current_color_nr'}];
}
sub set_current_color {
my ($self, $color) = @_;
return unless ref $color eq 'HASH';
$self->{'used_colors'}[$self->{'current_color_nr'}] = color( $color );
$self->{'color_display'}[$self->{'current_color_nr'}]->set_color( $color );
$self->{'browser'}->set_data( $color );
$self->{'call_back'}->( 'color' ); # update whole app
}
sub set_all_colors {
my ($self, @colors) = @_;
return unless @colors;
for my $i (0 .. $#colors){
my $temp = $colors[ $i ];
$colors[ $i ] = color( $temp ) if ref $temp ne 'Graphics::Toolkit::Color';
return "value number $i: $temp is no color" if ref $colors[ $i ] ne 'Graphics::Toolkit::Color';
}
$self->{'used_colors'} = [@colors];
$self->{'used_colors'}[$_] = color( $default_color_def ) for @colors .. $self->{'color_count'}-1;
$self->{'color_display'}[$_]->set_color( $self->{'used_colors'}[$_]->values(as => 'hash') ) for 0 .. $self->{'color_count'}-1;
$self->set_current_color_nr;
$self->{'call_back'}->( 'color' ); # update whole app
}
sub get_all_colors { @{$_[0]->{'used_colors'}} }
sub get_active_colors { @{$_[0]->{'used_colors'}}[ 0 .. $_[0]->{'active_color_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 0.797 second using v1.01-cache-2.11-cpan-39bf76dae61 )