Skip to content

Commit

Permalink
Add menu an button OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Mar 24, 2024
1 parent 1524be6 commit 4988a8d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
16 changes: 16 additions & 0 deletions mwes/mwe_04.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using GLMakie

const running = Observable(false)
fig = Figure(size=(400, 400), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
fig[2, 1] = buttongrid = GridLayout(tellwidth=true)
btn_PLAY_PAUSE = Button(sub_fig, label = @lift($running ? "PAUSE" : " RUN "))
btn_STOP = Button(sub_fig, label="STOP")
buttongrid[1, 1:2] = [btn_PLAY_PAUSE, btn_STOP]

menu1 = Menu(fig, bbox = fig.scene.viewport, options = ["plot", "save as jld2", "save as pdf"], default = "plot")
menu1.width[]=100
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(10)
fig
2 changes: 1 addition & 1 deletion src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function init_system(scene; show_kite=true)
font=se().fixed_font
end
text!(scene, textnode, position = Point2f(50, 110), fontsize=TEXT_SIZE, font=font, align = (:left, :top), show_axis = false, space=:pixel)
text!(scene, textnode2, position = Point2f(630, 750), fontsize=TEXT_SIZE, font=font, align = (:left, :bottom), show_axis = false, space=:pixel)
text!(scene, textnode2, position = Point2f(630, 735), fontsize=TEXT_SIZE, font=font, align = (:left, :bottom), show_axis = false, space=:pixel)
end

# update the kite power system, consisting of the tether, the kite and the state (text and numbers)
Expand Down
12 changes: 11 additions & 1 deletion src/viewer3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ function Viewer3D(show_kite=true, autolabel="Autopilot"; precompile=false)
HEIGHT = 900
fig = Figure(size=(WIDTH, HEIGHT), backgroundcolor=RGBf(0.7, 0.8, 1))
sub_fig = fig[1,1]
menu1 = Menu(fig, bbox = fig.scene.viewport,
options = ["plot", "save as .jld2", "save as .pdf"], default = "plot")
menu1.width[] =120
menu1.halign[]=:left
menu1.valign[]=:top
menu1.alignmode[]=Outside(30)
btn_OK = Button(fig, bbox=fig.scene.viewport, label = "OK")
btn_OK.halign[]=:left
btn_OK.valign[]=:top
btn_OK.alignmode[]=Outside(160, 0, 0, 30)
scene2D = LScene(fig[3,1], show_axis=false, height=16)
scene3D = LScene(sub_fig, show_axis=false, scenekw=(limits=Rect(-7,-10.0,0, 11,10,11), size=(800, 800)))

Expand Down Expand Up @@ -209,7 +219,7 @@ function Viewer3D(show_kite=true, autolabel="Autopilot"; precompile=false)
on(fig.scene.events.window_area) do x
dx = x.widths[1] - WIDTH
dy = x.widths[2] - HEIGHT
txt2.position[] = Point2f(630.0+dx, 750.0+dy)
txt2.position[] = Point2f(630.0+dx, 735.0+dy)
end
status[] = "Stopped"
s
Expand Down

0 comments on commit 4988a8d

Please # to comment.