Commit 16fcb907 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

FIJISettingsViewer: improve LFSR polynomial usability

 - show maximum polynomial for current LFSR width in tooltip
 - set maximum polynomial when changing LFSR width
parent e3c9456d
......@@ -529,7 +529,7 @@ sub _populate_widget {
# let entries eat up all the remaining space
$config_frame->gridColumnconfigure(2, -weight => 1);
# add tooltip the config frame
# add tooltip to the config frame
if (defined DISPLAYGROUPS->{$displaygroup}->{'description'}) {
$balloon->attach(
$config_frame,
......@@ -541,6 +541,8 @@ sub _populate_widget {
# add matching widgets for all values in this displaygroup
foreach my $k (sort { DESIGNMAP->{$a}->{'order'} <=> DESIGNMAP->{$b}->{'order'} } @keys) {
my $tooltip;
# label
my $label = $config_frame->Label(
'-text' => DESIGNMAP->{$k}->{'description'},
......@@ -655,6 +657,12 @@ sub _populate_widget {
-column => 2,
'-sticky' => 'ew'
);
my $lfsr_width = $self->{'settings'}->{'design'}->{'LFSR_WIDTH'};
my $lpc = LFSR_POLY_CHOICES;
my $c = $lpc->{$lfsr_width};
my $tmp = FIUMAP->{'FIU_LFSR_MASK'}->{'help'} . " [" . FIUMAP->{'FIU_LFSR_MASK'}->{'ini_name'} . "]\nPossible maximum polynomials for a LFSR with a width of ".$lfsr_width.": " . join(",", @{$c});
$tooltip = \$tmp;
$entry->{'LFSR_tooltip'} = \$tmp;
} elsif (defined($type) && $type eq 'boolean') {
# checkbutton for values which can only be "enabled" or "disabled"
......@@ -743,7 +751,7 @@ sub _populate_widget {
# add tooltip for widget
if (defined DESIGNMAP->{$k}->{'help'}) {
my $tooltip = DESIGNMAP->{$k}->{'help'} . " [" . DESIGNMAP->{$k}->{'ini_name'} . "]";
$tooltip = DESIGNMAP->{$k}->{'help'} . " [" . DESIGNMAP->{$k}->{'ini_name'} . "]" if (!defined($tooltip));
$balloon->attach(
$entry,
-balloonposition => 'mouse',
......@@ -1700,17 +1708,25 @@ sub _validate_entry {
$$old_ref = $$new_ref;
}
# if we are validating the LFSR WIDTH widget, update the list of
# suggested polynomials
# if we are validating the LFSR WIDTH widget, set the polynomial to the first known maximum,
# update the list of suggestions and add them to the respective tooltip
if ($name eq 'LFSR_WIDTH') {
for my $depending_widget (grep { ref($_) eq "Tk::CompleteEntry" } @{$self->{'depends'}->{$name}}) {
# Fetch and change only the LFSR_POLY widget
for my $lfsr_poly_widget (grep { $_->{'key'} eq "LFSR_POLY" } @{$self->{'depends'}->{$name}}) {
my $lpc = LFSR_POLY_CHOICES;
my $c = $lpc->{$$new_ref};
if (defined $c) {
$depending_widget->configure(-choices => $c);
$lfsr_poly_widget->configure(-choices => $c);
${$lfsr_poly_widget->cget('-textvariable')} = @{$c}[0];
# Replace the previous tooltip pointed to by the reference stored in LFSR_tooltip with two regexes.
my $replacement_width = "width of ".$$new_ref;
${$lfsr_poly_widget->{'LFSR_tooltip'}} =~ s/width of [0-9]+/$replacement_width/;
my $replacement_poly = ": ".join(",", @{$c});
${$lfsr_poly_widget->{'LFSR_tooltip'}} =~ s/:.*/$replacement_poly/;
} else {
$logger->debug("No LFSR_POLY suggestion for LFSR_LENGTH $$new_ref");
$depending_widget->configure(-choices => []);
$logger->debug("No LFSR_POLY suggestion for LFSR_WIDTH $$new_ref");
$lfsr_poly_widget->configure(-choices => []);
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment