Added checkboxes for frame and wheel swap control.

This commit is contained in:
Marat Fayzullin 2023-11-05 23:51:41 -05:00
parent 9b32d1bbd3
commit 73021a4682
6 changed files with 31 additions and 26 deletions

View File

@ -262,10 +262,10 @@
<div class="openwebrx-section-divider" onclick="toggleSection(this);">&blacktriangle;&nbsp;Settings</div>
<div class="openwebrx-section" style="display: none;">
<div class="openwebrx-panel-line">
<div title="Theme" class="openwebrx-button openwebrx-slider-button" onclick="UI.setTheme('default');">
<div title="Reset theme" class="openwebrx-button openwebrx-slider-button" onclick="UI.setTheme('default');">
<svg viewBox="56 -900 835 835" style="overflow: visible"><use xlink:href="static/gfx/svg-defs.svg#theme-chooser"></use></svg>
</div>
<select id="openwebrx-themes-listbox" class="openwebrx-panel-listbox" onchange="UI.setTheme(this.value);">
<select title="Theme" id="openwebrx-themes-listbox" class="openwebrx-panel-listbox" onchange="UI.setTheme(this.value);">
<option value="default">Default</option>
<option value="brown">Brown</option>
<option value="red">Red</option>
@ -276,11 +276,21 @@
<option value="black">Black</option>
<option value="night">Night</option>
</select>
<div title="Reset opacity (right-click to toggle frame)" id="openwebrx-opacity-reset" class="openwebrx-button openwebrx-slider-button" onclick="UI.setOpacity(100);">
<div title="Reset opacity" id="openwebrx-opacity-reset" class="openwebrx-button openwebrx-slider-button" onclick="UI.setOpacity(100);">
<svg viewBox="56 -900 835 835"><use xlink:href="static/gfx/svg-defs.svg#opacity"></use></svg>
</div>
<input title="Opacity" id="openwebrx-opacity-slider" class="openwebrx-panel-slider" type="range" min="20" max="100" value="100" step="1" oninput="UI.setOpacity(this.value);">
</div>
<div class="openwebrx-panel-line">
<input id="openwebrx-frame-checkbox" type="checkbox" onchange="UI.setFrame(this.checked);">
Draw white frame around panels
</input>
</div>
<div class="openwebrx-panel-line">
<input id="openwebrx-wheel-checkbox" type="checkbox" onchange="UI.setWheelSwap(this.checked);">
Hold mouse wheel down to tune
</input>
</div>
</div>
<div class="openwebrx-section-divider" onclick="toggleSection(this);">&blacktriangledown;&nbsp;Display</div>
<div class="openwebrx-section">

View File

@ -12,6 +12,7 @@ UI.volume = -1;
UI.volumeMuted = -1;
UI.nrThreshold = 0;
UI.nrEnabled = false;
UI.wheelSwap = false;
//
// Local Storage Access
@ -47,6 +48,7 @@ UI.loadSettings = function() {
if (this.has('ui_theme')) this.setTheme(this.loadStr('ui_theme'));
if (this.has('ui_frame')) this.setFrame(this.loadBool('ui_frame'));
if (this.has('ui_opacity')) this.setOpacity(this.loadInt('ui_opacity'));
if (this.has('ui_wheel')) this.setWheelSwap(this.loadBool('ui_wheel'));
if (this.has('volume')) this.setVolume(this.loadInt('volume'));
if (this.has('nr_threshold')) this.setNR(this.loadInt('nr_threshold'));
@ -137,21 +139,31 @@ UI.updateNR = function() {
// Look & Feel Controls
//
// Toggle frame around receiver and other panels.
UI.toggleFrame = function() {
this.setFrame(!this.frame);
};
// Show or hide frame around receiver and other panels.
UI.setFrame = function(x) {
if (this.frame != x) {
this.frame = x;
this.save('ui_frame', x);
$('#openwebrx-frame-checkbox').attr('checked', x);
$('#openwebrx-panel-receiver').css('border', x? '2px solid':'');
$('#openwebrx-dialog-bookmark').css('border', x? '2px solid':'');
}
};
// Get current mouse wheel function
UI.getWheelSwap = function(x) {
return this.wheelSwap;
};
// Set mouse wheel function (zooming when swapped)
UI.setWheelSwap = function(x) {
if (this.wheelSwap != x) {
this.wheelSwap = x;
this.save('ui_wheel', x);
$('#openwebrx-wheel-checkbox').attr('checked', x);
}
};
// Set user interface opacity in 10..100% range.
UI.setOpacity = function(x) {
x = x<10? 10 : x>100? 100 : x;

View File

@ -34,7 +34,6 @@ var waterfall_setup_done = 0;
var secondary_fft_size;
var tuning_step_default = 1;
var tuning_step = 1;
var swap_wheel = false;
function toggleSection(el) {
var next_el = el.nextElementSibling;
@ -870,7 +869,7 @@ function canvas_mousewheel(evt) {
// Zoom when mouse button down, tune otherwise
// (optionally, invert this behavior)
var zoom_me = (canvas_mouse2_down > 0) || evt.shiftKey?
!swap_wheel : swap_wheel;
!UI.getWheelSwap() : UI.getWheelSwap();
if (zoom_me) {
zoom_step(dir, relativeX, zoom_center_where_calc(evt.pageX));
} else {
@ -1050,10 +1049,6 @@ function on_ws_recv(evt) {
tuning_step_reset();
}
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');
@ -1602,12 +1597,6 @@ function initSliders() {
toggleScanner();
return false;
});
// Toggle UI panel frames by pressing right mouse button on OPACITY
$('#openwebrx-opacity-reset').on('contextmenu', function() {
UI.toggleFrame();
return false;
});
}
function digimodes_init() {

View File

@ -153,7 +153,6 @@ defaultConfig = PropertyLayer(
waterfall_auto_level_default_mode=False,
waterfall_auto_min_range=50,
key_locked=False,
ui_swap_wheel=False,
magic_key="memagic",
allow_center_freq_changes=False,
allow_audio_recording=True,

View File

@ -140,7 +140,6 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
"fft_compression",
"max_clients",
"tuning_precision",
"ui_swap_wheel",
"allow_center_freq_changes",
"allow_audio_recording",
"magic_key",

View File

@ -190,10 +190,6 @@ class GeneralSettingsController(SettingsFormController):
options=[Option(str(i), "{} Hz".format(10 ** i)) for i in range(0, 6)],
converter=IntConverter(),
),
CheckboxInput(
"ui_swap_wheel",
"Make mouse wheel control zoom, tune by holding wheel down",
),
NumberInput(
"eibi_bookmarks_range",
"Shortwave bookmarks range",