r/javascript • • Nov 10 '18

Goodbye Electron, Hello Desktop PWAs

https://medium.com/@novicki_david/goodbye-electron-hello-desktop-pwas-f316b8f39882
363 Upvotes

168 comments sorted by

View all comments

Show parent comments

2

u/State_ Nov 10 '18

I just played around with a UWP app using the following code w/ c++

auto coreTitleBar = CoreApplication::GetCurrentView()->TitleBar;
coreTitleBar->ExtendViewIntoTitleBar = true;

This was the end result: https://i.imgur.com/Y5aVP0l.png

you can draw your own custom title bar, but the caption buttons in the top right cannot be changed. The CoreTitleBar class has properties that tell you the dimensions to draw your own title bar.

The caption buttons are automatically hidden if you go to full screen however.

EDIT: that code goes inside of App::OnLaunched() function

1

u/[deleted] Nov 10 '18

Was that running locally interacting with the twitter app or injected into the running process? Apologies for my naivety.

2

u/State_ Nov 10 '18

No, it was running on my own local app that I created to test it out. It seems like you can't inject it into running processes without doing some extra black magic.

1

u/[deleted] Nov 10 '18

And was your local app a UWP one?

2

u/State_ Nov 10 '18

Uwp

1

u/[deleted] Nov 10 '18

And that link you posted above mentions that only color alteration is available to apps built with HTML. So it’s safe to assume we can change the title bar color using the WinRT API Windows.UI.ViewManagement which is progress! (Thinking about it, doesn’t the twitter app change the titlebar color when switching to dark mode?) 👍

1

u/State_ Nov 10 '18

No, you can use a completely custom title bar.

https://i.imgur.com/Q6aAaot.png

quick example using the toolbar.

You just need to account for the caption buttons on the right hand side when you create it.

1

u/[deleted] Nov 10 '18

You can from a c++ UWP but that MS link mentions (in the purple ‘note’ section) that only titlebar color is able to be manipulated from C# or HTML apps. I assumed (rightly or wrongly) that a PWA would be classified under this implementation.

1

u/State_ Nov 10 '18

you can do it with C# as well.

If you read further down there's plenty of examples. I suggest reading the entire page if you are interested in manipulating the title bar.

1

u/[deleted] Nov 10 '18

From MS site:

Note Simple color customization is available to UWP apps using XAML, DirectX, and HTML. Full customization is available only to UWP apps using XAML.

I take that to mean only XAML apps can do full customization (so yep I was wrong about the implementation language being important, sorry I misread) still I don’t know how MS implemented the window? (If it does use XAML then maybe it’s possible for us to customise the titlebar, otherwise it might just be color we can alter)

→ More replies (0)