Skip to content

Commit

Permalink
Windows title bar fixes and custom per-platform styling to keep origi…
Browse files Browse the repository at this point in the history
…nal behaviour.
  • Loading branch information
joethephish committed May 17, 2024
1 parent 507174a commit 0b8814b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
15 changes: 12 additions & 3 deletions app/main-process/projectWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ const Inklecate = require("./inklecate.js").Inklecate;
const Menu = electron.Menu;
const i18n = require("./i18n/i18n.js");

const electronWindowOptions = {
var electronWindowOptions = {
width: 1300,
height: 730,
minWidth: 350,
minHeight: 250,
titleBarStyle: 'hidden',
titleBarOverlay: true,
webPreferences: {
preload: path.join(__dirname, '..', 'renderer', 'preload.js'),
nodeIntegration: true,
Expand All @@ -23,6 +21,12 @@ const electronWindowOptions = {

};


if( process.platform == "darwin" ) {
electronWindowOptions.titleBarStyle = 'hidden';
electronWindowOptions.titleBarOverlay = true;
}

var windows = [];

const recentFilesPath = path.join(electron.app.getPath("userData"), "recent-files.json");
Expand Down Expand Up @@ -365,4 +369,9 @@ ipc.on("project-settings-needs-reload", (event, rootInkFilePath) => {
win.refreshProjectSettings(rootInkFilePath);
});

ipc.on("set-native-window-title", (event, newWindowTitle) => {
var win = ProjectWindow.withWebContents(event.sender);
win.browserWindow.title = newWindowTitle;
});

exports.ProjectWindow = ProjectWindow;
7 changes: 6 additions & 1 deletion app/renderer/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ ToolbarView.setEvents({
PlayerView.previewStepBack();
LiveCompiler.stepBack();
},
rewind: () => { LiveCompiler.rewind(); }
rewind: () => { LiveCompiler.rewind(); },
didSetTitle: (title) => {
if( process.platform == "win32" ) {
ipc.send("set-native-window-title", title);
}
}
});

NavView.setEvents({
Expand Down
3 changes: 2 additions & 1 deletion app/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

<script>
// Add the platform name as a class on the root HTML element for custom CSS
//document.getElementsByTagName("html")[0].classList.add(process.platform);
// platform is a variable exposed in preload.js
document.getElementsByTagName("html")[0].classList.add(platform);
</script>

</head>
Expand Down
6 changes: 3 additions & 3 deletions app/renderer/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ h1.title {
}

.win32 #toolbar, .linux #toolbar {
height: 30px;
background: #f0f0f0;
height: 34px;
background: white;
}

.win32 h1.title, .linux h1.title {
Expand Down Expand Up @@ -516,7 +516,7 @@ img.issue-icon.warning {
}

.win32 #main, .linux #main {
top: 30px;
top: 34px;
}

#editor {
Expand Down
2 changes: 2 additions & 0 deletions app/renderer/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ window.addEventListener('DOMContentLoaded', () => {
});
});
});

window.platform = process.platform;
4 changes: 3 additions & 1 deletion app/renderer/toolbarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const i18n = require("./i18n.js");
var events = {
rewind: () => {},
stepBack: () => {},
selectIssue: () => {}
selectIssue: () => {},
didSetTitle: () => {}
};

function updateIssueSummary(issues, issueClickCallback) {
Expand Down Expand Up @@ -157,6 +158,7 @@ $(document).ready(function() {

function setTitle(title) {
$("h1.title").text(title);
events.didSetTitle(title);
}

function setBusySpinnerVisible(vis) {
Expand Down

0 comments on commit 0b8814b

Please sign in to comment.