Skip to content

Commit

Permalink
poprawki na ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
kartofelek007 committed Apr 8, 2020
1 parent 85f51f2 commit 4a35bc9
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 83 deletions.
29 changes: 29 additions & 0 deletions css/pick-color.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,33 @@ body {
}
#optCanvas {
pointer-events: none;
}

.color-picker-close {
display: none;
z-index: 2;
position: absolute;
right: 0;
top: 0;
width: 70px;
height: 70px;
background: #222;
border:0;
cursor: pointer;
outline: none;
}
.color-picker-close::before,
.color-picker-close::after {
content: "";

width: 30px;
height: 3px;
background: #fff;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(45deg);
}
.color-picker-close::after {
transform: translate(-50%, -50%) rotate(-45deg);
}
3 changes: 1 addition & 2 deletions js/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const paletteElement = document.querySelector("#palette");

export const attachNewColor = function(color) {
const element = createPaletteElement(color);
paletteElement.append(element);
paletteElement.prepend(element);
}

export const createPaletteElement = function(color) {
Expand Down Expand Up @@ -95,7 +95,6 @@ const drag = new DragDrop('#palette', {
const elements = paletteElement.querySelectorAll(".palette-element");
const palette = [...elements].map(el => el.dataset.color);
saveColorsToFile(palette);
saveColorsToFile(palette);
},
className : "palette-element"
});
Expand Down
39 changes: 25 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,23 @@ const myApp = {
mainWindow: null,
contextMenu: false,
pickedWindow: null,
windowOpen: false,
menu: null,
tray: null, //musi byc globalne bo inaczej garbage collector sprawia ze nie mia ikonki w trayu

toggleMainWindow() {

if (this.windowOpen) {
this.windowOpen = false;
toggleMainWindow(show) {
if (!show) {
this.mainWindow.hide();
console.log(this.windowOpen);
} else {
this.windowOpen = true;
this.mainWindow.show();
this.mainWindow.restore();
console.log(this.windowOpen);
}
},

createMainWindow() {
const { width: screenW, height: screenH } = screen.getPrimaryDisplay().workAreaSize;

this.mainWindow = new BrowserWindow({
icon: path.join(__dirname, '/images/icon.ico'),
icon: path.join(__dirname, '/images/icon.png'),
width: 360,
height: screenH,
x: screenW - 360,
Expand All @@ -53,19 +47,19 @@ const myApp = {

this.mainWindow.loadFile('index.html');

this.mainWindow.hide();
//this.mainWindow.hide();

this.mainWindow.on('minimize', e => {
e.preventDefault();
this.mainWindow.hide();
});

const imgPath = path.join(__dirname, '/images/icon.ico');
const imgPath = path.join(__dirname, '/images/icon.png');

this.tray = new Tray(imgPath);
this.tray.setToolTip('kolory');
this.tray.on('click', () => {
this.toggleMainWindow();
this.toggleMainWindow(true);
});

Menu.setApplicationMenu(null);
Expand Down Expand Up @@ -96,9 +90,15 @@ const myApp = {
},

createColorPickWindow() {
const { width: screenW, height: screenH } = screen.getPrimaryDisplay().workAreaSize;

this.pickedWindow = new BrowserWindow({
icon: path.join(__dirname, './images/icon.ico'),
icon: path.join(__dirname, './images/icon.png'),
fullscreen: true,
// x: 0,
// y : 0,
// width: screenW,
// height: screenH,
alwaysOnTop: true,
movable: false,
minimizable: false,
Expand All @@ -112,16 +112,24 @@ const myApp = {
}
});

//this.pickedWindow.webContents.openDevTools()

this.pickedWindow.loadFile('pick-color.html');
this.pickedWindow.once('ready-to-show', () => {
this.pickedWindow.show();
});
//pickedWindow.webContents.openDevTools()
//this.pickedWindow.webContents.openDevTools()
},

bindCommunication() {
ipcMain.on('createColorPickWindow', (event, file, content) => {
this.createColorPickWindow();
this.mainWindow.hide();
});

ipcMain.on('closeColorPickWindow', (event, file, content) => {
this.pickedWindow.close();
this.toggleMainWindow(true);
});

ipcMain.on('colorPicked', (event, messages) => {
Expand All @@ -130,6 +138,9 @@ const myApp = {
},

init() {
app.commandLine.appendSwitch('disable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');

app.on('ready', () => {
this.createMainWindow();
this.createContextMenu();
Expand Down
87 changes: 75 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pick-color.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="css/pick-color.css">
</head>
<body>
<button class="color-picker-close"></button>
<canvas id="mainCanvas"></canvas>
<canvas id="optCanvas"></canvas>
<script src="renderer-pick-color.js" type="module"></script>
Expand Down
Loading

0 comments on commit 4a35bc9

Please sign in to comment.