Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit ac259a7

Browse files
remove all the Observable conversion clutter (#315)
* remove all the node conversion bullshit * test against observables#master * fixes * get READY * import from Observables that which is observable (#328) * move imports Co-authored-by: Anshul Singhvi <[email protected]>
1 parent 8e7e096 commit ac259a7

File tree

16 files changed

+72
-205
lines changed

16 files changed

+72
-205
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test:
1717
- mkdir $JULIA_DEPOT_PATH # Pkg.jl#325
1818
- julia -e 'using InteractiveUtils; versioninfo()'
1919
- mkdir temporary_for_project
20-
- julia --project=temporary_for_project -e 'using Pkg; Pkg.pkg"dev --local .; add StatsMakie#master MakieGallery#master GLMakie#master [email protected]; test AbstractPlotting"'
20+
- julia --project=temporary_for_project -e 'using Pkg; Pkg.pkg"dev --local .; add Observables#master StatsMakie#master MakieGallery#master GLMakie#master; test AbstractPlotting"'
2121

2222
artifacts:
2323
when: on_failure

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ FreeTypeAbstraction = "0.6"
5050
GeometryTypes = "0.7.2"
5151
ImageMagick = "0.7, 1.0"
5252
IntervalSets = "0.3, 0.4"
53-
Observables = "0.2.0"
53+
Observables = "0.3.0"
5454
Packing = "0.3"
5555
PlotUtils = "0.6.2"
5656
Showoff = "0.3"

src/AbstractPlotting.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ import ImageMagick, FileIO, SparseArrays
1414
import FileIO: save
1515
using Printf: @sprintf
1616

17+
# Imports from Base which we don't want to have to qualify
1718
using Base: RefValue
1819
using Base.Iterators: repeated, drop
1920
import Base: getindex, setindex!, push!, append!, parent, get, get!, delete!, haskey
21+
using Observables: listeners, notify!, to_value
22+
23+
# Imports from Observables which we use a lot
24+
using Observables: notify!, listeners
2025

2126
module ContoursHygiene
2227
import Contour
@@ -94,7 +99,7 @@ export xtickrotation, ytickrotation, ztickrotation
9499
export xtickrotation!, ytickrotation!, ztickrotation!
95100

96101
# Node/Signal related
97-
export Node, node, lift, map_once, to_value, on, @lift
102+
export Node, lift, map_once, to_value, on, @lift
98103

99104
# utilities and macros
100105
export @recipe, @extract, @extractvalue, @key_str, @get_attribute

src/basic_recipes/axis.jl

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -556,32 +556,24 @@ function plot!(scene::SceneLike, ::Type{<: Axis2D}, attributes::Attributes, args
556556

557557
textbuffer = TextBuffer(cplot, Point{2})
558558

559-
grid_linebuffer = to_node((
560-
LinesegmentBuffer(
561-
cplot, Point{2}, transparency = true,
562-
linestyle = lift(first, cplot[:grid, :linestyle])
563-
),
564-
LinesegmentBuffer(
565-
cplot, Point{2}, transparency = true,
566-
linestyle = lift(last, cplot[:grid, :linestyle])
567-
)
559+
grid_linebuffer = Node((
560+
LinesegmentBuffer(cplot, Point{2}, transparency=true,
561+
linestyle=lift(first, cplot[:grid, :linestyle])),
562+
LinesegmentBuffer(cplot, Point{2}; transparency=true,
563+
linestyle=lift(last, cplot[:grid, :linestyle]))
568564
))
569-
frame_linebuffer = to_node(LinesegmentBuffer(
570-
cplot, Point{2}, transparency = true, linestyle = cplot.frame.linestyle
571-
))
572-
tickmarks_linebuffer = to_node((
573-
LinesegmentBuffer(
574-
cplot, Point{2}, transparency = true,
575-
linestyle=lift(first, cplot[:tickmarks, :linestyle])
576-
),
577-
LinesegmentBuffer(
578-
cplot, Point{2}, transparency = true,
579-
linestyle = lift(last, cplot[:tickmarks, :linestyle])
580-
)
565+
566+
frame_linebuffer = Node(LinesegmentBuffer(cplot, Point{2}; transparency=true,
567+
linestyle=cplot.frame.linestyle))
568+
tickmarks_linebuffer = Node((
569+
LinesegmentBuffer(cplot, Point{2}; transparency=true,
570+
linestyle=lift(first, cplot[:tickmarks, :linestyle])),
571+
LinesegmentBuffer(cplot, Point{2}; transparency=true,
572+
linestyle=lift(last, cplot[:tickmarks, :linestyle]))
581573
))
582574
map_once(
583575
draw_axis2d,
584-
to_node(textbuffer),
576+
Node(textbuffer),
585577
frame_linebuffer, grid_linebuffer,tickmarks_linebuffer,
586578
transformationmatrix(scene),
587579
cplot.padding, cplot[1], cplot.ticks.ranges_labels,

src/basic_recipes/basic_recipes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function plot!(plot::Poly{<: Tuple{<: AbstractVector{P}}}) where P <: AbstractVe
7878
push!(line, poly[1])
7979
push!(line, Point2f0(NaN))
8080
end
81-
line
81+
return line
8282
end
8383
lines!(
8484
plot, outline, visible = plot.visible,
@@ -852,7 +852,7 @@ function plot!(vs::VolumeSlices)
852852
hattributes = vs[:heatmap]
853853
sliders = map(zip(planes, (x, y, z))) do plane_r
854854
plane, r = plane_r
855-
idx = node(plane, Node(1))
855+
idx = Node(1)
856856
vs[plane] = idx
857857
hmap = heatmap!(vs, hattributes, x, y, zeros(length(x[]), length(y[]))).plots[end]
858858
on(idx) do i

src/basic_recipes/multiple.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ combine(val1, val2; palette = nothing) = val2
4545
function combine!(theme1::Theme, theme2::Theme)
4646
palette = get(theme1, :palette, current_default_theme()[:palette])
4747
for (key, val) in theme2
48-
tv = get(theme1, key, nothing) |> to_node
49-
pv = get(palette, key, nothing) |> to_node
48+
tv = convert(Node, get(theme1, key, nothing))
49+
pv = convert(Node, get(palette, key, nothing))
5050
theme1[key] = lift((t, p, v) -> combine(t, v, palette = p), tv, pv, val)
5151
end
5252
theme1

src/basic_recipes/title.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Add a title with content `string` to `scene`. Pass a `Function` to the `formatt
99
if the value passed to `string` isn't actually a String.
1010
"""
1111
function title(scene, tstring; align = (:center, :bottom), textsize = 30, parent = Scene(), formatter = string, kw...)
12-
13-
string = to_node(tstring)
14-
12+
13+
string = convert(Node, tstring)
14+
1515
pos = lift(pixelarea(scene)) do area
1616
x = widths(area)[1] ./ 2
1717
Vec2f0(x, 10) # offset 10px, to give it some space
@@ -24,7 +24,7 @@ function title(scene, tstring; align = (:center, :bottom), textsize = 30, parent
2424
textsize = textsize;
2525
kw...
2626
)
27-
hbox(scene, t; parent = parent)
27+
return hbox(scene, t; parent = parent)
2828
end
2929

3030
function title(string; kw...)

src/camera/camera.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Observables.on(f, c::Camera, nodes::Node...)
5050
on(cl, n)
5151
end
5252
push!(c.steering_nodes, nodes...)
53-
node
53+
return f
5454
end
5555

5656
function Camera(px_area)

src/camera/camera2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Creates a 2D camera for the given Scene.
1616
function cam2d!(scene::SceneLike; kw_args...)
1717
cam_attributes = merged_get!(:cam2d, scene, Attributes(kw_args)) do
1818
Theme(
19-
area = node(:area, FRect(0, 0, 1, 1)),
19+
area = Node(FRect(0, 0, 1, 1)),
2020
zoomspeed = 0.10f0,
2121
zoombutton = nothing,
2222
panbutton = Mouse.right,

src/interaction/gui.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function plot!(slider::Slider)
9999
val = slider[:value]
100100
p2f0 = lift(Point2f0, position)
101101
startval = start[] === automatic ? first(range[]) : start[]
102-
push!(val, startval)
102+
val[] = startval
103103
label = lift((v, f)-> f(v), val, valueprinter)
104104
lplot = text!(
105105
slider, label,
@@ -128,7 +128,7 @@ function plot!(slider::Slider)
128128
).plots[end]
129129
dragslider(slider, button)
130130
move!(slider, find_closest(range[], startval))
131-
slider
131+
return slider
132132
end
133133

134134
function dragslider(slider, button)

0 commit comments

Comments
 (0)