Skip to content

Commit

Permalink
Merge pull request #57 from maykbrito/feat/dimensions
Browse files Browse the repository at this point in the history
Feat: Custom dimensions
  • Loading branch information
maykbrito authored Nov 14, 2021
2 parents 4851c42 + f1e4ed2 commit 0e9ae44
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
9 changes: 8 additions & 1 deletion electron/lib/ScreenController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserWindow, screen } from 'electron'
import { userPreferences } from '../store'

type ScreenSize = 'initial' | 'large'

Expand Down Expand Up @@ -35,7 +36,13 @@ export class ScreenController {
this.currentScreenEdge = initialScreenEdge
this.currentScreenSize = initialScreenSize

this.screenSizes = { initial: 300, large: 600 }
const {
store: { screen },
} = userPreferences
this.screenSizes = {
initial: screen.initial.width,
large: screen.large.width,
}

const { x, y } = this.browserWindow.getBounds()

Expand Down
14 changes: 10 additions & 4 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,20 @@ async function createTrayContextMenu() {
* Create main electron window
*/
async function createWindow() {
const {
store: {
screen: { initial },
},
} = userPreferences

win = new BrowserWindow({
icon: nativeImage.createFromPath(
path.join(assetsPath, 'assets', 'icon.png')
),
width: 300,
height: 300,
maxWidth: 300,
maxHeight: 300,
width: initial.width,
height: initial.height,
maxWidth: initial.width,
maxHeight: initial.height,
frame: false,
titleBarStyle: 'customButtonsOnHover',
transparent: true,
Expand Down
37 changes: 37 additions & 0 deletions electron/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ const userPreferencesSchema: Schema<unknown> = {
},
},
},
screen: {
type: JSONSchemaType.Object,
properties: {
initial: {
type: JSONSchemaType.Object,
properties: {
width: {
type: JSONSchemaType.Number,
},
height: {
type: JSONSchemaType.Number,
},
},
},
large: {
type: JSONSchemaType.Object,
properties: {
width: {
type: JSONSchemaType.Number,
},
height: {
type: JSONSchemaType.Number,
},
},
},
},
},
rounded: {
type: JSONSchemaType.Boolean,
},
Expand Down Expand Up @@ -112,6 +139,16 @@ export const userPreferences = new Store({
},
hideCamera: 'Shift+Alt+CommandOrControl+3',
},
screen: {
initial: {
width: 300,
height: 300,
},
large: {
width: 600,
heigth: 600,
},
},
rounded: true,
clipPath: '',
flipHorizontal: false,
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const config = {
borderColorCss: userPreferences.borderColorCss,
showBorder: userPreferences.showBorder,
clipPath: userPreferences.clipPath,
screenInitialWidth: userPreferences.screen.initial.width,
screenInitialHeight: userPreferences.screen.initial.height,
screenLargeWidth: userPreferences.screen.large.width,
screenLargeHeight: userPreferences.screen.large.height,
}

export { config }

0 comments on commit 0e9ae44

Please sign in to comment.