Skip to content

Commit da93881

Browse files
committed
Merge branch 'tiger808-component_name_option'
2 parents 1167139 + 2c3941c commit da93881

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/scenic/primitive.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Scenic.Primitive do
3636
versions of the drivers.
3737
3838
* [`Arc`](Scenic.Primitive.Arc.html) draws an arc. This would be a line cut out of a part of the edge of a circle. If you want a shape that looks like a piece of pie, then you should use the [`Sector`](Scenic.Primitive.Sector.html).
39-
* [`Circle`](Scenic.Primitive.Circle.html) draws a circle.
39+
* [`Circle`](Scenic.Primitive.Circle.html) draws a circle.
4040
* [`Ellipse`](Scenic.Primitive.Ellipse.html) draws an ellipse.
4141
* [`Group`](Scenic.Primitive.Group.html) doesn't draw anything. Instead, it creates a node in the graph that you can insert more primitives into. Any styles or transforms you apply to the Group are inherited by all the primitives below it.
4242
* [`Line`](Scenic.Primitive.Line.html) draws a line.
@@ -74,6 +74,7 @@ defmodule Scenic.Primitive do
7474
@not_styles [
7575
:module,
7676
:id,
77+
:name,
7778
:parent_uid,
7879
:builder,
7980
:data,
@@ -88,7 +89,7 @@ defmodule Scenic.Primitive do
8889

8990
@transform_types [:pin, :rotate, :matrix, :scale, :translate]
9091

91-
@standard_options [:id]
92+
@standard_options [:id, :name]
9293

9394
# note: the following fields are all optional on a primitive.
9495
# :id, :tags, :event_filter, :state, :styles, :transforms
@@ -239,8 +240,8 @@ defmodule Scenic.Primitive do
239240

240241
# enumerate and apply each of the standard opts
241242
Enum.reduce(opts, p, fn
242-
{:id, v}, p ->
243-
Map.put(p, :id, v)
243+
{opt, v}, p ->
244+
Map.put(p, opt, v)
244245
end)
245246
end
246247

lib/scenic/scene.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,12 +1387,18 @@ defmodule Scenic.Scene do
13871387

13881388
# prepare the startup options to send to the new scene
13891389
id = Map.get(raw_graph.primitives[uid], :id)
1390+
name = Map.get(raw_graph.primitives[uid], :name)
13901391

13911392
init_opts =
13921393
case viewport do
13931394
nil -> [styles: styles, id: id]
13941395
vp -> [viewport: vp, styles: styles, id: id]
13951396
end
1397+
init_opts =
1398+
case name do
1399+
nil -> init_opts
1400+
value -> [{:name, value} | init_opts]
1401+
end
13961402

13971403
# start the dynamic scene
13981404
{:ok, pid, ref} = mod.start_dynamic_scene(dyn_sup, self(), init_data, init_opts)

0 commit comments

Comments
 (0)