From 1408055c1786a853d01cdf603de56bad1d95609e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Sep 2024 14:44:45 +0200 Subject: [PATCH] hilo mode with maximum one channel active --- src/js/models/panel_model.js | 17 ++++++++++++----- src/js/views/channel_slider_view.js | 10 +++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/js/models/panel_model.js b/src/js/models/panel_model.js index 75c3b92f3..847a29cf0 100644 --- a/src/js/models/panel_model.js +++ b/src/js/models/panel_model.js @@ -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 = [], @@ -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))); @@ -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) { diff --git a/src/js/views/channel_slider_view.js b/src/js/views/channel_slider_view.js index 057ba8c48..0d2c36685 100644 --- a/src/js/views/channel_slider_view.js +++ b/src/js/views/channel_slider_view.js @@ -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")){