Interface IHostableView
Implemented by a view that can be embedded ("hosted") inside a composite view's layout instead of owning its own placement on the canvas. A composite arranges its children through a layout container, so a hosted view must be able to (a) relinquish any self-anchoring/self-sizing it does when standalone, and (b) report the content size the layout should reserve for it.
Namespace: Serenity.Ui.Application.Interfaces.Views
Assembly: Serenity.Ui.Application.dll
Syntax
public interface IHostableView
Remarks
This abstraction lets the composite layer host menus (and any future hostable view) without referencing their concrete Unity types, keeping the dependency direction pointing at the business layer rather than across infrastructure modules.
Methods
GetPreferredHostedHeight()
The content height, in pixels, the layout should reserve when this view is auto-sized.
Declaration
float GetPreferredHostedHeight()
Returns
| Type | Description |
|---|---|
| float | The preferred height in pixels, or a value <= 0 when unknown. |
GetPreferredHostedWidth()
The content width, in pixels, the layout should reserve when this view is auto-sized.
Declaration
float GetPreferredHostedWidth()
Returns
| Type | Description |
|---|---|
| float | The preferred width in pixels, or a value <= 0 when unknown. |
HideHosted()
Drives this view's real "hide" when its hosting composite is hidden. Counterpart of ShowHosted().
Declaration
void HideHosted()
PrepareForHosting(UiAnchorType)
Prepares this view to be placed inside a parent layout container: it should stop positioning or
sizing itself relative to the canvas and let the container drive its rect, anchoring its content
within the slot according to viewAlignment. The first call should snapshot the
standalone state so ReleaseFromHosting() can restore it. Idempotent.
Declaration
void PrepareForHosting(UiAnchorType viewAlignment)
Parameters
| Type | Name | Description |
|---|---|---|
| UiAnchorType | viewAlignment | Where this view's content is anchored within the slot it is given. |
ReleaseFromHosting()
Reverses PrepareForHosting(UiAnchorType): restores the standalone canvas anchoring/sizing captured on the first host so the view can be shown on its own again. Called when the hosting composite releases this view (e.g. when it is hidden), so a shared view instance is never left trapped under an inactive composite. Idempotent.
Declaration
void ReleaseFromHosting()
SetHostView(IViewBase)
Tells this hosted view which top-level view (the composite that ultimately owns it and is registered for navigation) contains it. Navigation history should record that host, not the hosted view itself, so "go back" returns to — and reactivates — the whole composite.
Declaration
void SetHostView(IViewBase host)
Parameters
| Type | Name | Description |
|---|---|---|
| IViewBase | host | The top-level composite view that hosts this view. |
ShowHosted()
Drives this view's real "show" when its hosting composite is shown. Some views (e.g. menus) are
not made visible by activating their GameObject alone — their visuals are revealed by a dedicated
show sequence. The composite calls this instead of Show() for hosted children so they
actually appear.
Declaration
void ShowHosted()
Events
HostedSizeChanged
Raised after this view (re)measures its content while hosted — e.g. when a menu's multi-frame sizing pass finishes. The host listens while the view is mounted so it can refresh the space it reserves (see GetPreferredHostedWidth()/GetPreferredHostedHeight()) and rebuild its layout; the initial build-time measurement of a hosted view is otherwise stale.
Declaration
event Action HostedSizeChanged
Event Type
| Type | Description |
|---|---|
| Action |