Flutter Engine
flutter_view_controller.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_
7 
8 #include <flutter_windows.h>
9 #include <windows.h>
10 
11 #include <memory>
12 #include <optional>
13 
14 #include "dart_project.h"
15 #include "flutter_engine.h"
16 #include "flutter_view.h"
17 #include "plugin_registrar.h"
18 #include "plugin_registry.h"
19 
20 #ifdef WINUWP
21 #include <windows.applicationmodel.activation.h>
22 #include <windows.ui.core.h>
23 #endif
24 
25 namespace flutter {
26 
27 // A controller for a view displaying Flutter content.
28 //
29 // This is the primary wrapper class for the desktop C API.
30 // If you use this class, you should not call any of the setup or teardown
31 // methods in the C API directly, as this class will do that internally.
33  public:
34 #ifndef WINUWP
35  // Creates a FlutterView that can be parented into a Windows View hierarchy
36  // either using HWNDs.
37  //
38  // |dart_project| will be used to configure the engine backing this view.
39  explicit FlutterViewController(int width,
40  int height,
41  const DartProject& project);
42 #else
43  // Creates a FlutterView that can be parented into a Windows View hierarchy
44  // either using CoreWindow.
45  //
46  // |dart_project| will be used to configure the engine backing this view.
47  // |IActivatedEventArgs| will be used to configure the engine switches. Can
48  // be set to nullptr.
49  explicit FlutterViewController(
50  ABI::Windows::ApplicationModel::Core::CoreApplicationView*
51  applicationview,
52  ABI::Windows::ApplicationModel::Activation::IActivatedEventArgs* args,
53  const DartProject& project);
54 #endif
55 
56  virtual ~FlutterViewController();
57 
58  // Prevent copying.
61 
62  // Returns the engine running Flutter content in this view.
63  FlutterEngine* engine() { return engine_.get(); }
64 
65  // Returns the view managed by this controller.
66  FlutterView* view() { return view_.get(); }
67 
68 #ifndef WINUWP
69  // Allows the Flutter engine and any interested plugins an opportunity to
70  // handle the given message.
71  //
72  // If a result is returned, then the message was handled in such a way that
73  // further handling should not be done.
74  std::optional<LRESULT> HandleTopLevelWindowProc(HWND hwnd,
75  UINT message,
76  WPARAM wparam,
77  LPARAM lparam);
78 #endif
79 
80  private:
81  // Handle for interacting with the C API's view controller, if any.
82  FlutterDesktopViewControllerRef controller_ = nullptr;
83 
84  // The backing engine
85  std::unique_ptr<FlutterEngine> engine_;
86 
87  // The owned FlutterView.
88  std::unique_ptr<FlutterView> view_;
89 };
90 
91 } // namespace flutter
92 
93 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_
G_BEGIN_DECLS FlValue * args
UINT_PTR WPARAM
Definition: windows_types.h:59
FlutterViewController(int width, int height, const DartProject &project)
std::optional< LRESULT > HandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
int32_t width
FlutterViewController & operator=(FlutterViewController const &)=delete
int32_t height
LONG_PTR LPARAM
Definition: windows_types.h:60
unsigned int UINT
Definition: windows_types.h:32