Unverified Commit fa12f443 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Update Windows app template (#65696)

parent 9dd67386
...@@ -7,12 +7,12 @@ add_executable(${BINARY_NAME} WIN32 ...@@ -7,12 +7,12 @@ add_executable(${BINARY_NAME} WIN32
"run_loop.cpp" "run_loop.cpp"
"utils.cpp" "utils.cpp"
"win32_window.cpp" "win32_window.cpp"
"window_configuration.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc" "Runner.rc"
"runner.exe.manifest" "runner.exe.manifest"
) )
apply_standard_settings(${BINARY_NAME}) apply_standard_settings(${BINARY_NAME})
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
add_dependencies(${BINARY_NAME} flutter_assemble) add_dependencies(${BINARY_NAME} flutter_assemble)
#ifndef FLUTTER_WINDOW_H_ #ifndef RUNNER_FLUTTER_WINDOW_H_
#define FLUTTER_WINDOW_H_ #define RUNNER_FLUTTER_WINDOW_H_
#include <flutter/dart_project.h> #include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h> #include <flutter/flutter_view_controller.h>
...@@ -36,4 +36,4 @@ class FlutterWindow : public Win32Window { ...@@ -36,4 +36,4 @@ class FlutterWindow : public Win32Window {
std::unique_ptr<flutter::FlutterViewController> flutter_controller_; std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
}; };
#endif // FLUTTER_WINDOW_H_ #endif // RUNNER_FLUTTER_WINDOW_H_
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "flutter_window.h" #include "flutter_window.h"
#include "run_loop.h" #include "run_loop.h"
#include "utils.h" #include "utils.h"
#include "window_configuration.h"
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) { _In_ wchar_t *command_line, _In_ int show_command) {
...@@ -23,9 +22,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, ...@@ -23,9 +22,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
flutter::DartProject project(L"data"); flutter::DartProject project(L"data");
FlutterWindow window(&run_loop, project); FlutterWindow window(&run_loop, project);
Win32Window::Point origin(kFlutterWindowOriginX, kFlutterWindowOriginY); Win32Window::Point origin(10, 10);
Win32Window::Size size(kFlutterWindowWidth, kFlutterWindowHeight); Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(kFlutterWindowTitle, origin, size)) { if (!window.CreateAndShow(L"{{projectName}}", origin, size)) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
window.SetQuitOnClose(true); window.SetQuitOnClose(true);
......
#include "run_loop.h" #include "run_loop.h"
#include <Windows.h> #include <windows.h>
// Don't stomp std::min/std::max
#undef max
#undef min
#include <algorithm> #include <algorithm>
......
#ifndef RUN_LOOP_H_ #ifndef RUNNER_RUN_LOOP_H_
#define RUN_LOOP_H_ #define RUNNER_RUN_LOOP_H_
#include <flutter/flutter_engine.h> #include <flutter/flutter_engine.h>
...@@ -37,4 +37,4 @@ class RunLoop { ...@@ -37,4 +37,4 @@ class RunLoop {
std::set<flutter::FlutterEngine*> flutter_instances_; std::set<flutter::FlutterEngine*> flutter_instances_;
}; };
#endif // RUN_LOOP_H_ #endif // RUNNER_RUN_LOOP_H_
#ifndef CONSOLE_UTILS_H_ #ifndef RUNNER_UTILS_H_
#define CONSOLE_UTILS_H_ #define RUNNER_UTILS_H_
// Creates a console for the process, and redirects stdout and stderr to // Creates a console for the process, and redirects stdout and stderr to
// it for both the runner and the Flutter library. // it for both the runner and the Flutter library.
void CreateAndAttachConsole(); void CreateAndAttachConsole();
#endif // CONSOLE_UTILS_H_ #endif // RUNNER_UTILS_H_
#ifndef WIN32_WINDOW_H_ #ifndef RUNNER_WIN32_WINDOW_H_
#define WIN32_WINDOW_H_ #define RUNNER_WIN32_WINDOW_H_
#include <Windows.h> #include <windows.h>
#include <Windowsx.h>
#include <functional> #include <functional>
#include <memory> #include <memory>
...@@ -96,4 +95,4 @@ class Win32Window { ...@@ -96,4 +95,4 @@ class Win32Window {
HWND child_content_ = nullptr; HWND child_content_ = nullptr;
}; };
#endif // WIN32_WINDOW_H_ #endif // RUNNER_WIN32_WINDOW_H_
#include "window_configuration.h"
const wchar_t* kFlutterWindowTitle = L"{{projectName}}";
const unsigned int kFlutterWindowOriginX = 10;
const unsigned int kFlutterWindowOriginY = 10;
const unsigned int kFlutterWindowWidth = 1280;
const unsigned int kFlutterWindowHeight = 720;
#ifndef WINDOW_CONFIGURATION_
#define WINDOW_CONFIGURATION_
// This is a temporary approach to isolate changes that people are likely to
// make to main.cpp, where the APIs are still in flux. This will reduce the
// need to resolve conflicts or re-create changes slightly differently every
// time the Windows Flutter API surface changes.
//
// Longer term there should be simpler configuration options for common
// customizations like this, without requiring native code changes.
extern const wchar_t* kFlutterWindowTitle;
extern const unsigned int kFlutterWindowOriginX;
extern const unsigned int kFlutterWindowOriginY;
extern const unsigned int kFlutterWindowWidth;
extern const unsigned int kFlutterWindowHeight;
#endif // WINDOW_CONFIGURATION_
...@@ -84,8 +84,6 @@ ...@@ -84,8 +84,6 @@
"templates/app/linux.tmpl/main.cc", "templates/app/linux.tmpl/main.cc",
"templates/app/linux.tmpl/my_application.cc", "templates/app/linux.tmpl/my_application.cc",
"templates/app/linux.tmpl/my_application.h", "templates/app/linux.tmpl/my_application.h",
"templates/app/linux.tmpl/window_configuration.cc.tmpl",
"templates/app/linux.tmpl/window_configuration.h",
"templates/app/macos.tmpl/.gitignore", "templates/app/macos.tmpl/.gitignore",
"templates/app/macos.tmpl/Flutter/Flutter-Debug.xcconfig", "templates/app/macos.tmpl/Flutter/Flutter-Debug.xcconfig",
"templates/app/macos.tmpl/Flutter/Flutter-Release.xcconfig", "templates/app/macos.tmpl/Flutter/Flutter-Release.xcconfig",
...@@ -128,7 +126,7 @@ ...@@ -128,7 +126,7 @@
"templates/app/windows.tmpl/runner/CMakeLists.txt", "templates/app/windows.tmpl/runner/CMakeLists.txt",
"templates/app/windows.tmpl/runner/flutter_window.cpp", "templates/app/windows.tmpl/runner/flutter_window.cpp",
"templates/app/windows.tmpl/runner/flutter_window.h", "templates/app/windows.tmpl/runner/flutter_window.h",
"templates/app/windows.tmpl/runner/main.cpp", "templates/app/windows.tmpl/runner/main.cpp.tmpl",
"templates/app/windows.tmpl/runner/resource.h", "templates/app/windows.tmpl/runner/resource.h",
"templates/app/windows.tmpl/runner/resources/app_icon.ico.img.tmpl", "templates/app/windows.tmpl/runner/resources/app_icon.ico.img.tmpl",
"templates/app/windows.tmpl/runner/runner.exe.manifest", "templates/app/windows.tmpl/runner/runner.exe.manifest",
...@@ -139,8 +137,6 @@ ...@@ -139,8 +137,6 @@
"templates/app/windows.tmpl/runner/utils.h", "templates/app/windows.tmpl/runner/utils.h",
"templates/app/windows.tmpl/runner/win32_window.cpp", "templates/app/windows.tmpl/runner/win32_window.cpp",
"templates/app/windows.tmpl/runner/win32_window.h", "templates/app/windows.tmpl/runner/win32_window.h",
"templates/app/windows.tmpl/runner/window_configuration.cpp.tmpl",
"templates/app/windows.tmpl/runner/window_configuration.h",
"templates/cocoapods/Podfile-ios-objc", "templates/cocoapods/Podfile-ios-objc",
"templates/cocoapods/Podfile-ios-swift", "templates/cocoapods/Podfile-ios-swift",
"templates/cocoapods/Podfile-macos", "templates/cocoapods/Podfile-macos",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment