mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Merge branch 'colorpicker' into next
This commit is contained in:
commit
c156c049c2
@ -1670,10 +1670,15 @@ const BARS = {
|
||||
'slider_color_h',
|
||||
'slider_color_s',
|
||||
'slider_color_v',
|
||||
'add_to_palette'
|
||||
'add_to_palette',
|
||||
'pick_screen_color'
|
||||
]
|
||||
})
|
||||
|
||||
if (isApp) {
|
||||
Blockbench.onUpdateTo('3.9', () => {
|
||||
Toolbars.animations.add(BarItems.pick_screen_color);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Toolbars.display = new Toolbar({
|
||||
|
@ -781,5 +781,13 @@ BARS.defineActions(function() {
|
||||
ColorPanel.updateFromHsv();
|
||||
}
|
||||
})
|
||||
new Action('pick_screen_color', {
|
||||
icon: 'colorize',
|
||||
category: 'color',
|
||||
condition: isApp,
|
||||
click: function () {
|
||||
ipcRenderer.send('request-color-picker', {sync: settings.sync_color.value});
|
||||
}
|
||||
})
|
||||
})
|
||||
})()
|
||||
|
@ -897,6 +897,8 @@
|
||||
"action.sort_palette.desc": "Sort all colors on the palette by color and brightness",
|
||||
"action.load_palette": "Load Palette",
|
||||
"action.load_palette.desc": "Load one of the built-in palette presets",
|
||||
"action.pick_screen_color": "Pick Screen Color",
|
||||
"action.pick_screen_color.desc": "Pick a color from somewhere on your screen",
|
||||
|
||||
"action.transform_space": "Transform Space",
|
||||
"action.transform_space.desc": "Default transform space for elements and bones",
|
||||
|
13
main.js
13
main.js
@ -3,6 +3,7 @@ const path = require('path')
|
||||
const url = require('url')
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const fs = require('fs');
|
||||
const {getColorHexRGB} = require('electron-color-picker')
|
||||
|
||||
let orig_win;
|
||||
let all_wins = [];
|
||||
@ -169,6 +170,18 @@ ipcMain.on('change-main-color', (event, arg) => {
|
||||
ipcMain.on('edit-launch-setting', (event, arg) => {
|
||||
LaunchSettings.set(arg.key, arg.value);
|
||||
})
|
||||
ipcMain.on('request-color-picker', async (event, arg) => {
|
||||
const color = await getColorHexRGB().catch((error) => {
|
||||
console.warn('[Error] Failed to pick color', error)
|
||||
return ''
|
||||
})
|
||||
if (color) {
|
||||
all_wins.forEach(win => {
|
||||
if (win.isDestroyed() || (!arg.sync && win.webContents != event.sender.webContents)) return;
|
||||
win.webContents.send('set-main-color', color)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
app.on('ready', () => {
|
||||
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -2835,6 +2835,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"electron-color-picker": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/electron-color-picker/-/electron-color-picker-0.2.0.tgz",
|
||||
"integrity": "sha512-SaTn7GPpIRw3K36Q2ZnRFup0ZqEgRWfu2Q/fO/jXcRFtrzvsDqFLDCzU69mwcDvCsqiFGKbQfXQPVYsqUWbjfA=="
|
||||
},
|
||||
"electron-notarize": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.0.0.tgz",
|
||||
|
@ -105,6 +105,7 @@
|
||||
"workbox-build": "^6.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-color-picker": "^0.2.0",
|
||||
"electron-updater": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user