Pixel-Composer/objects/o_dialog_panel/Draw_64.gml

95 lines
3.1 KiB
Text
Raw Normal View History

2023-03-12 02:28:21 +01:00
/// @description
if !ready exit;
#region base UI
var p = ui(8);
var m_in = point_in_rectangle(mouse_mx, mouse_my, dialog_x + p, dialog_y + p, dialog_x + dialog_w - p, dialog_y + dialog_h - p);
var m_ot = point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + dialog_h);
draw_sprite_stretched(THEME.dialog_bg, 0, dialog_x, dialog_y, dialog_w, dialog_h);
#endregion
2023-04-22 16:23:51 +02:00
#region content
2023-03-12 02:28:21 +01:00
if(!is_undefined(content) && content != noone) {
var cx = dialog_x + content.showHeader * padding;
var cy = dialog_y + content.showHeader * (padding + title_height);
content.x = cx;
content.y = cy;
content.onStepBegin();
2023-04-22 16:23:51 +02:00
2023-03-26 07:13:36 +02:00
content.pFOCUS = sFOCUS && m_in;
content.pHOVER = sHOVER && m_in;
2023-03-12 02:28:21 +01:00
panel = surface_verify(panel, dialog_w - content.showHeader * padding * 2,
dialog_h - content.showHeader * (padding * 2 + title_height));
if(!is_surface(mask_surface))
resetMask();
surface_set_target(panel);
2023-03-19 09:17:39 +01:00
DRAW_CLEAR
2023-03-12 02:28:21 +01:00
content.drawContent(panel);
gpu_set_blendmode(bm_subtract);
draw_surface_safe(mask_surface, 0, 0);
gpu_set_blendmode(bm_normal);
surface_reset_target();
2023-04-22 16:23:51 +02:00
content.drawGUI();
2023-03-12 02:28:21 +01:00
draw_surface(panel, cx, cy);
}
#endregion
#region overlay
if(content.showHeader) {
draw_sprite_stretched_ext(THEME.dialog_bg, 0, dialog_x, dialog_y, dialog_w, title_height + ui(8), COLORS._main_icon_light, 1);
draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub);
draw_text_cut(dialog_x + ui(32), dialog_y + ui(8), content.title, dialog_w - ui(32 + 32));
if(instanceof(content) != "Panel_Menu")
2023-04-23 16:47:33 +02:00
if(buttonInstant(THEME.button_hide, dialog_x + dialog_w - ui(28), dialog_y + ui(8), ui(20), ui(20), mouse_ui, sFOCUS, sHOVER, "", THEME.window_exit) == 2) {
onDestroy();
2023-03-12 02:28:21 +01:00
instance_destroy();
2023-04-23 16:47:33 +02:00
}
2023-03-12 02:28:21 +01:00
}
var bx = content.showHeader? dialog_x + ui(8) : dialog_x + ui(24);
var by = content.showHeader? dialog_y + ui(8) : dialog_y + ui(18);
var txt = destroy_on_click_out? get_text("pin", "Pin") : get_text("unpin", "Unpin");
var cc = destroy_on_click_out? COLORS._main_icon : COLORS._main_icon_light;
var ind = !destroy_on_click_out;
var ss = content.showHeader? ui(20) : ui(28);
var sc = content.showHeader? 0.75 : 1;
if(instanceof(content) != "Panel_Menu")
if(buttonInstant(THEME.button_hide, bx, by, ss, ss, mouse_ui, sFOCUS, sHOVER, txt, THEME.pin, ind, cc,, sc) == 2)
destroy_on_click_out = !destroy_on_click_out;
2023-03-28 06:58:28 +02:00
if(sFOCUS) {
2023-03-12 02:28:21 +01:00
draw_sprite_stretched_ext(THEME.dialog_active, 0, dialog_x, dialog_y, dialog_w, dialog_h, COLORS._main_accent, 1);
2023-03-28 06:58:28 +02:00
if(!m_in && m_ot) {
draw_sprite_stretched_ext(THEME.dialog_active, 0, dialog_x, dialog_y, dialog_w, dialog_h, c_white, 0.4);
2023-03-12 02:28:21 +01:00
2023-03-28 06:58:28 +02:00
if(DOUBLE_CLICK) {
content.dragSurface = surface_clone(panel);
o_main.panel_dragging = content;
content.in_dialog = false;
2023-03-12 02:28:21 +01:00
2023-03-28 06:58:28 +02:00
instance_destroy();
} else if(mouse_press(mb_right)) {
2023-05-03 21:42:17 +02:00
menuCall("panel_window_menu",,, [
2023-03-28 06:58:28 +02:00
menuItem("Move", function() {
content.dragSurface = surface_clone(panel);
o_main.panel_dragging = content;
content.in_dialog = false;
panel_mouse = 1;
2023-03-12 02:28:21 +01:00
2023-03-28 06:58:28 +02:00
instance_destroy();
}),
],, content);
2023-03-28 06:58:28 +02:00
}
2023-03-12 02:28:21 +01:00
}
}
#endregion