Skip to content

Commit 52cd988

Browse files
committed
Dynamic viewport without private APIs
1 parent db4d76d commit 52cd988

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/scenic/driver.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,11 @@ defmodule Scenic.Driver do
887887
name: [type: :atom]
888888
]
889889

890-
@doc false
890+
@doc """
891+
Validate driver configuration
892+
893+
Used primarily for dynamic view port creation
894+
"""
891895
def validate([]), do: {:ok, []}
892896

893897
def validate(drivers) do

lib/scenic/view_port.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ defmodule Scenic.ViewPort do
9191
leave the scene that thinks it has "captured" the input in an inconsistent
9292
state, so this is not recommended.
9393
94+
## Dynamically Creating View Ports
95+
96+
Pass in the same set of opts that you would use when starting `Scenic` in your
97+
supervision tree. For example:
98+
99+
opts = [
100+
name: name,
101+
module: Scenic.Driver.Local,
102+
window: [resizeable: false, title: "My Example Scenic App"],
103+
on_close: :stop_system
104+
]
105+
106+
{:ok, [opts]} = Scenic.Driver.validate([opts])
107+
Scenic.ViewPort.start_driver(view_port, opts)
94108
"""
95109

96110
@type t :: %ViewPort{

0 commit comments

Comments
 (0)