Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MakieLayout module #2008

Merged
merged 10 commits into from
Jun 6, 2022
2 changes: 1 addition & 1 deletion MakieRecipes/src/layout_integration.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function tomakie!(sc::AbstractScene, layout::MakieLayout.GridLayout, args...; attrs...)
function tomakie!(sc::AbstractScene, layout::Makie.GridLayout, args...; attrs...)
# TODO create a finalizer for a Tuple{Scene, Layout, Vector{LAxis}}
RecipesPipeline.recipe_pipeline!(sc, Dict{Symbol, Any}(attrs), args)
end
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Formatting = "0.4"
FreeType = "3.0, 4.0"
FreeTypeAbstraction = "0.8, 0.9"
GeometryBasics = "0.4.2"
GridLayoutBase = "0.7.1"
GridLayoutBase = "0.7.6"
ImageIO = "0.2, 0.3, 0.4, 0.5, 0.6"
IntervalSets = "0.3, 0.4, 0.5, 0.6, 0.7"
Isoband = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/cameras.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The 2D camera (\apilink{cam2d!(scene)}) uses an orthographic projection with a f
- `panbutton = Mouse.right` sets the mouse button that needs to be pressed to translate the view.
- `selectionbutton = (Keyboard.space, Mouse.left)` sets a set of buttons that need to be pressed to perform rectangle zooms.

Note that this camera is not used by MakieLayout `Axis`. It is used, by default, for 2D `LScene`s and `Scene`s.
Note that this camera is not used by `Axis`. It is used, by default, for 2D `LScene`s and `Scene`s.

## 3D Camera

Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/layouting.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How layouts work

