Skip to content

CefOverlayController

Header: cef_overlay_controller.h
Category: Views Framework

Overview

Browser-process UI toolkit: windows, panels, layouts, buttons, textfields, and their delegates.

CefOverlayController

Source File: include/views/cef_overlay_controller.h

Process / Thread Context: Browser Process / UI Thread.

Purpose: Controller for an overlay containing a contents view added via

Methods

virtual bool IsValid() = 0

Parameters:

  • none.

Return Value: True if this controller is still valid.

Usage Instruction: Verify before use after potential destruction.

Threading Constraint: Browser process UI thread.

virtual bool IsSame(CefRefPtr<CefOverlayController> that) = 0

Parameters:

  • that: Another controller to compare.

Return Value: True if both controllers refer to the same overlay.

Usage Instruction: Identity comparison.

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefView> GetContentsView() = 0

Parameters:

  • none.

Return Value: The contents view of the overlay.

Usage Instruction: Access the underlying view (e.g., to add child

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefWindow> GetWindow() = 0

Parameters:

  • none.

Return Value: The top-level window hosting this overlay. Preferred

Usage Instruction: Access the parent window.

Threading Constraint: Browser process UI thread.

virtual cef_docking_mode_t GetDockingMode() = 0

Parameters:

  • none.

Return Value: The docking mode used to create this overlay. Default

Usage Instruction: Branch on docking mode to decide which controller

Threading Constraint: Browser process UI thread.

virtual void Destroy() = 0

Parameters:

  • none.

Return Value: void.

Usage Instruction: Permanently destroy the overlay.

Threading Constraint: Browser process UI thread.

virtual void SetBounds(const CefRect& bounds) = 0

Parameters:

  • bounds: New bounds in parent coordinates. Any configured insets are

Return Value: void. Also sets the contents view's bounds and

Usage Instruction: **Only for overlays created with

Threading Constraint: Browser process UI thread.

virtual CefRect GetBounds() = 0

Parameters:

  • none.

Return Value: Bounds in parent coordinates.

Usage Instruction: Read overlay geometry.

Threading Constraint: Browser process UI thread.

virtual CefRect GetBoundsInScreen() = 0

Parameters:

  • none.

Return Value: Bounds in DIP screen coordinates.

Usage Instruction: Position popups relative to the overlay.

Threading Constraint: Browser process UI thread.

virtual void SetSize(const CefSize& size) = 0

Parameters:

  • size: New size in parent coordinates; insets ignored.

Return Value: void. Sets the contents view's size and triggers a

Usage Instruction: Only for CEF_DOCKING_MODE_CUSTOM overlays.

Threading Constraint: Browser process UI thread.

virtual CefSize GetSize() = 0

Parameters:

  • none.

Return Value: Size in parent coordinates.

Usage Instruction: Read overlay size.

Threading Constraint: Browser process UI thread.

virtual void SetPosition(const CefPoint& position) = 0

Parameters:

  • position: New position in parent coordinates; insets ignored.

Return Value: void.

Usage Instruction: Only for CEF_DOCKING_MODE_CUSTOM overlays.

Threading Constraint: Browser process UI thread.

virtual CefPoint GetPosition() = 0

Parameters:

  • none.

Return Value: Position in parent coordinates.

Usage Instruction: Read overlay position.

Threading Constraint: Browser process UI thread.

virtual void SetInsets(const CefInsets& insets) = 0

Parameters:

  • insets: New insets in parent coordinates.

Return Value: void.

Usage Instruction: **Only for overlays with docking mode other than

Threading Constraint: Browser process UI thread.

virtual CefInsets GetInsets() = 0

Parameters:

  • none.

Return Value: Current insets in parent coordinates.

Usage Instruction: Read insets.

Threading Constraint: Browser process UI thread.

virtual void SizeToPreferredSize() = 0

Parameters:

  • none.

Return Value: void. Resizes the overlay to its preferred size and

Usage Instruction: Recompute overlay size after contents change.

Threading Constraint: Browser process UI thread.

virtual void SetVisible(bool visible) = 0

Parameters:

  • visible: True to show. Overlays are hidden by default.

Return Value: void. Hidden overlays and their children are not drawn;

Usage Instruction: Toggle overlay visibility.

Threading Constraint: Browser process UI thread.

virtual bool IsVisible() = 0

Parameters:

  • none.

Return Value: True if this overlay's visibility flag is set. A visible

Usage Instruction: Visibility flag check.

Threading Constraint: Browser process UI thread.

virtual bool IsDrawn() = 0

Parameters:

  • none.

Return Value: True if this overlay and all parents are visible (so

Usage Instruction: Determine if the overlay is on screen.

Threading Constraint: Browser process UI thread.

Usage Example

cpp
// Create a small floating toolbar at the top-left of the window.
auto toolbar = CefPanel::CreatePanel(nullptr);
auto box = toolbar->SetToBoxLayout(CefBoxLayoutSettings{});
box->SetFlexForView(
    toolbar->AddChildViewAt(CefLabelButton::CreateLabelButton(bd, "Back"), 0),
    1);

auto overlay = window->AddOverlayView(toolbar,
                                       CEF_DOCKING_MODE_TOP_LEFT,
                                       /*can_activate=*/false);
overlay->SetInsets(CefInsets(8, 8, 0, 0));   // 8 DIP from top & left
overlay->SizeToPreferredSize();
overlay->SetVisible(true);

Derived from the CEF C++ headers — © Marshall A. Greenblatt, Google Inc. & contributors (BSD-style license). Not an official CEF project.