Skip to content

Feature/new toolbar #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
65e53cc
Auto connect if only one port available
sebromero Dec 17, 2024
07fa1ce
Display connection status
sebromero Dec 17, 2024
e2784f4
WIP: new file from editor.
ubidefeo Dec 18, 2024
6f025a7
WIP: dialog style.
ubidefeo Dec 18, 2024
f4e9b50
Merge branch 'development' into feature/new-file
ubidefeo Dec 18, 2024
5a7bd0f
WIP: new file dialog box.
ubidefeo Dec 19, 2024
cc93543
Removed ESC from global shortcuts to locally handle it in dialog.
ubidefeo Dec 19, 2024
1a13a43
Brought in bugfix/esc-key-event.
ubidefeo Dec 19, 2024
7fbc40c
Refactor of Tab creation and new file action/button.
ubidefeo Dec 20, 2024
ea5b620
Rework toolbar and CSS.
ubidefeo Dec 20, 2024
49d3ec8
UI font update, CSS update, labels.
ubidefeo Dec 20, 2024
5bf544d
Adjusted toolbar colours (hover) and layout.
ubidefeo Dec 20, 2024
07c7bc2
Split navigation bar actions|views.
ubidefeo Dec 21, 2024
689863a
Fixed file actions buttons states and CSS.
ubidefeo Dec 21, 2024
3a67bbb
Fixed clear state.selectedFiles.
ubidefeo Dec 21, 2024
aede0a2
Separator height adjustments.
ubidefeo Dec 21, 2024
5321c56
Merge branch 'development' into feature/new-toolbar
ubidefeo Dec 21, 2024
c996824
Toolbar: Reduced space between buttons and label.
ubidefeo Dec 21, 2024
fa82c79
Refactor menu, shortcuts, about window logic.
ubidefeo Dec 21, 2024
cc93603
Merge branch 'bugfix/about-window-issues' into feature/new-toolbar
ubidefeo Dec 21, 2024
ff5ca09
Cleaned CSS typo.
ubidefeo Dec 21, 2024
2791e00
Added New/Save shortcuts to menu.
ubidefeo Dec 21, 2024
22c541f
Merge branch 'feature/auto-connect' into feature/new-toolbar
ubidefeo Dec 21, 2024
838aa6f
Updated Connect shortcut.
ubidefeo Dec 21, 2024
9a05dd9
Cleanup unused code.
ubidefeo Dec 21, 2024
b5c766e
Concealed tooltips.
ubidefeo Dec 21, 2024
be5f149
CSS fix line-height to show underscores in come cases.
ubidefeo Dec 21, 2024
5b81693
Added META+W (close tab) and META+Q (quit).
ubidefeo Dec 21, 2024
3c1fc6c
Added multiple run safeguard to prevent too many Promises from crashi…
ubidefeo Dec 21, 2024
f442628
Transfer operations lock shortcuts. Progress is reset.
ubidefeo Dec 21, 2024
9f2adfd
Reworked panel bar to allow full area drag-to-resize.
ubidefeo Dec 21, 2024
aa91886
Clearing state.selectedFiles on open/view-switch.
ubidefeo Dec 22, 2024
828f21b
Renaming tabs/files will now reflect on the other view.
ubidefeo Dec 22, 2024
e0db436
Merge branch 'bugfix/windows-recursive-upload' into feature/new-toolbar
ubidefeo Dec 22, 2024
954010b
Fixed auto-connect for FM view and amended text to connect.
ubidefeo Mar 3, 2025
5266f50
Fixed toolbar icon opacity when disabled.
ubidefeo Mar 3, 2025
f7840ab
App views buttons made into segmented control.
ubidefeo Mar 3, 2025
505ba9a
Fixed fonts inconsistencies. Updated woff2 files.
ubidefeo Mar 3, 2025
a8a9307
WIP: migration of actions v3 to v4.
ubidefeo Mar 3, 2025
37100c8
WIP: artifacts v4 upgrade.
ubidefeo Mar 3, 2025
7483819
WIP: artifacts v4 upgrade.
ubidefeo Mar 3, 2025
8eaf584
WIP: artifacts v4 upgrade.
ubidefeo Mar 3, 2025
f68c835
WIP: artifacts v4 upgrade.
ubidefeo Mar 3, 2025
2fc901a
WIP: migrating actions v3 to v4 - universal mac build.
ubidefeo Mar 3, 2025
1f67ee6
Merge branch 'github/actions-v4' into feature/new-toolbar
ubidefeo Mar 3, 2025
6602bf5
Fixed Roboto Mono font for editor view.
ubidefeo Mar 4, 2025
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
49 changes: 30 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ jobs:
matrix:
config:
- os: [self-hosted, windows-sign-pc]
id: windows
- os: ubuntu-latest
- os: macos-13
- os: macos-14
id: linux
- os: macos-latest
id: macos-universal
runs-on: ${{ matrix.config.os }}
timeout-minutes: 90

