Preview a frame using the webview. Select monitor to display images on. Wooo!

This commit is contained in:
mmcwilliams 2019-06-26 20:08:49 -04:00
parent 073e778a3b
commit 084916c317
17 changed files with 278 additions and 162 deletions

View File

@ -379,7 +379,7 @@
</div> </div>
<div id="filmout_functions"> <div id="filmout_functions">
<div> <div>
<button id="filmout_preview">PREVIEW</button> <button id="filmout_preview" onclick="filmout.preview();">PREVIEW</button>
<button id="filmout_meter" onclick="filmout.meter();">METER</button> <button id="filmout_meter" onclick="filmout.meter();">METER</button>
<button id="filmout_focus" onclick="filmout.focus();">FOCUS</button> <button id="filmout_focus" onclick="filmout.focus();">FOCUS</button>
<button id="filmout_field" onclick="filmout.field();">FIELD GUIDE</button> <button id="filmout_field" onclick="filmout.field();">FIELD GUIDE</button>

View File

@ -17,10 +17,10 @@ function padded_frame(i) {
return str; return str;
} }
class WebView { class WebView {
constructor(platform) { constructor(platform, display) {
this.opened = false; this.opened = false;
this.showing = false; this.showing = false;
this.digitalWindow = new BrowserWindow({ const prefs = {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
allowRunningInsecureContent: false allowRunningInsecureContent: false
@ -30,7 +30,12 @@ class WebView {
minWidth: 800, minWidth: 800,
minHeight: 600 //, minHeight: 600 //,
//icon: path.join(__dirname, '../../assets/icons/icon.png') //icon: path.join(__dirname, '../../assets/icons/icon.png')
}); };
if (!display.primary) {
prefs.x = display.x + 50;
prefs.y = display.y + 50;
}
this.digitalWindow = new BrowserWindow(prefs);
this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html'); this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html');
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) { if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
this.digitalWindow.webContents.openDevTools(); this.digitalWindow.webContents.openDevTools();
@ -41,6 +46,7 @@ class WebView {
}); });
//this.digitalWindow.hide(); //this.digitalWindow.hide();
this.platform = platform; this.platform = platform;
this.display = display;
} }
async open() { async open() {
this.digitalWindow.show(); this.digitalWindow.show();
@ -149,51 +155,36 @@ class EOG {
class Display { class Display {
constructor(sys) { constructor(sys) {
this.platform = sys.platform; this.platform = sys.platform;
this.displays = sys.displays;
this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital'); this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital');
this.display = this.displays.find((display) => {
if (display.primary)
return true;
});
} }
async open() { async open() {
//if (this.platform !== 'nix') { if (this.wv && this.wv.display && this.wv.display.id !== this.display.id) {
this.wv.close();
}
if (!this.wv || !this.wv.opened) { if (!this.wv || !this.wv.opened) {
this.wv = new WebView(this.platform); this.wv = new WebView(this.platform, this.display);
await this.wv.open(); await this.wv.open();
} }
//} else {
// if (!this.eog) {
// this.eog = new EOG()
// }
//}
} }
async show(frame) { async show(frame) {
let padded = padded_frame(frame); let padded = padded_frame(frame);
let ext = 'tif'; let ext = 'png';
let tmppath; let tmppath;
//if (this.platform !== 'nix') {
ext = 'png';
//}
tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`); tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`);
//if (this.platform !== 'nix') {
await this.wv.show(tmppath); await this.wv.show(tmppath);
//} else {
//await this.eog.show(tmppath);
//}
} }
async showPath(pathStr) { async showPath(pathStr) {
return await this.wv.show(pathStr); return await this.wv.show(pathStr);
} }
hide() { hide() {
//if (this.platform !== 'nix') {
//don't hide between frames
//this.wv.hide();
//} else {
//this.eog.hide();
//}
} }
close() { async close() {
//if (this.platform !== 'nix') { return await this.wv.close();
this.wv.close();
//} else {
//this.eog.close()
//}
} }
async focus() { async focus() {
return await this.wv.focus(); return await this.wv.focus();
@ -204,6 +195,12 @@ class Display {
async meter() { async meter() {
return await this.wv.meter(); return await this.wv.meter();
} }
change(id) {
this.display = this.displays.find((display) => {
if (display.id == id)
return true;
});
}
} }
module.exports = function (sys) { module.exports = function (sys) {
return new Display(sys); return new Display(sys);

File diff suppressed because one or more lines are too long

View File

@ -41,8 +41,9 @@ class FilmOut {
this.ipc.on('field', this.field.bind(this)); this.ipc.on('field', this.field.bind(this));
this.ipc.on('meter', this.meter.bind(this)); this.ipc.on('meter', this.meter.bind(this));
this.ipc.on('filmout_close', this.close.bind(this)); this.ipc.on('filmout_close', this.close.bind(this));
//preview this.ipc.on('preview', this.preview.bind(this));
this.ipc.on('preview_frame', this.previewFrame.bind(this)); this.ipc.on('preview_frame', this.previewFrame.bind(this));
this.ipc.on('display', this.onDisplay.bind(this));
} }
/** /**
* *
@ -74,14 +75,14 @@ class FilmOut {
await this.ffmpeg.clearAll(); await this.ffmpeg.clearAll();
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
try { try {
await this.ffmpeg.frame(this.state, this.light.state); await this.ffmpeg.frame(this.state, this.light.state);
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
await this.display.show(this.state.frame); await this.display.show(this.state.frame);
@ -137,14 +138,34 @@ class FilmOut {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] }); path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
;
throw err; throw err;
} }
this.ui.send('preview_frame', { path, frame: arg.frame }); this.ui.send('preview_frame', { path, frame: arg.frame });
} }
async preview(evt, arg) { async preview(evt, arg) {
const state = JSON.parse(JSON.stringify(this.state));
let path;
state.frame = arg.frame;
this.log.info(`Previewing frame ${state.frame} of ${state.fileName}`);
try {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
throw err;
}
try {
await this.display.open();
await this.display.show(arg.frame);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
}
} }
async focus(evt, arg) { async focus(evt, arg) {
this.log.info(`Showing focus screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
@ -154,6 +175,7 @@ class FilmOut {
} }
} }
async field(evt, arg) { async field(evt, arg) {
this.log.info(`Showing field guide screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.field(); await this.display.field();
@ -163,6 +185,7 @@ class FilmOut {
} }
} }
async meter(evt, arg) { async meter(evt, arg) {
this.log.info(`Showing meter screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
@ -180,6 +203,10 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
onDisplay(evt, arg) {
this.display.change(arg.display);
this.log.info(`Changing the display to ${arg.display}`);
}
} }
module.exports = (display, ffmpeg, ffprobe, ui, light) => { module.exports = (display, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light); return new FilmOut(display, ffmpeg, ffprobe, ui, light);

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,8 @@ class FilmOut {
this.id = 'filmout'; this.id = 'filmout';
this.displays = []; this.displays = [];
this.state = { this.state = {
frame: 0 frame: 0,
display: null
}; };
} }
init() { init() {
@ -86,16 +87,21 @@ class FilmOut {
h = display.height / scale; h = display.height / scale;
top = Math.floor((maxH - h) / 2); top = Math.floor((maxH - h) / 2);
elem.height(h); elem.height(h);
elem.css('margin-top', `${top}px`); elem.width(maxW - 4);
elem.css('top', `${top}px`);
} }
else { else {
elem.width(w); elem.width(w);
elem.height(maxH - 4);
elem.css('top', `0px`);
} }
elem.addClass('on'); elem.addClass('on');
$('#filmout_stats_monitor_size').text(`${display.width} x ${display.height}`); $('#filmout_stats_monitor_size').text(`${display.width} x ${display.height}`);
$('#filmout_stats_monitor_aspect').text(`${aspect}`); $('#filmout_stats_monitor_aspect').text(`${aspect}`);
$('#filmout_stats_monitor_scale').text(`${parseFloat(display.scale).toFixed(1)} scale factor`); $('#filmout_stats_monitor_scale').text(`${parseFloat(display.scale).toFixed(1)} scale factor`);
console.dir(display); console.dir(display);
this.state.display = id;
ipcRenderer.send('display', { display: id });
} }
selectFile() { selectFile() {
const elem = $('#digital'); const elem = $('#digital');
@ -160,10 +166,7 @@ class FilmOut {
gui.spinner(false); gui.spinner(false);
gui.overlay(false); gui.overlay(false);
if (args.valid && args.valid === true) { if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state); state = JSON.parse(args.state);
//console.dir(args)
//console.dir(state)
$('#digital').addClass('active'); $('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked'); $('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`); gui.notify('DEVICES', `Using video ${state.fileName}`);
@ -217,7 +220,9 @@ class FilmOut {
} }
$('#filmout_position').val(this.state.frame).trigger('change'); $('#filmout_position').val(this.state.frame).trigger('change');
} }
preview(evt, arg) { preview() {
const frame = this.state.frame;
ipcRenderer.send('preview', { frame });
} }
focus() { focus() {
ipcRenderer.send('focus', { focus: true }); ipcRenderer.send('focus', { focus: true });

View File

@ -51,7 +51,8 @@ class FilmOut {
private id : string = 'filmout'; private id : string = 'filmout';
private displays : any[] = []; private displays : any[] = [];
private state : any = { private state : any = {
frame : 0 frame : 0,
display : null
} }
constructor () { constructor () {
@ -107,9 +108,12 @@ class FilmOut {
h = display.height / scale; h = display.height / scale;
top = Math.floor((maxH - h) / 2); top = Math.floor((maxH - h) / 2);
elem.height(h); elem.height(h);
elem.css('margin-top', `${top}px`); elem.width(maxW - 4);
elem.css('top', `${top}px`);
} else { } else {
elem.width(w); elem.width(w);
elem.height(maxH - 4);
elem.css('top', `0px`);
} }
elem.addClass('on'); elem.addClass('on');
@ -117,6 +121,8 @@ class FilmOut {
$('#filmout_stats_monitor_aspect').text(`${aspect}`); $('#filmout_stats_monitor_aspect').text(`${aspect}`);
$('#filmout_stats_monitor_scale').text(`${parseFloat(display.scale).toFixed(1)} scale factor`); $('#filmout_stats_monitor_scale').text(`${parseFloat(display.scale).toFixed(1)} scale factor`);
console.dir(display); console.dir(display);
this.state.display = id;
ipcRenderer.send('display', { display : id });
} }
selectFile () { selectFile () {
const elem : any = $('#digital'); const elem : any = $('#digital');
@ -182,10 +188,7 @@ class FilmOut {
gui.overlay(false); gui.overlay(false);
if (args.valid && args.valid === true) { if (args.valid && args.valid === true) {
//success state
state = JSON.parse(args.state); state = JSON.parse(args.state);
//console.dir(args)
//console.dir(state)
$('#digital').addClass('active'); $('#digital').addClass('active');
$('#projector_type_digital').prop('checked', 'checked'); $('#projector_type_digital').prop('checked', 'checked');
gui.notify('DEVICES', `Using video ${state.fileName}`); gui.notify('DEVICES', `Using video ${state.fileName}`);
@ -245,18 +248,23 @@ class FilmOut {
$('#filmout_position').val(this.state.frame).trigger('change'); $('#filmout_position').val(this.state.frame).trigger('change');
} }
preview (evt : any, arg : any) { preview () {
const frame : number = this.state.frame;
ipcRenderer.send('preview', { frame });
} }
focus () { focus () {
ipcRenderer.send('focus', { focus : true }); ipcRenderer.send('focus', { focus : true });
} }
field () { field () {
ipcRenderer.send('field', { field : true }); ipcRenderer.send('field', { field : true });
} }
meter () { meter () {
ipcRenderer.send('meter', { meter : true }); ipcRenderer.send('meter', { meter : true });
} }
close (evt : any, arg : any) { close (evt : any, arg : any) {
} }

View File

@ -17,10 +17,10 @@ function padded_frame(i) {
return str; return str;
} }
class WebView { class WebView {
constructor(platform) { constructor(platform, display) {
this.opened = false; this.opened = false;
this.showing = false; this.showing = false;
this.digitalWindow = new BrowserWindow({ const prefs = {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
allowRunningInsecureContent: false allowRunningInsecureContent: false
@ -30,7 +30,12 @@ class WebView {
minWidth: 800, minWidth: 800,
minHeight: 600 //, minHeight: 600 //,
//icon: path.join(__dirname, '../../assets/icons/icon.png') //icon: path.join(__dirname, '../../assets/icons/icon.png')
}); };
if (!display.primary) {
prefs.x = display.x + 50;
prefs.y = display.y + 50;
}
this.digitalWindow = new BrowserWindow(prefs);
this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html'); this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html');
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) { if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
this.digitalWindow.webContents.openDevTools(); this.digitalWindow.webContents.openDevTools();
@ -41,6 +46,7 @@ class WebView {
}); });
//this.digitalWindow.hide(); //this.digitalWindow.hide();
this.platform = platform; this.platform = platform;
this.display = display;
} }
async open() { async open() {
this.digitalWindow.show(); this.digitalWindow.show();
@ -149,51 +155,36 @@ class EOG {
class Display { class Display {
constructor(sys) { constructor(sys) {
this.platform = sys.platform; this.platform = sys.platform;
this.displays = sys.displays;
this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital'); this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital');
this.display = this.displays.find((display) => {
if (display.primary)
return true;
});
} }
async open() { async open() {
//if (this.platform !== 'nix') { if (this.wv && this.wv.display && this.wv.display.id !== this.display.id) {
this.wv.close();
}
if (!this.wv || !this.wv.opened) { if (!this.wv || !this.wv.opened) {
this.wv = new WebView(this.platform); this.wv = new WebView(this.platform, this.display);
await this.wv.open(); await this.wv.open();
} }
//} else {
// if (!this.eog) {
// this.eog = new EOG()
// }
//}
} }
async show(frame) { async show(frame) {
let padded = padded_frame(frame); let padded = padded_frame(frame);
let ext = 'tif'; let ext = 'png';
let tmppath; let tmppath;
//if (this.platform !== 'nix') {
ext = 'png';
//}
tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`); tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`);
//if (this.platform !== 'nix') {
await this.wv.show(tmppath); await this.wv.show(tmppath);
//} else {
//await this.eog.show(tmppath);
//}
} }
async showPath(pathStr) { async showPath(pathStr) {
return await this.wv.show(pathStr); return await this.wv.show(pathStr);
} }
hide() { hide() {
//if (this.platform !== 'nix') {
//don't hide between frames
//this.wv.hide();
//} else {
//this.eog.hide();
//}
} }
close() { async close() {
//if (this.platform !== 'nix') { return await this.wv.close();
this.wv.close();
//} else {
//this.eog.close()
//}
} }
async focus() { async focus() {
return await this.wv.focus(); return await this.wv.focus();
@ -204,6 +195,12 @@ class Display {
async meter() { async meter() {
return await this.wv.meter(); return await this.wv.meter();
} }
change(id) {
this.display = this.displays.find((display) => {
if (display.id == id)
return true;
});
}
} }
module.exports = function (sys) { module.exports = function (sys) {
return new Display(sys); return new Display(sys);

File diff suppressed because one or more lines are too long

View File

@ -41,8 +41,9 @@ class FilmOut {
this.ipc.on('field', this.field.bind(this)); this.ipc.on('field', this.field.bind(this));
this.ipc.on('meter', this.meter.bind(this)); this.ipc.on('meter', this.meter.bind(this));
this.ipc.on('filmout_close', this.close.bind(this)); this.ipc.on('filmout_close', this.close.bind(this));
//preview this.ipc.on('preview', this.preview.bind(this));
this.ipc.on('preview_frame', this.previewFrame.bind(this)); this.ipc.on('preview_frame', this.previewFrame.bind(this));
this.ipc.on('display', this.onDisplay.bind(this));
} }
/** /**
* *
@ -74,14 +75,14 @@ class FilmOut {
await this.ffmpeg.clearAll(); await this.ffmpeg.clearAll();
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
try { try {
await this.ffmpeg.frame(this.state, this.light.state); await this.ffmpeg.frame(this.state, this.light.state);
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
await this.display.show(this.state.frame); await this.display.show(this.state.frame);
@ -137,14 +138,34 @@ class FilmOut {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] }); path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
;
throw err; throw err;
} }
this.ui.send('preview_frame', { path, frame: arg.frame }); this.ui.send('preview_frame', { path, frame: arg.frame });
} }
async preview(evt, arg) { async preview(evt, arg) {
const state = JSON.parse(JSON.stringify(this.state));
let path;
state.frame = arg.frame;
this.log.info(`Previewing frame ${state.frame} of ${state.fileName}`);
try {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
throw err;
}
try {
await this.display.open();
await this.display.show(arg.frame);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
}
} }
async focus(evt, arg) { async focus(evt, arg) {
this.log.info(`Showing focus screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
@ -154,6 +175,7 @@ class FilmOut {
} }
} }
async field(evt, arg) { async field(evt, arg) {
this.log.info(`Showing field guide screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.field(); await this.display.field();
@ -163,6 +185,7 @@ class FilmOut {
} }
} }
async meter(evt, arg) { async meter(evt, arg) {
this.log.info(`Showing meter screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
@ -180,6 +203,10 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
onDisplay(evt, arg) {
this.display.change(arg.display);
this.log.info(`Changing the display to ${arg.display}`);
}
} }
module.exports = (display, ffmpeg, ffprobe, ui, light) => { module.exports = (display, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light); return new FilmOut(display, ffmpeg, ffprobe, ui, light);

File diff suppressed because one or more lines are too long

View File

@ -17,10 +17,10 @@ function padded_frame(i) {
return str; return str;
} }
class WebView { class WebView {
constructor(platform) { constructor(platform, display) {
this.opened = false; this.opened = false;
this.showing = false; this.showing = false;
this.digitalWindow = new BrowserWindow({ const prefs = {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
allowRunningInsecureContent: false allowRunningInsecureContent: false
@ -30,7 +30,12 @@ class WebView {
minWidth: 800, minWidth: 800,
minHeight: 600 //, minHeight: 600 //,
//icon: path.join(__dirname, '../../assets/icons/icon.png') //icon: path.join(__dirname, '../../assets/icons/icon.png')
}); };
if (!display.primary) {
prefs.x = display.x + 50;
prefs.y = display.y + 50;
}
this.digitalWindow = new BrowserWindow(prefs);
this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html'); this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html');
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) { if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
this.digitalWindow.webContents.openDevTools(); this.digitalWindow.webContents.openDevTools();
@ -41,6 +46,7 @@ class WebView {
}); });
//this.digitalWindow.hide(); //this.digitalWindow.hide();
this.platform = platform; this.platform = platform;
this.display = display;
} }
async open() { async open() {
this.digitalWindow.show(); this.digitalWindow.show();
@ -149,51 +155,36 @@ class EOG {
class Display { class Display {
constructor(sys) { constructor(sys) {
this.platform = sys.platform; this.platform = sys.platform;
this.displays = sys.displays;
this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital'); this.tmpdir = path_1.join(sys.tmp, 'mcopy_digital');
this.display = this.displays.find((display) => {
if (display.primary)
return true;
});
} }
async open() { async open() {
//if (this.platform !== 'nix') { if (this.wv && this.wv.display && this.wv.display.id !== this.display.id) {
this.wv.close();
}
if (!this.wv || !this.wv.opened) { if (!this.wv || !this.wv.opened) {
this.wv = new WebView(this.platform); this.wv = new WebView(this.platform, this.display);
await this.wv.open(); await this.wv.open();
} }
//} else {
// if (!this.eog) {
// this.eog = new EOG()
// }
//}
} }
async show(frame) { async show(frame) {
let padded = padded_frame(frame); let padded = padded_frame(frame);
let ext = 'tif'; let ext = 'png';
let tmppath; let tmppath;
//if (this.platform !== 'nix') {
ext = 'png';
//}
tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`); tmppath = path_1.join(this.tmpdir, `export-${padded}.${ext}`);
//if (this.platform !== 'nix') {
await this.wv.show(tmppath); await this.wv.show(tmppath);
//} else {
//await this.eog.show(tmppath);
//}
} }
async showPath(pathStr) { async showPath(pathStr) {
return await this.wv.show(pathStr); return await this.wv.show(pathStr);
} }
hide() { hide() {
//if (this.platform !== 'nix') {
//don't hide between frames
//this.wv.hide();
//} else {
//this.eog.hide();
//}
} }
close() { async close() {
//if (this.platform !== 'nix') { return await this.wv.close();
this.wv.close();
//} else {
//this.eog.close()
//}
} }
async focus() { async focus() {
return await this.wv.focus(); return await this.wv.focus();
@ -204,6 +195,12 @@ class Display {
async meter() { async meter() {
return await this.wv.meter(); return await this.wv.meter();
} }
change(id) {
this.display = this.displays.find((display) => {
if (display.id == id)
return true;
});
}
} }
module.exports = function (sys) { module.exports = function (sys) {
return new Display(sys); return new Display(sys);

File diff suppressed because one or more lines are too long

View File

@ -41,8 +41,9 @@ class FilmOut {
this.ipc.on('field', this.field.bind(this)); this.ipc.on('field', this.field.bind(this));
this.ipc.on('meter', this.meter.bind(this)); this.ipc.on('meter', this.meter.bind(this));
this.ipc.on('filmout_close', this.close.bind(this)); this.ipc.on('filmout_close', this.close.bind(this));
//preview this.ipc.on('preview', this.preview.bind(this));
this.ipc.on('preview_frame', this.previewFrame.bind(this)); this.ipc.on('preview_frame', this.previewFrame.bind(this));
this.ipc.on('display', this.onDisplay.bind(this));
} }
/** /**
* *
@ -74,14 +75,14 @@ class FilmOut {
await this.ffmpeg.clearAll(); await this.ffmpeg.clearAll();
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
try { try {
await this.ffmpeg.frame(this.state, this.light.state); await this.ffmpeg.frame(this.state, this.light.state);
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
await this.display.show(this.state.frame); await this.display.show(this.state.frame);
@ -137,14 +138,34 @@ class FilmOut {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] }); path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
} }
catch (err) { catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
;
throw err; throw err;
} }
this.ui.send('preview_frame', { path, frame: arg.frame }); this.ui.send('preview_frame', { path, frame: arg.frame });
} }
async preview(evt, arg) { async preview(evt, arg) {
const state = JSON.parse(JSON.stringify(this.state));
let path;
state.frame = arg.frame;
this.log.info(`Previewing frame ${state.frame} of ${state.fileName}`);
try {
path = await this.ffmpeg.frame(state, { color: [255, 255, 255] });
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
throw err;
}
try {
await this.display.open();
await this.display.show(arg.frame);
}
catch (err) {
this.log.error(err, 'FILMOUT', true, true);
}
} }
async focus(evt, arg) { async focus(evt, arg) {
this.log.info(`Showing focus screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
@ -154,6 +175,7 @@ class FilmOut {
} }
} }
async field(evt, arg) { async field(evt, arg) {
this.log.info(`Showing field guide screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.field(); await this.display.field();
@ -163,6 +185,7 @@ class FilmOut {
} }
} }
async meter(evt, arg) { async meter(evt, arg) {
this.log.info(`Showing meter screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
@ -180,6 +203,10 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
onDisplay(evt, arg) {
this.display.change(arg.display);
this.log.info(`Changing the display to ${arg.display}`);
}
} }
module.exports = (display, ffmpeg, ffprobe, ui, light) => { module.exports = (display, ffmpeg, ffprobe, ui, light) => {
return new FilmOut(display, ffmpeg, ffprobe, ui, light); return new FilmOut(display, ffmpeg, ffprobe, ui, light);

File diff suppressed because one or more lines are too long

View File

@ -26,9 +26,10 @@ class WebView {
public opened : boolean = false; public opened : boolean = false;
public showing : boolean = false; public showing : boolean = false;
private platform : string; private platform : string;
public display : any;
constructor (platform : string) { constructor (platform : string, display : any) {
this.digitalWindow = new BrowserWindow({ const prefs : any = {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
allowRunningInsecureContent: false allowRunningInsecureContent: false
@ -38,7 +39,12 @@ class WebView {
minWidth : 800, minWidth : 800,
minHeight : 600//, minHeight : 600//,
//icon: path.join(__dirname, '../../assets/icons/icon.png') //icon: path.join(__dirname, '../../assets/icons/icon.png')
}); }
if (!display.primary) {
prefs.x = display.x + 50;
prefs.y = display.y + 50;
}
this.digitalWindow = new BrowserWindow(prefs);
this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html'); this.digitalWindow.loadURL('file://' + __dirname + '../../../display.html');
if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) { if (process.argv.indexOf('-d') !== -1 || process.argv.indexOf('--dev') !== -1) {
this.digitalWindow.webContents.openDevTools(); this.digitalWindow.webContents.openDevTools();
@ -49,6 +55,7 @@ class WebView {
}); });
//this.digitalWindow.hide(); //this.digitalWindow.hide();
this.platform = platform; this.platform = platform;
this.display = display;
} }
async open () { async open () {
this.digitalWindow.show(); this.digitalWindow.show();
@ -159,60 +166,46 @@ class EOG {
class Display { class Display {
private platform : string; private platform : string;
private displays : any[];
private display : any;
private tmpdir : string; private tmpdir : string;
private wv : WebView; private wv : WebView;
private eog : EOG; private eog : EOG;
constructor (sys : any) { constructor (sys : any) {
this.platform = sys.platform; this.platform = sys.platform;
this.displays = sys.displays;
this.tmpdir = pathJoin(sys.tmp, 'mcopy_digital'); this.tmpdir = pathJoin(sys.tmp, 'mcopy_digital');
this.display = this.displays.find((display : any) => {
if (display.primary) return true;
})
} }
public async open () { public async open () {
//if (this.platform !== 'nix') { if (this.wv && this.wv.display && this.wv.display.id !== this.display.id) {
if (!this.wv || !this.wv.opened) { this.wv.close();
this.wv = new WebView(this.platform); }
await this.wv.open() if (!this.wv || !this.wv.opened) {
this.wv = new WebView(this.platform, this.display);
await this.wv.open();
} }
//} else {
// if (!this.eog) {
// this.eog = new EOG()
// }
//}
} }
public async show (frame : number) { public async show (frame : number) {
let padded : string = padded_frame(frame); let padded : string = padded_frame(frame);
let ext : string = 'tif'; let ext : string = 'png';
let tmppath : string; let tmppath : string;
//if (this.platform !== 'nix') {
ext = 'png';
//}
tmppath = pathJoin(this.tmpdir, `export-${padded}.${ext}`); tmppath = pathJoin(this.tmpdir, `export-${padded}.${ext}`);
//if (this.platform !== 'nix') {
await this.wv.show(tmppath); await this.wv.show(tmppath);
//} else {
//await this.eog.show(tmppath);
//}
} }
public async showPath (pathStr : string) { public async showPath (pathStr : string) {
return await this.wv.show(pathStr); return await this.wv.show(pathStr);
} }
public hide () { public hide () {
//if (this.platform !== 'nix') {
//don't hide between frames
//this.wv.hide();
//} else {
//this.eog.hide();
//}
} }
public close () { public async close () {
//if (this.platform !== 'nix') { return await this.wv.close()
this.wv.close()
//} else {
//this.eog.close()
//}
} }
public async focus () { public async focus () {
return await this.wv.focus(); return await this.wv.focus();
@ -223,6 +216,11 @@ class Display {
public async meter () { public async meter () {
return await this.wv.meter(); return await this.wv.meter();
} }
public change (id : any) {
this.display = this.displays.find((display : any) => {
if (display.id == id) return true;
});
}
} }
module.exports = function (sys : any) { module.exports = function (sys : any) {

View File

@ -49,8 +49,9 @@ class FilmOut {
this.ipc.on('field', this.field.bind(this)); this.ipc.on('field', this.field.bind(this));
this.ipc.on('meter', this.meter.bind(this)); this.ipc.on('meter', this.meter.bind(this));
this.ipc.on('filmout_close', this.close.bind(this)); this.ipc.on('filmout_close', this.close.bind(this));
//preview this.ipc.on('preview', this.preview.bind(this));
this.ipc.on('preview_frame', this.previewFrame.bind(this)); this.ipc.on('preview_frame', this.previewFrame.bind(this));
this.ipc.on('display', this.onDisplay.bind(this));
} }
/** /**
* *
@ -80,14 +81,14 @@ class FilmOut {
try { try {
await this.ffmpeg.clearAll(); await this.ffmpeg.clearAll();
} catch (err) { } catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
try { try {
await this.ffmpeg.frame(this.state, this.light.state); await this.ffmpeg.frame(this.state, this.light.state);
} catch (err) { } catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);
throw err; throw err;
} }
await this.display.show(this.state.frame); await this.display.show(this.state.frame);
@ -140,20 +141,42 @@ class FilmOut {
async previewFrame (evt : any, arg : any) { async previewFrame (evt : any, arg : any) {
const state : any = JSON.parse(JSON.stringify(this.state)); const state : any = JSON.parse(JSON.stringify(this.state));
let path : string; let path : string;
state.frame = arg.frame; state.frame = arg.frame;
try { try {
path = await this.ffmpeg.frame(state, { color : [255, 255, 255] }); path = await this.ffmpeg.frame(state, { color : [255, 255, 255] });
} catch (err) { } catch (err) {
console.error(err); this.log.error(err, 'FILMOUT', true, true);;
throw err; throw err;
} }
this.ui.send('preview_frame', { path, frame : arg.frame }) this.ui.send('preview_frame', { path, frame : arg.frame })
} }
async preview (evt : any, arg : any) { async preview (evt : any, arg : any) {
const state : any = JSON.parse(JSON.stringify(this.state));
let path : string;
state.frame = arg.frame;
this.log.info(`Previewing frame ${state.frame} of ${state.fileName}`);
try {
path = await this.ffmpeg.frame(state, { color : [255, 255, 255] });
} catch (err) {
this.log.error(err, 'FILMOUT', true, true);
throw err;
} }
try {
await this.display.open();
await this.display.show(arg.frame);
} catch (err) {
this.log.error(err, 'FILMOUT', true, true);
}
}
async focus (evt : any, arg : any) { async focus (evt : any, arg : any) {
this.log.info(`Showing focus screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.focus(); await this.display.focus();
@ -161,7 +184,9 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
async field (evt : any, arg : any) { async field (evt : any, arg : any) {
this.log.info(`Showing field guide screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.field(); await this.display.field();
@ -169,7 +194,9 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
async meter (evt : any, arg : any) { async meter (evt : any, arg : any) {
this.log.info(`Showing meter screen`);
try { try {
await this.display.open(); await this.display.open();
await this.display.meter(); await this.display.meter();
@ -177,6 +204,7 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
async close (evt : any, arg : any) { async close (evt : any, arg : any) {
try { try {
await this.display.hide(); await this.display.hide();
@ -185,6 +213,11 @@ class FilmOut {
this.log.error(err, 'FILMOUT', true, true); this.log.error(err, 'FILMOUT', true, true);
} }
} }
onDisplay (evt : any, arg : any) {
this.display.change(arg.display);
this.log.info(`Changing the display to ${arg.display}`);
}
} }
module.exports = (display : any, ffmpeg : any, ffprobe : any, ui : any, light : any) => { module.exports = (display : any, ffmpeg : any, ffprobe : any, ui : any, light : any) => {