spacing. When the selected layout is not freeform, calculate the ratio of computed size to stream source size to calculate a value for scale.

This commit is contained in:
Isaac Connor 2021-08-19 16:05:43 -04:00
parent 89d7685b14
commit 7a6c244aa7
1 changed files with 49 additions and 38 deletions

View File

@ -36,21 +36,19 @@ function selectLayout(element) {
for (style in styles) {
monitor_frame.css(style, styles[style]);
}
} else {
console.log("No Monitor styles to apply");
} // end if specific monitor style
} // end foreach monitor
} // end if a stored layout
if ( ! layout ) {
return;
}
setCookie('zmMontageLayout', layout_id, 3600);
if (layouts[layout_id].Name != 'Freeform') { // 'montage_freeform.css' ) {
// For freeform, we don't touch the width/height/scale settings, but we may need to update sizing and scales
setCookie('zmMontageScale', '', 3600);
$j('#scale').val('');
$j('#width').val('0');
} else {
// Is freeform, we don't touch the width/height/scale settings, but we may need to update sizing and scales
}
} // end if a stored layout
if (!layout) {
console.log('No layout?');
return;
}
var width = parseInt($j('#width').val());
var height = parseInt($j('#height').val());
@ -59,14 +57,28 @@ function selectLayout(element) {
for (var i = 0, length = monitors.length; i < length; i++) {
var monitor = monitors[i];
var stream_scale = 0;
if (scale) {
stream_scale = scale;
} else if (width) {
stream_scale = parseInt(100*width/monitor.width);
} else if (height) {
stream_scale = parseInt(100*height/monitor.height);
} else if (layouts[layout_id].Name != 'Freeform') {
monitor_frame = $j('#monitorFrame'+monitor.id);
console.log("Monitor frame width : " + monitor_frame.width() + " monitor Width: " + monitor.width);
if (monitor_frame.width() < monitor.width) {
stream_scale = parseInt(100 * monitor_frame.width() / monitor.width);
// Round to a multiple of 5, so 53 become 50% etc
stream_scale = Math.floor(stream_scale/5)*5;
}
var streamImg = document.getElementById('liveStream'+monitor.id);
}
setStreamScale('liveStream'+monitor.id, stream_scale, width, height);
} // end foreach monitor
} // end function selectLayout(element)
function setStreamScale(element_id, scale, width, height) {
var streamImg = document.getElementById(element_id);
if (streamImg) {
if (streamImg.nodeName == 'IMG') {
var src = streamImg.src;
@ -81,10 +93,9 @@ function selectLayout(element) {
} else if (streamImg.nodeName == 'APPLET' || streamImg.nodeName == 'OBJECT') {
// APPLET's and OBJECTS need to be re-initialized
}
streamImg.style.width = '100%';
//streamImg.style.width = '100%';
}
}
} // end foreach monitor
} // end function selectLayout(element)
/**
* called when the widthControl|heightControl select elements are changed