Expand Down Expand Up @@ -92,9 +94,9 @@ jobs:
npm run build

- name: Upload [GitHub Actions]
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
name: ${{ env.JOB_TRANSFER_ARTIFACT }}-${{ matrix.config.id }}
path: dist

artifacts:
Expand All @@ -108,26 +110,29 @@ jobs:
artifact:
- path: "*-linux_x64.zip"
name: Arduino-Lab-for-MicroPython_Linux_X86-64
- path: "*-mac_x64.zip"
name: Arduino-Lab-for-MicroPython_macOS_X86-64
- path: "*-mac_arm64.zip"
name: Arduino-Lab-for-MicroPython_macOS_arm-64
id: linux
- path: "*-mac_universal.zip"
name: Arduino-Lab-for-MicroPython_macOS_Universal
id: macos-universal
# - path: "*Windows_64bit.exe"
# name: Windows_X86-64_interactive_installer
# id: windows
# - path: "*Windows_64bit.msi"
# name: Windows_X86-64_MSI
# id: windows
- path: "*-win_x64.zip"
name: Arduino-Lab-for-MicroPython_Windows_X86-64
id: windows

steps:
- name: Download job transfer artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
name: ${{ env.JOB_TRANSFER_ARTIFACT }}-${{ matrix.artifact.id }}
path: ${{ env.JOB_TRANSFER_ARTIFACT }}

- name: Upload tester build artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact.name }}
path: ${{ env.JOB_TRANSFER_ARTIFACT }}/${{ matrix.artifact.path }}
Expand All @@ -137,23 +142,25 @@ jobs:
if: github.repository == 'arduino/lab-micropython-editor' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download [GitHub Actions]
uses: actions/download-artifact@v3
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
path: ${{ env.JOB_TRANSFER_ARTIFACT }}
path: artifacts

- name: List artifacts
run: ls -R artifacts

- name: Get Tag
id: tag_name
run: |
echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Publish Release [GitHub]
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: ${{ steps.tag_name.outputs.TAG_NAME }}
file: ${{ env.JOB_TRANSFER_ARTIFACT }}/*
file: artifacts/**/*
tag: ${{ github.ref }}
file_glob: true

Expand All @@ -167,7 +174,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Remove unneeded job transfer artifact
- name: Remove unneeded job transfer artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ env.JOB_TRANSFER_ARTIFACT }}
name: |
${{ env.JOB_TRANSFER_ARTIFACT }}-windows
${{ env.JOB_TRANSFER_ARTIFACT }}-linux
${{ env.JOB_TRANSFER_ARTIFACT }}-macos-x64
${{ env.JOB_TRANSFER_ARTIFACT }}-macos-arm64
80 changes: 51 additions & 29 deletions backend/menu.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
const { app, Menu } = require('electron')
const { shortcuts, disableShortcuts } = require('./shortcuts.js')
const path = require('path')
const serial = require('./serial/serial.js').sharedInstance
const openAboutWindow = require('about-window').default
const shortcuts = require('./shortcuts.js')

const { type } = require('os')

