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

Commit

Permalink
Merge pull request #538 from JuliaPlots/jk/laxis_interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel authored Nov 2, 2020
2 parents 51ffefb + f1e89d3 commit 65f677f
Show file tree
Hide file tree
Showing 13 changed files with 622 additions and 424 deletions.
76 changes: 11 additions & 65 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,17 @@
# Other branches (not yet merged)
# master

# `master`
- Changed default font to monospace in showlibrary (#190)
- Got `rotate!(Accum, ...)` working (#196)
- Updated Stepper documentation and allowed for custom file formats (#197)
## New features

# v0.9.10
- Fixed two-dimensional limits when passed to `Scene` (#195)
- Added interactions model to LAxis. Interactions can be added with `register_interaction!` and removed with `deregister_interaction!`, as well as activated or deactivated temporarily with `activate_interaction!` and `deactivate_interaction!`.
- Added `labelslidergrid!`, a function to create an internally aligned grid of sliders with labels and value-labels.
- LAxis has attributes `xrectzoom` and `yrectzoom` that control if the rectangle zoom changes the respective dimension or not.

# v0.9.9
- Added a custom docstring extension which allows the Attributes of a Recipe to be shown in
the help mode (#174).
- Documented a lot of internal features (#174).
- Added a new 3d camera type, `cam3d_cad!`(#161).
- Improved warning text when displaying to text or plotpane (#163).
- Ensured that unless `inline!(true)` was called, plots will always display in
interactive displays, even in Juno (#163).
- Added licenses for fonts shipped with AbstractPlotting (#160).
- Switched from using system `ffmpeg` to using `FFMPEG.jl` (#160).
- Better docstrings for recording functions (#160).
- Let certain attributes passed to mutating plot functions affect the Scene (#160).
- Changed the default theme for `colorlegend` so that it scales with the resolution of the scene.
- Provided a way to generate a lower quality texture atlas via `set_glyph_resolution!(Low)`
to make the WebGL backend more lightweight (#180).
- Fixed `scale_plot` not actually working (#180).
- Cleaned up theme merging & scene attribute composition, so this works (#180):
```julia
scatter(rand(4), resolution = (200, 200))
scatter(rand(4), limits = ((0, 0), (200, 200)))
```
## Improvements

## Internal changes
- Replaced the `nothing` conversion trait with a new `NoConversion` trait, for clarity (#150).
- A lot of backend API changes to accomodate `WGLMakie` (#160).
- Enabled Gitlab CI!
- Cleaned up LSlider style and implementation, LSlider doesn't react while below other objects anymore
- MakieLayout Mouse event types are now enum instances for less compilation
- MakieLayout Mouse events store position in both data and pixel coordinates
- Aligned colors of LMenu, LSlider, LButton etc better

# v0.9.8
## User interface changes
- Recipe docstrings are now associated with two functions instead of six (#116).
- New title recipe! (#99)
- Fixed buttons not respecting some attributes, and add a padding option (#114).
- Added `showlibrary(grad::Symbol)` function to show color libraries in `PlotUtils.jl` (#116).
- Added `showgradients` function to show an Array of gradients, indicated by Symbols (#116).
- Fixed incorrect frame duration in `record`. (#132)
- Fixed `save(path, io::VideoStream)` when file type is `.mkv` (#137).
- Improveed camera zooming (#140).
## Bugfixes

## Internal/other changes
- Changeed default alignment of buttons to (:center, :center) (#115)
- Documented a lot of recipes and functions
- Exported `HyperRectangle`, `update_limits!`, `update!`, and more...
- Updated `VideoStream`, `save` docstrings.
- Reworked tests to use `MakieGallery` (pretty big feature on the backend)
- Enabled Travis CI!

# Additions

## streamplot

```julia
using MakieGallery, Makie
run_example("streamplot")
```

## timeseries

```julia
using MakieGallery, Makie
run_example("timeseries")
```
9 changes: 6 additions & 3 deletions src/makielayout/MakieLayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ function __init__()
end

include("geometrybasics_extension.jl")
include("mousestatemachine.jl")
include("types.jl")
include("helpers.jl")
include("mousestatemachine.jl")
include("ticklocators/linear.jl")
include("ticklocators/wilkinson.jl")
include("defaultattributes.jl")
include("lineaxis.jl")
include("interactions.jl")
include("lobjects/laxis.jl")
include("lobjects/lcolorbar.jl")
include("lobjects/ltext.jl")
Expand Down Expand Up @@ -84,8 +85,10 @@ export tight_xticklabel_spacing!, tight_yticklabel_spacing!, tight_ticklabel_spa
export layoutscene
export set_close_to!
export xaxis_bottom!, xaxis_top!, yaxis_left!, yaxis_right!
export labelslider!
export addmousestate!
export labelslider!, labelslidergrid!
export addmouseevents!
export interactions, register_interaction!, deregister_interaction!, activate_interaction!, deactivate_interaction!
export MouseEventTypes, MouseEvent, ScrollEvent, KeysEvent
export hlines!, vlines!


Expand Down
36 changes: 17 additions & 19 deletions src/makielayout/defaultattributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ function default_attributes(::Type{LAxis}, scene)
xzoomlock = false
"Locks interactive zooming in the y direction."
yzoomlock = false
"Controls if rectangle zooming affects the x dimension."
xrectzoom = true
"Controls if rectangle zooming affects the y dimension."
yrectzoom = true
"The width of the axis spines."
spinewidth = 1f0
"Controls if the x grid lines are visible."
Expand Down Expand Up @@ -433,7 +437,7 @@ function default_attributes(::Type{LButton}, scene)
"The color of the button border."
strokecolor = :transparent
"The color of the button."
buttoncolor = RGBf0(0.9, 0.9, 0.9)
buttoncolor = RGBf0(0.94, 0.94, 0.94)
"The color of the label."
labelcolor = :black
"The color of the label when the mouse hovers over the button."
Expand Down Expand Up @@ -495,14 +499,12 @@ end

function default_attributes(::Type{LSlider}, scene)
attrs, docdict, defaultdict = @documented_attributes begin
"The line width of the main slider line."
linewidth = 4f0
"The horizontal alignment of the slider in its suggested bounding box."
halign = :center
"The vertical alignment of the slider in its suggested bounding box."
valign = :center
"The width setting of the slider."
width = nothing
width = Auto()
"The height setting of the slider."
height = Auto()
"The range of values that the slider can pick from."
Expand All @@ -511,24 +513,20 @@ function default_attributes(::Type{LSlider}, scene)
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The radius of the slider button."
buttonradius = 9f0
"The start value of the slider or the value that is closest in the slider range."
startvalue = 0
"The current value of the slider."
value = 0
"The width of the slider line"
linewidth = 15
"The color of the slider when the mouse hovers over it."
color_active_dimmed = COLOR_ACCENT_DIMMED[]
"The color of the slider when the mouse clicks and drags the slider."
color_active = COLOR_ACCENT[]
"The color of the slider when it is not interacted with."
color_inactive = RGBf0(0.9, 0.9, 0.9)
"The color of the button when it is not interacted with."
buttoncolor_inactive = RGBf0(1, 1, 1)
color_inactive = RGBf0(0.94, 0.94, 0.94)
"Controls if the slider has a horizontal orientation or not."
horizontal = true
"The line width of the slider button's border."
buttonstrokewidth = 4f0
"The align mode of the slider in its parent GridLayout."
alignmode = Inside()
end
Expand All @@ -554,28 +552,28 @@ function default_attributes(::Type{LToggle}, scene)
"The width of the toggle."
width = 60
"The height of the toggle."
height = 30
height = 28
"Controls if the parent layout can adjust to this element's width"
tellwidth = true
"Controls if the parent layout can adjust to this element's height"
tellheight = true
"The number of poly segments in each rounded corner."
cornersegments = 10
cornersegments = 15
# strokewidth = 2f0
# strokecolor = :transparent
"The color of the border when the toggle is inactive."
framecolor_inactive = RGBf0(0.9, 0.9, 0.9)
"The color of the border when the toggle is active."
framecolor_active = COLOR_ACCENT[]
framecolor_inactive = RGBf0(0.94, 0.94, 0.94)
"The color of the border when the toggle is hovered."
framecolor_active = COLOR_ACCENT_DIMMED[]
# buttoncolor = RGBf0(0.2, 0.2, 0.2)
"The color of the toggle button."
buttoncolor = RGBf0(1, 1, 1)
buttoncolor = COLOR_ACCENT[]
"Indicates if the toggle is active or not."
active = false
"The duration of the toggle animation."
toggleduration = 0.2
toggleduration = 0.15
"The border width as a fraction of the toggle height "
rimfraction = 0.25
rimfraction = 0.33
"The align mode of the toggle in its parent GridLayout."
alignmode = Inside()
end
Expand Down
46 changes: 45 additions & 1 deletion src/makielayout/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ layout[1, 1] = ls.layout
```
"""
function labelslider!(scene, label, range; format = string,
sliderkw = Dict(), labelkw = Dict(), valuekw = Dict(), layoutkw...)
sliderkw = Dict(), labelkw = Dict(), valuekw = Dict(), layoutkw...)
slider = LSlider(scene; range = range, sliderkw...)
label = LText(scene, label; labelkw...)
valuelabel = LText(scene, lift(format, slider.value); valuekw...)
Expand All @@ -435,6 +435,50 @@ function labelslider!(scene, label, range; format = string,
end


"""
labelslidergrid!(scene, labels, ranges; formats = [string],
sliderkw = Dict(), labelkw = Dict(), valuekw = Dict(), layoutkw...)
Construct a GridLayout with a column of label, a column of sliders and a column of value labels in `scene`.
The argument values are broadcast, so you can use scalars if you want to keep labels, ranges or formats constant across rows.
Returns a `NamedTuple`:
`(sliders = sliders, labels = labels, valuelabels = valuelabels, layout = layout)`
Specify format functions for the value labels with the `formats` keyword.
The sliders are forwarded the keywords from `sliderkw`.
The labels are forwarded the keywords from `labelkw`.
The value labels are forwarded the keywords from `valuekw`.
All other keywords are forwarded to the `GridLayout`.
Example:
```
ls = labelslidergrid!(scene, ["Voltage", "Ampere"], Ref(0:0.1:100); format = x -> "\$(x)V")
layout[1, 1] = ls.layout
```
"""
function labelslidergrid!(scene, labels, ranges; formats = [string],
sliderkw = Dict(), labelkw = Dict(), valuekw = Dict(), layoutkw...)

elements = broadcast(labels, ranges, formats) do label, range, format
slider = LSlider(scene; range = range, sliderkw...)
label = LText(scene, label; halign = :left, labelkw...)
valuelabel = LText(scene, lift(format, slider.value); halign = :right, valuekw...)
(; slider = slider, label = label, valuelabel = valuelabel)
end

sliders = map(x -> x.slider, elements)
labels = map(x -> x.label, elements)
valuelabels = map(x -> x.valuelabel, elements)

layout = grid!(hcat(labels, sliders, valuelabels))

(sliders = sliders, labels = labels, valuelabels = valuelabels, layout = layout)
end



# helper function to create either h or vlines depending on `direction`
# this works only with LAxes because it needs to react to limit changes
Expand Down
Loading

0 comments on commit 65f677f

Please sign in to comment.