From a6c27ade8ac6fb131a079c5cdd7983ced0fd18f3 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Date: Fri, 2 Dec 2022 19:06:22 +0300 Subject: [PATCH] Add resize event --- events.v | 1 + examples/resize_event.v | 9 +++++++++ mui.v | 1 + types.v | 2 ++ 4 files changed, 13 insertions(+) create mode 100644 examples/resize_event.v diff --git a/events.v b/events.v index b4ef382..5a4c7c3 100644 --- a/events.v +++ b/events.v @@ -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 } diff --git a/examples/resize_event.v b/examples/resize_event.v new file mode 100644 index 0000000..5170433 --- /dev/null +++ b/examples/resize_event.v @@ -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() diff --git a/mui.v b/mui.v index 9ac48a5..e5670fd 100644 --- a/mui.v +++ b/mui.v @@ -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 diff --git a/types.v b/types.v index 8d28d6a..727b63e 100644 --- a/types.v +++ b/types.v @@ -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{ @@ -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