Skip to content
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

Native Menu Support #43

Open
MikeYeager opened this issue Mar 11, 2021 · 34 comments
Open

Native Menu Support #43

MikeYeager opened this issue Mar 11, 2021 · 34 comments
Labels
enhancement New feature or request macOS Only on macOS

Comments

@MikeYeager
Copy link
Collaborator

Allow user to manipulate OS menu
By passing in JSON for initialization
Still need an API to add, remove, disable, etc.

@MikeYeager MikeYeager added enhancement New feature or request macOS Only on macOS labels Mar 11, 2021
@stevesobol
Copy link

I'd like to work on this, and systray/notification area integration on all three platforms. I may need some help figuring out what changes I need to make to both Photino.Net and Photino.Native.

@MikeYeager
Copy link
Collaborator Author

@stevesobol That's fantastic. Thank you. I believe the notifications are already implemented in the latest builds, so it's just the native menus remaining.

@stevesobol
Copy link

There were some other comments here - what happened to them?

@MikeYeager
Copy link
Collaborator Author

MikeYeager commented Jan 27, 2022

@stevesobol We don't delete anything from issues (except profanity, etc.) I think only you as the author can delete. I don't recall what the comments were. This particular one is for macOS, there are also issues for Windows and Linux. Perhaps the comments are in one of those?

@stevesobol
Copy link

stevesobol commented Jan 27, 2022

Ah, my comments are on #44. What's weird is that #42 and #43 seem identical. (Edit: I mean identical in every way; even the comments are identical)

Never mind, though, I found my comments.

@karino2
Copy link

karino2 commented Feb 14, 2022

What is the current status of this task?
I forked locally and hard corded some edit related menu and seems working.

In mac, this system menu is necessary for copy-paste keyboard shortcut functionality.
So I think this feature is inevitable even for small tools.
If implementing this task takes long time, it might be better always enable edit related menu as a workaround.
(Always on is far better than always off).

if @stevesobol do other platform first, I might help some for Mac part.

@stevesobol
Copy link

If you want to do the work for Mac, that's fine. I haven't touched any Objective-C code in a while, and you're probably better qualified than I am. We need to talk about an API, though. The same set of functions need to work on all three platforms, and the way I see it, there are going to be a couple (dealing with the Preferences and About menu items, specifically) that will actually do something on Mac but will need to be NOPs on the other platforms.

I haven't even had the chance to start on the Windows side yet.

@karino2
Copy link

karino2 commented Feb 14, 2022

Thanks for sharing.
I understand that there are many common parts, and it is much more time-consuming (especially for design discussion, though electron design helps a great deal).

I'm not sure I will have spare time when you complete some common parts done. But please keep sharing progress here or #44. Thank you!

@matthewsheeran
Copy link

matthewsheeran commented Mar 20, 2022

