Skip to content

Commit

Permalink
GUI Labels tab: Add a side menu for the tree
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Jan 4, 2024
1 parent 18cab44 commit a88fc21
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
71 changes: 71 additions & 0 deletions lib/Biodiverse/GUI/Tabs/Labels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ sub new {
$self->{menubar} = $self->get_xmlpage_object('menubarLabelsOptions');
$self->update_selection_menu;
$self->update_export_menu;
$self->update_tree_menu (output_ref => $self->get_base_ref->get_groups_ref);

say "[GUI] - Loaded tab - Labels";

Expand Down Expand Up @@ -326,6 +327,76 @@ sub init_dendrogram {
return 1;
}

sub get_tree_menu_items {
my $self = shift;

my @menu_items = (
{
type => 'Gtk2::MenuItem',
label => 'Tree controls',
tooltip => "Options to work with the displayed tree "
. "(this is the same as the one selected at "
. "the project level)",
},
{
type => 'submenu_radio_group',
label => 'Plot branches by',
items => [
{
type => 'Gtk2::RadioMenuItem',
label => 'Length',
event => 'activate',
callback => sub {
my $self = shift;
state $mode_string = 'length';
say "[Labels tab] Changing mode to $mode_string";
$self->{plot_mode} = $mode_string;
$self->{dendrogram}->set_plot_mode($mode_string);
},
},
{
type => 'Gtk2::RadioMenuItem',
label => 'Depth',
event => 'activate',
callback => sub {
my $self = shift;
state $mode_string = 'depth';
say "[Labels tab] Changing mode to $mode_string";
$self->{plot_mode} = $mode_string;
$self->{dendrogram}->set_plot_mode($mode_string);
},
},
],
},
{
type => 'Gtk2::SeparatorMenuItem',
},
{
type => 'Gtk2::MenuItem',
label => 'Set tree branch line widths',
tooltip => "Set the width of the tree branches.\n"
. "Does not affect the vertical connectors.",
event => 'activate',
callback => \&on_set_tree_line_widths,
},
{
type => 'Gtk2::SeparatorMenuItem',
},
{
type => 'Gtk2::MenuItem',
label => 'Export tree',
tooltip => 'Export the currently displayed tree',
event => 'activate',
callback => sub {
my $tree_ref = $self->{project}->get_selected_phylogeny;
return Biodiverse::GUI::Export::Run($tree_ref);
},
},
);

return wantarray ? @menu_items : \@menu_items;
}

##################################################
# Labels list
##################################################
Expand Down
6 changes: 3 additions & 3 deletions lib/Biodiverse/GUI/Tabs/Tab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1159,13 +1159,13 @@ sub update_display_list_combos {
}

sub update_tree_menu {
my ($self, $menu_items) = @_;
my ($self, %args) = @_;

my $menubar = $self->{menubar};
my $output_ref = $self->{output_ref};
my $output_ref = $args{output_ref} || $self->{output_ref};
return if !$output_ref;

$menu_items ||= $self->get_tree_menu_items;
my $menu_items = $args{menu_items} || $self->get_tree_menu_items;

my $tree_menu = $self->{tree_menu};

Expand Down

0 comments on commit a88fc21

Please sign in to comment.