Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

replace OSX window title bar with custom title-bar - #11790

Merged
nathansobo merged 21 commits into
atom:masterfrom
brumm:master
Aug 2, 2016
Merged

nathansobo merged 21 commits into
atom:masterfrom
brumm:master

Conversation

@brumm

@brumm brumm commented May 19, 2016 •

Copy link
Copy Markdown

This pull request is intended to naively implement a custom titlebar on OSX.

I've included fallback styling to match El Capitan's titlebars, which is probably not necessary as I modified the four included themes to provide their own titlebar styling. I'll create PRs for these in their respective repositories if this PR gets considered.

I'd like to hear your thoughts on the implementation, I just banged on the code until it worked 😁

This is what it looks like by default:
image

This is the titlebar provided by one-dark-ui, with the oceanic-next syntax
image

This is one-light-ui, with the atom-light syntax
image

Things left to do:

  • ✅ specs

This is a partial continuation of #10208 albeit without the combined title-bar-and-tabs functionality, for which this would be the groundwork. (As requested in #4599 for example.)

@FezVrasta

FezVrasta commented May 20, 2016 •

Copy link
Copy Markdown

@brumm Any chance to get rid of the black separation line between the title bar and the three file view? I think it would look much better.

image

@brumm

brumm commented May 20, 2016

Copy link
Copy Markdown
Author

@FezVrasta These screenshots are just a first stab at theming the title-bar and intended to show what it could look like. At any rate, you could always remove that line by tinkering with your user stylesheet :)

@simurai Would you like me to go ahead and create some PRs on https://github.com/atom/one-dark-ui/ and https://github.com/atom/one-light-ui/?

@simurai

simurai commented May 21, 2016

Copy link
Copy Markdown
Contributor

I wonder if the background should just be @base-background-color? So that "abandoned, but still in use" themes would adapt too. Then maybe make a PR with the current grey gradient for themes that try to stay close to OS X. Like unity-ui or native-ui.

Comment thread src/atom-environment.coffee Outdated
@deserialize(state) if state?
@deserializeTimings.atom = Date.now() - startTime

@document.body.appendChild(@views.getView(@titleBar)) if @titleBar

@simurai simurai May 21, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add the title bar into the atom-panel-container.header with addHeaderPanel().

Then eventually you could do some funky stuff like (visually) combining the title-bar with the tool-bar:

screen shot 2016-05-20 at 5 30 32 pm

Probably not by default, but maybe just restyle it in styles.less or as an option in the tool-bar package.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's exactly what I was wondering as well. It seemed easier for now to stick the title-bar above the atom-workspace, but I was hoping to also support the combined title-bar as well.

I thought the combined titlebar might primarily be hosting the tab-bar, which might be pragmatic for a start, toolbars do sound funky though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the combined titlebar might primarily be hosting the tab-bar, which might be pragmatic for a start, toolbars do sound funky though.

Only visually maybe, but tab-bars have to live inside panes. Because they can be split into different directions and each pane as its own tab-bar.

Anyways, I think for now it would be safer to add the title-bar into the .header. Because the changes to workspace-view.less might invite other packages to add their bars or other UI stuff outside of atom-workspace. With the addXXXPanel() all panels can be kept a bit more under control.

@brumm

brumm commented May 21, 2016

Copy link
Copy Markdown
Author

I wonder if the background should just be @base-background-color?

That's a much better idea than using the grey gradient! I'll change it.

@brumm

brumm commented May 21, 2016

Copy link
Copy Markdown
Author

atom-dark with a title-bar gradient based on @base-background-color
image

@FezVrasta

Copy link
Copy Markdown

What's the status of this PR? I think the top grey bar is one of the most annoying things of Atom. If I have to use it the whole day I need a pleasant environment, and that gray bar doesn't help at all 😓

In my opinion, this PR should have high priority.

@olegakbarov

olegakbarov commented May 22, 2016 •

Copy link
Copy Markdown

I just can't stress how awesome and cool this thing looks to me. Would love to see it!

@lee-dohm

Copy link
Copy Markdown
Contributor

