-
Notifications
You must be signed in to change notification settings - Fork 7
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
[WS-31] windows integrated titlebar #102
Conversation
WS-31 integrated titlebar/menubar UI for Windows, like on macOS
see what we can do, Windows looks ugly with the default title bar design (see screenshot) notes from Faris: https://replit.slack.com/archives/C0509G0FJNL/p1683158097198949 |
will check this in a bit with the web PR checked out - in the meantime looks like you have some conflicts here from the other PR |
thanks; conflicts fixed :) |
src/createWindow.ts
Outdated
titleBarOverlay: { | ||
color: backgroundColor, | ||
symbolColor: foregroundColor, | ||
height: 44, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this the same height as the above for consistency? i.e. 48px esp since that's more consistent with RUI values and matches some of our other header heights
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we go with 48
then the hover state of the windows native button touches the top of the pane below it, which looks unintentional/wrong, considering we have 4px padding in most places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea we have paddings everywhere so feels weird to me that it suddenly touches the pane... maybe worth circulating with #design for another opinion 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah agree worth asking. feel like at the OS level it's ok to be flush with the pane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asked here looks like 48px is the preferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will update together with the other changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not hardcoded, it just defaults to the background/foreground from the dark theme, but then uses the colors recorded when we close the window: Lines 171 to 184 in e6a0243
This obviously will break if we have a mismatch between stored/current colors, like if we change the theme without restarting the app. One possible way forward would be to expose some version of https://www.electronjs.org/docs/latest/api/browser-window#winsettitlebaroverlayoptions-windows through the electron API, and allow the client to change the color when we change the theme. What do you think @sergeichestakov? |
hmm it doesn't seem to restore for me in light mode (in other words, I still see the dark mode colors regardless). and yeah we're going to want to go with an approach that is resilient to switching themes |
ok cool, I'll switch it to draft and will update soon |
nvm looks like it does when I close and re-open a window (think I was just opening a window before without closing after switching themes) |
Yea that's what I was trying to say -- we only update when we close the window, so it's easy to get into a stale state, I think we should expose this through the API so we can switch colors dynamically. |
src/createWindow.ts
Outdated
color: backgroundColor, | ||
symbolColor: foregroundColor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not affect Mac styling in the context of this PR? I think using CSS vars is the ideal solution if it works on MacOS. Looks like we'll have to find a different approach on Windows but don't see a reason to switch on Mac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these actually don't do anything on macOS, I'll drop them completely
@sergeichestakov I updated the code with comments, and added an event to notify on theme change, so we get this: Screenshot.2023-08-21.at.11.01.17.movI tested on macOS and Windows, but would be good for you to test as well. Since this depends on a new desktop app API event, you should test together with recent changes in https://github.com/replit/repl-it-web/pull/35147 |
src/createWindow.ts
Outdated
titleBarStyle: "hidden", | ||
titleBarOverlay: { | ||
color: "var(--background-root)", | ||
symbolColor: "var(--foreground-default)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color
/symbolColor
does nothing on macOS -- it's a Windows thing only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exciting! let's just pass the theme values in directly as part of the IPC call? otherwise I see a flash in the transparent header when switching themes because the old values persist for a split second
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. let's just make it an object arg rather than positional. also some merge conflicts to fix. I can take over
src/preload.ts
Outdated
@@ -48,6 +48,8 @@ contextBridge.exposeInMainWorld('replitDesktop', { | |||
ipcRenderer.invoke(events.SHOW_MESSAGE_BOX, params), | |||
onEnterFullscreen: makeEventHandler(events.ON_ENTER_FULLSCREEN), | |||
onLeaveFullscreen: makeEventHandler(events.ON_LEAVE_FULLSCREEN), | |||
themeChanged: (backgroundColor: string, foregroundColor: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going to want to an object param here rather than multiple positional params since we may add more values down the line (for instance, if we want to send the full theme over).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also: we should just be explicit here what theme values these correspond to. e.g. backgroundRoot
and foregroundDefault
rather than just backgroundColor
, foregroundColor
since, again, we may want to send more at some point and this will be easier to pass down directly from the theme values on the client
src/createWindow.ts
Outdated
@@ -76,13 +76,17 @@ function isInBounds(rect: Rectangle) { | |||
}); | |||
} | |||
|
|||
async function getLastSeenBackgroundColor( | |||
export async function getColorsFromWindow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we need to export as this isn't used anywhere else
src/preload.ts
Outdated
@@ -48,6 +48,8 @@ contextBridge.exposeInMainWorld('replitDesktop', { | |||
ipcRenderer.invoke(events.SHOW_MESSAGE_BOX, params), | |||
onEnterFullscreen: makeEventHandler(events.ON_ENTER_FULLSCREEN), | |||
onLeaveFullscreen: makeEventHandler(events.ON_LEAVE_FULLSCREEN), | |||
themeChanged: (backgroundColor: string, foregroundColor: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also: we should just be explicit here what theme values these correspond to. e.g. backgroundRoot
and foregroundDefault
rather than just backgroundColor
, foregroundColor
since, again, we may want to send more at some point and this will be easier to pass down directly from the theme values on the client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the API a bit and did some minor refactoring. thanks for pushing this forward!
Why
Integrated titlebar on Windows like on macOS:
Needs https://github.com/replit/repl-it-web/pull/35147 to be merged.
What changed
var(--background-root)
in platform styling is not working on Windows, so changed to usegetLastSeenBackgroundColor
(and newgetLastSeenForegroundColor
)Test plan
Check out the screenshots.