Flutter Linux Embedder
fl_view.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_LINUX_PUBLIC_FLUTTER_LINUX_FL_VIEW_H_
6 #define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_VIEW_H_
7 
8 #if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9 #error "Only <flutter_linux/flutter_linux.h> can be included directly."
10 #endif
11 
12 #include <gmodule.h>
13 #include <gtk/gtk.h>
14 
15 #include "fl_dart_project.h"
16 #include "fl_engine.h"
17 
18 G_BEGIN_DECLS
19 
20 G_MODULE_EXPORT
21 G_DECLARE_FINAL_TYPE(FlView, fl_view, FL, VIEW, GtkBox)
22 
23 /**
24  * FlView:
25  *
26  * #FlView is a GTK widget that is capable of displaying a Flutter application.
27  *
28  * The following example shows how to set up a view in a GTK application:
29  * |[<!-- language="C" -->
30  * FlDartProject *project = fl_dart_project_new ();
31  * FlView *view = fl_view_new (project);
32  * gtk_widget_show (GTK_WIDGET (view));
33  * gtk_container_add (GTK_CONTAINER (parent), view);
34  *
35  * FlBinaryMessenger *messenger =
36  * fl_engine_get_binary_messenger (fl_view_get_engine (view));
37  * setup_channels_or_plugins (messenger);
38  * ]|
39  */
40 
41 /**
42  * fl_view_new:
43  * @project: The project to show.
44  *
45  * Creates a widget to show a Flutter application.
46  *
47  * Returns: a new #FlView.
48  */
49 FlView* fl_view_new(FlDartProject* project);
50 
51 /**
52  * fl_view_new_for_engine:
53  * @engine: an #FlEngine.
54  *
55  * Creates a widget to show a window in a Flutter application.
56  * The engine must be not be headless.
57  *
58  * Returns: a new #FlView.
59  */
60 FlView* fl_view_new_for_engine(FlEngine* engine);
61 
62 /**
63  * fl_view_new_sized_to_content:
64  * @engine: an #FlEngine.
65  *
66  * Creates a widget to show a window in a Flutter application.
67  * The window will always display content in the size that Flutter provides.
68  * The engine must be not be headless.
69  *
70  * Returns: a new #FlView.
71  */
72 FlView* fl_view_new_sized_to_content(FlEngine* engine);
73 
74 /**
75  * fl_view_get_engine:
76  * @view: an #FlView.
77  *
78  * Gets the engine being rendered in the view.
79  *
80  * Returns: an #FlEngine.
81  */
82 FlEngine* fl_view_get_engine(FlView* view);
83 
84 /**
85  * fl_view_get_id:
86  * @view: an #FlView.
87  *
88  * Gets the Flutter view ID used by this view.
89  *
90  * Returns: a view ID or -1 if now ID assigned.
91  */
92 int64_t fl_view_get_id(FlView* view);
93 
94 /**
95  * fl_view_set_background_color:
96  * @view: an #FlView.
97  * @color: a background color.
98  *
99  * Set the background color for Flutter (defaults to black).
100  */
101 void fl_view_set_background_color(FlView* view, const GdkRGBA* color);
102 
103 G_END_DECLS
104 
105 #endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_VIEW_H_
G_BEGIN_DECLS G_DECLARE_FINAL_TYPE(FlAccessibilityChannel, fl_accessibility_channel, FL, ACCESSIBILITY_CHANNEL, GObject)
FlView * view
FlView * fl_view_new_for_engine(FlEngine *engine)
Definition: fl_view.cc:817
void fl_view_set_background_color(FlView *view, const GdkRGBA *color)
Definition: fl_view.cc:862
FlView * fl_view_new_sized_to_content(FlEngine *engine)
Definition: fl_view.cc:833
G_BEGIN_DECLS G_MODULE_EXPORT FlView * fl_view_new(FlDartProject *project)
Definition: fl_view.cc:803
FlEngine * fl_view_get_engine(FlView *view)
Definition: fl_view.cc:851
int64_t fl_view_get_id(FlView *view)
Definition: fl_view.cc:857