@@ -168,6 +168,7 @@ pub fn setDefaultRootFolder(path: [:0]const u8) bool {
168168
169169/// Set a custom handler to serve files. This custom handler should
170170/// return full HTTP header and body.
171+ /// This deactivates any previous handler set with `setFileHandlerWindow`.
171172pub fn setFileHandler (self : Self , comptime handler : fn (filename : []const u8 ) ? []const u8 ) void {
172173 const tmp_struct = struct {
173174 fn handle (tmp_filename : [* c ]const u8 , length : [* c ]c_int ) callconv (.C ) ? * const anyopaque {
@@ -184,6 +185,25 @@ pub fn setFileHandler(self: Self, comptime handler: fn (filename: []const u8) ?[
184185 WebUI .webui_set_file_handler (self .window_handle , tmp_struct .handle );
185186}
186187
188+ /// Set a custom handler to serve files. This custom handler should
189+ /// return full HTTP header and body.
190+ /// This deactivates any previous handler set with `setFileHandler`.
191+ pub fn setFileHandlerWindow (self : Self , comptime handler : fn (window_handle : usize , filename : []const u8 ) ? []const u8 ) void {
192+ const tmp_struct = struct {
193+ fn handle (window : usize , tmp_filename : [* c ]const u8 , length : [* c ]c_int ) callconv (.C ) ? * const anyopaque {
194+ const len = str_len (tmp_filename );
195+ const content = handler (window , tmp_filename [0.. len ]);
196+ if (content ) | val | {
197+ length .* = @intCast (val .len );
198+ return @ptrCast (val .ptr );
199+ }
200+
201+ return null ;
202+ }
203+ };
204+ WebUI .webui_set_file_handler_window (self .window_handle , tmp_struct .handle );
205+ }
206+
187207/// Check if the specified window is still running.
188208pub fn isShown (self : Self ) bool {
189209 return WebUI .webui_is_shown (self .window_handle );
@@ -252,6 +272,11 @@ pub fn setSize(self: Self, width: u32, height: u32) void {
252272 WebUI .webui_set_size (self .window_handle , @intCast (width ), @intCast (height ));
253273}
254274
275+ /// Set the window minimum size.
276+ pub fn setMinimumSize (self : Self , width : u32 , height : u32 ) void {
277+ WebUI .webui_set_minimum_size (self .window_handle , @intCast (width ), @intCast (height ));
278+ }
279+
255280/// Set the window position.
256281pub fn setPosition (self : Self , x : u32 , y : u32 ) void {
257282 WebUI .webui_set_position (self .window_handle , @intCast (x ), @intCast (y ));
0 commit comments