Skip to content

Commit 849ad98

Browse files
authored
Merge pull request #100 from boydm/boyd
Document remaining styles
2 parents f45efcb + 5d1f3d0 commit 849ad98

File tree

8 files changed

+124
-9
lines changed

8 files changed

+124
-9
lines changed

lib/scenic/primitive/style/scissor.ex

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44
#
55

66
defmodule Scenic.Primitive.Style.Scissor do
7-
@moduledoc false
7+
@moduledoc """
8+
Define a "Scissor Rectangle" that drawing will be clipped to.
9+
10+
Example:
11+
12+
graph
13+
|> triangle( {{0,40},{40,40},{40,0}}
14+
miter_limit: 2,
15+
fill: :green,
16+
scissor: {20, 40}
17+
)
18+
19+
## Data
20+
21+
`{width, height}`
22+
23+
* `width` - Width of the scissor rectangle.
24+
* `height` - Height of the scissor rectangle.
25+
"""
826

927
use Scenic.Primitive.Style
1028

lib/scenic/primitive/style/stroke.ex

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44
#
55

66
defmodule Scenic.Primitive.Style.Stroke do
7-
@moduledoc false
7+
@moduledoc """
8+
Draw an outline around a primitive with the given paint.
9+
10+
Example:
11+
12+
graph
13+
|> triangle( {{0,40},{40,40},{40,0}}
14+
miter_limit: 2,
15+
stroke: {2, :green}
16+
)
17+
18+
## Data
19+
20+
`{width, paint}`
21+
22+
* `width` - Width of the border being stroked.
23+
* `:paint` - Any [valid paint](Scenic.Primitive.Style.Paint.html).
24+
"""
825

926
use Scenic.Primitive.Style
1027
alias Scenic.Primitive.Style.Paint

lib/scenic/primitive/style/text_align.ex

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@
44
#
55

66
defmodule Scenic.Primitive.Style.TextAlign do
7-
@moduledoc false
7+
@moduledoc """
8+
Set the alignment of the text with regard to the start point.
9+
10+
Example:
11+
12+
graph
13+
|> text( "Some Text" text_align: :center_middle )
14+
15+
## Data
16+
17+
`alignment`
18+
19+
The alignment type can be any one of the following
20+
21+
* `left` - Left side horizontally. Base of the text vertically.
22+
* `:right` - Right side horizontally. Base of the text vertically.
23+
* `:center` - Centered horizontally. Base of the text vertically.
24+
* `left_top` - Left side horizontally. Top of the text vertically.
25+
* `:right_top` - Right side horizontally. Top of the text vertically.
26+
* `:center_top` - Centered horizontally. Top of the text vertically.
27+
* `left_middle` - Left side horizontally. Centered vertically.
28+
* `:right_middle` - Right side horizontally. Centered vertically.
29+
* `:center_middle` - Centered horizontally. Centered vertically.
30+
* `left_bottom` - Left side horizontally. Bottom of the text vertically.
31+
* `:right_bottom` - Right side horizontally. Bottom of the text vertically.
32+
* `:center_bottom` - Centered horizontally. Bottom of the text vertically.
33+
"""
834

935
use Scenic.Primitive.Style
1036
# alias Scenic.Primitive.Style

lib/scenic/primitive/style/text_height.ex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,23 @@
44
#
55

66
defmodule Scenic.Primitive.Style.TextHeight do
7-
@moduledoc false
7+
@moduledoc """
8+
Set the vertical spacing of lines of text in a single block.
9+
10+
Example:
11+
12+
graph
13+
|> text( "Some Text\\r\\nMore Text" text_height: 50 )
14+
15+
The natural vertical spacing of the font is used by default. Set this style if
16+
you want to override it.
17+
18+
## Data
19+
20+
`spacing`
21+
22+
* `spacing` - Vertical spacing from line to line.
23+
"""
824

925
use Scenic.Primitive.Style
1026
# alias Scenic.Primitive.Style

lib/scenic/primitive/style/theme.ex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ defmodule Scenic.Primitive.Style.Theme do
1212
1313
Unlike other styles, these are a guide to the components.
1414
Each component gets to pick, choose, or ignore any colors in a given style.
15+
16+
## Main Predefined Themes
17+
* `:dark` - This is the default and most common. Use when the background is dark.
18+
* `:light` - Use when the background is light colored.
19+
20+
## Specialty Themes
21+
22+
The remaining themes are designed to color the standard components and don't really
23+
make much sense when applied to the root of a graph. You could, but it would be...
24+
interesting.
25+
26+
The most obvious place to use them is with [`Button`](Scenic.Component.Button.html)
27+
components.
28+
29+
* `:primary` - Blue background. This is the primary button type indicator.
30+
* `:secondary` - Grey background. Not primary type indicator.
31+
* `:success` - Green background.
32+
* `:danger` - Red background. Use for irreversible or dangerous actions.
33+
* `:warning` - Orange background.
34+
* `:info` - Lightish blue background.
35+
* `:text` - Transparent background.
1536
"""
1637

1738
use Scenic.Primitive.Style

lib/scenic/view_port.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,19 @@ defmodule Scenic.ViewPort do
356356
root_config: root_config,
357357
root_scene_pid: root_scene_pid,
358358
root_graph_key: root_graph_key,
359-
size: size
359+
size: size,
360+
master_styles: styles,
361+
master_transforms: transforms
360362
} = state
361363
) do
362364
status = %ViewPort.Status{
363365
root_scene_pid: root_scene_pid,
364366
root_config: root_config,
365367
root_graph: root_graph_key,
366368
drivers: driver_registry,
367-
size: size
369+
size: size,
370+
styles: styles,
371+
transforms: transforms
368372
}
369373

370374
{:reply, {:ok, status}, state}
@@ -434,6 +438,7 @@ defmodule Scenic.ViewPort do
434438
max_depth: config.max_depth,
435439
on_close: on_close,
436440
master_styles: styles,
441+
master_transforms: transforms,
437442
master_graph: master_graph,
438443
master_graph_key: master_graph_key
439444
}

lib/scenic/view_port/status.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ defmodule Scenic.ViewPort.Status do
1010
alias Scenic.ViewPort.Status
1111
alias Scenic.Math
1212

13-
defstruct drivers: nil, root_config: nil, root_graph: nil, root_scene_pid: nil, size: nil
13+
defstruct drivers: nil,
14+
root_config: nil,
15+
root_graph: nil,
16+
root_scene_pid: nil,
17+
size: nil,
18+
styles: %{},
19+
transforms: %{}
1420

1521
@type t :: %Status{
1622
drivers: map,
1723
root_config: {scene_module :: atom, args :: any} | (scene_name :: atom),
1824
root_graph: {:graph, reference, any},
1925
root_scene_pid: pid,
20-
size: Math.point()
26+
size: Math.point(),
27+
styles: map,
28+
transforms: map
2129
}
2230
end

test/scenic/view_port_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ defmodule Scenic.ViewPortTest do
234234
root_config: :root_config,
235235
root_scene_pid: :root_scene_pid,
236236
root_graph_key: :root_graph_key,
237-
size: :size
237+
size: :size,
238+
master_styles: %{},
239+
master_transforms: %{}
238240
}
239241
)
240242

@@ -243,6 +245,8 @@ defmodule Scenic.ViewPortTest do
243245
assert info.root_scene_pid == :root_scene_pid
244246
assert info.root_config == :root_config
245247
assert info.size == :size
248+
assert info.styles == %{}
249+
assert info.transforms == %{}
246250
end
247251

248252
# ============================================================================

0 commit comments

Comments
 (0)