App-GUI-Juliagraph

 view release on metacpan or  search on metacpan

lib/App/GUI/Juliagraph/Frame/Tab/Mapping.pm  view on Meta::CPAN

        next unless exists $settings->{$key} and exists $settings->{$key};
        $self->{$key}->SetValue( $settings->{$key} );
    }
    for my $key (qw/scale_distro background_color begin_color end_color gradient_dynamic
                gradient_space subgradient_dynamic subgradient_space subgradient_distro/){
        next unless exists $settings->{$key} and exists $self->{$key};
        $self->{$key}->SetSelection( $self->{$key}->FindString($settings->{$key}) );
    }
    $self->enable_partition( $settings->{'custom_partition'} );
    $self->enable_user_colors( $settings->{'user_colors'} );
    $self->enable_subgradient( $settings->{'use_subgradient'} );
    $self->update_max_color( );
    $self->RestoreCallBack();
    1;
}

sub get_settings {
    my ( $self ) = @_;
    return {
        custom_partition  => int $self->{'custom_partition'}->GetValue,
        user_colors       => int $self->{'user_colors'}->GetValue,
        use_subgradient   => int $self->{'use_subgradient'}->GetValue,
        scale_steps       => $self->{'scale_steps'}->GetValue,
        scale_distro      => $self->{'scale_distro'}->GetStringSelection,
        background_color  => $self->{'background_color'}->GetStringSelection,
        begin_color       => $self->{'begin_color'}->GetStringSelection,
        end_color         => $self->{'end_color'}->GetStringSelection,
        gradient_dynamic  => $self->{'gradient_dynamic'}->GetStringSelection,
        gradient_space    => $self->{'gradient_space'}->GetStringSelection,
        subgradient_size  => $self->{'subgradient_size'}->GetValue,
        subgradient_steps => $self->{'subgradient_steps'}->GetValue,
        subgradient_dynamic=>$self->{'subgradient_dynamic'}->GetStringSelection,
        subgradient_space => $self->{'subgradient_space'}->GetStringSelection,
        subgradient_distro => $self->{'subgradient_distro'}->GetStringSelection,
    };
}

sub enable_partition {
    my ( $self, $on ) = @_;
    $on //= $self->{'custom_partition'}->GetValue;
    $self->{'custom_partition'}->SetValue( $on ) unless int($on) == int $self->{'custom_partition'}->GetValue;
    $self->{$_}->Enable( $on ) for qw/scale_steps scale_distro scale_max lbl_max lbl_distro/;
    $self->enable_subgradient(0) if $on;
    $self->{'use_subgradient'}->Enable( not $on );
    $self->{'lbl_sub_use'}->Enable( not $on );
}
sub enable_user_colors {
    my ( $self, $on ) = @_;
    $on //= $self->{'user_colors'}->GetValue;
    $self->{'user_colors'}->SetValue( $on ) unless int($on) ==  int $self->{'user_colors'}->GetValue;
    $self->{ $_ }->Enable( $on ) for qw/background_color begin_color end_color lbl_begin lbl_end lbl_backg/;
}
sub enable_subgradient {
    my ( $self, $on ) = @_;
    $on //= $self->{'use_subgradient'}->GetValue;
    $self->{'use_subgradient'}->SetValue($on) unless int($on) == int $self->{'use_subgradient'}->GetValue;
    $self->{$_}->Enable( $on ) for qw/subgradient_steps subgradient_dynamic subgradient_space subgradient_distro
                                    lbl_sub_dyn lbl_sub_space lbl_sub_distro subgradient_size/;
}

sub update_max_color {
    my ( $self ) = @_;
    my $begin_color = substr $self->{'begin_color'}->GetStringSelection, 6;
    my $end_color = substr $self->{'end_color'}->GetStringSelection, 6;
    my $max_color = $begin_color > $end_color ? $begin_color : $end_color;
    $self->{'tab'}{'color'}->set_active_color_count( $max_color ) if ref $self->{'tab'}{'color'};
}

sub connect_color_tab {
    my ($self, $ref) = @_;
    return unless ref $ref eq 'App::GUI::Juliagraph::Frame::Tab::Color';
    $self->{'tab'}{'color'} = $ref;
    $self->update_max_color;
}

sub SetCallBack {
    my ($self, $code) = @_;
    return unless ref $code eq 'CODE';
    $self->{'callback'} = $code;
}
sub PauseCallBack {
    my ($self) = @_;
    $self->{'pause'} = $self->{'callback'};
    $self->{'callback'} = sub {};
}
sub RestoreCallBack {
    my ($self) = @_;
    return unless exists $self->{'pause'};
    $self->{'callback'} = $self->{'pause'};
    delete $self->{'pause'};
}


1;



( run in 1.408 second using v1.01-cache-2.11-cpan-39bf76dae61 )