The goal of MakieLayout is that all elements placed in a scene fit into the
The goal is that all elements placed in a scene fit into the
window, fill the available space, and are nicely aligned relative to each other.
This works by using `GridLayout` objects that determine how wide their rows and
columns should be given their content elements.
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/blocks/axis.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ To control ticks, you can set the axis attributes `xticks/yticks` and `xtickform
You can overload one or more of these three functions to implement custom ticks:

```julia
tickvalues, ticklabels = MakieLayout.get_ticks(ticks, scale, formatter, vmin, vmax)
tickvalues = MakieLayout.get_tickvalues(ticks, vmin, vmax)
ticklabels = MakieLayout.get_ticklabels(formatter, tickvalues)
tickvalues, ticklabels = Makie.get_ticks(ticks, scale, formatter, vmin, vmax)
tickvalues = Makie.get_tickvalues(ticks, vmin, vmax)
ticklabels = Makie.get_ticklabels(formatter, tickvalues)
```

If you overload `get_ticks`, you have to compute both tickvalues and ticklabels directly as a vector of floats and strings, respectively.
Expand Down Expand Up @@ -302,7 +302,7 @@ f
You can show minor ticks and grids by setting `x/yminorticksvisible = true` and `x/yminorgridvisible = true` which are off by default.
You can set size, color, width, align etc. like for the normal ticks, but there are no labels.
The `x/yminorticks` attributes control how minor ticks are computed given major ticks and axis limits.
For that purpose you can create your own minortick type and overload `MakieLayout.get_minor_tickvalues(minorticks, tickvalues, vmin, vmax)`.
For that purpose you can create your own minortick type and overload `Makie.get_minor_tickvalues(minorticks, tickvalues, vmin, vmax)`.

The default minor tick type is `IntervalsBetween(n, mirror = true)` where `n` gives the number of intervals each gap between major ticks is divided into with minor ticks, and `mirror` decides if outside of the major ticks there are more minor ticks with the same intervals as the adjacent gaps.

Expand Down Expand Up @@ -794,7 +794,7 @@ mutable struct MyInteraction
allow_right_click::Bool
end

function MakieLayout.process_interaction(interaction::MyInteraction, event::MouseEvent, axis)
function Makie.process_interaction(interaction::MyInteraction, event::MouseEvent, axis)
if interaction.use_left_click && event.type === MouseEventTypes.leftclick
println("Left click in correct mode")
end
Expand All @@ -803,7 +803,7 @@ function MakieLayout.process_interaction(interaction::MyInteraction, event::Mous
end
end

function MakieLayout.process_interaction(interaction::MyInteraction, event::KeysEvent, axis)
function Makie.process_interaction(interaction::MyInteraction, event::KeysEvent, axis)
interaction.allow_left_click = Keyboard.l in event.keys
interaction.allow_right_click = Keyboard.r in event.keys
end
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
@@box-container
@@box
~~~<a class="boxlink" href="https://www.youtube.com/watch?v=AtqXFfaMZqo">~~~
@@title MakieLayout Deep Dive @@
@@title Makie Layouting Deep Dive @@
@@box-content
@@description
A tour of some of the more complex layout features of Makie.
Expand Down
41 changes: 26 additions & 15 deletions src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ using Random
using FFMPEG # get FFMPEG on any system!
using Observables
using GeometryBasics
using IntervalSets
using PlotUtils
using ColorBrewer
using ColorTypes
using Colors
using ColorSchemes
using FixedPointNumbers
using Packing
using SignedDistanceFields
using Markdown
Expand All @@ -37,6 +35,8 @@ using FreeTypeAbstraction
using UnicodeFun
using LinearAlgebra
using Statistics
using MakieCore
using OffsetArrays

import RelocatableFolders
import StatsBase
Expand All @@ -48,10 +48,11 @@ import GridLayoutBase
import ImageIO
import FileIO
import SparseArrays
using MakieCore
using OffsetArrays

using GeometryBasics: widths, positive_widths, VecTypes, AbstractPolygon, value, StaticVector
using IntervalSets: IntervalSets, (..), OpenInterval, ClosedInterval, AbstractInterval, Interval, endpoints
using FixedPointNumbers: N0f8

using GeometryBasics: width, widths, height, positive_widths, VecTypes, AbstractPolygon, value, StaticVector
using Distributions: Distribution, VariateForm, Discrete, QQPair, pdf, quantile, qqbuild

import FileIO: save
Expand Down Expand Up @@ -272,6 +273,25 @@ function logo()
end

function __init__()
# Make GridLayoutBase default row and colgaps themeable when using Makie
# This mutates module-level state so it could mess up other libraries using
# GridLayoutBase at the same time as Makie, which is unlikely, though
GridLayoutBase.DEFAULT_COLGAP_GETTER[] = function()
ct = Makie.current_default_theme()
if haskey(ct, :colgap)
ct[:colgap][]
else
GridLayoutBase.DEFAULT_COLGAP[]
end
end
GridLayoutBase.DEFAULT_ROWGAP_GETTER[] = function()
ct = Makie.current_default_theme()
if haskey(ct, :rowgap)
ct[:rowgap][]
else
GridLayoutBase.DEFAULT_ROWGAP[]
end
end
# fonts aren't cacheable by precompilation, so we need to empty it on load!
empty!(FONT_CACHE)
cfg_path = joinpath(homedir(), ".config", "makie", "theme.jl")
Expand All @@ -286,12 +306,6 @@ export content
export resize_to_layout!

include("makielayout/MakieLayout.jl")
# re-export MakieLayout
for name in names(MakieLayout)
@eval import .MakieLayout: $(name)
@eval export $(name)
end

include("figureplotting.jl")
include("basic_recipes/series.jl")
include("basic_recipes/text.jl")
Expand All @@ -303,9 +317,6 @@ export heatmap!, image!, lines!, linesegments!, mesh!, meshscatter!, scatter!, s

export PointLight, EnvironmentLight, AmbientLight, SSAO

if Base.VERSION >= v"1.4.2"
include("precompiles.jl")
_precompile_()
end
include("precompiles.jl")

end # module
11 changes: 9 additions & 2 deletions src/basic_recipes/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ module Formatters
end
using .Formatters


to_3tuple(x) = ntuple(i -> x, Val(3))
to_3tuple(x::NTuple{3,Any}) = x

to_2tuple(x) = ntuple(i -> x, Val(2))
to_2tuple(x::NTuple{2,Any}) = x

"""
$(SIGNATURES)

Expand Down Expand Up @@ -66,7 +73,7 @@ $(ATTRIBUTES)
rotation = axisnames_rotation3d,
textsize = (6.0, 6.0, 6.0),
align = axisnames_align3d,
font = lift(dim3, theme(scene, :font)),
font = lift(to_3tuple, theme(scene, :font)),
gap = 3
),

Expand All @@ -80,7 +87,7 @@ $(ATTRIBUTES)
textsize = (tsize, tsize, tsize),
align = tickalign3d,
gap = 3,
font = lift(dim3, theme(scene, :font)),
font = lift(to_3tuple, theme(scene, :font)),
),

frame = Attributes(
Expand Down
2 changes: 1 addition & 1 deletion src/basic_recipes/series.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ function plot!(plot::Series)
end
end

function MakieLayout.get_plots(plot::Series)
function Makie.get_plots(plot::Series)
return plot.plots
end
14 changes: 7 additions & 7 deletions src/basic_recipes/text.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function plot!(plot::Text)
# attach a function to any text that calculates the glyph layout and stores it
glyphcollection = lift(plot[1], plot.textsize, plot.font, plot.align,
plot.rotation, plot.justification, plot.lineheight, plot.color,
plot.rotation, plot.justification, plot.lineheight, plot.color,
plot.strokecolor, plot.strokewidth, plot.word_wrap_width) do str,
ts, f, al, rot, jus, lh, col, scol, swi, www
ts = to_textsize(ts)
Expand All @@ -28,8 +28,8 @@ function plot!(plot::Text{<:Tuple{<:AbstractArray{<:AbstractString}}})
glyphcollections = Observable(GlyphCollection[])
rotation = Observable{Any}(nothing)

onany(plot[1], plot.textsize, plot.font, plot.align,
plot.rotation, plot.justification, plot.lineheight, plot.color,
onany(plot[1], plot.textsize, plot.font, plot.align,
plot.rotation, plot.justification, plot.lineheight, plot.color,
plot.strokecolor, plot.strokewidth, plot.word_wrap_width) do str,
ts, f, al, rot, jus, lh, col, scol, swi, wwws

Expand All @@ -54,7 +54,7 @@ function plot!(plot::Text{<:Tuple{<:AbstractArray{<:AbstractString}}})
notify(plot[1])

text!(plot, glyphcollections; position = plot.position, rotation = rotation,
model = plot.model, offset = plot.offset, markerspace = plot.markerspace,
model = plot.model, offset = plot.offset, markerspace = plot.markerspace,
visible=plot.visible, space = plot.space)

plot
Expand Down Expand Up @@ -90,7 +90,7 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr

# attach a function to any text that calculates the glyph layout and stores it
lineels_glyphcollection_offset = lift(plot[1], plot.textsize, plot.align, plot.rotation,
plot.model, plot.color, plot.strokecolor, plot.strokewidth,
plot.model, plot.color, plot.strokecolor, plot.strokewidth,
plot.word_wrap_width) do latexstring, ts, al, rot, mo, color, scolor, swidth, www

ts = to_textsize(ts)
Expand Down Expand Up @@ -182,7 +182,7 @@ function plot!(plot::Text{<:Tuple{<:Union{LaTeXString, AbstractVector{<:LaTeXStr
text!(plot, glyphcollection; plot.attributes...)
linesegments!(
plot, linepairs, linewidth = linewidths, color = plot.color,
visible = plot.visible, inspectable = plot.inspectable,
visible = plot.visible, inspectable = plot.inspectable,
transparent = plot.transparency, space = :pixel
)

Expand Down Expand Up @@ -284,4 +284,4 @@ function texelems_and_glyph_collection(str::LaTeXString, fontscale_px, halign, v
all_els, pre_align_gl, Point2f(xshift, yshift)
end

MakieLayout.iswhitespace(l::LaTeXString) = MakieLayout.iswhitespace(replace(l.s, '$' => ""))
iswhitespace(l::LaTeXString) = iswhitespace(replace(l.s, '$' => ""))
4 changes: 2 additions & 2 deletions src/figureplotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end

function plot(P::PlotFunc, gp::GridPosition, args...; axis = NamedTuple(), kwargs...)

f = MakieLayout.get_top_parent(gp)
f = get_top_parent(gp)

c = contents(gp, exact = true)
if !isempty(c)
Expand Down Expand Up @@ -108,7 +108,7 @@ function plot(P::PlotFunc, gsp::GridSubposition, args...; axis = NamedTuple(), k
""")
end

fig = MakieLayout.get_top_parent(gsp)
fig = get_top_parent(gsp)

axis = Dict(pairs(axis))

Expand Down
48 changes: 1 addition & 47 deletions src/makielayout/MakieLayout.jl
Original file line number Diff line number Diff line change
@@ -1,55 +1,14 @@
module MakieLayout

using ..Makie
using ..Makie: Rect2
import ..Makie: Rect2i
import ..Makie: RGBColors
using ..Makie.Keyboard
using ..Makie.Mouse
using ..Makie: ispressed, is_mouseinside, get_scene, FigureLike
using ..Makie: Consume
using ..Makie: OpenInterval, Interval
using ..Makie: is_data_space
using MakieCore
using MakieCore: Automatic, automatic
using Observables: onany
import Observables
import Formatting
using Match
import Animations
import PlotUtils
using GridLayoutBase
using GridLayoutBase: GridSubposition
import Showoff
using Colors
import Markdown

const FPS = Observable(30)
const COLOR_ACCENT = Ref(RGBf(((79, 122, 214) ./ 255)...))
const COLOR_ACCENT_DIMMED = Ref(RGBf(((174, 192, 230) ./ 255)...))

# Make GridLayoutBase default row and colgaps themeable when using MakieLayout
# This mutates module-level state so it could mess up other libraries using
# GridLayoutBase at the same time as MakieLayout, which is unlikely, though
function __init__()
GridLayoutBase.DEFAULT_COLGAP_GETTER[] = function()
ct = Makie.current_default_theme()
if haskey(ct, :colgap)
ct[:colgap][]
else
GridLayoutBase.DEFAULT_COLGAP[]
end
end
GridLayoutBase.DEFAULT_ROWGAP_GETTER[] = function()
ct = Makie.current_default_theme()
if haskey(ct, :rowgap)
ct[:rowgap][]
else
GridLayoutBase.DEFAULT_ROWGAP[]
end
end
end

include("blocks.jl")
include("geometrybasics_extension.jl")
include("mousestatemachine.jl")
Expand Down Expand Up @@ -133,9 +92,4 @@ export swap!
export ncols, nrows
export contents, content

if Base.VERSION >= v"1.4.2"
include("precompile.jl")
_precompile_()
end

end # module
Base.@deprecate_binding MakieLayout Makie true "The module `MakieLayout` has been removed and integrated into Makie, so simply replace all usage of `MakieLayout` with `Makie`."
Loading