Skip to content

Commit

Permalink
update for Makie 0.20 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz authored Jan 21, 2024
1 parent 03540c8 commit 2922a50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
GeometryBasics = "0.4"
Makie = "0.19"
Makie = "0.20"
Tables = "1"
julia = "1.6"

Expand Down
6 changes: 3 additions & 3 deletions src/geometry_canvas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function add_events!(c::GeometryCanvas{<:Point};

# Add points with left click
if event.action == Mouse.press
if Makie.mouseposition_px(fig.scene) in ax.scene.px_area[]
if Makie.mouseposition_px(fig.scene) in ax.scene.viewport[]
# Set how close to a point we have to be to select it
idx = c.current_point
# Get mouse position in the axis and figure
Expand Down Expand Up @@ -534,7 +534,7 @@ function add_events!(c::GeometryCanvas{T};

axis_pos = Makie.mouseposition(ax.scene)
# Add points with left click
if event.action == Mouse.press && Makie.mouseposition_px(fig.scene) in ax.scene.px_area[]
if event.action == Mouse.press && Makie.mouseposition_px(fig.scene) in ax.scene.viewport[]
insert = false
if _is_alt_pressed(fig)
deleting[] = true
Expand Down Expand Up @@ -715,7 +715,7 @@ end
# Get pixel click accuracy from the size of the visable heatmap.
function _accuracy(ax::Axis, accuracy_scale)
lift(ax.finallimits) do fl
sum(maximum(fl.widths) ./ ax.scene.px_area[].widths) / accuracy_scale * 4
sum(maximum(fl.widths) ./ ax.scene.viewport[].widths) / accuracy_scale * 4
end
end

Expand Down
6 changes: 3 additions & 3 deletions src/paint_canvas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mutable struct PaintCanvas{T,Fu,D,M<:AbstractMatrix{T},Fi,A} <: AbstractCanvas
on_mouse_events::Function
end
function PaintCanvas(data::AbstractMatrix;
f=(axis, xs, ys, v) -> image!(axis, xs, ys, v; interpolate=false, colormap=:inferno),
f=(axis, xs, ys, v) -> image!(axis, (first(xs), last(xs)), (first(ys), last(ys)), v; interpolate=false, colormap=:inferno),
drawing=Observable{Bool}(false),
drawbutton=Observable{Any}(Mouse.left),
active=Observable{Bool}(true),
Expand Down Expand Up @@ -92,7 +92,7 @@ function add_mouse_events!(fig::Figure, ax::Axis, c::PaintCanvas)

# Add points with left click
if event.action == Mouse.press
if !(fig_pos in ax.scene.px_area[])
if !(fig_pos in ax.scene.viewport[])
drawing[] = false
return Consume(false)
end
Expand Down Expand Up @@ -126,7 +126,7 @@ function add_mouse_events!(fig::Figure, ax::Axis, c::PaintCanvas)
if drawing[]
fig_pos = Makie.mouseposition_px(fig.scene)
axis_pos = Makie.mouseposition(ax.scene)
if !(fig_pos in ax.scene.px_area[])
if !(fig_pos in ax.scene.viewport[])
drawing[] = false
return Consume(false)
end
Expand Down

0 comments on commit 2922a50

Please sign in to comment.