I would be prepared to work on this as well IFF the native .NET implementation of it can be rolled out ahead of Mac and Linux. I was once a C++ Dev (these days C# and Python). At the moment I only need Windows Menus and can go back to using WebView2 directly with PostMessge for communications.

Your project appears to be stalling and I suspect progress on this will be slow. You need a bigger team and more developers. There is even an alternative approach which would be using C#.NET aka Xamarin and XAML whilst similarly integrating with the alternative native web view controls but just for Mac and Linux platforms and that would be the only Native C++ bit.

There does need to be enabled and disabled (greyed out) menus. Nested menus, left (e.g. Help) as well as right and menus using graphics (e.g. hamburger) menus, along with he ability to add and remove them dynamically. When you add all of this up it becomes a lot of work.

If all of this doesn't eventuate or isnt forthcoming then I would be better off continuing with my own control built around just WebView2+PostMessage for Windows which is all I need at the moment.. If the Windows component used pure C#.NET and didnt unnecesarily rely on the Native component in C++ (as I have been doing) then progress on the Windows side at least would be a lot quicker and more of the guts of the PhotoWindow control would be exposed and available for use on the Windows platform.

That said I like it and its simplicity and dont take this as criticism but my own rumination of my own development choices. I started with CefSharp while WebView2 was in beta flux and am now dropping the fromer so I'll pickup Photino again once I see the Menus that meet my needs. Theming also is an open question with a closed Native control: with a pure C#.NET codebase I can switch to something like MahApps with little difficulty even if I have to fork the codebase and make global changes.

@stevesobol
Copy link

Wow. You do realize that I'm a volunteer, as are other contributors, and we (and the maintainers) are doing this in our spare time, right?

It's OSS. If you want to fork the project, great. If you want to go in a different direction, just as great. Waltzing in here and dictating what happens, like you just did... not so great.

I'm trying to find time to work on Photino.Native. Native menus are a feature I want to see, and I want to work on that feature. If you want to work on that feature as well, that's wonderful. But the nasty comment isn't necessary.

(Note: my opinion is my own and may or may not represent the opinions of other volunteers or MikeYeager.)

@matthewsheeran
Copy link

My apologies as maybe I was blunt. Wasn't meant to be nasty. I know you need all the volunteers you can get. But we have an architectural difference as even with menus I can't see how to theme. A pure C#.NET implementation just for the Windows platform would probably be a better way to go for me otherwise I would most certainly pitch in. Please don't take it personally. I was probably pissed myself that I can't find a component that fits my needs - for the moment anyway - even though Photino looks very promising indeed and the only real second choice.

Just as an FYI I am looking to use it as a mixed language Web Map Control: Leaflet, OpenLayers or ArcGIS API for JS: as I can't find a Native Map Control that I am happy with either! So again please don't take it personally as I meant no offence.

@MikeYeager
Copy link
Collaborator Author

This is tricky to implement. No question. Photino's function is to provide platform-specific feature implementations for Windows, Linux and macOS and to make a common, unifying interface. We try to cover every feature common to all platforms and not focus on things that are not available on all platforms, though we'll take them. I started preliminary work to come up with a generic way to define and implement native menus as well as a format for storing and retrieving menus, but didn't get very far before shifting to something else. Those definitions might be a good first step. Then we can get feedback on the plan before implementing on any specific platform. Thoughts?

@stevesobol
Copy link

@matthewsheeran all good, apology accepted.

@stevesobol
Copy link

@MikeYeager I think the path you described is the right one. Where native menus are concerned, we will need to make an exception, though: we need to allow people to create event handlers for the Preferences and About items on the Mac application menu - and maybe also Quit. The function or method calls that add those event handlers would exist on the other platforms, but they'd do nothing there.

Unless I'm missing something, this doesn't have to be complicated.

@matthewsheeran Looking for a clarification. What do you mean by "theme"? In my vision for a typical Photino-powered app, you'd get a window, maybe some menus, maybe a tray/notification item, and theming/styling would be done entirely in CSS/HTML.

Are you referring to a Windows theme?

@matthewsheeran
Copy link

matthewsheeran commented Mar 22, 2022 via email

@stevesobol
Copy link

@matthewsheeran -

Even using XAML, what would you be able to style besides the window frame/chrome?

I think that Avalonia might be a far better solution for your use case. Avalonia is cross-platform and uses XAML to declaratively describe your UI. Not sure if it handles Windows visual styles.

https://avaloniaui.net/

https://github.com/AvaloniaUI/Avalonia

@matthewsheeran
Copy link

matthewsheeran commented Mar 24, 2022 via email

@matthewsheeran
Copy link

matthewsheeran commented Mar 24, 2022 via email

@ottodobretsberger
Copy link
Contributor

You could just hide the chrome and do your menus and styling in JavaScript.
We agree there are some cases where you want a native menu that follows that OS standards and looks.

@matthewsheeran
Copy link

Thank you for your suggestion as you are right of course: but I am coming from C#, wanted to get up and running quickly as I already have, need to do some canonicalization of the data next and probably in C# initially, also might eventually want to use some geospatial library or other from C#.NET.

My nephew as a novice JavaScript devloper has put me on to react and there is a react leaflet. If I go down the pure JS path later with it then I could go with react native also and ditch any WebView control entirely. I also found some vanila JS code for diff-ing with CSS which I need to do too probably in its own window at least initially which along with your comment got me thinking..

JavaScript with the HTML DOM is definitely the "in thing" like react so time for me to go and read SyncFusion's react(JS) Succinctly!.. (I am hoping it's a clean modular JS made simple as well (and with a reliable build process as well (although that has never really been true of node!).)

@stevesobol
Copy link

Hey @MikeYeager

I'm getting started on implementing native menus - first in Windows, then on other platforms if I have time. I'm using Visual Studio Community 2019 and I am not sure how best to set up my development environment. I'll need to work on the .NET side and the native side at the same time. Is it best to create a new solution containing all of the .NET projects, and the Native project?

@matthewsheeran
Copy link

matthewsheeran commented Jul 31, 2022 via email

@stevesobol
Copy link

For some reason, the reply I emailed a few minutes ago did not make it to Github. I'll just reproduce it here (now watch, I'll finish making my comment here on the site, and two minutes later, my emailed comment will arrive)

