Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

issue #1074: Rename KobukiViewer and use with electron #1133

Merged
merged 3 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/tools/TurtlebotViewer-web/kobukiviewerjs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd @CMAKE_INSTALL_PREFIX@/share/jderobot/webtools/kobukiviewerjs/

nodejs run.js
56 changes: 56 additions & 0 deletions src/tools/TurtlebotViewer-web/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const electron = require('electron')
const {app, BrowserWindow} = electron
const path = require('path')
const url = require('url')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win

function createWindow () {
// Create the browser window.
var screenElectron = electron.screen;
var mainScreen = screenElectron.getPrimaryDisplay();
var dimensions = mainScreen.size;
win = new BrowserWindow({width: dimensions.width, height: dimensions.height});

// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, '/public/index.html'),
protocol: 'file:',
slashes: true
}))

// Open the DevTools.
// win.webContents.openDevTools()

// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
})
Loading