Commit f47e41d4 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

fiji_scripts: add first try to delete FIU elements in fiji_setup.pl

parent 9361b986
......@@ -52,6 +52,67 @@ sub Populate {
$self->update();
}
## @method update()
# @brief redraws the widget on fundamental changes
#
sub update {
my $self = shift;
################
# design panel #
################
# TODO
##############
# FIUs panel #
##############
my $parent = $fr_fius->parent();
$parent->packForget(); # This and the next line would be redundant if
$fr_fius->destroy(); # the $parent->destroy() call would work.
$self->_add_fiu_frame($parent->parent());
# The code line below creates a segfault. It should delete all children
# of the parent frame of fr_fius.
# $parent->destroy();
# FIXME: Without this we have an obvious memory leak
# An alternative solution is apparently to start destroying higher up
# in the stack. This does not cause a segfault (but some more flickering).
# fr_fius<-frame <-pane <-frame <-frame1 <-border <-labframe1<-self
# my $parent = $fr_fius->parent()->parent()->parent()->parent()->parent()->parent();
# $self->_add_fiu_panel($parent->parent());
# $parent->destroy();
$fr_fius->gridColumnconfigure(1, -weight => 1);
my $i = 1;
my $hdr_row = 0;
foreach my $hdr ("Net Name", "Fault Model", "En. by LFSR", "En. Mask", "LFSR bit for s-o") {
$fr_fius->Label(
-text => $hdr,
)->grid(
'-row' => $hdr_row,
'-column' => $i++,
);
}
$fr_fius->Label(
-text => "Control",
)->grid(
'-row' => $hdr_row,
'-column' => $i++,
'-columnspan' => 2,
);
my $fiu_cnt = _fiu_cnt();
for (my $i = 0; $i < $fiu_cnt; $i++) {
my $fiu = @{${$self->{'settings'}}->{'FIUs'}}[$i];
_add_fiu($fiu, $i);
}
}
## @method _populate_widget()
# Creates, aranges and binds all widgets
......@@ -59,7 +120,6 @@ sub Populate {
sub _populate_widget {
my $logger = get_logger();
my ($self, $fr) = @_;
my $i;
$fr->DynaMouseWheelBind('Tk::Pane');
################
......@@ -75,7 +135,7 @@ sub _populate_widget {
);
$fr_design->gridColumnconfigure(2, -weight => 1);
$i = 0;
my $i = 0;
foreach my $hdr (qw(Name Unit Value)) {
$fr_design->Label(
-text => $hdr,
......@@ -121,7 +181,14 @@ sub _populate_widget {
##############
# FIUs panel #
##############
$self->_add_fiu_panel($fr);
}
sub _add_fiu_panel {
my($self, $fr) = @_;
my $fr_fius_main = $fr->LabFrame(
# -name => "LabFrame",
-label => "FIUs",
-labelside => "acrosstop"
)->pack(
......@@ -151,46 +218,16 @@ sub _populate_widget {
'-anchor' => 'nw',
'-side' => 'top',
);
$self->_add_fiu_frame($fr_fius_scroll);
}
$fr_fius = $fr_fius_scroll->Frame()->pack(
'-fill' => 'both',
'-side' => 'top',
'-anchor' => 'nw',
);
# Add an expanding dummy frame below the actual gridded frame with
# the FIUs to push the latter up if there are not enough FIUs added
# to use the whole space (FIXME: feels hackish... alternatives?)
$fr_fius_scroll->Frame()->pack(
'-expand' => 1,
sub _add_fiu_frame {
my($self, $parent) = @_;
$fr_fius = $parent->Frame()->pack(
'-fill' => 'both',
'-side' => 'top',
'-anchor' => 'nw',
);
$i = 1;
my $hdr_row = 0;
foreach my $hdr ("Net Name", "Fault Model", "En. by LFSR", "En. Mask", "LFSR bit for s-o") {
$fr_fius->Label(
-text => $hdr,
)->grid(
'-row' => $hdr_row,
'-column' => $i++,
);
}
$fr_fius->Label(
-text => "Control",
)->grid(
'-row' => $hdr_row,
'-column' => $i++,
'-columnspan' => 2,
);
$fr_fius->gridColumnconfigure(1, -weight => 1);
my $fiu_cnt = _fiu_cnt();
for (my $i = 0; $i < $fiu_cnt; $i++) {
my $fiu = @{${$self->{'settings'}}->{'FIUs'}}[$i];
_add_fiu($fiu, $i);
}
}
......@@ -241,7 +278,7 @@ sub _add_fiu ($$) {
'-justify' => 'center',
),
$fr_fius->Button(
-text => 'Defaults',
'-text' => 'Defaults',
# -command => [\&_save, $self],
# sub {
# my $state = defined($filename) ? 'normal' : 'disabled';
......@@ -251,12 +288,13 @@ sub _add_fiu ($$) {
),
$fr_fius->Button(
-text => 'Delete',
# -command => [\&_save, $self],
# sub {
-command => sub {
# my $state = defined($filename) ? 'normal' : 'disabled';
# $btn_open->configure(-state => $state);
# $btn_save->configure(-state => $state);
# },
splice(${$self->{'settings'}}->{'FIUs'}, $i, 1);
$self->update();
},
),
'-sticky' => 'ew'
);
......
......@@ -43,17 +43,6 @@ sub main {
my $mw = MainWindow->new(
-title => 'FIJI Settings Editor'
);
$mw->bind(
'<Destroy>'=> [
sub {
my $self = shift;
$self->detach();
},
$mw
]
);
$self->{'mw'} = $mw;
_ctrl_frame($self, $mw);
......
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