Let us know when you have the specs complete for this @brumm 😀

Comment thread static/title-bar.less Outdated
align-items: center;
justify-content: center;

font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't have to force a font-family and just let it inherit whatever the theme defined. The One themes use the system font, but some themes might wanna use something else.

@simurai

simurai commented May 24, 2016

Copy link
Copy Markdown
Contributor

Made a few more comments.. sorry.. 😇 I tried to make a PR to your PR, but your fork somehow didn't show up in the list to compare against.

@brumm

brumm commented May 24, 2016

Copy link
Copy Markdown
Author

Thanks for the comments! All good points. I'll be able to work on this in a few hours 👍

@brumm

brumm commented May 25, 2016

Copy link
Copy Markdown
Author

@simurai i made a couple of changes:

  • followed your advice and added title-bar as a headerPanel instead, which allowed me to undo the changes I made to workspace styling
  • moved title-bar variables into title-bars' less file and simplified the styling to a single background-color: @base-background-color. After much back-and-forth I decided against @tab-bar-background-color to preserve some contrast between title-bar and the rest of the UI, but I do like both.
  • cleaned up some superfluous code from title-bar-element and added a simple test

@brumm
brumm force-pushed the master branch 3 times, most recently from 094563a to 6159970 Compare May 25, 2016 14:24
@FezVrasta

FezVrasta commented May 25, 2016 •

Copy link
Copy Markdown

I'm for @tab-bar-background-color, it would look much better

@brumm

brumm commented May 25, 2016

Copy link
Copy Markdown
Author

@tab-bar-background-color
image

@base-background-color
image

@brumm

brumm commented May 25, 2016

Copy link
Copy Markdown
Author

As far as I can tell, the failed travis build doesn't seem to be related to my changes.
Should I squash now or after another once-over?
@lee-dohm @simurai

@simurai

simurai commented May 26, 2016

Copy link
Copy Markdown
Contributor

After much back-and-forth I decided against @tab-bar-background-color to preserve some contrast between title-bar and the rest of the UI, but I do like both.

Yeah, sounds good. For the bundled One + Atom themes, we can still thinking about customizing it. Also having a border by default should help make it clear where you can start dragging the window.

@FezVrasta In case your favorite theme doesn't look seamless, you could always make it transparent in your styles.less with:

.title-bar {
  background-color: transparent;
  border-color: transparent;
}

Should I squash now or after another once-over?

Only if you want, so far we haven't really bothered about it. Maybe one day we will enable it on the merge button, now that GitHub added that feature.

As far as I can tell, the failed travis build doesn't seem to be related to my changes.

Ya, looks like an unlreated timeout.

@simurai

simurai commented May 26, 2016

Copy link
Copy Markdown
Contributor

ok, so the styling is 👍

So hopefully we can get somebody from @atom/core to take a look at the code. And maybe @amytruong can give it another test drive?

Comment thread src/main-process/atom-window.coffee Outdated
options =
show: false
title: 'Atom'
titleBarStyle: 'hidden'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance of this ever doing something on platforms other than OS X? If so, I think it'd be nice to specifically check for the platform here, since we're also explicitly checking it in atom-environment, and we don't want it to accidentally get out of sync.

@brumm brumm May 27, 2016 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to check for darwin as well, thanks for the heads up!

@brumm

brumm commented Aug 22, 2016 •

Copy link
Copy Markdown
Author

@FezVrasta The window controls are drawn by the OS and positions can't be changed indivdually.
You might get some milage out of changing titleBarStyle to hidden-inset which moves the controls a bit further down, but also increases the size of the title bar.

I always figured that we'd have to completely hide the titlebar to support the 'tabs-on-top' style proposed in #10208, and dynamically switch draggable areas on and off with css.

That's what I came up with the other day:

screen shot 2016-07-11 at 18 12 38

Edit: this stuff is not feasible yet because it needs this fix electron/electron#5557 which is available from [email protected] and up

@FezVrasta

FezVrasta commented Aug 22, 2016 •

Copy link
Copy Markdown

