| 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 827 of file fl_view.cc.

827 {
828 g_return_val_if_fail(FL_IS_VIEW(self), nullptr);
829 return self->engine;
830 }

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 833 of file fl_view.cc.

833 {
834 g_return_val_if_fail(FL_IS_VIEW(self), -1);
835 return self->view_id;
836 }

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 775 of file fl_view.cc.

775 {
776 g_autoptr(FlEngine) engine = fl_engine_new(project);
777 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
778
779 self->view_id = flutter::kFlutterImplicitViewId;
780 self->engine = FL_ENGINE(g_object_ref(engine));
781 FlRenderer* renderer = fl_engine_get_renderer(engine);
782 g_assert(FL_IS_RENDERER_GDK(renderer));
783 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
784
785 self->pointer_manager = fl_pointer_manager_new(self->view_id, engine);
786
787 fl_engine_set_update_semantics_handler(self->engine, update_semantics_cb,
788 self, nullptr);
789 self->on_pre_engine_restart_cb_id =
790 g_signal_connect_swapped(engine, "on-pre-engine-restart",
791 G_CALLBACK(on_pre_engine_restart_cb), self);
792
793 g_signal_connect_swapped(self->gl_area, "create-context",
794 G_CALLBACK(create_context_cb), self);
795 g_signal_connect_swapped(self->gl_area, "realize", G_CALLBACK(realize_cb),
796 self);
797 g_signal_connect_swapped(self->gl_area, "unrealize", G_CALLBACK(unrealize_cb),
798 self);
799
800 return self;
801 }

References create_context_cb(), fl_engine_get_renderer(), fl_engine_new(), fl_engine_set_update_semantics_handler(), fl_pointer_manager_new(), 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 803 of file fl_view.cc.

803 {
804 FlView* self = FL_VIEW(g_object_new(fl_view_get_type(), nullptr));
805
806 self->engine = FL_ENGINE(g_object_ref(engine));
807 FlRenderer* renderer = fl_engine_get_renderer(engine);
808 g_assert(FL_IS_RENDERER_GDK(renderer));
809 self->renderer = FL_RENDERER_GDK(g_object_ref(renderer));
810
811 self->on_pre_engine_restart_cb_id =
812 g_signal_connect_swapped(engine, "on-pre-engine-restart",
813 G_CALLBACK(on_pre_engine_restart_cb), self);
814
815 self->view_id = fl_engine_add_view(self->engine, 1, 1, 1.0, self->cancellable,
816 view_added_cb, self);
817 fl_renderer_add_renderable(FL_RENDERER(self->renderer), self->view_id,
818 FL_RENDERABLE(self));
819
820 self->pointer_manager = fl_pointer_manager_new(self->view_id, engine);
821
822 setup_cursor(self);
823
824 return self;
825 }

References fl_engine_add_view(), fl_engine_get_renderer(), fl_pointer_manager_new(), fl_renderer_add_renderable(), on_pre_engine_restart_cb(), setup_cursor(), 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 838 of file fl_view.cc.

839 {
840 g_return_if_fail(FL_IS_VIEW(self));
841 gdk_rgba_free(self->background_color);
842 self->background_color = gdk_rgba_copy(color);
843 }
create_context_cb
static GdkGLContext * create_context_cb(FlView *self)
Definition: fl_view.cc:516
on_pre_engine_restart_cb
static void on_pre_engine_restart_cb(FlView *self)
Definition: fl_view.cc:288
fl_engine_get_renderer
FlRenderer * fl_engine_get_renderer(FlEngine *self)
Definition: fl_engine.cc:534
unrealize_cb
static void unrealize_cb(FlView *self)
Definition: fl_view.cc:591
realize_cb
static void realize_cb(FlView *self)
Definition: fl_view.cc:533
view_added_cb
static void view_added_cb(GObject *object, GAsyncResult *result, gpointer user_data)
Definition: fl_view.cc:255
update_semantics_cb
static void update_semantics_cb(FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
Definition: fl_view.cc:275
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:678
setup_cursor
static void setup_cursor(FlView *self)
Definition: fl_view.cc:210
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:524
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:778
fl_renderer_add_renderable
void fl_renderer_add_renderable(FlRenderer *self, FlutterViewId view_id, FlRenderable *renderable)
Definition: fl_renderer.cc:341
fl_pointer_manager_new
FlPointerManager * fl_pointer_manager_new(FlutterViewId view_id, FlEngine *engine)
Definition: fl_pointer_manager.cc:65