scenic_driver_renderling/lib/scenic_driver_rendering/window/config.ex
James Harton f322b7d9d8
Some checks failed
continuous-integration/drone/push Build is failing
chore: Set up tests, linting and CI.
2024-05-17 14:31:49 +12:00

49 lines
1.3 KiB
Elixir

defmodule Scenic.Driver.Renderling.Window.Config do
@moduledoc """
Configuration generated by parsing the options provided to the driver.
It's a struct to make it easier to derive from rustler.
"""
alias __MODULE__.{Position, Window}
defstruct name: nil,
antialias: true,
position: nil,
window: nil,
cursor: false,
key_map: Scenic.KeyMap.USEnglish,
on_close: :restart,
input_blacklist: [],
server_path: nil
@type t :: %__MODULE__{
name: atom | String.t(),
antialias: boolean,
position: Position.t(),
window: Window.t(),
cursor: boolean,
key_map: module,
on_close: :restart | :stop_driver | :stop_viewport | :stop_system | :halt_system,
input_blacklist: [String.t()],
server_path: Path.t()
}
@doc false
@spec init(keyword) :: t
def init(opts) do
attrs =
opts
|> Keyword.update(:position, Position.init([]), &Position.init/1)
|> Keyword.update(:window, Window.init([]), &Window.init/1)
|> Keyword.put(:server_path, compute_server_path())
struct(__MODULE__, attrs)
end
defp compute_server_path do
:scenic_driver_renderling
|> :code.priv_dir()
|> Path.join("native/scenic_window_server")
end
end