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

[RFC] Support tray menus (Windows) #1959

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3f82cea
Initial Tray support for Mac
leaanthony Apr 30, 2022
ee50170
Support activation policy
leaanthony Apr 30, 2022
1830c64
Better Checked implementation
leaanthony Apr 30, 2022
c1d4aeb
Merge branch 'master' into exp
leaanthony May 1, 2022
ae0933c
Move TrayMenu from config to runtime
leaanthony May 2, 2022
58b6e4c
Support retina images
leaanthony May 2, 2022
13fb535
Support sizing tray menu
leaanthony May 2, 2022
1947a9a
Hugely improved + darkmode bitmap support. Dynamic scaling factor sup…
leaanthony May 5, 2022
ee5ca1a
Add SetLabel, minor api updates
leaanthony May 7, 2022
368733b
WIP
leaanthony May 13, 2022
319d592
Support loading images into Windows tray
leaanthony May 13, 2022
11cbfb6
Merge branch 'master' into exp
leaanthony Jul 9, 2022
a11655c
Merge master
leaanthony Jul 9, 2022
823c365
Application refactor
leaanthony Sep 23, 2022
e5a1ddb
Merge branch 'exp' into feature/1521_Support_Tray_Menus
leaanthony Sep 23, 2022
26c6881
Add issue translator (#1891)
leaanthony Sep 23, 2022
022fd9a
chore: update the label name in the issue template (#1893)
misitebao Sep 24, 2022
2940a9e
obfuscated instead of obfuscate in the docs (#1895)
arifali123 Sep 24, 2022
cfb55f7
[assetHandler] Remove redundant log prefix (#1896)
stffabi Sep 24, 2022
311dde4
[windows] refactor out main loop. Create new application struct. Refa…
leaanthony Sep 25, 2022
d319d51
Refactor darwin app
leaanthony Sep 26, 2022
03dd514
Refactor app for linux
leaanthony Sep 27, 2022
bf088ea
Initial Windows systray support
leaanthony Sep 29, 2022
a967ce0
Refactor light/dark icons
leaanthony Oct 4, 2022
c63f816
Move systray startup into application
leaanthony Oct 4, 2022
68bdc7c
Support menu.Menu
leaanthony Oct 5, 2022
abe83f2
Support traymenu update
leaanthony Oct 5, 2022
0664c51
Fix GetMessage bug
leaanthony Oct 6, 2022
249dc81
Fix GetMessage bug.
leaanthony Oct 6, 2022
181ba42
Support submenus
leaanthony Oct 6, 2022
b5478e5
Support checkbox logic. Support duplicate checkboxes
leaanthony Oct 7, 2022
d6f20d5
menu refactor
leaanthony Oct 7, 2022
5fab671
Support Hidden attribute. Add SetTooltip & SetIcons to SystemTray. Ad…
leaanthony Oct 7, 2022
12a309c
Update menu docs
leaanthony Oct 7, 2022
c5ad7de
Menu to follow theme
leaanthony Oct 7, 2022
9d6d90c
Add transparency methods
leaanthony Oct 8, 2022
c38e0ea
Use MenuManager for processing and handling menu state changes
leaanthony Oct 9, 2022
5adf800
Support Radio Groups
leaanthony Oct 9, 2022
bd0e3b4
Add accelerator code
leaanthony Oct 11, 2022
bca58af
Remove accelerator code, but leave text in menu
leaanthony Oct 11, 2022
828ebd8
Support left/right click override
leaanthony Oct 11, 2022
2f99ef7
Add example
leaanthony Oct 11, 2022
7ef6f7d
Fix bug in `runtime.Show()`. Tidy up debug.
leaanthony Oct 11, 2022
72a0db3
Add translucency effects
leaanthony Oct 11, 2022
c767c75
Update example
leaanthony Oct 11, 2022
cb879d7
Update example
leaanthony Oct 11, 2022
3ffb92d
Fix radio group bug when group is last in menu
leaanthony Oct 12, 2022
4fe1aff
Fix menuID bug
leaanthony Oct 12, 2022
804816d
Update example
leaanthony Oct 12, 2022
62c19f1
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 12, 2022
312f1a6
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 12, 2022
97ca838
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 13, 2022
d7db4c1
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 15, 2022
7969419
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 22, 2022
58be270
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 22, 2022
6dac029
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 22, 2022
ca07910
Add support for double click mouse button events and menu open/close …
leaanthony Oct 23, 2022
78e3132
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Oct 26, 2022
f469d3e
Merge branch 'master' into feature/1521_Support_Tray_Menus
leaanthony Nov 24, 2022
4b11bed
Address some issues in Code Review
leaanthony Nov 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ v2/test/kitchensink/frontend/package.json.md5
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
.env
/website/static/img/.cache.json

v2/internal/frontend/desktop/darwin/test.xcodeproj
TODO.md
15 changes: 15 additions & 0 deletions v2/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<p align="center">
<img alt="Wails logo" src="https://github.com/wailsapp/wails/raw/master/assets/images/logo-universal.png" style="width:55%; max-width:400px"><br/>
</p>

<p align="center">
Various example applications for Wails.
</p>

## Table of Contents

- [Systray](./systray/README.md)

## Contributing

Please create a directory with your example, add a link to this README and raise a PR.
93 changes: 93 additions & 0 deletions v2/examples/common/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2016 The Nunito Project Authors ([email protected]),

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file added v2/examples/common/images/logo-universal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions v2/examples/systray/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/bin
node_modules
frontend/wailsjs
17 changes: 17 additions & 0 deletions v2/examples/systray/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# System Tray

This example shows how to create a system tray using an experimental programmatic API.

## Running

As this example outputs text to the console, it is recommended to build using `wails build -debug`.

## Supported Platforms

- [x] Windows
- [ ] macOS
- [ ] Linux




Binary file added v2/examples/systray/build/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions v2/examples/systray/build/darwin/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleName</key><string>{{.Info.ProductName}}</string>
<key>CFBundleExecutable</key><string>{{.Name}}</string>
<key>CFBundleIdentifier</key><string>com.wails.{{.Name}}</string>
<key>CFBundleVersion</key><string>{{.Info.ProductVersion}}</string>
<key>CFBundleGetInfoString</key><string>{{.Info.Comments}}</string>
<key>CFBundleShortVersionString</key><string>{{.Info.ProductVersion}}</string>
<key>CFBundleIconFile</key><string>iconfile</string>
<key>LSMinimumSystemVersion</key><string>10.13.0</string>
<key>NSHighResolutionCapable</key><string>true</string>
<key>NSHumanReadableCopyright</key><string>{{.Info.Copyright}}</string>
</dict></plist>
Binary file added v2/examples/systray/build/windows/icon.ico
Binary file not shown.
15 changes: 15 additions & 0 deletions v2/examples/systray/build/windows/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"fixed": {
"file_version": "{{.Info.ProductVersion}}"
},
"info": {
"0000": {
"ProductVersion": "{{.Info.ProductVersion}}",
"CompanyName": "{{.Info.CompanyName}}",
"FileDescription": "{{.Info.ProductName}}",
"LegalCopyright": "{{.Info.Copyright}}",
"ProductName": "{{.Info.ProductName}}",
"Comments": "{{.Info.Comments}}"
}
}
}
101 changes: 101 additions & 0 deletions v2/examples/systray/build/windows/installer/project.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Unicode true

####
## Please note: Template replacements don't work in this file. They are provided with default defines like
## mentioned underneath.
## If the keyword is not defined, "wails_tools.nsh" will populate them with the values from ProjectInfo.
## If they are defined here, "wails_tools.nsh" will not touch them. This allows to use this project.nsi manually
## from outside of Wails for debugging and development of the installer.
##
## For development first make a wails nsis build to populate the "wails_tools.nsh":
## > wails build --target windows/amd64 --nsis
## Then you can call makensis on this file with specifying the path to your binary:
## For a AMD64 only installer:
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe
## For a ARM64 only installer:
## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe
## For a installer with both architectures:
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe
####
## The following information is taken from the ProjectInfo file, but they can be overwritten here.
####
## !define INFO_PROJECTNAME "MyProject" # Default "{{.Name}}"
## !define INFO_COMPANYNAME "MyCompany" # Default "{{.Info.CompanyName}}"
## !define INFO_PRODUCTNAME "MyProduct" # Default "{{.Info.ProductName}}"
## !define INFO_PRODUCTVERSION "1.0.0" # Default "{{.Info.ProductVersion}}"
## !define INFO_COPYRIGHT "Copyright" # Default "{{.Info.Copyright}}"
###
## !define PRODUCT_EXECUTABLE "Application.exe" # Default "${INFO_PROJECTNAME}.exe"
## !define UNINST_KEY_NAME "UninstKeyInRegistry" # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
####
## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html
####
## Include the wails tools
####
!include "wails_tools.nsh"

# The version information for this two must consist of 4 parts
VIProductVersion "${INFO_PRODUCTVERSION}.0"
VIFileVersion "${INFO_PRODUCTVERSION}.0"

VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}"
VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}"
VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}"
VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}"
VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}"

!include "MUI.nsh"

!define MUI_ICON "..\icon.ico"
!define MUI_UNICON "..\icon.ico"
# !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314
!define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.

!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
# !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
!insertmacro MUI_PAGE_INSTFILES # Installing page.
!insertmacro MUI_PAGE_FINISH # Finished installation page.

!insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page

!insertmacro MUI_LANGUAGE "English" # Set the Language of the installer

## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
#!uninstfinalize 'signtool --file "%1"'
#!finalize 'signtool --file "%1"'

Name "${INFO_PRODUCTNAME}"
OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
ShowInstDetails show # This will always show the installation details.

Function .onInit
!insertmacro wails.checkArchitecture
FunctionEnd

Section
!insertmacro wails.webview2runtime

SetOutPath $INSTDIR

!insertmacro wails.files

CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"

!insertmacro wails.writeUninstaller
SectionEnd

Section "uninstall"
RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath

RMDir /r $INSTDIR

Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"

!insertmacro wails.deleteUninstaller
SectionEnd
Loading