Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
18namespace 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.
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.
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,
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_
FlutterViewController & operator=(FlutterViewController const &)=delete
FlutterViewController(FlutterViewController const &)=delete
std::optional< LRESULT > HandleTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
Win32Message message
int64_t FlutterViewId
int32_t height
int32_t width
unsigned int UINT
LONG_PTR LPARAM
UINT_PTR WPARAM