let appInfoWindow = null

function closeAppInfo(win) {
disableShortcuts(win, false)
appInfoWindow.off('close', () => closeAppInfo(win))
appInfoWindow = null

}
function openAppInfo(win) {
if (appInfoWindow != null) {
appInfoWindow.show()
} else {
appInfoWindow = openAboutWindow({
icon_path: path.resolve(__dirname, '../ui/arduino/media/about_image.png'),
css_path: path.resolve(__dirname, '../ui/arduino/views/about.css'),
copyright: '© Arduino SA 2022',
package_json_dir: path.resolve(__dirname, '..'),
bug_report_url: "https://github.com/arduino/lab-micropython-editor/issues",
bug_link_text: "report an issue",
homepage: "https://labs.arduino.cc",
use_version_info: false,
win_options: {
parent: win,
modal: true,
},
show_close_button: 'Close',
})
appInfoWindow.on('close', () => closeAppInfo(win));
disableShortcuts(win, true)
}
}

module.exports = function registerMenu(win, state = {}) {
const isMac = process.platform === 'darwin'
const template = [
Expand All @@ -22,7 +55,22 @@ module.exports = function registerMenu(win, state = {}) {
{
label: 'File',
submenu: [
isMac ? { role: 'close' } : { role: 'quit' }
{ label: 'New',
accelerator: shortcuts.menu.NEW,
enabled: state.view === 'editor',
click: () => win.webContents.send('shortcut-cmd', shortcuts.global.NEW)
},
{ label: 'Save',
accelerator: shortcuts.menu.SAVE,
enabled: state.view === 'editor',
click: () => win.webContents.send('shortcut-cmd', shortcuts.global.SAVE)
},
{ label: 'Close tab',
accelerator: 'CmdOrCtrl+W',
enabled: state.view === 'editor',
click: () => win.webContents.send('shortcut-cmd', shortcuts.global.CLOSE)
},
{ role: 'quit' }
]
},
{
Expand Down Expand Up @@ -166,40 +214,14 @@ module.exports = function registerMenu(win, state = {}) {
},
{
label:'About Arduino Lab for MicroPython',
click: () => {
openAboutWindow({
icon_path: path.resolve(__dirname, '../ui/arduino/media/about_image.png'),
css_path: path.resolve(__dirname, '../ui/arduino/views/about.css'),
copyright: '© Arduino SA 2022',
package_json_dir: path.resolve(__dirname, '..'),
bug_report_url: "https://github.com/arduino/lab-micropython-editor/issues",
bug_link_text: "report an issue",
homepage: "https://labs.arduino.cc",
use_version_info: false,
win_options: {
parent: win,
modal: true,
},
show_close_button: 'Close',
})
}
click: () => { openAppInfo(win) }
},
]
}
]

const menu = Menu.buildFromTemplate(template)

app.setAboutPanelOptions({
applicationName: app.name,
applicationVersion: app.getVersion(),
copyright: app.copyright,
credits: '(See "Info about this app" in the Help menu)',
authors: ['Arduino'],
website: 'https://arduino.cc',
iconPath: path.join(__dirname, '../assets/image.png'),
})

Menu.setApplicationMenu(menu)

}
27 changes: 22 additions & 5 deletions backend/shortcuts.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
module.exports = {
const { globalShortcut } = require('electron')
let shortcutsActive = false
const shortcuts = {
global: {
CLOSE: 'CommandOrControl+W',
CONNECT: 'CommandOrControl+Shift+C',
DISCONNECT: 'CommandOrControl+Shift+D',
SAVE: 'CommandOrControl+S',
RUN: 'CommandOrControl+R',
RUN_SELECTION: 'CommandOrControl+Alt+R',
RUN_SELECTION_WL: 'CommandOrControl+Alt+S',
STOP: 'CommandOrControl+H',
RESET: 'CommandOrControl+Shift+R',
NEW: 'CommandOrControl+N',
SAVE: 'CommandOrControl+S',
CLEAR_TERMINAL: 'CommandOrControl+L',
EDITOR_VIEW: 'CommandOrControl+Alt+1',
FILES_VIEW: 'CommandOrControl+Alt+2',
ESC: 'Escape'
},
menu: {
CLOSE: 'CmdOrCtrl+W',
CONNECT: 'CmdOrCtrl+Shift+C',
DISCONNECT: 'CmdOrCtrl+Shift+D',
SAVE: 'CmdOrCtrl+S',
RUN: 'CmdOrCtrl+R',
RUN_SELECTION: 'CmdOrCtrl+Alt+R',
RUN_SELECTION_WL: 'CmdOrCtrl+Alt+S',
STOP: 'CmdOrCtrl+H',
RESET: 'CmdOrCtrl+Shift+R',
NEW: 'CmdOrCtrl+N',
SAVE: 'CmdOrCtrl+S',
CLEAR_TERMINAL: 'CmdOrCtrl+L',
EDITOR_VIEW: 'CmdOrCtrl+Alt+1',
FILES_VIEW: 'CmdOrCtrl+Alt+2'
}
},
// Shortcuts
}

