| Flutter Linux Embedder |

Functions
fl_view.h File Reference
`#include <gmodule.h>`
`#include <gtk/gtk.h>`
`#include "fl_dart_project.h"`
`#include "fl_engine.h"`

Go to the source code of this file.

## Functions
G_BEGIN_DECLS G_MODULE_EXPORT FlView * | fl_view_new (FlDartProject *project)
FlView * | fl_view_new_for_engine (FlEngine *engine)
FlEngine * | fl_view_get_engine (FlView *view)
int64_t | fl_view_get_id (FlView *view)
void | fl_view_set_background_color (FlView *view, const GdkRGBA *color)

## Function Documentation

## ◆ fl_view_get_engine()

FlEngine* fl_view_get_engine | ( | FlView * | view | ) |

fl_view_get_engine: @view: an #FlView.

Gets the engine being rendered in the view.

Returns: an #FlEngine.

Definition at line 874 of file fl_view.cc.

874 {
875 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
876 return self->engine;
877 }

Referenced by TEST().

## ◆ fl_view_get_id()

int64_t fl_view_get_id | ( | FlView * | view | ) |

fl_view_get_id: @view: an #FlView.

Gets the Flutter view ID used by this view.

Returns: a view ID or -1 if now ID assigned.

Definition at line 880 of file fl_view.cc.

880 {
881 g_return_val_if_fail(FL_IS_VIEW(self), -1);
882 return self->view_id;
883 }

Referenced by TEST().

## ◆ fl_view_new()

G_BEGIN_DECLS G_MODULE_EXPORT FlView* fl_view_new | ( | FlDartProject * | project | ) |

FlView:

#FlView is a GTK widget that is capable of displaying a Flutter application.

The following example shows how to set up a view in a GTK application: |[ FlDartProject *project = fl_dart_project_new (); FlView *view = fl_view_new (project); gtk_widget_show (GTK_WIDGET (view)); gtk_container_add (GTK_CONTAINER (parent), view);

FlBinaryMessenger *messenger = fl_engine_get_binary_messenger (fl_view_get_engine (view)); setup_channels_or_plugins (messenger); ]| fl_view_new: @project: The project to show.

Creates a widget to show a Flutter application.

Returns: a new #FlView.

Definition at line 829 of file fl_view.cc.

829 {
830 g_autoptr(FlEngine) engine = fl_engine_new(project);
831 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
832
833 self->view_id = flutter::kFlutterImplicitViewId;
834 self->engine = FL_ENGINE(g_object_ref(engine));
835 FlRenderer* renderer = fl_engine_get_renderer(engine);
836 g_assert(FL_IS_RENDERER_GDK(renderer));
837 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
838
839 fl_engine_set_update_semantics_handler(self->engine, update_semantics_cb,
840 self, nullptr);
841 self->on_pre_engine_restart_handler =
842 g_signal_connect_swapped(engine, "on-pre-engine-restart",
843 G_CALLBACK(on_pre_engine_restart_cb), self);
844
845 g_signal_connect_swapped(self->gl_area, "create-context",
846 G_CALLBACK(create_context_cb), self);
847 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
848 self);
849 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
850 self);
851
852 return self;
853 }

References create_context_cb(), fl_engine_get_renderer(), fl_engine_new(), fl_engine_set_update_semantics_handler(), on_pre_engine_restart_cb(), realize_cb(), unrealize_cb(), and update_semantics_cb().

Referenced by fl_application_activate(), and TEST().

## ◆ fl_view_new_for_engine()

FlView* fl_view_new_for_engine | ( | FlEngine * | engine | ) |

fl_view_new_for_engine: @engine: an #FlEngine.

Creates a widget to show a window in a Flutter application. The engine must be not be headless.

Returns: a new #FlView.

Definition at line 855 of file fl_view.cc.

855 {
856 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
857
858 self->engine = FL_ENGINE(g_object_ref(engine));
859 FlRenderer* renderer = fl_engine_get_renderer(engine);
860 g_assert(FL_IS_RENDERER_GDK(renderer));
861 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
862
863 self->on_pre_engine_restart_handler =
864 g_signal_connect_swapped(engine, "on-pre-engine-restart",
865 G_CALLBACK(on_pre_engine_restart_cb), self);
866
867 self->view_id = fl_engine_add_view(self->engine, 1, 1, 1.0, self->cancellable,
868 view_added_cb, self);
869 fl_renderer_add_view(FL_RENDERER(self->renderer), self->view_id, self);
870
871 return self;
872 }

References fl_engine_add_view(), fl_engine_get_renderer(), fl_renderer_add_view(), on_pre_engine_restart_cb(), and view_added_cb().

Referenced by TEST().

## ◆ fl_view_set_background_color()

void fl_view_set_background_color | ( | FlView * | view,
|  | const GdkRGBA * | color
| ) |  |

fl_view_set_background_color: @view: an #FlView. @color: a background color.

Set the background color for Flutter (defaults to black).

Definition at line 885 of file fl_view.cc.

886 {
887 g_return_if_fail(FL_IS_VIEW(self));
888 gdk_rgba_free(self->background_color);
889 self->background_color = gdk_rgba_copy(color);
890 }
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:574
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:315
fl_engine_get_renderer
FlRenderer * fl_engine_get_renderer(FlEngine *self)
Definition: fl_engine.cc:504
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:654
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:599
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:282
update_semantics_cb
static void update_semantics_cb(FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
Definition: fl_view.cc:302
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:641
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:494
fl_renderer_add_view
void fl_renderer_add_view(FlRenderer *self, FlutterViewId view_id, FlView *view)
Definition: fl_renderer.cc:314
fl_engine_set_update_semantics_handler
void fl_engine_set_update_semantics_handler(FlEngine *self, FlEngineUpdateSemanticsHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:736