| Flutter Windows Embedder |

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
18 namespace flutter {
19
20 // A controller for a view displaying Flutter content.
21 //
22 // This is the primary wrapper class for the desktop C API.
23 // If you use this class, you should not call any of the setup or teardown
24 // methods in the C API directly, as this class will do that internally.
25 class FlutterViewController {
26 public:
27 // Creates a FlutterView that can be parented into a Windows View hierarchy
28 // either using HWNDs.
29 //
30 // |dart_project| will be used to configure the engine backing this view.
31 explicit FlutterViewController(int width,
32 int height,
33 const DartProject& project);
34
35 virtual ~FlutterViewController();
36
37 // Prevent copying.
38 FlutterViewController(FlutterViewController const&) = delete;
39 FlutterViewController& operator=(FlutterViewController const&) = delete;
40
41 // Returns the engine running Flutter content in this view.
42 FlutterEngine* engine() { return engine_.get(); }
43
44 // Returns the view managed by this controller.
45 FlutterView* view() { return view_.get(); }
46
47 // Requests new frame from the engine and repaints the view.
48 void ForceRedraw();
49
50 // Allows the Flutter engine and any interested plugins an opportunity to
51 // handle the given message.
52 //
53 // If a result is returned, then the message was handled in such a way that
54 // further handling should not be done.
55 std::optional<LRESULT> HandleTopLevelWindowProc(HWND hwnd,
56 UINT message,
57 WPARAM wparam,
58 LPARAM lparam);
59
60 private:
61 // Handle for interacting with the C API's view controller, if any.
62 FlutterDesktopViewControllerRef controller_ = nullptr;
63
64 // The backing engine
65 std::unique_ptr<FlutterEngine> engine_;
66
67 // The owned FlutterView.
68 std::unique_ptr<FlutterView> view_;
69 };
70
71 } // namespace flutter
72
73 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_
dart_project.h
flutter::FlutterEngine
Definition: flutter_engine.h:28
flutter::FlutterViewController::HandleTopLevelWindowProc
std::optional< LRESULT > HandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Definition: flutter_view_controller.cc:36
flutter::DartProject
Definition: dart_project.h:14
flutter_engine.h
flutter::FlutterViewController
Definition: flutter_view_controller.h:25
flutter_view.h
flutter::FlutterViewController::operator=
FlutterViewController & operator=(FlutterViewController const &)=delete
flutter
Definition: accessibility_bridge_windows.cc:11
FlutterDesktopViewControllerRef
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
Definition: flutter_windows.h:25
flutter::FlutterViewController::FlutterViewController
FlutterViewController(int width, int height, const DartProject &project)
Definition: flutter_view_controller.cc:12
flutter::FlutterView
Definition: flutter_view.h:13
flutter::FlutterViewController::view
FlutterView * view()
Definition: flutter_view_controller.h:45
flutter::FlutterViewController::engine
FlutterEngine * engine()
Definition: flutter_view_controller.h:42
flutter_windows.h
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::FlutterViewController::ForceRedraw
void ForceRedraw()
Definition: flutter_view_controller.cc:32
flutter::FlutterViewController::~FlutterViewController
virtual ~FlutterViewController()
Definition: flutter_view_controller.cc:26