Skip to content

Commit

Permalink
hilo mode with maximum one channel active
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-TBT committed Sep 11, 2024
1 parent b477928 commit 1408055
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
// labels_map is {labelKey: {size:s, text:t, position:p, color:c}} or {labelKey: false} to delete
// where labelKey specifies the label to edit. "l.text + '_' + l.size + '_' + l.color + '_' + l.position"
edit_labels: function(labels_map) {

var oldLabs = this.get('labels');
// Need to clone the list of labels...
var labs = [],
Expand All @@ -483,7 +483,7 @@
// Extract all the keys (even duplicates)
var keys = labs.map(lbl => this.get_label_key(lbl));

// get all unique labels based on filtering keys
// get all unique labels based on filtering keys
//(i.e removing duplicate keys based on the index of the first occurrence of the value)
var filtered_lbls = labs.filter((lbl, index) => index == keys.indexOf(this.get_label_key(lbl)));

Expand Down Expand Up @@ -515,12 +515,19 @@
this.save('channels', chs);
},

toggle_channel: function(cIndex, active ) {

toggle_channel: function(cIndex, active) {
if (typeof active == "undefined") {
active = !this.get('channels')[cIndex].active;
}
this.save_channel(cIndex, 'active', active);

if (this.get("hilo_enabled") && active) {
let newChs = this.get('channels').map(function(channel, idx) {
return {'active': idx == cIndex};
});
this.save_channels(newChs);
} else {
this.save_channel(cIndex, 'active', active);
}
},

save_channel_window: function(cIndex, new_w) {
Expand Down
10 changes: 9 additions & 1 deletion src/js/views/channel_slider_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,16 @@ var ChannelSliderView = Backbone.View.extend({
return channel.color;
})
});
let foundActive = false;
let newChs = m.get('channels').map(function(channel, idx) {
return {'color': 'hilo.lut'};
// Switch LUT to HiLo for all channels
// Keep only the first active channel active
let new_state = {
'color': 'hilo.lut',
'active': (!foundActive && channel.active)
}
foundActive = (foundActive || channel.active);
return new_state;
});
m.save_channels(newChs);
} else if (!checkboxState && m.get("hilo_enabled")){
Expand Down

0 comments on commit 1408055

Please sign in to comment.