2023-03-12 02:28:21 +01:00
|
|
|
/// @description
|
|
|
|
event_inherited();
|
|
|
|
|
|
|
|
#region panel
|
|
|
|
dialog_w = 640;
|
|
|
|
dialog_h = 480;
|
|
|
|
padding = ui(8);
|
|
|
|
title_height = ui(24);
|
|
|
|
dialog_resizable = true;
|
|
|
|
|
|
|
|
panel = surface_create(dialog_w, dialog_h);
|
|
|
|
mask_surface = noone;
|
2023-03-24 09:32:08 +01:00
|
|
|
content = noone;
|
2023-03-12 02:28:21 +01:00
|
|
|
destroy_on_click_out = true;
|
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
function setContent(content) { #region
|
2023-03-12 02:28:21 +01:00
|
|
|
self.content = content;
|
|
|
|
|
|
|
|
if(struct_has(content, "title_height"))
|
|
|
|
title_height = content.title_height;
|
|
|
|
|
|
|
|
dialog_w = content.w + content.showHeader * padding * 2;
|
|
|
|
dialog_h = content.h + content.showHeader * (padding * 2 + title_height);
|
|
|
|
dialog_w_min = content.min_w;
|
|
|
|
dialog_h_min = content.min_h;
|
2023-07-15 20:01:29 +02:00
|
|
|
dialog_resizable = content.resizable;
|
2023-03-12 02:28:21 +01:00
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
content.panel = self;
|
2023-03-12 02:28:21 +01:00
|
|
|
content.in_dialog = true;
|
|
|
|
|
2023-09-08 12:27:22 +02:00
|
|
|
if(content.auto_pin) destroy_on_click_out = false;
|
2023-11-13 05:38:37 +01:00
|
|
|
} #endregion
|
2023-03-12 02:28:21 +01:00
|
|
|
|
2023-12-18 04:40:21 +01:00
|
|
|
function contentResize() { #region
|
|
|
|
dialog_w = content.w + content.showHeader * padding * 2;
|
|
|
|
dialog_h = content.h + content.showHeader * (padding * 2 + title_height);
|
|
|
|
} #endregion
|
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
function resetMask() { #region
|
2023-03-12 02:28:21 +01:00
|
|
|
if(!content) return;
|
|
|
|
mask_surface = surface_verify(mask_surface, dialog_w - content.showHeader * padding * 2,
|
|
|
|
dialog_h - content.showHeader * (padding * 2 + title_height));
|
|
|
|
|
|
|
|
surface_set_target(mask_surface);
|
|
|
|
draw_clear(c_black);
|
|
|
|
gpu_set_blendmode(bm_subtract);
|
|
|
|
draw_sprite_stretched(THEME.ui_panel_bg, 0, 0, 0, dialog_w - content.showHeader * padding * 2,
|
|
|
|
dialog_h - content.showHeader * (padding * 2 + title_height));
|
|
|
|
gpu_set_blendmode(bm_normal);
|
|
|
|
surface_reset_target();
|
2023-11-13 05:38:37 +01:00
|
|
|
} resetMask(); #endregion
|
2023-03-12 02:28:21 +01:00
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
onResize = function() { #region
|
2023-03-12 02:28:21 +01:00
|
|
|
panel = surface_verify(panel, dialog_w, dialog_h);
|
|
|
|
resetMask();
|
|
|
|
|
|
|
|
if(content) {
|
|
|
|
content.w = dialog_w - content.showHeader * padding * 2;
|
|
|
|
content.h = dialog_h - content.showHeader * (padding * 2 + title_height);
|
|
|
|
|
|
|
|
content.onResize();
|
|
|
|
}
|
2023-11-13 05:38:37 +01:00
|
|
|
} #endregion
|
2023-04-23 16:47:33 +02:00
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
function checkClosable() { #region
|
2023-09-15 20:12:02 +02:00
|
|
|
if(!content) return true;
|
|
|
|
return content.checkClosable();
|
2023-11-13 05:38:37 +01:00
|
|
|
} #endregion
|
2023-09-15 20:12:02 +02:00
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
function onDestroy() { #region
|
2023-11-03 14:43:28 +01:00
|
|
|
if(content == noone) return;
|
2023-04-23 16:47:33 +02:00
|
|
|
content.onClose();
|
2023-11-13 05:38:37 +01:00
|
|
|
} #endregion
|
2023-08-29 14:33:44 +02:00
|
|
|
|
2023-11-13 05:38:37 +01:00
|
|
|
function remove() { #region
|
2023-08-29 14:33:44 +02:00
|
|
|
instance_destroy();
|
2023-11-13 05:38:37 +01:00
|
|
|
} #endregion
|
2024-03-27 11:51:14 +01:00
|
|
|
|
|
|
|
function onFocusBegin() { if(content) content.onFocusBegin(); }
|
|
|
|
function onFocusEnd() { if(content) content.onFocusEnd(); }
|
2023-03-12 02:28:21 +01:00
|
|
|
#endregion
|