Added option to swap mouse wheen function between tuning and zooming.

This commit is contained in:
Marat Fayzullin 2023-06-03 11:58:58 -04:00
parent e01c3c19f0
commit 42cc4f37bf
4 changed files with 17 additions and 3 deletions

View File

@ -36,6 +36,7 @@ var tuning_step_default = 1;
var tuning_step = 1;
var nr_enabled = false;
var nr_threshold = 0;
var swap_wheel = false;
function updateVolume() {
audioEngine.setVolume(parseFloat($("#openwebrx-panel-volume").val()) / 100);
@ -430,8 +431,8 @@ function scale_canvas_mousewheel(evt) {
var demodulators = getDemodulators();
var event_handled = false;
for (var i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.wheel(evt.pageX, dir, adjustWidth);
// If not handled by demodulators, default to tuning
if (!event_handled) tuneBySteps(dir? -1:1);
// If not handled by demodulators, default to tuning or zooming
if (!event_handled) canvas_mousewheel(evt);
}
function scale_px_from_freq(f, range) {
@ -908,7 +909,10 @@ function canvas_mousewheel(evt) {
var dir = (evt.deltaY / Math.abs(evt.deltaY)) > 0;
// Zoom when mouse button down, tune otherwise
if ((canvas_mouse2_down > 0) || evt.shiftKey) {
// (optionally, invert this behavior)
var zoom_me = (canvas_mouse2_down > 0) || evt.shiftKey?
!swap_wheel : swap_wheel;
if (zoom_me) {
zoom_step(dir, relativeX, zoom_center_where_calc(evt.pageX));
} else {
tuneBySteps(dir? -1:1);
@ -1092,6 +1096,10 @@ function on_ws_recv(evt) {
$('#openwebrx-panel-receiver').css('border', x? '2px solid':'');
}
if ('ui_swap_wheel' in config) {
swap_wheel = config['ui_swap_wheel'];
}
if ('allow_audio_recording' in config) {
var x = config['allow_audio_recording'];
$('.openwebrx-record-button').css('display', x? '':'none');

View File

@ -157,6 +157,7 @@ defaultConfig = PropertyLayer(
waterfall_auto_min_range=50,
ui_opacity=100,
ui_frame=False,
ui_swap_wheel=False,
magic_key="memagic",
allow_center_freq_changes=False,
allow_audio_recording=True,

View File

@ -139,6 +139,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
"tuning_precision",
"ui_opacity",
"ui_frame",
"ui_swap_wheel",
"allow_center_freq_changes",
"allow_audio_recording",
"magic_key",

View File

@ -194,6 +194,10 @@ class GeneralSettingsController(SettingsFormController):
"ui_frame",
"Show frame around receiver panel",
),
CheckboxInput(
"ui_swap_wheel",
"Make mouse wheel control zoom, tune by holding wheel down",
),
DropdownInput(
"tuning_precision",
"Tuning precision",