| 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 // This also creates a new FlutterEngine.
31 //
32 // |dart_project| will be used to configure the engine backing this view.
33 FlutterViewController(int width, int height, 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 view controller's view ID.
42 FlutterViewId view_id() const;
43
44 // Returns the engine running Flutter content in this view.
45 FlutterEngine* engine() const { return engine_.get(); }
46
47 // Returns the view managed by this controller.
48 FlutterView* view() const { return view_.get(); }
49
50 // Requests new frame from the engine and repaints the view.
51 void ForceRedraw();
52
53 // Allows the Flutter engine and any interested plugins an opportunity to
54 // handle the given message.
55 //
56 // If a result is returned, then the message was handled in such a way that
57 // further handling should not be done.
58 std::optional<LRESULT> HandleTopLevelWindowProc(HWND hwnd,
59 UINT message,
60 WPARAM wparam,
61 LPARAM lparam);
62
63 private:
64 // Handle for interacting with the C API's view controller, if any.
65 FlutterDesktopViewControllerRef controller_ = nullptr;
66
67 // The backing engine
68 std::shared_ptr<FlutterEngine> engine_;
69
70 // The owned FlutterView.
71 std::unique_ptr<FlutterView> view_;
72 };
73
74 } // namespace flutter
75
76 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_
flutter::DartProject
Definition: dart_project.h:39
flutter::FlutterEngine
Definition: flutter_engine.h:28
flutter::FlutterViewController
Definition: flutter_view_controller.h:25
flutter::FlutterViewController::HandleTopLevelWindowProc
std::optional< LRESULT > HandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Definition: flutter_view_controller.cc:42
flutter::FlutterViewController::ForceRedraw
void ForceRedraw()
Definition: flutter_view_controller.cc:38
flutter::FlutterViewController::FlutterViewController
FlutterViewController(int width, int height, const DartProject &project)
Definition: flutter_view_controller.cc:12
flutter::FlutterViewController::FlutterViewController
FlutterViewController(FlutterViewController const &)=delete
flutter::FlutterViewController::view
FlutterView * view() const
Definition: flutter_view_controller.h:48
flutter::FlutterViewController::view_id
FlutterViewId view_id() const
Definition: flutter_view_controller.cc:32
flutter::FlutterViewController::engine
FlutterEngine * engine() const
Definition: flutter_view_controller.h:45
flutter::FlutterViewController::~FlutterViewController
virtual ~FlutterViewController()
Definition: flutter_view_controller.cc:26
flutter::FlutterViewController::operator=
FlutterViewController & operator=(FlutterViewController const &)=delete
flutter::FlutterView
Definition: flutter_view.h:16
dart_project.h
flutter_engine.h
flutter_view.h
flutter_windows.h
FlutterDesktopViewControllerRef
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
Definition: flutter_windows.h:25
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::FlutterViewId
int64_t FlutterViewId
Definition: accessibility_plugin.h:15