Skip to content

Commit

Permalink
Add resize event
Browse files Browse the repository at this point in the history
  • Loading branch information
malisipi committed Dec 2, 2022
1 parent 6fb78e6 commit a6c27ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions events.v
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ fn keyboard_fn(chr U32OrString, mut app &Window){
[unsafe]
fn resized_fn(event &gg.Event, mut app &Window){
unsafe{
app.resized_fn(EventDetails{event:"resize",trigger:"resize",value:event.window_width.str()+","+event.window_height.str()},mut app, mut app.app_data)
app.get_object_by_id("@scrollbar:horizontal")[0]["sThum"].num=event.window_width
app.get_object_by_id("@scrollbar:vertical")[0]["sThum"].num=event.window_height
}
Expand Down
9 changes: 9 additions & 0 deletions examples/resize_event.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import malisipi.mui as m

mut app:=m.create(m.WindowConfig{ title:"Resize Event - MUI Examples",
resized_fn: fn (e m.EventDetails, mut app &m.Window, mut a voidptr){
m.messagebox("You resized the window!",e.value,"ok","info")
}
})

app.run()
1 change: 1 addition & 0 deletions mui.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn create(args &WindowConfig) &Window{
file_handler: args.file_handler
ask_quit: args.ask_quit
quit_fn: args.quit_fn
resized_fn: args.resized_fn
}

mut emoji_font:=args.font
Expand Down
2 changes: 2 additions & 0 deletions types.v
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mut:
file_handler OnEvent = empty_fn
ask_quit bool //= false
quit_fn OnEvent = empty_fn
resized_fn OnEvent = empty_fn
}

pub struct EventDetails{
Expand Down Expand Up @@ -91,6 +92,7 @@ pub mut:
file_handler OnEvent
ask_quit bool
quit_fn OnEvent
resized_fn OnEvent
active_dialog string //= "" //messagebox, input, password, progress, color, date, notification, openfile, savefile, openfolder, custom
dialog_answer string = dialogs_null_answer
dialog_objects []map[string]WindowData // for dialogs
Expand Down

0 comments on commit a6c27ad

Please sign in to comment.