Flutter Engine
The Flutter Engine
flutter_window.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_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_
6#define FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_
7
8#include <flutter_glfw.h>
9
10#include <string>
11#include <vector>
12
13#include "plugin_registrar.h"
14
15namespace flutter {
16
17// A data type for window position and size.
19 int left;
20 int top;
21 int width;
22 int height;
23};
24
25// A window displaying Flutter content.
27 public:
29
30 ~FlutterWindow() = default;
31
32 // Prevent copying.
33 FlutterWindow(FlutterWindow const&) = delete;
35
36 // Enables or disables hover tracking.
37 //
38 // If hover is enabled, mouse movement will send hover events to the Flutter
39 // engine, rather than only tracking the mouse while the button is pressed.
40 // Defaults to off.
41 void SetHoverEnabled(bool enabled) {
43 }
44
45 // Sets the displayed title of the window.
46 void SetTitle(const std::string& title) {
47 FlutterDesktopWindowSetTitle(window_, title.c_str());
48 }
49
50 // Sets the displayed icon for the window.
51 //
52 // The pixel format is 32-bit RGBA. The provided image data only needs to be
53 // valid for the duration of the call to this method. Pass a nullptr to revert
54 // to the default icon.
55 void SetIcon(uint8_t* pixel_data, int width, int height) {
56 FlutterDesktopWindowSetIcon(window_, pixel_data, width, height);
57 }
58
59 // Returns the frame of the window, including any decoration (e.g., title
60 // bar), in screen coordinates.
62 WindowFrame frame = {};
63 FlutterDesktopWindowGetFrame(window_, &frame.left, &frame.top, &frame.width,
64 &frame.height);
65 return frame;
66 }
67
68 // Set the frame of the window, including any decoration (e.g., title
69 // bar), in screen coordinates.
70 void SetFrame(const WindowFrame& frame) {
71 FlutterDesktopWindowSetFrame(window_, frame.left, frame.top, frame.width,
72 frame.height);
73 }
74
75 // Returns the number of pixels per screen coordinate for the window.
76 //
77 // Flutter uses pixel coordinates, so this is the ratio of positions and sizes
78 // seen by Flutter as compared to the screen.
79 double GetScaleFactor() {
81 }
82
83 // Forces a specific pixel ratio for Flutter rendering, rather than one
84 // computed automatically from screen information.
85 //
86 // To clear a previously set override, pass an override value of zero.
87 void SetPixelRatioOverride(double pixel_ratio) {
89 }
90
91 // Sets the min/max size of |flutter_window| in screen coordinates. Use
92 // kFlutterDesktopDontCare for any dimension you wish to leave unconstrained.
94 FlutterDesktopSize maximum_size) {
95 FlutterDesktopWindowSetSizeLimits(window_, minimum_size, maximum_size);
96 }
97
98 private:
99 // Handle for interacting with the C API's window.
100 //
101 // Note: window_ is conceptually owned by the controller, not this object.
103};
104
105} // namespace flutter
106
107#endif // FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_WINDOW_H_
FlutterWindow & operator=(FlutterWindow const &)=delete
void SetTitle(const std::string &title)
void SetIcon(uint8_t *pixel_data, int width, int height)
FlutterWindow(FlutterDesktopWindowRef window)
WindowFrame GetFrame()
FlutterWindow(FlutterWindow const &)=delete
void SetPixelRatioOverride(double pixel_ratio)
void SetFrame(const WindowFrame &frame)
void SetSizeLimits(FlutterDesktopSize minimum_size, FlutterDesktopSize maximum_size)
void SetHoverEnabled(bool enabled)
GLFWwindow * window
Definition: main.cc:45
double frame
Definition: examples.cpp:31
int32_t height
int32_t width
double FlutterDesktopWindowGetScaleFactor(FlutterDesktopWindowRef flutter_window)
void FlutterDesktopWindowSetPixelRatioOverride(FlutterDesktopWindowRef flutter_window, double pixel_ratio)
void FlutterDesktopWindowSetSizeLimits(FlutterDesktopWindowRef flutter_window, FlutterDesktopSize minimum_size, FlutterDesktopSize maximum_size)
void FlutterDesktopWindowGetFrame(FlutterDesktopWindowRef flutter_window, int *x, int *y, int *width, int *height)
void FlutterDesktopWindowSetHoverEnabled(FlutterDesktopWindowRef flutter_window, bool enabled)
void FlutterDesktopWindowSetFrame(FlutterDesktopWindowRef flutter_window, int x, int y, int width, int height)
void FlutterDesktopWindowSetTitle(FlutterDesktopWindowRef flutter_window, const char *title)
void FlutterDesktopWindowSetIcon(FlutterDesktopWindowRef flutter_window, uint8_t *pixel_data, int width, int height)