@matthewsheeran - I actually prefer the idea of using HTML/CSS/JS and creating an attractive UI in React. XAML is great, but it's not my first choice. It feels clunky to me.

This comment isn't intended to be derogatory to XAML, which is more than capable of handling lots of different scenarios. Nor is it intended to be derogatory to MAUI, which I haven't even played with yet. HTML/CSS/JS/React/Bootstrap is a personal preference.

Besides... I want to contribute to this project. I see a lot of potential for it to become very popular, if we build it into a useful product. The current feature set is nice, but I would like to help take the project from "that's nice" to "OMG WHY AM I NOT USING THIS?!"

Anyhow... my goal is to extend Photino, so recommending XAML to me is completely pointless. If I wanted to use MAUI, I probably would not be volunteering to add features to Photino in the first place.

@stevesobol
Copy link

stevesobol commented Oct 11, 2022 via email

@matthewsheeran
Copy link

matthewsheeran commented Oct 11, 2022 via email

@stevesobol
Copy link

Ok, what's going on? @matthewsheeran - this latest reply from you isn't 15 hours old, it's at least a month or two old, as is the message that you replied to. I haven't posted anything anywhere on Github in the past 24 hours.

@matthewsheeran
Copy link

matthewsheeran commented Oct 14, 2022 via email

@stevesobol
Copy link

Wow, ok.

I can't do either of those things.

I can't close the thread because I didn't open it.

I can't unsubscribe you from responses to this thread because I'm not you.

You can unsubscribe from the Notifications page.

@matthewsheeran
Copy link

matthewsheeran commented Oct 14, 2022 via email

@stevesobol
Copy link

@MikeYeager So yeah, I know I'm a little behind with work I want to get done on several OSS projects including this one...

But tonight, I'm sitting here actually trying to figure out how to move forward with this work I've promised to do. And on the native end, getting menus working means we are going to need to interact with

  • Win32 APIs on Windows
  • GTK? on Linux
  • Cocoa on Mac

I think this is going to require a lot of P/Invoke calls, which I'm hoping work the same way on Mac and Linux that they do on Windows. This will not be pretty. 🤣

@MikeYeager
Copy link
Collaborator Author

@stevesobol Agreed! (That's why this one has been postponed for so long :-)) I think the initial conversation has to be how to define and interface that unifies all platforms. For very basic menu items and sub-menus it's pretty straightforward, but it gets complex quickly with things like separator lines, icons, hot keys, multi-line items, support for OS themes, multi-level sub-menus, fonts, etc., etc. This is going to be fun! Also, there should probably be some way to define and save/recall an entire menu structure. (JSON maybe?)

@stevesobol
Copy link

Saving/recalling (importing/exporting) menus seems like it'd be simple. C# and Javascript objects can be serialized to JSON.

Let me think about the API - I'll get back to you.

@stevesobol
Copy link

What do you think about adding methods to window.external?

window.external.addMenuItem()
window.external.deleteMenuItem()
window.external.modifyMenuItem()

And (macOS specific)
window.external.macosAddAboutMenutItem()
window.external.macosAddPreferencesMenuItem()

@matthewsheeran
Copy link

matthewsheeran commented Dec 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request macOS Only on macOS
Projects
None yet
Development

No branches or pull requests

5 participants