Skip to content

Commit

Permalink
Add capacity to reset branch colours under multi-select
Browse files Browse the repository at this point in the history
Uses a toggle button to do so.

Updates #600
  • Loading branch information
shawnlaffan committed Sep 6, 2016
1 parent d03e1ac commit d9027f2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
16 changes: 15 additions & 1 deletion bin/ui/hboxClusteringPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ for RegionGrower analyses. </property>
<object class="GtkToolbar" id="toolbar_clustering_bottom">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="toolbar_style">both</property>
<property name="toolbar_style">icons</property>
<child>
<object class="GtkToolItem" id="toolitem1">
<property name="visible">True</property>
Expand Down Expand Up @@ -1526,6 +1526,20 @@ This setting has no effect on the slider bar.</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToggleToolButton" id="selector_toggle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">When selected, clicking on
a branch will reset it to uncoloured.</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-clear</property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand Down
34 changes: 22 additions & 12 deletions lib/Biodiverse/GUI/Dendrogram.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ sub new {
$self->{sp_index} = undef;
bless $self, $class;

foreach my $widget_name (qw /selector_toggle selector_colorbutton/) {
eval {
$self->{$widget_name}
= $self->{parent_tab}->{xmlPage}->get_object($widget_name);
};
}

# also initialises it
$self->increment_sequential_selection_colour(1);

Expand Down Expand Up @@ -886,7 +893,8 @@ sub recolour_cluster_elements {

return if !$cluster_node;

return $colour_for_sequential || COLOUR_PALETTE_OVERFLOW;
return $colour_for_sequential || COLOUR_OUTSIDE_SELECTION;
#COLOUR_PALETTE_OVERFLOW;
};
}
elsif ($cluster_colour_mode eq 'list-values') {
Expand Down Expand Up @@ -932,22 +940,27 @@ sub recolour_cluster_elements {

sub get_current_sequential_colour {
my $self = shift;

my $widget_name = 'selector_colorbutton';

my $colour;
eval {
my $widget = $self->{parent_tab}->{xmlPage}->get_object($widget_name);
$colour = $widget->get_color;
$colour = !$self->{selector_toggle}->get_active
? $self->{selector_colorbutton}->get_color
: undef;
};
#croak $@ if $@;

return $colour;
}

sub increment_sequential_selection_colour {
my $self = shift;
my $force_increment = shift;

return if !$force_increment && $self->{cluster_colour_mode} ne 'sequential';
return if !$force_increment
&& $self->{cluster_colour_mode} ne 'sequential';

return
if $self->{selector_toggle}
&& $self->{selector_toggle}->get_active;

my $colour = $self->get_current_sequential_colour;

Expand All @@ -963,12 +976,9 @@ sub increment_sequential_selection_colour {
$colour = $colours[0];
}

my $widget_name = 'selector_colorbutton';
eval {
my $widget = $self->{parent_tab}->{xmlPage}->get_object($widget_name);
$widget->set_color ($colour);
$self->{selector_colorbutton}->set_color ($colour);
};
#croak $@ if $@;

$self->{last_sequential_colour} = $colour;

Expand Down Expand Up @@ -1007,7 +1017,7 @@ sub recolour_cluster_lines {
$colour_ref = $self->{node_palette_colours}{$node_name} || COLOUR_RED;
}
elsif ($colour_mode eq 'sequential') {
$colour_ref = $self->get_current_sequential_colour || COLOUR_RED;
$colour_ref = $self->get_current_sequential_colour || COLOUR_BLACK;
}
elsif ($colour_mode eq 'list-values') {

Expand Down
2 changes: 1 addition & 1 deletion lib/Biodiverse/GUI/Tabs/Clustering.pm
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ sub on_combo_map_list_changed {

# show/hide some widgets
my @cluster_widgets = qw /label_cluster_spin_button spinClusters/;
my @cloister_widgets = qw /label_selector_colour selector_colorbutton/;
my @cloister_widgets = qw /label_selector_colour selector_colorbutton selector_toggle/;
my $m1 = $list eq '<i>Cloister</i>' ? 'hide' : 'show';
my $m2 = $list eq '<i>Cloister</i>' ? 'show' : 'hide';
foreach my $widget_name (@cluster_widgets) {
Expand Down

0 comments on commit d9027f2

Please sign in to comment.