From 877df27341bd321a45c777a4eddf6d2bd12ee3f8 Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Sat, 1 Jun 2024 09:24:55 +1000 Subject: [PATCH] GUI spatial tab: add menu option for undef branch colour --- lib/Biodiverse/GUI/Tabs/Spatial.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/Biodiverse/GUI/Tabs/Spatial.pm b/lib/Biodiverse/GUI/Tabs/Spatial.pm index 07bf78f5e..100a81051 100644 --- a/lib/Biodiverse/GUI/Tabs/Spatial.pm +++ b/lib/Biodiverse/GUI/Tabs/Spatial.pm @@ -379,6 +379,13 @@ sub get_tree_menu_items { }, active => 0, }, + { + type => 'Gtk2::MenuItem', + label => 'Set colour for undefined list values', + tooltip => 'Set the colour used to display list values that are undefined.', + event => 'activate', + callback => \&on_tree_undef_colour_changed, + }, { type => 'submenu_radio_group', label => 'Colour mode', @@ -2641,6 +2648,29 @@ sub on_tree_colour_mode_changed { return; } +sub on_tree_undef_colour_changed { + my ($self, $menu_item) = @_; + + return if !$menu_item; + + # Pop up dialog for choosing the hue to use in saturation mode + my $colour_dialog = Gtk2::ColorSelectionDialog->new('Select colour'); + my $colour_select = $colour_dialog->get_color_selection(); + if (my $current_colour = $self->get_dendrogram_colour_for_undef) { + $colour_select->set_current_color ($current_colour); + } + $colour_dialog->show_all(); + my $response = $colour_dialog->run; + if ($response eq 'ok') { + my $hue = $colour_select->get_current_color(); + $self->set_dendrogram_colour_for_undef ($hue); + $self->{dendrogram}->update_legend; + } + $colour_dialog->destroy(); + + return; +} + # methods aren't inherited when called as GTK callbacks # so we have to manually inherit them using SUPER::