tools-template-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/index.js +380 -0
- package/dist/templates.js +44 -0
- package/package.json +49 -0
- package/supabase-expo-app/.env.example +2 -0
- package/supabase-expo-app/App.tsx +55 -0
- package/supabase-expo-app/README.md +179 -0
- package/supabase-expo-app/app.json +34 -0
- package/supabase-expo-app/assets/adaptive-icon.png +0 -0
- package/supabase-expo-app/assets/favicon.png +0 -0
- package/supabase-expo-app/assets/icon.png +0 -0
- package/supabase-expo-app/assets/splash-icon.png +0 -0
- package/supabase-expo-app/components/Account.tsx +234 -0
- package/supabase-expo-app/components/Auth.tsx +161 -0
- package/supabase-expo-app/components/Avatar.tsx +173 -0
- package/supabase-expo-app/index.ts +8 -0
- package/supabase-expo-app/lib/supabase.ts +63 -0
- package/supabase-expo-app/package-lock.json +8983 -0
- package/supabase-expo-app/package.json +32 -0
- package/supabase-expo-app/scripts/setup-supabase.sh +73 -0
- package/supabase-expo-app/supabase/schema.sql +57 -0
- package/supabase-expo-app/tsconfig.json +6 -0
- package/supabase-swiftui-app/Package.swift +32 -0
- package/supabase-swiftui-app/README.md +215 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/AccountView.swift +181 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/AuthView.swift +123 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/AvatarView.swift +113 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/ContentView.swift +18 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/Supabase.swift +13 -0
- package/supabase-swiftui-app/SupabaseSwiftUIApp/SupabaseSwiftUIApp.swift +22 -0
- package/supabase-swiftui-app/scripts/setup-supabase.sh +67 -0
- package/supabase-swiftui-app/supabase/schema.sql +57 -0
- package/supabase-user-management/AGENTS.md +5 -0
- package/supabase-user-management/CLAUDE.md +1 -0
- package/supabase-user-management/README.md +178 -0
- package/supabase-user-management/app/account/account-form.tsx +174 -0
- package/supabase-user-management/app/account/avatar.tsx +109 -0
- package/supabase-user-management/app/account/page.tsx +28 -0
- package/supabase-user-management/app/auth/confirm/route.ts +26 -0
- package/supabase-user-management/app/error.tsx +14 -0
- package/supabase-user-management/app/favicon.ico +0 -0
- package/supabase-user-management/app/globals.css +130 -0
- package/supabase-user-management/app/layout.tsx +22 -0
- package/supabase-user-management/app/loading.tsx +7 -0
- package/supabase-user-management/app/login/actions.ts +45 -0
- package/supabase-user-management/app/login/page.tsx +90 -0
- package/supabase-user-management/app/page.tsx +16 -0
- package/supabase-user-management/components/ui/button.tsx +58 -0
- package/supabase-user-management/components.json +25 -0
- package/supabase-user-management/eslint.config.mjs +18 -0
- package/supabase-user-management/lib/supabase/client.ts +8 -0
- package/supabase-user-management/lib/supabase/middleware.ts +52 -0
- package/supabase-user-management/lib/supabase/server.ts +29 -0
- package/supabase-user-management/lib/utils.ts +6 -0
- package/supabase-user-management/next.config.ts +7 -0
- package/supabase-user-management/package-lock.json +9910 -0
- package/supabase-user-management/package.json +36 -0
- package/supabase-user-management/postcss.config.mjs +7 -0
- package/supabase-user-management/public/file.svg +1 -0
- package/supabase-user-management/public/globe.svg +1 -0
- package/supabase-user-management/public/next.svg +1 -0
- package/supabase-user-management/public/vercel.svg +1 -0
- package/supabase-user-management/public/window.svg +1 -0
- package/supabase-user-management/scripts/setup-supabase.sh +98 -0
- package/supabase-user-management/src/proxy.ts +12 -0
- package/supabase-user-management/supabase/schema.sql +57 -0
- package/supabase-user-management/tsconfig.json +34 -0
- package/supabase_flutter_app/.metadata +45 -0
- package/supabase_flutter_app/README.md +195 -0
- package/supabase_flutter_app/analysis_options.yaml +28 -0
- package/supabase_flutter_app/android/app/build.gradle.kts +44 -0
- package/supabase_flutter_app/android/app/src/debug/AndroidManifest.xml +7 -0
- package/supabase_flutter_app/android/app/src/main/AndroidManifest.xml +54 -0
- package/supabase_flutter_app/android/app/src/main/kotlin/com/example/supabase_flutter_app/MainActivity.kt +5 -0
- package/supabase_flutter_app/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/supabase_flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/supabase_flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/supabase_flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/supabase_flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/supabase_flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/supabase_flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/supabase_flutter_app/android/app/src/main/res/values/styles.xml +18 -0
- package/supabase_flutter_app/android/app/src/main/res/values-night/styles.xml +18 -0
- package/supabase_flutter_app/android/app/src/profile/AndroidManifest.xml +7 -0
- package/supabase_flutter_app/android/build.gradle.kts +24 -0
- package/supabase_flutter_app/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/supabase_flutter_app/android/gradle.properties +2 -0
- package/supabase_flutter_app/android/settings.gradle.kts +26 -0
- package/supabase_flutter_app/ios/Flutter/AppFrameworkInfo.plist +26 -0
- package/supabase_flutter_app/ios/Flutter/Debug.xcconfig +2 -0
- package/supabase_flutter_app/ios/Flutter/Release.xcconfig +2 -0
- package/supabase_flutter_app/ios/Podfile +43 -0
- package/supabase_flutter_app/ios/Runner/AppDelegate.swift +13 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/supabase_flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
- package/supabase_flutter_app/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
- package/supabase_flutter_app/ios/Runner/Base.lproj/Main.storyboard +26 -0
- package/supabase_flutter_app/ios/Runner/Info.plist +61 -0
- package/supabase_flutter_app/ios/Runner/Runner-Bridging-Header.h +1 -0
- package/supabase_flutter_app/ios/Runner.xcodeproj/project.pbxproj +619 -0
- package/supabase_flutter_app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/supabase_flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/supabase_flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/supabase_flutter_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +101 -0
- package/supabase_flutter_app/ios/Runner.xcworkspace/contents.xcworkspacedata +7 -0
- package/supabase_flutter_app/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/supabase_flutter_app/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/supabase_flutter_app/ios/RunnerTests/RunnerTests.swift +12 -0
- package/supabase_flutter_app/lib/components/avatar.dart +153 -0
- package/supabase_flutter_app/lib/main.dart +70 -0
- package/supabase_flutter_app/lib/pages/account_page.dart +189 -0
- package/supabase_flutter_app/lib/pages/login_page.dart +150 -0
- package/supabase_flutter_app/linux/CMakeLists.txt +128 -0
- package/supabase_flutter_app/linux/flutter/CMakeLists.txt +88 -0
- package/supabase_flutter_app/linux/flutter/generated_plugin_registrant.cc +23 -0
- package/supabase_flutter_app/linux/flutter/generated_plugin_registrant.h +15 -0
- package/supabase_flutter_app/linux/flutter/generated_plugins.cmake +26 -0
- package/supabase_flutter_app/linux/runner/CMakeLists.txt +26 -0
- package/supabase_flutter_app/linux/runner/main.cc +6 -0
- package/supabase_flutter_app/linux/runner/my_application.cc +148 -0
- package/supabase_flutter_app/linux/runner/my_application.h +21 -0
- package/supabase_flutter_app/macos/Flutter/Flutter-Debug.xcconfig +2 -0
- package/supabase_flutter_app/macos/Flutter/Flutter-Release.xcconfig +2 -0
- package/supabase_flutter_app/macos/Flutter/GeneratedPluginRegistrant.swift +18 -0
- package/supabase_flutter_app/macos/Podfile +42 -0
- package/supabase_flutter_app/macos/Runner/AppDelegate.swift +13 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/supabase_flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/supabase_flutter_app/macos/Runner/Base.lproj/MainMenu.xib +343 -0
- package/supabase_flutter_app/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/supabase_flutter_app/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/supabase_flutter_app/macos/Runner/Configs/Release.xcconfig +2 -0
- package/supabase_flutter_app/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/supabase_flutter_app/macos/Runner/DebugProfile.entitlements +12 -0
- package/supabase_flutter_app/macos/Runner/Info.plist +32 -0
- package/supabase_flutter_app/macos/Runner/MainFlutterWindow.swift +15 -0
- package/supabase_flutter_app/macos/Runner/Release.entitlements +8 -0
- package/supabase_flutter_app/macos/Runner.xcodeproj/project.pbxproj +705 -0
- package/supabase_flutter_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/supabase_flutter_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +99 -0
- package/supabase_flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata +7 -0
- package/supabase_flutter_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/supabase_flutter_app/macos/RunnerTests/RunnerTests.swift +12 -0
- package/supabase_flutter_app/pubspec.lock +818 -0
- package/supabase_flutter_app/pubspec.yaml +26 -0
- package/supabase_flutter_app/scripts/setup-supabase.sh +72 -0
- package/supabase_flutter_app/supabase/schema.sql +57 -0
- package/supabase_flutter_app/test/widget_test.dart +30 -0
- package/supabase_flutter_app/web/favicon.png +0 -0
- package/supabase_flutter_app/web/icons/Icon-192.png +0 -0
- package/supabase_flutter_app/web/icons/Icon-512.png +0 -0
- package/supabase_flutter_app/web/icons/Icon-maskable-192.png +0 -0
- package/supabase_flutter_app/web/icons/Icon-maskable-512.png +0 -0
- package/supabase_flutter_app/web/index.html +38 -0
- package/supabase_flutter_app/web/manifest.json +35 -0
- package/supabase_flutter_app/windows/CMakeLists.txt +108 -0
- package/supabase_flutter_app/windows/flutter/CMakeLists.txt +109 -0
- package/supabase_flutter_app/windows/flutter/generated_plugin_registrant.cc +20 -0
- package/supabase_flutter_app/windows/flutter/generated_plugin_registrant.h +15 -0
- package/supabase_flutter_app/windows/flutter/generated_plugins.cmake +26 -0
- package/supabase_flutter_app/windows/runner/CMakeLists.txt +40 -0
- package/supabase_flutter_app/windows/runner/Runner.rc +121 -0
- package/supabase_flutter_app/windows/runner/flutter_window.cpp +71 -0
- package/supabase_flutter_app/windows/runner/flutter_window.h +33 -0
- package/supabase_flutter_app/windows/runner/main.cpp +43 -0
- package/supabase_flutter_app/windows/runner/resource.h +16 -0
- package/supabase_flutter_app/windows/runner/resources/app_icon.ico +0 -0
- package/supabase_flutter_app/windows/runner/runner.exe.manifest +14 -0
- package/supabase_flutter_app/windows/runner/utils.cpp +65 -0
- package/supabase_flutter_app/windows/runner/utils.h +19 -0
- package/supabase_flutter_app/windows/runner/win32_window.cpp +288 -0
- package/supabase_flutter_app/windows/runner/win32_window.h +102 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Microsoft Visual C++ generated resource script.
|
|
2
|
+
//
|
|
3
|
+
#pragma code_page(65001)
|
|
4
|
+
#include "resource.h"
|
|
5
|
+
|
|
6
|
+
#define APSTUDIO_READONLY_SYMBOLS
|
|
7
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
8
|
+
//
|
|
9
|
+
// Generated from the TEXTINCLUDE 2 resource.
|
|
10
|
+
//
|
|
11
|
+
#include "winres.h"
|
|
12
|
+
|
|
13
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
14
|
+
#undef APSTUDIO_READONLY_SYMBOLS
|
|
15
|
+
|
|
16
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
17
|
+
// English (United States) resources
|
|
18
|
+
|
|
19
|
+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
|
20
|
+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
|
21
|
+
|
|
22
|
+
#ifdef APSTUDIO_INVOKED
|
|
23
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
24
|
+
//
|
|
25
|
+
// TEXTINCLUDE
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
1 TEXTINCLUDE
|
|
29
|
+
BEGIN
|
|
30
|
+
"resource.h\0"
|
|
31
|
+
END
|
|
32
|
+
|
|
33
|
+
2 TEXTINCLUDE
|
|
34
|
+
BEGIN
|
|
35
|
+
"#include ""winres.h""\r\n"
|
|
36
|
+
"\0"
|
|
37
|
+
END
|
|
38
|
+
|
|
39
|
+
3 TEXTINCLUDE
|
|
40
|
+
BEGIN
|
|
41
|
+
"\r\n"
|
|
42
|
+
"\0"
|
|
43
|
+
END
|
|
44
|
+
|
|
45
|
+
#endif // APSTUDIO_INVOKED
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
49
|
+
//
|
|
50
|
+
// Icon
|
|
51
|
+
//
|
|
52
|
+
|
|
53
|
+
// Icon with lowest ID value placed first to ensure application icon
|
|
54
|
+
// remains consistent on all systems.
|
|
55
|
+
IDI_APP_ICON ICON "resources\\app_icon.ico"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
//
|
|
60
|
+
// Version
|
|
61
|
+
//
|
|
62
|
+
|
|
63
|
+
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
|
|
64
|
+
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
|
|
65
|
+
#else
|
|
66
|
+
#define VERSION_AS_NUMBER 1,0,0,0
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
#if defined(FLUTTER_VERSION)
|
|
70
|
+
#define VERSION_AS_STRING FLUTTER_VERSION
|
|
71
|
+
#else
|
|
72
|
+
#define VERSION_AS_STRING "1.0.0"
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
VS_VERSION_INFO VERSIONINFO
|
|
76
|
+
FILEVERSION VERSION_AS_NUMBER
|
|
77
|
+
PRODUCTVERSION VERSION_AS_NUMBER
|
|
78
|
+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
|
79
|
+
#ifdef _DEBUG
|
|
80
|
+
FILEFLAGS VS_FF_DEBUG
|
|
81
|
+
#else
|
|
82
|
+
FILEFLAGS 0x0L
|
|
83
|
+
#endif
|
|
84
|
+
FILEOS VOS__WINDOWS32
|
|
85
|
+
FILETYPE VFT_APP
|
|
86
|
+
FILESUBTYPE 0x0L
|
|
87
|
+
BEGIN
|
|
88
|
+
BLOCK "StringFileInfo"
|
|
89
|
+
BEGIN
|
|
90
|
+
BLOCK "040904e4"
|
|
91
|
+
BEGIN
|
|
92
|
+
VALUE "CompanyName", "com.example" "\0"
|
|
93
|
+
VALUE "FileDescription", "supabase_flutter_app" "\0"
|
|
94
|
+
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
|
95
|
+
VALUE "InternalName", "supabase_flutter_app" "\0"
|
|
96
|
+
VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0"
|
|
97
|
+
VALUE "OriginalFilename", "supabase_flutter_app.exe" "\0"
|
|
98
|
+
VALUE "ProductName", "supabase_flutter_app" "\0"
|
|
99
|
+
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
|
100
|
+
END
|
|
101
|
+
END
|
|
102
|
+
BLOCK "VarFileInfo"
|
|
103
|
+
BEGIN
|
|
104
|
+
VALUE "Translation", 0x409, 1252
|
|
105
|
+
END
|
|
106
|
+
END
|
|
107
|
+
|
|
108
|
+
#endif // English (United States) resources
|
|
109
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
#ifndef APSTUDIO_INVOKED
|
|
114
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
115
|
+
//
|
|
116
|
+
// Generated from the TEXTINCLUDE 3 resource.
|
|
117
|
+
//
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
121
|
+
#endif // not APSTUDIO_INVOKED
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "flutter_window.h"
|
|
2
|
+
|
|
3
|
+
#include <optional>
|
|
4
|
+
|
|
5
|
+
#include "flutter/generated_plugin_registrant.h"
|
|
6
|
+
|
|
7
|
+
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
|
|
8
|
+
: project_(project) {}
|
|
9
|
+
|
|
10
|
+
FlutterWindow::~FlutterWindow() {}
|
|
11
|
+
|
|
12
|
+
bool FlutterWindow::OnCreate() {
|
|
13
|
+
if (!Win32Window::OnCreate()) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
RECT frame = GetClientArea();
|
|
18
|
+
|
|
19
|
+
// The size here must match the window dimensions to avoid unnecessary surface
|
|
20
|
+
// creation / destruction in the startup path.
|
|
21
|
+
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
|
|
22
|
+
frame.right - frame.left, frame.bottom - frame.top, project_);
|
|
23
|
+
// Ensure that basic setup of the controller was successful.
|
|
24
|
+
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
RegisterPlugins(flutter_controller_->engine());
|
|
28
|
+
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
|
29
|
+
|
|
30
|
+
flutter_controller_->engine()->SetNextFrameCallback([&]() {
|
|
31
|
+
this->Show();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Flutter can complete the first frame before the "show window" callback is
|
|
35
|
+
// registered. The following call ensures a frame is pending to ensure the
|
|
36
|
+
// window is shown. It is a no-op if the first frame hasn't completed yet.
|
|
37
|
+
flutter_controller_->ForceRedraw();
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void FlutterWindow::OnDestroy() {
|
|
43
|
+
if (flutter_controller_) {
|
|
44
|
+
flutter_controller_ = nullptr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Win32Window::OnDestroy();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
LRESULT
|
|
51
|
+
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
|
|
52
|
+
WPARAM const wparam,
|
|
53
|
+
LPARAM const lparam) noexcept {
|
|
54
|
+
// Give Flutter, including plugins, an opportunity to handle window messages.
|
|
55
|
+
if (flutter_controller_) {
|
|
56
|
+
std::optional<LRESULT> result =
|
|
57
|
+
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
|
|
58
|
+
lparam);
|
|
59
|
+
if (result) {
|
|
60
|
+
return *result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
switch (message) {
|
|
65
|
+
case WM_FONTCHANGE:
|
|
66
|
+
flutter_controller_->engine()->ReloadSystemFonts();
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
|
|
71
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef RUNNER_FLUTTER_WINDOW_H_
|
|
2
|
+
#define RUNNER_FLUTTER_WINDOW_H_
|
|
3
|
+
|
|
4
|
+
#include <flutter/dart_project.h>
|
|
5
|
+
#include <flutter/flutter_view_controller.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
|
|
9
|
+
#include "win32_window.h"
|
|
10
|
+
|
|
11
|
+
// A window that does nothing but host a Flutter view.
|
|
12
|
+
class FlutterWindow : public Win32Window {
|
|
13
|
+
public:
|
|
14
|
+
// Creates a new FlutterWindow hosting a Flutter view running |project|.
|
|
15
|
+
explicit FlutterWindow(const flutter::DartProject& project);
|
|
16
|
+
virtual ~FlutterWindow();
|
|
17
|
+
|
|
18
|
+
protected:
|
|
19
|
+
// Win32Window:
|
|
20
|
+
bool OnCreate() override;
|
|
21
|
+
void OnDestroy() override;
|
|
22
|
+
LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
|
|
23
|
+
LPARAM const lparam) noexcept override;
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
// The project to run.
|
|
27
|
+
flutter::DartProject project_;
|
|
28
|
+
|
|
29
|
+
// The Flutter instance hosted by this window.
|
|
30
|
+
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#endif // RUNNER_FLUTTER_WINDOW_H_
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include <flutter/dart_project.h>
|
|
2
|
+
#include <flutter/flutter_view_controller.h>
|
|
3
|
+
#include <windows.h>
|
|
4
|
+
|
|
5
|
+
#include "flutter_window.h"
|
|
6
|
+
#include "utils.h"
|
|
7
|
+
|
|
8
|
+
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|
9
|
+
_In_ wchar_t *command_line, _In_ int show_command) {
|
|
10
|
+
// Attach to console when present (e.g., 'flutter run') or create a
|
|
11
|
+
// new console when running with a debugger.
|
|
12
|
+
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
|
|
13
|
+
CreateAndAttachConsole();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Initialize COM, so that it is available for use in the library and/or
|
|
17
|
+
// plugins.
|
|
18
|
+
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
|
19
|
+
|
|
20
|
+
flutter::DartProject project(L"data");
|
|
21
|
+
|
|
22
|
+
std::vector<std::string> command_line_arguments =
|
|
23
|
+
GetCommandLineArguments();
|
|
24
|
+
|
|
25
|
+
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
|
26
|
+
|
|
27
|
+
FlutterWindow window(project);
|
|
28
|
+
Win32Window::Point origin(10, 10);
|
|
29
|
+
Win32Window::Size size(1280, 720);
|
|
30
|
+
if (!window.Create(L"supabase_flutter_app", origin, size)) {
|
|
31
|
+
return EXIT_FAILURE;
|
|
32
|
+
}
|
|
33
|
+
window.SetQuitOnClose(true);
|
|
34
|
+
|
|
35
|
+
::MSG msg;
|
|
36
|
+
while (::GetMessage(&msg, nullptr, 0, 0)) {
|
|
37
|
+
::TranslateMessage(&msg);
|
|
38
|
+
::DispatchMessage(&msg);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::CoUninitialize();
|
|
42
|
+
return EXIT_SUCCESS;
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//{{NO_DEPENDENCIES}}
|
|
2
|
+
// Microsoft Visual C++ generated include file.
|
|
3
|
+
// Used by Runner.rc
|
|
4
|
+
//
|
|
5
|
+
#define IDI_APP_ICON 101
|
|
6
|
+
|
|
7
|
+
// Next default values for new objects
|
|
8
|
+
//
|
|
9
|
+
#ifdef APSTUDIO_INVOKED
|
|
10
|
+
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
11
|
+
#define _APS_NEXT_RESOURCE_VALUE 102
|
|
12
|
+
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
13
|
+
#define _APS_NEXT_CONTROL_VALUE 1001
|
|
14
|
+
#define _APS_NEXT_SYMED_VALUE 101
|
|
15
|
+
#endif
|
|
16
|
+
#endif
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
3
|
+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
4
|
+
<windowsSettings>
|
|
5
|
+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
|
6
|
+
</windowsSettings>
|
|
7
|
+
</application>
|
|
8
|
+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
9
|
+
<application>
|
|
10
|
+
<!-- Windows 10 and Windows 11 -->
|
|
11
|
+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
|
12
|
+
</application>
|
|
13
|
+
</compatibility>
|
|
14
|
+
</assembly>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#include "utils.h"
|
|
2
|
+
|
|
3
|
+
#include <flutter_windows.h>
|
|
4
|
+
#include <io.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <windows.h>
|
|
7
|
+
|
|
8
|
+
#include <iostream>
|
|
9
|
+
|
|
10
|
+
void CreateAndAttachConsole() {
|
|
11
|
+
if (::AllocConsole()) {
|
|
12
|
+
FILE *unused;
|
|
13
|
+
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
|
|
14
|
+
_dup2(_fileno(stdout), 1);
|
|
15
|
+
}
|
|
16
|
+
if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
|
|
17
|
+
_dup2(_fileno(stdout), 2);
|
|
18
|
+
}
|
|
19
|
+
std::ios::sync_with_stdio();
|
|
20
|
+
FlutterDesktopResyncOutputStreams();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
std::vector<std::string> GetCommandLineArguments() {
|
|
25
|
+
// Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
|
|
26
|
+
int argc;
|
|
27
|
+
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
|
28
|
+
if (argv == nullptr) {
|
|
29
|
+
return std::vector<std::string>();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
std::vector<std::string> command_line_arguments;
|
|
33
|
+
|
|
34
|
+
// Skip the first argument as it's the binary name.
|
|
35
|
+
for (int i = 1; i < argc; i++) {
|
|
36
|
+
command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
::LocalFree(argv);
|
|
40
|
+
|
|
41
|
+
return command_line_arguments;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
std::string Utf8FromUtf16(const wchar_t* utf16_string) {
|
|
45
|
+
if (utf16_string == nullptr) {
|
|
46
|
+
return std::string();
|
|
47
|
+
}
|
|
48
|
+
unsigned int target_length = ::WideCharToMultiByte(
|
|
49
|
+
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
|
50
|
+
-1, nullptr, 0, nullptr, nullptr)
|
|
51
|
+
-1; // remove the trailing null character
|
|
52
|
+
int input_length = (int)wcslen(utf16_string);
|
|
53
|
+
std::string utf8_string;
|
|
54
|
+
if (target_length == 0 || target_length > utf8_string.max_size()) {
|
|
55
|
+
return utf8_string;
|
|
56
|
+
}
|
|
57
|
+
utf8_string.resize(target_length);
|
|
58
|
+
int converted_length = ::WideCharToMultiByte(
|
|
59
|
+
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
|
|
60
|
+
input_length, utf8_string.data(), target_length, nullptr, nullptr);
|
|
61
|
+
if (converted_length == 0) {
|
|
62
|
+
return std::string();
|
|
63
|
+
}
|
|
64
|
+
return utf8_string;
|
|
65
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#ifndef RUNNER_UTILS_H_
|
|
2
|
+
#define RUNNER_UTILS_H_
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
// Creates a console for the process, and redirects stdout and stderr to
|
|
8
|
+
// it for both the runner and the Flutter library.
|
|
9
|
+
void CreateAndAttachConsole();
|
|
10
|
+
|
|
11
|
+
// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
|
|
12
|
+
// encoded in UTF-8. Returns an empty std::string on failure.
|
|
13
|
+
std::string Utf8FromUtf16(const wchar_t* utf16_string);
|
|
14
|
+
|
|
15
|
+
// Gets the command line arguments passed in as a std::vector<std::string>,
|
|
16
|
+
// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
|
|
17
|
+
std::vector<std::string> GetCommandLineArguments();
|
|
18
|
+
|
|
19
|
+
#endif // RUNNER_UTILS_H_
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
#include "win32_window.h"
|
|
2
|
+
|
|
3
|
+
#include <dwmapi.h>
|
|
4
|
+
#include <flutter_windows.h>
|
|
5
|
+
|
|
6
|
+
#include "resource.h"
|
|
7
|
+
|
|
8
|
+
namespace {
|
|
9
|
+
|
|
10
|
+
/// Window attribute that enables dark mode window decorations.
|
|
11
|
+
///
|
|
12
|
+
/// Redefined in case the developer's machine has a Windows SDK older than
|
|
13
|
+
/// version 10.0.22000.0.
|
|
14
|
+
/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
|
15
|
+
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
|
16
|
+
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
|
|
20
|
+
|
|
21
|
+
/// Registry key for app theme preference.
|
|
22
|
+
///
|
|
23
|
+
/// A value of 0 indicates apps should use dark mode. A non-zero or missing
|
|
24
|
+
/// value indicates apps should use light mode.
|
|
25
|
+
constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
|
|
26
|
+
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
|
|
27
|
+
constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
|
|
28
|
+
|
|
29
|
+
// The number of Win32Window objects that currently exist.
|
|
30
|
+
static int g_active_window_count = 0;
|
|
31
|
+
|
|
32
|
+
using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
|
|
33
|
+
|
|
34
|
+
// Scale helper to convert logical scaler values to physical using passed in
|
|
35
|
+
// scale factor
|
|
36
|
+
int Scale(int source, double scale_factor) {
|
|
37
|
+
return static_cast<int>(source * scale_factor);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
|
|
41
|
+
// This API is only needed for PerMonitor V1 awareness mode.
|
|
42
|
+
void EnableFullDpiSupportIfAvailable(HWND hwnd) {
|
|
43
|
+
HMODULE user32_module = LoadLibraryA("User32.dll");
|
|
44
|
+
if (!user32_module) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
auto enable_non_client_dpi_scaling =
|
|
48
|
+
reinterpret_cast<EnableNonClientDpiScaling*>(
|
|
49
|
+
GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
|
|
50
|
+
if (enable_non_client_dpi_scaling != nullptr) {
|
|
51
|
+
enable_non_client_dpi_scaling(hwnd);
|
|
52
|
+
}
|
|
53
|
+
FreeLibrary(user32_module);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} // namespace
|
|
57
|
+
|
|
58
|
+
// Manages the Win32Window's window class registration.
|
|
59
|
+
class WindowClassRegistrar {
|
|
60
|
+
public:
|
|
61
|
+
~WindowClassRegistrar() = default;
|
|
62
|
+
|
|
63
|
+
// Returns the singleton registrar instance.
|
|
64
|
+
static WindowClassRegistrar* GetInstance() {
|
|
65
|
+
if (!instance_) {
|
|
66
|
+
instance_ = new WindowClassRegistrar();
|
|
67
|
+
}
|
|
68
|
+
return instance_;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Returns the name of the window class, registering the class if it hasn't
|
|
72
|
+
// previously been registered.
|
|
73
|
+
const wchar_t* GetWindowClass();
|
|
74
|
+
|
|
75
|
+
// Unregisters the window class. Should only be called if there are no
|
|
76
|
+
// instances of the window.
|
|
77
|
+
void UnregisterWindowClass();
|
|
78
|
+
|
|
79
|
+
private:
|
|
80
|
+
WindowClassRegistrar() = default;
|
|
81
|
+
|
|
82
|
+
static WindowClassRegistrar* instance_;
|
|
83
|
+
|
|
84
|
+
bool class_registered_ = false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
|
|
88
|
+
|
|
89
|
+
const wchar_t* WindowClassRegistrar::GetWindowClass() {
|
|
90
|
+
if (!class_registered_) {
|
|
91
|
+
WNDCLASS window_class{};
|
|
92
|
+
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
|
93
|
+
window_class.lpszClassName = kWindowClassName;
|
|
94
|
+
window_class.style = CS_HREDRAW | CS_VREDRAW;
|
|
95
|
+
window_class.cbClsExtra = 0;
|
|
96
|
+
window_class.cbWndExtra = 0;
|
|
97
|
+
window_class.hInstance = GetModuleHandle(nullptr);
|
|
98
|
+
window_class.hIcon =
|
|
99
|
+
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
|
|
100
|
+
window_class.hbrBackground = 0;
|
|
101
|
+
window_class.lpszMenuName = nullptr;
|
|
102
|
+
window_class.lpfnWndProc = Win32Window::WndProc;
|
|
103
|
+
RegisterClass(&window_class);
|
|
104
|
+
class_registered_ = true;
|
|
105
|
+
}
|
|
106
|
+
return kWindowClassName;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void WindowClassRegistrar::UnregisterWindowClass() {
|
|
110
|
+
UnregisterClass(kWindowClassName, nullptr);
|
|
111
|
+
class_registered_ = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Win32Window::Win32Window() {
|
|
115
|
+
++g_active_window_count;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Win32Window::~Win32Window() {
|
|
119
|
+
--g_active_window_count;
|
|
120
|
+
Destroy();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
bool Win32Window::Create(const std::wstring& title,
|
|
124
|
+
const Point& origin,
|
|
125
|
+
const Size& size) {
|
|
126
|
+
Destroy();
|
|
127
|
+
|
|
128
|
+
const wchar_t* window_class =
|
|
129
|
+
WindowClassRegistrar::GetInstance()->GetWindowClass();
|
|
130
|
+
|
|
131
|
+
const POINT target_point = {static_cast<LONG>(origin.x),
|
|
132
|
+
static_cast<LONG>(origin.y)};
|
|
133
|
+
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
|
134
|
+
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
|
135
|
+
double scale_factor = dpi / 96.0;
|
|
136
|
+
|
|
137
|
+
HWND window = CreateWindow(
|
|
138
|
+
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
|
|
139
|
+
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
|
140
|
+
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
|
141
|
+
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
|
142
|
+
|
|
143
|
+
if (!window) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
UpdateTheme(window);
|
|
148
|
+
|
|
149
|
+
return OnCreate();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
bool Win32Window::Show() {
|
|
153
|
+
return ShowWindow(window_handle_, SW_SHOWNORMAL);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// static
|
|
157
|
+
LRESULT CALLBACK Win32Window::WndProc(HWND const window,
|
|
158
|
+
UINT const message,
|
|
159
|
+
WPARAM const wparam,
|
|
160
|
+
LPARAM const lparam) noexcept {
|
|
161
|
+
if (message == WM_NCCREATE) {
|
|
162
|
+
auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
|
|
163
|
+
SetWindowLongPtr(window, GWLP_USERDATA,
|
|
164
|
+
reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
|
|
165
|
+
|
|
166
|
+
auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
|
|
167
|
+
EnableFullDpiSupportIfAvailable(window);
|
|
168
|
+
that->window_handle_ = window;
|
|
169
|
+
} else if (Win32Window* that = GetThisFromHandle(window)) {
|
|
170
|
+
return that->MessageHandler(window, message, wparam, lparam);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return DefWindowProc(window, message, wparam, lparam);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
LRESULT
|
|
177
|
+
Win32Window::MessageHandler(HWND hwnd,
|
|
178
|
+
UINT const message,
|
|
179
|
+
WPARAM const wparam,
|
|
180
|
+
LPARAM const lparam) noexcept {
|
|
181
|
+
switch (message) {
|
|
182
|
+
case WM_DESTROY:
|
|
183
|
+
window_handle_ = nullptr;
|
|
184
|
+
Destroy();
|
|
185
|
+
if (quit_on_close_) {
|
|
186
|
+
PostQuitMessage(0);
|
|
187
|
+
}
|
|
188
|
+
return 0;
|
|
189
|
+
|
|
190
|
+
case WM_DPICHANGED: {
|
|
191
|
+
auto newRectSize = reinterpret_cast<RECT*>(lparam);
|
|
192
|
+
LONG newWidth = newRectSize->right - newRectSize->left;
|
|
193
|
+
LONG newHeight = newRectSize->bottom - newRectSize->top;
|
|
194
|
+
|
|
195
|
+
SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
|
|
196
|
+
newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
|
|
197
|
+
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
case WM_SIZE: {
|
|
201
|
+
RECT rect = GetClientArea();
|
|
202
|
+
if (child_content_ != nullptr) {
|
|
203
|
+
// Size and position the child window.
|
|
204
|
+
MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
|
|
205
|
+
rect.bottom - rect.top, TRUE);
|
|
206
|
+
}
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
case WM_ACTIVATE:
|
|
211
|
+
if (child_content_ != nullptr) {
|
|
212
|
+
SetFocus(child_content_);
|
|
213
|
+
}
|
|
214
|
+
return 0;
|
|
215
|
+
|
|
216
|
+
case WM_DWMCOLORIZATIONCOLORCHANGED:
|
|
217
|
+
UpdateTheme(hwnd);
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return DefWindowProc(window_handle_, message, wparam, lparam);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void Win32Window::Destroy() {
|
|
225
|
+
OnDestroy();
|
|
226
|
+
|
|
227
|
+
if (window_handle_) {
|
|
228
|
+
DestroyWindow(window_handle_);
|
|
229
|
+
window_handle_ = nullptr;
|
|
230
|
+
}
|
|
231
|
+
if (g_active_window_count == 0) {
|
|
232
|
+
WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
|
|
237
|
+
return reinterpret_cast<Win32Window*>(
|
|
238
|
+
GetWindowLongPtr(window, GWLP_USERDATA));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
void Win32Window::SetChildContent(HWND content) {
|
|
242
|
+
child_content_ = content;
|
|
243
|
+
SetParent(content, window_handle_);
|
|
244
|
+
RECT frame = GetClientArea();
|
|
245
|
+
|
|
246
|
+
MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
|
|
247
|
+
frame.bottom - frame.top, true);
|
|
248
|
+
|
|
249
|
+
SetFocus(child_content_);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
RECT Win32Window::GetClientArea() {
|
|
253
|
+
RECT frame;
|
|
254
|
+
GetClientRect(window_handle_, &frame);
|
|
255
|
+
return frame;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
HWND Win32Window::GetHandle() {
|
|
259
|
+
return window_handle_;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
|
263
|
+
quit_on_close_ = quit_on_close;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
bool Win32Window::OnCreate() {
|
|
267
|
+
// No-op; provided for subclasses.
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
void Win32Window::OnDestroy() {
|
|
272
|
+
// No-op; provided for subclasses.
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
void Win32Window::UpdateTheme(HWND const window) {
|
|
276
|
+
DWORD light_mode;
|
|
277
|
+
DWORD light_mode_size = sizeof(light_mode);
|
|
278
|
+
LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
|
|
279
|
+
kGetPreferredBrightnessRegValue,
|
|
280
|
+
RRF_RT_REG_DWORD, nullptr, &light_mode,
|
|
281
|
+
&light_mode_size);
|
|
282
|
+
|
|
283
|
+
if (result == ERROR_SUCCESS) {
|
|
284
|
+
BOOL enable_dark_mode = light_mode == 0;
|
|
285
|
+
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
|
|
286
|
+
&enable_dark_mode, sizeof(enable_dark_mode));
|
|
287
|
+
}
|
|
288
|
+
}
|