Skip to content

Commit

Permalink
Fix Hidden Frame Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
malisipi committed Aug 1, 2022
1 parent b89d2ae commit 8b7b31d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions examples/side_menu.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import malisipi.mui as m

fn toggle_menu(event_details m.EventDetails,mut app &m.Window, app_data voidptr){
unsafe{
app.get_object_by_id("menu_frame")[0]["hi"].bol=!app.get_object_by_id("menu_frame")[0]["hi"].bol
}
}

fn menu_open(event_details m.EventDetails,mut app &m.Window, app_data voidptr){
toggle_menu(event_details,mut app, app_data)
unsafe {
app.get_object_by_id("text")[0]["text"].str="You clicked "+app.get_object_by_id(event_details.target_id)[0]["text"].str
}
}

mut app:=m.create(m.WindowConfig{ title:"Side Menu - MUI Example", height:600, width:800 })

app.frame(m.Widget{ id:"menu_frame", x:"0", y:"0", width:"300", height:"100%y", hidden:true })
app.button(m.Widget{ id:"menu_1", x:"10", y:"60", width:"280", height:"30", text:"Welcome", icon:false, frame:"menu_frame", onclick:menu_open })
app.button(m.Widget{ id:"menu_2", x:"10", y:"90", width:"280", height:"30", text:"Edit", icon:false, frame:"menu_frame", onclick:menu_open })
app.button(m.Widget{ id:"menu_3", x:"10", y:"120", width:"280", height:"30", text:"About", icon:false, frame:"menu_frame", onclick:menu_open })
app.button(m.Widget{ id:"menu_open", x:"10", y:"10", width:"30", height:"30", text:"↩", icon:true, onclick:toggle_menu })
app.label(m.Widget{ id:"text", x:"# 10", y:"# 10", width:"100", height:"25", text_align:2 text:"" })

app.run()
5 changes: 4 additions & 1 deletion mui.v
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ fn frame_fn(app &Window) {
} else {
frame:=app.get_object_by_id(object["in"].str)[0]
if frame["hi"].bol {
break
object["x"]=WindowData{num:-1}
object["y"]=WindowData{num:-1}
object["w"]=WindowData{num:0}
object["h"]=WindowData{num:0}
} else {
points:=calc_points([frame["w"].num,frame["h"].num,frame["w"].num,frame["h"].num,0,0],
object["x_raw"].str,object["y_raw"].str,object["w_raw"].str,object["h_raw"].str)
Expand Down

0 comments on commit 8b7b31d

Please sign in to comment.