Thanks for the reply. If it can be helpful I posted my custom CSS at #10208 (comment)

@anaisbetts

Copy link
Copy Markdown
Contributor

@brumm We came up with that design too - it looks great but the problem is that objects in the non-client area (i.e. the invisible bar from the traffic lights onward) cannot be dragged, so reordering tabs is busted 😢

@controversial

Copy link
Copy Markdown

Couldn't we hide the title bar altogether, and create fake window buttons with CSS, as shown here? @paulcbetts @brumm

@silvestreh

Copy link
Copy Markdown

@controversial In Atom's case, window buttons are rendered by the OS and can't be changed.

@controversial

Copy link
Copy Markdown

@silvestreh Why couldn't that be changed? This is a PR to the atom core...

@silvestreh

Copy link
Copy Markdown

@controversial This is what the titlebar's DOM element looks like:

captura de pantalla 2016-09-02 a las 11 12 50 a m

As you can see, the buttons aren't part of the DOM. You can't style them with CSS because the window manager, not Chrome, is rendering them.

AFAIK, you can't move, resize, nor hide them.

@controversial

Copy link
Copy Markdown

You can spawn a frameless window, which would hide the title bar completely, then you could emulate the buttons using custom CSS. https://github.com/electron/electron/blob/master/docs/api/frameless-window.md

Maybe this isn't available in the version of Electron atom is on though.

@thomasjo

thomasjo commented Sep 2, 2016

Copy link
Copy Markdown
Contributor

Maybe this isn't available in the version of Electron atom is on though.

This does indeed require a more modern Electron. We're very close to shipping #12300 though 🎉

@controversial

Copy link
Copy Markdown

Ah, great. I'll look forward to #12300 😃

@sveggiani

Copy link
Copy Markdown

@controversial I think it's not a good practice to replace native OS UI controls. They are a hell to maintain and avoids OS level customization and third party software control over them.

@controversial

Copy link
Copy Markdown

Yeah, you're probably right. Waiting for the newer Electron version will be a much better choice.

@keplersj

keplersj commented Oct 10, 2016 •

Copy link
Copy Markdown

I love this addition so much! I'm just trying it out right now but I've noticed a little bit of extra black under the bar with Nuclide. Not sure if this an Atom issue or a Nuclide issue.
screen shot 2016-10-10 at 12 17 00 pm
Not a huge issue, just thought it was worth noting.

Edit: I think it's definitely a Nuclide issue, the Buck task bar makes the black bar super apparent.
screen shot 2016-10-10 at 12 23 57 pm

Edit: Definitely Nuclide
screen shot 2016-10-10 at 12 29 23 pm

@Daniel15

Copy link
Copy Markdown

Any plans to have something like this for other operating systems, given 57% of the Atom userbase is on Linux or Windows? 😄

You can spawn a frameless window, which would hide the title bar completely, then you could emulate the buttons using custom CSS

I agree with @sveggiani... Emulating native OS controls is tricky and very difficult to maintain. It's better to use the native APIs to render the native controls (for example, I believe the title bar of Google Chrome does it this way). This used to be reasonably common with native apps on Windows, I don't know if Electron exposes this functionality though.

@controversial

Copy link
Copy Markdown

@Daniel15 Electron does expose this, but only in a version of Electron that's later than the one Atom uses. I think a fake control would be good for the short term, using the native controls once we get to that version of Electron.

@controversial

Copy link
Copy Markdown

Now that Atom is on a modern Electron version can we do this? I really like @brumm's solution, even though the tabs can't be reordered. Hyper does this and the tabs aren't reorderable, but it never really bothers me. If this was an option that could be enabled by users, I think it'd be great to include some kind of solution in the Atom core.

@lacostenycoder

Copy link
Copy Markdown

I'm probably late to the party, but is there any way I can do this currently? Is there a dev branch or beta release with this enabled?

@MaximSokolov

Copy link
Copy Markdown
Contributor

@lacostenycoder, look for Title Bar option in latest stable Atom release

@lacostenycoder

Copy link
Copy Markdown

@MaximSokolov, already found that thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.