function disableShortcuts (win, value) {
console.log(value ? 'disabling' : 'enabling', 'shortcuts')
win.send('ignore-shortcuts', value)
}

module.exports = {
shortcuts,
disableShortcuts
}

23 changes: 4 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { app, BrowserWindow, ipcMain, dialog, globalShortcut } = require('electron')
const path = require('path')
const fs = require('fs')
const shortcuts = require('./backend/shortcuts.js').global

const registerIPCHandlers = require('./backend/ipc.js')
const registerMenu = require('./backend/menu.js')

Expand Down Expand Up @@ -63,28 +61,15 @@ function createWindow () {
})
}

function shortcutAction(key) {
win.webContents.send('shortcut-cmd', key);
}

// Shortcuts
function registerShortcuts() {
Object.entries(shortcuts).forEach(([command, shortcut]) => {
globalShortcut.register(shortcut, () => {
shortcutAction(shortcut)
});
})
}

app.on('ready', () => {
createWindow()
registerShortcuts()

win.on('focus', () => {
registerShortcuts()
console.log("win focus")
})

win.on('blur', () => {
globalShortcut.unregisterAll()
console.log("win blur")
})

})
})
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"artifactName": "${productName}-${os}_${arch}.${ext}",
"extraResources": "./ui/arduino/helpers.py",
"mac": {
"target": "zip",
"target": [{
"target": "zip",
"arch": ["universal"]
}],
"icon": "build_resources/icon.icns"
},
"win": {
Expand Down
7 changes: 6 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
console.log('preload')
const { contextBridge, ipcRenderer } = require('electron')
const path = require('path')
const shortcuts = require('./backend/shortcuts.js').global
const shortcuts = require('./backend/shortcuts.js').shortcuts.global
const { emit, platform } = require('process')
const SerialBridge = require('./backend/serial/serial-bridge.js')

Expand Down Expand Up @@ -63,6 +63,11 @@ const Window = {
callback(k);
})
},
onDisableShortcuts: (callback, value) => {
ipcRenderer.on('ignore-shortcuts', (e, value) => {
callback(value);
})
},

beforeClose: (callback) => ipcRenderer.on('check-before-close', callback),
confirmClose: () => ipcRenderer.invoke('confirm-close'),
Expand Down
1 change: 1 addition & 0 deletions ui/arduino/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<!-- Components -->
<script type="text/javascript" src="views/components/code-editor.js" charset="utf-8"></script>
<script type="text/javascript" src="views/components/connection-dialog.js" charset="utf-8"></script>
<script type="text/javascript" src="views/components/new-file-dialog.js" charset="utf-8"></script>
<script type="text/javascript" src="views/components/file-actions.js" charset="utf-8"></script>
<script type="text/javascript" src="views/components/file-list.js" charset="utf-8"></script>
<script type="text/javascript" src="views/components/repl-panel.js" charset="utf-8"></script>
Expand Down
Loading